home-hosted 0.6.2 → 0.6.3

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,11 +36,11 @@ 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=>Sx(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:K.intrinsic.object;if(e.domain!==t.domain){let n=e.domain===`undefined`||e.domain===`null`||e.domain===`boolean`?e.domain:K.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=Sx(this.unit);domain=Ky(this.unit);get defaultShortDescription(){return this.domain===`object`?qy.object:this.description}innerToJsonSchema(e){return this.unit===null?{type:`null`}:K.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(K.intrinsic.key))return G(qw(n.expression));let r=n.branches.filter(e=>e.hasKind(`unit`));return r.length?G(Kw(r.map(e=>Sx(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?K.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=K.intrinsic.object.internal;expression=`[${this.signature.expression}]: ${this.value.expression}`;flatRefs=zy(this.value.flatRefs.map(e=>jS([this.signature,...e.path],e.node)),jS([this.signature],this.value));traverseAllows=(e,t)=>ub(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 ub(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 G(rT);if(e.optionals?.length||e.defaultables?.length)return G(nT)}return e.minVariadicLength&&!e.variadic?G(`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} = ${Sx(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=K.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=By(this.variadic&&[this.variadic],this.postfix);flatRefs=this.addFlatRefs();addFlatRefs(){return NS(this.flatRefs,this.prevariadic.flatMap((e,t)=>zy(e.node.flatRefs.map(e=>jS([`${t}`,...e.path],e.node)),jS([`${t}`],e.node)))),NS(this.flatRefs,this.variadicOrPostfix.flatMap(e=>zy(e.flatRefs.map(e=>jS([K.intrinsic.nonNegativeIntegerString.internal,...e.path],e.node)),jS([K.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?Bx(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??Xy(`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(K.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=K.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=zy(e.defaultables,[[t.node,t.default]]):e[t.kind]=zy(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:K.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&&G(GC(t.default,r.default)),e.result=[...e.result,{kind:s,node:c,default:t.kind===`defaultables`?t.default:r.kind===`defaultables`?r.default:Xy(`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:K.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=zy(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]=zy(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`,K.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=By(i.required,a.required)),a.optional&&(i.optional=By(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,K.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=By(r.required,a.required)),a.optional&&(r.optional=By(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&&G(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&&G(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=K.intrinsic.object.internal;impliedSiblings=this.children.flatMap(e=>e.impliedSiblings??[]);props=By(this.required,this.optional);propsByKey=eb(this.props,(e,t)=>[t.key,t]);propsByKeyReference=Bx(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`?G(`Map result must have kind "required" or "optional" (was ${t.kind})`):(e[t.kind]=zy(e[t.kind],t),e);let r=t.kind??n?.kind??`required`,i=eb(t,(e,t)=>e in KC.implementation.keys?[e,t]:[]);return e[r]=zy(e[r],this.$.node(r,i)),e},{}))}assertHasKeys(e){let t=e.filter(e=>!iw(e,this.keyof()));if(t.length)return G(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,K.intrinsic.nonNegativeIntegerString)){if(q(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&&q(i,`root`)&&i.extends(K.intrinsic.number)?G(vT(i.expression,this.sequence.expression)):G(xT(this.expression,[i]));let a=n.get(...t);return r?a:a.or(K.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=zy(t.required,e.required)),e.optional&&(t.optional=zy(t.optional,e.optional)),e.index&&(t.index=zy(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=qx(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&&K.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&&Bx(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=K.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(K.intrinsic.string)){e.additionalProperties=r;continue}for(let i of n.signature.branches){if(!i.extends(K.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 Xy(`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=>(q(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]=Fy(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]=zy(a[r.kind],r)}return i.length&&(a.index=n.node(`index`,{signature:i,value:t})),a},bT=e=>q(e,`root`)?e.expression:Sx(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 ${Hx(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};K.defaultConfig=fb(Object.assign(eb(CT,(e,t)=>[e,t.defaults]),{jitless:Fb(),clone:kb,onUndeclaredKey:`ignore`,exactOptionalPropertyTypes:!0,numberAllowsNaN:!1,dateAllowsInvalid:!1,onFail:null,keywords:{},toJsonSchema:fS.defaultConfig})),K.resolvedConfig=pS(K.defaultConfig,K.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 ib{get[Jx](){return`module`}},ET=(e,t)=>new TT(eb(e,(e,n)=>[e,q(n,`module`)?ET(n,t):t.bindReference(n)])),DT=e=>Sb(e)?e:`branches`in e&&Sb(e.branches)?e.branches:void 0,OT=(e,t)=>G(`Node of kind ${t} is not valid as a ${e} definition`),kT=e=>`#${e} duplicates public alias ${e}`,AT={};K.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 Vx().return(e.reduce((e,t)=>{let n=new Kx({kind:`Allows`}).indent();t.compile(n);let r=n.write(`${t.id}Allows`),i=new Kx({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 Kx({kind:`Allows`,optimistic:!0}).indent();return t.compile(o),`${a}${o.write(`${t.id}Optimistic`)},\n`},`{
38
38
  `)+`}`),IT=class{config;resolvedConfig;name;get[Jx](){return`scope`}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor(e,t){this.config=pS(K.config,t),this.resolvedConfig=pS(K.resolvedConfig,t),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(AT).length}`,this.name in AT&&G(`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&&G(kT(n)),this.aliases[n]=t):(n in this.aliases&&G(kT(e)),this.aliases[n]=t,this.exportedNames.push(n)),!q(t,`module`)&&!q(t,`generic`)&&!Mb(t)){let e=this.preparseOwnDefinitionFormat(t,{alias:n});this.resolutions[n]=q(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=K.intrinsic?eb(K.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`&&Gy(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)??G(WT(e))}maybeResolveRoot(e){let t=this.maybeResolve(e);if(!q(t,`generic`))return t}maybeResolveSubalias(e){return BT(this.aliases,e)??BT(this.ambient,e)}get ambient(){return K.ambient}maybeResolve(e){let t=this.resolutions[e];if(t){if(typeof t!=`string`)return this.bindReference(t);let n=IC[t];if(q(n,`root`))return this.resolutions[e]=n;if(q(n,`context`)){if(n.phase===`resolving`)return this.node(`alias`,{reference:`$${e}`},{prereduced:!0});if(n.phase===`resolved`)return Xy(`Unexpected resolved context for was uncached by its scope: ${Sx(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 Xy(`Unexpected nodesById entry for ${t}: ${Sx(n)}`)}let n=this.aliases[e]??this.ambient?.[e];return n?(n=this.normalizeRootScopeValue(n),q(n,`generic`)?this.resolutions[e]=this.bindReference(n):q(n,`module`)?(n.root||G(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,{[Jx]:`context`,$:this,id:t,phase:`unresolved`})}traversal(e){return new CS(e,this.resolvedConfig)}import(...e){return new TT(eb(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]=q(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(eb(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(q(e,`root`))return this.bindReference(e);let n=this.preparseOwnDefinitionFormat(e,t);if(q(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=>eb(e,(e,t)=>[e,q(t,`root`)||q(t,`generic`)?t.json:q(t,`module`)?zT(t):Xy(`Unexpected resolution ${Sx(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(!q(i,`module`))return G(GT(r));let a=t.slice(n+1),o=i[a];if(o===void 0)return BT(i,a);if(q(o,`root`)||q(o,`generic`))return o;if(q(o,`module`))return o.root??G(KT(t));Xy(`Unexpected resolution for alias '${t}': ${Sx(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(q(i,`module`)){let t=eb(UT(e,i),(e,t)=>[`${r}.${e}`,t]);Object.assign(n,t)}else q(i,`root`)||q(i,`generic`)?n[r]=i:Xy(`Unexpected scope resolution ${Sx(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*)$`;Bx(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();K.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(K.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})};K.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=lx(e);if(r!==void 0){let e=new Date(r);if(rE(e))return e}return t?G(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){G(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(nb(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,...Ub},SE=(e,t)=>e===`>`?t[0]===`=`?t[1]===`=`:t.trimStart()===``||nb(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(Fx(`>`))},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(q(n,`root`))return n;if(n!==void 0)return q(n,`generic`)?DE(t,n,e):G(`Unexpected resolution ${Sx(n)}`)},AE=(e,t)=>{let n=ux(t);if(n!==void 0)return e.ctx.$.node(`unit`,{unit:n});let r=px(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(Ub)?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(K.intrinsic.number)?typeof t==`number`?e===`==`?[`min`,`max`]:e[0]===`>`?[`min`]:[`max`]:G(qE(e,t,r)):n.extends(K.intrinsic.lengthBoundable)?typeof t==`number`?e===`==`?[`exactLength`]:e[0]===`>`?[`minLength`]:[`maxLength`]:G(qE(e,t,r)):n.extends(K.intrinsic.Date)?e===`==`?[`after`,`before`]:e[0]===`>`?[`after`]:[`before`]:G(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(!nb(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=dx(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):nb(t,HE)?VE(e,t):t===`%`?YE(e):t===`#`?JE(e):t in Ub?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 Nx(e),t),i=rD(r);return r.finalizer===`>`&&G(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&&G(QE(e.scanner.lookahead)),t):Xy(`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 G(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(Fx(`)`));this.finalizeBranches(),this.finalizer=e}reduceLeftBound(e,t){let n=LE[t];if(!nb(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(Px(`)`,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():Xy(`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:G(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 Pb{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 G(pD);o=e.parse(t[n+1])}return e=>new fD(e,a,o)};super(t,{attach:{$:e,raw:t}})}},fD=class extends Pb{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 Pb{$;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 Pb{$;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&&G(vD),this.branches.length&&G(_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&&G(`default may only be specified as the last key of a switch definition`),this.default(r);if(typeof r!=`function`)return G(`Value for case "${n}" must be a function (was ${Ky(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(Sb(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=ub(e);for(let[e,a]of i){let i=ED(e);if(i.kind===`spread`){if(!lb(r))return G(TD);let e=t.$.parseOwnDefinitionFormat(a,t);if(e.equals(eE.object))continue;if(!e.hasKind(`intersection`)||!e.basis?.equals(eE.object))return G(DD(e.expression));n=e.structure;continue}if(i.kind===`undeclared`){a!==`reject`&&a!==`delete`&&a!==`ignore`&&G(wD(a)),r.undeclared=a;continue}let o=yD(a,t),s=i;if(i.kind===`required`){Sb(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(Sb(o)&&(o[1]===`?`&&G(bD),o[1]===`=`&&G(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=zy(r.index,c.index)),c.required&&(r.required=zy(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]=zy(e[t],r.$.node(t,n))},wD=e=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${Sx(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 G(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]):G(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]):G(ND(`:`,e[2])),FD=(e,t)=>t.$.parseOwnDefinitionFormat(e[0],t).configure(e[2],e[3]),ID=e=>e,LD=ID({"[]":jD,"?":()=>G(yE)}),RD=ID({"|":AD,"&":AD,":":PD,"=>":MD,"|>":AD,"@":FD,"=":()=>G(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 G(UD(xb(e[1])));let n=e.slice(1).map(e=>typeof e==`function`?t.$.node(`proto`,{proto:e}):G(UD(xb(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]=Sb(a)?a:[a];if(r++,i){if(!o.extends(K.intrinsic.Array))return G(XD(o.expression));n=n.flatMap(e=>o.distribute(t=>YD(qx(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=>lb(e)?{proto:Array,exactLength:0}:{proto:Array,sequence:e}))},GD=(e,t)=>e.defaultables||e.optionals?G(e.variadic?nT:QD):(e.variadic?e.postfix=zy(e.postfix,t):e.prefix=zy(e.prefix,t),e),KD=(e,t)=>e.variadic?G($D):(e.optionals=zy(e.optionals,t),e),qD=(e,t,n)=>e.variadic?G($D):e.optionals?G(eO):(e.defaultables=zy(e.defaultables,[[t,n]]),e),JD=(e,t)=>(e.postfix&&G(ZD),e.variadic?e.variadic.equals(t)||G(ZD):e.variadic=t.internal,e),YD=(e,t)=>{let n=t.select({method:`find`,kind:`sequence`});if(!n)return JD(e,K.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 Gy(e,`object`)?rO(e,t):G(oO(Ky(e)))},rO=(e,t)=>{let n=bb(e);switch(n){case void 0:return q(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=Mb(e)?e():e;return q(t,`root`)?t:G(oO(`Function`))}default:return G(oO(n??Sx(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:zb(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 Pb{constructor(e){let t=Object.assign({errors:bS,hkt:Ib,$: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=K,lO=class e extends IT{get ambientAttachments(){if(cO.typeAttachments)return this.cacheGetter(`ambientAttachments`,eb(cO.typeAttachments,(e,t)=>[e,this.bindReference(t)]))}preparseOwnAliasEntry(e,t){let n=e.indexOf(`<`);if(n===-1){if(q(t,`module`)||q(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]!==`>`&&G(`'>' 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 Nx(e),[],this.createParseContext({...t,def:e,prefix:`generic`}))}normalizeRootScopeValue(e){return Mb(e)&&!q(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(Sb(n)){if(n[1]===`=`)return G(bE);if(n[1]===`?`)return G(yE)}return n}unit=e=>this.units([e]);valueOf=e=>this.units(mb(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 Ib{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 Ib{},gO=YT(`element`)(e=>{let t=e.element.exclude(eE.Array),n=t.array();return t.rawOr(n).pipe(Py).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`,mx.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 mx.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({...eb({...hb,..._b},(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(ex,`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=eb(tk,(e,t)=>[t,qT({domain:`string`,predicate:e=>e.normalize(t)===e,meta:`${t}-normalized unicode`})]),rk=eb(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(Zb,`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 Ib{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 Ib{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 Ib{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 Ib{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 Ib{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 Ib{description='exclude branches of a union like `Exclude("boolean", "true")`'},Lk=YT(`T`,`U`)(e=>e.T.exclude(e.U),Ik),Rk=class extends Ib{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.enumerated(`block`,`warn`,`follow`,`reclaim`,`kill`),qk=Kk.default(`block`),Jk=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`),Yk=Y({path:`string = "/"`,method:`"GET" | "HEAD" = "GET"`,expectStatus:`number.integer | null?`,expectStatusBelow:`number.integer = 400`,expectBody:`string = ""`}).onUndeclaredKey(`reject`),Xk=Y({maxRssBytes:`number.integer >= 0 = 0`}).onUndeclaredKey(`reject`),Zk=Y({enabled:`boolean = true`,mode:`"port" | "http" = "port"`,http:Yk.default(()=>({})),intervalMs:`number >= 500 = 5000`,timeoutMs:`number >= 100 = 1500`,unhealthyThreshold:`number.integer >= 1 = 3`,forceRestartAfterMs:`number >= 0 = 0`,startTimeoutMs:`number >= 0 = 20000`}).onUndeclaredKey(`reject`),Qk=Y({signal:`"SIGTERM" | "SIGINT" | "SIGKILL" = "SIGTERM"`,killGroup:`boolean = true`,graceMs:`number >= 0 = 5000`,killPortHolders:`boolean = false`}).onUndeclaredKey(`reject`),$k=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`)),eA=Y(`50 <= number.integer <= 100000`),tA=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:$k.optional(),port:Gk.optional(),bind:Uk.default(()=>`local`),onPortConflict:qk,restart:Jk.default(()=>({})),health:Zk.default(()=>({})),stop:Qk.default(()=>({})),logBufferLines:eA.default(()=>500),dependsOn:Y(`string[]`).default(()=>[]),envFile:`string = ""`,resources:Xk.default(()=>({})),backupPaths:Y(`string[]`).default(()=>[]),backupIgnoreGenerated:`boolean = true`}).onUndeclaredKey(`reject`),nA=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 rA=Y({persist:`boolean = true`,maxBytes:`10000 <= number <= 100000000 = 2000000`,keep:`1 <= number.integer <= 10 = 3`}).onUndeclaredKey(`reject`),iA=Y({enabled:`boolean = false`}).onUndeclaredKey(`reject`),aA=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:nA.default(()=>({})),tls:iA.default(()=>({}))}).onUndeclaredKey(`reject`);var oA=Y({enabled:`boolean = true`,autostart:`boolean = false`,bind:Uk.default(()=>`local`),onPortConflict:qk,restart:Jk.default(()=>({})),health:Zk.default(()=>({})),stop:Qk.default(()=>({})),logBufferLines:eA.default(()=>500)}).onUndeclaredKey(`reject`),sA=Y({enabled:`boolean?`,maxRetries:`number.integer >= 0?`,baseDelayMs:`number >= 0?`,factor:`number >= 1?`,maxDelayMs:`number >= 0?`,resetAfterMs:`number >= 0?`}).onUndeclaredKey(`reject`),cA=Y({path:`string?`,method:`"GET" | "HEAD"?`,expectStatus:`number.integer | null?`,expectStatusBelow:`number.integer?`,expectBody:`string?`}).onUndeclaredKey(`reject`),lA=Y({maxRssBytes:`number.integer >= 0?`}).onUndeclaredKey(`reject`),uA=Y({enabled:`boolean?`,mode:`"port" | "http"?`,http:cA.optional(),intervalMs:`number >= 500?`,timeoutMs:`number >= 100?`,unhealthyThreshold:`number.integer >= 1?`,forceRestartAfterMs:`number >= 0?`,startTimeoutMs:`number >= 0?`}).onUndeclaredKey(`reject`),dA=Y({signal:`"SIGTERM" | "SIGINT" | "SIGKILL"?`,killGroup:`boolean?`,graceMs:`number >= 0?`,killPortHolders:`boolean?`}).onUndeclaredKey(`reject`),fA=Y({enabled:`boolean?`,sessionTtlMs:`number >= 60000?`,cookieSecure:`"auto" | "always" | "never"?`,trustProxy:`boolean?`,maxLoginAttempts:`number.integer >= 1?`,lockoutMs:`number >= 1000?`}).onUndeclaredKey(`reject`),pA=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`),mA=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`),hA=Y({enabled:`boolean?`,dir:`string?`,keep:`number.integer >= 1?`,includePaths:Y(`string[]`).optional()}).onUndeclaredKey(`reject`),gA=Y({persist:`boolean?`,maxBytes:`10000 <= number <= 100000000?`,keep:`1 <= number.integer <= 10?`}).onUndeclaredKey(`reject`),_A=Y({enabled:`boolean?`}).onUndeclaredKey(`reject`),vA=Y({label:`1 <= string <= 60?`,port:`1 <= number.integer <= 65535?`,host:Uk.optional(),openBrowser:`boolean?`,auth:fA.optional(),tls:_A.optional()}).onUndeclaredKey(`reject`),yA=Y({enabled:`boolean?`,autostart:`boolean?`,bind:Uk.optional(),onPortConflict:Kk.optional(),restart:sA.optional(),health:uA.optional(),stop:dA.optional(),logBufferLines:eA.optional()}).onUndeclaredKey(`reject`),bA={label:`string?`,enabled:`boolean?`,autostart:`boolean?`,command:`string?`,args:`string[]?`,cwd:`string?`,env:`Record<string, string>?`,dataEnvs:`Record<string, string>?`,bootstrap:$k.optional(),port:Gk.optional(),bind:Uk.optional(),onPortConflict:Kk.optional(),restart:sA.optional(),health:uA.optional(),stop:dA.optional(),logBufferLines:eA.optional(),dependsOn:Y(`string[]`).optional(),envFile:`string?`,resources:lA.optional(),backupPaths:Y(`string[]`).optional(),backupIgnoreGenerated:`boolean?`},xA=Y(bA).onUndeclaredKey(`reject`),SA=Y({id:`/^[a-z0-9][a-z0-9_-]*$/`,...bA,command:`string`}).onUndeclaredKey(`reject`),CA=Y({control:vA.optional(),defaults:yA.optional(),logs:gA.optional(),notifications:pA.optional(),host:mA.optional(),backups:hA.optional()}).onUndeclaredKey(`reject`),wA=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`}),TA=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`}),EA=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 DA=Y({password:`string`}).onUndeclaredKey(`reject`),OA=Y(`1 <= string <= 512`),kA=Y({currentPassword:`string?`,newPassword:OA}).onUndeclaredKey(`reject`),AA=Y(`"stopped" | "starting" | "running" | "stopping" | "backoff" | "crashed" | "conflict"`),jA=Y(`"disabled" | "unknown" | "healthy" | "unhealthy"`),MA=Y(`"unknown" | "free" | "in-use"`),NA=Y({ts:`number`,stream:Y(`"stdout" | "stderr" | "system"`),text:`string`}),PA=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()}),FA=Y({cpuPercent:`number | null`,rssBytes:`number | null`,processes:`number`,sampledAt:`number`}),IA=Y({path:`string`,totalBytes:`number`,freeBytes:`number`,usedPercent:`number`}),LA=Y({enabled:`boolean`,cpus:`number`,loadAvg:Y(`number[]`),uptimeMs:`number`,memoryUsedPercent:`number`,swapUsedPercent:`number`,tempCelsius:`number | null`,disks:IA.array(),alerts:Y(`string[]`),sampledAt:`number | null`}),RA=Y({name:`string`,sizeBytes:`number`,createdAt:`number`,encrypted:`boolean`}),zA=Y({path:`string`,origin:`string`,included:`boolean`,note:`string | null`,ignoreGenerated:`boolean?`}),BA=Y({enabled:`boolean`,dir:`string`,keep:`number`,includePaths:Y(`string[]`),paths:zA.array(),files:RA.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:OA.optional()}).onUndeclaredKey(`reject`),Y({name:`string?`,password:OA.optional(),include:Y(`string[]`).optional()}).onUndeclaredKey(`reject`);var VA=Y({id:`string`,config:tA,bindHost:`string`,url:`string | null`,status:AA,health:jA,portState:MA,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:PA,responseMs:`number | null`,resources:FA.or(Y(`null`))}),HA=Y({label:`string`,port:`number`,host:`string`,bindHost:`string`,url:`string`,openBrowser:`boolean`,restartRequired:`boolean`,protocol:`string`,auth:wA,tls:TA}),UA=Y({control:HA,defaults:oA,logs:rA,notifications:EA,host:LA,backups:BA,configPath:`string`,configError:`string | null`,projectDir:`string`,dataRoot:`string`,logsDir:`string`,servers:VA.array()}),WA=Y({type:`"hello" | "state" | "log" | "server"`,ts:`number`,serverId:`string?`,state:UA.optional(),server:VA.optional(),lines:NA.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 GA=Y({servers:Y({serverId:`string`,label:`string`,status:AA,enabled:`boolean`,sizeBytes:`number`,files:Y({name:`string`,sizeBytes:`number`}).array()}).array()}),KA=Y({serverId:`string`,enabled:`boolean`,sizeBytes:`number`,files:Y(`string[]`),searched:`number | null`,lines:NA.array()});Y({botToken:`string?`,chatId:`string?`}).onUndeclaredKey(`reject`),Y({botToken:`string >= 1`}).onUndeclaredKey(`reject`),Y({message:`string`,code:`string`,detail:`unknown`}).onUndeclaredKey(`reject`);var qA=Y({custom:`boolean`,dir:`string`,meta:Y({"name?":`string`,"version?":`string | null`,"uploadedAt?":`number`,"files?":`number.integer >= 1`,"repo?":`string`,"tag?":`string`,"asset?":`string`,"unix?":`number.integer >= 0`}).or(Y(`null`))});Y({certificate:`string >= 1`,privateKey:`string >= 1`}).onUndeclaredKey(`reject`),Y({control:HA,defaults:oA,logs:rA,notifications:EA,host:aA,backups:BA,ui:qA}).and(Y({rebinding:`boolean`,targetUrl:`string | null`}));var JA=/^[\w!#$%&'*.^`|~+-]+$/,YA=(e,t,n={})=>{if(!JA.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},XA=(e,t,n)=>(t=encodeURIComponent(t),YA(e,t,n)),ZA=(e,t)=>(e=e.replace(/\/+$/,``),e+=`/`,t=t.replace(/^\/+/,``),e+t),QA=(e,t)=>{for(let[n,r]of Object.entries(t)){let t=RegExp(`/:`+n+`(?:{[^/]+})?\\??(?=/|$)`);e=e.replace(t,()=>r?`/${r}`:``)}return e},$A=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},ej=(e,t)=>{switch(t){case`ws`:return e.replace(/^http/,`ws`);case`http`:return e.replace(/^ws/,`http`)}},tj=e=>/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(e)?e.replace(/\/index(?=\?|$)/,`/`):e.replace(/\/index(?=\?|$)/,``);function nj(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rj(e,t){if(!nj(e)&&!nj(t))return t;let n={...e};for(let e in t){let r=t[e];n[e]=nj(n[e])&&nj(r)?rj(n[e],r):r}return n}var ij=(e,t)=>new Proxy(()=>{},{get(n,r){if(typeof r==`string`&&r!==`then`)return ij(e,[...t,r])},apply(n,r,i){return e({path:t,args:i})}}),aj=(e,t)=>{let n=t.toString();return n?`${e}?${n}`:e},oj=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(XA(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=tj(a),a=QA(a,this.pathParams),this.queryParams&&(a=aj(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})}},sj=((e,t)=>ij(function n(r){let i=t?.buildSearchParams??$A,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=ZA(e,a.join(`/`));if(s===`url`||s===`path`){let t=tj(c);return r.args[0]&&(r.args[0].param&&(t=QA(t,r.args[0].param)),r.args[0].query&&(t=aj(t,i(r.args[0].query)))),s===`url`?new URL(t):t.slice(e.replace(/\/+$/,``).length).replace(/^\/?/,`/`)}if(s===`ws`){let e=tj(c),n=ej(r.args[0]?.param?QA(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 oj(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=rj(t,e);return l.fetch(r.args[0],a)}return l},[]))(typeof window>`u`?`http://127.0.0.1`:window.location.origin),cj=class extends Error{name=`AuthRequiredError`;constructor(){super(`authentication required`)}};function lj(e){return typeof e==`object`&&!!e}async function uj(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&&lj(i)&&i.code===`AUTH_REQUIRED`)throw new cj;let e=lj(i)&&typeof i.message==`string`?i.message:lj(i)&&`error`in i?String(i.error):`request failed with ${n.status}`;throw Error(e)}return i}async function dj(){let e=UA(await uj(`/api/state`));if(e instanceof Y.errors)throw Error(`state contract mismatch: ${e.summary}`);return e}function fj(){return uj(`/api/auth/session`)}function pj(e){let t=DA({password:e});if(t instanceof Y.errors)throw Error(t.summary);return uj(`/api/auth/login`,{method:`POST`,body:JSON.stringify(t)})}function mj(){return uj(`/api/auth/logout`,{method:`POST`})}function hj(e,t){let n=kA(e===void 0?{newPassword:t}:{currentPassword:e,newPassword:t});if(n instanceof Y.errors)throw Error(n.summary);return uj(`/api/auth/password`,{method:`POST`,body:JSON.stringify(n)})}function gj(){return uj(`/api/auth/password`,{method:`DELETE`})}function _j(){return uj(`/api/settings`)}function vj(e){let t=CA(e);if(t instanceof Y.errors)throw Error(t.summary);return uj(`/api/settings`,{method:`PATCH`,body:JSON.stringify(t)})}async function yj(){let e=GA(await uj(`/api/logs`));if(e instanceof Y.errors)throw Error(`logs contract mismatch: ${e.summary}`);return e.servers}async function bj(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=KA(await uj(`/api/logs/${encodeURIComponent(e)}?${n.toString()}`));if(r instanceof Y.errors)throw Error(`log history contract mismatch: ${r.summary}`);return r}function xj(e){return uj(`/api/logs/${encodeURIComponent(e)}`,{method:`DELETE`})}function Sj(e,t){return`/api/logs/${encodeURIComponent(e)}/download?file=${encodeURIComponent(t)}`}function Cj(e){return uj(`/api/backups`,{method:`POST`,body:JSON.stringify(e===void 0||e.length===0?{}:{password:e})})}function wj(e){return uj(`/api/backups/${encodeURIComponent(e)}`,{method:`DELETE`})}function Tj(e){return`/api/backups/${encodeURIComponent(e)}/download`}function Ej(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 Dj(e,t,n={}){return uj(`/api/backups/restore?confirm=${t}`,{method:`POST`,body:JSON.stringify({name:e,...Ej(n)})})}async function Oj(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 kj(e){return uj(`/api/notifications/token`,{method:`PUT`,body:JSON.stringify({botToken:e})})}function Aj(){return uj(`/api/notifications/token`,{method:`DELETE`})}function jj(e){return uj(`/api/notifications/test`,{method:`POST`,body:JSON.stringify(e)})}function Mj(e){return uj(`/api/notifications/detect-chats`,{method:`POST`,body:JSON.stringify(e)})}async function Nj(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 Pj(){return uj(`/api/settings/ui`,{method:`DELETE`})}function Fj(e,t){return uj(`/api/settings/tls`,{method:`POST`,body:JSON.stringify({certificate:e,privateKey:t})})}function Ij(){return uj(`/api/settings/tls`,{method:`DELETE`})}async function Lj(e,t){let n=await sj.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 Rj(){return uj(`/api/servers/start-all`,{method:`POST`})}async function zj(e){let t=await sj.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 Bj(){return uj(`/api/servers/stop-all`,{method:`POST`})}function Vj(e){return uj(`/api/servers/${encodeURIComponent(e)}/clear-logs`,{method:`POST`})}function Hj(e,t){return uj(`/api/servers/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)})}function Uj(e){return uj(`/api/servers/${encodeURIComponent(e)}`,{method:`DELETE`})}function Wj(e){return uj(`/api/servers`,{method:`POST`,body:JSON.stringify(e)})}var Gj=A(null),Kj=A(null);function qj(e){return e===null?`wait`:e.authRequired&&!e.authenticated?`login`:`connect`}function Jj(){async function e(){try{Gj.value=await fj()}catch{Gj.value=null}}async function t(e){Kj.value=null;try{return Gj.value=await pj(e),!0}catch(e){return Kj.value=e instanceof Error?e.message:String(e),!1}}async function n(){try{await mj()}finally{await e()}}function r(){Gj.value={authenticated:!1,authRequired:!0,passwordSet:Gj.value?.passwordSet??!0,apiTokenSet:Gj.value?.apiTokenSet??!1,usingDefaultPassword:Gj.value?.usingDefaultPassword??!1,defaultPassword:Gj.value?.defaultPassword??null,sessionTtlMs:Gj.value?.sessionTtlMs??0}}async function i(t,n){Kj.value=null;try{return await hj(t,n),await e(),null}catch(e){return e instanceof Error?e.message:String(e)}}async function a(){Kj.value=null;try{return await gj(),await e(),null}catch(e){return e instanceof Error?e.message:String(e)}}return{session:rn(Gj),error:rn(Kj),refresh:e,login:t,logout:n,requireLogin:r,setPassword:i,clearPassword:a}}var Yj=A([]),Xj=1;function Zj(e){Yj.value=Yj.value.filter(t=>t.id!==e)}function Qj(e,t=4800){let n=Xj++;return Yj.value=[...Yj.value,{...e,id:n}],t>0&&setTimeout(Zj,t,n),n}function $j(){return{toasts:rn(Yj),dismiss:Zj,push:Qj,success:(e,t)=>Qj({tone:`ok`,title:e,description:t}),failure:(e,t)=>Qj({tone:`danger`,title:e,description:t},9e3),info:(e,t)=>Qj({tone:`info`,title:e,description:t}),warn:(e,t)=>Qj({tone:`warn`,title:e,description:t},7e3)}}var eM=4e3;function tM(){return tn({ts:[],cpu:[],rss:[],probe:[],lastSampledAt:-1})}function nM(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 rM(e,t,n){let r=t.resources?.sampledAt??0,i=e.ts[e.ts.length-1]??0;if(!(r!==e.lastSampledAt||n-i>=eM)){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),nM(e)}function iM(e){let t=0;for(let n of e)n!==null&&n>t&&(t=n);return t}function aM(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n!=null)return n}return null}var oM=8e3,sM=A(null),cM=A(`connecting`),lM=A(null),uM=A(Date.now()),dM=new Map,fM=$j(),pM=new Map,mM=A(0),hM=null,gM=null;function _M(e){let t=pM.get(e);if(t)return t;let n={lines:[],version:A(0),refs:0,source:null};return pM.set(e,n),n}function vM(e,t){let n=_M(e),r=n.lines.concat(t);n.lines=r.length>8e3?r.slice(r.length-oM):r,n.version.value+=1,mM.value+=1}function yM(e){return pM.get(e)?.lines??[]}function bM(e){let t=pM.get(e);t&&(t.lines=[],t.version.value+=1,mM.value+=1)}function xM(e){let t=dM.get(e);if(t)return t;let n=tM();return dM.set(e,n),n}function SM(e){rM(xM(e.id),e,Date.now())}function CM(e){let t=sM.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 wM(e){let t;try{t=JSON.parse(e)}catch{return}let n=WA(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){sM.value=n.state;for(let e of sM.value.servers)SM(e)}return}if(n.type===`server`&&n.server){let e=n.server;CM(e),SM(e);return}n.type===`log`&&n.serverId&&n.lines&&vM(n.serverId,n.lines)}function TM(e,t){let n=new EventSource(`/api/servers/${encodeURIComponent(e)}/stream`),r=e=>wM(e.data);for(let e of[`log`,`server`])n.addEventListener(e,r);n.onerror=()=>{},t.source=n}function EM(e){let t=_M(e);t.refs+=1,t.source||TM(e,t)}function DM(e){let t=pM.get(e);t&&(t.refs=Math.max(0,t.refs-1),t.refs===0&&(t.source?.close(),t.source=null))}function OM(){if(hM)return;gM??=setInterval(()=>{uM.value=Date.now()},1e3);let e=new EventSource(`/api/events?logs=0`);hM=e,cM.value=`connecting`,e.onopen=()=>{cM.value=`open`},e.onerror=()=>{cM.value=`closed`};for(let t of[`hello`,`state`,`server`,`log`])e.addEventListener(t,e=>{wM(e.data)})}function kM(){hM?.close(),hM=null,gM&&clearInterval(gM),gM=null}function AM(e){let t=U(()=>yn(e)),n=null;return jr(t,e=>{n!==null&&n!==e&&DM(n),n=e,e!==null&&e.length>0&&EM(e)},{immediate:!0}),Be(()=>{n!==null&&DM(n),n=null}),{version:U(()=>{let e=t.value;return mM.value,e===null?0:pM.get(e)?.version.value??0}),lines(){let e=t.value;return e===null?[]:yM(e)},count:U(()=>{let e=t.value;return mM.value,e===null?0:pM.get(e)?.lines.length??0}),clear(){let e=t.value;e!==null&&bM(e)}}}function jM(){let e=U(()=>sM.value?.servers??[]),t=U(()=>sM.value?.control??null),n=U(()=>sM.value?.defaults??null),r=U(()=>sM.value?.host??null),i=U(()=>sM.value?.backups??null),a=U(()=>sM.value?.notifications??null),o=U(()=>sM.value?.logs??null),s=U(()=>sM.value?.configError??null);function c(e){return sM.value?.servers.find(t=>t.id===e)}function l(e){return xM(e)}async function u(e,t){lM.value=null;try{let n=await e();sM.value=await dj();let r=typeof t.success==`function`?t.success(n):t.success;return r&&fM.success(r),n}catch(e){if(e instanceof cj){Jj().requireLogin();return}let n=e instanceof Error?e.message:String(e);lM.value=n,fM.failure(t.title,n);return}}return{appState:rn(sM),servers:e,control:t,defaults:n,host:r,backups:i,notifications:a,logsConfig:o,configError:s,connection:rn(cM),lastError:rn(lM),now:rn(uM),serverById:c,seriesOf:l,refresh:(e=`Refresh failed`)=>u(async()=>{},{title:e}),start:e=>u(()=>Lj(e,`start`),{title:`Could not start ${e}`}),stop:e=>u(()=>Lj(e,`stop`),{title:`Could not stop ${e}`}),restart:e=>u(()=>Lj(e,`restart`),{title:`Could not restart ${e}`}),startAll:()=>u(()=>Rj(),{title:`Could not start every server`,success:`Starting every enabled server`}),stopAll:()=>u(()=>Bj(),{title:`Could not stop every server`,success:`Stopping every server`}),setAutostart:(e,t)=>u(()=>Hj(e,{autostart:t}),{title:`Could not change autostart for ${e}`}),setEnabled:(e,t)=>u(()=>Hj(e,{enabled:t}),{title:`Could not change ${e}`}),freePort:e=>u(()=>zj(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?(fM.failure(`Could not change the bind for ${e}`,`"${t}" is not a bind value`),Promise.resolve(void 0)):u(()=>Hj(e,{bind:n}),{title:`Could not change the bind for ${e}`})},saveConfig:(e,t)=>u(()=>Hj(e,t),{title:`Could not save ${e}`,success:`${e} updated`}),saveSettings:e=>u(()=>vj(e),{title:`Could not save the settings`}),clearLogs:e=>u(async()=>{await Vj(e),bM(e)},{title:`Could not clear the logs for ${e}`,success:`Buffer cleared`}),create:e=>u(()=>Wj(e),{title:`Could not add the server`,success:`Server added`}),remove:e=>u(async()=>{await Uj(e),DM(e),pM.delete(e),dM.delete(e)},{title:`Could not remove ${e}`,success:`${e} removed`})}}var MM=`hh.theme`;function NM(){try{let e=localStorage.getItem(MM);if(e===`light`||e===`dark`||e===`system`)return e}catch{}return`system`}var PM=A(NM()),FM=A(typeof matchMedia<`u`&&matchMedia(`(prefers-color-scheme: dark)`).matches),IM=!1;function LM(){IM||typeof matchMedia>`u`||(IM=!0,matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,e=>{FM.value=e.matches,zM()}))}var RM=U(()=>PM.value===`system`?FM.value:PM.value===`dark`);function zM(){typeof document<`u`&&document.documentElement.classList.toggle(`dark`,RM.value)}function BM(){LM(),zM();function e(e){PM.value=e;try{localStorage.setItem(MM,e)}catch{}zM()}return{preference:PM,isDark:RM,setPreference:e,cycle(){e(PM.value===`light`?`dark`:PM.value===`dark`?`system`:`light`)}}}function VM(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=VM(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function HM(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=VM(e))&&(r&&(r+=` `),r+=t);return r}var UM=(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},WM=(e,t)=>({classGroupId:e,validator:t}),GM=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),KM=`-`,qM=[],JM=`arbitrary..`,YM=e=>{let t=QM(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return ZM(e);let n=e.split(KM);return XM(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?UM(i,t):t:i||qM}return n[e]||qM}}},XM=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=XM(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(KM):e.slice(t).join(KM),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},ZM=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?JM+r:void 0})(),QM=e=>{let{theme:t,classGroups:n}=e;return $M(n,t)},$M=(e,t)=>{let n=GM();for(let r in e){let i=e[r];eN(i,n,r,t)}return n},eN=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];tN(i,t,n,r)}},tN=(e,t,n,r)=>{if(typeof e==`string`){nN(e,t,n);return}if(typeof e==`function`){rN(e,t,n,r);return}iN(e,t,n,r)},nN=(e,t,n)=>{let r=e===``?t:aN(t,e);r.classGroupId=n},rN=(e,t,n,r)=>{if(oN(e)){eN(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(WM(n,e))},iN=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];eN(o,aN(t,a),n,r)}},aN=(e,t)=>{let n=e,r=t.split(KM),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=GM(),n.nextPart.set(t,i)),n=i}return n},oN=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,sN=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)}}},cN=`!`,lN=`:`,uN=[],dN=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),fN=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===lN){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(cN)?(c=s.slice(0,-1),l=!0):s.startsWith(cN)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return dN(t,l,c,u)};if(t){let e=t+lN,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):dN(uN,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},pN=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}},mN=e=>({cache:sN(e.cacheSize),parseClassName:fN(e),sortModifiers:pN(e),postfixLookupClassGroupIds:hN(e),...YM(e)}),hN=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},gN=/\s+/,_N=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(gN),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?_+cN:_,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},vN=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=yN(n))&&(i&&(i+=` `),i+=r);return i},yN=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=yN(e[r]))&&(n&&(n+=` `),n+=t);return n},bN=(e,...t)=>{let n,r,i,a,o=o=>(n=mN(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=_N(e,n);return i(e,a),a};return a=o,(...e)=>a(vN(...e))},xN=[],SN=e=>{let t=t=>t[e]||xN;return t.isThemeGetter=!0,t.themeKey=e,t},CN=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,wN=/^\((?:(\w[\w-]*):)?(.+)\)$/i,TN=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,EN=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,DN=/\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$/,ON=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,kN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,AN=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,jN=e=>TN.test(e),MN=e=>!!e&&!Number.isNaN(Number(e)),NN=e=>!!e&&Number.isInteger(Number(e)),PN=e=>e.endsWith(`%`)&&MN(e.slice(0,-1)),FN=e=>EN.test(e),IN=()=>!0,LN=e=>DN.test(e)&&!ON.test(e),RN=()=>!1,zN=e=>kN.test(e),BN=e=>AN.test(e),VN=e=>!X(e)&&!Z(e),HN=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)),UN=e=>iP(e,cP,RN),X=e=>CN.test(e),WN=e=>iP(e,lP,LN),GN=e=>iP(e,uP,MN),KN=e=>iP(e,fP,IN),qN=e=>iP(e,dP,RN),JN=e=>iP(e,oP,RN),YN=e=>iP(e,sP,BN),XN=e=>iP(e,pP,zN),Z=e=>wN.test(e),ZN=e=>aP(e,lP),QN=e=>aP(e,dP),$N=e=>aP(e,oP),eP=e=>aP(e,cP),tP=e=>aP(e,sP),nP=e=>aP(e,pP,!0),rP=e=>aP(e,fP,!0),iP=(e,t,n)=>{let r=CN.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},aP=(e,t,n=!1)=>{let r=wN.exec(e);return r?r[1]?t(r[1]):n:!1},oP=e=>e===`position`||e===`percentage`,sP=e=>e===`image`||e===`url`,cP=e=>e===`length`||e===`size`||e===`bg-size`,lP=e=>e===`length`,uP=e=>e===`number`,dP=e=>e===`family-name`,fP=e=>e===`number`||e===`weight`,pP=e=>e===`shadow`,mP=bN(()=>{let e=SN(`color`),t=SN(`font`),n=SN(`text`),r=SN(`font-weight`),i=SN(`tracking`),a=SN(`leading`),o=SN(`breakpoint`),s=SN(`container`),c=SN(`spacing`),l=SN(`radius`),u=SN(`shadow`),d=SN(`inset-shadow`),f=SN(`text-shadow`),p=SN(`drop-shadow`),m=SN(`blur`),h=SN(`perspective`),g=SN(`aspect`),_=SN(`ease`),v=SN(`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=()=>[jN,`full`,`auto`,...w()],ee=()=>[NN,`none`,`subgrid`,Z,X],te=()=>[`auto`,{span:[`full`,NN,Z,X]},NN,Z,X],ne=()=>[NN,`auto`,Z,X],re=()=>[`auto`,`min`,`max`,`fr`,Z,X],ie=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],ae=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],oe=()=>[`auto`,...w()],se=()=>[jN,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ce=()=>[s,jN,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],le=()=>[jN,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],E=()=>[e,Z,X],ue=()=>[...b(),$N,JN,{position:[Z,X]}],de=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],fe=()=>[`auto`,`cover`,`contain`,eP,UN,{size:[Z,X]}],pe=()=>[PN,ZN,WN],me=()=>[``,`none`,`full`,l,Z,X],he=()=>[``,MN,ZN,WN],ge=()=>[`solid`,`dashed`,`dotted`,`double`],_e=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],ve=()=>[MN,PN,$N,JN],ye=()=>[``,`none`,m,Z,X],be=()=>[`none`,MN,Z,X],xe=()=>[`none`,MN,Z,X],D=()=>[MN,Z,X],Se=()=>[jN,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[FN],breakpoint:[FN],color:[IN],container:[FN],"drop-shadow":[FN],ease:[`in`,`out`,`in-out`],font:[VN],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[FN],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[FN],shadow:[FN],spacing:[`px`,MN],text:[FN],"text-shadow":[FN],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,jN,X,Z,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,Z,X]}],"container-named":[HN],columns:[{columns:[MN,`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:[NN,`auto`,Z,X]}],basis:[{basis:[jN,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[MN,jN,`auto`,`initial`,`none`,X]}],grow:[{grow:[``,MN,Z,X]}],shrink:[{shrink:[``,MN,Z,X]}],order:[{order:[NN,`first`,`last`,`none`,Z,X]}],"grid-cols":[{"grid-cols":ee()}],"col-start-end":[{col:te()}],"col-start":[{"col-start":ne()}],"col-end":[{"col-end":ne()}],"grid-rows":[{"grid-rows":ee()}],"row-start-end":[{row:te()}],"row-start":[{"row-start":ne()}],"row-end":[{"row-end":ne()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":re()}],"auto-rows":[{"auto-rows":re()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...ie(),`normal`]}],"justify-items":[{"justify-items":[...ae(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...ae()]}],"align-content":[{content:[`normal`,...ie()]}],"align-items":[{items:[...ae(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...ae(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":ie()}],"place-items":[{"place-items":[...ae(),`baseline`]}],"place-self":[{"place-self":[`auto`,...ae()]}],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:oe()}],mx:[{mx:oe()}],my:[{my:oe()}],ms:[{ms:oe()}],me:[{me:oe()}],mbs:[{mbs:oe()}],mbe:[{mbe:oe()}],mt:[{mt:oe()}],mr:[{mr:oe()}],mb:[{mb:oe()}],ml:[{ml:oe()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:se()}],"inline-size":[{inline:[`auto`,...ce()]}],"min-inline-size":[{"min-inline":[`auto`,...ce()]}],"max-inline-size":[{"max-inline":[`none`,...ce()]}],"block-size":[{block:[`auto`,...le()]}],"min-block-size":[{"min-block":[`auto`,...le()]}],"max-block-size":[{"max-block":[`none`,...le()]}],w:[{w:[s,`screen`,...se()]}],"min-w":[{"min-w":[s,`screen`,`none`,...se()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...se()]}],h:[{h:[`screen`,`lh`,...se()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...se()]}],"max-h":[{"max-h":[`screen`,`lh`,`none`,...se()]}],"font-size":[{text:[`base`,n,ZN,WN]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,rP,KN]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,PN,X]}],"font-family":[{font:[QN,qN,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":[MN,`none`,Z,GN]}],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:E()}],"text-color":[{text:E()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...ge(),`wavy`]}],"text-decoration-thickness":[{decoration:[MN,`from-font`,`auto`,Z,WN]}],"text-decoration-color":[{decoration:E()}],"underline-offset":[{"underline-offset":[MN,`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:[NN,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:ue()}],"bg-repeat":[{bg:de()}],"bg-size":[{bg:fe()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},NN,Z,X],radial:[``,Z,X],conic:[``,NN,Z,X]},tP,YN]}],"bg-color":[{bg:E()}],"gradient-from-pos":[{from:pe()}],"gradient-via-pos":[{via:pe()}],"gradient-to-pos":[{to:pe()}],"gradient-from":[{from:E()}],"gradient-via":[{via:E()}],"gradient-to":[{to:E()}],rounded:[{rounded:me()}],"rounded-s":[{"rounded-s":me()}],"rounded-e":[{"rounded-e":me()}],"rounded-t":[{"rounded-t":me()}],"rounded-r":[{"rounded-r":me()}],"rounded-b":[{"rounded-b":me()}],"rounded-l":[{"rounded-l":me()}],"rounded-ss":[{"rounded-ss":me()}],"rounded-se":[{"rounded-se":me()}],"rounded-ee":[{"rounded-ee":me()}],"rounded-es":[{"rounded-es":me()}],"rounded-tl":[{"rounded-tl":me()}],"rounded-tr":[{"rounded-tr":me()}],"rounded-br":[{"rounded-br":me()}],"rounded-bl":[{"rounded-bl":me()}],"border-w":[{border:he()}],"border-w-x":[{"border-x":he()}],"border-w-y":[{"border-y":he()}],"border-w-s":[{"border-s":he()}],"border-w-e":[{"border-e":he()}],"border-w-bs":[{"border-bs":he()}],"border-w-be":[{"border-be":he()}],"border-w-t":[{"border-t":he()}],"border-w-r":[{"border-r":he()}],"border-w-b":[{"border-b":he()}],"border-w-l":[{"border-l":he()}],"divide-x":[{"divide-x":he()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":he()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...ge(),`hidden`,`none`]}],"divide-style":[{divide:[...ge(),`hidden`,`none`]}],"border-color":[{border:E()}],"border-color-x":[{"border-x":E()}],"border-color-y":[{"border-y":E()}],"border-color-s":[{"border-s":E()}],"border-color-e":[{"border-e":E()}],"border-color-bs":[{"border-bs":E()}],"border-color-be":[{"border-be":E()}],"border-color-t":[{"border-t":E()}],"border-color-r":[{"border-r":E()}],"border-color-b":[{"border-b":E()}],"border-color-l":[{"border-l":E()}],"divide-color":[{divide:E()}],"outline-style":[{outline:[...ge(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[MN,Z,X]}],"outline-w":[{outline:[``,MN,ZN,WN]}],"outline-color":[{outline:E()}],shadow:[{shadow:[``,`inner`,`none`,u,nP,XN]}],"shadow-color":[{shadow:E()}],"inset-shadow":[{"inset-shadow":[`none`,d,nP,XN]}],"inset-shadow-color":[{"inset-shadow":E()}],"ring-w":[{ring:he()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:E()}],"ring-offset-w":[{"ring-offset":[MN,WN]}],"ring-offset-color":[{"ring-offset":E()}],"inset-ring-w":[{"inset-ring":he()}],"inset-ring-color":[{"inset-ring":E()}],"text-shadow":[{"text-shadow":[`none`,f,nP,XN]}],"text-shadow-color":[{"text-shadow":E()}],opacity:[{opacity:[MN,Z,X]}],"mix-blend":[{"mix-blend":[..._e(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":_e()}],"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":[MN]}],"mask-image-linear-from-pos":[{"mask-linear-from":ve()}],"mask-image-linear-to-pos":[{"mask-linear-to":ve()}],"mask-image-linear-from-color":[{"mask-linear-from":E()}],"mask-image-linear-to-color":[{"mask-linear-to":E()}],"mask-image-t-from-pos":[{"mask-t-from":ve()}],"mask-image-t-to-pos":[{"mask-t-to":ve()}],"mask-image-t-from-color":[{"mask-t-from":E()}],"mask-image-t-to-color":[{"mask-t-to":E()}],"mask-image-r-from-pos":[{"mask-r-from":ve()}],"mask-image-r-to-pos":[{"mask-r-to":ve()}],"mask-image-r-from-color":[{"mask-r-from":E()}],"mask-image-r-to-color":[{"mask-r-to":E()}],"mask-image-b-from-pos":[{"mask-b-from":ve()}],"mask-image-b-to-pos":[{"mask-b-to":ve()}],"mask-image-b-from-color":[{"mask-b-from":E()}],"mask-image-b-to-color":[{"mask-b-to":E()}],"mask-image-l-from-pos":[{"mask-l-from":ve()}],"mask-image-l-to-pos":[{"mask-l-to":ve()}],"mask-image-l-from-color":[{"mask-l-from":E()}],"mask-image-l-to-color":[{"mask-l-to":E()}],"mask-image-x-from-pos":[{"mask-x-from":ve()}],"mask-image-x-to-pos":[{"mask-x-to":ve()}],"mask-image-x-from-color":[{"mask-x-from":E()}],"mask-image-x-to-color":[{"mask-x-to":E()}],"mask-image-y-from-pos":[{"mask-y-from":ve()}],"mask-image-y-to-pos":[{"mask-y-to":ve()}],"mask-image-y-from-color":[{"mask-y-from":E()}],"mask-image-y-to-color":[{"mask-y-to":E()}],"mask-image-radial":[{"mask-radial":[Z,X]}],"mask-image-radial-from-pos":[{"mask-radial-from":ve()}],"mask-image-radial-to-pos":[{"mask-radial-to":ve()}],"mask-image-radial-from-color":[{"mask-radial-from":E()}],"mask-image-radial-to-color":[{"mask-radial-to":E()}],"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":[MN]}],"mask-image-conic-from-pos":[{"mask-conic-from":ve()}],"mask-image-conic-to-pos":[{"mask-conic-to":ve()}],"mask-image-conic-from-color":[{"mask-conic-from":E()}],"mask-image-conic-to-color":[{"mask-conic-to":E()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:ue()}],"mask-repeat":[{mask:de()}],"mask-size":[{mask:fe()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,Z,X]}],filter:[{filter:[``,`none`,Z,X]}],blur:[{blur:ye()}],brightness:[{brightness:[MN,Z,X]}],contrast:[{contrast:[MN,Z,X]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,nP,XN]}],"drop-shadow-color":[{"drop-shadow":E()}],grayscale:[{grayscale:[``,MN,Z,X]}],"hue-rotate":[{"hue-rotate":[MN,Z,X]}],invert:[{invert:[``,MN,Z,X]}],saturate:[{saturate:[MN,Z,X]}],sepia:[{sepia:[``,MN,Z,X]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,Z,X]}],"backdrop-blur":[{"backdrop-blur":ye()}],"backdrop-brightness":[{"backdrop-brightness":[MN,Z,X]}],"backdrop-contrast":[{"backdrop-contrast":[MN,Z,X]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,MN,Z,X]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[MN,Z,X]}],"backdrop-invert":[{"backdrop-invert":[``,MN,Z,X]}],"backdrop-opacity":[{"backdrop-opacity":[MN,Z,X]}],"backdrop-saturate":[{"backdrop-saturate":[MN,Z,X]}],"backdrop-sepia":[{"backdrop-sepia":[``,MN,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:[MN,`initial`,Z,X]}],ease:[{ease:[`linear`,`initial`,_,Z,X]}],delay:[{delay:[MN,Z,X]}],animate:[{animate:[`none`,v,Z,X]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,Z,X]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:be()}],"rotate-x":[{"rotate-x":be()}],"rotate-y":[{"rotate-y":be()}],"rotate-z":[{"rotate-z":be()}],scale:[{scale:xe()}],"scale-x":[{"scale-x":xe()}],"scale-y":[{"scale-y":xe()}],"scale-z":[{"scale-z":xe()}],"scale-3d":[`scale-3d`],skew:[{skew:D()}],"skew-x":[{"skew-x":D()}],"skew-y":[{"skew-y":D()}],transform:[{transform:[Z,X,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:Se()}],"translate-x":[{"translate-x":Se()}],"translate-y":[{"translate-y":Se()}],"translate-z":[{"translate-z":Se()}],"translate-none":[`translate-none`],zoom:[{zoom:[NN,Z,X]}],accent:[{accent:E()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:E()}],"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":E()}],"scrollbar-track-color":[{"scrollbar-track":E()}],"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`,...E()]}],"stroke-w":[{stroke:[MN,ZN,WN,GN]}],stroke:[{stroke:[`none`,...E()]}],"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 mP(HM(e))}var hP={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}},gP={disabled:{label:`Not checked`,tone:`neutral`},unknown:{label:`Not probed`,tone:`neutral`},healthy:{label:`Healthy`,tone:`ok`},unhealthy:{label:`Unhealthy`,tone:`danger`}},_P={ok:`text-ok`,warn:`text-warn`,danger:`text-danger`,info:`text-info`,neutral:`text-muted`,accent:`text-accent`},vP={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`},yP={ok:`bg-ok`,warn:`bg-warn`,danger:`bg-danger`,info:`bg-info`,neutral:`bg-faint`,accent:`bg-accent`};function bP(e,t){return e===`crashed`||e===`conflict`||t===`unhealthy`?`danger`:e===`starting`||e===`stopping`||e===`backoff`?`warn`:e===`running`?`ok`:`neutral`}var xP={start:`Started`,exit:`Exited`,crash:`Crashed`,"forced-restart":`Forced restart`,unhealthy:`Unhealthy`,recovered:`Recovered`},SP={start:`ok`,exit:`neutral`,crash:`danger`,"forced-restart":`warn`,unhealthy:`warn`,recovered:`info`},CP={class:`flex items-center gap-2.5 border-b border-line px-3.5`},wP={key:0,class:`px-3 py-8 text-center text-xs text-muted`},TP={class:`px-2.5 pb-1 pt-2.5 text-2xs font-medium text-faint`},EP=[`data-active`,`onMousemove`,`onClick`],DP={class:`min-w-0 flex-1 truncate text-sm`},OP={key:0,class:`shrink-0 font-mono text-2xs text-faint`},kP={class:`flex items-center gap-3 border-t border-line bg-panel-2 px-3.5 py-2 text-2xs text-faint`},AP={class:`ml-auto font-mono`},jP=N({__name:`CommandPalette`,props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:[`update:open`],setup(e){let t=co(e,`open`),n=zg(),r=jM(),i=BM(),a=A(``),o=A(0),s=A(null),c=A(null);function l(e){n.push(e)}function u(e){e(),t.value=!1}let d=[`stopped`,`crashed`,`conflict`],f=[`running`,`starting`,`backoff`],p=U(()=>{let e=[],t=r.appState.value?.servers??[];for(let n of t){let t=n.config.label??n.id,i=hP[n.status].label;e.push({id:`open:${n.id}`,title:`Open ${t}`,group:`Servers`,icon:xy,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:Oy,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:py,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:Ey,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:vy,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:ny,keywords:`dashboard home`,run:()=>l(`/`)},{id:`nav:servers`,title:`Go to Servers`,group:`Navigate`,icon:xy,keywords:`processes list`,run:()=>l(`/servers`)},{id:`nav:logs`,title:`Go to Logs`,group:`Navigate`,icon:yy,keywords:`output files tail`,run:()=>l(`/logs`)},{id:`nav:settings`,title:`Go to Settings`,group:`Navigate`,icon:Ty,keywords:`config panel`,run:()=>l(`/settings`)},{id:`act:start-all`,title:`Start every enabled server`,group:`Actions`,icon:py,keywords:`boot all`,run:()=>u(()=>void r.startAll())},{id:`act:stop-all`,title:`Stop every server`,group:`Actions`,icon:Ey,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:Ty,keywords:`configure ${t}`,run:()=>l(`/settings?section=${t}`)});let n=[[`light`,`Light`,Dy],[`dark`,`Dark`,ly],[`system`,`System`,cy]];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=U(()=>{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=U(()=>{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=U(()=>h.value.flatMap(([,e])=>e));jr(m,()=>{o.value=0}),jr(t,async e=>{e&&(a.value=``,o.value=0,await rr(),s.value?.focus())});function _(e){let t=g.value.length;t!==0&&(o.value=(o.value+e+t)%t,rr(()=>{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 na(()=>window.addEventListener(`keydown`,y)),Be(()=>window.removeEventListener(`keydown`,y)),(e,n)=>(I(),R(j(uf),{open:t.value,"onUpdate:open":n[2]||=e=>t.value=e},{default:M(()=>[B(j(Xf),null,{default:M(()=>[B(j(Jf),{class:`fixed inset-0 z-50 bg-black/40 backdrop-blur-[1px] data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`}),B(j(Gf),{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]||=uu(()=>{},[`prevent`]),onKeydown:v},{default:M(()=>[B(j(Zf),{class:`sr-only`},{default:M(()=>[...n[3]||=[V(` Command palette `,-1)]]),_:1}),z(`div`,CP,[B(j(by),{class:`size-4 shrink-0 text-faint`}),xr(z(`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),[[Yl,a.value]]),n[4]||=z(`kbd`,{class:`shrink-0 rounded border border-line bg-page px-1.5 py-0.5 font-mono text-2xs text-faint`},`esc`,-1)]),z(`div`,{ref_key:`list`,ref:c,class:`max-h-[min(60vh,26rem)] overflow-y-auto p-1.5`},[g.value.length===0?(I(),L(`p`,wP,` Nothing matches “`+O(a.value)+`”. `,1)):H(``,!0),(I(!0),L(F,null,ya(h.value,([e,t])=>(I(),L(F,{key:e},[z(`p`,TP,O(e),1),(I(!0),L(F,null,ya(t,e=>(I(),L(`button`,{key:e.id,type:`button`,"data-active":g.value[o.value]?.id===e.id,class:D(j(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()},[(I(),R(ha(e.icon),{class:D([`size-4 shrink-0`,g.value[o.value]?.id===e.id?`text-accent`:`text-faint`])},null,8,[`class`])),z(`span`,DP,O(e.title),1),e.detail?(I(),L(`span`,OP,O(e.detail),1)):H(``,!0),B(j(Rv),{class:D([`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,EP))),128))],64))),128))],512),z(`div`,kP,[n[5]||=z(`span`,null,[z(`kbd`,{class:`font-mono`},`↑↓`),V(` navigate`)],-1),n[6]||=z(`span`,null,[z(`kbd`,{class:`font-mono`},`↵`),V(` run`)],-1),z(`span`,AP,O(g.value.length)+` results`,1)])]),_:1})]),_:1})]),_:1},8,[`open`]))}}),MP={viewBox:`0 0 80 80`,class:`size-full -rotate-0`},NP=[`stroke-dasharray`],PP=[`stroke-dasharray`],FP={class:`absolute inset-0 grid place-items-center`},IP={class:`font-mono text-sm font-semibold tabular-nums text-ink`},LP={class:`text-2xs font-medium text-faint`},RP=34,zP=.75,BP=N({__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*RP,r=U(()=>t.value===null||!Number.isFinite(t.value)?0:Math.min(1,Math.max(0,t.value/100))*zP),i=U(()=>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)=>(I(),L(`div`,{class:D(j(Q)(`flex flex-col items-center gap-1`))},[z(`div`,{class:`relative`,style:_e({width:`${t.size}px`,height:`${t.size}px`})},[(I(),L(`svg`,MP,[z(`circle`,{cx:`40`,cy:`40`,r:RP,fill:`none`,class:`stroke-line-soft`,"stroke-width":6,"stroke-dasharray":`${zP*n} ${n}`,transform:`rotate(135 40 40)`,"stroke-linecap":`round`},null,8,NP),z(`circle`,{cx:`40`,cy:`40`,r:RP,fill:`none`,class:D([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,PP)])),z(`div`,FP,[z(`span`,IP,O(t.display??(t.value===null?`—`:`${Math.round(t.value)}%`)),1)])],4),z(`span`,LP,O(t.label),1)],2))}}),VP={class:`rounded-panel border border-line bg-panel-2/70 p-3`},HP={class:`mb-2 flex items-center justify-between`},UP={key:0,class:`text-2xs text-faint`},WP={key:0,class:`grid grid-cols-2 gap-x-1 gap-y-2`},GP={key:1,class:`py-3 text-center text-2xs text-faint`},KP={key:2,class:`mt-2 flex items-start gap-1.5 rounded-control bg-danger-soft px-2 py-1.5`},qP={class:`text-2xs leading-4 text-danger`},JP=2,YP=85,XP=N({__name:`InstrumentCluster`,props:{host:{}},setup(e){let t=e,n=U(()=>{let e=t.host;return e?(e.loadAvg[0]??0)/Math.max(1,e.cpus):null}),r=U(()=>n.value===null?null:n.value/JP*100),i=U(()=>n.value===null?`—`:n.value.toFixed(2)),a=U(()=>{let e=t.host?.disks??[];return e.length===0?null:Math.max(...e.map(e=>e.usedPercent))}),o=U(()=>{let e=t.host?.tempCelsius??null;return e===null?null:e/YP*100}),s=U(()=>{let e=t.host?.tempCelsius??null;return e===null?`n/a`:`${Math.round(e)}°`});return(e,n)=>(I(),L(`div`,VP,[z(`div`,HP,[n[0]||=z(`span`,{class:`text-2xs font-medium text-faint`},`Host vitals`,-1),t.host?.enabled===!1?(I(),L(`span`,UP,`off`)):H(``,!0)]),t.host?.enabled?(I(),L(`div`,WP,[B(BP,{value:r.value,label:`Load / cpu`,display:i.value,size:58,"warn-at":70,"danger-at":100},null,8,[`value`,`display`]),B(BP,{value:t.host?.memoryUsedPercent??null,label:`Memory`,size:58},null,8,[`value`]),B(BP,{value:a.value,label:`Disk`,size:58},null,8,[`value`]),B(BP,{value:o.value,label:`CPU temp`,display:s.value,size:58},null,8,[`value`,`display`])])):(I(),L(`p`,GP,` Sampling is disabled in Settings. `)),t.host&&t.host.alerts.length>0?(I(),L(`div`,KP,[n[1]||=z(`span`,{class:`mt-1 size-1.5 shrink-0 rounded-full bg-danger`},null,-1),z(`span`,qP,O(t.host.alerts.join(` · `)),1)])):H(``,!0)]))}}),ZP={class:`flex h-full min-h-0 flex-col gap-3 overflow-y-auto p-3`},QP={class:`flex items-center gap-2 px-1 pt-1`},$P={class:`min-w-0`},eF={class:`truncate text-2xs text-faint`},tF={class:`flex flex-col gap-0.5`},nF={class:`mt-auto flex flex-col gap-3`},rF={class:`flex items-center gap-2 rounded-control border border-line bg-panel-2/70 px-2.5 py-2`},iF={class:`relative flex size-2 shrink-0`},aF={class:`text-2xs text-muted`},oF=[`title`],sF=N({__name:`SideNav`,props:{host:{},connection:{},panelLabel:{},planLabel:{},running:{},total:{}},emits:[`navigate`,`close`],setup(e,{emit:t}){let n=e,r=t,i=Bg(),a=[{to:`/`,label:`Overview`,icon:ny,exact:!0},{to:`/servers`,label:`Servers`,icon:xy,exact:!1},{to:`/logs`,label:`Logs`,icon:yy,exact:!1},{to:`/settings`,label:`Settings`,icon:Ty,exact:!1}];function o(e){return e.exact?i.path===e.to:i.path===e.to||i.path.startsWith(`${e.to}/`)}let s=U(()=>({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=pa(`RouterLink`);return I(),L(`div`,ZP,[z(`div`,QP,[t[3]||=ks(`<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),z(`div`,$P,[t[2]||=z(`p`,{class:`truncate text-sm font-semibold tracking-tight text-ink`},` home-hosted `,-1),z(`p`,eF,O(n.panelLabel),1)]),z(`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`)},[B(j(Ny),{class:`size-4`})])]),z(`nav`,tF,[(I(),L(F,null,ya(a,e=>B(i,{key:e.to,to:e.to,class:D(j(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:M(()=>[(I(),R(ha(e.icon),{class:`size-4 shrink-0`,"stroke-width":o(e)?2.1:1.8},null,8,[`stroke-width`])),V(` `+O(e.label)+` `,1),e.to===`/servers`?(I(),L(`span`,{key:0,class:D([`ml-auto font-mono text-2xs tabular-nums`,o(e)?`text-accent`:`text-faint`])},O(n.running)+`/`+O(n.total),3)):H(``,!0)]),_:2},1032,[`to`,`class`])),64))]),z(`div`,nF,[B(XP,{host:n.host},null,8,[`host`]),z(`div`,rF,[z(`span`,iF,[z(`span`,{class:D(j(Q)(`absolute inset-0 rounded-full`,s.value.dot,n.connection!==`open`&&`animate-ping opacity-60`))},null,2),z(`span`,{class:D(j(Q)(`relative size-2 rounded-full`,s.value.dot))},null,2)]),z(`span`,aF,O(s.value.label),1),z(`span`,{class:`ml-auto truncate font-mono text-2xs text-faint`,title:n.planLabel},O(n.planLabel),9,oF)])])])}}}),cF={key:0,class:`flex flex-col gap-px border-b border-line bg-panel/60`},lF={class:`text-2xs leading-4`},uF={class:`font-medium`},dF={key:0,class:`opacity-80`},fF=N({__name:`SystemNotices`,props:{control:{},configError:{},configPath:{}},setup(e){let t=e,n=U(()=>{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:`The panel keeps running the config it already had; fix ${t.configPath??`servers.config.json`} and it reloads on its own.`}),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:My},danger:{wrap:`border-danger/25 bg-danger-soft text-danger`,icon:Bv},info:{wrap:`border-line bg-panel-2 text-muted`,icon:Bv}};return(e,t)=>n.value.length>0?(I(),L(`div`,cF,[(I(!0),L(F,null,ya(n.value,e=>(I(),L(`div`,{key:e.id,class:D([`flex items-start gap-2 px-3 py-1.5 sm:px-4`,r[e.tone].wrap])},[(I(),R(ha(r[e.tone].icon),{class:`mt-0.5 size-3.5 shrink-0`})),z(`p`,lF,[z(`span`,uF,O(e.text),1),e.hint?(I(),L(`span`,dF,O(e.hint),1)):H(``,!0)])],2))),128))])):H(``,!0)}}),pF={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`},mF={class:`min-w-0 flex-1`},hF={class:`text-xs font-medium text-ink`},gF={key:0,class:`mt-0.5 break-words text-2xs leading-4 text-muted`},_F=[`onClick`],vF=N({__name:`ToastStack`,setup(e){let{toasts:t,dismiss:n}=$j(),r={ok:Vv,danger:Hv,warn:My,info:ty,accent:ty,neutral:ty},i={ok:`text-ok`,danger:`text-danger`,warn:`text-warn`,info:`text-info`,neutral:`text-muted`,accent:`text-accent`},a=U(()=>t.value);return(e,t)=>(I(),L(`div`,pF,[B(Ll,{"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:M(()=>[(I(!0),L(F,null,ya(a.value,e=>(I(),L(`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`},[(I(),R(ha(r[e.tone]),{class:D(j(Q)(`mt-0.5 size-4 shrink-0`,i[e.tone]))},null,8,[`class`])),z(`div`,mF,[z(`p`,hF,O(e.title),1),e.description?(I(),L(`p`,gF,O(e.description),1)):H(``,!0)]),z(`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=>j(n)(e.id)},[B(j(Ny),{class:`size-3.5`})],8,_F)]))),128))]),_:1})]))}}),yF=`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60 focus-visible:ring-offset-2 focus-visible:ring-offset-page`,bF=`text-xs font-medium text-muted`,xF=`text-2xs leading-4 text-faint`,SF=[`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(` `),CF=`${SF} font-mono text-xs`,wF=[`type`,`disabled`,`aria-busy`],$=N({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=Ia(),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=U(()=>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`,yF,n.class));return(e,r)=>(I(),L(`button`,Ns({...j(n),class:void 0},{type:t.type,class:a.value,disabled:t.disabled||t.loading,"aria-busy":t.loading||void 0}),[t.loading?(I(),R(j(ry),{key:0,class:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`})):H(``,!0),P(e.$slots,`default`)],16,wF))}}),TF=N({__name:`Tip`,props:{label:{},side:{default:`top`},disabled:{type:Boolean,default:!1}},setup(e){return(t,n)=>(I(),R(j(_g),{"delay-duration":350},{default:M(()=>[B(j(Sg),{"as-child":``},{default:M(()=>[P(t.$slots,`default`)]),_:3}),e.disabled?H(``,!0):(I(),R(j(xg),{key:0},{default:M(()=>[B(j(bg),{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:M(()=>[V(O(e.label),1)]),_:1},8,[`side`])]),_:1}))]),_:3}))}}),EF={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`},DF={class:`truncate text-sm font-semibold tracking-tight text-ink`},OF={class:`ml-auto flex items-center gap-1.5`},kF={class:`hidden items-center gap-1.5 rounded-control border border-line bg-panel-2 px-2 py-1.5 md:flex`},AF={class:`font-mono text-2xs text-muted`},jF={class:`px-2 py-1.5`},MF={class:`truncate font-mono text-2xs text-muted`},NF=N({__name:`TopBar`,props:{panelUrl:{},connection:{},authenticated:{type:Boolean}},emits:[`menu`,`palette`,`signOut`],setup(e,{emit:t}){let n=e,r=t,i=Bg(),a=BM(),o=U(()=>i.name===`server-detail`?`Servers / ${String(i.params.id??``)}`:String(i.meta.title??`home-hosted`)),s=U(()=>a.preference.value===`dark`?ly:a.preference.value===`light`?Dy:cy),c=U(()=>`Theme: ${a.preference.value}`),l=U(()=>({open:`bg-ok`,connecting:`bg-warn`,closed:`bg-danger`})[n.connection]),u=U(()=>({open:`Live updates`,connecting:`Connecting`,closed:`Reconnecting`})[n.connection]);return(t,i)=>(I(),L(`header`,EF,[z(`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`)},[B(j(oy),{class:`size-4`})]),z(`h1`,DF,O(o.value),1),z(`div`,OF,[z(`button`,{type:`button`,class:D(j(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`,j(yF))),onClick:i[1]||=e=>r(`palette`)},[B(j(by),{class:`size-3.5`}),i[5]||=z(`span`,{class:`pr-6`},`Search or run a command`,-1),i[6]||=z(`kbd`,{class:`rounded border border-line bg-page px-1 py-0.5 font-mono text-2xs text-faint`},`⌘K`,-1)],2),B(TF,{label:u.value},{default:M(()=>[z(`span`,kF,[z(`span`,{class:D(j(Q)(`size-1.5 rounded-full`,l.value))},null,2),z(`span`,AF,O(e.panelUrl),1)])]),_:1},8,[`label`]),B(TF,{label:c.value},{default:M(()=>[B($,{variant:`ghost`,size:`icon-sm`,"aria-label":c.value,onClick:i[2]||=e=>j(a).cycle()},{default:M(()=>[(I(),R(ha(s.value),{class:`size-4`}))]),_:1},8,[`aria-label`])]),_:1},8,[`label`]),n.authenticated?(I(),R(j(tg),{key:0},{default:M(()=>[B(j(og),{"as-child":``},{default:M(()=>[B($,{variant:`ghost`,size:`icon-sm`,"aria-label":`Account`},{default:M(()=>[...i[7]||=[z(`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}),B(j(ig),null,{default:M(()=>[B(j(ng),{"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:M(()=>[z(`div`,jF,[i[8]||=z(`p`,{class:`text-2xs text-faint`},` Signed in `,-1),z(`p`,MF,O(n.panelUrl),1)]),B(j(ag),{class:`my-1 h-px bg-line`}),B(j(rg),{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:M(()=>[B(j(ay),{class:`size-3.5`}),i[9]||=V(` Sign out `,-1)]),_:1})]),_:1})]),_:1})]),_:1})):H(``,!0),B(TF,{label:`Command palette`},{default:M(()=>[B($,{variant:`ghost`,size:`icon-sm`,class:`sm:hidden`,"aria-label":`Open the command palette`,onClick:i[4]||=e=>r(`palette`)},{default:M(()=>[B(j(Gv),{class:`size-4`})]),_:1})]),_:1})])]))}}),PF={key:1,class:`flex h-dvh overflow-hidden bg-page`},FF={class:`hidden w-60 shrink-0 border-r border-line bg-panel/50 lg:block`},IF={key:0,class:`fixed inset-y-0 left-0 z-40 w-64 border-r border-line bg-panel lg:hidden`},LF={class:`flex min-w-0 flex-1 flex-col`},RF=N({__name:`App`,setup(e){let t=Bg(),n=zg(),r=jM(),{session:i,logout:a}=Jj(),o=A(!1),s=A(!1),c=U(()=>i.value?.authenticated===!0),l=U(()=>i.value?.authRequired===!0),u=U(()=>t.name===`login`),d=U(()=>t.name===`logs`),f=U(()=>r.servers.value),p=U(()=>f.value.filter(e=>e.status===`running`).length),m=U(()=>r.control.value?.url??`—`),h=U(()=>r.host.value),g=U(()=>r.control.value?.label??`home-hosted`);return jr(U(()=>qj(i.value)),e=>{if(e!==`wait`){if(e===`login`){kM(),n.push({name:`login`});return}OM()}},{immediate:!0}),jr(()=>t.fullPath,()=>{s.value=!1}),na(async()=>{(!l.value||c.value)&&await r.refresh()}),Be(()=>kM()),(e,t)=>{let n=pa(`RouterView`);return I(),R(j(pg),{"delay-duration":300},{default:M(()=>[u.value?(I(),R(n,{key:0})):(I(),L(`div`,PF,[z(`aside`,FF,[B(sF,{host:h.value,connection:j(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`])]),B(Oc,{"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:M(()=>[s.value?(I(),L(`div`,{key:0,class:`fixed inset-0 z-40 bg-black/45 lg:hidden`,onClick:t[0]||=e=>s.value=!1})):H(``,!0)]),_:1}),B(Oc,{"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:M(()=>[s.value?(I(),L(`aside`,IF,[B(sF,{host:h.value,connection:j(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`])])):H(``,!0)]),_:1}),z(`div`,LF,[B(NF,{"panel-url":m.value,connection:j(r).connection.value,authenticated:c.value,onMenu:t[3]||=e=>s.value=!0,onPalette:t[4]||=e=>o.value=!0,onSignOut:t[5]||=e=>j(a)()},null,8,[`panel-url`,`connection`,`authenticated`]),u.value?H(``,!0):(I(),R(fF,{key:0,control:j(r).control.value,"config-error":j(r).configError.value,"config-path":j(r).appState.value?.configPath},null,8,[`control`,`config-error`,`config-path`])),z(`main`,{class:D(j(Q)(`min-h-0 flex-1`,d.value?`overflow-hidden`:`overflow-y-auto`))},[B(n)],2)])])),B(jP,{open:o.value,"onUpdate:open":t[6]||=e=>o.value=e},null,8,[`open`]),B(vF)]),_:1})}}}),zF={key:0,class:`size-1.5 shrink-0 rounded-full bg-current`},BF=N({__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=U(()=>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`,vP[t.tone].split(` `).filter(e=>e.startsWith(`text-`)).join(` `)):vP[t.tone],t.mono&&`font-mono`));return(e,r)=>(I(),L(`span`,{class:D(n.value)},[t.dot?(I(),L(`span`,zF)):H(``,!0),P(e.$slots,`default`)],2))}}),VF={class:`relative flex min-h-dvh items-center justify-center overflow-hidden bg-page px-4 py-10`},HF={class:`hh-enter relative w-full max-w-md`},UF={class:`rounded-panel border border-line bg-panel/95 p-5 shadow-float backdrop-blur-sm`},WF={class:`flex items-start justify-between gap-3`},GF={class:`min-w-0`},KF={class:`text-base font-semibold text-ink`},qF={class:`mt-1 text-xs leading-relaxed text-muted`},JF={class:`flex flex-col gap-1.5`},YF={class:`relative`},XF=[`type`],ZF=[`aria-label`],QF={key:0,class:`rounded-control border border-danger/25 bg-danger-soft px-2.5 py-2 text-xs text-danger`},$F={key:1,class:`mt-5`},eI={class:`mt-4 space-y-2`},tI={key:0,class:`flex items-start gap-2 rounded-control border border-warn/25 bg-warn-soft px-2.5 py-2`},nI={class:`text-2xs leading-4 text-warn`},rI={class:`ml-1 rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},iI={key:1,class:`flex items-start gap-2 rounded-control border border-warn/25 bg-warn-soft px-2.5 py-2`},aI={key:2,class:`flex items-start gap-2 rounded-control border border-line-soft bg-panel-2 px-2.5 py-2`},oI={class:`text-2xs leading-4 text-muted`},sI={class:`mt-4 flex items-center justify-center gap-2 text-2xs text-faint`},cI={class:`font-mono`},lI=N({__name:`LoginView`,setup(e){let t=Bg(),n=zg(),r=jM(),{session:i,error:a,login:o,refresh:s}=Jj(),c=A(``),l=A(!1),u=A(!1),d=U(()=>i.value?.passwordSet===!1),f=U(()=>i.value!==null&&!i.value.authRequired),p=U(()=>i.value?.usingDefaultPassword===!0&&i.value.defaultPassword!==null),m=U(()=>r.control.value?.auth.exposed===!0),h=U(()=>r.control.value?.url??`—`),g=U(()=>d.value?`This panel has no password yet`:f.value?`Authentication is turned off`:`Sign in to continue`),_=U(()=>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 na(async()=>{i.value===null&&await s()}),(e,t)=>(I(),L(`div`,VF,[t[11]||=z(`div`,{class:`bg-instrument pointer-events-none absolute inset-0 opacity-60`},null,-1),t[12]||=z(`div`,{class:`pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_at_center,transparent_15%,var(--page)_78%)]`},null,-1),z(`div`,HF,[t[10]||=ks(`<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),z(`section`,UF,[z(`div`,WF,[z(`div`,GF,[z(`h1`,KF,O(g.value),1),z(`p`,qF,O(_.value),1)]),m.value?(I(),R(BF,{key:0,tone:`warn`,dot:``},{default:M(()=>[...t[2]||=[V(` Exposed `,-1)]]),_:1})):H(``,!0)]),f.value?(I(),L(`div`,$F,[B($,{variant:`primary`,size:`md`,block:``,onClick:y},{default:M(()=>[...t[4]||=[V(` Open the dashboard `,-1)]]),_:1})])):(I(),L(`form`,{key:0,class:`mt-5 space-y-3`,onSubmit:uu(v,[`prevent`])},[z(`div`,JF,[z(`label`,{for:`hh-password`,class:D(j(bF))},`Password`,2),z(`div`,YF,[xr(z(`input`,{id:`hh-password`,"onUpdate:modelValue":t[0]||=e=>c.value=e,type:u.value?`text`:`password`,autocomplete:`current-password`,autofocus:``,required:``,class:D(j(Q)(j(SF),`pr-9`))},null,10,XF),[[iu,c.value]]),z(`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?(I(),R(j(Zv),{key:0,class:`size-3.5`})):(I(),R(j(Qv),{key:1,class:`size-3.5`}))],8,ZF)])]),j(a)?(I(),L(`p`,QF,O(j(a)),1)):H(``,!0),B($,{type:`submit`,variant:`primary`,size:`md`,block:``,loading:l.value},{default:M(()=>[B(j(iy),{class:`size-3.5`}),t[3]||=V(` Sign in `,-1)]),_:1},8,[`loading`])],32)),z(`div`,eI,[p.value?(I(),L(`div`,tI,[B(j(Sy),{class:`mt-0.5 size-3.5 shrink-0 text-warn`}),z(`p`,nI,[t[5]||=V(` Still on the default password `,-1),z(`code`,rI,O(j(i)?.defaultPassword),1),t[6]||=V(`. Change it under Settings — binding beyond 127.0.0.1 stays refused until you do. `,-1)])])):d.value?(I(),L(`div`,iI,[B(j(wy),{class:`mt-0.5 size-3.5 shrink-0 text-warn`}),t[7]||=z(`p`,{class:`text-2xs leading-4 text-warn`},[V(` No password is set. Open Settings from this machine to add one, or run `),z(`code`,{class:`rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},`pnpm run auth:set-password`),V(`. `)],-1)])):(I(),L(`div`,aI,[B(j(Cy),{class:`mt-0.5 size-3.5 shrink-0 text-ok`}),z(`p`,oI,` Sessions last `+O(Math.round((j(i)?.sessionTtlMs??0)/864e5))+` days. Signing out clears this browser only. `,1)]))])]),z(`p`,sI,[z(`span`,cI,O(h.value),1),t[8]||=z(`span`,{"aria-hidden":`true`},`·`,-1),t[9]||=z(`span`,null,`served from this machine`,-1)])])]))}}),uI=[`#3f4a5c`,`#f07178`,`#7fd88f`,`#e6b673`,`#82aaff`,`#c792ea`,`#7fdbca`,`#c7d2e3`,`#5a6779`,`#ff8b92`,`#9ae6a8`,`#f2c98a`,`#9dbaff`,`#d7aef0`,`#9ce9dc`,`#eef3fb`],dI=[`#4b5563`,`#c0392b`,`#1c7c3f`,`#9a6700`,`#2f5fe0`,`#7c3aed`,`#0b6f89`,`#334155`,`#6b7280`,`#d64535`,`#22854a`,`#a8620d`,`#3f6bff`,`#8b5cf6`,`#0e7d9c`,`#0f1722`],fI=/\u001B\[([0-9;]*)m/g,pI=/\u001B(?:\[[0-9;?]*[A-HJKSTfhilmnprsu]|\][^\u0007\u001B]*(?:\u0007|\u001B\\)?|[()][0-9A-Z])/g;function mI(e){return Math.max(0,Math.min(255,e))}function hI(e){return e===0?0:55+e*40}function gI(e,t){let n=t?uI:dI;if(e<16)return n[e]??n[7];if(e<232){let t=e-16;return`rgb(${hI(Math.floor(t/36))} ${hI(Math.floor(t%36/6))} ${hI(t%6)})`}let r=8+(e-232)*10;return`rgb(${r} ${r} ${r})`}function _I(){return{fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1}}function vI(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,_I());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?uI:dI)[i-30]??null;else if(i>=90&&i<=97)e.fg=(n?uI:dI)[i-90+8]??null;else if(i>=40&&i<=47)e.bg=(n?uI:dI)[i-40]??null;else if(i>=100&&i<=107)e.bg=(n?uI:dI)[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]=gI(mI(r[t+2]),n),t+=2):o===2&&(e[a]=`rgb(${mI(r[t+2]??0)} ${mI(r[t+3]??0)} ${mI(r[t+4]??0)})`,t+=4)}}}function yI(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 bI(e){return e.includes(`\x1B`)}function xI(e,t=!0){if(!bI(e))return[{text:e,fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1}];let n=[],r=_I(),i=0;fI.lastIndex=0;let a=fI.exec(e);for(;a!==null;)yI(n,e.slice(i,a.index).replace(pI,``),r),vI(r,a[1]??``,t),i=a.index+a[0].length,a=fI.exec(e);return yI(n,e.slice(i).replace(pI,``),r),n}function SI(e){let t=new Date(e);return`${t.toLocaleTimeString(void 0,{hour12:!1})}.${String(t.getMilliseconds()).padStart(3,`0`)}`}function CI(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 wI(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 TI(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 EI(e){return e===null?`—`:`${(e*100).toFixed(e>=.999?0:1)}%`}function DI(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 OI(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 kI(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 AI(e){return e===null||!Number.isFinite(e)?`—`:e>=100?`${Math.round(e)}%`:`${e.toFixed(1)}%`}function jI(e){return e===void 0?`unset`:typeof e==`string`?e:JSON.stringify(e)}var MI={class:`flex h-5 w-max min-w-full items-center gap-2 whitespace-pre px-2 font-mono text-xs leading-5`},NI={key:0,class:`shrink-0 select-none text-faint`},PI={class:`min-w-0`},FI=N({__name:`LogRow`,props:{line:{},query:{},dark:{type:Boolean},showTime:{type:Boolean}},setup(e){let t=e,n=U(()=>xI(t.line.text,t.dark)),r=U(()=>{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)=>(I(),L(`div`,MI,[t.showTime?(I(),L(`span`,NI,O(j(SI)(t.line.ts)),1)):H(``,!0),z(`span`,{class:D([`h-3.5 w-0.5 shrink-0 rounded-full`,[i[t.line.stream]]]),"aria-hidden":`true`},null,2),z(`span`,PI,[(I(!0),L(F,null,ya(r.value,(e,t)=>(I(),L(`span`,{key:t,style:_e(a(e))},O(e.text),5))),128))])]))}}),II={class:`inline-flex items-center gap-0.5 rounded-control border border-line bg-panel-2 p-0.5`},LI=[`aria-pressed`,`onClick`],RI=N({__name:`SegmentedControl`,props:Ba({options:{},size:{default:`sm`}},{modelValue:{default:``},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=co(e,`modelValue`);return(e,r)=>(I(),L(`div`,II,[(I(!0),L(F,null,ya(t.options,e=>(I(),L(`button`,{key:e.value,type:`button`,class:D(j(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},O(e.label),11,LI))),128))]))}}),zI={class:`flex min-h-0 flex-col overflow-hidden rounded-panel border border-line bg-panel`},BI={class:`flex flex-wrap items-center gap-2 border-b border-line bg-panel-2/60 px-2.5 py-2`},VI={class:`relative min-w-40 flex-1 sm:max-w-72`},HI={class:`absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5`},UI={key:0,class:`px-1 font-mono text-2xs tabular-nums text-faint`},WI={class:`ml-auto flex items-center gap-1.5`},GI=[`href`,`download`],KI={class:`relative min-h-0 flex-1`},qI={key:0,class:`px-3 py-6 text-center text-xs text-faint`},JI={class:`flex items-center gap-3 border-t border-line bg-panel-2/60 px-2.5 py-1.5 text-2xs text-faint`},YI={class:`flex items-center gap-1.5`},XI={class:`font-mono tabular-nums`},ZI={key:0,class:`font-mono tabular-nums`},QI=20,$I=12,eL=N({__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=BM(),a=A(null),o=A(0),s=A(320),c=A(!0),l=A(`all`),u=A(``),d=A(!0),f=A(0),p=U(()=>{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=U(()=>p.value.length),h=U(()=>{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=U(()=>Math.max(0,Math.floor(o.value/QI)-$I)),_=U(()=>Math.min(m.value,Math.ceil((o.value+s.value)/QI)+$I)),v=U(()=>p.value.slice(g.value,_.value)),y=U(()=>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*QI-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]))}jr(m,()=>{c.value&&(f.value=0,requestAnimationFrame(x))}),jr(h,()=>{f.value=0,h.value.length>0&&u.value.trim().length>0&&requestAnimationFrame(()=>S(h.value[0]))}),jr(l,()=>{c.value=!0,requestAnimationFrame(x)});let w=null;na(()=>{let e=a.value;e&&(s.value=e.clientHeight,w=new ResizeObserver(()=>{a.value&&(s.value=a.value.clientHeight)}),w.observe(e),x())}),Be(()=>{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)=>(I(),L(`div`,zI,[z(`header`,BI,[B(RI,{modelValue:l.value,"onUpdate:modelValue":t[0]||=e=>l.value=e,options:T},null,8,[`modelValue`]),z(`div`,VI,[B(j(by),{class:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),xr(z(`input`,{"onUpdate:modelValue":t[1]||=e=>u.value=e,type:`search`,placeholder:`Search this output`,class:D([`h-7 py-0 pl-7 text-xs`,[j(SF)]]),"aria-label":`Search the log output`,onKeydown:t[2]||=fu(uu(e=>C(e.shiftKey?-1:1),[`prevent`]),[`enter`])},null,34),[[Yl,u.value]]),z(`div`,HI,[u.value.trim().length>0?(I(),L(`span`,UI,O(h.value.length===0?`0`:`${f.value+1}/${h.value.length}`),1)):H(``,!0),u.value.length>0?(I(),L(`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=``},[B(j(Ny),{class:`size-3`})])):H(``,!0),h.value.length>0?(I(),L(`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)},[B(j(zv),{class:`size-3`})])):H(``,!0),h.value.length>0?(I(),L(`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)},[B(j(Iv),{class:`size-3`})])):H(``,!0)])]),z(`div`,WI,[B(TF,{label:d.value?`Hide timestamps`:`Show timestamps`},{default:M(()=>[B($,{size:`xs`,variant:`ghost`,onClick:t[6]||=e=>d.value=!d.value},{default:M(()=>[B(j(Uv),{class:D(j(Q)(`size-3`,d.value?`fill-accent text-accent`:`text-faint`))},null,8,[`class`]),t[9]||=V(` ts `,-1)]),_:1})]),_:1},8,[`label`]),B($,{size:`xs`,variant:c.value?`secondary`:`primary`,onClick:t[7]||=e=>c.value?c.value=!1:x()},{default:M(()=>[(I(),R(ha(c.value?j(dy):j(py)),{class:`size-3`})),V(` `+O(c.value?`Pause`:`Follow`),1)]),_:1},8,[`variant`]),n.clearable?(I(),R(TF,{key:0,label:`Clear the in-memory buffer`},{default:M(()=>[B($,{size:`icon-sm`,variant:`ghost`,"aria-label":`Clear the log buffer`,onClick:t[8]||=e=>r(`clear`)},{default:M(()=>[B(j(jy),{class:`size-3.5`})]),_:1})]),_:1})):H(``,!0),n.downloadUrl?(I(),R(TF,{key:1,label:`Download the persisted file`},{default:M(()=>[z(`a`,{href:n.downloadUrl,download:n.downloadName},[B($,{size:`icon-sm`,variant:`ghost`,"aria-label":`Download the log file`},{default:M(()=>[B(j(Pv),{class:`size-3.5`})]),_:1})],8,GI)]),_:1})):H(``,!0)])]),z(`div`,KI,[z(`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:_e({minHeight:n.minHeight}),tabindex:`0`,role:`log`,"aria-label":`Log output`,onScrollPassive:b},[m.value===0?(I(),L(`p`,qI,O(n.lines.length===0?n.emptyHint:`Nothing matches that search or stream filter.`),1)):(I(),L(`div`,{key:1,class:`relative w-full`,style:_e({height:`${m.value*QI}px`})},[(I(!0),L(F,null,ya(v.value,(e,t)=>(I(),L(`div`,{key:g.value+t,class:D([`absolute left-0 top-0`,g.value+t===y.value&&`bg-warn/10`]),style:_e({transform:`translateY(${(g.value+t)*QI}px)`})},[B(FI,{line:e,query:u.value,dark:j(i).isDark.value,"show-time":d.value},null,8,[`line`,`query`,`dark`,`show-time`])],6))),128))],4))],36),B(Oc,{"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:M(()=>[!c.value&&m.value>0?(I(),L(`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},[B(j(Pv),{class:`size-3`}),t[10]||=V(` Jump to latest `,-1)])):H(``,!0)]),_:1})]),z(`footer`,JI,[z(`span`,YI,[z(`span`,{class:D(j(Q)(`size-1.5 rounded-full`,n.live?c.value?`bg-ok`:`bg-warn`:`bg-faint`))},null,2),V(` `+O(n.live?c.value?`streaming`:`paused`:`snapshot`),1)]),z(`span`,XI,O(m.value===n.lines.length?`${m.value} lines`:`${m.value} of ${n.lines.length} lines`),1),u.value.trim().length>0?(I(),L(`span`,ZI,O(h.value.length)+` matches`,1)):H(``,!0),z(`span`,{class:`ml-auto hidden font-mono tabular-nums sm:inline`},`row height `+O(QI)+`px · windowed`)])]))}}),tL={key:0,class:`grid size-10 place-items-center rounded-full border border-line bg-panel-2 text-faint`},nL={class:`max-w-sm space-y-1`},rL={class:`text-sm font-medium text-ink`},iL={key:0,class:`text-xs leading-relaxed text-muted`},aL={key:1,class:`flex items-center gap-2`},oL=N({__name:`EmptyState`,props:{title:{},description:{default:void 0},compact:{type:Boolean,default:!1}},setup(e){return(e,t)=>(I(),L(`div`,{class:D(j(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?(I(),L(`div`,tL,[P(e.$slots,`icon`)])):H(``,!0),z(`div`,nL,[z(`p`,rL,O(e.$props.title),1),e.$props.description?(I(),L(`p`,iL,O(e.$props.description),1)):H(``,!0)]),e.$slots.action?(I(),L(`div`,aL,[P(e.$slots,`action`)])):H(``,!0)],2))}}),sL={class:`flex shrink-0 items-start justify-between gap-4 border-b border-line px-4 py-3`},cL={class:`min-w-0`},lL={class:`min-h-0 flex-1 overflow-y-auto px-4 py-3.5`},uL={key:0,class:`flex shrink-0 items-center justify-end gap-2 border-t border-line bg-panel-2 px-4 py-3`},dL=N({__name:`Modal`,props:Ba({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=co(e,`open`);return(e,r)=>(I(),R(j(uf),{open:n.value,"onUpdate:open":r[0]||=e=>n.value=e},{default:M(()=>[B(j(Xf),null,{default:M(()=>[B(j(Jf),{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]`}),B(j(Gf),{class:D(j(Q)(`fixed left-1/2 top-1/2 z-50 flex max-h-[88dvh] -translate-x-1/2 -translate-y-1/2 flex-col 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:M(()=>[z(`header`,sL,[z(`div`,cL,[B(j(Zf),{class:`text-sm font-semibold text-ink`},{default:M(()=>[V(O(t.title),1)]),_:1}),t.description?(I(),R(j(Kf),{key:0,class:`mt-0.5 text-xs text-muted`},{default:M(()=>[V(O(t.description),1)]),_:1})):H(``,!0)]),B(j(df),{class:D(j(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`,j(yF))),"aria-label":`Close`},{default:M(()=>[B(j(Ny),{class:`size-4`})]),_:1},8,[`class`])]),z(`div`,lL,[P(e.$slots,`default`)]),e.$slots.footer?(I(),L(`footer`,uL,[P(e.$slots,`footer`)])):H(``,!0)]),_:3},8,[`class`])]),_:3})]),_:3},8,[`open`]))}}),fL=[`for`],pL={class:`relative`},mL=[`id`],hL=[`value`,`disabled`],gL={key:1,class:`text-2xs text-danger`},_L=N({inheritAttrs:!1,__name:`SelectField`,props:Ba({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=co(e,`modelValue`),r=ui();return(e,i)=>(I(),L(`div`,{class:D(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(I(),L(`label`,{key:0,for:j(r),class:D(j(bF))},O(t.label),11,fL)):H(``,!0),z(`div`,pL,[xr(z(`select`,Ns({id:j(r),"onUpdate:modelValue":i[0]||=e=>n.value=e,class:j(Q)(j(SF),`cursor-pointer appearance-none pr-7`,t.mono&&`font-mono text-xs`,t.error&&`border-danger`)},e.$attrs),[(I(!0),L(F,null,ya(t.options,e=>(I(),L(`option`,{key:e.value,value:e.value,disabled:e.disabled},O(e.label),9,hL))),128))],16,mL),[[$l,n.value]]),B(j(Iv),{class:`pointer-events-none absolute right-2 top-1/2 size-3.5 -translate-y-1/2 text-faint`,"aria-hidden":`true`})]),t.error?(I(),L(`p`,gL,O(t.error),1)):t.hint?(I(),L(`p`,{key:2,class:D(j(xF))},O(t.hint),3)):H(``,!0)],2))}}),vL=N({__name:`Skeleton`,props:{class:{default:`h-4 w-24`},rounded:{default:`rounded`}},setup(e){return(t,n)=>(I(),L(`span`,{class:D(j(Q)(`block animate-pulse bg-line-soft`,e.rounded,t.$props.class)),style:{"animation-duration":`1.4s`},"aria-hidden":`true`},null,2))}}),yL={class:`flex h-full min-h-0`},bL={class:`hidden w-64 shrink-0 flex-col border-r border-line bg-panel/40 md:flex`},xL={class:`border-b border-line px-3 py-2.5`},SL={class:`mt-0.5 text-2xs text-faint`},CL={class:`min-h-0 flex-1 overflow-y-auto p-1.5`},wL={key:0,class:`space-y-1.5 p-1.5`},TL=[`onClick`],EL={class:`min-w-0 flex-1`},DL={class:`block truncate font-mono text-2xs text-faint`},OL={class:`flex min-w-0 flex-1 flex-col`},kL={class:`flex flex-wrap items-center gap-2 border-b border-line bg-panel/40 px-3 py-2.5`},AL={class:`min-w-0`},jL={class:`truncate text-sm font-semibold text-ink`},ML={key:0,class:`ml-1.5 font-mono text-2xs font-normal text-faint`},NL={key:0,class:`flex flex-wrap items-center gap-1.5 border-b border-line-soft bg-panel-2/40 px-3 py-2`},PL=[`href`,`download`],FL={class:`text-faint`},IL={key:1,class:`text-2xs text-faint`},LL={key:2,class:`ml-auto font-mono text-2xs text-faint`},RL={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`},zL={class:`min-h-0 flex-1 p-3`},BL=N({__name:`LogsView`,setup(e){let t=Bg(),n=zg(),r=A([]),i=A(null),a=A(`disk`),o=A(`2000`),s=A(!1),c=A(null),l=A([]),u=A(0),d=A(!1),f=A(!0),p=U(()=>r.value.find(e=>e.serverId===i.value)??null),m=AM(()=>a.value===`live`?i.value:null),h=m.version,g=U(()=>(h.value,m.lines())),_=U(()=>a.value===`live`?g.value:l.value),v=U(()=>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=U(()=>r.value.reduce((e,t)=>e+t.sizeBytes,0)),x=U(()=>r.value.filter(e=>e.files.length>0).length);async function S(){f.value=!0;try{r.value=await yj();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 bj(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 xj(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 jr([i,o,a],()=>{a.value===`disk`&&C()},{immediate:!1}),na(async()=>{await S(),a.value===`disk`&&await C()}),(e,t)=>(I(),L(`div`,yL,[z(`aside`,bL,[z(`div`,xL,[t[5]||=z(`p`,{class:`text-xs font-semibold text-ink`},` Persisted logs `,-1),z(`p`,SL,O(x.value)+` of `+O(r.value.length)+` servers on disk · `+O(j(OI)(b.value)),1)]),z(`div`,CL,[f.value?(I(),L(`div`,wL,[(I(),L(F,null,ya(5,e=>B(vL,{key:e,class:`h-10 w-full`,rounded:`rounded-control`})),64))])):(I(!0),L(F,{key:1},ya(r.value,e=>(I(),L(`button`,{key:e.serverId,type:`button`,class:D(j(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)},[z(`span`,{class:D(j(Q)(`size-1.5 shrink-0 rounded-full`,j(yP)[j(hP)[e.status].tone]))},null,2),z(`span`,EL,[z(`span`,{class:D(j(Q)(`block truncate text-xs`,e.serverId===i.value?`font-medium text-accent`:`text-ink`))},O(e.label),3),z(`span`,DL,O(e.files.length>0?`${e.files.length} file${e.files.length===1?``:`s`} · ${j(OI)(e.sizeBytes)}`:`nothing persisted`),1)])],10,TL))),128)),!f.value&&r.value.length===0?(I(),R(oL,{key:2,compact:``,title:`No servers`,description:`Add one and its output will be persisted here.`})):H(``,!0)]),t[6]||=z(`div`,{class:`border-t border-line p-2.5`},[z(`p`,{class:`text-2xs leading-4 text-faint`},` Rotation and retention are set under Settings → Log storage. `)],-1)]),z(`div`,OL,[z(`header`,kL,[z(`div`,AL,[z(`h1`,jL,[V(O(p.value?.label??`Logs`)+` `,1),p.value?(I(),L(`span`,ML,O(p.value.serverId),1)):H(``,!0)])]),B(RI,{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`?(I(),R(_L,{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`])):H(``,!0),a.value===`disk`?(I(),R($,{key:1,size:`sm`,loading:s.value,onClick:C},{default:M(()=>[B(j(gy),{class:`size-3.5`}),t[7]||=V(`Reload `,-1)]),_:1},8,[`loading`])):H(``,!0),a.value===`disk`?(I(),R($,{key:2,size:`sm`,variant:`ghost`,disabled:!p.value||p.value.files.length===0,onClick:t[2]||=e=>d.value=!0},{default:M(()=>[B(j(jy),{class:`size-3.5`}),t[8]||=V(`Clear file `,-1)]),_:1},8,[`disabled`])):H(``,!0)]),p.value?(I(),L(`div`,NL,[B(j($v),{class:`size-3.5 shrink-0 text-faint`}),p.value.files.length>0?(I(!0),L(F,{key:0},ya(p.value.files,e=>(I(),L(`a`,{key:e.name,href:Sj(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`},[V(O(e.name)+` `,1),z(`span`,FL,O(j(OI)(e.sizeBytes)),1),B(j(Pv),{class:`size-3`})],8,PL))),128)):(I(),L(`span`,IL,` Nothing on disk for this server — persistence is off, or it has not written anything yet. `)),a.value===`disk`&&l.value.length>0?(I(),L(`span`,LL,` loaded `+O(l.value.length)+` lines `,1)):H(``,!0)])):H(``,!0),c.value?(I(),L(`p`,RL,[B(j(Bv),{class:`size-3.5`}),V(` `+O(c.value),1)])):H(``,!0),z(`div`,zL,[p.value?s.value&&_.value.length===0?(I(),R(vL,{key:1,class:`h-full w-full`,rounded:`rounded-panel`})):(I(),R(eL,{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`])):(I(),R(oL,{key:0,title:`Pick a server`,description:`Persisted output and live streams are per server. Choose one from the list.`},{icon:M(()=>[B(j(yy),{class:`size-4`})]),_:1}))])]),B(dL,{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:M(()=>[B($,{variant:`ghost`,onClick:t[3]||=e=>d.value=!1},{default:M(()=>[...t[9]||=[V(` Keep it `,-1)]]),_:1}),B($,{variant:`danger`,onClick:w},{default:M(()=>[B(j(jy),{class:`size-3.5`}),t[10]||=V(`Clear `,-1)]),_:1})]),default:M(()=>[t[11]||=z(`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`])]))}}),VL=N({__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=U(()=>t.value===null||!Number.isFinite(t.value)?0:Math.min(100,Math.max(0,t.value))),r=U(()=>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)=>(I(),L(`div`,{class:D(j(Q)(`w-full overflow-hidden rounded-full bg-line-soft`,t.height,t.class))},[z(`div`,{class:D(j(Q)(`h-full rounded-full transition-[width] duration-300 ease-out`,i[r.value])),style:_e({width:`${n.value}%`})},null,6)],2))}}),HL={key:1,class:`space-y-4`},UL={class:`grid grid-cols-2 gap-3 sm:grid-cols-4`},WL={class:`grid grid-cols-2 gap-x-4 gap-y-2 border-t border-line-soft pt-3 sm:grid-cols-4`},GL={class:`flex items-center gap-1 text-2xs text-faint`},KL={class:`font-mono text-xs text-ink`},qL={class:`font-mono text-xs tabular-nums text-ink`},JL={class:`flex items-center gap-1 text-2xs text-faint`},YL={class:`font-mono text-xs text-ink`},XL={class:`flex items-center gap-1 text-2xs text-faint`},ZL={class:`font-mono text-xs text-ink`},QL={class:`space-y-2 border-t border-line-soft pt-3`},$L={class:`flex items-center gap-1.5 text-2xs font-medium text-faint`},eR={class:`flex items-baseline justify-between gap-2`},tR=[`title`],nR={class:`shrink-0 font-mono text-2xs tabular-nums text-faint`},rR={key:0,class:`space-y-1 rounded-control border border-danger/25 bg-danger-soft px-2.5 py-2`},iR=N({__name:`HostVitalsPanel`,props:{host:{},now:{}},setup(e){let t=e,n=U(()=>{let e=t.host;return e?(e.loadAvg[0]??0)/Math.max(1,e.cpus):null}),r=U(()=>t.host?.loadAvg.map(e=>e.toFixed(2)).join(` `)??`—`);return(e,i)=>!t.host||!t.host.enabled?(I(),R(oL,{key:0,compact:``,title:`Host sampling is off`,description:`Turn it on in Settings to collect load, memory, disk and temperature.`})):(I(),L(`div`,HL,[z(`div`,UL,[B(BP,{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`]),B(BP,{value:t.host.memoryUsedPercent,label:`Memory`,size:72},null,8,[`value`]),B(BP,{value:t.host.swapUsedPercent,label:`Swap`,size:72,"warn-at":50},null,8,[`value`]),B(BP,{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`])]),z(`dl`,WL,[z(`div`,null,[z(`dt`,GL,[B(j(qv),{class:`size-3`}),i[0]||=V(`CPUs `,-1)]),z(`dd`,KL,O(t.host.cpus),1)]),z(`div`,null,[i[1]||=z(`dt`,{class:`text-2xs text-faint`},` Load 1 / 5 / 15 `,-1),z(`dd`,qL,O(r.value),1)]),z(`div`,null,[z(`dt`,JL,[B(j(sy),{class:`size-3`}),i[2]||=V(`Memory used `,-1)]),z(`dd`,YL,O(t.host.memoryUsedPercent.toFixed(0))+`% `,1)]),z(`div`,null,[z(`dt`,XL,[B(j(ky),{class:`size-3`}),i[3]||=V(`Sampled `,-1)]),z(`dd`,ZL,O(j(DI)(t.host.sampledAt,t.now)),1)])]),z(`div`,QL,[z(`p`,$L,[B(j(ey),{class:`size-3`}),i[4]||=V(`Filesystems `,-1)]),(I(!0),L(F,null,ya(t.host.disks,e=>(I(),L(`div`,{key:e.path,class:`space-y-1`},[z(`div`,eR,[z(`span`,{class:`truncate font-mono text-2xs text-muted`,title:e.path},O(e.path),9,tR),z(`span`,nR,O(j(OI)(e.totalBytes-e.freeBytes))+` / `+O(j(OI)(e.totalBytes))+` · `+O(e.usedPercent.toFixed(0))+`% `,1)]),B(VL,{value:e.usedPercent},null,8,[`value`])]))),128))]),t.host.alerts.length>0?(I(),L(`div`,rR,[i[5]||=z(`p`,{class:`text-2xs font-medium text-danger`},` Thresholds breached `,-1),(I(!0),L(F,null,ya(t.host.alerts,e=>(I(),L(`p`,{key:e,class:`text-2xs text-danger`},O(e),1))),128))])):H(``,!0)]))}}),aR={key:1,class:`flex flex-col`},oR={class:`min-w-0 flex-1`},sR={class:`flex items-baseline gap-1.5`},cR={class:`truncate text-xs font-medium text-ink`},lR=[`title`],uR={key:0,class:`text-muted`},dR={class:`shrink-0 pt-0.5 text-2xs text-faint`},fR=N({__name:`ActivityFeed`,props:{servers:{},now:{},limit:{default:12},serverId:{default:void 0}},setup(e){let t=e,n={start:py,exit:Ey,crash:Bv,"forced-restart":vy,unhealthy:My,recovered:Vv},r=U(()=>{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=pa(`RouterLink`);return r.value.length===0?(I(),R(oL,{key:0,compact:``,title:`No events in the last 24 hours`,description:`Starts, exits, crashes and recoveries show up here as they happen.`})):(I(),L(`ol`,aR,[(I(!0),L(F,null,ya(r.value,(e,r)=>(I(),L(`li`,{key:`${e.serverId}-${e.ts}-${r}`,class:D([`flex items-start gap-2.5 border-line-soft py-2`,r>0&&`border-t`])},[(I(),R(ha(n[e.type]),{class:D(j(Q)(`mt-0.5 size-3.5 shrink-0`,j(_P)[j(SP)[e.type]]))},null,8,[`class`])),z(`div`,oR,[z(`p`,sR,[z(`span`,cR,O(j(xP)[e.type]),1),B(a,{to:`/servers/${e.serverId}`,class:`truncate text-2xs text-muted hover:text-accent`},{default:M(()=>[V(O(e.label),1)]),_:2},1032,[`to`])]),z(`p`,{class:`mt-0.5 truncate font-mono text-2xs text-faint`,title:e.detail},[V(O(e.detail)+` `,1),e.runtimeMs===void 0?H(``,!0):(I(),L(`span`,uR,` · ran `+O(j(wI)(e.runtimeMs)),1))],8,lR)]),z(`span`,dR,O(j(DI)(e.ts,t.now)),1)],2))),128))]))}}}),pR=[`restart`,`health`,`stop`];function mR(e,t){return JSON.stringify(hR(e))===JSON.stringify(hR(t))}function hR(e){if(Array.isArray(e))return e.map(hR);if(typeof e==`object`&&e){let t={};for(let n of Object.keys(e).sort()){let r=e[n];r!=null&&(t[n]=hR(r))}return t}return e??null}function gR(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??{}))mR(t[e],r)||(n[e]=r);Object.keys(n).length>0&&(r[i]=n);continue}mR(e[i],a)||(r[i]=a)}return r}function _R(e,t){let n=e;return gR({...n,label:n.label??``},t,pR)}function vR(e,t=``){return typeof e!=`object`||!e||Array.isArray(e)?[{path:t,value:e}]:Object.entries(e).flatMap(([e,n])=>vR(n,t.length===0?e:`${t}.${e}`))}function yR(e,t){let n=new Map(vR(t).map(e=>[e.path,e.value]));return vR(e).map(e=>({path:e.path,from:n.get(e.path),to:e.value}))}function bR(e){let t=0;for(let n of Object.values(e))t+=typeof n==`object`&&n&&!Array.isArray(n)?bR(n):1;return t}async function xR(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 SR={enabled:!0,maxRetries:3,baseDelayMs:1e3,factor:2,maxDelayMs:3e4,resetAfterMs:6e4},CR={enabled:!0,mode:`port`,http:{path:`/`,method:`GET`,expectStatusBelow:400,expectBody:``},intervalMs:5e3,timeoutMs:1500,unhealthyThreshold:3,forceRestartAfterMs:0,startTimeoutMs:2e4},wR={signal:`SIGTERM`,killGroup:!0,graceMs:5e3,killPortHolders:!1};function TR(e){return{...e,http:{...e.http}}}function ER(){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:{...SR},health:TR(CR),stop:{...wR}},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 DR(e){return{enabled:e.enabled,sessionTtlMs:e.sessionTtlMs,cookieSecure:e.cookieSecure,trustProxy:e.trustProxy,maxLoginAttempts:e.maxLoginAttempts,lockoutMs:e.lockoutMs}}function OR(e){return{label:e.label,port:e.port,host:e.host,openBrowser:e.openBrowser,tlsEnabled:e.tls.enabled}}function kR(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 AR(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function jR(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 MR(e){return{enabled:e.enabled,keep:e.keep,includePaths:e.includePaths.join(`, `)}}function NR(e,t){return gR(e,{...t,diskPaths:AR(t.diskPaths)})}function PR(e,t){return gR(e,{...t,includePaths:AR(t.includePaths)})}function FR(e,t){return gR({label:e.label,port:e.port,host:e.host,openBrowser:e.openBrowser,auth:DR(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 IR(e,t){return gR(e,t,[`restart`,`health`,`stop`])}function LR(e,t){return gR(e,t)}function RR(e,t){return gR({telegram:kR(e)},{telegram:{...t}},[`telegram`])}function zR(e,t){switch(t){case`control`:return{...e.control,auth:{...e.auth}};case`defaults`:return{...e.defaults,restart:{...e.defaults.restart},health:TR(e.defaults.health),stop:{...e.defaults.stop}};case`logs`:return{...e.logs};case`telegram`:return{...e.telegram};case`host`:return{...e.host};case`backups`:return{...e.backups}}}function BR(e,t,n){let r=t[n];return r!==void 0&&JSON.stringify(r)!==JSON.stringify(zR(e,n))}function VR(e,t){return e.label!==t.control.label||e.port!==t.control.port||e.host!==t.control.host||e.openBrowser!==t.control.openBrowser}function HR(e,t){return e.tls.enabled!==t.control.tlsEnabled}function UR(e,t){return bR(gR({...DR(e.auth)},{...t.auth}))>0}function WR(e,t,n){return U({get:e,set:e=>{t(e===null||Number.isNaN(e)?n:e)}})}async function GR(e){if(!e.rebinding)return null;let t=e.targetUrl??e.control.url;return t.length===0||t===window.location.origin?null:await xR(t)?(window.location.replace(t),null):`The control panel did not answer on ${t}. Check the console for the new listener.`}function KR(e){return e.split(`
39
+ fn("string", ":", "number")(s => s.length)`,mD=class extends Pb{$;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 Pb{$;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&&G(vD),this.branches.length&&G(_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&&G(`default may only be specified as the last key of a switch definition`),this.default(r);if(typeof r!=`function`)return G(`Value for case "${n}" must be a function (was ${Ky(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(Sb(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=ub(e);for(let[e,a]of i){let i=ED(e);if(i.kind===`spread`){if(!lb(r))return G(TD);let e=t.$.parseOwnDefinitionFormat(a,t);if(e.equals(eE.object))continue;if(!e.hasKind(`intersection`)||!e.basis?.equals(eE.object))return G(DD(e.expression));n=e.structure;continue}if(i.kind===`undeclared`){a!==`reject`&&a!==`delete`&&a!==`ignore`&&G(wD(a)),r.undeclared=a;continue}let o=yD(a,t),s=i;if(i.kind===`required`){Sb(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(Sb(o)&&(o[1]===`?`&&G(bD),o[1]===`=`&&G(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=zy(r.index,c.index)),c.required&&(r.required=zy(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]=zy(e[t],r.$.node(t,n))},wD=e=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${Sx(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 G(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]):G(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]):G(ND(`:`,e[2])),FD=(e,t)=>t.$.parseOwnDefinitionFormat(e[0],t).configure(e[2],e[3]),ID=e=>e,LD=ID({"[]":jD,"?":()=>G(yE)}),RD=ID({"|":AD,"&":AD,":":PD,"=>":MD,"|>":AD,"@":FD,"=":()=>G(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 G(UD(xb(e[1])));let n=e.slice(1).map(e=>typeof e==`function`?t.$.node(`proto`,{proto:e}):G(UD(xb(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]=Sb(a)?a:[a];if(r++,i){if(!o.extends(K.intrinsic.Array))return G(XD(o.expression));n=n.flatMap(e=>o.distribute(t=>YD(qx(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=>lb(e)?{proto:Array,exactLength:0}:{proto:Array,sequence:e}))},GD=(e,t)=>e.defaultables||e.optionals?G(e.variadic?nT:QD):(e.variadic?e.postfix=zy(e.postfix,t):e.prefix=zy(e.prefix,t),e),KD=(e,t)=>e.variadic?G($D):(e.optionals=zy(e.optionals,t),e),qD=(e,t,n)=>e.variadic?G($D):e.optionals?G(eO):(e.defaultables=zy(e.defaultables,[[t,n]]),e),JD=(e,t)=>(e.postfix&&G(ZD),e.variadic?e.variadic.equals(t)||G(ZD):e.variadic=t.internal,e),YD=(e,t)=>{let n=t.select({method:`find`,kind:`sequence`});if(!n)return JD(e,K.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 Gy(e,`object`)?rO(e,t):G(oO(Ky(e)))},rO=(e,t)=>{let n=bb(e);switch(n){case void 0:return q(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=Mb(e)?e():e;return q(t,`root`)?t:G(oO(`Function`))}default:return G(oO(n??Sx(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:zb(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 Pb{constructor(e){let t=Object.assign({errors:bS,hkt:Ib,$: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=K,lO=class e extends IT{get ambientAttachments(){if(cO.typeAttachments)return this.cacheGetter(`ambientAttachments`,eb(cO.typeAttachments,(e,t)=>[e,this.bindReference(t)]))}preparseOwnAliasEntry(e,t){let n=e.indexOf(`<`);if(n===-1){if(q(t,`module`)||q(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]!==`>`&&G(`'>' 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 Nx(e),[],this.createParseContext({...t,def:e,prefix:`generic`}))}normalizeRootScopeValue(e){return Mb(e)&&!q(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(Sb(n)){if(n[1]===`=`)return G(bE);if(n[1]===`?`)return G(yE)}return n}unit=e=>this.units([e]);valueOf=e=>this.units(mb(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 Ib{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 Ib{},gO=YT(`element`)(e=>{let t=e.element.exclude(eE.Array),n=t.array();return t.rawOr(n).pipe(Py).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`,mx.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 mx.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({...eb({...hb,..._b},(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(ex,`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=eb(tk,(e,t)=>[t,qT({domain:`string`,predicate:e=>e.normalize(t)===e,meta:`${t}-normalized unicode`})]),rk=eb(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(Zb,`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 Ib{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 Ib{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 Ib{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 Ib{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 Ib{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 Ib{description='exclude branches of a union like `Exclude("boolean", "true")`'},Lk=YT(`T`,`U`)(e=>e.T.exclude(e.U),Ik),Rk=class extends Ib{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.enumerated(`block`,`warn`,`follow`,`reclaim`,`kill`),qk=Kk.default(`block`),Jk=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`),Yk=Y({path:`string = "/"`,method:`"GET" | "HEAD" = "GET"`,expectStatus:`number.integer | null?`,expectStatusBelow:`number.integer = 400`,expectBody:`string = ""`}).onUndeclaredKey(`reject`),Xk=Y({maxRssBytes:`number.integer >= 0 = 0`}).onUndeclaredKey(`reject`),Zk=Y({enabled:`boolean = true`,mode:`"port" | "http" = "port"`,http:Yk.default(()=>({})),intervalMs:`number >= 500 = 5000`,timeoutMs:`number >= 100 = 1500`,unhealthyThreshold:`number.integer >= 1 = 3`,forceRestartAfterMs:`number >= 0 = 0`,startTimeoutMs:`number >= 0 = 20000`}).onUndeclaredKey(`reject`),Qk=Y({signal:`"SIGTERM" | "SIGINT" | "SIGKILL" = "SIGTERM"`,killGroup:`boolean = true`,graceMs:`number >= 0 = 5000`,killPortHolders:`boolean = false`}).onUndeclaredKey(`reject`),$k=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`)),eA=Y(`50 <= number.integer <= 100000`),tA=Y({id:`/^[a-z0-9][a-z0-9_-]*$/`,label:`string?`,enabled:`boolean = true`,autostart:`boolean = false`,persistent:`boolean = false`,command:`string >= 1`,args:Y(`string[]`).default(()=>[]),cwd:`string = "."`,env:Y(`Record<string, string>`).default(()=>({})),dataEnvs:Y(`Record<string, string>`).default(()=>({})),bootstrap:$k.optional(),port:Gk.optional(),bind:Uk.default(()=>`local`),onPortConflict:qk,restart:Jk.default(()=>({})),health:Zk.default(()=>({})),stop:Qk.default(()=>({})),logBufferLines:eA.default(()=>500),dependsOn:Y(`string[]`).default(()=>[]),envFile:`string = ""`,resources:Xk.default(()=>({})),backupPaths:Y(`string[]`).default(()=>[]),backupIgnoreGenerated:`boolean = true`}).onUndeclaredKey(`reject`),nA=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 rA=Y({persist:`boolean = true`,maxBytes:`10000 <= number <= 100000000 = 2000000`,keep:`1 <= number.integer <= 10 = 3`}).onUndeclaredKey(`reject`),iA=Y({enabled:`boolean = false`}).onUndeclaredKey(`reject`),aA=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:nA.default(()=>({})),tls:iA.default(()=>({}))}).onUndeclaredKey(`reject`);var oA=Y({enabled:`boolean = true`,autostart:`boolean = false`,bind:Uk.default(()=>`local`),onPortConflict:qk,restart:Jk.default(()=>({})),health:Zk.default(()=>({})),stop:Qk.default(()=>({})),logBufferLines:eA.default(()=>500)}).onUndeclaredKey(`reject`),sA=Y({enabled:`boolean?`,maxRetries:`number.integer >= 0?`,baseDelayMs:`number >= 0?`,factor:`number >= 1?`,maxDelayMs:`number >= 0?`,resetAfterMs:`number >= 0?`}).onUndeclaredKey(`reject`),cA=Y({path:`string?`,method:`"GET" | "HEAD"?`,expectStatus:`number.integer | null?`,expectStatusBelow:`number.integer?`,expectBody:`string?`}).onUndeclaredKey(`reject`),lA=Y({maxRssBytes:`number.integer >= 0?`}).onUndeclaredKey(`reject`),uA=Y({enabled:`boolean?`,mode:`"port" | "http"?`,http:cA.optional(),intervalMs:`number >= 500?`,timeoutMs:`number >= 100?`,unhealthyThreshold:`number.integer >= 1?`,forceRestartAfterMs:`number >= 0?`,startTimeoutMs:`number >= 0?`}).onUndeclaredKey(`reject`),dA=Y({signal:`"SIGTERM" | "SIGINT" | "SIGKILL"?`,killGroup:`boolean?`,graceMs:`number >= 0?`,killPortHolders:`boolean?`}).onUndeclaredKey(`reject`),fA=Y({enabled:`boolean?`,sessionTtlMs:`number >= 60000?`,cookieSecure:`"auto" | "always" | "never"?`,trustProxy:`boolean?`,maxLoginAttempts:`number.integer >= 1?`,lockoutMs:`number >= 1000?`}).onUndeclaredKey(`reject`),pA=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`),mA=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`),hA=Y({enabled:`boolean?`,dir:`string?`,keep:`number.integer >= 1?`,includePaths:Y(`string[]`).optional()}).onUndeclaredKey(`reject`),gA=Y({persist:`boolean?`,maxBytes:`10000 <= number <= 100000000?`,keep:`1 <= number.integer <= 10?`}).onUndeclaredKey(`reject`),_A=Y({enabled:`boolean?`}).onUndeclaredKey(`reject`),vA=Y({label:`1 <= string <= 60?`,port:`1 <= number.integer <= 65535?`,host:Uk.optional(),openBrowser:`boolean?`,auth:fA.optional(),tls:_A.optional()}).onUndeclaredKey(`reject`),yA=Y({enabled:`boolean?`,autostart:`boolean?`,bind:Uk.optional(),onPortConflict:Kk.optional(),restart:sA.optional(),health:uA.optional(),stop:dA.optional(),logBufferLines:eA.optional()}).onUndeclaredKey(`reject`),bA={label:`string?`,enabled:`boolean?`,autostart:`boolean?`,persistent:`boolean?`,command:`string?`,args:`string[]?`,cwd:`string?`,env:`Record<string, string>?`,dataEnvs:`Record<string, string>?`,bootstrap:$k.optional(),port:Gk.optional(),bind:Uk.optional(),onPortConflict:Kk.optional(),restart:sA.optional(),health:uA.optional(),stop:dA.optional(),logBufferLines:eA.optional(),dependsOn:Y(`string[]`).optional(),envFile:`string?`,resources:lA.optional(),backupPaths:Y(`string[]`).optional(),backupIgnoreGenerated:`boolean?`},xA=Y(bA).onUndeclaredKey(`reject`),SA=Y({id:`/^[a-z0-9][a-z0-9_-]*$/`,...bA,command:`string`}).onUndeclaredKey(`reject`);Y({serverId:`string`,command:`string`,args:`string[]`,cwd:`string`,env:`Record<string, string>`,logDir:`string`,logs:rA,stop:Qk}).onUndeclaredKey(`reject`),Y({serverId:`string`,nannyPid:`number`,childPid:`number | null`,startedAt:`number`,logFile:`string`,heartbeatAt:`number`,"lastExit?":Y({code:`number | null`,signal:`string | null`,at:`number`,runtimeMs:`number`}).onUndeclaredKey(`reject`)}).onUndeclaredKey(`reject`);var CA=Y({control:vA.optional(),defaults:yA.optional(),logs:gA.optional(),notifications:pA.optional(),host:mA.optional(),backups:hA.optional()}).onUndeclaredKey(`reject`),wA=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`}),TA=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`}),EA=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 DA=Y({password:`string`}).onUndeclaredKey(`reject`),OA=Y(`1 <= string <= 512`),kA=Y({currentPassword:`string?`,newPassword:OA}).onUndeclaredKey(`reject`),AA=Y(`"stopped" | "starting" | "running" | "stopping" | "backoff" | "crashed" | "conflict"`),jA=Y(`"disabled" | "unknown" | "healthy" | "unhealthy"`),MA=Y(`"unknown" | "free" | "in-use"`),NA=Y({ts:`number`,stream:Y(`"stdout" | "stderr" | "system"`),text:`string`}),PA=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()}),FA=Y({cpuPercent:`number | null`,rssBytes:`number | null`,processes:`number`,sampledAt:`number`}),IA=Y({path:`string`,totalBytes:`number`,freeBytes:`number`,usedPercent:`number`}),LA=Y({enabled:`boolean`,cpus:`number`,loadAvg:Y(`number[]`),uptimeMs:`number`,memoryUsedPercent:`number`,swapUsedPercent:`number`,tempCelsius:`number | null`,disks:IA.array(),alerts:Y(`string[]`),sampledAt:`number | null`}),RA=Y({name:`string`,sizeBytes:`number`,createdAt:`number`,encrypted:`boolean`}),zA=Y({path:`string`,origin:`string`,included:`boolean`,note:`string | null`,ignoreGenerated:`boolean?`}),BA=Y({enabled:`boolean`,dir:`string`,keep:`number`,includePaths:Y(`string[]`),paths:zA.array(),files:RA.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:OA.optional()}).onUndeclaredKey(`reject`),Y({name:`string?`,password:OA.optional(),include:Y(`string[]`).optional()}).onUndeclaredKey(`reject`);var VA=Y({id:`string`,config:tA,bindHost:`string`,url:`string | null`,status:AA,health:jA,portState:MA,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:PA,responseMs:`number | null`,resources:FA.or(Y(`null`))}),HA=Y({label:`string`,port:`number`,host:`string`,bindHost:`string`,url:`string`,openBrowser:`boolean`,restartRequired:`boolean`,protocol:`string`,auth:wA,tls:TA}),UA=Y({control:HA,defaults:oA,logs:rA,notifications:EA,host:LA,backups:BA,configPath:`string`,configError:`string | null`,projectDir:`string`,dataRoot:`string`,logsDir:`string`,servers:VA.array()}),WA=Y({type:`"hello" | "state" | "log" | "server"`,ts:`number`,serverId:`string?`,state:UA.optional(),server:VA.optional(),lines:NA.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 GA=Y({servers:Y({serverId:`string`,label:`string`,status:AA,enabled:`boolean`,sizeBytes:`number`,files:Y({name:`string`,sizeBytes:`number`}).array()}).array()}),KA=Y({serverId:`string`,enabled:`boolean`,sizeBytes:`number`,files:Y(`string[]`),searched:`number | null`,lines:NA.array()});Y({botToken:`string?`,chatId:`string?`}).onUndeclaredKey(`reject`),Y({botToken:`string >= 1`}).onUndeclaredKey(`reject`),Y({message:`string`,code:`string`,detail:`unknown`}).onUndeclaredKey(`reject`);var qA=Y({custom:`boolean`,dir:`string`,meta:Y({"name?":`string`,"version?":`string | null`,"uploadedAt?":`number`,"files?":`number.integer >= 1`,"repo?":`string`,"tag?":`string`,"asset?":`string`,"unix?":`number.integer >= 0`}).or(Y(`null`))});Y({certificate:`string >= 1`,privateKey:`string >= 1`}).onUndeclaredKey(`reject`),Y({control:HA,defaults:oA,logs:rA,notifications:EA,host:aA,backups:BA,ui:qA}).and(Y({rebinding:`boolean`,targetUrl:`string | null`}));var JA=/^[\w!#$%&'*.^`|~+-]+$/,YA=(e,t,n={})=>{if(!JA.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},XA=(e,t,n)=>(t=encodeURIComponent(t),YA(e,t,n)),ZA=(e,t)=>(e=e.replace(/\/+$/,``),e+=`/`,t=t.replace(/^\/+/,``),e+t),QA=(e,t)=>{for(let[n,r]of Object.entries(t)){let t=RegExp(`/:`+n+`(?:{[^/]+})?\\??(?=/|$)`);e=e.replace(t,()=>r?`/${r}`:``)}return e},$A=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},ej=(e,t)=>{switch(t){case`ws`:return e.replace(/^http/,`ws`);case`http`:return e.replace(/^ws/,`http`)}},tj=e=>/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(e)?e.replace(/\/index(?=\?|$)/,`/`):e.replace(/\/index(?=\?|$)/,``);function nj(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rj(e,t){if(!nj(e)&&!nj(t))return t;let n={...e};for(let e in t){let r=t[e];n[e]=nj(n[e])&&nj(r)?rj(n[e],r):r}return n}var ij=(e,t)=>new Proxy(()=>{},{get(n,r){if(typeof r==`string`&&r!==`then`)return ij(e,[...t,r])},apply(n,r,i){return e({path:t,args:i})}}),aj=(e,t)=>{let n=t.toString();return n?`${e}?${n}`:e},oj=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(XA(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=tj(a),a=QA(a,this.pathParams),this.queryParams&&(a=aj(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})}},sj=((e,t)=>ij(function n(r){let i=t?.buildSearchParams??$A,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=ZA(e,a.join(`/`));if(s===`url`||s===`path`){let t=tj(c);return r.args[0]&&(r.args[0].param&&(t=QA(t,r.args[0].param)),r.args[0].query&&(t=aj(t,i(r.args[0].query)))),s===`url`?new URL(t):t.slice(e.replace(/\/+$/,``).length).replace(/^\/?/,`/`)}if(s===`ws`){let e=tj(c),n=ej(r.args[0]?.param?QA(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 oj(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=rj(t,e);return l.fetch(r.args[0],a)}return l},[]))(typeof window>`u`?`http://127.0.0.1`:window.location.origin),cj=class extends Error{name=`AuthRequiredError`;constructor(){super(`authentication required`)}};function lj(e){return typeof e==`object`&&!!e}async function uj(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&&lj(i)&&i.code===`AUTH_REQUIRED`)throw new cj;let e=lj(i)&&typeof i.message==`string`?i.message:lj(i)&&`error`in i?String(i.error):`request failed with ${n.status}`;throw Error(e)}return i}async function dj(){let e=UA(await uj(`/api/state`));if(e instanceof Y.errors)throw Error(`state contract mismatch: ${e.summary}`);return e}function fj(){return uj(`/api/auth/session`)}function pj(e){let t=DA({password:e});if(t instanceof Y.errors)throw Error(t.summary);return uj(`/api/auth/login`,{method:`POST`,body:JSON.stringify(t)})}function mj(){return uj(`/api/auth/logout`,{method:`POST`})}function hj(e,t){let n=kA(e===void 0?{newPassword:t}:{currentPassword:e,newPassword:t});if(n instanceof Y.errors)throw Error(n.summary);return uj(`/api/auth/password`,{method:`POST`,body:JSON.stringify(n)})}function gj(){return uj(`/api/auth/password`,{method:`DELETE`})}function _j(){return uj(`/api/settings`)}function vj(e){let t=CA(e);if(t instanceof Y.errors)throw Error(t.summary);return uj(`/api/settings`,{method:`PATCH`,body:JSON.stringify(t)})}async function yj(){let e=GA(await uj(`/api/logs`));if(e instanceof Y.errors)throw Error(`logs contract mismatch: ${e.summary}`);return e.servers}async function bj(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=KA(await uj(`/api/logs/${encodeURIComponent(e)}?${n.toString()}`));if(r instanceof Y.errors)throw Error(`log history contract mismatch: ${r.summary}`);return r}function xj(e){return uj(`/api/logs/${encodeURIComponent(e)}`,{method:`DELETE`})}function Sj(e,t){return`/api/logs/${encodeURIComponent(e)}/download?file=${encodeURIComponent(t)}`}function Cj(e){return uj(`/api/backups`,{method:`POST`,body:JSON.stringify(e===void 0||e.length===0?{}:{password:e})})}function wj(e){return uj(`/api/backups/${encodeURIComponent(e)}`,{method:`DELETE`})}function Tj(e){return`/api/backups/${encodeURIComponent(e)}/download`}function Ej(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 Dj(e,t,n={}){return uj(`/api/backups/restore?confirm=${t}`,{method:`POST`,body:JSON.stringify({name:e,...Ej(n)})})}async function Oj(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 kj(e){return uj(`/api/notifications/token`,{method:`PUT`,body:JSON.stringify({botToken:e})})}function Aj(){return uj(`/api/notifications/token`,{method:`DELETE`})}function jj(e){return uj(`/api/notifications/test`,{method:`POST`,body:JSON.stringify(e)})}function Mj(e){return uj(`/api/notifications/detect-chats`,{method:`POST`,body:JSON.stringify(e)})}async function Nj(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 Pj(){return uj(`/api/settings/ui`,{method:`DELETE`})}function Fj(e,t){return uj(`/api/settings/tls`,{method:`POST`,body:JSON.stringify({certificate:e,privateKey:t})})}function Ij(){return uj(`/api/settings/tls`,{method:`DELETE`})}async function Lj(e,t){let n=await sj.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 Rj(){return uj(`/api/servers/start-all`,{method:`POST`})}async function zj(e){let t=await sj.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 Bj(){return uj(`/api/servers/stop-all`,{method:`POST`})}function Vj(e){return uj(`/api/servers/${encodeURIComponent(e)}/clear-logs`,{method:`POST`})}function Hj(e,t){return uj(`/api/servers/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)})}function Uj(e){return uj(`/api/servers/${encodeURIComponent(e)}`,{method:`DELETE`})}function Wj(e){return uj(`/api/servers`,{method:`POST`,body:JSON.stringify(e)})}var Gj=A(null),Kj=A(null);function qj(e){return e===null?`wait`:e.authRequired&&!e.authenticated?`login`:`connect`}function Jj(){async function e(){try{Gj.value=await fj()}catch{Gj.value=null}}async function t(e){Kj.value=null;try{return Gj.value=await pj(e),!0}catch(e){return Kj.value=e instanceof Error?e.message:String(e),!1}}async function n(){try{await mj()}finally{await e()}}function r(){Gj.value={authenticated:!1,authRequired:!0,passwordSet:Gj.value?.passwordSet??!0,apiTokenSet:Gj.value?.apiTokenSet??!1,usingDefaultPassword:Gj.value?.usingDefaultPassword??!1,defaultPassword:Gj.value?.defaultPassword??null,sessionTtlMs:Gj.value?.sessionTtlMs??0}}async function i(t,n){Kj.value=null;try{return await hj(t,n),await e(),null}catch(e){return e instanceof Error?e.message:String(e)}}async function a(){Kj.value=null;try{return await gj(),await e(),null}catch(e){return e instanceof Error?e.message:String(e)}}return{session:rn(Gj),error:rn(Kj),refresh:e,login:t,logout:n,requireLogin:r,setPassword:i,clearPassword:a}}var Yj=A([]),Xj=1;function Zj(e){Yj.value=Yj.value.filter(t=>t.id!==e)}function Qj(e,t=4800){let n=Xj++;return Yj.value=[...Yj.value,{...e,id:n}],t>0&&setTimeout(Zj,t,n),n}function $j(){return{toasts:rn(Yj),dismiss:Zj,push:Qj,success:(e,t)=>Qj({tone:`ok`,title:e,description:t}),failure:(e,t)=>Qj({tone:`danger`,title:e,description:t},9e3),info:(e,t)=>Qj({tone:`info`,title:e,description:t}),warn:(e,t)=>Qj({tone:`warn`,title:e,description:t},7e3)}}var eM=4e3;function tM(){return tn({ts:[],cpu:[],rss:[],probe:[],lastSampledAt:-1})}function nM(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 rM(e,t,n){let r=t.resources?.sampledAt??0,i=e.ts[e.ts.length-1]??0;if(!(r!==e.lastSampledAt||n-i>=eM)){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),nM(e)}function iM(e){let t=0;for(let n of e)n!==null&&n>t&&(t=n);return t}function aM(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n!=null)return n}return null}var oM=8e3,sM=A(null),cM=A(`connecting`),lM=A(null),uM=A(Date.now()),dM=new Map,fM=$j(),pM=new Map,mM=A(0),hM=null,gM=null;function _M(e){let t=pM.get(e);if(t)return t;let n={lines:[],version:A(0),refs:0,source:null};return pM.set(e,n),n}function vM(e,t){let n=_M(e),r=n.lines.concat(t);n.lines=r.length>8e3?r.slice(r.length-oM):r,n.version.value+=1,mM.value+=1}function yM(e){return pM.get(e)?.lines??[]}function bM(e){let t=pM.get(e);t&&(t.lines=[],t.version.value+=1,mM.value+=1)}function xM(e){let t=dM.get(e);if(t)return t;let n=tM();return dM.set(e,n),n}function SM(e){rM(xM(e.id),e,Date.now())}function CM(e){let t=sM.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 wM(e){let t;try{t=JSON.parse(e)}catch{return}let n=WA(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){sM.value=n.state;for(let e of sM.value.servers)SM(e)}return}if(n.type===`server`&&n.server){let e=n.server;CM(e),SM(e);return}n.type===`log`&&n.serverId&&n.lines&&vM(n.serverId,n.lines)}function TM(e,t){let n=new EventSource(`/api/servers/${encodeURIComponent(e)}/stream`),r=e=>wM(e.data);for(let e of[`log`,`server`])n.addEventListener(e,r);n.onerror=()=>{},t.source=n}function EM(e){let t=_M(e);t.refs+=1,t.source||TM(e,t)}function DM(e){let t=pM.get(e);t&&(t.refs=Math.max(0,t.refs-1),t.refs===0&&(t.source?.close(),t.source=null))}function OM(){if(hM)return;gM??=setInterval(()=>{uM.value=Date.now()},1e3);let e=new EventSource(`/api/events?logs=0`);hM=e,cM.value=`connecting`,e.onopen=()=>{cM.value=`open`},e.onerror=()=>{cM.value=`closed`};for(let t of[`hello`,`state`,`server`,`log`])e.addEventListener(t,e=>{wM(e.data)})}function kM(){hM?.close(),hM=null,gM&&clearInterval(gM),gM=null}function AM(e){let t=U(()=>yn(e)),n=null;return jr(t,e=>{n!==null&&n!==e&&DM(n),n=e,e!==null&&e.length>0&&EM(e)},{immediate:!0}),Be(()=>{n!==null&&DM(n),n=null}),{version:U(()=>{let e=t.value;return mM.value,e===null?0:pM.get(e)?.version.value??0}),lines(){let e=t.value;return e===null?[]:yM(e)},count:U(()=>{let e=t.value;return mM.value,e===null?0:pM.get(e)?.lines.length??0}),clear(){let e=t.value;e!==null&&bM(e)}}}function jM(){let e=U(()=>sM.value?.servers??[]),t=U(()=>sM.value?.control??null),n=U(()=>sM.value?.defaults??null),r=U(()=>sM.value?.host??null),i=U(()=>sM.value?.backups??null),a=U(()=>sM.value?.notifications??null),o=U(()=>sM.value?.logs??null),s=U(()=>sM.value?.configError??null);function c(e){return sM.value?.servers.find(t=>t.id===e)}function l(e){return xM(e)}async function u(e,t){lM.value=null;try{let n=await e();sM.value=await dj();let r=typeof t.success==`function`?t.success(n):t.success;return r&&fM.success(r),n}catch(e){if(e instanceof cj){Jj().requireLogin();return}let n=e instanceof Error?e.message:String(e);lM.value=n,fM.failure(t.title,n);return}}return{appState:rn(sM),servers:e,control:t,defaults:n,host:r,backups:i,notifications:a,logsConfig:o,configError:s,connection:rn(cM),lastError:rn(lM),now:rn(uM),serverById:c,seriesOf:l,refresh:(e=`Refresh failed`)=>u(async()=>{},{title:e}),start:e=>u(()=>Lj(e,`start`),{title:`Could not start ${e}`}),stop:e=>u(()=>Lj(e,`stop`),{title:`Could not stop ${e}`}),restart:e=>u(()=>Lj(e,`restart`),{title:`Could not restart ${e}`}),startAll:()=>u(()=>Rj(),{title:`Could not start every server`,success:`Starting every enabled server`}),stopAll:()=>u(()=>Bj(),{title:`Could not stop every server`,success:`Stopping every server`}),setAutostart:(e,t)=>u(()=>Hj(e,{autostart:t}),{title:`Could not change autostart for ${e}`}),setEnabled:(e,t)=>u(()=>Hj(e,{enabled:t}),{title:`Could not change ${e}`}),freePort:e=>u(()=>zj(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?(fM.failure(`Could not change the bind for ${e}`,`"${t}" is not a bind value`),Promise.resolve(void 0)):u(()=>Hj(e,{bind:n}),{title:`Could not change the bind for ${e}`})},saveConfig:(e,t)=>u(()=>Hj(e,t),{title:`Could not save ${e}`,success:`${e} updated`}),saveSettings:e=>u(()=>vj(e),{title:`Could not save the settings`}),clearLogs:e=>u(async()=>{await Vj(e),bM(e)},{title:`Could not clear the logs for ${e}`,success:`Buffer cleared`}),create:e=>u(()=>Wj(e),{title:`Could not add the server`,success:`Server added`}),remove:e=>u(async()=>{await Uj(e),DM(e),pM.delete(e),dM.delete(e)},{title:`Could not remove ${e}`,success:`${e} removed`})}}var MM=`hh.theme`;function NM(){try{let e=localStorage.getItem(MM);if(e===`light`||e===`dark`||e===`system`)return e}catch{}return`system`}var PM=A(NM()),FM=A(typeof matchMedia<`u`&&matchMedia(`(prefers-color-scheme: dark)`).matches),IM=!1;function LM(){IM||typeof matchMedia>`u`||(IM=!0,matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,e=>{FM.value=e.matches,zM()}))}var RM=U(()=>PM.value===`system`?FM.value:PM.value===`dark`);function zM(){typeof document<`u`&&document.documentElement.classList.toggle(`dark`,RM.value)}function BM(){LM(),zM();function e(e){PM.value=e;try{localStorage.setItem(MM,e)}catch{}zM()}return{preference:PM,isDark:RM,setPreference:e,cycle(){e(PM.value===`light`?`dark`:PM.value===`dark`?`system`:`light`)}}}function VM(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=VM(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function HM(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=VM(e))&&(r&&(r+=` `),r+=t);return r}var UM=(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},WM=(e,t)=>({classGroupId:e,validator:t}),GM=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),KM=`-`,qM=[],JM=`arbitrary..`,YM=e=>{let t=QM(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return ZM(e);let n=e.split(KM);return XM(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?UM(i,t):t:i||qM}return n[e]||qM}}},XM=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=XM(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(KM):e.slice(t).join(KM),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},ZM=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?JM+r:void 0})(),QM=e=>{let{theme:t,classGroups:n}=e;return $M(n,t)},$M=(e,t)=>{let n=GM();for(let r in e){let i=e[r];eN(i,n,r,t)}return n},eN=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];tN(i,t,n,r)}},tN=(e,t,n,r)=>{if(typeof e==`string`){nN(e,t,n);return}if(typeof e==`function`){rN(e,t,n,r);return}iN(e,t,n,r)},nN=(e,t,n)=>{let r=e===``?t:aN(t,e);r.classGroupId=n},rN=(e,t,n,r)=>{if(oN(e)){eN(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(WM(n,e))},iN=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];eN(o,aN(t,a),n,r)}},aN=(e,t)=>{let n=e,r=t.split(KM),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=GM(),n.nextPart.set(t,i)),n=i}return n},oN=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,sN=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)}}},cN=`!`,lN=`:`,uN=[],dN=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),fN=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===lN){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(cN)?(c=s.slice(0,-1),l=!0):s.startsWith(cN)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return dN(t,l,c,u)};if(t){let e=t+lN,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):dN(uN,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},pN=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}},mN=e=>({cache:sN(e.cacheSize),parseClassName:fN(e),sortModifiers:pN(e),postfixLookupClassGroupIds:hN(e),...YM(e)}),hN=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},gN=/\s+/,_N=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(gN),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?_+cN:_,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},vN=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=yN(n))&&(i&&(i+=` `),i+=r);return i},yN=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=yN(e[r]))&&(n&&(n+=` `),n+=t);return n},bN=(e,...t)=>{let n,r,i,a,o=o=>(n=mN(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=_N(e,n);return i(e,a),a};return a=o,(...e)=>a(vN(...e))},xN=[],SN=e=>{let t=t=>t[e]||xN;return t.isThemeGetter=!0,t.themeKey=e,t},CN=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,wN=/^\((?:(\w[\w-]*):)?(.+)\)$/i,TN=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,EN=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,DN=/\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$/,ON=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,kN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,AN=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,jN=e=>TN.test(e),MN=e=>!!e&&!Number.isNaN(Number(e)),NN=e=>!!e&&Number.isInteger(Number(e)),PN=e=>e.endsWith(`%`)&&MN(e.slice(0,-1)),FN=e=>EN.test(e),IN=()=>!0,LN=e=>DN.test(e)&&!ON.test(e),RN=()=>!1,zN=e=>kN.test(e),BN=e=>AN.test(e),VN=e=>!X(e)&&!Z(e),HN=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)),UN=e=>iP(e,cP,RN),X=e=>CN.test(e),WN=e=>iP(e,lP,LN),GN=e=>iP(e,uP,MN),KN=e=>iP(e,fP,IN),qN=e=>iP(e,dP,RN),JN=e=>iP(e,oP,RN),YN=e=>iP(e,sP,BN),XN=e=>iP(e,pP,zN),Z=e=>wN.test(e),ZN=e=>aP(e,lP),QN=e=>aP(e,dP),$N=e=>aP(e,oP),eP=e=>aP(e,cP),tP=e=>aP(e,sP),nP=e=>aP(e,pP,!0),rP=e=>aP(e,fP,!0),iP=(e,t,n)=>{let r=CN.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},aP=(e,t,n=!1)=>{let r=wN.exec(e);return r?r[1]?t(r[1]):n:!1},oP=e=>e===`position`||e===`percentage`,sP=e=>e===`image`||e===`url`,cP=e=>e===`length`||e===`size`||e===`bg-size`,lP=e=>e===`length`,uP=e=>e===`number`,dP=e=>e===`family-name`,fP=e=>e===`number`||e===`weight`,pP=e=>e===`shadow`,mP=bN(()=>{let e=SN(`color`),t=SN(`font`),n=SN(`text`),r=SN(`font-weight`),i=SN(`tracking`),a=SN(`leading`),o=SN(`breakpoint`),s=SN(`container`),c=SN(`spacing`),l=SN(`radius`),u=SN(`shadow`),d=SN(`inset-shadow`),f=SN(`text-shadow`),p=SN(`drop-shadow`),m=SN(`blur`),h=SN(`perspective`),g=SN(`aspect`),_=SN(`ease`),v=SN(`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=()=>[jN,`full`,`auto`,...w()],ee=()=>[NN,`none`,`subgrid`,Z,X],te=()=>[`auto`,{span:[`full`,NN,Z,X]},NN,Z,X],ne=()=>[NN,`auto`,Z,X],re=()=>[`auto`,`min`,`max`,`fr`,Z,X],ie=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],ae=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],oe=()=>[`auto`,...w()],se=()=>[jN,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ce=()=>[s,jN,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],le=()=>[jN,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],E=()=>[e,Z,X],ue=()=>[...b(),$N,JN,{position:[Z,X]}],de=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],fe=()=>[`auto`,`cover`,`contain`,eP,UN,{size:[Z,X]}],pe=()=>[PN,ZN,WN],me=()=>[``,`none`,`full`,l,Z,X],he=()=>[``,MN,ZN,WN],ge=()=>[`solid`,`dashed`,`dotted`,`double`],_e=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],ve=()=>[MN,PN,$N,JN],ye=()=>[``,`none`,m,Z,X],be=()=>[`none`,MN,Z,X],xe=()=>[`none`,MN,Z,X],D=()=>[MN,Z,X],Se=()=>[jN,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[FN],breakpoint:[FN],color:[IN],container:[FN],"drop-shadow":[FN],ease:[`in`,`out`,`in-out`],font:[VN],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[FN],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[FN],shadow:[FN],spacing:[`px`,MN],text:[FN],"text-shadow":[FN],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,jN,X,Z,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,Z,X]}],"container-named":[HN],columns:[{columns:[MN,`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:[NN,`auto`,Z,X]}],basis:[{basis:[jN,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[MN,jN,`auto`,`initial`,`none`,X]}],grow:[{grow:[``,MN,Z,X]}],shrink:[{shrink:[``,MN,Z,X]}],order:[{order:[NN,`first`,`last`,`none`,Z,X]}],"grid-cols":[{"grid-cols":ee()}],"col-start-end":[{col:te()}],"col-start":[{"col-start":ne()}],"col-end":[{"col-end":ne()}],"grid-rows":[{"grid-rows":ee()}],"row-start-end":[{row:te()}],"row-start":[{"row-start":ne()}],"row-end":[{"row-end":ne()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":re()}],"auto-rows":[{"auto-rows":re()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...ie(),`normal`]}],"justify-items":[{"justify-items":[...ae(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...ae()]}],"align-content":[{content:[`normal`,...ie()]}],"align-items":[{items:[...ae(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...ae(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":ie()}],"place-items":[{"place-items":[...ae(),`baseline`]}],"place-self":[{"place-self":[`auto`,...ae()]}],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:oe()}],mx:[{mx:oe()}],my:[{my:oe()}],ms:[{ms:oe()}],me:[{me:oe()}],mbs:[{mbs:oe()}],mbe:[{mbe:oe()}],mt:[{mt:oe()}],mr:[{mr:oe()}],mb:[{mb:oe()}],ml:[{ml:oe()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:se()}],"inline-size":[{inline:[`auto`,...ce()]}],"min-inline-size":[{"min-inline":[`auto`,...ce()]}],"max-inline-size":[{"max-inline":[`none`,...ce()]}],"block-size":[{block:[`auto`,...le()]}],"min-block-size":[{"min-block":[`auto`,...le()]}],"max-block-size":[{"max-block":[`none`,...le()]}],w:[{w:[s,`screen`,...se()]}],"min-w":[{"min-w":[s,`screen`,`none`,...se()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...se()]}],h:[{h:[`screen`,`lh`,...se()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...se()]}],"max-h":[{"max-h":[`screen`,`lh`,`none`,...se()]}],"font-size":[{text:[`base`,n,ZN,WN]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,rP,KN]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,PN,X]}],"font-family":[{font:[QN,qN,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":[MN,`none`,Z,GN]}],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:E()}],"text-color":[{text:E()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...ge(),`wavy`]}],"text-decoration-thickness":[{decoration:[MN,`from-font`,`auto`,Z,WN]}],"text-decoration-color":[{decoration:E()}],"underline-offset":[{"underline-offset":[MN,`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:[NN,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:ue()}],"bg-repeat":[{bg:de()}],"bg-size":[{bg:fe()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},NN,Z,X],radial:[``,Z,X],conic:[``,NN,Z,X]},tP,YN]}],"bg-color":[{bg:E()}],"gradient-from-pos":[{from:pe()}],"gradient-via-pos":[{via:pe()}],"gradient-to-pos":[{to:pe()}],"gradient-from":[{from:E()}],"gradient-via":[{via:E()}],"gradient-to":[{to:E()}],rounded:[{rounded:me()}],"rounded-s":[{"rounded-s":me()}],"rounded-e":[{"rounded-e":me()}],"rounded-t":[{"rounded-t":me()}],"rounded-r":[{"rounded-r":me()}],"rounded-b":[{"rounded-b":me()}],"rounded-l":[{"rounded-l":me()}],"rounded-ss":[{"rounded-ss":me()}],"rounded-se":[{"rounded-se":me()}],"rounded-ee":[{"rounded-ee":me()}],"rounded-es":[{"rounded-es":me()}],"rounded-tl":[{"rounded-tl":me()}],"rounded-tr":[{"rounded-tr":me()}],"rounded-br":[{"rounded-br":me()}],"rounded-bl":[{"rounded-bl":me()}],"border-w":[{border:he()}],"border-w-x":[{"border-x":he()}],"border-w-y":[{"border-y":he()}],"border-w-s":[{"border-s":he()}],"border-w-e":[{"border-e":he()}],"border-w-bs":[{"border-bs":he()}],"border-w-be":[{"border-be":he()}],"border-w-t":[{"border-t":he()}],"border-w-r":[{"border-r":he()}],"border-w-b":[{"border-b":he()}],"border-w-l":[{"border-l":he()}],"divide-x":[{"divide-x":he()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":he()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...ge(),`hidden`,`none`]}],"divide-style":[{divide:[...ge(),`hidden`,`none`]}],"border-color":[{border:E()}],"border-color-x":[{"border-x":E()}],"border-color-y":[{"border-y":E()}],"border-color-s":[{"border-s":E()}],"border-color-e":[{"border-e":E()}],"border-color-bs":[{"border-bs":E()}],"border-color-be":[{"border-be":E()}],"border-color-t":[{"border-t":E()}],"border-color-r":[{"border-r":E()}],"border-color-b":[{"border-b":E()}],"border-color-l":[{"border-l":E()}],"divide-color":[{divide:E()}],"outline-style":[{outline:[...ge(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[MN,Z,X]}],"outline-w":[{outline:[``,MN,ZN,WN]}],"outline-color":[{outline:E()}],shadow:[{shadow:[``,`inner`,`none`,u,nP,XN]}],"shadow-color":[{shadow:E()}],"inset-shadow":[{"inset-shadow":[`none`,d,nP,XN]}],"inset-shadow-color":[{"inset-shadow":E()}],"ring-w":[{ring:he()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:E()}],"ring-offset-w":[{"ring-offset":[MN,WN]}],"ring-offset-color":[{"ring-offset":E()}],"inset-ring-w":[{"inset-ring":he()}],"inset-ring-color":[{"inset-ring":E()}],"text-shadow":[{"text-shadow":[`none`,f,nP,XN]}],"text-shadow-color":[{"text-shadow":E()}],opacity:[{opacity:[MN,Z,X]}],"mix-blend":[{"mix-blend":[..._e(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":_e()}],"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":[MN]}],"mask-image-linear-from-pos":[{"mask-linear-from":ve()}],"mask-image-linear-to-pos":[{"mask-linear-to":ve()}],"mask-image-linear-from-color":[{"mask-linear-from":E()}],"mask-image-linear-to-color":[{"mask-linear-to":E()}],"mask-image-t-from-pos":[{"mask-t-from":ve()}],"mask-image-t-to-pos":[{"mask-t-to":ve()}],"mask-image-t-from-color":[{"mask-t-from":E()}],"mask-image-t-to-color":[{"mask-t-to":E()}],"mask-image-r-from-pos":[{"mask-r-from":ve()}],"mask-image-r-to-pos":[{"mask-r-to":ve()}],"mask-image-r-from-color":[{"mask-r-from":E()}],"mask-image-r-to-color":[{"mask-r-to":E()}],"mask-image-b-from-pos":[{"mask-b-from":ve()}],"mask-image-b-to-pos":[{"mask-b-to":ve()}],"mask-image-b-from-color":[{"mask-b-from":E()}],"mask-image-b-to-color":[{"mask-b-to":E()}],"mask-image-l-from-pos":[{"mask-l-from":ve()}],"mask-image-l-to-pos":[{"mask-l-to":ve()}],"mask-image-l-from-color":[{"mask-l-from":E()}],"mask-image-l-to-color":[{"mask-l-to":E()}],"mask-image-x-from-pos":[{"mask-x-from":ve()}],"mask-image-x-to-pos":[{"mask-x-to":ve()}],"mask-image-x-from-color":[{"mask-x-from":E()}],"mask-image-x-to-color":[{"mask-x-to":E()}],"mask-image-y-from-pos":[{"mask-y-from":ve()}],"mask-image-y-to-pos":[{"mask-y-to":ve()}],"mask-image-y-from-color":[{"mask-y-from":E()}],"mask-image-y-to-color":[{"mask-y-to":E()}],"mask-image-radial":[{"mask-radial":[Z,X]}],"mask-image-radial-from-pos":[{"mask-radial-from":ve()}],"mask-image-radial-to-pos":[{"mask-radial-to":ve()}],"mask-image-radial-from-color":[{"mask-radial-from":E()}],"mask-image-radial-to-color":[{"mask-radial-to":E()}],"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":[MN]}],"mask-image-conic-from-pos":[{"mask-conic-from":ve()}],"mask-image-conic-to-pos":[{"mask-conic-to":ve()}],"mask-image-conic-from-color":[{"mask-conic-from":E()}],"mask-image-conic-to-color":[{"mask-conic-to":E()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:ue()}],"mask-repeat":[{mask:de()}],"mask-size":[{mask:fe()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,Z,X]}],filter:[{filter:[``,`none`,Z,X]}],blur:[{blur:ye()}],brightness:[{brightness:[MN,Z,X]}],contrast:[{contrast:[MN,Z,X]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,nP,XN]}],"drop-shadow-color":[{"drop-shadow":E()}],grayscale:[{grayscale:[``,MN,Z,X]}],"hue-rotate":[{"hue-rotate":[MN,Z,X]}],invert:[{invert:[``,MN,Z,X]}],saturate:[{saturate:[MN,Z,X]}],sepia:[{sepia:[``,MN,Z,X]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,Z,X]}],"backdrop-blur":[{"backdrop-blur":ye()}],"backdrop-brightness":[{"backdrop-brightness":[MN,Z,X]}],"backdrop-contrast":[{"backdrop-contrast":[MN,Z,X]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,MN,Z,X]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[MN,Z,X]}],"backdrop-invert":[{"backdrop-invert":[``,MN,Z,X]}],"backdrop-opacity":[{"backdrop-opacity":[MN,Z,X]}],"backdrop-saturate":[{"backdrop-saturate":[MN,Z,X]}],"backdrop-sepia":[{"backdrop-sepia":[``,MN,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:[MN,`initial`,Z,X]}],ease:[{ease:[`linear`,`initial`,_,Z,X]}],delay:[{delay:[MN,Z,X]}],animate:[{animate:[`none`,v,Z,X]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,Z,X]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:be()}],"rotate-x":[{"rotate-x":be()}],"rotate-y":[{"rotate-y":be()}],"rotate-z":[{"rotate-z":be()}],scale:[{scale:xe()}],"scale-x":[{"scale-x":xe()}],"scale-y":[{"scale-y":xe()}],"scale-z":[{"scale-z":xe()}],"scale-3d":[`scale-3d`],skew:[{skew:D()}],"skew-x":[{"skew-x":D()}],"skew-y":[{"skew-y":D()}],transform:[{transform:[Z,X,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:Se()}],"translate-x":[{"translate-x":Se()}],"translate-y":[{"translate-y":Se()}],"translate-z":[{"translate-z":Se()}],"translate-none":[`translate-none`],zoom:[{zoom:[NN,Z,X]}],accent:[{accent:E()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:E()}],"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":E()}],"scrollbar-track-color":[{"scrollbar-track":E()}],"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`,...E()]}],"stroke-w":[{stroke:[MN,ZN,WN,GN]}],stroke:[{stroke:[`none`,...E()]}],"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 mP(HM(e))}var hP={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}},gP={disabled:{label:`Not checked`,tone:`neutral`},unknown:{label:`Not probed`,tone:`neutral`},healthy:{label:`Healthy`,tone:`ok`},unhealthy:{label:`Unhealthy`,tone:`danger`}},_P={ok:`text-ok`,warn:`text-warn`,danger:`text-danger`,info:`text-info`,neutral:`text-muted`,accent:`text-accent`},vP={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`},yP={ok:`bg-ok`,warn:`bg-warn`,danger:`bg-danger`,info:`bg-info`,neutral:`bg-faint`,accent:`bg-accent`};function bP(e,t){return e===`crashed`||e===`conflict`||t===`unhealthy`?`danger`:e===`starting`||e===`stopping`||e===`backoff`?`warn`:e===`running`?`ok`:`neutral`}var xP={start:`Started`,exit:`Exited`,crash:`Crashed`,"forced-restart":`Forced restart`,unhealthy:`Unhealthy`,recovered:`Recovered`},SP={start:`ok`,exit:`neutral`,crash:`danger`,"forced-restart":`warn`,unhealthy:`warn`,recovered:`info`},CP={class:`flex items-center gap-2.5 border-b border-line px-3.5`},wP={key:0,class:`px-3 py-8 text-center text-xs text-muted`},TP={class:`px-2.5 pb-1 pt-2.5 text-2xs font-medium text-faint`},EP=[`data-active`,`onMousemove`,`onClick`],DP={class:`min-w-0 flex-1 truncate text-sm`},OP={key:0,class:`shrink-0 font-mono text-2xs text-faint`},kP={class:`flex items-center gap-3 border-t border-line bg-panel-2 px-3.5 py-2 text-2xs text-faint`},AP={class:`ml-auto font-mono`},jP=N({__name:`CommandPalette`,props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:[`update:open`],setup(e){let t=co(e,`open`),n=zg(),r=jM(),i=BM(),a=A(``),o=A(0),s=A(null),c=A(null);function l(e){n.push(e)}function u(e){e(),t.value=!1}let d=[`stopped`,`crashed`,`conflict`],f=[`running`,`starting`,`backoff`],p=U(()=>{let e=[],t=r.appState.value?.servers??[];for(let n of t){let t=n.config.label??n.id,i=hP[n.status].label;e.push({id:`open:${n.id}`,title:`Open ${t}`,group:`Servers`,icon:xy,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:Oy,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:py,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:Ey,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:vy,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:ny,keywords:`dashboard home`,run:()=>l(`/`)},{id:`nav:servers`,title:`Go to Servers`,group:`Navigate`,icon:xy,keywords:`processes list`,run:()=>l(`/servers`)},{id:`nav:logs`,title:`Go to Logs`,group:`Navigate`,icon:yy,keywords:`output files tail`,run:()=>l(`/logs`)},{id:`nav:settings`,title:`Go to Settings`,group:`Navigate`,icon:Ty,keywords:`config panel`,run:()=>l(`/settings`)},{id:`act:start-all`,title:`Start every enabled server`,group:`Actions`,icon:py,keywords:`boot all`,run:()=>u(()=>void r.startAll())},{id:`act:stop-all`,title:`Stop every server`,group:`Actions`,icon:Ey,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:Ty,keywords:`configure ${t}`,run:()=>l(`/settings?section=${t}`)});let n=[[`light`,`Light`,Dy],[`dark`,`Dark`,ly],[`system`,`System`,cy]];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=U(()=>{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=U(()=>{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=U(()=>h.value.flatMap(([,e])=>e));jr(m,()=>{o.value=0}),jr(t,async e=>{e&&(a.value=``,o.value=0,await rr(),s.value?.focus())});function _(e){let t=g.value.length;t!==0&&(o.value=(o.value+e+t)%t,rr(()=>{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 na(()=>window.addEventListener(`keydown`,y)),Be(()=>window.removeEventListener(`keydown`,y)),(e,n)=>(I(),R(j(uf),{open:t.value,"onUpdate:open":n[2]||=e=>t.value=e},{default:M(()=>[B(j(Xf),null,{default:M(()=>[B(j(Jf),{class:`fixed inset-0 z-50 bg-black/40 backdrop-blur-[1px] data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`}),B(j(Gf),{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]||=uu(()=>{},[`prevent`]),onKeydown:v},{default:M(()=>[B(j(Zf),{class:`sr-only`},{default:M(()=>[...n[3]||=[V(` Command palette `,-1)]]),_:1}),z(`div`,CP,[B(j(by),{class:`size-4 shrink-0 text-faint`}),xr(z(`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),[[Yl,a.value]]),n[4]||=z(`kbd`,{class:`shrink-0 rounded border border-line bg-page px-1.5 py-0.5 font-mono text-2xs text-faint`},`esc`,-1)]),z(`div`,{ref_key:`list`,ref:c,class:`max-h-[min(60vh,26rem)] overflow-y-auto p-1.5`},[g.value.length===0?(I(),L(`p`,wP,` Nothing matches “`+O(a.value)+`”. `,1)):H(``,!0),(I(!0),L(F,null,ya(h.value,([e,t])=>(I(),L(F,{key:e},[z(`p`,TP,O(e),1),(I(!0),L(F,null,ya(t,e=>(I(),L(`button`,{key:e.id,type:`button`,"data-active":g.value[o.value]?.id===e.id,class:D(j(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()},[(I(),R(ha(e.icon),{class:D([`size-4 shrink-0`,g.value[o.value]?.id===e.id?`text-accent`:`text-faint`])},null,8,[`class`])),z(`span`,DP,O(e.title),1),e.detail?(I(),L(`span`,OP,O(e.detail),1)):H(``,!0),B(j(Rv),{class:D([`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,EP))),128))],64))),128))],512),z(`div`,kP,[n[5]||=z(`span`,null,[z(`kbd`,{class:`font-mono`},`↑↓`),V(` navigate`)],-1),n[6]||=z(`span`,null,[z(`kbd`,{class:`font-mono`},`↵`),V(` run`)],-1),z(`span`,AP,O(g.value.length)+` results`,1)])]),_:1})]),_:1})]),_:1},8,[`open`]))}}),MP={viewBox:`0 0 80 80`,class:`size-full -rotate-0`},NP=[`stroke-dasharray`],PP=[`stroke-dasharray`],FP={class:`absolute inset-0 grid place-items-center`},IP={class:`font-mono text-sm font-semibold tabular-nums text-ink`},LP={class:`text-2xs font-medium text-faint`},RP=34,zP=.75,BP=N({__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*RP,r=U(()=>t.value===null||!Number.isFinite(t.value)?0:Math.min(1,Math.max(0,t.value/100))*zP),i=U(()=>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)=>(I(),L(`div`,{class:D(j(Q)(`flex flex-col items-center gap-1`))},[z(`div`,{class:`relative`,style:_e({width:`${t.size}px`,height:`${t.size}px`})},[(I(),L(`svg`,MP,[z(`circle`,{cx:`40`,cy:`40`,r:RP,fill:`none`,class:`stroke-line-soft`,"stroke-width":6,"stroke-dasharray":`${zP*n} ${n}`,transform:`rotate(135 40 40)`,"stroke-linecap":`round`},null,8,NP),z(`circle`,{cx:`40`,cy:`40`,r:RP,fill:`none`,class:D([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,PP)])),z(`div`,FP,[z(`span`,IP,O(t.display??(t.value===null?`—`:`${Math.round(t.value)}%`)),1)])],4),z(`span`,LP,O(t.label),1)],2))}}),VP={class:`rounded-panel border border-line bg-panel-2/70 p-3`},HP={class:`mb-2 flex items-center justify-between`},UP={key:0,class:`text-2xs text-faint`},WP={key:0,class:`grid grid-cols-2 gap-x-1 gap-y-2`},GP={key:1,class:`py-3 text-center text-2xs text-faint`},KP={key:2,class:`mt-2 flex items-start gap-1.5 rounded-control bg-danger-soft px-2 py-1.5`},qP={class:`text-2xs leading-4 text-danger`},JP=2,YP=85,XP=N({__name:`InstrumentCluster`,props:{host:{}},setup(e){let t=e,n=U(()=>{let e=t.host;return e?(e.loadAvg[0]??0)/Math.max(1,e.cpus):null}),r=U(()=>n.value===null?null:n.value/JP*100),i=U(()=>n.value===null?`—`:n.value.toFixed(2)),a=U(()=>{let e=t.host?.disks??[];return e.length===0?null:Math.max(...e.map(e=>e.usedPercent))}),o=U(()=>{let e=t.host?.tempCelsius??null;return e===null?null:e/YP*100}),s=U(()=>{let e=t.host?.tempCelsius??null;return e===null?`n/a`:`${Math.round(e)}°`});return(e,n)=>(I(),L(`div`,VP,[z(`div`,HP,[n[0]||=z(`span`,{class:`text-2xs font-medium text-faint`},`Host vitals`,-1),t.host?.enabled===!1?(I(),L(`span`,UP,`off`)):H(``,!0)]),t.host?.enabled?(I(),L(`div`,WP,[B(BP,{value:r.value,label:`Load / cpu`,display:i.value,size:58,"warn-at":70,"danger-at":100},null,8,[`value`,`display`]),B(BP,{value:t.host?.memoryUsedPercent??null,label:`Memory`,size:58},null,8,[`value`]),B(BP,{value:a.value,label:`Disk`,size:58},null,8,[`value`]),B(BP,{value:o.value,label:`CPU temp`,display:s.value,size:58},null,8,[`value`,`display`])])):(I(),L(`p`,GP,` Sampling is disabled in Settings. `)),t.host&&t.host.alerts.length>0?(I(),L(`div`,KP,[n[1]||=z(`span`,{class:`mt-1 size-1.5 shrink-0 rounded-full bg-danger`},null,-1),z(`span`,qP,O(t.host.alerts.join(` · `)),1)])):H(``,!0)]))}}),ZP={class:`flex h-full min-h-0 flex-col gap-3 overflow-y-auto p-3`},QP={class:`flex items-center gap-2 px-1 pt-1`},$P={class:`min-w-0`},eF={class:`truncate text-2xs text-faint`},tF={class:`flex flex-col gap-0.5`},nF={class:`mt-auto flex flex-col gap-3`},rF={class:`flex items-center gap-2 rounded-control border border-line bg-panel-2/70 px-2.5 py-2`},iF={class:`relative flex size-2 shrink-0`},aF={class:`text-2xs text-muted`},oF=[`title`],sF=N({__name:`SideNav`,props:{host:{},connection:{},panelLabel:{},planLabel:{},running:{},total:{}},emits:[`navigate`,`close`],setup(e,{emit:t}){let n=e,r=t,i=Bg(),a=[{to:`/`,label:`Overview`,icon:ny,exact:!0},{to:`/servers`,label:`Servers`,icon:xy,exact:!1},{to:`/logs`,label:`Logs`,icon:yy,exact:!1},{to:`/settings`,label:`Settings`,icon:Ty,exact:!1}];function o(e){return e.exact?i.path===e.to:i.path===e.to||i.path.startsWith(`${e.to}/`)}let s=U(()=>({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=pa(`RouterLink`);return I(),L(`div`,ZP,[z(`div`,QP,[t[3]||=ks(`<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),z(`div`,$P,[t[2]||=z(`p`,{class:`truncate text-sm font-semibold tracking-tight text-ink`},` home-hosted `,-1),z(`p`,eF,O(n.panelLabel),1)]),z(`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`)},[B(j(Ny),{class:`size-4`})])]),z(`nav`,tF,[(I(),L(F,null,ya(a,e=>B(i,{key:e.to,to:e.to,class:D(j(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:M(()=>[(I(),R(ha(e.icon),{class:`size-4 shrink-0`,"stroke-width":o(e)?2.1:1.8},null,8,[`stroke-width`])),V(` `+O(e.label)+` `,1),e.to===`/servers`?(I(),L(`span`,{key:0,class:D([`ml-auto font-mono text-2xs tabular-nums`,o(e)?`text-accent`:`text-faint`])},O(n.running)+`/`+O(n.total),3)):H(``,!0)]),_:2},1032,[`to`,`class`])),64))]),z(`div`,nF,[B(XP,{host:n.host},null,8,[`host`]),z(`div`,rF,[z(`span`,iF,[z(`span`,{class:D(j(Q)(`absolute inset-0 rounded-full`,s.value.dot,n.connection!==`open`&&`animate-ping opacity-60`))},null,2),z(`span`,{class:D(j(Q)(`relative size-2 rounded-full`,s.value.dot))},null,2)]),z(`span`,aF,O(s.value.label),1),z(`span`,{class:`ml-auto truncate font-mono text-2xs text-faint`,title:n.planLabel},O(n.planLabel),9,oF)])])])}}}),cF={key:0,class:`flex flex-col gap-px border-b border-line bg-panel/60`},lF={class:`text-2xs leading-4`},uF={class:`font-medium`},dF={key:0,class:`opacity-80`},fF=N({__name:`SystemNotices`,props:{control:{},configError:{},configPath:{}},setup(e){let t=e,n=U(()=>{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:`The panel keeps running the config it already had; fix ${t.configPath??`servers.config.json`} and it reloads on its own.`}),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:My},danger:{wrap:`border-danger/25 bg-danger-soft text-danger`,icon:Bv},info:{wrap:`border-line bg-panel-2 text-muted`,icon:Bv}};return(e,t)=>n.value.length>0?(I(),L(`div`,cF,[(I(!0),L(F,null,ya(n.value,e=>(I(),L(`div`,{key:e.id,class:D([`flex items-start gap-2 px-3 py-1.5 sm:px-4`,r[e.tone].wrap])},[(I(),R(ha(r[e.tone].icon),{class:`mt-0.5 size-3.5 shrink-0`})),z(`p`,lF,[z(`span`,uF,O(e.text),1),e.hint?(I(),L(`span`,dF,O(e.hint),1)):H(``,!0)])],2))),128))])):H(``,!0)}}),pF={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`},mF={class:`min-w-0 flex-1`},hF={class:`text-xs font-medium text-ink`},gF={key:0,class:`mt-0.5 break-words text-2xs leading-4 text-muted`},_F=[`onClick`],vF=N({__name:`ToastStack`,setup(e){let{toasts:t,dismiss:n}=$j(),r={ok:Vv,danger:Hv,warn:My,info:ty,accent:ty,neutral:ty},i={ok:`text-ok`,danger:`text-danger`,warn:`text-warn`,info:`text-info`,neutral:`text-muted`,accent:`text-accent`},a=U(()=>t.value);return(e,t)=>(I(),L(`div`,pF,[B(Ll,{"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:M(()=>[(I(!0),L(F,null,ya(a.value,e=>(I(),L(`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`},[(I(),R(ha(r[e.tone]),{class:D(j(Q)(`mt-0.5 size-4 shrink-0`,i[e.tone]))},null,8,[`class`])),z(`div`,mF,[z(`p`,hF,O(e.title),1),e.description?(I(),L(`p`,gF,O(e.description),1)):H(``,!0)]),z(`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=>j(n)(e.id)},[B(j(Ny),{class:`size-3.5`})],8,_F)]))),128))]),_:1})]))}}),yF=`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60 focus-visible:ring-offset-2 focus-visible:ring-offset-page`,bF=`text-xs font-medium text-muted`,xF=`text-2xs leading-4 text-faint`,SF=[`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(` `),CF=`${SF} font-mono text-xs`,wF=[`type`,`disabled`,`aria-busy`],$=N({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=Ia(),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=U(()=>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`,yF,n.class));return(e,r)=>(I(),L(`button`,Ns({...j(n),class:void 0},{type:t.type,class:a.value,disabled:t.disabled||t.loading,"aria-busy":t.loading||void 0}),[t.loading?(I(),R(j(ry),{key:0,class:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`})):H(``,!0),P(e.$slots,`default`)],16,wF))}}),TF=N({__name:`Tip`,props:{label:{},side:{default:`top`},disabled:{type:Boolean,default:!1}},setup(e){return(t,n)=>(I(),R(j(_g),{"delay-duration":350},{default:M(()=>[B(j(Sg),{"as-child":``},{default:M(()=>[P(t.$slots,`default`)]),_:3}),e.disabled?H(``,!0):(I(),R(j(xg),{key:0},{default:M(()=>[B(j(bg),{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:M(()=>[V(O(e.label),1)]),_:1},8,[`side`])]),_:1}))]),_:3}))}}),EF={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`},DF={class:`truncate text-sm font-semibold tracking-tight text-ink`},OF={class:`ml-auto flex items-center gap-1.5`},kF={class:`hidden items-center gap-1.5 rounded-control border border-line bg-panel-2 px-2 py-1.5 md:flex`},AF={class:`font-mono text-2xs text-muted`},jF={class:`px-2 py-1.5`},MF={class:`truncate font-mono text-2xs text-muted`},NF=N({__name:`TopBar`,props:{panelUrl:{},connection:{},authenticated:{type:Boolean}},emits:[`menu`,`palette`,`signOut`],setup(e,{emit:t}){let n=e,r=t,i=Bg(),a=BM(),o=U(()=>i.name===`server-detail`?`Servers / ${String(i.params.id??``)}`:String(i.meta.title??`home-hosted`)),s=U(()=>a.preference.value===`dark`?ly:a.preference.value===`light`?Dy:cy),c=U(()=>`Theme: ${a.preference.value}`),l=U(()=>({open:`bg-ok`,connecting:`bg-warn`,closed:`bg-danger`})[n.connection]),u=U(()=>({open:`Live updates`,connecting:`Connecting`,closed:`Reconnecting`})[n.connection]);return(t,i)=>(I(),L(`header`,EF,[z(`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`)},[B(j(oy),{class:`size-4`})]),z(`h1`,DF,O(o.value),1),z(`div`,OF,[z(`button`,{type:`button`,class:D(j(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`,j(yF))),onClick:i[1]||=e=>r(`palette`)},[B(j(by),{class:`size-3.5`}),i[5]||=z(`span`,{class:`pr-6`},`Search or run a command`,-1),i[6]||=z(`kbd`,{class:`rounded border border-line bg-page px-1 py-0.5 font-mono text-2xs text-faint`},`⌘K`,-1)],2),B(TF,{label:u.value},{default:M(()=>[z(`span`,kF,[z(`span`,{class:D(j(Q)(`size-1.5 rounded-full`,l.value))},null,2),z(`span`,AF,O(e.panelUrl),1)])]),_:1},8,[`label`]),B(TF,{label:c.value},{default:M(()=>[B($,{variant:`ghost`,size:`icon-sm`,"aria-label":c.value,onClick:i[2]||=e=>j(a).cycle()},{default:M(()=>[(I(),R(ha(s.value),{class:`size-4`}))]),_:1},8,[`aria-label`])]),_:1},8,[`label`]),n.authenticated?(I(),R(j(tg),{key:0},{default:M(()=>[B(j(og),{"as-child":``},{default:M(()=>[B($,{variant:`ghost`,size:`icon-sm`,"aria-label":`Account`},{default:M(()=>[...i[7]||=[z(`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}),B(j(ig),null,{default:M(()=>[B(j(ng),{"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:M(()=>[z(`div`,jF,[i[8]||=z(`p`,{class:`text-2xs text-faint`},` Signed in `,-1),z(`p`,MF,O(n.panelUrl),1)]),B(j(ag),{class:`my-1 h-px bg-line`}),B(j(rg),{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:M(()=>[B(j(ay),{class:`size-3.5`}),i[9]||=V(` Sign out `,-1)]),_:1})]),_:1})]),_:1})]),_:1})):H(``,!0),B(TF,{label:`Command palette`},{default:M(()=>[B($,{variant:`ghost`,size:`icon-sm`,class:`sm:hidden`,"aria-label":`Open the command palette`,onClick:i[4]||=e=>r(`palette`)},{default:M(()=>[B(j(Gv),{class:`size-4`})]),_:1})]),_:1})])]))}}),PF={key:1,class:`flex h-dvh overflow-hidden bg-page`},FF={class:`hidden w-60 shrink-0 border-r border-line bg-panel/50 lg:block`},IF={key:0,class:`fixed inset-y-0 left-0 z-40 w-64 border-r border-line bg-panel lg:hidden`},LF={class:`flex min-w-0 flex-1 flex-col`},RF=N({__name:`App`,setup(e){let t=Bg(),n=zg(),r=jM(),{session:i,logout:a}=Jj(),o=A(!1),s=A(!1),c=U(()=>i.value?.authenticated===!0),l=U(()=>i.value?.authRequired===!0),u=U(()=>t.name===`login`),d=U(()=>t.name===`logs`),f=U(()=>r.servers.value),p=U(()=>f.value.filter(e=>e.status===`running`).length),m=U(()=>r.control.value?.url??`—`),h=U(()=>r.host.value),g=U(()=>r.control.value?.label??`home-hosted`);return jr(U(()=>qj(i.value)),e=>{if(e!==`wait`){if(e===`login`){kM(),n.push({name:`login`});return}OM()}},{immediate:!0}),jr(()=>t.fullPath,()=>{s.value=!1}),na(async()=>{(!l.value||c.value)&&await r.refresh()}),Be(()=>kM()),(e,t)=>{let n=pa(`RouterView`);return I(),R(j(pg),{"delay-duration":300},{default:M(()=>[u.value?(I(),R(n,{key:0})):(I(),L(`div`,PF,[z(`aside`,FF,[B(sF,{host:h.value,connection:j(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`])]),B(Oc,{"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:M(()=>[s.value?(I(),L(`div`,{key:0,class:`fixed inset-0 z-40 bg-black/45 lg:hidden`,onClick:t[0]||=e=>s.value=!1})):H(``,!0)]),_:1}),B(Oc,{"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:M(()=>[s.value?(I(),L(`aside`,IF,[B(sF,{host:h.value,connection:j(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`])])):H(``,!0)]),_:1}),z(`div`,LF,[B(NF,{"panel-url":m.value,connection:j(r).connection.value,authenticated:c.value,onMenu:t[3]||=e=>s.value=!0,onPalette:t[4]||=e=>o.value=!0,onSignOut:t[5]||=e=>j(a)()},null,8,[`panel-url`,`connection`,`authenticated`]),u.value?H(``,!0):(I(),R(fF,{key:0,control:j(r).control.value,"config-error":j(r).configError.value,"config-path":j(r).appState.value?.configPath},null,8,[`control`,`config-error`,`config-path`])),z(`main`,{class:D(j(Q)(`min-h-0 flex-1`,d.value?`overflow-hidden`:`overflow-y-auto`))},[B(n)],2)])])),B(jP,{open:o.value,"onUpdate:open":t[6]||=e=>o.value=e},null,8,[`open`]),B(vF)]),_:1})}}}),zF={key:0,class:`size-1.5 shrink-0 rounded-full bg-current`},BF=N({__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=U(()=>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`,vP[t.tone].split(` `).filter(e=>e.startsWith(`text-`)).join(` `)):vP[t.tone],t.mono&&`font-mono`));return(e,r)=>(I(),L(`span`,{class:D(n.value)},[t.dot?(I(),L(`span`,zF)):H(``,!0),P(e.$slots,`default`)],2))}}),VF={class:`relative flex min-h-dvh items-center justify-center overflow-hidden bg-page px-4 py-10`},HF={class:`hh-enter relative w-full max-w-md`},UF={class:`rounded-panel border border-line bg-panel/95 p-5 shadow-float backdrop-blur-sm`},WF={class:`flex items-start justify-between gap-3`},GF={class:`min-w-0`},KF={class:`text-base font-semibold text-ink`},qF={class:`mt-1 text-xs leading-relaxed text-muted`},JF={class:`flex flex-col gap-1.5`},YF={class:`relative`},XF=[`type`],ZF=[`aria-label`],QF={key:0,class:`rounded-control border border-danger/25 bg-danger-soft px-2.5 py-2 text-xs text-danger`},$F={key:1,class:`mt-5`},eI={class:`mt-4 space-y-2`},tI={key:0,class:`flex items-start gap-2 rounded-control border border-warn/25 bg-warn-soft px-2.5 py-2`},nI={class:`text-2xs leading-4 text-warn`},rI={class:`ml-1 rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},iI={key:1,class:`flex items-start gap-2 rounded-control border border-warn/25 bg-warn-soft px-2.5 py-2`},aI={key:2,class:`flex items-start gap-2 rounded-control border border-line-soft bg-panel-2 px-2.5 py-2`},oI={class:`text-2xs leading-4 text-muted`},sI={class:`mt-4 flex items-center justify-center gap-2 text-2xs text-faint`},cI={class:`font-mono`},lI=N({__name:`LoginView`,setup(e){let t=Bg(),n=zg(),r=jM(),{session:i,error:a,login:o,refresh:s}=Jj(),c=A(``),l=A(!1),u=A(!1),d=U(()=>i.value?.passwordSet===!1),f=U(()=>i.value!==null&&!i.value.authRequired),p=U(()=>i.value?.usingDefaultPassword===!0&&i.value.defaultPassword!==null),m=U(()=>r.control.value?.auth.exposed===!0),h=U(()=>r.control.value?.url??`—`),g=U(()=>d.value?`This panel has no password yet`:f.value?`Authentication is turned off`:`Sign in to continue`),_=U(()=>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 na(async()=>{i.value===null&&await s()}),(e,t)=>(I(),L(`div`,VF,[t[11]||=z(`div`,{class:`bg-instrument pointer-events-none absolute inset-0 opacity-60`},null,-1),t[12]||=z(`div`,{class:`pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_at_center,transparent_15%,var(--page)_78%)]`},null,-1),z(`div`,HF,[t[10]||=ks(`<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),z(`section`,UF,[z(`div`,WF,[z(`div`,GF,[z(`h1`,KF,O(g.value),1),z(`p`,qF,O(_.value),1)]),m.value?(I(),R(BF,{key:0,tone:`warn`,dot:``},{default:M(()=>[...t[2]||=[V(` Exposed `,-1)]]),_:1})):H(``,!0)]),f.value?(I(),L(`div`,$F,[B($,{variant:`primary`,size:`md`,block:``,onClick:y},{default:M(()=>[...t[4]||=[V(` Open the dashboard `,-1)]]),_:1})])):(I(),L(`form`,{key:0,class:`mt-5 space-y-3`,onSubmit:uu(v,[`prevent`])},[z(`div`,JF,[z(`label`,{for:`hh-password`,class:D(j(bF))},`Password`,2),z(`div`,YF,[xr(z(`input`,{id:`hh-password`,"onUpdate:modelValue":t[0]||=e=>c.value=e,type:u.value?`text`:`password`,autocomplete:`current-password`,autofocus:``,required:``,class:D(j(Q)(j(SF),`pr-9`))},null,10,XF),[[iu,c.value]]),z(`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?(I(),R(j(Zv),{key:0,class:`size-3.5`})):(I(),R(j(Qv),{key:1,class:`size-3.5`}))],8,ZF)])]),j(a)?(I(),L(`p`,QF,O(j(a)),1)):H(``,!0),B($,{type:`submit`,variant:`primary`,size:`md`,block:``,loading:l.value},{default:M(()=>[B(j(iy),{class:`size-3.5`}),t[3]||=V(` Sign in `,-1)]),_:1},8,[`loading`])],32)),z(`div`,eI,[p.value?(I(),L(`div`,tI,[B(j(Sy),{class:`mt-0.5 size-3.5 shrink-0 text-warn`}),z(`p`,nI,[t[5]||=V(` Still on the default password `,-1),z(`code`,rI,O(j(i)?.defaultPassword),1),t[6]||=V(`. Change it under Settings — binding beyond 127.0.0.1 stays refused until you do. `,-1)])])):d.value?(I(),L(`div`,iI,[B(j(wy),{class:`mt-0.5 size-3.5 shrink-0 text-warn`}),t[7]||=z(`p`,{class:`text-2xs leading-4 text-warn`},[V(` No password is set. Open Settings from this machine to add one, or run `),z(`code`,{class:`rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},`pnpm run auth:set-password`),V(`. `)],-1)])):(I(),L(`div`,aI,[B(j(Cy),{class:`mt-0.5 size-3.5 shrink-0 text-ok`}),z(`p`,oI,` Sessions last `+O(Math.round((j(i)?.sessionTtlMs??0)/864e5))+` days. Signing out clears this browser only. `,1)]))])]),z(`p`,sI,[z(`span`,cI,O(h.value),1),t[8]||=z(`span`,{"aria-hidden":`true`},`·`,-1),t[9]||=z(`span`,null,`served from this machine`,-1)])])]))}}),uI=[`#3f4a5c`,`#f07178`,`#7fd88f`,`#e6b673`,`#82aaff`,`#c792ea`,`#7fdbca`,`#c7d2e3`,`#5a6779`,`#ff8b92`,`#9ae6a8`,`#f2c98a`,`#9dbaff`,`#d7aef0`,`#9ce9dc`,`#eef3fb`],dI=[`#4b5563`,`#c0392b`,`#1c7c3f`,`#9a6700`,`#2f5fe0`,`#7c3aed`,`#0b6f89`,`#334155`,`#6b7280`,`#d64535`,`#22854a`,`#a8620d`,`#3f6bff`,`#8b5cf6`,`#0e7d9c`,`#0f1722`],fI=/\u001B\[([0-9;]*)m/g,pI=/\u001B(?:\[[0-9;?]*[A-HJKSTfhilmnprsu]|\][^\u0007\u001B]*(?:\u0007|\u001B\\)?|[()][0-9A-Z])/g;function mI(e){return Math.max(0,Math.min(255,e))}function hI(e){return e===0?0:55+e*40}function gI(e,t){let n=t?uI:dI;if(e<16)return n[e]??n[7];if(e<232){let t=e-16;return`rgb(${hI(Math.floor(t/36))} ${hI(Math.floor(t%36/6))} ${hI(t%6)})`}let r=8+(e-232)*10;return`rgb(${r} ${r} ${r})`}function _I(){return{fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1}}function vI(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,_I());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?uI:dI)[i-30]??null;else if(i>=90&&i<=97)e.fg=(n?uI:dI)[i-90+8]??null;else if(i>=40&&i<=47)e.bg=(n?uI:dI)[i-40]??null;else if(i>=100&&i<=107)e.bg=(n?uI:dI)[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]=gI(mI(r[t+2]),n),t+=2):o===2&&(e[a]=`rgb(${mI(r[t+2]??0)} ${mI(r[t+3]??0)} ${mI(r[t+4]??0)})`,t+=4)}}}function yI(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 bI(e){return e.includes(`\x1B`)}function xI(e,t=!0){if(!bI(e))return[{text:e,fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1}];let n=[],r=_I(),i=0;fI.lastIndex=0;let a=fI.exec(e);for(;a!==null;)yI(n,e.slice(i,a.index).replace(pI,``),r),vI(r,a[1]??``,t),i=a.index+a[0].length,a=fI.exec(e);return yI(n,e.slice(i).replace(pI,``),r),n}function SI(e){let t=new Date(e);return`${t.toLocaleTimeString(void 0,{hour12:!1})}.${String(t.getMilliseconds()).padStart(3,`0`)}`}function CI(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 wI(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 TI(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 EI(e){return e===null?`—`:`${(e*100).toFixed(e>=.999?0:1)}%`}function DI(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 OI(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 kI(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 AI(e){return e===null||!Number.isFinite(e)?`—`:e>=100?`${Math.round(e)}%`:`${e.toFixed(1)}%`}function jI(e){return e===void 0?`unset`:typeof e==`string`?e:JSON.stringify(e)}var MI={class:`flex h-5 w-max min-w-full items-center gap-2 whitespace-pre px-2 font-mono text-xs leading-5`},NI={key:0,class:`shrink-0 select-none text-faint`},PI={class:`min-w-0`},FI=N({__name:`LogRow`,props:{line:{},query:{},dark:{type:Boolean},showTime:{type:Boolean}},setup(e){let t=e,n=U(()=>xI(t.line.text,t.dark)),r=U(()=>{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)=>(I(),L(`div`,MI,[t.showTime?(I(),L(`span`,NI,O(j(SI)(t.line.ts)),1)):H(``,!0),z(`span`,{class:D([`h-3.5 w-0.5 shrink-0 rounded-full`,[i[t.line.stream]]]),"aria-hidden":`true`},null,2),z(`span`,PI,[(I(!0),L(F,null,ya(r.value,(e,t)=>(I(),L(`span`,{key:t,style:_e(a(e))},O(e.text),5))),128))])]))}}),II={class:`inline-flex items-center gap-0.5 rounded-control border border-line bg-panel-2 p-0.5`},LI=[`aria-pressed`,`onClick`],RI=N({__name:`SegmentedControl`,props:Ba({options:{},size:{default:`sm`}},{modelValue:{default:``},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=co(e,`modelValue`);return(e,r)=>(I(),L(`div`,II,[(I(!0),L(F,null,ya(t.options,e=>(I(),L(`button`,{key:e.value,type:`button`,class:D(j(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},O(e.label),11,LI))),128))]))}}),zI={class:`flex min-h-0 flex-col overflow-hidden rounded-panel border border-line bg-panel`},BI={class:`flex flex-wrap items-center gap-2 border-b border-line bg-panel-2/60 px-2.5 py-2`},VI={class:`relative min-w-40 flex-1 sm:max-w-72`},HI={class:`absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5`},UI={key:0,class:`px-1 font-mono text-2xs tabular-nums text-faint`},WI={class:`ml-auto flex items-center gap-1.5`},GI=[`href`,`download`],KI={class:`relative min-h-0 flex-1`},qI={key:0,class:`px-3 py-6 text-center text-xs text-faint`},JI={class:`flex items-center gap-3 border-t border-line bg-panel-2/60 px-2.5 py-1.5 text-2xs text-faint`},YI={class:`flex items-center gap-1.5`},XI={class:`font-mono tabular-nums`},ZI={key:0,class:`font-mono tabular-nums`},QI=20,$I=12,eL=N({__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=BM(),a=A(null),o=A(0),s=A(320),c=A(!0),l=A(`all`),u=A(``),d=A(!0),f=A(0),p=U(()=>{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=U(()=>p.value.length),h=U(()=>{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=U(()=>Math.max(0,Math.floor(o.value/QI)-$I)),_=U(()=>Math.min(m.value,Math.ceil((o.value+s.value)/QI)+$I)),v=U(()=>p.value.slice(g.value,_.value)),y=U(()=>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*QI-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]))}jr(m,()=>{c.value&&(f.value=0,requestAnimationFrame(x))}),jr(h,()=>{f.value=0,h.value.length>0&&u.value.trim().length>0&&requestAnimationFrame(()=>S(h.value[0]))}),jr(l,()=>{c.value=!0,requestAnimationFrame(x)});let w=null;na(()=>{let e=a.value;e&&(s.value=e.clientHeight,w=new ResizeObserver(()=>{a.value&&(s.value=a.value.clientHeight)}),w.observe(e),x())}),Be(()=>{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)=>(I(),L(`div`,zI,[z(`header`,BI,[B(RI,{modelValue:l.value,"onUpdate:modelValue":t[0]||=e=>l.value=e,options:T},null,8,[`modelValue`]),z(`div`,VI,[B(j(by),{class:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),xr(z(`input`,{"onUpdate:modelValue":t[1]||=e=>u.value=e,type:`search`,placeholder:`Search this output`,class:D([`h-7 py-0 pl-7 text-xs`,[j(SF)]]),"aria-label":`Search the log output`,onKeydown:t[2]||=fu(uu(e=>C(e.shiftKey?-1:1),[`prevent`]),[`enter`])},null,34),[[Yl,u.value]]),z(`div`,HI,[u.value.trim().length>0?(I(),L(`span`,UI,O(h.value.length===0?`0`:`${f.value+1}/${h.value.length}`),1)):H(``,!0),u.value.length>0?(I(),L(`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=``},[B(j(Ny),{class:`size-3`})])):H(``,!0),h.value.length>0?(I(),L(`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)},[B(j(zv),{class:`size-3`})])):H(``,!0),h.value.length>0?(I(),L(`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)},[B(j(Iv),{class:`size-3`})])):H(``,!0)])]),z(`div`,WI,[B(TF,{label:d.value?`Hide timestamps`:`Show timestamps`},{default:M(()=>[B($,{size:`xs`,variant:`ghost`,onClick:t[6]||=e=>d.value=!d.value},{default:M(()=>[B(j(Uv),{class:D(j(Q)(`size-3`,d.value?`fill-accent text-accent`:`text-faint`))},null,8,[`class`]),t[9]||=V(` ts `,-1)]),_:1})]),_:1},8,[`label`]),B($,{size:`xs`,variant:c.value?`secondary`:`primary`,onClick:t[7]||=e=>c.value?c.value=!1:x()},{default:M(()=>[(I(),R(ha(c.value?j(dy):j(py)),{class:`size-3`})),V(` `+O(c.value?`Pause`:`Follow`),1)]),_:1},8,[`variant`]),n.clearable?(I(),R(TF,{key:0,label:`Clear the in-memory buffer`},{default:M(()=>[B($,{size:`icon-sm`,variant:`ghost`,"aria-label":`Clear the log buffer`,onClick:t[8]||=e=>r(`clear`)},{default:M(()=>[B(j(jy),{class:`size-3.5`})]),_:1})]),_:1})):H(``,!0),n.downloadUrl?(I(),R(TF,{key:1,label:`Download the persisted file`},{default:M(()=>[z(`a`,{href:n.downloadUrl,download:n.downloadName},[B($,{size:`icon-sm`,variant:`ghost`,"aria-label":`Download the log file`},{default:M(()=>[B(j(Pv),{class:`size-3.5`})]),_:1})],8,GI)]),_:1})):H(``,!0)])]),z(`div`,KI,[z(`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:_e({minHeight:n.minHeight}),tabindex:`0`,role:`log`,"aria-label":`Log output`,onScrollPassive:b},[m.value===0?(I(),L(`p`,qI,O(n.lines.length===0?n.emptyHint:`Nothing matches that search or stream filter.`),1)):(I(),L(`div`,{key:1,class:`relative w-full`,style:_e({height:`${m.value*QI}px`})},[(I(!0),L(F,null,ya(v.value,(e,t)=>(I(),L(`div`,{key:g.value+t,class:D([`absolute left-0 top-0`,g.value+t===y.value&&`bg-warn/10`]),style:_e({transform:`translateY(${(g.value+t)*QI}px)`})},[B(FI,{line:e,query:u.value,dark:j(i).isDark.value,"show-time":d.value},null,8,[`line`,`query`,`dark`,`show-time`])],6))),128))],4))],36),B(Oc,{"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:M(()=>[!c.value&&m.value>0?(I(),L(`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},[B(j(Pv),{class:`size-3`}),t[10]||=V(` Jump to latest `,-1)])):H(``,!0)]),_:1})]),z(`footer`,JI,[z(`span`,YI,[z(`span`,{class:D(j(Q)(`size-1.5 rounded-full`,n.live?c.value?`bg-ok`:`bg-warn`:`bg-faint`))},null,2),V(` `+O(n.live?c.value?`streaming`:`paused`:`snapshot`),1)]),z(`span`,XI,O(m.value===n.lines.length?`${m.value} lines`:`${m.value} of ${n.lines.length} lines`),1),u.value.trim().length>0?(I(),L(`span`,ZI,O(h.value.length)+` matches`,1)):H(``,!0),z(`span`,{class:`ml-auto hidden font-mono tabular-nums sm:inline`},`row height `+O(QI)+`px · windowed`)])]))}}),tL={key:0,class:`grid size-10 place-items-center rounded-full border border-line bg-panel-2 text-faint`},nL={class:`max-w-sm space-y-1`},rL={class:`text-sm font-medium text-ink`},iL={key:0,class:`text-xs leading-relaxed text-muted`},aL={key:1,class:`flex items-center gap-2`},oL=N({__name:`EmptyState`,props:{title:{},description:{default:void 0},compact:{type:Boolean,default:!1}},setup(e){return(e,t)=>(I(),L(`div`,{class:D(j(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?(I(),L(`div`,tL,[P(e.$slots,`icon`)])):H(``,!0),z(`div`,nL,[z(`p`,rL,O(e.$props.title),1),e.$props.description?(I(),L(`p`,iL,O(e.$props.description),1)):H(``,!0)]),e.$slots.action?(I(),L(`div`,aL,[P(e.$slots,`action`)])):H(``,!0)],2))}}),sL={class:`flex shrink-0 items-start justify-between gap-4 border-b border-line px-4 py-3`},cL={class:`min-w-0`},lL={class:`min-h-0 flex-1 overflow-y-auto px-4 py-3.5`},uL={key:0,class:`flex shrink-0 items-center justify-end gap-2 border-t border-line bg-panel-2 px-4 py-3`},dL=N({__name:`Modal`,props:Ba({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=co(e,`open`);return(e,r)=>(I(),R(j(uf),{open:n.value,"onUpdate:open":r[0]||=e=>n.value=e},{default:M(()=>[B(j(Xf),null,{default:M(()=>[B(j(Jf),{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]`}),B(j(Gf),{class:D(j(Q)(`fixed left-1/2 top-1/2 z-50 flex max-h-[88dvh] -translate-x-1/2 -translate-y-1/2 flex-col 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:M(()=>[z(`header`,sL,[z(`div`,cL,[B(j(Zf),{class:`text-sm font-semibold text-ink`},{default:M(()=>[V(O(t.title),1)]),_:1}),t.description?(I(),R(j(Kf),{key:0,class:`mt-0.5 text-xs text-muted`},{default:M(()=>[V(O(t.description),1)]),_:1})):H(``,!0)]),B(j(df),{class:D(j(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`,j(yF))),"aria-label":`Close`},{default:M(()=>[B(j(Ny),{class:`size-4`})]),_:1},8,[`class`])]),z(`div`,lL,[P(e.$slots,`default`)]),e.$slots.footer?(I(),L(`footer`,uL,[P(e.$slots,`footer`)])):H(``,!0)]),_:3},8,[`class`])]),_:3})]),_:3},8,[`open`]))}}),fL=[`for`],pL={class:`relative`},mL=[`id`],hL=[`value`,`disabled`],gL={key:1,class:`text-2xs text-danger`},_L=N({inheritAttrs:!1,__name:`SelectField`,props:Ba({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=co(e,`modelValue`),r=ui();return(e,i)=>(I(),L(`div`,{class:D(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(I(),L(`label`,{key:0,for:j(r),class:D(j(bF))},O(t.label),11,fL)):H(``,!0),z(`div`,pL,[xr(z(`select`,Ns({id:j(r),"onUpdate:modelValue":i[0]||=e=>n.value=e,class:j(Q)(j(SF),`cursor-pointer appearance-none pr-7`,t.mono&&`font-mono text-xs`,t.error&&`border-danger`)},e.$attrs),[(I(!0),L(F,null,ya(t.options,e=>(I(),L(`option`,{key:e.value,value:e.value,disabled:e.disabled},O(e.label),9,hL))),128))],16,mL),[[$l,n.value]]),B(j(Iv),{class:`pointer-events-none absolute right-2 top-1/2 size-3.5 -translate-y-1/2 text-faint`,"aria-hidden":`true`})]),t.error?(I(),L(`p`,gL,O(t.error),1)):t.hint?(I(),L(`p`,{key:2,class:D(j(xF))},O(t.hint),3)):H(``,!0)],2))}}),vL=N({__name:`Skeleton`,props:{class:{default:`h-4 w-24`},rounded:{default:`rounded`}},setup(e){return(t,n)=>(I(),L(`span`,{class:D(j(Q)(`block animate-pulse bg-line-soft`,e.rounded,t.$props.class)),style:{"animation-duration":`1.4s`},"aria-hidden":`true`},null,2))}}),yL={class:`flex h-full min-h-0`},bL={class:`hidden w-64 shrink-0 flex-col border-r border-line bg-panel/40 md:flex`},xL={class:`border-b border-line px-3 py-2.5`},SL={class:`mt-0.5 text-2xs text-faint`},CL={class:`min-h-0 flex-1 overflow-y-auto p-1.5`},wL={key:0,class:`space-y-1.5 p-1.5`},TL=[`onClick`],EL={class:`min-w-0 flex-1`},DL={class:`block truncate font-mono text-2xs text-faint`},OL={class:`flex min-w-0 flex-1 flex-col`},kL={class:`flex flex-wrap items-center gap-2 border-b border-line bg-panel/40 px-3 py-2.5`},AL={class:`min-w-0`},jL={class:`truncate text-sm font-semibold text-ink`},ML={key:0,class:`ml-1.5 font-mono text-2xs font-normal text-faint`},NL={key:0,class:`flex flex-wrap items-center gap-1.5 border-b border-line-soft bg-panel-2/40 px-3 py-2`},PL=[`href`,`download`],FL={class:`text-faint`},IL={key:1,class:`text-2xs text-faint`},LL={key:2,class:`ml-auto font-mono text-2xs text-faint`},RL={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`},zL={class:`min-h-0 flex-1 p-3`},BL=N({__name:`LogsView`,setup(e){let t=Bg(),n=zg(),r=A([]),i=A(null),a=A(`disk`),o=A(`2000`),s=A(!1),c=A(null),l=A([]),u=A(0),d=A(!1),f=A(!0),p=U(()=>r.value.find(e=>e.serverId===i.value)??null),m=AM(()=>a.value===`live`?i.value:null),h=m.version,g=U(()=>(h.value,m.lines())),_=U(()=>a.value===`live`?g.value:l.value),v=U(()=>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=U(()=>r.value.reduce((e,t)=>e+t.sizeBytes,0)),x=U(()=>r.value.filter(e=>e.files.length>0).length);async function S(){f.value=!0;try{r.value=await yj();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 bj(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 xj(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 jr([i,o,a],()=>{a.value===`disk`&&C()},{immediate:!1}),na(async()=>{await S(),a.value===`disk`&&await C()}),(e,t)=>(I(),L(`div`,yL,[z(`aside`,bL,[z(`div`,xL,[t[5]||=z(`p`,{class:`text-xs font-semibold text-ink`},` Persisted logs `,-1),z(`p`,SL,O(x.value)+` of `+O(r.value.length)+` servers on disk · `+O(j(OI)(b.value)),1)]),z(`div`,CL,[f.value?(I(),L(`div`,wL,[(I(),L(F,null,ya(5,e=>B(vL,{key:e,class:`h-10 w-full`,rounded:`rounded-control`})),64))])):(I(!0),L(F,{key:1},ya(r.value,e=>(I(),L(`button`,{key:e.serverId,type:`button`,class:D(j(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)},[z(`span`,{class:D(j(Q)(`size-1.5 shrink-0 rounded-full`,j(yP)[j(hP)[e.status].tone]))},null,2),z(`span`,EL,[z(`span`,{class:D(j(Q)(`block truncate text-xs`,e.serverId===i.value?`font-medium text-accent`:`text-ink`))},O(e.label),3),z(`span`,DL,O(e.files.length>0?`${e.files.length} file${e.files.length===1?``:`s`} · ${j(OI)(e.sizeBytes)}`:`nothing persisted`),1)])],10,TL))),128)),!f.value&&r.value.length===0?(I(),R(oL,{key:2,compact:``,title:`No servers`,description:`Add one and its output will be persisted here.`})):H(``,!0)]),t[6]||=z(`div`,{class:`border-t border-line p-2.5`},[z(`p`,{class:`text-2xs leading-4 text-faint`},` Rotation and retention are set under Settings → Log storage. `)],-1)]),z(`div`,OL,[z(`header`,kL,[z(`div`,AL,[z(`h1`,jL,[V(O(p.value?.label??`Logs`)+` `,1),p.value?(I(),L(`span`,ML,O(p.value.serverId),1)):H(``,!0)])]),B(RI,{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`?(I(),R(_L,{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`])):H(``,!0),a.value===`disk`?(I(),R($,{key:1,size:`sm`,loading:s.value,onClick:C},{default:M(()=>[B(j(gy),{class:`size-3.5`}),t[7]||=V(`Reload `,-1)]),_:1},8,[`loading`])):H(``,!0),a.value===`disk`?(I(),R($,{key:2,size:`sm`,variant:`ghost`,disabled:!p.value||p.value.files.length===0,onClick:t[2]||=e=>d.value=!0},{default:M(()=>[B(j(jy),{class:`size-3.5`}),t[8]||=V(`Clear file `,-1)]),_:1},8,[`disabled`])):H(``,!0)]),p.value?(I(),L(`div`,NL,[B(j($v),{class:`size-3.5 shrink-0 text-faint`}),p.value.files.length>0?(I(!0),L(F,{key:0},ya(p.value.files,e=>(I(),L(`a`,{key:e.name,href:Sj(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`},[V(O(e.name)+` `,1),z(`span`,FL,O(j(OI)(e.sizeBytes)),1),B(j(Pv),{class:`size-3`})],8,PL))),128)):(I(),L(`span`,IL,` Nothing on disk for this server — persistence is off, or it has not written anything yet. `)),a.value===`disk`&&l.value.length>0?(I(),L(`span`,LL,` loaded `+O(l.value.length)+` lines `,1)):H(``,!0)])):H(``,!0),c.value?(I(),L(`p`,RL,[B(j(Bv),{class:`size-3.5`}),V(` `+O(c.value),1)])):H(``,!0),z(`div`,zL,[p.value?s.value&&_.value.length===0?(I(),R(vL,{key:1,class:`h-full w-full`,rounded:`rounded-panel`})):(I(),R(eL,{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`])):(I(),R(oL,{key:0,title:`Pick a server`,description:`Persisted output and live streams are per server. Choose one from the list.`},{icon:M(()=>[B(j(yy),{class:`size-4`})]),_:1}))])]),B(dL,{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:M(()=>[B($,{variant:`ghost`,onClick:t[3]||=e=>d.value=!1},{default:M(()=>[...t[9]||=[V(` Keep it `,-1)]]),_:1}),B($,{variant:`danger`,onClick:w},{default:M(()=>[B(j(jy),{class:`size-3.5`}),t[10]||=V(`Clear `,-1)]),_:1})]),default:M(()=>[t[11]||=z(`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`])]))}}),VL=N({__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=U(()=>t.value===null||!Number.isFinite(t.value)?0:Math.min(100,Math.max(0,t.value))),r=U(()=>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)=>(I(),L(`div`,{class:D(j(Q)(`w-full overflow-hidden rounded-full bg-line-soft`,t.height,t.class))},[z(`div`,{class:D(j(Q)(`h-full rounded-full transition-[width] duration-300 ease-out`,i[r.value])),style:_e({width:`${n.value}%`})},null,6)],2))}}),HL={key:1,class:`space-y-4`},UL={class:`grid grid-cols-2 gap-3 sm:grid-cols-4`},WL={class:`grid grid-cols-2 gap-x-4 gap-y-2 border-t border-line-soft pt-3 sm:grid-cols-4`},GL={class:`flex items-center gap-1 text-2xs text-faint`},KL={class:`font-mono text-xs text-ink`},qL={class:`font-mono text-xs tabular-nums text-ink`},JL={class:`flex items-center gap-1 text-2xs text-faint`},YL={class:`font-mono text-xs text-ink`},XL={class:`flex items-center gap-1 text-2xs text-faint`},ZL={class:`font-mono text-xs text-ink`},QL={class:`space-y-2 border-t border-line-soft pt-3`},$L={class:`flex items-center gap-1.5 text-2xs font-medium text-faint`},eR={class:`flex items-baseline justify-between gap-2`},tR=[`title`],nR={class:`shrink-0 font-mono text-2xs tabular-nums text-faint`},rR={key:0,class:`space-y-1 rounded-control border border-danger/25 bg-danger-soft px-2.5 py-2`},iR=N({__name:`HostVitalsPanel`,props:{host:{},now:{}},setup(e){let t=e,n=U(()=>{let e=t.host;return e?(e.loadAvg[0]??0)/Math.max(1,e.cpus):null}),r=U(()=>t.host?.loadAvg.map(e=>e.toFixed(2)).join(` `)??`—`);return(e,i)=>!t.host||!t.host.enabled?(I(),R(oL,{key:0,compact:``,title:`Host sampling is off`,description:`Turn it on in Settings to collect load, memory, disk and temperature.`})):(I(),L(`div`,HL,[z(`div`,UL,[B(BP,{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`]),B(BP,{value:t.host.memoryUsedPercent,label:`Memory`,size:72},null,8,[`value`]),B(BP,{value:t.host.swapUsedPercent,label:`Swap`,size:72,"warn-at":50},null,8,[`value`]),B(BP,{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`])]),z(`dl`,WL,[z(`div`,null,[z(`dt`,GL,[B(j(qv),{class:`size-3`}),i[0]||=V(`CPUs `,-1)]),z(`dd`,KL,O(t.host.cpus),1)]),z(`div`,null,[i[1]||=z(`dt`,{class:`text-2xs text-faint`},` Load 1 / 5 / 15 `,-1),z(`dd`,qL,O(r.value),1)]),z(`div`,null,[z(`dt`,JL,[B(j(sy),{class:`size-3`}),i[2]||=V(`Memory used `,-1)]),z(`dd`,YL,O(t.host.memoryUsedPercent.toFixed(0))+`% `,1)]),z(`div`,null,[z(`dt`,XL,[B(j(ky),{class:`size-3`}),i[3]||=V(`Sampled `,-1)]),z(`dd`,ZL,O(j(DI)(t.host.sampledAt,t.now)),1)])]),z(`div`,QL,[z(`p`,$L,[B(j(ey),{class:`size-3`}),i[4]||=V(`Filesystems `,-1)]),(I(!0),L(F,null,ya(t.host.disks,e=>(I(),L(`div`,{key:e.path,class:`space-y-1`},[z(`div`,eR,[z(`span`,{class:`truncate font-mono text-2xs text-muted`,title:e.path},O(e.path),9,tR),z(`span`,nR,O(j(OI)(e.totalBytes-e.freeBytes))+` / `+O(j(OI)(e.totalBytes))+` · `+O(e.usedPercent.toFixed(0))+`% `,1)]),B(VL,{value:e.usedPercent},null,8,[`value`])]))),128))]),t.host.alerts.length>0?(I(),L(`div`,rR,[i[5]||=z(`p`,{class:`text-2xs font-medium text-danger`},` Thresholds breached `,-1),(I(!0),L(F,null,ya(t.host.alerts,e=>(I(),L(`p`,{key:e,class:`text-2xs text-danger`},O(e),1))),128))])):H(``,!0)]))}}),aR={key:1,class:`flex flex-col`},oR={class:`min-w-0 flex-1`},sR={class:`flex items-baseline gap-1.5`},cR={class:`truncate text-xs font-medium text-ink`},lR=[`title`],uR={key:0,class:`text-muted`},dR={class:`shrink-0 pt-0.5 text-2xs text-faint`},fR=N({__name:`ActivityFeed`,props:{servers:{},now:{},limit:{default:12},serverId:{default:void 0}},setup(e){let t=e,n={start:py,exit:Ey,crash:Bv,"forced-restart":vy,unhealthy:My,recovered:Vv},r=U(()=>{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=pa(`RouterLink`);return r.value.length===0?(I(),R(oL,{key:0,compact:``,title:`No events in the last 24 hours`,description:`Starts, exits, crashes and recoveries show up here as they happen.`})):(I(),L(`ol`,aR,[(I(!0),L(F,null,ya(r.value,(e,r)=>(I(),L(`li`,{key:`${e.serverId}-${e.ts}-${r}`,class:D([`flex items-start gap-2.5 border-line-soft py-2`,r>0&&`border-t`])},[(I(),R(ha(n[e.type]),{class:D(j(Q)(`mt-0.5 size-3.5 shrink-0`,j(_P)[j(SP)[e.type]]))},null,8,[`class`])),z(`div`,oR,[z(`p`,sR,[z(`span`,cR,O(j(xP)[e.type]),1),B(a,{to:`/servers/${e.serverId}`,class:`truncate text-2xs text-muted hover:text-accent`},{default:M(()=>[V(O(e.label),1)]),_:2},1032,[`to`])]),z(`p`,{class:`mt-0.5 truncate font-mono text-2xs text-faint`,title:e.detail},[V(O(e.detail)+` `,1),e.runtimeMs===void 0?H(``,!0):(I(),L(`span`,uR,` · ran `+O(j(wI)(e.runtimeMs)),1))],8,lR)]),z(`span`,dR,O(j(DI)(e.ts,t.now)),1)],2))),128))]))}}}),pR=[`restart`,`health`,`stop`];function mR(e,t){return JSON.stringify(hR(e))===JSON.stringify(hR(t))}function hR(e){if(Array.isArray(e))return e.map(hR);if(typeof e==`object`&&e){let t={};for(let n of Object.keys(e).sort()){let r=e[n];r!=null&&(t[n]=hR(r))}return t}return e??null}function gR(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??{}))mR(t[e],r)||(n[e]=r);Object.keys(n).length>0&&(r[i]=n);continue}mR(e[i],a)||(r[i]=a)}return r}function _R(e,t){let n=e;return gR({...n,label:n.label??``},t,pR)}function vR(e,t=``){return typeof e!=`object`||!e||Array.isArray(e)?[{path:t,value:e}]:Object.entries(e).flatMap(([e,n])=>vR(n,t.length===0?e:`${t}.${e}`))}function yR(e,t){let n=new Map(vR(t).map(e=>[e.path,e.value]));return vR(e).map(e=>({path:e.path,from:n.get(e.path),to:e.value}))}function bR(e){let t=0;for(let n of Object.values(e))t+=typeof n==`object`&&n&&!Array.isArray(n)?bR(n):1;return t}async function xR(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 SR={enabled:!0,maxRetries:3,baseDelayMs:1e3,factor:2,maxDelayMs:3e4,resetAfterMs:6e4},CR={enabled:!0,mode:`port`,http:{path:`/`,method:`GET`,expectStatusBelow:400,expectBody:``},intervalMs:5e3,timeoutMs:1500,unhealthyThreshold:3,forceRestartAfterMs:0,startTimeoutMs:2e4},wR={signal:`SIGTERM`,killGroup:!0,graceMs:5e3,killPortHolders:!1};function TR(e){return{...e,http:{...e.http}}}function ER(){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:{...SR},health:TR(CR),stop:{...wR}},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 DR(e){return{enabled:e.enabled,sessionTtlMs:e.sessionTtlMs,cookieSecure:e.cookieSecure,trustProxy:e.trustProxy,maxLoginAttempts:e.maxLoginAttempts,lockoutMs:e.lockoutMs}}function OR(e){return{label:e.label,port:e.port,host:e.host,openBrowser:e.openBrowser,tlsEnabled:e.tls.enabled}}function kR(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 AR(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function jR(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 MR(e){return{enabled:e.enabled,keep:e.keep,includePaths:e.includePaths.join(`, `)}}function NR(e,t){return gR(e,{...t,diskPaths:AR(t.diskPaths)})}function PR(e,t){return gR(e,{...t,includePaths:AR(t.includePaths)})}function FR(e,t){return gR({label:e.label,port:e.port,host:e.host,openBrowser:e.openBrowser,auth:DR(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 IR(e,t){return gR(e,t,[`restart`,`health`,`stop`])}function LR(e,t){return gR(e,t)}function RR(e,t){return gR({telegram:kR(e)},{telegram:{...t}},[`telegram`])}function zR(e,t){switch(t){case`control`:return{...e.control,auth:{...e.auth}};case`defaults`:return{...e.defaults,restart:{...e.defaults.restart},health:TR(e.defaults.health),stop:{...e.defaults.stop}};case`logs`:return{...e.logs};case`telegram`:return{...e.telegram};case`host`:return{...e.host};case`backups`:return{...e.backups}}}function BR(e,t,n){let r=t[n];return r!==void 0&&JSON.stringify(r)!==JSON.stringify(zR(e,n))}function VR(e,t){return e.label!==t.control.label||e.port!==t.control.port||e.host!==t.control.host||e.openBrowser!==t.control.openBrowser}function HR(e,t){return e.tls.enabled!==t.control.tlsEnabled}function UR(e,t){return bR(gR({...DR(e.auth)},{...t.auth}))>0}function WR(e,t,n){return U({get:e,set:e=>{t(e===null||Number.isNaN(e)?n:e)}})}async function GR(e){if(!e.rebinding)return null;let t=e.targetUrl??e.control.url;return t.length===0||t===window.location.origin?null:await xR(t)?(window.location.replace(t),null):`The control panel did not answer on ${t}. Check the console for the new listener.`}function KR(e){return e.split(`
40
40
  `).map(e=>e.trim()).filter(e=>e.length>0)}function qR(e){return Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`
41
- `)}function JR(e){let t={};for(let n of KR(e)){let e=n.indexOf(`=`);e<=0||(t[n.slice(0,e).trim()]=n.slice(e+1).trim())}return t}function YR(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}var XR=/^[a-z0-9][a-z0-9_-]*$/;function ZR(e){return{id:``,label:``,command:``,args:``,cwd:``,port:null,bind:e?.bind??`local`,autostart:e?.autostart??!1,enabled:e?.enabled??!0,onPortConflict:e?.onPortConflict??`block`,logBufferLines:null,dependsOn:``,envFile:``,env:``,dataEnvs:``,backupPaths:``,backupIgnoreGenerated:!0,maxRssMb:null,restart:{...e?.restart??SR},health:TR(e?.health??CR),stop:{...e?.stop??wR},bootstrapEnabled:!1,bootstrapCommand:``,bootstrapArgs:``,bootstrapEnv:``,bootstrapTimeoutMs:12e4,bootstrapRunOnce:!0}}function QR(e){return e!==null&&Number.isFinite(e)?e:0}function $R(e){return{args:[],cwd:`.`,env:{},dataEnvs:{},dependsOn:[],envFile:``,backupPaths:[],backupIgnoreGenerated:!0,resources:{maxRssBytes:0},bind:e?.bind??`local`,enabled:e?.enabled??!0,autostart:e?.autostart??!1,onPortConflict:e?.onPortConflict??`block`,logBufferLines:e?.logBufferLines??500}}function ez(e){return e===null||Number.isNaN(e)||Number.isInteger(e)&&e>=1&&e<=65535?null:`Port must be a whole number between 1 and 65535.`}function tz(e,t){let n=QR(e.maxRssMb),r=QR(e.bootstrapTimeoutMs),i=$R(t),a=gR({restart:t?.restart??SR,health:t?.health??CR,stop:t?.stop??wR},{restart:e.restart,health:e.health,stop:e.stop});return{...gR(i,{args:KR(e.args),cwd:e.cwd.trim().length>0?e.cwd.trim():`.`,env:JR(e.env),dataEnvs:JR(e.dataEnvs),dependsOn:YR(e.dependsOn),envFile:e.envFile.trim(),backupPaths:KR(e.backupPaths),backupIgnoreGenerated:e.backupIgnoreGenerated,resources:{maxRssBytes:n>0?Math.round(n*1024*1024):0},bind:e.bind,enabled:e.enabled,autostart:e.autostart,onPortConflict:e.onPortConflict,logBufferLines:QR(e.logBufferLines)>0?QR(e.logBufferLines):i.logBufferLines}),...a,id:e.id.trim(),...e.label.trim().length===0?{}:{label:e.label.trim()},command:e.command.trim(),...e.port===null||Number.isNaN(e.port)?{}:{port:e.port},...e.bootstrapEnabled?{bootstrap:{command:e.bootstrapCommand.trim(),args:KR(e.bootstrapArgs),env:JR(e.bootstrapEnv),timeoutMs:r>=1e3?r:12e4,runOnce:e.bootstrapRunOnce}}:{}}}function nz(e){return e.id.trim().length===0?`An id is required — it is the key this server lives under.`:XR.test(e.id.trim())?e.command.trim().length===0?`A command is required — the executable the supervisor spawns.`:e.bootstrapEnabled&&e.bootstrapCommand.trim().length===0?`A bootstrap needs a command to run.`:ez(e.port):`The id must start with a lowercase letter or digit and contain only lowercase letters, digits, dashes and underscores.`}var rz={class:`mb-3 flex items-start justify-between gap-3`},iz={class:`min-w-0`},az={class:`text-xs font-semibold text-ink`},oz={key:0,class:`mt-0.5 text-2xs leading-4 text-muted`},sz={class:`flex shrink-0 items-center gap-2`},cz=N({__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=U(()=>({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)=>(I(),L(`section`,{class:D(j(Q)(`rounded-panel border border-line bg-panel-2/40`,t.dense?`p-3`:`p-3.5`,t.class))},[z(`header`,rz,[z(`div`,iz,[z(`h3`,az,O(t.title),1),t.description?(I(),L(`p`,oz,O(t.description),1)):H(``,!0)]),z(`div`,sz,[P(e.$slots,`actions`)])]),z(`div`,{class:D(j(Q)(`grid gap-3`,n.value))},[P(e.$slots,`default`)],2)],2))}});function lz(e){return e==null||Number.isNaN(e)?``:String(e)}function uz(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 dz=[`for`],fz=[`id`,`step`,`min`,`max`,`aria-invalid`],pz={key:1,class:`text-2xs text-danger`},mz=N({inheritAttrs:!1,__name:`NumberField`,props:Ba({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=co(e,`modelValue`),r=ui(),i=U({get:()=>lz(n.value),set:e=>{n.value=uz(e,t.nullable)}}),a=U(()=>n.value!==null&&Number.isNaN(n.value));return(e,n)=>(I(),L(`div`,{class:D(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(I(),L(`label`,{key:0,for:j(r),class:D(j(bF))},O(t.label),11,dz)):H(``,!0),xr(z(`input`,Ns({id:j(r),"onUpdate:modelValue":n[0]||=e=>i.value=e,type:`number`,inputmode:`numeric`,step:t.step,min:t.min,max:t.max,class:j(Q)(j(SF),`font-mono tabular-nums`,(t.error||a.value)&&`border-danger`),"aria-invalid":t.error||a.value?!0:void 0},e.$attrs),null,16,fz),[[Yl,i.value]]),t.error?(I(),L(`p`,pz,O(t.error),1)):t.hint?(I(),L(`p`,{key:2,class:D(j(xF))},O(t.hint),3)):H(``,!0)],2))}}),hz=[`for`],gz=[`id`,`aria-invalid`,`aria-describedby`],_z=[`id`],vz=[`id`],yz=N({inheritAttrs:!1,__name:`TextField`,props:Ba({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=co(e,`modelValue`),r=ui(),i=U(()=>t.hint||t.error?`${r}-hint`:void 0);return(e,a)=>(I(),L(`div`,{class:D(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(I(),L(`label`,{key:0,for:j(r),class:D(j(bF))},O(t.label),11,hz)):H(``,!0),xr(z(`input`,Ns({id:j(r),"onUpdate:modelValue":a[0]||=e=>n.value=e,class:j(Q)(j(SF),t.error&&`border-danger`),"aria-invalid":t.error?!0:void 0,"aria-describedby":i.value},e.$attrs),null,16,gz),[[iu,n.value]]),t.error?(I(),L(`p`,{key:1,id:`${j(r)}-hint`,class:`text-2xs text-danger`},O(t.error),9,_z)):t.hint?(I(),L(`p`,{key:2,id:`${j(r)}-hint`,class:D(j(xF))},O(t.hint),11,vz)):H(``,!0)],2))}}),bz={class:`block text-xs text-ink`},xz={key:0,class:`block text-2xs text-faint`},Sz=N({__name:`ToggleSwitch`,props:Ba({label:{},hint:{default:void 0},disabled:{type:Boolean,default:!1},trailing:{type:Boolean,default:!1},wide:{type:Boolean,default:!1}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=co(e,`modelValue`);return(e,r)=>(I(),L(`div`,{class:D(j(Q)(`flex items-center gap-2.5`,t.trailing&&`flex-row-reverse justify-end`,t.wide&&`sm:col-span-2`))},[B(j(lg),{modelValue:n.value,"onUpdate:modelValue":r[0]||=e=>n.value=e,disabled:t.disabled,class:D(j(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`,j(yF)))},{default:M(()=>[B(j(ug),{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`]),z(`label`,{class:`min-w-0 cursor-pointer select-none`,onClick:r[1]||=e=>!t.disabled&&(n.value=!n.value)},[z(`span`,bz,O(t.label),1),t.hint?(I(),L(`span`,xz,O(t.hint),1)):H(``,!0)])],2))}}),Cz=N({__name:`LifecycleFields`,props:Ba({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=co(e,`restart`),n=co(e,`health`),r=co(e,`stop`);function i(e,t,n=0){return U({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=U({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)=>(I(),L(F,null,[B(cz,{title:`Restart policy`,description:`Backoff between attempts after a crash.`,columns:3},{default:M(()=>[B(Sz,{modelValue:t.value.enabled,"onUpdate:modelValue":y[0]||=e=>t.value.enabled=e,label:`Restart on crash`,wide:``},null,8,[`modelValue`]),B(mz,{modelValue:j(a),"onUpdate:modelValue":y[1]||=e=>k(a)?a.value=e:null,label:`Max retries`,min:0,hint:`Attempts before the server is left crashed.`},null,8,[`modelValue`]),B(mz,{modelValue:j(o),"onUpdate:modelValue":y[2]||=e=>k(o)?o.value=e:null,label:`Base delay (ms)`,min:0},null,8,[`modelValue`]),B(mz,{modelValue:j(s),"onUpdate:modelValue":y[3]||=e=>k(s)?s.value=e:null,label:`Backoff factor`,min:1,step:.1},null,8,[`modelValue`]),B(mz,{modelValue:j(c),"onUpdate:modelValue":y[4]||=e=>k(c)?c.value=e:null,label:`Max delay (ms)`,min:0},null,8,[`modelValue`]),B(mz,{modelValue:j(l),"onUpdate:modelValue":y[5]||=e=>k(l)?l.value=e:null,label:`Reset after (ms)`,min:0,hint:`A run this long clears the retry counter.`},null,8,[`modelValue`])]),_:1}),B(cz,{title:`Health check`,description:`How readiness is probed once the process is up.`,columns:3},{default:M(()=>[B(Sz,{modelValue:n.value.enabled,"onUpdate:modelValue":y[6]||=e=>n.value.enabled=e,label:`Probe this server`,wide:``},null,8,[`modelValue`]),B(_L,{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`]),B(mz,{modelValue:j(u),"onUpdate:modelValue":y[8]||=e=>k(u)?u.value=e:null,label:`Interval (ms)`,min:500,step:100},null,8,[`modelValue`]),B(mz,{modelValue:j(d),"onUpdate:modelValue":y[9]||=e=>k(d)?d.value=e:null,label:`Timeout (ms)`,min:100,step:100},null,8,[`modelValue`]),B(mz,{modelValue:j(f),"onUpdate:modelValue":y[10]||=e=>k(f)?f.value=e:null,label:`Unhealthy after`,min:1,hint:`Consecutive failed probes.`},null,8,[`modelValue`]),B(mz,{modelValue:j(p),"onUpdate:modelValue":y[11]||=e=>k(p)?p.value=e:null,label:`Force restart after (ms)`,min:0,hint:`0 disables it.`},null,8,[`modelValue`]),B(mz,{modelValue:j(m),"onUpdate:modelValue":y[12]||=e=>k(m)?m.value=e:null,label:`Start timeout (ms)`,min:0},null,8,[`modelValue`]),e.showHttp&&n.value.mode===`http`?(I(),L(F,{key:0},[B(yz,{modelValue:n.value.http.path,"onUpdate:modelValue":y[13]||=e=>n.value.http.path=e,label:`HTTP path`,placeholder:`/healthz`},null,8,[`modelValue`]),B(_L,{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`]),B(mz,{modelValue:h.value,"onUpdate:modelValue":y[15]||=e=>h.value=e,label:`Expect status`,nullable:``,hint:`Blank accepts anything below.`},null,8,[`modelValue`]),B(mz,{modelValue:j(g),"onUpdate:modelValue":y[16]||=e=>k(g)?g.value=e:null,label:`Healthy below status`,min:100},null,8,[`modelValue`]),B(yz,{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)):H(``,!0)]),_:1}),B(cz,{title:`Stop behaviour`,description:`How the process tree is asked to go away.`,columns:3},{default:M(()=>[B(_L,{modelValue:r.value.signal,"onUpdate:modelValue":y[18]||=e=>r.value.signal=e,label:`Signal`,options:v},null,8,[`modelValue`]),B(mz,{modelValue:j(_),"onUpdate:modelValue":y[19]||=e=>k(_)?_.value=e:null,label:`Grace period (ms)`,min:0},null,8,[`modelValue`]),B(Sz,{modelValue:r.value.killGroup,"onUpdate:modelValue":y[20]||=e=>r.value.killGroup=e,label:`Kill the whole process group`},null,8,[`modelValue`]),B(Sz,{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))}}),wz=[`open`],Tz={class:`flex cursor-pointer list-none select-none items-center gap-1.5 px-3 py-2 text-xs font-semibold text-ink [&::-webkit-details-marker]:hidden`},Ez={key:0,class:`ml-1 truncate text-2xs font-normal text-faint`},Dz={class:`grid gap-3 border-t border-line-soft px-3 py-3`},Oz=N({__name:`Disclosure`,props:{title:{},hint:{default:void 0},open:{type:Boolean,default:!1}},setup(e){let t=e;return(e,n)=>(I(),L(`details`,{class:`group rounded-panel border border-line bg-panel-2/40`,open:t.open},[z(`summary`,Tz,[B(j(Rv),{class:`size-3.5 shrink-0 text-muted transition-transform duration-150 group-open:rotate-90`,"aria-hidden":`true`}),V(` `+O(t.title)+` `,1),t.hint?(I(),L(`span`,Ez,O(t.hint),1)):H(``,!0)]),z(`div`,Dz,[P(e.$slots,`default`)])],8,wz))}}),kz=[`for`],Az=[`id`,`rows`,`placeholder`],jz={key:1,class:`text-2xs text-danger`},Mz=N({inheritAttrs:!1,__name:`TextAreaField`,props:Ba({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=co(e,`modelValue`),r=ui();return(e,i)=>(I(),L(`div`,{class:D(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(I(),L(`label`,{key:0,for:j(r),class:D(j(bF))},O(t.label),11,kz)):H(``,!0),xr(z(`textarea`,Ns({id:j(r),"onUpdate:modelValue":i[0]||=e=>n.value=e,rows:t.rows,placeholder:t.placeholder,spellcheck:`false`,class:j(Q)(t.mono?j(CF):`font-sans`,`resize-y leading-relaxed`,t.error&&`border-danger`)},e.$attrs),null,16,Az),[[Yl,n.value]]),t.error?(I(),L(`p`,jz,O(t.error),1)):t.hint?(I(),L(`p`,{key:2,class:D(j(xF))},O(t.hint),3)):H(``,!0)],2))}}),Nz={class:`rounded-panel border border-line-soft bg-panel-2/40 p-3`},Pz={class:`mt-1.5 flex flex-wrap gap-1`},Fz={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`},Iz=N({__name:`AddServerDialog`,props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:Ba([`created`],[`update:open`]),setup(e,{emit:t}){let n=t,r=co(e,`open`),i=jM(),a=A(!1),o=A(null),s=[`{port}`,`{host}`,`{home}`,`{projectDir}`,`{dataRoot}`,`{id}`,`{label}`,`{cwd}`,`{bind}`,`{lanIp}`],c=U(()=>i.defaults.value??void 0),l=tn(ZR(c.value)),u=U(()=>ez(l.port));function d(){Object.assign(l,ZR(c.value)),o.value=null}jr(r,e=>{e&&d()});async function f(){o.value=null;let e=nz(l);if(e!==null){o.value=e;return}let t=SA(tz(l,c.value));if(t instanceof Y.errors){o.value=t.summary;return}a.value=!0;try{if(await i.create(t),i.lastError.value!==null){o.value=i.lastError.value;return}n(`created`),r.value=!1,d()}finally{a.value=!1}}return(e,t)=>(I(),R(dL,{open:r.value,"onUpdate:open":t[28]||=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:M(()=>[B($,{variant:`ghost`,onClick:t[27]||=e=>r.value=!1},{default:M(()=>[...t[31]||=[V(` Cancel `,-1)]]),_:1}),B($,{type:`submit`,form:`add-server-form`,variant:`primary`,loading:a.value},{default:M(()=>[...t[32]||=[V(` Add to servers.config.json `,-1)]]),_:1},8,[`loading`])]),default:M(()=>[z(`form`,{id:`add-server-form`,class:`flex flex-col gap-3`,onSubmit:uu(f,[`prevent`])},[B(cz,{title:`Identity`,columns:2,dense:``},{default:M(()=>[B(yz,{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`]),B(yz,{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}),B(cz,{title:`Process`,columns:2,dense:``},{default:M(()=>[B(yz,{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`]),B(yz,{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}),B(Mz,{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
42
- {port}`},null,8,[`modelValue`]),B(cz,{title:`Port & lifecycle`,columns:2,dense:``},{default:M(()=>[B(mz,{modelValue:l.port,"onUpdate:modelValue":t[5]||=e=>l.port=e,label:`Port`,nullable:``,min:1,max:65535,error:u.value,hint:`Blank means the server has no port to probe or preflight.`},null,8,[`modelValue`,`error`]),B(_L,{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`]),B(Sz,{modelValue:l.autostart,"onUpdate:modelValue":t[7]||=e=>l.autostart=e,label:`Autostart with up`,hint:`Start it whenever the control plane comes up.`,wide:``},null,8,[`modelValue`])]),_:1}),B(Oz,{title:`Advanced settings`,hint:`environment, backups, policy, lifecycle, bootstrap`},{default:M(()=>[B(cz,{title:`Environment`,columns:2,dense:``},{default:M(()=>[B(Mz,{modelValue:l.env,"onUpdate:modelValue":t[8]||=e=>l.env=e,label:`Environment`,rows:3,hint:`KEY=value per line, exported to the process.`,placeholder:`NODE_ENV=production`},null,8,[`modelValue`]),B(Mz,{modelValue:l.dataEnvs,"onUpdate:modelValue":t[9]||=e=>l.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`]),B(yz,{modelValue:l.envFile,"onUpdate:modelValue":t[10]||=e=>l.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`]),B(yz,{modelValue:l.dependsOn,"onUpdate:modelValue":t[11]||=e=>l.dependsOn=e,label:`Depends on`,placeholder:`postgres, redis`,hint:`Comma separated; started first, stopped last.`,class:`font-mono text-xs`},null,8,[`modelValue`])]),_:1}),B(cz,{title:`Backups`,columns:2,dense:``},{default:M(()=>[B(Mz,{modelValue:l.backupPaths,"onUpdate:modelValue":t[12]||=e=>l.backupPaths=e,label:`Extra backup paths`,rows:2,hint:`One per line, placeholders allowed; data envs are captured already.`,placeholder:`{home}/.app/uploads`},null,8,[`modelValue`]),B(Sz,{modelValue:l.backupIgnoreGenerated,"onUpdate:modelValue":t[13]||=e=>l.backupIgnoreGenerated=e,label:`Ignore known generated files`,hint:`Skips node_modules, dist, .next and the other caches nothing restores from.`,wide:``},null,8,[`modelValue`])]),_:1}),B(Cz,{restart:l.restart,"onUpdate:restart":t[14]||=e=>l.restart=e,health:l.health,"onUpdate:health":t[15]||=e=>l.health=e,stop:l.stop,"onUpdate:stop":t[16]||=e=>l.stop=e},null,8,[`restart`,`health`,`stop`]),B(cz,{title:`Bootstrap`,description:`A one-off command run before the first start.`,columns:2,dense:``},{default:M(()=>[B(Sz,{modelValue:l.bootstrapEnabled,"onUpdate:modelValue":t[17]||=e=>l.bootstrapEnabled=e,label:`Run a bootstrap`,hint:`Installs, migrations, downloads — before the first start, not on every one.`,wide:``},null,8,[`modelValue`]),l.bootstrapEnabled?(I(),L(F,{key:0},[B(yz,{modelValue:l.bootstrapCommand,"onUpdate:modelValue":t[18]||=e=>l.bootstrapCommand=e,label:`Command`,placeholder:`./scripts/install.sh`,class:`font-mono text-xs`},null,8,[`modelValue`]),B(mz,{modelValue:l.bootstrapTimeoutMs,"onUpdate:modelValue":t[19]||=e=>l.bootstrapTimeoutMs=e,label:`Timeout (ms)`,min:1e3,step:1e3},null,8,[`modelValue`]),B(Sz,{modelValue:l.bootstrapRunOnce,"onUpdate:modelValue":t[20]||=e=>l.bootstrapRunOnce=e,label:`Only once per session`,hint:`Off means every start re-runs it.`},null,8,[`modelValue`]),B(Mz,{modelValue:l.bootstrapArgs,"onUpdate:modelValue":t[21]||=e=>l.bootstrapArgs=e,label:`Bootstrap arguments`,rows:2,hint:`One per line; same placeholders as the main arguments.`},null,8,[`modelValue`]),B(Mz,{modelValue:l.bootstrapEnv,"onUpdate:modelValue":t[22]||=e=>l.bootstrapEnv=e,label:`Bootstrap environment`,rows:2,hint:`KEY=value per line, exported to the bootstrap process only.`},null,8,[`modelValue`])],64)):H(``,!0)]),_:1}),B(cz,{title:`Policy & resources`,columns:2,dense:``},{default:M(()=>[B(_L,{modelValue:l.onPortConflict,"onUpdate:modelValue":t[23]||=e=>l.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`},{value:`kill`,label:`kill — stop whatever holds the port`}]},null,8,[`modelValue`]),B(mz,{modelValue:l.logBufferLines,"onUpdate:modelValue":t[24]||=e=>l.logBufferLines=e,label:`Log buffer lines`,min:50,max:1e5,step:50,hint:`Blank keeps the default.`},null,8,[`modelValue`]),B(mz,{modelValue:l.maxRssMb,"onUpdate:modelValue":t[25]||=e=>l.maxRssMb=e,label:`Max RSS (MB)`,min:0,hint:`Restart above this; blank or 0 disables it.`},null,8,[`modelValue`]),B(Sz,{modelValue:l.enabled,"onUpdate:modelValue":t[26]||=e=>l.enabled=e,label:`Enabled`,hint:`Off keeps the entry in the config but refuses to start it.`,wide:``},null,8,[`modelValue`])]),_:1}),t[29]||=z(`p`,{class:`text-2xs leading-4 text-faint`},[V(` Restart, health and stop start out matching `),z(`span`,{class:`font-mono`},`Settings → Server defaults`),V(`; change one here and it is written into this entry instead of staying inherited. `)],-1)]),_:1}),z(`div`,Nz,[t[30]||=z(`p`,{class:`text-2xs font-medium text-muted`},` Available argument placeholders `,-1),z(`div`,Pz,[(I(),L(F,null,ya(s,e=>z(`code`,{key:e,class:`rounded-control border border-line bg-raise px-1.5 py-0.5 font-mono text-2xs text-ink`},O(e),1)),64))])]),o.value?(I(),L(`p`,Fz,O(o.value),1)):H(``,!0)],32)]),_:1},8,[`open`]))}}),Lz={class:`text-xs font-semibold text-ink`},Rz={class:`mt-2.5 flex justify-end gap-1.5`},zz=N({__name:`KillPortButton`,props:{port:{},busy:{type:Boolean,default:!1}},emits:[`confirm`],setup(e,{emit:t}){let n=e,r=t,i=A(!1);function a(){i.value=!1,r(`confirm`)}return(e,t)=>(I(),R(j(Gh),{open:i.value,"onUpdate:open":t[0]||=e=>i.value=e},{default:M(()=>[B(j(Qh),{"as-child":``},{default:M(()=>[B($,{variant:`danger-ghost`,size:`xs`,loading:n.busy},{default:M(()=>[V(` Kill what holds port `+O(n.port),1)]),_:1},8,[`loading`])]),_:1}),B(j(Zh),null,{default:M(()=>[B(j(Xh),{"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:M(()=>[z(`p`,Lz,` Kill the process on port `+O(n.port)+`? `,1),t[3]||=z(`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),z(`div`,Rz,[B(j(Kh),{"as-child":``},{default:M(()=>[B($,{size:`xs`,variant:`ghost`},{default:M(()=>[...t[1]||=[V(` Keep it `,-1)]]),_:1})]),_:1}),B($,{size:`xs`,variant:`danger`,loading:n.busy,onClick:a},{default:M(()=>[...t[2]||=[V(` Kill it `,-1)]]),_:1},8,[`loading`])])]),_:1})]),_:1})]),_:1},8,[`open`]))}}),Bz=[`viewBox`],Vz=[`id`],Hz=[`stop-color`],Uz=[`stop-color`],Wz=[`d`,`fill`],Gz=[`d`,`stroke`,`stroke-width`],Kz=[`x1`,`x2`,`y2`,`stroke`],qz=[`cx`,`cy`,`fill`],Jz={key:0,class:`absolute inset-x-0 top-1/2 border-t border-dashed border-line`},Yz=100,Xz=N({__name:`Sparkline`,props:Ba({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=co(e,`hoverIndex`),r=ui(),i=A(null),a=U(()=>{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=U(()=>{let e=t.values,{bottom:n,ceiling:r}=a.value,i=r-n,o=e.length>1?Yz/(e.length-1):Yz,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=U(()=>n.value===null||t.values.length<2?null:n.value/(t.values.length-1)*Yz),c=U(()=>{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)=>(I(),L(`div`,{ref_key:`track`,ref:i,class:D(j(Q)(`relative w-full`,t.class)),style:_e({height:`${t.height}px`}),onMousemove:l,onMouseleave:u},[(I(),L(`svg`,{viewBox:`0 0 ${Yz} ${t.height}`,preserveAspectRatio:`none`,class:`block size-full overflow-visible`,role:`img`,"aria-hidden":`true`},[z(`defs`,null,[z(`linearGradient`,{id:j(r),x1:`0`,y1:`0`,x2:`0`,y2:`1`},[z(`stop`,{offset:`0%`,"stop-color":t.color??`currentColor`,"stop-opacity":`0.26`},null,8,Hz),z(`stop`,{offset:`100%`,"stop-color":t.color??`currentColor`,"stop-opacity":`0`},null,8,Uz)],8,Vz)]),(I(!0),L(F,null,ya(o.value,(e,n)=>(I(),L(F,{key:n},[t.fill?(I(),L(`path`,{key:0,d:e.area,fill:`url(#${j(r)})`,stroke:`none`},null,8,Wz)):H(``,!0),z(`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,Gz)],64))),128)),s.value===null?H(``,!0):(I(),L(`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,Kz)),s.value!==null&&c.value!==null?(I(),L(`circle`,{key:1,cx:s.value,cy:c.value,r:`2`,fill:t.color??`currentColor`,"vector-effect":`non-scaling-stroke`},null,8,qz)):H(``,!0)],8,Bz)),o.value.length===0?(I(),L(`div`,Jz)):H(``,!0)],38))}}),Zz={class:`min-w-0`},Qz={class:`flex items-baseline justify-between gap-2`},$z={class:`truncate text-2xs font-medium text-faint`},eB={class:`flex shrink-0 items-baseline gap-1.5`},tB={key:0,class:`font-mono text-2xs text-faint`},nB=N({__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=A(null),r=U(()=>aM(t.values)),i=U(()=>t.values.some(e=>e!==null)),a=U(()=>{let e=n.value;return e!==null&&t.values[e]!==void 0?t.values[e]??null:r.value}),o=U(()=>{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)=>(I(),L(`div`,Zz,[z(`div`,Qz,[z(`span`,$z,O(t.label),1),z(`span`,eB,[o.value?(I(),L(`span`,tB,O(o.value),1)):H(``,!0),z(`span`,{class:D(j(Q)(`font-mono text-xs font-medium tabular-nums`,i.value?`text-ink`:`text-faint`))},O(i.value?t.format(a.value):t.emptyHint),3)])]),B(Xz,{"hover-index":n.value,"onUpdate:hoverIndex":r[0]||=e=>n.value=e,values:t.values,height:t.height,max:t.max,interactive:``,class:D(j(Q)(`mt-1`,t.colorClass))},null,8,[`hover-index`,`values`,`height`,`max`,`class`])]))}}),rB={class:`inline-flex flex-wrap items-center gap-1.5`},iB={class:`relative flex size-1.5`},aB={key:0,class:`absolute inset-0 rounded-full bg-current opacity-60`,style:{animation:`hh-pulse-ring 1.6s ease-out infinite`}},oB=N({__name:`StatusPill`,props:{status:{},health:{default:null},showHealth:{type:Boolean,default:!0}},setup(e){let t=e,n=U(()=>hP[t.status]),r=U(()=>t.health?gP[t.health]:null),i=U(()=>t.showHealth&&r.value!==null&&t.health!==`disabled`&&t.health!==`unknown`&&(r.value.tone===`danger`||r.value.tone===`warn`)),a=U(()=>n.value.transitional);return(e,t)=>(I(),L(`span`,rB,[z(`span`,{class:D(j(Q)(`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-2xs font-medium`,j(vP)[n.value.tone]))},[z(`span`,iB,[a.value?(I(),L(`span`,aB)):H(``,!0),z(`span`,{class:D(j(Q)(`relative size-1.5 rounded-full`,j(yP)[n.value.tone]))},null,2)]),V(` `+O(n.value.label),1)],2),i.value&&r.value?(I(),L(`span`,{key:0,class:D(j(Q)(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-2xs font-medium`,j(vP)[r.value.tone]))},O(r.value.label),3)):H(``,!0)]))}}),sB={class:`flex items-start justify-between gap-3 px-4 pb-2.5 pt-3.5`},cB={class:`min-w-0`},lB={class:`flex items-center gap-2`},uB=[`href`,`title`,`aria-label`],dB={class:`mt-0.5 flex items-center gap-1.5 truncate font-mono text-2xs text-faint`},fB={class:`text-muted`},pB={key:1,class:`rounded bg-hover px-1 py-px text-muted`},mB={key:2,class:`rounded bg-accent-soft px-1 py-px text-accent`},hB=[`title`],gB={key:0,class:`space-y-2.5 border-y border-line-soft px-4 py-3`},_B={class:`grid grid-cols-2 gap-x-4 gap-y-2`},vB={key:1,class:`flex flex-wrap items-center gap-x-3 gap-y-1 px-4 pt-2.5`},yB={class:`text-muted`},bB={class:`text-faint`},xB={key:2,class:`flex flex-col gap-1 px-4 pt-2.5`},SB={key:0,class:`flex items-start gap-1.5 text-2xs leading-4 text-danger`},CB={class:`min-w-0 break-words`},wB={key:2,class:`text-2xs leading-4 text-warn`},TB={key:3,class:`text-2xs leading-4 text-warn`},EB={class:`grid grid-cols-2 gap-x-4 gap-y-1 px-4 py-3 sm:grid-cols-4`},DB={class:`truncate text-2xs text-faint`},OB={class:`truncate font-mono text-xs tabular-nums text-ink capitalize`},kB={class:`mt-auto flex items-center gap-1.5 border-t border-line-soft px-4 py-2.5`},AB={class:`grid grid-cols-2 gap-2 text-xs`},jB={class:`font-mono text-ink`},MB={class:`text-ink capitalize`},NB=N({__name:`ServerCard`,props:{server:{},series:{},now:{},variant:{default:`default`}},setup(e){let t=e,n={start:py,exit:Ey,crash:Bv,"forced-restart":vy,unhealthy:My,recovered:Vv},r=jM(),i=A(!1),a=A(!1),o=U(()=>t.server.config),s=U(()=>o.value.label&&o.value.label.length>0?o.value.label:t.server.id),c=U(()=>`${o.value.command} ${o.value.args.join(` `)}`.trim()),l=U(()=>bP(t.server.status,t.server.health)),u=U(()=>t.server.status===`running`),d=U(()=>o.value.enabled&&[`stopped`,`crashed`,`conflict`].includes(t.server.status)),f=U(()=>[`running`,`starting`,`backoff`].includes(t.server.status)),p=U(()=>t.server.startedAt===null||!u.value?`—`:wI(t.now-t.server.startedAt)),m=U(()=>t.server.nextRetryAt===null?null:TI(t.server.nextRetryAt,t.now)),h=U(()=>t.server.unhealthySince===null?null:wI(t.now-t.server.unhealthySince)),g=U(()=>t.series?.cpu??[]),_=U(()=>t.series?.rss??[]),v=U(()=>t.series?.probe??[]),y=U(()=>[...t.server.history.events].slice(-3).reverse()),b=U(()=>{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:EI(e.history.uptimeRatio)},{key:`probe`,label:`Probe`,value:e.responseMs===null?`—`:`${e.responseMs} ms`},{key:`rss`,label:`RSS`,value:kI(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:DI(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=pa(`RouterLink`);return I(),L(`article`,{class:D(j(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`))},[z(`span`,{class:D(j(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),z(`header`,sB,[z(`div`,cB,[z(`div`,lB,[B(T,{to:`/servers/${e.server.id}`,class:`truncate text-sm font-semibold tracking-tight text-ink hover:text-accent`},{default:M(()=>[V(O(s.value),1)]),_:1},8,[`to`]),e.server.url?(I(),L(`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}`},[B(j(Xv),{class:`size-3.5`})],8,uB)):H(``,!0)]),z(`p`,dB,[z(`span`,null,O(e.server.id),1),o.value.port===null?H(``,!0):(I(),L(F,{key:0},[p[9]||=z(`span`,{"aria-hidden":`true`},`·`,-1),z(`span`,fB,`:`+O(o.value.port),1)],64)),p[10]||=z(`span`,{"aria-hidden":`true`},`·`,-1),z(`span`,null,O(e.server.bindHost),1),o.value.enabled?H(``,!0):(I(),L(`span`,pB,`disabled`)),o.value.autostart?(I(),L(`span`,mB,`autostart`)):H(``,!0)])]),B(oB,{status:e.server.status,health:e.server.health},null,8,[`status`,`health`]),e.server.adopted?(I(),R(TF,{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:M(()=>[...p[11]||=[z(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`detached`,-1)]]),_:1})):H(``,!0)]),z(`p`,{class:`truncate px-4 pb-3 font-mono text-2xs text-muted`,title:c.value},O(c.value),9,hB),t.variant===`compact`?H(``,!0):(I(),L(`div`,gB,[z(`div`,_B,[B(nB,{label:`CPU`,values:g.value,format:j(AI),max:100,"color-class":`text-cpu`},null,8,[`values`,`format`]),B(nB,{label:`Memory`,values:_.value,format:j(kI),"color-class":`text-mem`},null,8,[`values`,`format`])]),B(nB,{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?(I(),L(`div`,vB,[(I(!0),L(F,null,ya(y.value,e=>(I(),L(`span`,{key:`${e.ts}`,class:`inline-flex items-center gap-1 text-2xs`},[(I(),R(ha(n[e.type]),{class:D(j(Q)(`size-3`,j(_P)[j(SP)[e.type]]))},null,8,[`class`])),z(`span`,yB,O(j(xP)[e.type]),1),z(`span`,bB,O(j(DI)(e.ts,t.now)),1)]))),128))])):H(``,!0),e.server.lastError||h.value||m.value?(I(),L(`div`,xB,[e.server.lastError?(I(),L(`p`,SB,[B(j(Bv),{class:`mt-0.5 size-3 shrink-0`}),z(`span`,CB,O(e.server.lastError),1)])):H(``,!0),e.server.status===`conflict`&&o.value.port!==null?(I(),R(zz,{key:1,port:o.value.port,busy:i.value,class:`self-start`,onConfirm:S},null,8,[`port`,`busy`])):H(``,!0),h.value?(I(),L(`p`,wB,` Unhealthy for `+O(h.value),1)):H(``,!0),m.value?(I(),L(`p`,TB,` Next attempt `+O(m.value),1)):H(``,!0)])):H(``,!0),z(`dl`,EB,[(I(!0),L(F,null,ya(b.value,e=>(I(),L(`div`,{key:e.key,class:`min-w-0`},[z(`dt`,DB,O(e.label),1),z(`dd`,OB,O(e.value),1)]))),128))]),z(`div`,kB,[B($,{variant:`primary`,size:`xs`,disabled:i.value||!d.value,onClick:p[0]||=e=>x(`start`)},{default:M(()=>[B(j(py),{class:`size-3`}),p[12]||=V(`Start `,-1)]),_:1},8,[`disabled`]),B($,{size:`xs`,disabled:i.value||!f.value,onClick:p[1]||=e=>x(`stop`)},{default:M(()=>[B(j(Ey),{class:`size-3`}),p[13]||=V(`Stop `,-1)]),_:1},8,[`disabled`]),B($,{size:`xs`,disabled:i.value||!o.value.enabled,onClick:p[2]||=e=>x(`restart`)},{default:M(()=>[B(j(vy),{class:`size-3`}),p[14]||=V(`Restart `,-1)]),_:1},8,[`disabled`]),B(TF,{label:`Live logs and full telemetry`},{default:M(()=>[B(T,{to:`/servers/${e.server.id}`},{default:M(()=>[B($,{size:`xs`,variant:`ghost`},{default:M(()=>[B(j(yy),{class:`size-3`}),p[15]||=V(`Details `,-1)]),_:1})]),_:1},8,[`to`])]),_:1}),B(j(tg),null,{default:M(()=>[B(j(og),{"as-child":``},{default:M(()=>[B($,{size:`icon-sm`,variant:`ghost`,class:`ml-auto`,"aria-label":`More actions for ${s.value}`},{default:M(()=>[B(j(Yv),{class:`size-4`})]),_:1},8,[`aria-label`])]),_:1}),B(j(ig),null,{default:M(()=>[B(j(ng),{"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:M(()=>[B(j(rg),{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:M(()=>[B(j(hy),{class:`size-3.5`}),V(` `+O(o.value.enabled?`Disable server`:`Enable server`),1)]),_:1}),B(j(rg),{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:M(()=>[B(j(py),{class:`size-3.5`}),V(` `+O(o.value.autostart?`Remove from autostart`:`Autostart with the panel`),1)]),_:1}),B(j(rg),{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=>j(r).clearLogs(e.server.id)},{default:M(()=>[B(j(yy),{class:`size-3.5`}),p[16]||=V(` Clear log buffer `,-1)]),_:1}),B(j(ag),{class:`my-1 h-px bg-line`}),B(j(rg),{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:M(()=>[B(j(jy),{class:`size-3.5`}),p[17]||=V(` Remove server `,-1)]),_:1})]),_:1})]),_:1})]),_:1})]),B(dL,{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:M(()=>[B($,{variant:`ghost`,onClick:p[7]||=e=>a.value=!1},{default:M(()=>[...p[20]||=[V(` Keep it `,-1)]]),_:1}),B($,{variant:`danger`,onClick:w},{default:M(()=>[B(j(jy),{class:`size-3.5`}),p[21]||=V(`Remove `,-1)]),_:1})]),default:M(()=>[z(`dl`,AB,[z(`div`,null,[p[18]||=z(`dt`,{class:`text-faint`},` id `,-1),z(`dd`,jB,O(e.server.id),1)]),z(`div`,null,[p[19]||=z(`dt`,{class:`text-faint`},` status `,-1),z(`dd`,MB,O(e.server.status),1)])])]),_:1},8,[`open`,`description`])],2)}}}),PB={class:`flex flex-wrap items-start justify-between gap-3`},FB={class:`min-w-0`},IB={class:`flex flex-wrap items-center gap-x-3 gap-y-1.5`},LB={class:`text-2xl font-semibold tracking-tight text-ink`},RB={key:1,class:`mt-1 max-w-2xl text-xs leading-relaxed text-muted`},zB={class:`flex shrink-0 flex-wrap items-center gap-2`},BB=N({__name:`PageHeader`,props:{title:{},description:{default:void 0},backTo:{default:void 0},backLabel:{default:`Back`}},setup(e){return(e,t)=>{let n=pa(`RouterLink`);return I(),L(`header`,PB,[z(`div`,FB,[e.$props.backTo?(I(),R(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:M(()=>[B(j(Lv),{class:`size-3`}),V(` `+O(e.$props.backLabel),1)]),_:1},8,[`to`])):H(``,!0),z(`div`,IB,[z(`h1`,LB,O(e.$props.title),1),P(e.$slots,`badges`)]),e.$props.description?(I(),L(`p`,RB,O(e.$props.description),1)):H(``,!0)]),z(`div`,zB,[P(e.$slots,`actions`)])])}}}),VB={key:0,class:`mb-3 flex items-start justify-between gap-3`},HB={class:`min-w-0`},UB={class:`flex shrink-0 items-center gap-1.5`},WB=N({__name:`Panel`,props:{padded:{type:Boolean,default:!0},class:{}},setup(e){return(e,t)=>(I(),L(`section`,{class:D(j(mP)(`rounded-panel border border-line bg-panel shadow-card`,e.$props.padded&&`p-4`,e.$props.class))},[e.$slots.header||e.$slots.actions?(I(),L(`header`,VB,[z(`div`,HB,[P(e.$slots,`header`)]),z(`div`,UB,[P(e.$slots,`actions`)])])):H(``,!0),P(e.$slots,`default`)],2))}}),GB={class:`min-w-0`},KB={class:`truncate text-2xs font-medium text-faint`},qB={key:0,class:`mt-0.5 truncate text-2xs text-muted`},JB=N({__name:`StatTile`,props:{label:{},value:{},hint:{default:void 0},tone:{default:`neutral`},mono:{type:Boolean,default:!0}},setup(e){return(e,t)=>(I(),L(`div`,GB,[z(`p`,KB,O(e.$props.label),1),z(`p`,{class:D(j(Q)(`mt-0.5 truncate text-xl font-semibold tracking-tight`,e.$props.mono&&`font-mono tabular-nums`,e.$props.tone===`neutral`?`text-ink`:j(_P)[e.$props.tone]))},O(e.$props.value),3),e.$props.hint?(I(),L(`p`,qB,O(e.$props.hint),1)):H(``,!0)]))}}),YB=A(null),XB=A(`unknown`),ZB=null;async function QB(){try{let e=await(await fetch(`/healthz`,{cache:`no-store`})).json();typeof e.uptimeMs==`number`&&(YB.value=Date.now()-e.uptimeMs),XB.value=e.status===`degraded`?`degraded`:`ok`}catch{XB.value=`unknown`}}function $B(){return ZB??=QB().finally(()=>{ZB=null}),{startedAt:YB,status:XB,refresh:QB}}var eV={class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},tV={key:0,class:`grid grid-cols-2 gap-4 p-4 sm:grid-cols-3 lg:grid-cols-6`},nV={key:1,class:`grid grid-cols-2 divide-line-soft sm:grid-cols-3 sm:divide-x lg:grid-cols-6`},rV={class:`p-4`},iV={class:`p-4`},aV={class:`p-4`},oV={class:`p-4`},sV={class:`p-4`},cV={class:`p-4`},lV={key:0,class:`flex items-start gap-2.5 rounded-panel border border-danger/25 bg-danger-soft px-3.5 py-3`},uV={class:`min-w-0`},dV={class:`text-xs font-medium text-danger`},fV={class:`mt-0.5 flex flex-wrap gap-x-2 text-2xs text-danger`},pV={class:`space-y-3`},mV={class:`flex items-center justify-between`},hV={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},gV={key:0,class:`grid gap-4 lg:grid-cols-2`},_V={key:2,class:`grid gap-4 lg:grid-cols-2`},vV={class:`grid gap-4 lg:grid-cols-3`},yV={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},bV={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},xV={class:`flex flex-wrap items-center gap-x-3 gap-y-1 text-2xs text-faint`},SV={class:`flex items-center gap-1`},CV={class:`font-mono`},wV=N({__name:`OverviewView`,setup(e){let{servers:t,host:n,now:r,appState:i,seriesOf:a,startAll:o,stopAll:s}=jM(),c=$B(),l=A(!1),u=U(()=>i.value===null),d=U(()=>t.value.filter(e=>e.status===`running`)),f=U(()=>t.value.filter(e=>[`stopped`,`stopping`].includes(e.status))),p=U(()=>t.value.filter(e=>e.status===`crashed`||e.status===`conflict`||e.health===`unhealthy`)),m=U(()=>{let e=0;for(let t of d.value){let n=t.resources?.rssBytes;typeof n==`number`&&(e+=n)}return e}),h=U(()=>{let e=0;for(let n of t.value){let t=iM(a(n.id).rss);t>e&&(e=t)}return e}),g=U(()=>c.startedAt.value===null?`—`:wI(r.value-c.startedAt.value)),_=U(()=>n.value?.enabled?wI(n.value.uptimeMs):`—`),v=U(()=>{let e=0;for(let t of d.value)e+=t.resources?.cpuPercent??0;return e});return na(async()=>{await c.refresh()}),(e,y)=>{let b=pa(`RouterLink`);return I(),L(`div`,eV,[B(BB,{title:`Overview`,description:`Live state of everything this panel supervises, refreshed over a single event stream.`},{actions:M(()=>[B($,{variant:`ghost`,onClick:y[0]||=e=>j(o)()},{default:M(()=>[B(j(py),{class:`size-3.5`}),y[5]||=V(`Start all `,-1)]),_:1}),B($,{variant:`ghost`,onClick:y[1]||=e=>j(s)()},{default:M(()=>[B(j(Ey),{class:`size-3.5`}),y[6]||=V(`Stop all `,-1)]),_:1}),B($,{variant:`primary`,onClick:y[2]||=e=>l.value=!0},{default:M(()=>[B(j(my),{class:`size-3.5`}),y[7]||=V(`Add server `,-1)]),_:1})]),_:1}),B(WB,{class:`p-0`},{default:M(()=>[u.value?(I(),L(`div`,tV,[(I(),L(F,null,ya(6,e=>z(`div`,{key:e,class:`space-y-2`},[B(vL,{class:`h-2.5 w-16`}),B(vL,{class:`h-6 w-20`})])),64))])):(I(),L(`div`,nV,[z(`div`,rV,[B(JB,{label:`Running`,value:`${d.value.length}/${j(t).length}`,tone:`ok`,hint:`${j(t).length-d.value.length} not up`},null,8,[`value`,`hint`])]),z(`div`,iV,[B(JB,{label:`Stopped`,value:String(f.value.length),hint:`${j(t).filter(e=>e.config.enabled).length} enabled`},null,8,[`value`,`hint`])]),z(`div`,aV,[B(JB,{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`])]),z(`div`,oV,[B(JB,{label:`Process memory`,value:j(kI)(m.value),hint:h.value>0?`peak ${j(kI)(h.value)}`:`across the tree`},null,8,[`value`,`hint`])]),z(`div`,sV,[B(JB,{label:`Panel uptime`,value:g.value,hint:j(c).status.value===`degraded`?`degraded`:`serving`},null,8,[`value`,`hint`])]),z(`div`,cV,[B(JB,{label:`Host uptime`,value:_.value,hint:j(n)?.enabled?`${v.value.toFixed(1)}% cpu now`:`sampling off`},null,8,[`value`,`hint`])])]))]),_:1}),p.value.length>0?(I(),L(`div`,lV,[B(j(Bv),{class:`mt-0.5 size-4 shrink-0 text-danger`}),z(`div`,uV,[z(`p`,dV,O(p.value.length)+` server`+O(p.value.length===1?``:`s`)+` need a look `,1),z(`p`,fV,[(I(!0),L(F,null,ya(p.value,e=>(I(),R(b,{key:e.id,to:`/servers/${e.id}`,class:`font-mono underline-offset-2 hover:underline`},{default:M(()=>[V(O(e.id),1)]),_:2},1032,[`to`]))),128))])])])):H(``,!0),z(`section`,pV,[z(`div`,mV,[z(`h2`,hV,[B(j(xy),{class:`size-3.5 text-faint`}),y[8]||=V(` Servers `,-1)]),B(b,{to:`/servers`,class:`text-2xs text-muted transition-colors duration-150 hover:text-accent`},{default:M(()=>[...y[9]||=[V(` Open the full list `,-1)]]),_:1})]),u.value?(I(),L(`div`,gV,[(I(),L(F,null,ya(4,e=>B(vL,{key:e,class:`h-64 w-full`,rounded:`rounded-panel`})),64))])):j(t).length===0?(I(),R(oL,{key:1,title:`No servers yet`,description:`Add the first process this panel should keep alive.`},{icon:M(()=>[B(j(xy),{class:`size-4`})]),action:M(()=>[B($,{variant:`primary`,onClick:y[3]||=e=>l.value=!0},{default:M(()=>[B(j(my),{class:`size-3.5`}),y[10]||=V(`Add a server `,-1)]),_:1})]),_:1})):(I(),L(`div`,_V,[(I(!0),L(F,null,ya(j(t),e=>(I(),R(NB,{key:e.id,server:e,series:j(a)(e.id),now:j(r)},null,8,[`server`,`series`,`now`]))),128))]))]),z(`div`,vV,[B(WB,{class:`lg:col-span-2`},{header:M(()=>[z(`h2`,yV,[B(j(qv),{class:`size-3.5 text-faint`}),y[11]||=V(` Host vitals `,-1)])]),default:M(()=>[B(iR,{host:j(n),now:j(r)},null,8,[`host`,`now`])]),_:1}),B(WB,null,{header:M(()=>[z(`h2`,bV,[B(j(Mv),{class:`size-3.5 text-faint`}),y[12]||=V(` Recent activity `,-1)])]),actions:M(()=>[B(b,{to:`/logs`,class:`text-2xs text-muted transition-colors duration-150 hover:text-accent`},{default:M(()=>[...y[13]||=[V(` Logs `,-1)]]),_:1})]),default:M(()=>[B(fR,{servers:j(t),now:j(r),limit:10},null,8,[`servers`,`now`])]),_:1})]),z(`p`,xV,[z(`span`,SV,[B(j(Ay),{class:`size-3`}),y[14]||=V(`resource history is sampled every 5 s and kept for this session`,-1)]),z(`span`,CV,O(j(i)?.control.url),1),z(`span`,{class:D(j(Q)(`flex items-center gap-1`,j(c).status.value===`degraded`&&`text-danger`))},[z(`span`,{class:D(j(Q)(`size-1.5 rounded-full`,j(c).status.value===`degraded`?`bg-danger`:`bg-ok`))},null,2),V(` panel `+O(j(c).status.value),1)],2)]),B(Iz,{open:l.value,"onUpdate:open":y[4]||=e=>l.value=e},null,8,[`open`])])}}}),TV={class:`mb-4 flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`},EV={class:`flex items-center gap-2`},DV={class:`font-mono tabular-nums`},OV={key:1,class:`text-2xs text-faint`},kV={class:`flex flex-col gap-3`},AV={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`},jV={class:`mt-4 flex items-center justify-end gap-2 border-t border-line pt-3.5`},MV={class:`max-h-[60dvh] overflow-auto`},NV={key:0,class:`divide-y divide-line-soft`},PV={class:`font-mono text-xs text-ink`},FV={class:`ml-auto font-mono text-xs text-muted line-through`},IV={class:`font-mono text-xs text-accent`},LV={key:1,class:`text-xs text-muted`},RV=N({__name:`ServerConfigEditor`,props:{serverId:{},config:{}},emits:[`saved`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=[`restart`,`health`,`stop`],a=jM(),o=A(!1),s=A(null);function c(e){return e>0?Math.round(e/1024/1024):null}function l(e){return{label:e.label??``,command:e.command,cwd:e.cwd,args:e.args.join(`
41
+ `)}function JR(e){let t={};for(let n of KR(e)){let e=n.indexOf(`=`);e<=0||(t[n.slice(0,e).trim()]=n.slice(e+1).trim())}return t}function YR(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}var XR=/^[a-z0-9][a-z0-9_-]*$/;function ZR(e){return{id:``,label:``,command:``,args:``,cwd:``,port:null,bind:e?.bind??`local`,autostart:e?.autostart??!1,persistent:!1,enabled:e?.enabled??!0,onPortConflict:e?.onPortConflict??`block`,logBufferLines:null,dependsOn:``,envFile:``,env:``,dataEnvs:``,backupPaths:``,backupIgnoreGenerated:!0,maxRssMb:null,restart:{...e?.restart??SR},health:TR(e?.health??CR),stop:{...e?.stop??wR},bootstrapEnabled:!1,bootstrapCommand:``,bootstrapArgs:``,bootstrapEnv:``,bootstrapTimeoutMs:12e4,bootstrapRunOnce:!0}}function QR(e){return e!==null&&Number.isFinite(e)?e:0}function $R(e){return{args:[],cwd:`.`,env:{},dataEnvs:{},dependsOn:[],envFile:``,backupPaths:[],backupIgnoreGenerated:!0,resources:{maxRssBytes:0},bind:e?.bind??`local`,enabled:e?.enabled??!0,autostart:e?.autostart??!1,persistent:!1,onPortConflict:e?.onPortConflict??`block`,logBufferLines:e?.logBufferLines??500}}function ez(e){return e===null||Number.isNaN(e)||Number.isInteger(e)&&e>=1&&e<=65535?null:`Port must be a whole number between 1 and 65535.`}function tz(e,t){let n=QR(e.maxRssMb),r=QR(e.bootstrapTimeoutMs),i=$R(t),a=gR({restart:t?.restart??SR,health:t?.health??CR,stop:t?.stop??wR},{restart:e.restart,health:e.health,stop:e.stop});return{...gR(i,{args:KR(e.args),cwd:e.cwd.trim().length>0?e.cwd.trim():`.`,env:JR(e.env),dataEnvs:JR(e.dataEnvs),dependsOn:YR(e.dependsOn),envFile:e.envFile.trim(),backupPaths:KR(e.backupPaths),backupIgnoreGenerated:e.backupIgnoreGenerated,resources:{maxRssBytes:n>0?Math.round(n*1024*1024):0},bind:e.bind,enabled:e.enabled,autostart:e.autostart,persistent:e.persistent,onPortConflict:e.onPortConflict,logBufferLines:QR(e.logBufferLines)>0?QR(e.logBufferLines):i.logBufferLines}),...a,id:e.id.trim(),...e.label.trim().length===0?{}:{label:e.label.trim()},command:e.command.trim(),...e.port===null||Number.isNaN(e.port)?{}:{port:e.port},...e.bootstrapEnabled?{bootstrap:{command:e.bootstrapCommand.trim(),args:KR(e.bootstrapArgs),env:JR(e.bootstrapEnv),timeoutMs:r>=1e3?r:12e4,runOnce:e.bootstrapRunOnce}}:{}}}function nz(e){return e.id.trim().length===0?`An id is required — it is the key this server lives under.`:XR.test(e.id.trim())?e.command.trim().length===0?`A command is required — the executable the supervisor spawns.`:e.bootstrapEnabled&&e.bootstrapCommand.trim().length===0?`A bootstrap needs a command to run.`:ez(e.port):`The id must start with a lowercase letter or digit and contain only lowercase letters, digits, dashes and underscores.`}var rz={class:`mb-3 flex items-start justify-between gap-3`},iz={class:`min-w-0`},az={class:`text-xs font-semibold text-ink`},oz={key:0,class:`mt-0.5 text-2xs leading-4 text-muted`},sz={class:`flex shrink-0 items-center gap-2`},cz=N({__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=U(()=>({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)=>(I(),L(`section`,{class:D(j(Q)(`rounded-panel border border-line bg-panel-2/40`,t.dense?`p-3`:`p-3.5`,t.class))},[z(`header`,rz,[z(`div`,iz,[z(`h3`,az,O(t.title),1),t.description?(I(),L(`p`,oz,O(t.description),1)):H(``,!0)]),z(`div`,sz,[P(e.$slots,`actions`)])]),z(`div`,{class:D(j(Q)(`grid gap-3`,n.value))},[P(e.$slots,`default`)],2)],2))}});function lz(e){return e==null||Number.isNaN(e)?``:String(e)}function uz(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 dz=[`for`],fz=[`id`,`step`,`min`,`max`,`aria-invalid`],pz={key:1,class:`text-2xs text-danger`},mz=N({inheritAttrs:!1,__name:`NumberField`,props:Ba({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=co(e,`modelValue`),r=ui(),i=U({get:()=>lz(n.value),set:e=>{n.value=uz(e,t.nullable)}}),a=U(()=>n.value!==null&&Number.isNaN(n.value));return(e,n)=>(I(),L(`div`,{class:D(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(I(),L(`label`,{key:0,for:j(r),class:D(j(bF))},O(t.label),11,dz)):H(``,!0),xr(z(`input`,Ns({id:j(r),"onUpdate:modelValue":n[0]||=e=>i.value=e,type:`number`,inputmode:`numeric`,step:t.step,min:t.min,max:t.max,class:j(Q)(j(SF),`font-mono tabular-nums`,(t.error||a.value)&&`border-danger`),"aria-invalid":t.error||a.value?!0:void 0},e.$attrs),null,16,fz),[[Yl,i.value]]),t.error?(I(),L(`p`,pz,O(t.error),1)):t.hint?(I(),L(`p`,{key:2,class:D(j(xF))},O(t.hint),3)):H(``,!0)],2))}}),hz=[`for`],gz=[`id`,`aria-invalid`,`aria-describedby`],_z=[`id`],vz=[`id`],yz=N({inheritAttrs:!1,__name:`TextField`,props:Ba({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=co(e,`modelValue`),r=ui(),i=U(()=>t.hint||t.error?`${r}-hint`:void 0);return(e,a)=>(I(),L(`div`,{class:D(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(I(),L(`label`,{key:0,for:j(r),class:D(j(bF))},O(t.label),11,hz)):H(``,!0),xr(z(`input`,Ns({id:j(r),"onUpdate:modelValue":a[0]||=e=>n.value=e,class:j(Q)(j(SF),t.error&&`border-danger`),"aria-invalid":t.error?!0:void 0,"aria-describedby":i.value},e.$attrs),null,16,gz),[[iu,n.value]]),t.error?(I(),L(`p`,{key:1,id:`${j(r)}-hint`,class:`text-2xs text-danger`},O(t.error),9,_z)):t.hint?(I(),L(`p`,{key:2,id:`${j(r)}-hint`,class:D(j(xF))},O(t.hint),11,vz)):H(``,!0)],2))}}),bz={class:`block text-xs text-ink`},xz={key:0,class:`block text-2xs text-faint`},Sz=N({__name:`ToggleSwitch`,props:Ba({label:{},hint:{default:void 0},disabled:{type:Boolean,default:!1},trailing:{type:Boolean,default:!1},wide:{type:Boolean,default:!1}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=co(e,`modelValue`);return(e,r)=>(I(),L(`div`,{class:D(j(Q)(`flex items-center gap-2.5`,t.trailing&&`flex-row-reverse justify-end`,t.wide&&`sm:col-span-2`))},[B(j(lg),{modelValue:n.value,"onUpdate:modelValue":r[0]||=e=>n.value=e,disabled:t.disabled,class:D(j(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`,j(yF)))},{default:M(()=>[B(j(ug),{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`]),z(`label`,{class:`min-w-0 cursor-pointer select-none`,onClick:r[1]||=e=>!t.disabled&&(n.value=!n.value)},[z(`span`,bz,O(t.label),1),t.hint?(I(),L(`span`,xz,O(t.hint),1)):H(``,!0)])],2))}}),Cz=N({__name:`LifecycleFields`,props:Ba({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=co(e,`restart`),n=co(e,`health`),r=co(e,`stop`);function i(e,t,n=0){return U({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=U({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)=>(I(),L(F,null,[B(cz,{title:`Restart policy`,description:`Backoff between attempts after a crash.`,columns:3},{default:M(()=>[B(Sz,{modelValue:t.value.enabled,"onUpdate:modelValue":y[0]||=e=>t.value.enabled=e,label:`Restart on crash`,wide:``},null,8,[`modelValue`]),B(mz,{modelValue:j(a),"onUpdate:modelValue":y[1]||=e=>k(a)?a.value=e:null,label:`Max retries`,min:0,hint:`Attempts before the server is left crashed.`},null,8,[`modelValue`]),B(mz,{modelValue:j(o),"onUpdate:modelValue":y[2]||=e=>k(o)?o.value=e:null,label:`Base delay (ms)`,min:0},null,8,[`modelValue`]),B(mz,{modelValue:j(s),"onUpdate:modelValue":y[3]||=e=>k(s)?s.value=e:null,label:`Backoff factor`,min:1,step:.1},null,8,[`modelValue`]),B(mz,{modelValue:j(c),"onUpdate:modelValue":y[4]||=e=>k(c)?c.value=e:null,label:`Max delay (ms)`,min:0},null,8,[`modelValue`]),B(mz,{modelValue:j(l),"onUpdate:modelValue":y[5]||=e=>k(l)?l.value=e:null,label:`Reset after (ms)`,min:0,hint:`A run this long clears the retry counter.`},null,8,[`modelValue`])]),_:1}),B(cz,{title:`Health check`,description:`How readiness is probed once the process is up.`,columns:3},{default:M(()=>[B(Sz,{modelValue:n.value.enabled,"onUpdate:modelValue":y[6]||=e=>n.value.enabled=e,label:`Probe this server`,wide:``},null,8,[`modelValue`]),B(_L,{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`]),B(mz,{modelValue:j(u),"onUpdate:modelValue":y[8]||=e=>k(u)?u.value=e:null,label:`Interval (ms)`,min:500,step:100},null,8,[`modelValue`]),B(mz,{modelValue:j(d),"onUpdate:modelValue":y[9]||=e=>k(d)?d.value=e:null,label:`Timeout (ms)`,min:100,step:100},null,8,[`modelValue`]),B(mz,{modelValue:j(f),"onUpdate:modelValue":y[10]||=e=>k(f)?f.value=e:null,label:`Unhealthy after`,min:1,hint:`Consecutive failed probes.`},null,8,[`modelValue`]),B(mz,{modelValue:j(p),"onUpdate:modelValue":y[11]||=e=>k(p)?p.value=e:null,label:`Force restart after (ms)`,min:0,hint:`0 disables it.`},null,8,[`modelValue`]),B(mz,{modelValue:j(m),"onUpdate:modelValue":y[12]||=e=>k(m)?m.value=e:null,label:`Start timeout (ms)`,min:0},null,8,[`modelValue`]),e.showHttp&&n.value.mode===`http`?(I(),L(F,{key:0},[B(yz,{modelValue:n.value.http.path,"onUpdate:modelValue":y[13]||=e=>n.value.http.path=e,label:`HTTP path`,placeholder:`/healthz`},null,8,[`modelValue`]),B(_L,{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`]),B(mz,{modelValue:h.value,"onUpdate:modelValue":y[15]||=e=>h.value=e,label:`Expect status`,nullable:``,hint:`Blank accepts anything below.`},null,8,[`modelValue`]),B(mz,{modelValue:j(g),"onUpdate:modelValue":y[16]||=e=>k(g)?g.value=e:null,label:`Healthy below status`,min:100},null,8,[`modelValue`]),B(yz,{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)):H(``,!0)]),_:1}),B(cz,{title:`Stop behaviour`,description:`How the process tree is asked to go away.`,columns:3},{default:M(()=>[B(_L,{modelValue:r.value.signal,"onUpdate:modelValue":y[18]||=e=>r.value.signal=e,label:`Signal`,options:v},null,8,[`modelValue`]),B(mz,{modelValue:j(_),"onUpdate:modelValue":y[19]||=e=>k(_)?_.value=e:null,label:`Grace period (ms)`,min:0},null,8,[`modelValue`]),B(Sz,{modelValue:r.value.killGroup,"onUpdate:modelValue":y[20]||=e=>r.value.killGroup=e,label:`Kill the whole process group`},null,8,[`modelValue`]),B(Sz,{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))}}),wz=[`open`],Tz={class:`flex cursor-pointer list-none select-none items-center gap-1.5 px-3 py-2 text-xs font-semibold text-ink [&::-webkit-details-marker]:hidden`},Ez={key:0,class:`ml-1 truncate text-2xs font-normal text-faint`},Dz={class:`grid gap-3 border-t border-line-soft px-3 py-3`},Oz=N({__name:`Disclosure`,props:{title:{},hint:{default:void 0},open:{type:Boolean,default:!1}},setup(e){let t=e;return(e,n)=>(I(),L(`details`,{class:`group rounded-panel border border-line bg-panel-2/40`,open:t.open},[z(`summary`,Tz,[B(j(Rv),{class:`size-3.5 shrink-0 text-muted transition-transform duration-150 group-open:rotate-90`,"aria-hidden":`true`}),V(` `+O(t.title)+` `,1),t.hint?(I(),L(`span`,Ez,O(t.hint),1)):H(``,!0)]),z(`div`,Dz,[P(e.$slots,`default`)])],8,wz))}}),kz=[`for`],Az=[`id`,`rows`,`placeholder`],jz={key:1,class:`text-2xs text-danger`},Mz=N({inheritAttrs:!1,__name:`TextAreaField`,props:Ba({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=co(e,`modelValue`),r=ui();return(e,i)=>(I(),L(`div`,{class:D(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(I(),L(`label`,{key:0,for:j(r),class:D(j(bF))},O(t.label),11,kz)):H(``,!0),xr(z(`textarea`,Ns({id:j(r),"onUpdate:modelValue":i[0]||=e=>n.value=e,rows:t.rows,placeholder:t.placeholder,spellcheck:`false`,class:j(Q)(t.mono?j(CF):`font-sans`,`resize-y leading-relaxed`,t.error&&`border-danger`)},e.$attrs),null,16,Az),[[Yl,n.value]]),t.error?(I(),L(`p`,jz,O(t.error),1)):t.hint?(I(),L(`p`,{key:2,class:D(j(xF))},O(t.hint),3)):H(``,!0)],2))}}),Nz={class:`rounded-panel border border-line-soft bg-panel-2/40 p-3`},Pz={class:`mt-1.5 flex flex-wrap gap-1`},Fz={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`},Iz=N({__name:`AddServerDialog`,props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:Ba([`created`],[`update:open`]),setup(e,{emit:t}){let n=t,r=co(e,`open`),i=jM(),a=A(!1),o=A(null),s=[`{port}`,`{host}`,`{home}`,`{projectDir}`,`{dataRoot}`,`{id}`,`{label}`,`{cwd}`,`{bind}`,`{lanIp}`],c=U(()=>i.defaults.value??void 0),l=tn(ZR(c.value)),u=U(()=>ez(l.port));function d(){Object.assign(l,ZR(c.value)),o.value=null}jr(r,e=>{e&&d()});async function f(){o.value=null;let e=nz(l);if(e!==null){o.value=e;return}let t=SA(tz(l,c.value));if(t instanceof Y.errors){o.value=t.summary;return}a.value=!0;try{if(await i.create(t),i.lastError.value!==null){o.value=i.lastError.value;return}n(`created`),r.value=!1,d()}finally{a.value=!1}}return(e,t)=>(I(),R(dL,{open:r.value,"onUpdate:open":t[29]||=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:M(()=>[B($,{variant:`ghost`,onClick:t[28]||=e=>r.value=!1},{default:M(()=>[...t[32]||=[V(` Cancel `,-1)]]),_:1}),B($,{type:`submit`,form:`add-server-form`,variant:`primary`,loading:a.value},{default:M(()=>[...t[33]||=[V(` Add to servers.config.json `,-1)]]),_:1},8,[`loading`])]),default:M(()=>[z(`form`,{id:`add-server-form`,class:`flex flex-col gap-3`,onSubmit:uu(f,[`prevent`])},[B(cz,{title:`Identity`,columns:2,dense:``},{default:M(()=>[B(yz,{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`]),B(yz,{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}),B(cz,{title:`Process`,columns:2,dense:``},{default:M(()=>[B(yz,{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`]),B(yz,{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}),B(Mz,{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
42
+ {port}`},null,8,[`modelValue`]),B(cz,{title:`Port & lifecycle`,columns:2,dense:``},{default:M(()=>[B(mz,{modelValue:l.port,"onUpdate:modelValue":t[5]||=e=>l.port=e,label:`Port`,nullable:``,min:1,max:65535,error:u.value,hint:`Blank means the server has no port to probe or preflight.`},null,8,[`modelValue`,`error`]),B(_L,{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`]),B(Sz,{modelValue:l.autostart,"onUpdate:modelValue":t[7]||=e=>l.autostart=e,label:`Autostart with up`,hint:`Start it whenever the control plane comes up.`,wide:``},null,8,[`modelValue`]),B(Sz,{modelValue:l.persistent,"onUpdate:modelValue":t[8]||=e=>l.persistent=e,label:`Persistent`,hint:"Keeps running when the panel stops; `down` reports it instead of stopping it.",wide:``},null,8,[`modelValue`])]),_:1}),B(Oz,{title:`Advanced settings`,hint:`environment, backups, policy, lifecycle, bootstrap`},{default:M(()=>[B(cz,{title:`Environment`,columns:2,dense:``},{default:M(()=>[B(Mz,{modelValue:l.env,"onUpdate:modelValue":t[9]||=e=>l.env=e,label:`Environment`,rows:3,hint:`KEY=value per line, exported to the process.`,placeholder:`NODE_ENV=production`},null,8,[`modelValue`]),B(Mz,{modelValue:l.dataEnvs,"onUpdate:modelValue":t[10]||=e=>l.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`]),B(yz,{modelValue:l.envFile,"onUpdate:modelValue":t[11]||=e=>l.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`]),B(yz,{modelValue:l.dependsOn,"onUpdate:modelValue":t[12]||=e=>l.dependsOn=e,label:`Depends on`,placeholder:`postgres, redis`,hint:`Comma separated; started first, stopped last.`,class:`font-mono text-xs`},null,8,[`modelValue`])]),_:1}),B(cz,{title:`Backups`,columns:2,dense:``},{default:M(()=>[B(Mz,{modelValue:l.backupPaths,"onUpdate:modelValue":t[13]||=e=>l.backupPaths=e,label:`Extra backup paths`,rows:2,hint:`One per line, placeholders allowed; data envs are captured already.`,placeholder:`{home}/.app/uploads`},null,8,[`modelValue`]),B(Sz,{modelValue:l.backupIgnoreGenerated,"onUpdate:modelValue":t[14]||=e=>l.backupIgnoreGenerated=e,label:`Ignore known generated files`,hint:`Skips node_modules, dist, .next and the other caches nothing restores from.`,wide:``},null,8,[`modelValue`])]),_:1}),B(Cz,{restart:l.restart,"onUpdate:restart":t[15]||=e=>l.restart=e,health:l.health,"onUpdate:health":t[16]||=e=>l.health=e,stop:l.stop,"onUpdate:stop":t[17]||=e=>l.stop=e},null,8,[`restart`,`health`,`stop`]),B(cz,{title:`Bootstrap`,description:`A one-off command run before the first start.`,columns:2,dense:``},{default:M(()=>[B(Sz,{modelValue:l.bootstrapEnabled,"onUpdate:modelValue":t[18]||=e=>l.bootstrapEnabled=e,label:`Run a bootstrap`,hint:`Installs, migrations, downloads — before the first start, not on every one.`,wide:``},null,8,[`modelValue`]),l.bootstrapEnabled?(I(),L(F,{key:0},[B(yz,{modelValue:l.bootstrapCommand,"onUpdate:modelValue":t[19]||=e=>l.bootstrapCommand=e,label:`Command`,placeholder:`./scripts/install.sh`,class:`font-mono text-xs`},null,8,[`modelValue`]),B(mz,{modelValue:l.bootstrapTimeoutMs,"onUpdate:modelValue":t[20]||=e=>l.bootstrapTimeoutMs=e,label:`Timeout (ms)`,min:1e3,step:1e3},null,8,[`modelValue`]),B(Sz,{modelValue:l.bootstrapRunOnce,"onUpdate:modelValue":t[21]||=e=>l.bootstrapRunOnce=e,label:`Only once per session`,hint:`Off means every start re-runs it.`},null,8,[`modelValue`]),B(Mz,{modelValue:l.bootstrapArgs,"onUpdate:modelValue":t[22]||=e=>l.bootstrapArgs=e,label:`Bootstrap arguments`,rows:2,hint:`One per line; same placeholders as the main arguments.`},null,8,[`modelValue`]),B(Mz,{modelValue:l.bootstrapEnv,"onUpdate:modelValue":t[23]||=e=>l.bootstrapEnv=e,label:`Bootstrap environment`,rows:2,hint:`KEY=value per line, exported to the bootstrap process only.`},null,8,[`modelValue`])],64)):H(``,!0)]),_:1}),B(cz,{title:`Policy & resources`,columns:2,dense:``},{default:M(()=>[B(_L,{modelValue:l.onPortConflict,"onUpdate:modelValue":t[24]||=e=>l.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`},{value:`kill`,label:`kill — stop whatever holds the port`}]},null,8,[`modelValue`]),B(mz,{modelValue:l.logBufferLines,"onUpdate:modelValue":t[25]||=e=>l.logBufferLines=e,label:`Log buffer lines`,min:50,max:1e5,step:50,hint:`Blank keeps the default.`},null,8,[`modelValue`]),B(mz,{modelValue:l.maxRssMb,"onUpdate:modelValue":t[26]||=e=>l.maxRssMb=e,label:`Max RSS (MB)`,min:0,hint:`Restart above this; blank or 0 disables it.`},null,8,[`modelValue`]),B(Sz,{modelValue:l.enabled,"onUpdate:modelValue":t[27]||=e=>l.enabled=e,label:`Enabled`,hint:`Off keeps the entry in the config but refuses to start it.`,wide:``},null,8,[`modelValue`])]),_:1}),t[30]||=z(`p`,{class:`text-2xs leading-4 text-faint`},[V(` Restart, health and stop start out matching `),z(`span`,{class:`font-mono`},`Settings → Server defaults`),V(`; change one here and it is written into this entry instead of staying inherited. `)],-1)]),_:1}),z(`div`,Nz,[t[31]||=z(`p`,{class:`text-2xs font-medium text-muted`},` Available argument placeholders `,-1),z(`div`,Pz,[(I(),L(F,null,ya(s,e=>z(`code`,{key:e,class:`rounded-control border border-line bg-raise px-1.5 py-0.5 font-mono text-2xs text-ink`},O(e),1)),64))])]),o.value?(I(),L(`p`,Fz,O(o.value),1)):H(``,!0)],32)]),_:1},8,[`open`]))}}),Lz={class:`text-xs font-semibold text-ink`},Rz={class:`mt-2.5 flex justify-end gap-1.5`},zz=N({__name:`KillPortButton`,props:{port:{},busy:{type:Boolean,default:!1}},emits:[`confirm`],setup(e,{emit:t}){let n=e,r=t,i=A(!1);function a(){i.value=!1,r(`confirm`)}return(e,t)=>(I(),R(j(Gh),{open:i.value,"onUpdate:open":t[0]||=e=>i.value=e},{default:M(()=>[B(j(Qh),{"as-child":``},{default:M(()=>[B($,{variant:`danger-ghost`,size:`xs`,loading:n.busy},{default:M(()=>[V(` Kill what holds port `+O(n.port),1)]),_:1},8,[`loading`])]),_:1}),B(j(Zh),null,{default:M(()=>[B(j(Xh),{"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:M(()=>[z(`p`,Lz,` Kill the process on port `+O(n.port)+`? `,1),t[3]||=z(`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),z(`div`,Rz,[B(j(Kh),{"as-child":``},{default:M(()=>[B($,{size:`xs`,variant:`ghost`},{default:M(()=>[...t[1]||=[V(` Keep it `,-1)]]),_:1})]),_:1}),B($,{size:`xs`,variant:`danger`,loading:n.busy,onClick:a},{default:M(()=>[...t[2]||=[V(` Kill it `,-1)]]),_:1},8,[`loading`])])]),_:1})]),_:1})]),_:1},8,[`open`]))}}),Bz=[`viewBox`],Vz=[`id`],Hz=[`stop-color`],Uz=[`stop-color`],Wz=[`d`,`fill`],Gz=[`d`,`stroke`,`stroke-width`],Kz=[`x1`,`x2`,`y2`,`stroke`],qz=[`cx`,`cy`,`fill`],Jz={key:0,class:`absolute inset-x-0 top-1/2 border-t border-dashed border-line`},Yz=100,Xz=N({__name:`Sparkline`,props:Ba({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=co(e,`hoverIndex`),r=ui(),i=A(null),a=U(()=>{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=U(()=>{let e=t.values,{bottom:n,ceiling:r}=a.value,i=r-n,o=e.length>1?Yz/(e.length-1):Yz,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=U(()=>n.value===null||t.values.length<2?null:n.value/(t.values.length-1)*Yz),c=U(()=>{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)=>(I(),L(`div`,{ref_key:`track`,ref:i,class:D(j(Q)(`relative w-full`,t.class)),style:_e({height:`${t.height}px`}),onMousemove:l,onMouseleave:u},[(I(),L(`svg`,{viewBox:`0 0 ${Yz} ${t.height}`,preserveAspectRatio:`none`,class:`block size-full overflow-visible`,role:`img`,"aria-hidden":`true`},[z(`defs`,null,[z(`linearGradient`,{id:j(r),x1:`0`,y1:`0`,x2:`0`,y2:`1`},[z(`stop`,{offset:`0%`,"stop-color":t.color??`currentColor`,"stop-opacity":`0.26`},null,8,Hz),z(`stop`,{offset:`100%`,"stop-color":t.color??`currentColor`,"stop-opacity":`0`},null,8,Uz)],8,Vz)]),(I(!0),L(F,null,ya(o.value,(e,n)=>(I(),L(F,{key:n},[t.fill?(I(),L(`path`,{key:0,d:e.area,fill:`url(#${j(r)})`,stroke:`none`},null,8,Wz)):H(``,!0),z(`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,Gz)],64))),128)),s.value===null?H(``,!0):(I(),L(`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,Kz)),s.value!==null&&c.value!==null?(I(),L(`circle`,{key:1,cx:s.value,cy:c.value,r:`2`,fill:t.color??`currentColor`,"vector-effect":`non-scaling-stroke`},null,8,qz)):H(``,!0)],8,Bz)),o.value.length===0?(I(),L(`div`,Jz)):H(``,!0)],38))}}),Zz={class:`min-w-0`},Qz={class:`flex items-baseline justify-between gap-2`},$z={class:`truncate text-2xs font-medium text-faint`},eB={class:`flex shrink-0 items-baseline gap-1.5`},tB={key:0,class:`font-mono text-2xs text-faint`},nB=N({__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=A(null),r=U(()=>aM(t.values)),i=U(()=>t.values.some(e=>e!==null)),a=U(()=>{let e=n.value;return e!==null&&t.values[e]!==void 0?t.values[e]??null:r.value}),o=U(()=>{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)=>(I(),L(`div`,Zz,[z(`div`,Qz,[z(`span`,$z,O(t.label),1),z(`span`,eB,[o.value?(I(),L(`span`,tB,O(o.value),1)):H(``,!0),z(`span`,{class:D(j(Q)(`font-mono text-xs font-medium tabular-nums`,i.value?`text-ink`:`text-faint`))},O(i.value?t.format(a.value):t.emptyHint),3)])]),B(Xz,{"hover-index":n.value,"onUpdate:hoverIndex":r[0]||=e=>n.value=e,values:t.values,height:t.height,max:t.max,interactive:``,class:D(j(Q)(`mt-1`,t.colorClass))},null,8,[`hover-index`,`values`,`height`,`max`,`class`])]))}}),rB={class:`inline-flex flex-wrap items-center gap-1.5`},iB={class:`relative flex size-1.5`},aB={key:0,class:`absolute inset-0 rounded-full bg-current opacity-60`,style:{animation:`hh-pulse-ring 1.6s ease-out infinite`}},oB=N({__name:`StatusPill`,props:{status:{},health:{default:null},showHealth:{type:Boolean,default:!0}},setup(e){let t=e,n=U(()=>hP[t.status]),r=U(()=>t.health?gP[t.health]:null),i=U(()=>t.showHealth&&r.value!==null&&t.health!==`disabled`&&t.health!==`unknown`&&(r.value.tone===`danger`||r.value.tone===`warn`)),a=U(()=>n.value.transitional);return(e,t)=>(I(),L(`span`,rB,[z(`span`,{class:D(j(Q)(`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-2xs font-medium`,j(vP)[n.value.tone]))},[z(`span`,iB,[a.value?(I(),L(`span`,aB)):H(``,!0),z(`span`,{class:D(j(Q)(`relative size-1.5 rounded-full`,j(yP)[n.value.tone]))},null,2)]),V(` `+O(n.value.label),1)],2),i.value&&r.value?(I(),L(`span`,{key:0,class:D(j(Q)(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-2xs font-medium`,j(vP)[r.value.tone]))},O(r.value.label),3)):H(``,!0)]))}}),sB={class:`flex items-start justify-between gap-3 px-4 pb-2.5 pt-3.5`},cB={class:`min-w-0`},lB={class:`flex items-center gap-2`},uB=[`href`,`title`,`aria-label`],dB={class:`mt-0.5 flex items-center gap-1.5 truncate font-mono text-2xs text-faint`},fB={class:`text-muted`},pB={key:1,class:`rounded bg-hover px-1 py-px text-muted`},mB={key:2,class:`rounded bg-accent-soft px-1 py-px text-accent`},hB=[`title`],gB={key:0,class:`space-y-2.5 border-y border-line-soft px-4 py-3`},_B={class:`grid grid-cols-2 gap-x-4 gap-y-2`},vB={key:1,class:`flex flex-wrap items-center gap-x-3 gap-y-1 px-4 pt-2.5`},yB={class:`text-muted`},bB={class:`text-faint`},xB={key:2,class:`flex flex-col gap-1 px-4 pt-2.5`},SB={key:0,class:`flex items-start gap-1.5 text-2xs leading-4 text-danger`},CB={class:`min-w-0 break-words`},wB={key:2,class:`text-2xs leading-4 text-warn`},TB={key:3,class:`text-2xs leading-4 text-warn`},EB={class:`grid grid-cols-2 gap-x-4 gap-y-1 px-4 py-3 sm:grid-cols-4`},DB={class:`truncate text-2xs text-faint`},OB={class:`truncate font-mono text-xs tabular-nums text-ink capitalize`},kB={class:`mt-auto flex items-center gap-1.5 border-t border-line-soft px-4 py-2.5`},AB={class:`grid grid-cols-2 gap-2 text-xs`},jB={class:`font-mono text-ink`},MB={class:`text-ink capitalize`},NB=N({__name:`ServerCard`,props:{server:{},series:{},now:{},variant:{default:`default`}},setup(e){let t=e,n={start:py,exit:Ey,crash:Bv,"forced-restart":vy,unhealthy:My,recovered:Vv},r=jM(),i=A(!1),a=A(!1),o=U(()=>t.server.config),s=U(()=>o.value.label&&o.value.label.length>0?o.value.label:t.server.id),c=U(()=>`${o.value.command} ${o.value.args.join(` `)}`.trim()),l=U(()=>bP(t.server.status,t.server.health)),u=U(()=>t.server.status===`running`),d=U(()=>o.value.enabled&&[`stopped`,`crashed`,`conflict`].includes(t.server.status)),f=U(()=>[`running`,`starting`,`backoff`].includes(t.server.status)),p=U(()=>t.server.startedAt===null||!u.value?`—`:wI(t.now-t.server.startedAt)),m=U(()=>t.server.nextRetryAt===null?null:TI(t.server.nextRetryAt,t.now)),h=U(()=>t.server.unhealthySince===null?null:wI(t.now-t.server.unhealthySince)),g=U(()=>t.series?.cpu??[]),_=U(()=>t.series?.rss??[]),v=U(()=>t.series?.probe??[]),y=U(()=>[...t.server.history.events].slice(-3).reverse()),b=U(()=>{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:EI(e.history.uptimeRatio)},{key:`probe`,label:`Probe`,value:e.responseMs===null?`—`:`${e.responseMs} ms`},{key:`rss`,label:`RSS`,value:kI(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:DI(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=pa(`RouterLink`);return I(),L(`article`,{class:D(j(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`))},[z(`span`,{class:D(j(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),z(`header`,sB,[z(`div`,cB,[z(`div`,lB,[B(T,{to:`/servers/${e.server.id}`,class:`truncate text-sm font-semibold tracking-tight text-ink hover:text-accent`},{default:M(()=>[V(O(s.value),1)]),_:1},8,[`to`]),e.server.url?(I(),L(`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}`},[B(j(Xv),{class:`size-3.5`})],8,uB)):H(``,!0)]),z(`p`,dB,[z(`span`,null,O(e.server.id),1),o.value.port===null?H(``,!0):(I(),L(F,{key:0},[p[9]||=z(`span`,{"aria-hidden":`true`},`·`,-1),z(`span`,fB,`:`+O(o.value.port),1)],64)),p[10]||=z(`span`,{"aria-hidden":`true`},`·`,-1),z(`span`,null,O(e.server.bindHost),1),o.value.enabled?H(``,!0):(I(),L(`span`,pB,`disabled`)),o.value.autostart?(I(),L(`span`,mB,`autostart`)):H(``,!0)])]),B(oB,{status:e.server.status,health:e.server.health},null,8,[`status`,`health`]),e.server.adopted?(I(),R(TF,{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:M(()=>[...p[11]||=[z(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`detached`,-1)]]),_:1})):H(``,!0),o.value.persistent?(I(),R(TF,{key:1,label:"This entry runs under its own nanny, so it keeps running when the panel stops, restarts or is killed. `home-hosted down` reports it instead of stopping it; only an explicit stop does."},{default:M(()=>[...p[12]||=[z(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`persistent`,-1)]]),_:1})):H(``,!0)]),z(`p`,{class:`truncate px-4 pb-3 font-mono text-2xs text-muted`,title:c.value},O(c.value),9,hB),t.variant===`compact`?H(``,!0):(I(),L(`div`,gB,[z(`div`,_B,[B(nB,{label:`CPU`,values:g.value,format:j(AI),max:100,"color-class":`text-cpu`},null,8,[`values`,`format`]),B(nB,{label:`Memory`,values:_.value,format:j(kI),"color-class":`text-mem`},null,8,[`values`,`format`])]),B(nB,{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?(I(),L(`div`,vB,[(I(!0),L(F,null,ya(y.value,e=>(I(),L(`span`,{key:`${e.ts}`,class:`inline-flex items-center gap-1 text-2xs`},[(I(),R(ha(n[e.type]),{class:D(j(Q)(`size-3`,j(_P)[j(SP)[e.type]]))},null,8,[`class`])),z(`span`,yB,O(j(xP)[e.type]),1),z(`span`,bB,O(j(DI)(e.ts,t.now)),1)]))),128))])):H(``,!0),e.server.lastError||h.value||m.value?(I(),L(`div`,xB,[e.server.lastError?(I(),L(`p`,SB,[B(j(Bv),{class:`mt-0.5 size-3 shrink-0`}),z(`span`,CB,O(e.server.lastError),1)])):H(``,!0),e.server.status===`conflict`&&o.value.port!==null?(I(),R(zz,{key:1,port:o.value.port,busy:i.value,class:`self-start`,onConfirm:S},null,8,[`port`,`busy`])):H(``,!0),h.value?(I(),L(`p`,wB,` Unhealthy for `+O(h.value),1)):H(``,!0),m.value?(I(),L(`p`,TB,` Next attempt `+O(m.value),1)):H(``,!0)])):H(``,!0),z(`dl`,EB,[(I(!0),L(F,null,ya(b.value,e=>(I(),L(`div`,{key:e.key,class:`min-w-0`},[z(`dt`,DB,O(e.label),1),z(`dd`,OB,O(e.value),1)]))),128))]),z(`div`,kB,[B($,{variant:`primary`,size:`xs`,disabled:i.value||!d.value,onClick:p[0]||=e=>x(`start`)},{default:M(()=>[B(j(py),{class:`size-3`}),p[13]||=V(`Start `,-1)]),_:1},8,[`disabled`]),B($,{size:`xs`,disabled:i.value||!f.value,onClick:p[1]||=e=>x(`stop`)},{default:M(()=>[B(j(Ey),{class:`size-3`}),p[14]||=V(`Stop `,-1)]),_:1},8,[`disabled`]),B($,{size:`xs`,disabled:i.value||!o.value.enabled,onClick:p[2]||=e=>x(`restart`)},{default:M(()=>[B(j(vy),{class:`size-3`}),p[15]||=V(`Restart `,-1)]),_:1},8,[`disabled`]),B(TF,{label:`Live logs and full telemetry`},{default:M(()=>[B(T,{to:`/servers/${e.server.id}`},{default:M(()=>[B($,{size:`xs`,variant:`ghost`},{default:M(()=>[B(j(yy),{class:`size-3`}),p[16]||=V(`Details `,-1)]),_:1})]),_:1},8,[`to`])]),_:1}),B(j(tg),null,{default:M(()=>[B(j(og),{"as-child":``},{default:M(()=>[B($,{size:`icon-sm`,variant:`ghost`,class:`ml-auto`,"aria-label":`More actions for ${s.value}`},{default:M(()=>[B(j(Yv),{class:`size-4`})]),_:1},8,[`aria-label`])]),_:1}),B(j(ig),null,{default:M(()=>[B(j(ng),{"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:M(()=>[B(j(rg),{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:M(()=>[B(j(hy),{class:`size-3.5`}),V(` `+O(o.value.enabled?`Disable server`:`Enable server`),1)]),_:1}),B(j(rg),{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:M(()=>[B(j(py),{class:`size-3.5`}),V(` `+O(o.value.autostart?`Remove from autostart`:`Autostart with the panel`),1)]),_:1}),B(j(rg),{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=>j(r).clearLogs(e.server.id)},{default:M(()=>[B(j(yy),{class:`size-3.5`}),p[17]||=V(` Clear log buffer `,-1)]),_:1}),B(j(ag),{class:`my-1 h-px bg-line`}),B(j(rg),{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:M(()=>[B(j(jy),{class:`size-3.5`}),p[18]||=V(` Remove server `,-1)]),_:1})]),_:1})]),_:1})]),_:1})]),B(dL,{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:M(()=>[B($,{variant:`ghost`,onClick:p[7]||=e=>a.value=!1},{default:M(()=>[...p[21]||=[V(` Keep it `,-1)]]),_:1}),B($,{variant:`danger`,onClick:w},{default:M(()=>[B(j(jy),{class:`size-3.5`}),p[22]||=V(`Remove `,-1)]),_:1})]),default:M(()=>[z(`dl`,AB,[z(`div`,null,[p[19]||=z(`dt`,{class:`text-faint`},` id `,-1),z(`dd`,jB,O(e.server.id),1)]),z(`div`,null,[p[20]||=z(`dt`,{class:`text-faint`},` status `,-1),z(`dd`,MB,O(e.server.status),1)])])]),_:1},8,[`open`,`description`])],2)}}}),PB={class:`flex flex-wrap items-start justify-between gap-3`},FB={class:`min-w-0`},IB={class:`flex flex-wrap items-center gap-x-3 gap-y-1.5`},LB={class:`text-2xl font-semibold tracking-tight text-ink`},RB={key:1,class:`mt-1 max-w-2xl text-xs leading-relaxed text-muted`},zB={class:`flex shrink-0 flex-wrap items-center gap-2`},BB=N({__name:`PageHeader`,props:{title:{},description:{default:void 0},backTo:{default:void 0},backLabel:{default:`Back`}},setup(e){return(e,t)=>{let n=pa(`RouterLink`);return I(),L(`header`,PB,[z(`div`,FB,[e.$props.backTo?(I(),R(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:M(()=>[B(j(Lv),{class:`size-3`}),V(` `+O(e.$props.backLabel),1)]),_:1},8,[`to`])):H(``,!0),z(`div`,IB,[z(`h1`,LB,O(e.$props.title),1),P(e.$slots,`badges`)]),e.$props.description?(I(),L(`p`,RB,O(e.$props.description),1)):H(``,!0)]),z(`div`,zB,[P(e.$slots,`actions`)])])}}}),VB={key:0,class:`mb-3 flex items-start justify-between gap-3`},HB={class:`min-w-0`},UB={class:`flex shrink-0 items-center gap-1.5`},WB=N({__name:`Panel`,props:{padded:{type:Boolean,default:!0},class:{}},setup(e){return(e,t)=>(I(),L(`section`,{class:D(j(mP)(`rounded-panel border border-line bg-panel shadow-card`,e.$props.padded&&`p-4`,e.$props.class))},[e.$slots.header||e.$slots.actions?(I(),L(`header`,VB,[z(`div`,HB,[P(e.$slots,`header`)]),z(`div`,UB,[P(e.$slots,`actions`)])])):H(``,!0),P(e.$slots,`default`)],2))}}),GB={class:`min-w-0`},KB={class:`truncate text-2xs font-medium text-faint`},qB={key:0,class:`mt-0.5 truncate text-2xs text-muted`},JB=N({__name:`StatTile`,props:{label:{},value:{},hint:{default:void 0},tone:{default:`neutral`},mono:{type:Boolean,default:!0}},setup(e){return(e,t)=>(I(),L(`div`,GB,[z(`p`,KB,O(e.$props.label),1),z(`p`,{class:D(j(Q)(`mt-0.5 truncate text-xl font-semibold tracking-tight`,e.$props.mono&&`font-mono tabular-nums`,e.$props.tone===`neutral`?`text-ink`:j(_P)[e.$props.tone]))},O(e.$props.value),3),e.$props.hint?(I(),L(`p`,qB,O(e.$props.hint),1)):H(``,!0)]))}}),YB=A(null),XB=A(`unknown`),ZB=null;async function QB(){try{let e=await(await fetch(`/healthz`,{cache:`no-store`})).json();typeof e.uptimeMs==`number`&&(YB.value=Date.now()-e.uptimeMs),XB.value=e.status===`degraded`?`degraded`:`ok`}catch{XB.value=`unknown`}}function $B(){return ZB??=QB().finally(()=>{ZB=null}),{startedAt:YB,status:XB,refresh:QB}}var eV={class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},tV={key:0,class:`grid grid-cols-2 gap-4 p-4 sm:grid-cols-3 lg:grid-cols-6`},nV={key:1,class:`grid grid-cols-2 divide-line-soft sm:grid-cols-3 sm:divide-x lg:grid-cols-6`},rV={class:`p-4`},iV={class:`p-4`},aV={class:`p-4`},oV={class:`p-4`},sV={class:`p-4`},cV={class:`p-4`},lV={key:0,class:`flex items-start gap-2.5 rounded-panel border border-danger/25 bg-danger-soft px-3.5 py-3`},uV={class:`min-w-0`},dV={class:`text-xs font-medium text-danger`},fV={class:`mt-0.5 flex flex-wrap gap-x-2 text-2xs text-danger`},pV={class:`space-y-3`},mV={class:`flex items-center justify-between`},hV={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},gV={key:0,class:`grid gap-4 lg:grid-cols-2`},_V={key:2,class:`grid gap-4 lg:grid-cols-2`},vV={class:`grid gap-4 lg:grid-cols-3`},yV={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},bV={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},xV={class:`flex flex-wrap items-center gap-x-3 gap-y-1 text-2xs text-faint`},SV={class:`flex items-center gap-1`},CV={class:`font-mono`},wV=N({__name:`OverviewView`,setup(e){let{servers:t,host:n,now:r,appState:i,seriesOf:a,startAll:o,stopAll:s}=jM(),c=$B(),l=A(!1),u=U(()=>i.value===null),d=U(()=>t.value.filter(e=>e.status===`running`)),f=U(()=>t.value.filter(e=>[`stopped`,`stopping`].includes(e.status))),p=U(()=>t.value.filter(e=>e.status===`crashed`||e.status===`conflict`||e.health===`unhealthy`)),m=U(()=>{let e=0;for(let t of d.value){let n=t.resources?.rssBytes;typeof n==`number`&&(e+=n)}return e}),h=U(()=>{let e=0;for(let n of t.value){let t=iM(a(n.id).rss);t>e&&(e=t)}return e}),g=U(()=>c.startedAt.value===null?`—`:wI(r.value-c.startedAt.value)),_=U(()=>n.value?.enabled?wI(n.value.uptimeMs):`—`),v=U(()=>{let e=0;for(let t of d.value)e+=t.resources?.cpuPercent??0;return e});return na(async()=>{await c.refresh()}),(e,y)=>{let b=pa(`RouterLink`);return I(),L(`div`,eV,[B(BB,{title:`Overview`,description:`Live state of everything this panel supervises, refreshed over a single event stream.`},{actions:M(()=>[B($,{variant:`ghost`,onClick:y[0]||=e=>j(o)()},{default:M(()=>[B(j(py),{class:`size-3.5`}),y[5]||=V(`Start all `,-1)]),_:1}),B($,{variant:`ghost`,onClick:y[1]||=e=>j(s)()},{default:M(()=>[B(j(Ey),{class:`size-3.5`}),y[6]||=V(`Stop all `,-1)]),_:1}),B($,{variant:`primary`,onClick:y[2]||=e=>l.value=!0},{default:M(()=>[B(j(my),{class:`size-3.5`}),y[7]||=V(`Add server `,-1)]),_:1})]),_:1}),B(WB,{class:`p-0`},{default:M(()=>[u.value?(I(),L(`div`,tV,[(I(),L(F,null,ya(6,e=>z(`div`,{key:e,class:`space-y-2`},[B(vL,{class:`h-2.5 w-16`}),B(vL,{class:`h-6 w-20`})])),64))])):(I(),L(`div`,nV,[z(`div`,rV,[B(JB,{label:`Running`,value:`${d.value.length}/${j(t).length}`,tone:`ok`,hint:`${j(t).length-d.value.length} not up`},null,8,[`value`,`hint`])]),z(`div`,iV,[B(JB,{label:`Stopped`,value:String(f.value.length),hint:`${j(t).filter(e=>e.config.enabled).length} enabled`},null,8,[`value`,`hint`])]),z(`div`,aV,[B(JB,{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`])]),z(`div`,oV,[B(JB,{label:`Process memory`,value:j(kI)(m.value),hint:h.value>0?`peak ${j(kI)(h.value)}`:`across the tree`},null,8,[`value`,`hint`])]),z(`div`,sV,[B(JB,{label:`Panel uptime`,value:g.value,hint:j(c).status.value===`degraded`?`degraded`:`serving`},null,8,[`value`,`hint`])]),z(`div`,cV,[B(JB,{label:`Host uptime`,value:_.value,hint:j(n)?.enabled?`${v.value.toFixed(1)}% cpu now`:`sampling off`},null,8,[`value`,`hint`])])]))]),_:1}),p.value.length>0?(I(),L(`div`,lV,[B(j(Bv),{class:`mt-0.5 size-4 shrink-0 text-danger`}),z(`div`,uV,[z(`p`,dV,O(p.value.length)+` server`+O(p.value.length===1?``:`s`)+` need a look `,1),z(`p`,fV,[(I(!0),L(F,null,ya(p.value,e=>(I(),R(b,{key:e.id,to:`/servers/${e.id}`,class:`font-mono underline-offset-2 hover:underline`},{default:M(()=>[V(O(e.id),1)]),_:2},1032,[`to`]))),128))])])])):H(``,!0),z(`section`,pV,[z(`div`,mV,[z(`h2`,hV,[B(j(xy),{class:`size-3.5 text-faint`}),y[8]||=V(` Servers `,-1)]),B(b,{to:`/servers`,class:`text-2xs text-muted transition-colors duration-150 hover:text-accent`},{default:M(()=>[...y[9]||=[V(` Open the full list `,-1)]]),_:1})]),u.value?(I(),L(`div`,gV,[(I(),L(F,null,ya(4,e=>B(vL,{key:e,class:`h-64 w-full`,rounded:`rounded-panel`})),64))])):j(t).length===0?(I(),R(oL,{key:1,title:`No servers yet`,description:`Add the first process this panel should keep alive.`},{icon:M(()=>[B(j(xy),{class:`size-4`})]),action:M(()=>[B($,{variant:`primary`,onClick:y[3]||=e=>l.value=!0},{default:M(()=>[B(j(my),{class:`size-3.5`}),y[10]||=V(`Add a server `,-1)]),_:1})]),_:1})):(I(),L(`div`,_V,[(I(!0),L(F,null,ya(j(t),e=>(I(),R(NB,{key:e.id,server:e,series:j(a)(e.id),now:j(r)},null,8,[`server`,`series`,`now`]))),128))]))]),z(`div`,vV,[B(WB,{class:`lg:col-span-2`},{header:M(()=>[z(`h2`,yV,[B(j(qv),{class:`size-3.5 text-faint`}),y[11]||=V(` Host vitals `,-1)])]),default:M(()=>[B(iR,{host:j(n),now:j(r)},null,8,[`host`,`now`])]),_:1}),B(WB,null,{header:M(()=>[z(`h2`,bV,[B(j(Mv),{class:`size-3.5 text-faint`}),y[12]||=V(` Recent activity `,-1)])]),actions:M(()=>[B(b,{to:`/logs`,class:`text-2xs text-muted transition-colors duration-150 hover:text-accent`},{default:M(()=>[...y[13]||=[V(` Logs `,-1)]]),_:1})]),default:M(()=>[B(fR,{servers:j(t),now:j(r),limit:10},null,8,[`servers`,`now`])]),_:1})]),z(`p`,xV,[z(`span`,SV,[B(j(Ay),{class:`size-3`}),y[14]||=V(`resource history is sampled every 5 s and kept for this session`,-1)]),z(`span`,CV,O(j(i)?.control.url),1),z(`span`,{class:D(j(Q)(`flex items-center gap-1`,j(c).status.value===`degraded`&&`text-danger`))},[z(`span`,{class:D(j(Q)(`size-1.5 rounded-full`,j(c).status.value===`degraded`?`bg-danger`:`bg-ok`))},null,2),V(` panel `+O(j(c).status.value),1)],2)]),B(Iz,{open:l.value,"onUpdate:open":y[4]||=e=>l.value=e},null,8,[`open`])])}}}),TV={class:`mb-4 flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`},EV={class:`flex items-center gap-2`},DV={class:`font-mono tabular-nums`},OV={key:1,class:`text-2xs text-faint`},kV={class:`flex flex-col gap-3`},AV={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`},jV={class:`mt-4 flex items-center justify-end gap-2 border-t border-line pt-3.5`},MV={class:`max-h-[60dvh] overflow-auto`},NV={key:0,class:`divide-y divide-line-soft`},PV={class:`font-mono text-xs text-ink`},FV={class:`ml-auto font-mono text-xs text-muted line-through`},IV={class:`font-mono text-xs text-accent`},LV={key:1,class:`text-xs text-muted`},RV=N({__name:`ServerConfigEditor`,props:{serverId:{},config:{}},emits:[`saved`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=[`restart`,`health`,`stop`],a=jM(),o=A(!1),s=A(null);function c(e){return e>0?Math.round(e/1024/1024):null}function l(e){return{label:e.label??``,command:e.command,cwd:e.cwd,args:e.args.join(`
43
43
  `),env:qR(e.env),dataEnvs:qR(e.dataEnvs),backupPaths:e.backupPaths.join(`
44
- `),backupIgnoreGenerated:e.backupIgnoreGenerated!==!1,dependsOn:e.dependsOn.join(`, `),envFile:e.envFile,maxRssMb:c(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(`
45
- `),bootstrapEnv:qR(e.bootstrap?.env??{}),bootstrapTimeoutMs:e.bootstrap?.timeoutMs??12e4,bootstrapRunOnce:e.bootstrap?.runOnce??!0}}let u=tn(l(n.config)),d=A({...n.config.restart}),f=A({...n.config.health}),p=A({...n.config.stop}),m=U(()=>{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 h(){let e=Number.isFinite(u.maxRssMb)?u.maxRssMb:0,t=Number.isFinite(u.logBufferLines)&&u.logBufferLines>=50?u.logBufferLines:50,n=Number.isFinite(u.bootstrapTimeoutMs)?u.bootstrapTimeoutMs:0;return{label:u.label.trim(),command:u.command.trim(),cwd:u.cwd.trim()===``?`.`:u.cwd.trim(),args:KR(u.args),env:JR(u.env),dataEnvs:JR(u.dataEnvs),backupPaths:KR(u.backupPaths),backupIgnoreGenerated:u.backupIgnoreGenerated,dependsOn:YR(u.dependsOn),envFile:u.envFile.trim(),resources:{maxRssBytes:e>0?Math.round(e*1024*1024):0},port:u.port===null||Number.isNaN(u.port)?null:u.port,bind:u.bind,onPortConflict:u.onPortConflict,logBufferLines:t,enabled:u.enabled,autostart:u.autostart,restart:{...d.value},health:{...f.value},stop:{...p.value},bootstrap:u.bootstrapEnabled?{command:u.bootstrapCommand.trim(),args:KR(u.bootstrapArgs),env:JR(u.bootstrapEnv),timeoutMs:n,runOnce:u.bootstrapRunOnce}:null}}function g(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 _(e){for(let t of i)g(e,t)===null&&delete e[t];return _R(n.config,e)}function v(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}let y=U(()=>_(h())),b=U(()=>bR(y.value)),x=U(()=>b.value>0),S=U(()=>yR(y.value,n.config)),C=A(!1),w={...n.config};function T(e){Object.assign(u,l(e)),d.value={...e.restart},f.value={...e.health},p.value={...e.stop},w={...e},s.value=null}jr(()=>n.config,e=>{v(e,w)||T(e)});async function ee(){s.value=null,o.value=!0;try{let e=h(),t=xA(e);if(t instanceof Y.errors){s.value=t.summary;return}let i=_(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}r(`saved`)}finally{o.value=!1}}return(e,t)=>(I(),L(F,null,[z(`form`,{class:`border-t border-line bg-page/40 px-4 py-4`,onSubmit:uu(ee,[`prevent`])},[z(`header`,TV,[t[31]||=z(`div`,{class:`min-w-0`},[z(`h2`,{class:`text-sm font-semibold text-ink`},` Edit configuration `),z(`p`,{class:`mt-0.5 text-2xs leading-4 text-muted`},[V(` Writes overrides to `),z(`span`,{class:`font-mono`},`servers.config.json`),V(`; anything left alone keeps inheriting the defaults. `)])],-1),z(`div`,EV,[b.value>0?(I(),L(`button`,{key:0,type:`button`,class:`rounded-control px-1 py-0.5 text-2xs text-warn underline decoration-warn/40 underline-offset-2 transition-colors duration-150 hover:text-ink`,onClick:t[0]||=e=>C.value=!0},[z(`span`,DV,O(b.value),1),V(` unsaved `+O(b.value===1?`change`:`changes`),1)])):(I(),L(`span`,OV,`in sync`))])]),z(`div`,kV,[B(cz,{title:`Process`,description:`What gets spawned, where, and with which environment.`,columns:2},{default:M(()=>[B(yz,{modelValue:u.label,"onUpdate:modelValue":t[1]||=e=>u.label=e,label:`Label`,placeholder:`falls back to the id`},null,8,[`modelValue`]),B(yz,{modelValue:u.command,"onUpdate:modelValue":t[2]||=e=>u.command=e,label:`Command`,placeholder:`node`,required:``,class:`font-mono text-xs`},null,8,[`modelValue`]),B(yz,{modelValue:u.cwd,"onUpdate:modelValue":t[3]||=e=>u.cwd=e,label:`Working directory`,placeholder:`.`,hint:`Relative paths resolve under projectDir.`,class:`font-mono text-xs`},null,8,[`modelValue`]),B(yz,{modelValue:u.envFile,"onUpdate:modelValue":t[4]||=e=>u.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`]),B(Mz,{modelValue:u.args,"onUpdate:modelValue":t[5]||=e=>u.args=e,label:`Arguments`,rows:3,hint:`One per line; {port} {host} {home} {projectDir} {dataRoot} {id} {label} {cwd} {bind} {lanIp} are substituted.`,placeholder:`-p
46
- {port}`},null,8,[`modelValue`]),B(Mz,{modelValue:u.env,"onUpdate:modelValue":t[6]||=e=>u.env=e,label:`Environment`,rows:3,hint:`KEY=value per line, exported to the process.`,placeholder:`NODE_ENV=production`},null,8,[`modelValue`]),B(Mz,{modelValue:u.dataEnvs,"onUpdate:modelValue":t[7]||=e=>u.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`]),B(Mz,{modelValue:u.backupPaths,"onUpdate:modelValue":t[8]||=e=>u.backupPaths=e,label:`Extra backup paths`,rows:2,hint:`One per line, placeholders allowed; data envs are captured already.`,placeholder:`{home}/.app/uploads`},null,8,[`modelValue`]),B(Sz,{modelValue:u.backupIgnoreGenerated,"onUpdate:modelValue":t[9]||=e=>u.backupIgnoreGenerated=e,label:`Ignore known generated files when backing this up`,hint:`Skips node_modules, dist, .next and the other caches nothing restores from.`,wide:``},null,8,[`modelValue`]),B(yz,{modelValue:u.dependsOn,"onUpdate:modelValue":t[10]||=e=>u.dependsOn=e,label:`Depends on`,placeholder:`postgres, redis`,hint:`Comma separated; started first, stopped last.`,class:`font-mono text-xs`},null,8,[`modelValue`]),B(mz,{modelValue:u.maxRssMb,"onUpdate:modelValue":t[11]||=e=>u.maxRssMb=e,label:`Max RSS (MB)`,min:0,hint:`Restart above this; blank or 0 disables it.`},null,8,[`modelValue`])]),_:1}),B(cz,{title:`Port & binding`,description:`How the port is preflighted and where the process is reachable.`,columns:2},{default:M(()=>[B(mz,{modelValue:u.port,"onUpdate:modelValue":t[12]||=e=>u.port=e,label:`Port`,nullable:``,min:1,max:65535,hint:`Blank means no port: no probe, no preflight.`},null,8,[`modelValue`]),B(_L,{modelValue:u.bind,"onUpdate:modelValue":t[13]||=e=>u.bind=e,label:`Bind address`,options:m.value,hint:`A custom IPv4 the config already sets stays selectable.`},null,8,[`modelValue`,`options`]),B(_L,{modelValue:u.onPortConflict,"onUpdate:modelValue":t[14]||=e=>u.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`},{value:`kill`,label:`kill — stop whatever holds the port`}]},null,8,[`modelValue`]),B(mz,{modelValue:u.logBufferLines,"onUpdate:modelValue":t[15]||=e=>u.logBufferLines=e,label:`Log buffer lines`,min:50,max:1e5,step:50},null,8,[`modelValue`])]),_:1}),B(cz,{title:`Lifecycle`,description:`Whether the supervisor owns this entry at all.`,columns:2},{default:M(()=>[B(Sz,{modelValue:u.enabled,"onUpdate:modelValue":t[16]||=e=>u.enabled=e,label:`Enabled`,hint:`Shows up and can be started at all.`},null,8,[`modelValue`]),B(Sz,{modelValue:u.autostart,"onUpdate:modelValue":t[17]||=e=>u.autostart=e,label:`Autostart with up`,hint:`Started when the control plane comes up.`},null,8,[`modelValue`])]),_:1}),B(Cz,{restart:d.value,"onUpdate:restart":t[18]||=e=>d.value=e,health:f.value,"onUpdate:health":t[19]||=e=>f.value=e,stop:p.value,"onUpdate:stop":t[20]||=e=>p.value=e},null,8,[`restart`,`health`,`stop`]),B(cz,{title:`Bootstrap`,description:`A one-off command run before the first start — installs, migrations, downloads.`,columns:2},{default:M(()=>[B(Sz,{modelValue:u.bootstrapEnabled,"onUpdate:modelValue":t[21]||=e=>u.bootstrapEnabled=e,label:`Run a bootstrap`,hint:`Off means the entry has none and the key is sent as null.`,wide:``},null,8,[`modelValue`]),u.bootstrapEnabled?(I(),L(F,{key:0},[B(yz,{modelValue:u.bootstrapCommand,"onUpdate:modelValue":t[22]||=e=>u.bootstrapCommand=e,label:`Command`,placeholder:`./scripts/install.sh`,class:`font-mono text-xs`},null,8,[`modelValue`]),B(mz,{modelValue:u.bootstrapTimeoutMs,"onUpdate:modelValue":t[23]||=e=>u.bootstrapTimeoutMs=e,label:`Timeout (ms)`,min:1e3,step:1e3},null,8,[`modelValue`]),B(Sz,{modelValue:u.bootstrapRunOnce,"onUpdate:modelValue":t[24]||=e=>u.bootstrapRunOnce=e,label:`Only once per session`,hint:`Off means every start re-runs it.`},null,8,[`modelValue`])],64)):H(``,!0),u.bootstrapEnabled?(I(),R(Mz,{key:1,modelValue:u.bootstrapArgs,"onUpdate:modelValue":t[25]||=e=>u.bootstrapArgs=e,label:`Bootstrap arguments`,rows:2,hint:`One per line; same placeholders as the main arguments.`},null,8,[`modelValue`])):H(``,!0),u.bootstrapEnabled?(I(),R(Mz,{key:2,modelValue:u.bootstrapEnv,"onUpdate:modelValue":t[26]||=e=>u.bootstrapEnv=e,label:`Bootstrap environment`,rows:2,hint:`KEY=value per line, exported to the bootstrap process only.`},null,8,[`modelValue`])):H(``,!0)]),_:1})]),s.value?(I(),L(`p`,AV,O(s.value),1)):H(``,!0),z(`div`,jV,[B($,{variant:`ghost`,onClick:t[27]||=e=>r(`cancel`)},{default:M(()=>[...t[32]||=[V(` Cancel `,-1)]]),_:1}),B($,{type:`submit`,variant:`primary`,disabled:o.value||!x.value,loading:o.value},{default:M(()=>[...t[33]||=[V(` Save to servers.config.json `,-1)]]),_:1},8,[`disabled`,`loading`])])],32),B(dL,{open:C.value,"onUpdate:open":t[30]||=e=>C.value=e,title:`Unsaved changes`,description:`What Save would write to servers.config.json.`,width:`w-[min(92vw,42rem)]`},{footer:M(()=>[B($,{size:`sm`,variant:`ghost`,onClick:t[28]||=e=>C.value=!1},{default:M(()=>[...t[35]||=[V(` Close `,-1)]]),_:1}),B($,{size:`sm`,variant:`primary`,disabled:S.value.length===0||o.value,loading:o.value,onClick:t[29]||=e=>{ee(),C.value=!1}},{default:M(()=>[V(` Save `+O(S.value.length)+` change`+O(S.value.length===1?``:`s`),1)]),_:1},8,[`disabled`,`loading`])]),default:M(()=>[z(`div`,MV,[S.value.length>0?(I(),L(`ul`,NV,[(I(!0),L(F,null,ya(S.value,e=>(I(),L(`li`,{key:e.path,class:`flex flex-wrap items-baseline gap-x-3 gap-y-1 py-2 first:pt-0`},[z(`code`,PV,O(e.path),1),z(`span`,FV,O(j(jI)(e.from)),1),t[34]||=z(`span`,{class:`text-2xs text-faint`},`→`,-1),z(`span`,IV,O(j(jI)(e.to)),1)]))),128))])):(I(),L(`p`,LV,` Nothing to save. `))])]),_:1},8,[`open`])],64))}}),zV=[`aria-label`],BV=N({__name:`CopyButton`,props:{value:{},label:{default:`Copy`},class:{default:void 0}},setup(e){let t=e,n=A(!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 Be(()=>{r&&clearTimeout(r)}),(e,r)=>(I(),L(`button`,{type:`button`,class:D(j(Q)(`grid size-6 shrink-0 place-items-center rounded-control text-faint transition-colors duration-150 hover:bg-hover hover:text-ink`,j(yF),t.class)),"aria-label":n.value?`Copied`:t.label,onClick:i},[n.value?(I(),R(j(Fv),{key:0,class:`size-3.5 text-ok`})):(I(),R(j(Kv),{key:1,class:`size-3.5`}))],10,zV))}}),VV={key:0,class:`mx-auto max-w-3xl p-4 sm:p-5`},HV={key:1,class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},UV={class:`font-mono text-xs text-faint`},WV=[`href`],GV={class:`px-2 py-1.5`},KV={class:`flex flex-col gap-0.5`},qV=[`onClick`],JV={class:`space-y-2`},YV={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`},XV={class:`min-w-0 flex-1 text-2xs leading-4 text-danger`},ZV={key:1,class:`rounded-control border border-warn/25 bg-warn-soft px-3 py-2 text-2xs leading-4 text-warn`},QV={class:`grid grid-cols-2 gap-x-4 gap-y-3 p-4 sm:grid-cols-4 lg:grid-cols-6`},$V={class:`truncate text-2xs text-faint`},eH={class:`truncate font-mono text-xs tabular-nums text-ink capitalize`},tH={class:`grid gap-4 sm:grid-cols-3`},nH={class:`flex items-center justify-between gap-3`},rH=[`title`],iH={key:1,class:`space-y-4`},aH={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`},oH={key:1,class:`grid grid-cols-1 gap-x-6 gap-y-2 sm:grid-cols-2`},sH={class:`text-2xs text-faint`},cH=[`title`],lH={key:2,class:`grid gap-4 lg:grid-cols-3`},uH={key:0,class:`flex flex-wrap gap-1.5`},dH={key:1,class:`text-xs text-muted`},fH=N({__name:`ServerDetailView`,setup(e){let t=Bg(),{serverById:n,now:r,seriesOf:i,start:a,stop:o,restart:s,setEnabled:c,setAutostart:l,setBind:u,clearLogs:d,freePort:f,remove:p}=jM(),m=U(()=>String(t.params.id??``)),h=U(()=>n(m.value)),g=U(()=>h.value?.config),_=U(()=>{let e=g.value;return e?.label&&e.label.length>0?e.label:m.value}),v=A(`output`),y=A(!1),b=A(!1),x=A(!1),S=A(!1),C=AM(()=>h.value?m.value:null),w=C.version,T=U(()=>(w.value,C.lines())),ee=U(()=>i(m.value)),te=U(()=>ee.value.cpu),ne=U(()=>ee.value.rss),re=U(()=>ee.value.probe),ie=U(()=>{let e=h.value;return!e||e.startedAt===null||e.status!==`running`?`—`:wI(r.value-e.startedAt)}),ae=U(()=>h.value?.status===`running`),oe=U(()=>{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:ie.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:kI(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:EI(e.history.uptimeRatio)},{key:`crashes`,label:`24h crashes`,value:String(e.history.crashes)},{key:`lastcrash`,label:`Last crash`,value:DI(e.history.lastCrashAt,r.value)}];return e.nextRetryAt!==null&&t.push({key:`retry`,label:`Next attempt`,value:TI(e.nextRetryAt,r.value)}),e.unhealthySince!==null&&t.push({key:`unhealthy`,label:`Unhealthy for`,value:wI(r.value-e.unhealthySince)}),t}),se=U(()=>JSON.stringify(g.value??{},null,2)),ce=U(()=>g.value?`${g.value.command} ${g.value.args.join(` `)}`.trim():``),le=U(()=>{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 E(e){S.value=!0;try{await{start:a,stop:o,restart:s}[e](m.value)}finally{S.value=!1}}async function ue(){x.value=!1,await p(m.value)}async function de(){let e=h.value;if(e){S.value=!0;try{await f(e.id)}finally{S.value=!1}}}let fe=U(()=>Sj(m.value,`${m.value}.log`)),pe=[{value:`output`,label:`Live output`},{value:`config`,label:`Configuration`},{value:`history`,label:`History`}];return(e,t)=>{let n=pa(`RouterLink`);return h.value?(I(),L(`div`,HV,[B(BB,{title:_.value,"back-to":`/servers`,"back-label":`All servers`},{badges:M(()=>[B(oB,{status:h.value.status,health:h.value.health},null,8,[`status`,`health`]),h.value.adopted?(I(),R(TF,{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:M(()=>[...t[16]||=[z(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`detached`,-1)]]),_:1})):H(``,!0),z(`span`,UV,O(h.value.id),1),h.value.url?(I(),L(`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`},[V(O(h.value.url)+` `,1),B(j(Xv),{class:`size-3`})],8,WV)):H(``,!0)]),actions:M(()=>[B($,{variant:`primary`,disabled:S.value||!g.value?.enabled||[`running`,`starting`].includes(h.value.status),onClick:t[0]||=e=>E(`start`)},{default:M(()=>[B(j(py),{class:`size-3.5`}),t[17]||=V(`Start `,-1)]),_:1},8,[`disabled`]),B($,{disabled:S.value||h.value.status===`stopped`,onClick:t[1]||=e=>E(`stop`)},{default:M(()=>[B(j(Ey),{class:`size-3.5`}),t[18]||=V(`Stop `,-1)]),_:1},8,[`disabled`]),B($,{disabled:S.value||!g.value?.enabled,onClick:t[2]||=e=>E(`restart`)},{default:M(()=>[B(j(vy),{class:`size-3.5`}),t[19]||=V(`Restart `,-1)]),_:1},8,[`disabled`]),B(TF,{label:`Edit every field of this entry`},{default:M(()=>[B($,{variant:y.value?`secondary`:`ghost`,onClick:t[3]||=e=>{y.value=!y.value,v.value=`config`}},{default:M(()=>[B(j(fy),{class:`size-3.5`}),V(O(y.value?`Close editor`:`Edit`),1)]),_:1},8,[`variant`])]),_:1}),B(j(tg),null,{default:M(()=>[B(j(og),{"as-child":``},{default:M(()=>[B($,{variant:`ghost`,size:`icon-sm`,"aria-label":`More actions for ${_.value}`},{default:M(()=>[B(j(Yv),{class:`size-4`})]),_:1},8,[`aria-label`])]),_:1}),B(j(ig),null,{default:M(()=>[B(j(ng),{"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:M(()=>[B(j(rg),{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=>j(c)(h.value.id,!h.value.config.enabled)},{default:M(()=>[V(O(g.value?.enabled?`Disable server`:`Enable server`),1)]),_:1}),B(j(rg),{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=>j(l)(h.value.id,!h.value.config.autostart)},{default:M(()=>[V(O(g.value?.autostart?`Remove from autostart`:`Autostart with the panel`),1)]),_:1}),B(j(ag),{class:`my-1 h-px bg-line`}),z(`div`,GV,[t[20]||=z(`p`,{class:`mb-1 text-2xs text-faint`},` Bind `,-1),z(`div`,KV,[(I(!0),L(F,null,ya(le.value,e=>(I(),L(`button`,{key:e.value,type:`button`,class:D([`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=>j(u)(h.value.id,e.value)},O(e.label),11,qV))),128))])]),B(j(ag),{class:`my-1 h-px bg-line`}),B(j(rg),{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:M(()=>[B(j(jy),{class:`size-3.5`}),t[21]||=V(` Remove server `,-1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,[`title`]),z(`div`,JV,[h.value.lastError?(I(),L(`div`,YV,[z(`p`,XV,O(h.value.lastError),1),h.value.status===`conflict`&&h.value.config.port!==null?(I(),R(zz,{key:0,port:h.value.config.port,busy:S.value,onConfirm:de},null,8,[`port`,`busy`])):H(``,!0)])):H(``,!0),h.value.health===`unhealthy`?(I(),L(`p`,ZV,[t[22]||=V(` The health probe has not passed `,-1),h.value.unhealthySince===null?H(``,!0):(I(),L(F,{key:0},[V(` for `+O(j(wI)(j(r)-h.value.unhealthySince)),1)],64)),t[23]||=V(`. `,-1)])):H(``,!0)]),B(WB,{class:`p-0`},{default:M(()=>[z(`dl`,QV,[(I(!0),L(F,null,ya(oe.value,e=>(I(),L(`div`,{key:e.key,class:`min-w-0`},[z(`dt`,$V,O(e.label),1),z(`dd`,eH,O(e.value),1)]))),128))])]),_:1}),B(WB,null,{header:M(()=>[...t[24]||=[z(`h2`,{class:`text-sm font-semibold text-ink`},` Telemetry `,-1),z(`p`,{class:`text-2xs text-muted`},` Sampled every 5 s while this page is open. `,-1)]]),default:M(()=>[z(`div`,tH,[B(nB,{label:`CPU`,values:te.value,format:j(AI),max:100,"color-class":`text-cpu`,height:40},null,8,[`values`,`format`]),B(nB,{label:`Memory (RSS)`,values:ne.value,format:j(kI),"color-class":`text-mem`,height:40},null,8,[`values`,`format`]),B(nB,{label:`Health probe`,values:re.value,format:e=>e===null?`—`:`${e} ms`,"color-class":`text-probe`,height:40},null,8,[`values`,`format`])])]),_:1}),z(`div`,nH,[B(RI,{modelValue:v.value,"onUpdate:modelValue":t[7]||=e=>v.value=e,options:pe,size:`md`},null,8,[`modelValue`]),z(`p`,{class:`hidden font-mono text-2xs text-faint sm:block`,title:ce.value},O(ce.value),9,rH)]),v.value===`output`?(I(),R(eL,{key:0,lines:T.value,version:j(w),live:``,clearable:``,"download-url":h.value.config.logBufferLines>0?fe.value:void 0,"download-name":`${h.value.id}.log`,"empty-hint":ae.value?`Waiting for the first line…`:`This server has not written anything yet.`,"min-height":`22rem`,onClear:t[8]||=e=>j(d)(h.value.id)},null,8,[`lines`,`version`,`download-url`,`download-name`,`empty-hint`])):v.value===`config`?(I(),L(`div`,iH,[y.value?(I(),R(RV,{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`])):(I(),R(WB,{key:1},{header:M(()=>[...t[25]||=[z(`h2`,{class:`text-sm font-semibold text-ink`},` Effective configuration `,-1),z(`p`,{class:`text-2xs text-muted`},` Defaults from Settings are already merged into these values. `,-1)]]),actions:M(()=>[B($,{size:`xs`,variant:`ghost`,onClick:t[11]||=e=>b.value=!b.value},{default:M(()=>[B(j(Wv),{class:`size-3`}),V(O(b.value?`Fields`:`Raw JSON`),1)]),_:1}),B(BV,{value:se.value,label:`Copy the JSON config`},null,8,[`value`]),B($,{size:`xs`,variant:`primary`,onClick:t[12]||=e=>y.value=!0},{default:M(()=>[B(j(fy),{class:`size-3`}),t[26]||=V(`Edit `,-1)]),_:1})]),default:M(()=>[b.value?(I(),L(`pre`,aH,O(se.value),1)):(I(),L(`dl`,oH,[(I(!0),L(F,null,ya([{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?j(kI)(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=>(I(),L(`div`,{key:e.label,class:`min-w-0 border-b border-line-soft pb-1.5 last:border-0`},[z(`dt`,sH,O(e.label),1),z(`dd`,{class:`truncate font-mono text-xs text-ink`,title:String(e.value)},O(e.value),9,cH)]))),128))]))]),_:1}))])):(I(),L(`div`,lH,[B(WB,{class:`lg:col-span-2`},{header:M(()=>[...t[27]||=[z(`h2`,{class:`text-sm font-semibold text-ink`},` Event history `,-1),z(`p`,{class:`text-2xs text-muted`},` Kept by the panel for 24 hours. `,-1)]]),default:M(()=>[B(fR,{servers:[h.value],now:j(r),limit:30},null,8,[`servers`,`now`])]),_:1}),B(WB,null,{header:M(()=>[...t[28]||=[z(`h2`,{class:`text-sm font-semibold text-ink`},` Dependencies `,-1)]]),default:M(()=>[g.value&&g.value.dependsOn.length>0?(I(),L(`div`,uH,[(I(!0),L(F,null,ya(g.value.dependsOn,e=>(I(),R(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:M(()=>[V(O(e),1)]),_:2},1032,[`to`]))),128))])):(I(),L(`p`,dH,[...t[29]||=[V(` Starts on its own. Add ids under `,-1),z(`code`,null,`dependsOn`,-1),V(` to order it after other servers. `,-1)]]))]),_:1})])),B(dL,{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:M(()=>[B($,{variant:`ghost`,onClick:t[13]||=e=>x.value=!1},{default:M(()=>[...t[30]||=[V(` Keep it `,-1)]]),_:1}),B($,{variant:`danger`,onClick:ue},{default:M(()=>[B(j(jy),{class:`size-3.5`}),t[31]||=V(`Remove `,-1)]),_:1})]),default:M(()=>[t[32]||=z(`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`])])):(I(),L(`div`,VV,[B(oL,{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:M(()=>[B(n,{to:`/servers`},{default:M(()=>[B($,{variant:`primary`},{default:M(()=>[...t[15]||=[V(` Back to servers `,-1)]]),_:1})]),_:1})]),_:1},8,[`description`])]))}}}),pH={class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},mH={class:`flex flex-wrap items-center gap-2`},hH={class:`relative ml-auto w-full sm:w-64`},gH={key:0,class:`grid gap-4 lg:grid-cols-2`},_H={key:3,class:`grid gap-4 lg:grid-cols-2`},vH=N({__name:`ServersView`,setup(e){let{servers:t,appState:n,now:r,seriesOf:i,startAll:a,stopAll:o}=jM(),s=A(!1),c=A(``),l=A(`all`),u=[{value:`all`,label:`All`},{value:`running`,label:`Running`},{value:`stopped`,label:`Stopped`},{value:`attention`,label:`Attention`},{value:`disabled`,label:`Disabled`}],d=U(()=>n.value===null),f=U(()=>{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=U(()=>({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)=>(I(),L(`div`,pH,[B(BB,{title:`Servers`,description:`Every entry in servers.config.json, with live resources, health and history.`},{actions:M(()=>[B($,{variant:`ghost`,onClick:n[0]||=e=>j(a)()},{default:M(()=>[B(j(py),{class:`size-3.5`}),n[9]||=V(`Start all `,-1)]),_:1}),B($,{variant:`ghost`,onClick:n[1]||=e=>j(o)()},{default:M(()=>[B(j(Ey),{class:`size-3.5`}),n[10]||=V(`Stop all `,-1)]),_:1}),B($,{variant:`primary`,onClick:n[2]||=e=>s.value=!0},{default:M(()=>[B(j(my),{class:`size-3.5`}),n[11]||=V(`Add server `,-1)]),_:1})]),_:1}),z(`div`,mH,[B(RI,{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`]),z(`div`,hH,[B(j(by),{class:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),xr(z(`input`,{"onUpdate:modelValue":n[4]||=e=>c.value=e,type:`search`,placeholder:`Filter by id, label, command or port`,class:D([`pl-8`,[j(SF)]]),"aria-label":`Filter servers`},null,2),[[Yl,c.value]]),c.value.length>0?(I(),L(`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=``},[B(j(Ny),{class:`size-3.5`})])):H(``,!0)])]),d.value?(I(),L(`div`,gH,[(I(),L(F,null,ya(4,e=>B(vL,{key:e,class:`h-72 w-full`,rounded:`rounded-panel`})),64))])):j(t).length===0?(I(),R(oL,{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:M(()=>[B(j(xy),{class:`size-4`})]),action:M(()=>[B($,{variant:`primary`,onClick:n[6]||=e=>s.value=!0},{default:M(()=>[B(j(my),{class:`size-3.5`}),n[12]||=V(`Add a server `,-1)]),_:1})]),_:1})):f.value.length===0?(I(),R(oL,{key:2,compact:``,title:`Nothing matches that filter`,description:`Try a different status or clear the search.`},{action:M(()=>[B($,{onClick:n[7]||=e=>{c.value=``,l.value=`all`}},{default:M(()=>[...n[13]||=[V(` Clear filters `,-1)]]),_:1})]),_:1})):(I(),L(`div`,_H,[(I(!0),L(F,null,ya(f.value,e=>(I(),R(NB,{key:e.id,server:e,series:j(i)(e.id),now:j(r)},null,8,[`server`,`series`,`now`]))),128))])),B(Iz,{open:s.value,"onUpdate:open":n[8]||=e=>s.value=e},null,8,[`open`])]))}}),yH=N({__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=A(!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 Be(o),(e,t)=>(I(),R($,{variant:i.value?n.confirmVariant:n.variant,size:n.size,disabled:n.disabled,loading:n.loading,onClick:s},{default:M(()=>[V(O(i.value?n.confirmLabel:n.label),1)]),_:1},8,[`variant`,`size`,`disabled`,`loading`]))}}),bH={class:`min-w-0 flex-1`},xH={key:0,class:`text-xs font-semibold`},SH=N({__name:`Notice`,props:{tone:{default:`info`},title:{default:void 0},class:{default:void 0}},setup(e){let t=e,n={ok:Vv,warn:My,danger:uy,info:ty,neutral:ty,accent:Sy},r=U(()=>n[t.tone]);return(e,n)=>(I(),L(`div`,{class:D(j(Q)(`flex items-start gap-2 rounded-panel border px-3 py-2`,j(vP)[t.tone],t.class))},[(I(),R(ha(r.value),{class:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`})),z(`div`,bH,[t.title?(I(),L(`p`,xH,O(t.title),1)):H(``,!0),z(`div`,{class:D(j(Q)(`text-xs leading-relaxed text-ink/85`,t.title&&`mt-0.5`))},[P(e.$slots,`default`)],2)])],2))}}),CH={class:`space-y-2`},wH={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},TH=N({__name:`AuthenticationSection`,props:Ba({view:{},dirty:{type:Boolean}},{auth:{required:!0},authModifiers:{}}),emits:Ba([`reset`],[`update:auth`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`auth`),a=WR(()=>i.value.sessionTtlMs,e=>i.value.sessionTtlMs=e,6048e5),o=WR(()=>i.value.maxLoginAttempts,e=>i.value.maxLoginAttempts=e,5),s=WR(()=>i.value.lockoutMs,e=>i.value.lockoutMs=e,6e4),c=U(()=>n.view?.auth.passwordSet===!0),l=U(()=>n.view?.auth.apiTokenSet===!0),u=U(()=>n.view?.auth.blockedReason??null),d=U(()=>n.view?.auth.exposed===!0),f=U(()=>n.view?.auth.usingDefaultPassword===!0),p=U(()=>i.value.enabled&&!c.value),{setPassword:m,clearPassword:h}=Jj(),g=A(``),_=A(``),v=A(``),y=A(null),b=A(null),x=A(!1),S=U(()=>v.value.length>0&&v.value!==_.value),C=U(()=>_.value.length>0&&_.value.length<8),w=U(()=>_.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)=>(I(),L(F,null,[B(cz,{title:`Access policy`,description:`Authentication applies whether the panel is on loopback or exposed to the network.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[10]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(Sz,{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`]),B(mz,{modelValue:j(a),"onUpdate:modelValue":t[2]||=e=>k(a)?a.value=e:null,label:`Session lifetime (ms)`,min:6e4,hint:`604800000 is one week.`},null,8,[`modelValue`]),B(_L,{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`]),B(Sz,{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`]),B(mz,{modelValue:j(o),"onUpdate:modelValue":t[5]||=e=>k(o)?o.value=e:null,label:`Max login attempts`,min:1,hint:`Failures before a temporary lockout.`},null,8,[`modelValue`]),B(mz,{modelValue:j(s),"onUpdate:modelValue":t[6]||=e=>k(s)?s.value=e:null,label:`Lockout (ms)`,min:1e3},null,8,[`modelValue`])]),_:1}),z(`div`,CH,[B(SH,{tone:l.value?`info`:`neutral`,title:l.value?`An API token is set`:`No API token`},{default:M(()=>[l.value?(I(),L(F,{key:0},[t[11]||=V(` Scripts can call the API with `,-1),t[12]||=z(`code`,null,`Authorization: Bearer …`,-1),t[13]||=V(` instead of signing in. `,-1)],64)):(I(),L(F,{key:1},[t[14]||=V(` For shell scripts and agents, generate one with `,-1),t[15]||=z(`code`,null,`home-hosted set-token --generate`,-1),t[16]||=V(`. `,-1)],64))]),_:1},8,[`tone`,`title`]),f.value?(I(),R(SH,{key:0,tone:`warn`,title:`The default password is still in use`},{default:M(()=>[...t[17]||=[V(` Set your own password below. Binding beyond `,-1),z(`code`,null,`127.0.0.1`,-1),V(` stays refused until you do. `,-1)]]),_:1})):H(``,!0),u.value?(I(),R(SH,{key:1,tone:`danger`,title:`This listener is being refused`},{default:M(()=>[V(O(u.value),1)]),_:1})):p.value?(I(),R(SH,{key:2,tone:`warn`,title:`Authentication is on but no password is set`},{default:M(()=>[...t[18]||=[V(` Nothing is actually required yet, and binding beyond `,-1),z(`code`,null,`127.0.0.1`,-1),V(` stays refused until a password exists. `,-1)]]),_:1})):d.value?(I(),R(SH,{key:3,tone:`warn`,title:`Reachable beyond 127.0.0.1`},{default:M(()=>[...t[19]||=[V(` Keep the password strong, or put a TLS-terminating proxy in front of the panel. `,-1)]]),_:1})):H(``,!0)]),z(`form`,{class:`mt-3`,onSubmit:uu(T,[`prevent`])},[B(cz,{title:c.value?`Change password`:`Set a password`,description:`Stored as a scrypt hash in the secrets file, never in the config.`},{default:M(()=>[c.value?(I(),R(yz,{key:0,modelValue:g.value,"onUpdate:modelValue":t[7]||=e=>g.value=e,type:`password`,autocomplete:`current-password`,label:`Current password`},null,8,[`modelValue`])):H(``,!0),B(yz,{modelValue:_.value,"onUpdate:modelValue":t[8]||=e=>_.value=e,type:`password`,autocomplete:`new-password`,label:`New password`},null,8,[`modelValue`]),B(yz,{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`]),z(`div`,wH,[B($,{type:`submit`,variant:`primary`,disabled:!w.value,loading:x.value},{default:M(()=>[V(O(c.value?`Update password`:`Set password and enable auth`),1)]),_:1},8,[`disabled`,`loading`]),c.value?(I(),R(yH,{key:0,label:`Clear password`,"confirm-label":`Confirm clear`,"confirm-variant":`danger`,disabled:x.value,onConfirm:ee},null,8,[`disabled`])):H(``,!0)]),C.value||b.value||y.value?(I(),L(F,{key:1},[C.value?(I(),R(SH,{key:0,tone:`warn`,title:`That is a short password`,class:`sm:col-span-2`},{default:M(()=>[...t[20]||=[V(` It is allowed, but longer is the only thing standing between the network and this panel. `,-1)]]),_:1})):H(``,!0),b.value?(I(),R(SH,{key:1,tone:`danger`,class:`sm:col-span-2`},{default:M(()=>[V(O(b.value),1)]),_:1})):H(``,!0),y.value?(I(),R(SH,{key:2,tone:`ok`,class:`sm:col-span-2`},{default:M(()=>[V(O(y.value),1)]),_:1})):H(``,!0)],64)):H(``,!0)]),_:1},8,[`title`])],32)],64))}}),EH=[`disabled`],DH={class:`min-w-0`},OH={class:`text-ink`},kH=N({__name:`CheckField`,props:Ba({label:{},hint:{default:void 0},disabled:{type:Boolean,default:!1}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=co(e,`modelValue`);return(e,r)=>(I(),L(`label`,{class:D(j(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`))},[xr(z(`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,EH),[[Xl,n.value]]),z(`span`,DH,[z(`span`,OH,O(t.label),1),t.hint?(I(),L(`span`,{key:0,class:D([`mt-0.5 block`,[j(xF)]])},O(t.hint),3)):H(``,!0),P(e.$slots,`default`)])],2))}}),AH={class:`space-y-3`},jH={key:0,class:`sm:col-span-2`},MH={key:1,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`},PH={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},FH={class:`text-2xs leading-4 text-faint`},IH={key:0,class:`space-y-2 sm:col-span-2`},LH={key:1,class:`text-xs text-muted sm:col-span-2`},RH={key:2,class:`divide-y divide-line-soft sm:col-span-2`},zH={class:`min-w-0`},BH={class:`truncate font-mono text-xs text-ink`},VH={class:`mt-0.5 text-2xs leading-4 text-muted`},HH={class:`sm:col-span-2`},UH={key:0,class:`space-y-2 sm:col-span-2`},WH={key:1,class:`sm:col-span-2`},GH={key:2,class:`divide-y divide-line-soft sm:col-span-2`},KH={class:`min-w-0 flex-1`},qH={class:`flex items-center gap-2`},JH={class:`truncate font-mono text-xs text-ink`},YH={class:`mt-0.5 font-mono text-2xs tabular-nums text-muted`},XH={class:`flex items-center gap-1.5`},ZH=[`href`],QH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},$H={key:0,class:`font-mono text-2xs text-muted`},eU={class:`sm:col-span-2`},tU={key:0,class:`sm:col-span-2`},nU={class:`mt-2`},rU={class:`mt-2 max-w-sm`},iU={class:`mt-2`},aU={class:`mt-2`},oU={class:`mt-1 max-h-64 space-y-0.5 overflow-auto`},sU={class:`mt-2 flex flex-wrap items-center gap-2`},cU={class:`mt-2`},lU={class:`mt-2`},uU={key:1,class:`space-y-2 sm:col-span-2`},dU=N({__name:`BackupsSection`,props:Ba({state:{},policy:{},configPath:{},dirty:{type:Boolean}},{form:{required:!0},formModifiers:{}}),emits:Ba([`reset`],[`update:form`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`form`),a=jM(),o=WR(()=>i.value.keep,e=>i.value.keep=e,5),s=A(!1),c=A(null),l=A(null),u=A(``),d=A(null),f=A(null),p=A(``),m=A(null),h=U(()=>n.state?.files??[]),g=U(()=>n.state?.paths??[]),_=U(()=>d.value?.items.filter(e=>e.selected).length??0),v=U(()=>d.value?.items.some(e=>e.id===`config`&&e.selected)??!1),y=Q(SF,`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`,yF);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 Cj(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 wj(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 Oj(f.value,!1,T())):(m.value={kind:`stored`,name:e},d.value=await Dj(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 te(){let e=m.value;e!==null&&await ee(e.kind===`stored`?e.name:void 0)}async function ne(){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 Dj(e.name,!0,n):f.value===null?null:await Oj(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)=>(I(),L(`div`,AH,[B(cz,{title:`Policy`,description:`What a backup captures, and how many archives are kept.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[9]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(Sz,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Allow backups`,hint:`Off stops new archives; whatever is already on disk stays downloadable and restorable.`,wide:``},null,8,[`modelValue`]),i.value.enabled?H(``,!0):(I(),L(`div`,jH,[B(SH,{tone:`warn`,title:`Backups are off`},{default:M(()=>[...t[10]||=[V(` Nothing new is archived until this is back on. The archives below can still be downloaded, restored and deleted. `,-1)]]),_:1})])),B(mz,{modelValue:j(o),"onUpdate:modelValue":t[2]||=e=>k(o)?o.value=e:null,label:`Keep`,min:1,hint:`Older archives are pruned after each backup.`},null,8,[`modelValue`]),B(yz,{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?H(``,!0):(I(),L(`div`,MH,[t[13]||=z(`span`,{class:`text-xs font-medium text-muted`},`Archive directory`,-1),z(`div`,NH,[z(`span`,PH,O(n.policy.dir),1),B(BV,{value:n.policy.dir,label:`Copy the archive directory`},null,8,[`value`])]),z(`p`,FH,[t[11]||=V(` Changing it is a file-level decision: edit `,-1),z(`code`,null,O(n.configPath??`the config file`),1),t[12]||=V(`. `,-1)])]))]),_:1}),B(cz,{title:`Declared paths`,description:`Config, secrets and TLS are always captured. A path already covered by a declared parent is skipped.`},{default:M(()=>[n.state===null?(I(),L(`div`,IH,[B(vL,{class:`h-4 w-full`})])):g.value.length===0?(I(),L(`p`,LH,[...t[14]||=[V(` No data paths are declared yet. Add `,-1),z(`code`,null,`dataEnvs`,-1),V(` or `,-1),z(`code`,null,`backupPaths`,-1),V(` to a server to capture its data. `,-1)]])):(I(),L(`ul`,RH,[(I(!0),L(F,null,ya(g.value,e=>(I(),L(`li`,{key:`${e.origin}:${e.path}`,class:`flex items-start justify-between gap-3 py-1.5`},[z(`div`,zH,[z(`p`,BH,O(e.path),1),z(`p`,VH,[V(O(e.included?`from ${e.origin}`:e.note??`not captured`)+` `,1),e.included&&e.ignoreGenerated?(I(),L(F,{key:0},[V(` · generated directories skipped `)],64)):H(``,!0)])]),B(BF,{tone:e.included?`ok`:`neutral`,plain:``},{default:M(()=>[V(O(e.included?`included`:`skipped`),1)]),_:2},1032,[`tone`])]))),128))]))]),_:1}),i.value.enabled?(I(),R(cz,{key:0,title:`Create a backup now`,description:`Optional password encrypts the archive; restoring it will ask for the same password.`},{default:M(()=>[B(yz,{modelValue:u.value,"onUpdate:modelValue":t[4]||=e=>u.value=e,type:`password`,autocomplete:`new-password`,label:`Password (optional)`,wide:``},null,8,[`modelValue`]),z(`div`,HH,[B($,{variant:`primary`,disabled:s.value,loading:s.value,onClick:S},{default:M(()=>[...t[15]||=[V(` Create backup now `,-1)]]),_:1},8,[`disabled`,`loading`])])]),_:1})):H(``,!0),B(cz,{title:`Archives`,description:`Stored in the backup directory and downloadable at any time.`},{default:M(()=>[n.state===null?(I(),L(`div`,UH,[B(vL,{class:`h-4 w-full`}),B(vL,{class:`h-4 w-2/3`})])):h.value.length===0?(I(),L(`div`,WH,[B(oL,{compact:``,title:`No archives yet`,description:i.value.enabled?`Create one now to capture the config, secrets and every declared data path.`:`Nothing has been archived yet, and backups are off.`},ba({icon:M(()=>[B(j(Nv),{class:`size-4`})]),_:2},[i.value.enabled?{name:`action`,fn:M(()=>[B($,{size:`sm`,variant:`primary`,disabled:s.value,onClick:S},{default:M(()=>[...t[16]||=[V(` Create backup now `,-1)]]),_:1},8,[`disabled`])]),key:`0`}:void 0]),1032,[`description`])])):(I(),L(`ul`,GH,[(I(!0),L(F,null,ya(h.value,e=>(I(),L(`li`,{key:e.name,class:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 first:pt-0 last:pb-0`},[z(`div`,KH,[z(`div`,qH,[z(`span`,JH,O(e.name),1),e.encrypted?(I(),R(BF,{key:0,tone:`warn`,plain:``},{default:M(()=>[...t[17]||=[V(` encrypted `,-1)]]),_:1})):H(``,!0)]),z(`p`,YH,O(j(OI)(e.sizeBytes))+` · `+O(j(CI)(e.createdAt)),1)]),z(`div`,XH,[z(`a`,{href:Tj(e.name),class:D(j(b))},[B(j(Jv),{class:`size-3`,"aria-hidden":`true`}),t[18]||=V(` Download `,-1)],10,ZH),B($,{size:`xs`,variant:`secondary`,disabled:s.value,onClick:t=>ee(e.name)},{default:M(()=>[B(j(_y),{class:`size-3`,"aria-hidden":`true`}),t[19]||=V(` Restore `,-1)]),_:1},8,[`disabled`,`onClick`]),B(yH,{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}),B(cz,{title:`Restore`,description:`Nothing is written until the plan is applied.`},{default:M(()=>[z(`div`,QH,[z(`label`,{class:D(j(bF)),for:`restore-upload`},`Restore from an uploaded .zip`,2),z(`input`,{id:`restore-upload`,type:`file`,accept:`.zip,application/zip`,class:D(j(y)),onChange:w},null,34),f.value?(I(),L(`p`,$H,O(f.value.name),1)):H(``,!0)]),z(`div`,eU,[B($,{variant:`secondary`,disabled:s.value||f.value===null,onClick:t[5]||=e=>ee()},{default:M(()=>[...t[20]||=[V(` Check the upload `,-1)]]),_:1},8,[`disabled`])]),d.value?(I(),L(`div`,tU,[B(SH,{tone:`warn`,title:d.value.dryRun?`Nothing has changed yet`:`Applied`},{default:M(()=>[z(`p`,null,[m.value?.kind===`stored`?(I(),L(F,{key:0},[t[21]||=V(` Archive `,-1),z(`code`,null,O(m.value.name),1),t[22]||=V(`. `,-1)],64)):(I(),L(F,{key:1},[V(` The uploaded archive. `)],64))]),d.value.needsPassword?(I(),L(F,{key:0},[z(`p`,nU,O(d.value.error??`This backup is password-protected.`),1),z(`div`,rU,[B(yz,{modelValue:p.value,"onUpdate:modelValue":t[6]||=e=>p.value=e,type:`password`,autocomplete:`off`,label:`Password`},null,8,[`modelValue`])]),z(`div`,iU,[B($,{size:`sm`,variant:`secondary`,disabled:s.value,onClick:te},{default:M(()=>[...t[23]||=[V(` Check again with the password `,-1)]]),_:1},8,[`disabled`])])],64)):(I(),L(F,{key:1},[z(`p`,aU,` Choose what to restore — `+O(_.value)+` of `+O(d.value.items.length)+` selected. `,1),z(`ul`,oU,[(I(!0),L(F,null,ya(d.value.items,e=>(I(),L(`li`,{key:e.id},[B(kH,{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))]),z(`div`,sU,[B($,{size:`xs`,variant:`ghost`,disabled:s.value,onClick:t[7]||=e=>x(!0)},{default:M(()=>[...t[24]||=[V(` Select all `,-1)]]),_:1},8,[`disabled`]),B($,{size:`xs`,variant:`ghost`,disabled:s.value,onClick:t[8]||=e=>x(!1)},{default:M(()=>[...t[25]||=[V(` Select none `,-1)]]),_:1},8,[`disabled`])]),z(`p`,cU,[V(` Will restore: `+O(d.value.applied.join(`, `)||`nothing`)+`. `,1),d.value.skipped.length?(I(),L(F,{key:0},[V(` Skipped: `+O(d.value.skipped.join(`, `))+`. `,1)],64)):H(``,!0),d.value.restartRequired?(I(),L(F,{key:1},[V(` The panel's own settings differ, so restart the panel afterwards. `)],64)):v.value?(I(),L(F,{key:2},[V(` Restored servers are reloaded immediately; entries marked autostart start on their own. `)],64)):H(``,!0)]),z(`div`,lU,[B($,{size:`sm`,variant:`danger`,disabled:s.value||_.value===0,loading:s.value,onClick:ne},{default:M(()=>[V(O(m.value?.kind===`stored`?`Apply this restore`:`Restore the upload`),1)]),_:1},8,[`disabled`,`loading`])])],64))]),_:1},8,[`title`])])):H(``,!0),l.value||c.value?(I(),L(`div`,uU,[l.value?(I(),R(SH,{key:0,tone:`danger`},{default:M(()=>[V(O(l.value),1)]),_:1})):H(``,!0),c.value?(I(),R(SH,{key:1,tone:`ok`},{default:M(()=>[V(O(c.value),1)]),_:1})):H(``,!0)])):H(``,!0)]),_:1})]))}}),fU={class:`mt-3 space-y-3`},pU=N({__name:`DefaultsSection`,props:Ba({dirty:{type:Boolean}},{defaults:{required:!0},defaultsModifiers:{}}),emits:Ba([`reset`],[`update:defaults`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`defaults`),a=WR(()=>i.value.logBufferLines,e=>i.value.logBufferLines=e,500);return(e,t)=>(I(),L(F,null,[B(cz,{title:`Server defaults`,description:`Applied to every entry that does not set its own value.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[9]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(Sz,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Enabled`,hint:`New entries start enabled.`,wide:``},null,8,[`modelValue`]),B(Sz,{modelValue:i.value.autostart,"onUpdate:modelValue":t[2]||=e=>i.value.autostart=e,label:`Autostart with the panel`},null,8,[`modelValue`]),B(_L,{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`]),B(_L,{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`},{value:`kill`,label:`Kill whatever holds the port`}]},null,8,[`modelValue`]),B(mz,{modelValue:j(a),"onUpdate:modelValue":t[5]||=e=>k(a)?a.value=e:null,label:`Log buffer lines`,min:50,max:1e5,hint:`Kept in memory per server.`},null,8,[`modelValue`])]),_:1}),z(`div`,fU,[B(Cz,{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))}}),mU={key:0,class:`mt-3 flex flex-wrap items-center gap-1.5`},hU={key:1,class:`mt-3 text-xs text-muted`},gU=N({__name:`HostSection`,props:Ba({config:{},alerts:{},dirty:{type:Boolean}},{host:{required:!0},hostModifiers:{}}),emits:Ba([`reset`],[`update:host`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`host`),a=WR(()=>i.value.intervalMs,e=>i.value.intervalMs=e,15e3),o=WR(()=>i.value.diskUsedPercent,e=>i.value.diskUsedPercent=e,90),s=WR(()=>i.value.memoryUsedPercent,e=>i.value.memoryUsedPercent=e,90),c=WR(()=>i.value.swapUsedPercent,e=>i.value.swapUsedPercent=e,50),l=WR(()=>i.value.loadPerCpu,e=>i.value.loadPerCpu=e,2),u=WR(()=>i.value.tempCelsius,e=>i.value.tempCelsius=e,85);return(e,t)=>(I(),L(F,null,[B(cz,{title:`Thresholds`,description:`A threshold of 0 disables that alert. Breaches notify once, and once more on recovery.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[9]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(Sz,{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.`,wide:``},null,8,[`modelValue`]),B(mz,{modelValue:j(a),"onUpdate:modelValue":t[2]||=e=>k(a)?a.value=e:null,label:`Interval (ms)`,min:5e3,hint:`How often the host is sampled and alerts are checked.`},null,8,[`modelValue`]),B(yz,{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`]),B(mz,{modelValue:j(o),"onUpdate:modelValue":t[4]||=e=>k(o)?o.value=e:null,label:`Disk used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),B(mz,{modelValue:j(s),"onUpdate:modelValue":t[5]||=e=>k(s)?s.value=e:null,label:`Memory used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),B(mz,{modelValue:j(c),"onUpdate:modelValue":t[6]||=e=>k(c)?c.value=e:null,label:`Swap used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),B(mz,{modelValue:j(l),"onUpdate:modelValue":t[7]||=e=>k(l)?l.value=e:null,label:`Load per CPU`,min:0,hint:`1-minute load average divided by the core count.`},null,8,[`modelValue`]),B(mz,{modelValue:j(u),"onUpdate:modelValue":t[8]||=e=>k(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?(I(),L(`div`,mU,[t[10]||=z(`span`,{class:`text-xs text-muted`},`Breaching now:`,-1),(I(!0),L(F,null,ya(n.alerts,e=>(I(),R(BF,{key:e,tone:`danger`,dot:``},{default:M(()=>[V(O(e),1)]),_:2},1024))),128))])):i.value.enabled?(I(),L(`p`,hU,` Nothing is breaching right now. `)):H(``,!0)],64))}}),_U={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},vU={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},yU={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},bU={class:`text-2xs leading-4 text-faint`},xU={key:0},SU={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},CU=[`disabled`],wU=N({__name:`InterfaceSection`,props:Ba({ui:{},labelDirty:{type:Boolean}},{label:{required:!0},labelModifiers:{}}),emits:Ba([`changed`,`resetLabel`],[`update:label`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`label`),a=A(null),o=A(!1),s=A(null),c=A(null),l=A(!1),u=U(()=>{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=U(()=>{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 Nj(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 Pj();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)=>(I(),R(cz,{title:`Interface`,description:`The panel is a static site: keep the stock one, or serve your own build from the state directory.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.labelDirty,onClick:h[1]||=e=>r(`resetLabel`)},{default:M(()=>[...h[4]||=[V(` Reset name `,-1)]]),_:1},8,[`disabled`]),e.ui?.custom?(I(),R($,{key:0,size:`xs`,variant:`ghost`,disabled:o.value,onClick:m},{default:M(()=>[V(O(l.value?`Confirm revert`:`Revert to stock`),1)]),_:1},8,[`disabled`])):H(``,!0),B($,{size:`xs`,variant:`primary`,disabled:o.value||a.value===null,onClick:p},{default:M(()=>[...h[5]||=[V(` Install UI `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[z(`div`,_U,[h[2]||=z(`span`,{class:`text-xs font-medium text-muted`},`Currently serving`,-1),z(`div`,vU,[z(`span`,yU,O(u.value),1),B(BV,{value:e.ui?.dir??``,label:`Copy the UI directory`},null,8,[`value`])]),z(`p`,bU,[d.value?(I(),L(`span`,xU,O(d.value)+` · `,1)):H(``,!0),z(`code`,null,O(e.ui?.dir??`—`),1)])]),B(yz,{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`]),z(`label`,SU,[h[3]||=z(`span`,{class:`text-xs font-medium text-muted`},`Upload a UI build (.zip with an index.html)`,-1),z(`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,CU)]),c.value?(I(),R(SH,{key:0,tone:`warn`,title:c.value},null,8,[`title`])):s.value?(I(),R(SH,{key:1,tone:`ok`,title:s.value},null,8,[`title`])):H(``,!0),h[6]||=z(`p`,{class:`text-2xs leading-4 text-faint sm:col-span-2`},[V(` See `),z(`code`,null,`docs/UI_CREATION.md`),V(` for the API contract. If a custom UI breaks the panel, `),z(`code`,null,`home-hosted ui-revert`),V(` puts the stock one back from the terminal. `)],-1)]),_:1}))}}),TU={class:`flex min-w-0 flex-col gap-1`},EU={class:`text-2xs leading-4 text-faint`},DU={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},OU={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},kU={class:`min-w-0 flex-1 truncate font-mono text-xs tabular-nums text-ink`},AU=N({__name:`ListenerSection`,props:Ba({view:{},dirty:{type:Boolean}},{control:{required:!0},controlModifiers:{}}),emits:Ba([`reset`],[`update:control`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`control`),a=WR(()=>i.value.port,e=>i.value.port=e,3999),o=[`local`,`lan`],s=U({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=U(()=>{if(s.value===`custom`&&Wk(i.value.host)===null)return`Enter an IPv4 address, for example 192.168.1.20.`}),l=U(()=>n.view?.url??`—`);return(e,t)=>(I(),R(cz,{title:`Listener`,description:`Where the panel answers. Moving this restarts the panel and sends this page to the new address.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[5]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(mz,{modelValue:j(a),"onUpdate:modelValue":t[1]||=e=>k(a)?a.value=e:null,label:`Control port`,min:1,max:65535,hint:`Default 3999.`},null,8,[`modelValue`]),z(`div`,TU,[t[6]||=z(`span`,{class:`text-xs font-medium text-muted`},`Bind`,-1),B(RI,{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`]),z(`p`,EU,O(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`?(I(),R(yz,{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`])):H(``,!0),B(Sz,{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`]),z(`div`,DU,[t[8]||=z(`span`,{class:`text-xs font-medium text-muted`},`Live address`,-1),z(`div`,OU,[z(`span`,kU,O(l.value),1),n.view?.restartRequired?(I(),R(BF,{key:0,tone:`warn`,dot:``},{default:M(()=>[...t[7]||=[V(` restart required `,-1)]]),_:1})):H(``,!0),B(BV,{value:l.value,label:`Copy the live address`},null,8,[`value`])]),t[9]||=z(`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}))}}),jU={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},MU={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`},PU={class:`text-2xs leading-4 text-faint`},FU=N({__name:`LogsSection`,props:Ba({logsDir:{},dirty:{type:Boolean}},{logs:{required:!0},logsModifiers:{}}),emits:Ba([`reset`],[`update:logs`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`logs`),a=WR(()=>i.value.maxBytes,e=>i.value.maxBytes=e,2e6),o=WR(()=>i.value.keep,e=>i.value.keep=e,3),s=U(()=>n.logsDir??`—`);return(e,t)=>{let c=pa(`RouterLink`);return I(),R(cz,{title:`Retention`,description:`The live view always comes from memory; these files survive a restart and feed the Logs page.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[4]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(Sz,{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`]),B(mz,{modelValue:j(a),"onUpdate:modelValue":t[2]||=e=>k(a)?a.value=e:null,label:`Rotate at (bytes)`,min:1e4,max:1e8,hint:`Per server, before rolling to .1, .2, …`},null,8,[`modelValue`]),B(mz,{modelValue:j(o),"onUpdate:modelValue":t[3]||=e=>k(o)?o.value=e:null,label:`Keep rotated files`,min:1,max:10},null,8,[`modelValue`]),z(`div`,jU,[t[8]||=z(`span`,{class:`text-xs font-medium text-muted`},`Logs directory`,-1),z(`div`,MU,[z(`span`,NU,O(s.value),1),B(BV,{value:s.value,label:`Copy the logs directory`},null,8,[`value`])]),z(`p`,PU,[t[6]||=V(` Browse and download these files on the `,-1),B(c,{to:`/logs`,class:`text-accent underline decoration-accent/40 underline-offset-2 hover:decoration-accent`},{default:M(()=>[...t[5]||=[V(` Logs `,-1)]]),_:1}),t[7]||=V(` page. `,-1)])])]),_:1})}}}),IU={class:`flex items-center gap-2 border-t border-line-soft pt-3 sm:col-span-2`},LU={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},RU={key:0,class:`sm:col-span-2`},zU={class:`flex flex-wrap gap-1.5`},BU={key:1,class:`sm:col-span-2`},VU={class:`text-2xs leading-4 text-faint`},HU={key:2,class:`space-y-2 sm:col-span-2`},UU=N({__name:`NotificationsSection`,props:Ba({status:{},dirty:{type:Boolean}},{telegram:{required:!0},telegramModifiers:{}}),emits:Ba([`reset`],[`update:telegram`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`telegram`),a=jM(),o=WR(()=>i.value.cooldownMs,e=>i.value.cooldownMs=e,12e4),s=A(``),c=A(null),l=A(null),u=A([]),d=A(!1),f=U(()=>n.status?.tokenSet===!0),p=U(()=>n.status?.lastResult??null),m=U(()=>n.status?.lastResultAt??null),h=U(()=>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 kj(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 Aj(),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 Mj(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 jj({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)=>(I(),R(cz,{title:`Telegram`,description:`Policy lives in the config; the bot token is a secret and never comes back from the server.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[10]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(Sz,{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.`,wide:``},null,8,[`modelValue`]),B(yz,{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`]),B(mz,{modelValue:j(o),"onUpdate:modelValue":t[3]||=e=>k(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`]),B(Sz,{modelValue:i.value.onCrash,"onUpdate:modelValue":t[4]||=e=>i.value.onCrash=e,label:`Retries exhausted`},null,8,[`modelValue`]),B(Sz,{modelValue:i.value.onUnhealthy,"onUpdate:modelValue":t[5]||=e=>i.value.onUnhealthy=e,label:`Port unhealthy`},null,8,[`modelValue`]),B(Sz,{modelValue:i.value.onForcedRestart,"onUpdate:modelValue":t[6]||=e=>i.value.onForcedRestart=e,label:`Forced restart`},null,8,[`modelValue`]),B(Sz,{modelValue:i.value.onRecovered,"onUpdate:modelValue":t[7]||=e=>i.value.onRecovered=e,label:`Recovered`},null,8,[`modelValue`]),B(Sz,{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`]),z(`div`,IU,[t[11]||=z(`span`,{class:`text-xs font-medium text-muted`},`Bot token`,-1),B(BF,{tone:f.value?`ok`:`warn`,dot:``},{default:M(()=>[V(O(f.value?`token set`:`no token`),1)]),_:1},8,[`tone`]),t[12]||=z(`span`,{class:`text-2xs text-faint`},`From @BotFather — a secret, never in servers.config.json.`,-1)]),B(yz,{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`]),z(`div`,LU,[B($,{variant:`primary`,disabled:d.value||s.value.trim().length===0,loading:d.value&&s.value.trim().length>0,onClick:g},{default:M(()=>[...t[13]||=[V(` Save token `,-1)]]),_:1},8,[`disabled`,`loading`]),B($,{variant:`secondary`,disabled:d.value,onClick:v},{default:M(()=>[...t[14]||=[V(` Detect chats `,-1)]]),_:1},8,[`disabled`]),B($,{variant:`secondary`,disabled:d.value,onClick:y},{default:M(()=>[...t[15]||=[V(` Send test `,-1)]]),_:1},8,[`disabled`]),f.value?(I(),R(yH,{key:0,label:`Remove token`,"confirm-label":`Confirm remove`,"confirm-variant":`danger`,disabled:d.value,onConfirm:_},null,8,[`disabled`])):H(``,!0)]),u.value.length>0?(I(),L(`div`,RU,[t[16]||=z(`p`,{class:`mb-1.5 text-xs text-muted`},` Chats the bot has seen: `,-1),z(`div`,zU,[(I(!0),L(F,null,ya(u.value,e=>(I(),R($,{key:String(e.id),size:`xs`,variant:`secondary`,onClick:t=>i.value.chatId=String(e.id)},{default:M(()=>[V(O(e.title)+` (`+O(e.id)+`) `,1)]),_:2},1032,[`onClick`]))),128))])])):H(``,!0),p.value?(I(),L(`div`,BU,[z(`p`,VU,` Last send: `+O(p.value)+O(m.value?` · ${j(DI)(m.value,j(a).now.value)}`:``),1)])):H(``,!0),l.value||c.value?(I(),L(`div`,HU,[l.value?(I(),R(SH,{key:0,tone:`danger`},{default:M(()=>[V(O(l.value),1)]),_:1})):H(``,!0),c.value?(I(),R(SH,{key:1,tone:`ok`},{default:M(()=>[V(O(c.value),1)]),_:1})):H(``,!0)])):H(``,!0)]),_:1}))}}),WU={class:`divide-y divide-line-soft sm:col-span-2`},GU={class:`min-w-0`},KU={class:`text-xs font-medium text-ink`},qU={class:`mt-0.5 text-2xs leading-4 text-faint`},JU={class:`flex min-w-0 flex-1 items-center justify-end gap-1.5`},YU={class:`min-w-0 truncate font-mono text-xs text-ink`},XU=N({__name:`PathsSection`,props:{configPath:{},dataRoot:{},logsDir:{},projectDir:{},panelUrl:{}},setup(e){let t=e,n=U(()=>[{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)=>(I(),R(cz,{title:`Where things live`,description:`Read-only. Copy a path straight into a shell or an editor.`},{default:M(()=>[z(`ul`,WU,[(I(!0),L(F,null,ya(n.value,e=>(I(),L(`li`,{key:e.key,class:`flex items-start justify-between gap-3 py-2 first:pt-0 last:pb-0`},[z(`div`,GU,[z(`p`,KU,O(e.label),1),z(`p`,qU,O(e.hint),1)]),z(`div`,JU,[z(`span`,YU,O(e.value),1),B(BV,{value:e.value,label:`Copy ${e.label.toLowerCase()}`},null,8,[`value`,`label`])])]))),128))])]),_:1}))}}),ZU={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},QU={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},$U={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},eW={key:0,class:`sm:col-span-2`},tW={key:1,class:`space-y-3 sm:col-span-2`},nW={class:`divide-y divide-line-soft text-xs`},rW={class:`flex items-start justify-between gap-4 py-1.5`},iW={class:`min-w-0 text-right font-mono text-xs text-ink`},aW={class:`flex items-start justify-between gap-4 py-1.5`},oW={class:`min-w-0 text-right font-mono text-xs text-ink`},sW={class:`flex items-start justify-between gap-4 py-1.5`},cW={class:`font-mono text-xs tabular-nums text-ink`},lW={class:`flex items-center justify-between gap-4 py-1.5`},uW={class:`flex items-start justify-between gap-4 py-1.5`},dW={class:`flex min-w-0 items-center gap-1.5`},fW={class:`min-w-0 truncate font-mono text-2xs text-ink`},pW={key:2,class:`sm:col-span-2`},mW={class:`flex min-w-0 flex-col gap-1`},hW={class:`flex min-w-0 flex-col gap-1`},gW={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},_W={key:3,class:`space-y-2 sm:col-span-2`},vW=N({__name:`TlsSection`,props:Ba({view:{},dirty:{type:Boolean}},{tlsEnabled:{type:Boolean,required:!0},tlsEnabledModifiers:{}}),emits:Ba([`reset`],[`update:tlsEnabled`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`tlsEnabled`),a=jM(),o=A(``),s=A(``),c=A(null),l=A(null),u=A(!1),d=U(()=>n.view?.tls??null),f=U(()=>n.view?`${n.view.protocol}://${n.view.bindHost}:${n.view.port}`:`—`),p=U(()=>o.value.trim().length>0&&s.value.trim().length>0&&!u.value),m=Q(SF,`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 Fj(o.value,s.value);o.value=``,s.value=``,c.value=`Certificate stored.`,await a.refresh();let t=await GR(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 Ij();c.value=`Certificate removed.`,await a.refresh();let t=await GR(e);t!==null&&(l.value=t)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}return(e,t)=>(I(),L(F,null,[B(cz,{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:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[6]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(Sz,{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`]),z(`div`,ZU,[t[7]||=z(`span`,{class:`text-xs font-medium text-muted`},`Live address`,-1),z(`div`,QU,[z(`span`,$U,O(f.value),1),B(BV,{value:f.value,label:`Copy the live address`},null,8,[`value`])])])]),_:1}),B(cz,{class:`mt-3`,title:`Certificate`,description:`PEM-encoded certificate and its private key. Both stay in the secrets file.`},{default:M(()=>[d.value?.error?(I(),L(`div`,eW,[B(SH,{tone:`danger`,title:`The stored certificate cannot be used`},{default:M(()=>[V(O(d.value.error),1)]),_:1})])):d.value?.certPresent?(I(),L(`div`,tW,[z(`dl`,nW,[z(`div`,rW,[t[8]||=z(`dt`,{class:`text-muted`},` Subject `,-1),z(`dd`,iW,O(d.value.subject??`—`),1)]),z(`div`,aW,[t[9]||=z(`dt`,{class:`text-muted`},` Issuer `,-1),z(`dd`,oW,O(d.value.issuer??`—`),1)]),z(`div`,sW,[t[10]||=z(`dt`,{class:`text-muted`},` Valid until `,-1),z(`dd`,cW,[V(O(d.value.validTo?d.value.validTo.slice(0,10):`—`)+` `,1),d.value.daysRemaining===null?H(``,!0):(I(),L(`span`,{key:0,class:D(j(Q)(`ml-1.5`,d.value.daysRemaining<14?`text-warn`:`text-faint`))},` (`+O(d.value.daysRemaining)+` days) `,3))])]),z(`div`,lW,[t[11]||=z(`dt`,{class:`text-muted`},` Private key `,-1),z(`dd`,null,[B(BF,{tone:d.value.keyMatches?`ok`:`danger`,dot:``},{default:M(()=>[V(O(d.value.keyMatches?`matches the certificate`:`does not match`),1)]),_:1},8,[`tone`])])]),z(`div`,uW,[t[12]||=z(`dt`,{class:`text-muted`},` Fingerprint `,-1),z(`dd`,dW,[z(`span`,fW,O(d.value.fingerprint??`—`),1),d.value.fingerprint?(I(),R(BV,{key:0,value:d.value.fingerprint,label:`Copy the fingerprint`},null,8,[`value`])):H(``,!0)])])])])):(I(),L(`div`,pW,[B(SH,{tone:`info`,title:`No certificate uploaded`},{default:M(()=>[...t[13]||=[V(` Upload a PEM certificate and key below, then save. HTTPS is not served until a certificate is present. `,-1)]]),_:1})])),z(`div`,mW,[z(`label`,{class:D(j(bF)),for:`tls-cert-file`},`Certificate file (.pem, .crt)`,2),z(`input`,{id:`tls-cert-file`,type:`file`,accept:`.pem,.crt,.cer,text/plain`,class:D(j(m)),onChange:t[2]||=e=>h(e,`cert`)},null,34)]),z(`div`,hW,[z(`label`,{class:D(j(bF)),for:`tls-key-file`},`Private key file (.pem, .key)`,2),z(`input`,{id:`tls-key-file`,type:`file`,accept:`.pem,.key,text/plain`,class:D(j(m)),onChange:t[3]||=e=>h(e,`key`)},null,34)]),B(Mz,{modelValue:o.value,"onUpdate:modelValue":t[4]||=e=>o.value=e,label:`Or paste the certificate`,rows:4,placeholder:`-----BEGIN CERTIFICATE-----`},null,8,[`modelValue`]),B(Mz,{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`]),z(`div`,gW,[B($,{variant:`primary`,disabled:!p.value,loading:u.value,onClick:g},{default:M(()=>[...t[14]||=[V(` Save certificate `,-1)]]),_:1},8,[`disabled`,`loading`]),d.value?.certPresent?(I(),R(yH,{key:0,label:`Remove certificate`,"confirm-label":`Confirm remove`,"confirm-variant":`danger`,disabled:u.value,onConfirm:_},null,8,[`disabled`])):H(``,!0)]),l.value||c.value?(I(),L(`div`,_W,[l.value?(I(),R(SH,{key:0,tone:`danger`},{default:M(()=>[V(O(l.value),1)]),_:1})):H(``,!0),c.value?(I(),R(SH,{key:1,tone:`ok`},{default:M(()=>[V(O(c.value),1)]),_:1})):H(``,!0)])):H(``,!0)]),_:1})],64))}}),yW={class:`min-h-full`},bW={class:`mx-auto w-full max-w-5xl px-4 pb-6 pt-5 sm:px-6`},xW={class:`lg:grid lg:grid-cols-[11rem_minmax(0,1fr)] lg:gap-8`},SW={"aria-label":`Settings sections`,class:`hidden lg:block`},CW={class:`sticky top-6 space-y-0.5 border-l border-line`},wW=[`aria-current`,`onClick`],TW={class:`space-y-6`},EW={id:`listener`,class:`scroll-mt-5`},DW={id:`authentication`,class:`scroll-mt-5`},OW={id:`defaults`,class:`scroll-mt-5`},kW={id:`logs`,class:`scroll-mt-5`},AW={id:`notifications`,class:`scroll-mt-5`},jW={id:`host`,class:`scroll-mt-5`},MW={id:`backups`,class:`scroll-mt-5`},NW={id:`tls`,class:`scroll-mt-5`},PW={id:`interface`,class:`scroll-mt-5`},FW={id:`paths`,class:`scroll-mt-5`},IW={class:`sticky bottom-0 z-30 border-t border-line bg-panel/95 backdrop-blur`},LW={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`},RW={class:`min-w-0 flex-1`},zW={class:`text-xs text-muted`},BW={class:`font-mono tabular-nums text-ink`},VW={key:0,class:`mt-0.5 text-xs text-danger`},HW={key:1,class:`mt-0.5 text-xs text-ok`},UW={class:`flex shrink-0 items-center gap-2`},WW={class:`max-h-[60dvh] overflow-auto px-4 py-3`},GW={key:0,class:`divide-y divide-line-soft`},KW={class:`font-mono text-xs text-ink`},qW={class:`ml-auto font-mono text-xs text-muted line-through`},JW={class:`font-mono text-xs text-accent`},YW={key:1,class:`text-xs text-muted`},XW={class:`flex items-center justify-end gap-2 border-t border-line px-4 py-3`},ZW=N({__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=Bg(),r=zg(),i=jM(),a=$j(),o=tn(ER()),s=A(`listener`),c=A(!1),l=A(null),u=A(null),d=A(null),f=A(null),p=U(()=>i.control.value),m=U(()=>i.defaults.value),h=U(()=>i.logsConfig.value),g=U(()=>i.notifications.value?.telegram??null),_=U(()=>i.host.value?.alerts??[]),v=U(()=>f.value?.host??null),y=U(()=>f.value?.backups??null),b=U(()=>f.value?.ui??null),x=U(()=>i.backups.value),S=U(()=>i.appState.value?.configPath??null),C=U(()=>{let e={},t=p.value,n=m.value,r=h.value,i=g.value;if(t!==null){let n=FR(t,o);Object.keys(n).length>0&&(e.control=n)}if(n!==null){let t=IR(n,o.defaults);Object.keys(t).length>0&&(e.defaults=t)}if(r!==null){let t=LR(r,o.logs);Object.keys(t).length>0&&(e.logs=t)}if(i!==null){let t=RR(i,o.telegram);Object.keys(t).length>0&&(e.notifications=t)}let a=v.value;if(a!==null){let t=NR(a,o.host);Object.keys(t).length>0&&(e.host=t)}let s=y.value;if(s!==null){let t=PR(s,o.backups);Object.keys(t).length>0&&(e.backups=t)}return e}),w=U(()=>bR(C.value)),T=U(()=>{let e=p.value,t=g.value,n=v.value,r=y.value;return{control:e===null?{}:{...OR(e),auth:DR(e.auth)},defaults:m.value??{},logs:h.value??{},notifications:t===null?{}:{telegram:kR(t)},host:n??{},backups:r===null?{}:{enabled:r.enabled,keep:r.keep,includePaths:r.includePaths}}}),ee=U(()=>yR(C.value,T.value)),te=A(!1),ne=U(()=>p.value!==null&&VR(p.value,o)),re=U(()=>p.value!==null&&HR(p.value,o)),ie=U(()=>p.value!==null&&UR(p.value,o)),ae=U(()=>m.value!==null&&Object.keys(IR(m.value,o.defaults)).length>0),oe=U(()=>h.value!==null&&Object.keys(LR(h.value,o.logs)).length>0),se=U(()=>g.value!==null&&Object.keys(RR(g.value,o.telegram)).length>0),ce=U(()=>v.value!==null&&Object.keys(NR(v.value,o.host)).length>0),le=U(()=>y.value!==null&&Object.keys(PR(y.value,o.backups)).length>0),E={};function ue(){let e=(e,t)=>{BR(o,E,e)||(t(),E[e]=zR(o,e))},t=p.value;t!==null&&e(`control`,()=>{Object.assign(o.control,OR(t)),Object.assign(o.auth,DR(t.auth))});let n=h.value;n!==null&&e(`logs`,()=>Object.assign(o.logs,n));let r=g.value;r!==null&&e(`telegram`,()=>Object.assign(o.telegram,kR(r)));let i=v.value;i!==null&&e(`host`,()=>Object.assign(o.host,jR(i)));let a=y.value;a!==null&&e(`backups`,()=>Object.assign(o.backups,MR(a)));let s=m.value;s!==null&&e(`defaults`,()=>{o.defaults.enabled=s.enabled,o.defaults.autostart=s.autostart,o.defaults.bind=s.bind,o.defaults.onPortConflict=s.onPortConflict,o.defaults.logBufferLines=s.logBufferLines,o.defaults.restart={...s.restart},o.defaults.health=TR(s.health),o.defaults.stop={...s.stop}})}function de(){for(let e of Object.keys(E))delete E[e]}function fe(e){E[e]=zR(o,e)}jr([p,m,h,g,f],()=>{ue()},{immediate:!0});async function pe(){d.value=null;try{f.value=await _j()}catch(e){d.value=e instanceof Error?e.message:String(e)}}na(()=>{pe()});async function me(){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 pe(),de(),ue();let n=await GR(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 he(){l.value=null,u.value=null,de(),ue()}function ge(){v.value!==null&&Object.assign(o.host,jR(v.value)),fe(`host`)}function _e(){y.value!==null&&Object.assign(o.backups,MR(y.value)),fe(`backups`)}function ve(){if(p.value!==null){let e=OR(p.value);o.control.label=e.label,o.control.port=e.port,o.control.host=e.host,o.control.openBrowser=e.openBrowser}fe(`control`)}function ye(){p.value!==null&&Object.assign(o.auth,DR(p.value.auth)),fe(`control`)}function be(){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=TR(e.health),o.defaults.stop={...e.stop},fe(`defaults`))}function xe(){h.value!==null&&Object.assign(o.logs,h.value),fe(`logs`)}function Se(){g.value!==null&&Object.assign(o.telegram,kR(g.value)),fe(`telegram`)}function Ce(){p.value!==null&&(o.control.tlsEnabled=p.value.tls.enabled),fe(`control`)}function we(e){rr(()=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})})}function Te(e){s.value=e,n.query.section!==e&&r.replace({query:{...n.query,section:e}}),we(e)}jr(()=>n.query.section,e=>{let n=typeof e==`string`?e:``;t.some(e=>e.id===n)&&(s.value=n,we(n))},{immediate:!0});let Ee=null;return na(()=>{Ee=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&&Ee.observe(t)}}),aa(()=>Ee?.disconnect()),(e,n)=>(I(),L(F,null,[z(`div`,yW,[z(`div`,bW,[n[24]||=z(`header`,{class:`mb-5`},[z(`h1`,{class:`text-xl font-semibold tracking-tight text-ink`},` Settings `),z(`p`,{class:`mt-1 text-xs text-muted`},` Listener, access, defaults, retention, alerts, backups and paths for this panel. `)],-1),j(i).configError.value?(I(),R(SH,{key:0,tone:`danger`,title:`The config file could not be read`,class:`mb-4`},{default:M(()=>[z(`p`,null,O(j(i).configError.value),1),n[13]||=z(`p`,{class:`mt-1`},` The panel keeps running the config it already had; fixing the file reloads it on its own. `,-1)]),_:1})):d.value?(I(),R(SH,{key:1,tone:`warn`,title:`Some file-only values could not be loaded`,class:`mb-4`},{default:M(()=>[V(O(d.value),1)]),_:1})):H(``,!0),z(`div`,xW,[z(`nav`,SW,[z(`ul`,CW,[(I(),L(F,null,ya(t,e=>z(`li`,{key:e.id},[z(`button`,{type:`button`,"aria-current":s.value===e.id?`true`:void 0,class:D(j(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=>Te(e.id)},O(e.title),11,wW)])),64))])]),z(`div`,TW,[z(`section`,EW,[n[14]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Listener `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Where the control panel listens and how it announces itself. `)],-1),B(AU,{control:o.control,"onUpdate:control":n[0]||=e=>o.control=e,view:p.value,dirty:ne.value,onReset:ve},null,8,[`control`,`view`,`dirty`])]),z(`section`,DW,[n[15]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Authentication `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Who may sign in, and how a session is trusted. `)],-1),B(TH,{auth:o.auth,"onUpdate:auth":n[1]||=e=>o.auth=e,view:p.value,dirty:ie.value,onReset:ye},null,8,[`auth`,`view`,`dirty`])]),z(`section`,OW,[n[16]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Server defaults `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Applied to every entry that does not set its own value. `)],-1),B(pU,{defaults:o.defaults,"onUpdate:defaults":n[2]||=e=>o.defaults=e,dirty:ae.value,onReset:be},null,8,[`defaults`,`dirty`])]),z(`section`,kW,[n[17]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Logs `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` How much output is kept on disk and for how long. `)],-1),B(FU,{logs:o.logs,"onUpdate:logs":n[3]||=e=>o.logs=e,"logs-dir":j(i).appState.value?.logsDir??null,dirty:oe.value,onReset:xe},null,8,[`logs`,`logs-dir`,`dirty`])]),z(`section`,AW,[n[18]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Notifications `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Crash and health alerts sent to a Telegram chat. `)],-1),B(UU,{telegram:o.telegram,"onUpdate:telegram":n[4]||=e=>o.telegram=e,status:g.value,dirty:se.value,onReset:Se},null,8,[`telegram`,`status`,`dirty`])]),z(`section`,jW,[n[19]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Host vitals `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Alert thresholds for this machine's own resources. `)],-1),B(gU,{host:o.host,"onUpdate:host":n[5]||=e=>o.host=e,config:v.value,alerts:_.value,dirty:ce.value,onReset:ge},null,8,[`host`,`config`,`alerts`,`dirty`])]),z(`section`,MW,[n[20]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Backups `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Archives of config, secrets and declared data paths. `)],-1),B(dU,{form:o.backups,"onUpdate:form":n[6]||=e=>o.backups=e,state:x.value,policy:y.value,"config-path":S.value,dirty:le.value,onReset:_e},null,8,[`form`,`state`,`policy`,`config-path`,`dirty`])]),z(`section`,NW,[n[21]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` TLS `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Serve the panel over HTTPS with your own certificate. `)],-1),B(vW,{"tls-enabled":o.control.tlsEnabled,"onUpdate:tlsEnabled":n[7]||=e=>o.control.tlsEnabled=e,view:p.value,dirty:re.value,onReset:Ce},null,8,[`tls-enabled`,`view`,`dirty`])]),z(`section`,PW,[n[22]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Interface `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Serve your own panel UI instead of the stock one. `)],-1),B(wU,{label:o.control.label,"onUpdate:label":n[8]||=e=>o.control.label=e,ui:b.value,"label-dirty":ne.value,onChanged:pe,onResetLabel:ve},null,8,[`label`,`ui`,`label-dirty`])]),z(`section`,FW,[n[23]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Paths `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Where home-hosted keeps its files. `)],-1),B(XU,{"config-path":S.value,"data-root":j(i).appState.value?.dataRoot??null,"logs-dir":j(i).appState.value?.logsDir??null,"project-dir":j(i).appState.value?.projectDir??null,"panel-url":p.value?.url??null},null,8,[`config-path`,`data-root`,`logs-dir`,`project-dir`,`panel-url`])])])])]),z(`div`,IW,[z(`div`,LW,[z(`div`,RW,[z(`p`,zW,[w.value>0?(I(),L(`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=>te.value=!0},[z(`span`,BW,O(w.value),1),V(` field`+O(w.value===1?``:`s`)+` changed `,1)])):(I(),L(F,{key:1},[V(` No unsaved changes `)],64))]),l.value?(I(),L(`p`,VW,O(l.value),1)):u.value?(I(),L(`p`,HW,O(u.value),1)):H(``,!0)]),z(`div`,UW,[B($,{variant:`ghost`,disabled:w.value===0||c.value,onClick:he},{default:M(()=>[...n[25]||=[V(` Discard changes `,-1)]]),_:1},8,[`disabled`]),B($,{variant:`primary`,disabled:w.value===0,loading:c.value,onClick:me},{default:M(()=>[...n[26]||=[V(` Save settings `,-1)]]),_:1},8,[`disabled`,`loading`])])])])]),B(dL,{open:te.value,"onUpdate:open":n[12]||=e=>te.value=e,title:`Unsaved changes`,description:`What Save would write to servers.config.json.`,width:`w-[min(92vw,42rem)]`},{default:M(()=>[z(`div`,WW,[ee.value.length>0?(I(),L(`ul`,GW,[(I(!0),L(F,null,ya(ee.value,e=>(I(),L(`li`,{key:e.path,class:`flex flex-wrap items-baseline gap-x-3 gap-y-1 py-2 first:pt-0`},[z(`code`,KW,O(e.path),1),z(`span`,qW,O(j(jI)(e.from)),1),n[27]||=z(`span`,{class:`text-2xs text-faint`},`→`,-1),z(`span`,JW,O(j(jI)(e.to)),1)]))),128))])):(I(),L(`p`,YW,` Nothing to save. `))]),z(`footer`,XW,[B($,{size:`sm`,variant:`ghost`,onClick:n[10]||=e=>te.value=!1},{default:M(()=>[...n[28]||=[V(` Close `,-1)]]),_:1}),B($,{size:`sm`,variant:`primary`,disabled:ee.value.length===0||c.value,loading:c.value,onClick:n[11]||=e=>{me(),te.value=!1}},{default:M(()=>[V(` Save `+O(ee.value.length)+` change`+O(ee.value.length===1?``:`s`),1)]),_:1},8,[`disabled`,`loading`])])]),_:1},8,[`open`])],64))}}),QW=Cv({history:G_(),routes:[{path:`/`,name:`overview`,component:wV,meta:{title:`Overview`}},{path:`/servers`,name:`servers`,component:vH,meta:{title:`Servers`}},{path:`/servers/:id`,name:`server-detail`,component:fH,meta:{title:`Server`}},{path:`/logs`,name:`logs`,component:BL,meta:{title:`Logs`}},{path:`/settings`,name:`settings`,component:ZW,meta:{title:`Settings`}},{path:`/login`,name:`login`,component:lI,meta:{title:`Sign in`}},{path:`/:pathMatch(.*)*`,redirect:`/`}]});QW.beforeEach(async e=>{let{session:t,refresh:n}=Jj();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}),bu(RF).use(QW).mount(`#app`);
44
+ `),backupIgnoreGenerated:e.backupIgnoreGenerated!==!1,dependsOn:e.dependsOn.join(`, `),envFile:e.envFile,maxRssMb:c(e.resources.maxRssBytes),port:e.port,bind:e.bind,onPortConflict:e.onPortConflict,logBufferLines:e.logBufferLines,enabled:e.enabled,autostart:e.autostart,persistent:e.persistent===!0,bootstrapEnabled:e.bootstrap!==null&&e.bootstrap!==void 0,bootstrapCommand:e.bootstrap?.command??``,bootstrapArgs:(e.bootstrap?.args??[]).join(`
45
+ `),bootstrapEnv:qR(e.bootstrap?.env??{}),bootstrapTimeoutMs:e.bootstrap?.timeoutMs??12e4,bootstrapRunOnce:e.bootstrap?.runOnce??!0}}let u=tn(l(n.config)),d=A({...n.config.restart}),f=A({...n.config.health}),p=A({...n.config.stop}),m=U(()=>{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 h(){let e=Number.isFinite(u.maxRssMb)?u.maxRssMb:0,t=Number.isFinite(u.logBufferLines)&&u.logBufferLines>=50?u.logBufferLines:50,n=Number.isFinite(u.bootstrapTimeoutMs)?u.bootstrapTimeoutMs:0;return{label:u.label.trim(),command:u.command.trim(),cwd:u.cwd.trim()===``?`.`:u.cwd.trim(),args:KR(u.args),env:JR(u.env),dataEnvs:JR(u.dataEnvs),backupPaths:KR(u.backupPaths),backupIgnoreGenerated:u.backupIgnoreGenerated,dependsOn:YR(u.dependsOn),envFile:u.envFile.trim(),resources:{maxRssBytes:e>0?Math.round(e*1024*1024):0},port:u.port===null||Number.isNaN(u.port)?null:u.port,bind:u.bind,onPortConflict:u.onPortConflict,logBufferLines:t,enabled:u.enabled,autostart:u.autostart,persistent:u.persistent,restart:{...d.value},health:{...f.value},stop:{...p.value},bootstrap:u.bootstrapEnabled?{command:u.bootstrapCommand.trim(),args:KR(u.bootstrapArgs),env:JR(u.bootstrapEnv),timeoutMs:n,runOnce:u.bootstrapRunOnce}:null}}function g(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 _(e){for(let t of i)g(e,t)===null&&delete e[t];return _R(n.config,e)}function v(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}let y=U(()=>_(h())),b=U(()=>bR(y.value)),x=U(()=>b.value>0),S=U(()=>yR(y.value,n.config)),C=A(!1),w={...n.config};function T(e){Object.assign(u,l(e)),d.value={...e.restart},f.value={...e.health},p.value={...e.stop},w={...e},s.value=null}jr(()=>n.config,e=>{v(e,w)||T(e)});async function ee(){s.value=null,o.value=!0;try{let e=h(),t=xA(e);if(t instanceof Y.errors){s.value=t.summary;return}let i=_(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}r(`saved`)}finally{o.value=!1}}return(e,t)=>(I(),L(F,null,[z(`form`,{class:`border-t border-line bg-page/40 px-4 py-4`,onSubmit:uu(ee,[`prevent`])},[z(`header`,TV,[t[32]||=z(`div`,{class:`min-w-0`},[z(`h2`,{class:`text-sm font-semibold text-ink`},` Edit configuration `),z(`p`,{class:`mt-0.5 text-2xs leading-4 text-muted`},[V(` Writes overrides to `),z(`span`,{class:`font-mono`},`servers.config.json`),V(`; anything left alone keeps inheriting the defaults. `)])],-1),z(`div`,EV,[b.value>0?(I(),L(`button`,{key:0,type:`button`,class:`rounded-control px-1 py-0.5 text-2xs text-warn underline decoration-warn/40 underline-offset-2 transition-colors duration-150 hover:text-ink`,onClick:t[0]||=e=>C.value=!0},[z(`span`,DV,O(b.value),1),V(` unsaved `+O(b.value===1?`change`:`changes`),1)])):(I(),L(`span`,OV,`in sync`))])]),z(`div`,kV,[B(cz,{title:`Process`,description:`What gets spawned, where, and with which environment.`,columns:2},{default:M(()=>[B(yz,{modelValue:u.label,"onUpdate:modelValue":t[1]||=e=>u.label=e,label:`Label`,placeholder:`falls back to the id`},null,8,[`modelValue`]),B(yz,{modelValue:u.command,"onUpdate:modelValue":t[2]||=e=>u.command=e,label:`Command`,placeholder:`node`,required:``,class:`font-mono text-xs`},null,8,[`modelValue`]),B(yz,{modelValue:u.cwd,"onUpdate:modelValue":t[3]||=e=>u.cwd=e,label:`Working directory`,placeholder:`.`,hint:`Relative paths resolve under projectDir.`,class:`font-mono text-xs`},null,8,[`modelValue`]),B(yz,{modelValue:u.envFile,"onUpdate:modelValue":t[4]||=e=>u.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`]),B(Mz,{modelValue:u.args,"onUpdate:modelValue":t[5]||=e=>u.args=e,label:`Arguments`,rows:3,hint:`One per line; {port} {host} {home} {projectDir} {dataRoot} {id} {label} {cwd} {bind} {lanIp} are substituted.`,placeholder:`-p
46
+ {port}`},null,8,[`modelValue`]),B(Mz,{modelValue:u.env,"onUpdate:modelValue":t[6]||=e=>u.env=e,label:`Environment`,rows:3,hint:`KEY=value per line, exported to the process.`,placeholder:`NODE_ENV=production`},null,8,[`modelValue`]),B(Mz,{modelValue:u.dataEnvs,"onUpdate:modelValue":t[7]||=e=>u.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`]),B(Mz,{modelValue:u.backupPaths,"onUpdate:modelValue":t[8]||=e=>u.backupPaths=e,label:`Extra backup paths`,rows:2,hint:`One per line, placeholders allowed; data envs are captured already.`,placeholder:`{home}/.app/uploads`},null,8,[`modelValue`]),B(Sz,{modelValue:u.backupIgnoreGenerated,"onUpdate:modelValue":t[9]||=e=>u.backupIgnoreGenerated=e,label:`Ignore known generated files when backing this up`,hint:`Skips node_modules, dist, .next and the other caches nothing restores from.`,wide:``},null,8,[`modelValue`]),B(yz,{modelValue:u.dependsOn,"onUpdate:modelValue":t[10]||=e=>u.dependsOn=e,label:`Depends on`,placeholder:`postgres, redis`,hint:`Comma separated; started first, stopped last.`,class:`font-mono text-xs`},null,8,[`modelValue`]),B(mz,{modelValue:u.maxRssMb,"onUpdate:modelValue":t[11]||=e=>u.maxRssMb=e,label:`Max RSS (MB)`,min:0,hint:`Restart above this; blank or 0 disables it.`},null,8,[`modelValue`])]),_:1}),B(cz,{title:`Port & binding`,description:`How the port is preflighted and where the process is reachable.`,columns:2},{default:M(()=>[B(mz,{modelValue:u.port,"onUpdate:modelValue":t[12]||=e=>u.port=e,label:`Port`,nullable:``,min:1,max:65535,hint:`Blank means no port: no probe, no preflight.`},null,8,[`modelValue`]),B(_L,{modelValue:u.bind,"onUpdate:modelValue":t[13]||=e=>u.bind=e,label:`Bind address`,options:m.value,hint:`A custom IPv4 the config already sets stays selectable.`},null,8,[`modelValue`,`options`]),B(_L,{modelValue:u.onPortConflict,"onUpdate:modelValue":t[14]||=e=>u.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`},{value:`kill`,label:`kill — stop whatever holds the port`}]},null,8,[`modelValue`]),B(mz,{modelValue:u.logBufferLines,"onUpdate:modelValue":t[15]||=e=>u.logBufferLines=e,label:`Log buffer lines`,min:50,max:1e5,step:50},null,8,[`modelValue`])]),_:1}),B(cz,{title:`Lifecycle`,description:`Whether the supervisor owns this entry at all.`,columns:3},{default:M(()=>[B(Sz,{modelValue:u.enabled,"onUpdate:modelValue":t[16]||=e=>u.enabled=e,label:`Enabled`,hint:`Shows up and can be started at all.`},null,8,[`modelValue`]),B(Sz,{modelValue:u.autostart,"onUpdate:modelValue":t[17]||=e=>u.autostart=e,label:`Autostart with up`,hint:`Started when the control plane comes up.`},null,8,[`modelValue`]),B(Sz,{modelValue:u.persistent,"onUpdate:modelValue":t[18]||=e=>u.persistent=e,label:`Persistent`,hint:"Keeps running when the panel stops; `down` reports it instead of stopping it."},null,8,[`modelValue`])]),_:1}),B(Cz,{restart:d.value,"onUpdate:restart":t[19]||=e=>d.value=e,health:f.value,"onUpdate:health":t[20]||=e=>f.value=e,stop:p.value,"onUpdate:stop":t[21]||=e=>p.value=e},null,8,[`restart`,`health`,`stop`]),B(cz,{title:`Bootstrap`,description:`A one-off command run before the first start — installs, migrations, downloads.`,columns:2},{default:M(()=>[B(Sz,{modelValue:u.bootstrapEnabled,"onUpdate:modelValue":t[22]||=e=>u.bootstrapEnabled=e,label:`Run a bootstrap`,hint:`Off means the entry has none and the key is sent as null.`,wide:``},null,8,[`modelValue`]),u.bootstrapEnabled?(I(),L(F,{key:0},[B(yz,{modelValue:u.bootstrapCommand,"onUpdate:modelValue":t[23]||=e=>u.bootstrapCommand=e,label:`Command`,placeholder:`./scripts/install.sh`,class:`font-mono text-xs`},null,8,[`modelValue`]),B(mz,{modelValue:u.bootstrapTimeoutMs,"onUpdate:modelValue":t[24]||=e=>u.bootstrapTimeoutMs=e,label:`Timeout (ms)`,min:1e3,step:1e3},null,8,[`modelValue`]),B(Sz,{modelValue:u.bootstrapRunOnce,"onUpdate:modelValue":t[25]||=e=>u.bootstrapRunOnce=e,label:`Only once per session`,hint:`Off means every start re-runs it.`},null,8,[`modelValue`])],64)):H(``,!0),u.bootstrapEnabled?(I(),R(Mz,{key:1,modelValue:u.bootstrapArgs,"onUpdate:modelValue":t[26]||=e=>u.bootstrapArgs=e,label:`Bootstrap arguments`,rows:2,hint:`One per line; same placeholders as the main arguments.`},null,8,[`modelValue`])):H(``,!0),u.bootstrapEnabled?(I(),R(Mz,{key:2,modelValue:u.bootstrapEnv,"onUpdate:modelValue":t[27]||=e=>u.bootstrapEnv=e,label:`Bootstrap environment`,rows:2,hint:`KEY=value per line, exported to the bootstrap process only.`},null,8,[`modelValue`])):H(``,!0)]),_:1})]),s.value?(I(),L(`p`,AV,O(s.value),1)):H(``,!0),z(`div`,jV,[B($,{variant:`ghost`,onClick:t[28]||=e=>r(`cancel`)},{default:M(()=>[...t[33]||=[V(` Cancel `,-1)]]),_:1}),B($,{type:`submit`,variant:`primary`,disabled:o.value||!x.value,loading:o.value},{default:M(()=>[...t[34]||=[V(` Save to servers.config.json `,-1)]]),_:1},8,[`disabled`,`loading`])])],32),B(dL,{open:C.value,"onUpdate:open":t[31]||=e=>C.value=e,title:`Unsaved changes`,description:`What Save would write to servers.config.json.`,width:`w-[min(92vw,42rem)]`},{footer:M(()=>[B($,{size:`sm`,variant:`ghost`,onClick:t[29]||=e=>C.value=!1},{default:M(()=>[...t[36]||=[V(` Close `,-1)]]),_:1}),B($,{size:`sm`,variant:`primary`,disabled:S.value.length===0||o.value,loading:o.value,onClick:t[30]||=e=>{ee(),C.value=!1}},{default:M(()=>[V(` Save `+O(S.value.length)+` change`+O(S.value.length===1?``:`s`),1)]),_:1},8,[`disabled`,`loading`])]),default:M(()=>[z(`div`,MV,[S.value.length>0?(I(),L(`ul`,NV,[(I(!0),L(F,null,ya(S.value,e=>(I(),L(`li`,{key:e.path,class:`flex flex-wrap items-baseline gap-x-3 gap-y-1 py-2 first:pt-0`},[z(`code`,PV,O(e.path),1),z(`span`,FV,O(j(jI)(e.from)),1),t[35]||=z(`span`,{class:`text-2xs text-faint`},`→`,-1),z(`span`,IV,O(j(jI)(e.to)),1)]))),128))])):(I(),L(`p`,LV,` Nothing to save. `))])]),_:1},8,[`open`])],64))}}),zV=[`aria-label`],BV=N({__name:`CopyButton`,props:{value:{},label:{default:`Copy`},class:{default:void 0}},setup(e){let t=e,n=A(!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 Be(()=>{r&&clearTimeout(r)}),(e,r)=>(I(),L(`button`,{type:`button`,class:D(j(Q)(`grid size-6 shrink-0 place-items-center rounded-control text-faint transition-colors duration-150 hover:bg-hover hover:text-ink`,j(yF),t.class)),"aria-label":n.value?`Copied`:t.label,onClick:i},[n.value?(I(),R(j(Fv),{key:0,class:`size-3.5 text-ok`})):(I(),R(j(Kv),{key:1,class:`size-3.5`}))],10,zV))}}),VV={key:0,class:`mx-auto max-w-3xl p-4 sm:p-5`},HV={key:1,class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},UV={class:`font-mono text-xs text-faint`},WV=[`href`],GV={class:`px-2 py-1.5`},KV={class:`flex flex-col gap-0.5`},qV=[`onClick`],JV={class:`space-y-2`},YV={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`},XV={class:`min-w-0 flex-1 text-2xs leading-4 text-danger`},ZV={key:1,class:`rounded-control border border-warn/25 bg-warn-soft px-3 py-2 text-2xs leading-4 text-warn`},QV={class:`grid grid-cols-2 gap-x-4 gap-y-3 p-4 sm:grid-cols-4 lg:grid-cols-6`},$V={class:`truncate text-2xs text-faint`},eH={class:`truncate font-mono text-xs tabular-nums text-ink capitalize`},tH={class:`grid gap-4 sm:grid-cols-3`},nH={class:`flex items-center justify-between gap-3`},rH=[`title`],iH={key:1,class:`space-y-4`},aH={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`},oH={key:1,class:`grid grid-cols-1 gap-x-6 gap-y-2 sm:grid-cols-2`},sH={class:`text-2xs text-faint`},cH=[`title`],lH={key:2,class:`grid gap-4 lg:grid-cols-3`},uH={key:0,class:`flex flex-wrap gap-1.5`},dH={key:1,class:`text-xs text-muted`},fH=N({__name:`ServerDetailView`,setup(e){let t=Bg(),{serverById:n,now:r,seriesOf:i,start:a,stop:o,restart:s,setEnabled:c,setAutostart:l,setBind:u,clearLogs:d,freePort:f,remove:p}=jM(),m=U(()=>String(t.params.id??``)),h=U(()=>n(m.value)),g=U(()=>h.value?.config),_=U(()=>{let e=g.value;return e?.label&&e.label.length>0?e.label:m.value}),v=A(`output`),y=A(!1),b=A(!1),x=A(!1),S=A(!1),C=AM(()=>h.value?m.value:null),w=C.version,T=U(()=>(w.value,C.lines())),ee=U(()=>i(m.value)),te=U(()=>ee.value.cpu),ne=U(()=>ee.value.rss),re=U(()=>ee.value.probe),ie=U(()=>{let e=h.value;return!e||e.startedAt===null||e.status!==`running`?`—`:wI(r.value-e.startedAt)}),ae=U(()=>h.value?.status===`running`),oe=U(()=>{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:ie.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:kI(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:EI(e.history.uptimeRatio)},{key:`crashes`,label:`24h crashes`,value:String(e.history.crashes)},{key:`lastcrash`,label:`Last crash`,value:DI(e.history.lastCrashAt,r.value)}];return e.nextRetryAt!==null&&t.push({key:`retry`,label:`Next attempt`,value:TI(e.nextRetryAt,r.value)}),e.unhealthySince!==null&&t.push({key:`unhealthy`,label:`Unhealthy for`,value:wI(r.value-e.unhealthySince)}),t}),se=U(()=>JSON.stringify(g.value??{},null,2)),ce=U(()=>g.value?`${g.value.command} ${g.value.args.join(` `)}`.trim():``),le=U(()=>{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 E(e){S.value=!0;try{await{start:a,stop:o,restart:s}[e](m.value)}finally{S.value=!1}}async function ue(){x.value=!1,await p(m.value)}async function de(){let e=h.value;if(e){S.value=!0;try{await f(e.id)}finally{S.value=!1}}}let fe=U(()=>Sj(m.value,`${m.value}.log`)),pe=[{value:`output`,label:`Live output`},{value:`config`,label:`Configuration`},{value:`history`,label:`History`}];return(e,t)=>{let n=pa(`RouterLink`);return h.value?(I(),L(`div`,HV,[B(BB,{title:_.value,"back-to":`/servers`,"back-label":`All servers`},{badges:M(()=>[B(oB,{status:h.value.status,health:h.value.health},null,8,[`status`,`health`]),h.value.adopted?(I(),R(TF,{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:M(()=>[...t[16]||=[z(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`detached`,-1)]]),_:1})):H(``,!0),h.value.config.persistent?(I(),R(TF,{key:1,label:"This entry runs under its own nanny, so it keeps running when the panel stops, restarts or is killed. `home-hosted down` reports it instead of stopping it; only Stop does."},{default:M(()=>[...t[17]||=[z(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`persistent`,-1)]]),_:1})):H(``,!0),z(`span`,UV,O(h.value.id),1),h.value.url?(I(),L(`a`,{key:2,href:h.value.url,target:`_blank`,rel:`noreferrer`,class:`inline-flex items-center gap-1 font-mono text-xs text-accent hover:underline`},[V(O(h.value.url)+` `,1),B(j(Xv),{class:`size-3`})],8,WV)):H(``,!0)]),actions:M(()=>[B($,{variant:`primary`,disabled:S.value||!g.value?.enabled||[`running`,`starting`].includes(h.value.status),onClick:t[0]||=e=>E(`start`)},{default:M(()=>[B(j(py),{class:`size-3.5`}),t[18]||=V(`Start `,-1)]),_:1},8,[`disabled`]),B($,{disabled:S.value||h.value.status===`stopped`,onClick:t[1]||=e=>E(`stop`)},{default:M(()=>[B(j(Ey),{class:`size-3.5`}),t[19]||=V(`Stop `,-1)]),_:1},8,[`disabled`]),B($,{disabled:S.value||!g.value?.enabled,onClick:t[2]||=e=>E(`restart`)},{default:M(()=>[B(j(vy),{class:`size-3.5`}),t[20]||=V(`Restart `,-1)]),_:1},8,[`disabled`]),B(TF,{label:`Edit every field of this entry`},{default:M(()=>[B($,{variant:y.value?`secondary`:`ghost`,onClick:t[3]||=e=>{y.value=!y.value,v.value=`config`}},{default:M(()=>[B(j(fy),{class:`size-3.5`}),V(O(y.value?`Close editor`:`Edit`),1)]),_:1},8,[`variant`])]),_:1}),B(j(tg),null,{default:M(()=>[B(j(og),{"as-child":``},{default:M(()=>[B($,{variant:`ghost`,size:`icon-sm`,"aria-label":`More actions for ${_.value}`},{default:M(()=>[B(j(Yv),{class:`size-4`})]),_:1},8,[`aria-label`])]),_:1}),B(j(ig),null,{default:M(()=>[B(j(ng),{"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:M(()=>[B(j(rg),{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=>j(c)(h.value.id,!h.value.config.enabled)},{default:M(()=>[V(O(g.value?.enabled?`Disable server`:`Enable server`),1)]),_:1}),B(j(rg),{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=>j(l)(h.value.id,!h.value.config.autostart)},{default:M(()=>[V(O(g.value?.autostart?`Remove from autostart`:`Autostart with the panel`),1)]),_:1}),B(j(ag),{class:`my-1 h-px bg-line`}),z(`div`,GV,[t[21]||=z(`p`,{class:`mb-1 text-2xs text-faint`},` Bind `,-1),z(`div`,KV,[(I(!0),L(F,null,ya(le.value,e=>(I(),L(`button`,{key:e.value,type:`button`,class:D([`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=>j(u)(h.value.id,e.value)},O(e.label),11,qV))),128))])]),B(j(ag),{class:`my-1 h-px bg-line`}),B(j(rg),{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:M(()=>[B(j(jy),{class:`size-3.5`}),t[22]||=V(` Remove server `,-1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,[`title`]),z(`div`,JV,[h.value.lastError?(I(),L(`div`,YV,[z(`p`,XV,O(h.value.lastError),1),h.value.status===`conflict`&&h.value.config.port!==null?(I(),R(zz,{key:0,port:h.value.config.port,busy:S.value,onConfirm:de},null,8,[`port`,`busy`])):H(``,!0)])):H(``,!0),h.value.health===`unhealthy`?(I(),L(`p`,ZV,[t[23]||=V(` The health probe has not passed `,-1),h.value.unhealthySince===null?H(``,!0):(I(),L(F,{key:0},[V(` for `+O(j(wI)(j(r)-h.value.unhealthySince)),1)],64)),t[24]||=V(`. `,-1)])):H(``,!0)]),B(WB,{class:`p-0`},{default:M(()=>[z(`dl`,QV,[(I(!0),L(F,null,ya(oe.value,e=>(I(),L(`div`,{key:e.key,class:`min-w-0`},[z(`dt`,$V,O(e.label),1),z(`dd`,eH,O(e.value),1)]))),128))])]),_:1}),B(WB,null,{header:M(()=>[...t[25]||=[z(`h2`,{class:`text-sm font-semibold text-ink`},` Telemetry `,-1),z(`p`,{class:`text-2xs text-muted`},` Sampled every 5 s while this page is open. `,-1)]]),default:M(()=>[z(`div`,tH,[B(nB,{label:`CPU`,values:te.value,format:j(AI),max:100,"color-class":`text-cpu`,height:40},null,8,[`values`,`format`]),B(nB,{label:`Memory (RSS)`,values:ne.value,format:j(kI),"color-class":`text-mem`,height:40},null,8,[`values`,`format`]),B(nB,{label:`Health probe`,values:re.value,format:e=>e===null?`—`:`${e} ms`,"color-class":`text-probe`,height:40},null,8,[`values`,`format`])])]),_:1}),z(`div`,nH,[B(RI,{modelValue:v.value,"onUpdate:modelValue":t[7]||=e=>v.value=e,options:pe,size:`md`},null,8,[`modelValue`]),z(`p`,{class:`hidden font-mono text-2xs text-faint sm:block`,title:ce.value},O(ce.value),9,rH)]),v.value===`output`?(I(),R(eL,{key:0,lines:T.value,version:j(w),live:``,clearable:``,"download-url":h.value.config.logBufferLines>0?fe.value:void 0,"download-name":`${h.value.id}.log`,"empty-hint":ae.value?`Waiting for the first line…`:`This server has not written anything yet.`,"min-height":`22rem`,onClear:t[8]||=e=>j(d)(h.value.id)},null,8,[`lines`,`version`,`download-url`,`download-name`,`empty-hint`])):v.value===`config`?(I(),L(`div`,iH,[y.value?(I(),R(RV,{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`])):(I(),R(WB,{key:1},{header:M(()=>[...t[26]||=[z(`h2`,{class:`text-sm font-semibold text-ink`},` Effective configuration `,-1),z(`p`,{class:`text-2xs text-muted`},` Defaults from Settings are already merged into these values. `,-1)]]),actions:M(()=>[B($,{size:`xs`,variant:`ghost`,onClick:t[11]||=e=>b.value=!b.value},{default:M(()=>[B(j(Wv),{class:`size-3`}),V(O(b.value?`Fields`:`Raw JSON`),1)]),_:1}),B(BV,{value:se.value,label:`Copy the JSON config`},null,8,[`value`]),B($,{size:`xs`,variant:`primary`,onClick:t[12]||=e=>y.value=!0},{default:M(()=>[B(j(fy),{class:`size-3`}),t[27]||=V(`Edit `,-1)]),_:1})]),default:M(()=>[b.value?(I(),L(`pre`,aH,O(se.value),1)):(I(),L(`dl`,oH,[(I(!0),L(F,null,ya([{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?j(kI)(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=>(I(),L(`div`,{key:e.label,class:`min-w-0 border-b border-line-soft pb-1.5 last:border-0`},[z(`dt`,sH,O(e.label),1),z(`dd`,{class:`truncate font-mono text-xs text-ink`,title:String(e.value)},O(e.value),9,cH)]))),128))]))]),_:1}))])):(I(),L(`div`,lH,[B(WB,{class:`lg:col-span-2`},{header:M(()=>[...t[28]||=[z(`h2`,{class:`text-sm font-semibold text-ink`},` Event history `,-1),z(`p`,{class:`text-2xs text-muted`},` Kept by the panel for 24 hours. `,-1)]]),default:M(()=>[B(fR,{servers:[h.value],now:j(r),limit:30},null,8,[`servers`,`now`])]),_:1}),B(WB,null,{header:M(()=>[...t[29]||=[z(`h2`,{class:`text-sm font-semibold text-ink`},` Dependencies `,-1)]]),default:M(()=>[g.value&&g.value.dependsOn.length>0?(I(),L(`div`,uH,[(I(!0),L(F,null,ya(g.value.dependsOn,e=>(I(),R(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:M(()=>[V(O(e),1)]),_:2},1032,[`to`]))),128))])):(I(),L(`p`,dH,[...t[30]||=[V(` Starts on its own. Add ids under `,-1),z(`code`,null,`dependsOn`,-1),V(` to order it after other servers. `,-1)]]))]),_:1})])),B(dL,{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:M(()=>[B($,{variant:`ghost`,onClick:t[13]||=e=>x.value=!1},{default:M(()=>[...t[31]||=[V(` Keep it `,-1)]]),_:1}),B($,{variant:`danger`,onClick:ue},{default:M(()=>[B(j(jy),{class:`size-3.5`}),t[32]||=V(`Remove `,-1)]),_:1})]),default:M(()=>[t[33]||=z(`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`])])):(I(),L(`div`,VV,[B(oL,{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:M(()=>[B(n,{to:`/servers`},{default:M(()=>[B($,{variant:`primary`},{default:M(()=>[...t[15]||=[V(` Back to servers `,-1)]]),_:1})]),_:1})]),_:1},8,[`description`])]))}}}),pH={class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},mH={class:`flex flex-wrap items-center gap-2`},hH={class:`relative ml-auto w-full sm:w-64`},gH={key:0,class:`grid gap-4 lg:grid-cols-2`},_H={key:3,class:`grid gap-4 lg:grid-cols-2`},vH=N({__name:`ServersView`,setup(e){let{servers:t,appState:n,now:r,seriesOf:i,startAll:a,stopAll:o}=jM(),s=A(!1),c=A(``),l=A(`all`),u=[{value:`all`,label:`All`},{value:`running`,label:`Running`},{value:`stopped`,label:`Stopped`},{value:`attention`,label:`Attention`},{value:`disabled`,label:`Disabled`}],d=U(()=>n.value===null),f=U(()=>{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=U(()=>({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)=>(I(),L(`div`,pH,[B(BB,{title:`Servers`,description:`Every entry in servers.config.json, with live resources, health and history.`},{actions:M(()=>[B($,{variant:`ghost`,onClick:n[0]||=e=>j(a)()},{default:M(()=>[B(j(py),{class:`size-3.5`}),n[9]||=V(`Start all `,-1)]),_:1}),B($,{variant:`ghost`,onClick:n[1]||=e=>j(o)()},{default:M(()=>[B(j(Ey),{class:`size-3.5`}),n[10]||=V(`Stop all `,-1)]),_:1}),B($,{variant:`primary`,onClick:n[2]||=e=>s.value=!0},{default:M(()=>[B(j(my),{class:`size-3.5`}),n[11]||=V(`Add server `,-1)]),_:1})]),_:1}),z(`div`,mH,[B(RI,{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`]),z(`div`,hH,[B(j(by),{class:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),xr(z(`input`,{"onUpdate:modelValue":n[4]||=e=>c.value=e,type:`search`,placeholder:`Filter by id, label, command or port`,class:D([`pl-8`,[j(SF)]]),"aria-label":`Filter servers`},null,2),[[Yl,c.value]]),c.value.length>0?(I(),L(`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=``},[B(j(Ny),{class:`size-3.5`})])):H(``,!0)])]),d.value?(I(),L(`div`,gH,[(I(),L(F,null,ya(4,e=>B(vL,{key:e,class:`h-72 w-full`,rounded:`rounded-panel`})),64))])):j(t).length===0?(I(),R(oL,{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:M(()=>[B(j(xy),{class:`size-4`})]),action:M(()=>[B($,{variant:`primary`,onClick:n[6]||=e=>s.value=!0},{default:M(()=>[B(j(my),{class:`size-3.5`}),n[12]||=V(`Add a server `,-1)]),_:1})]),_:1})):f.value.length===0?(I(),R(oL,{key:2,compact:``,title:`Nothing matches that filter`,description:`Try a different status or clear the search.`},{action:M(()=>[B($,{onClick:n[7]||=e=>{c.value=``,l.value=`all`}},{default:M(()=>[...n[13]||=[V(` Clear filters `,-1)]]),_:1})]),_:1})):(I(),L(`div`,_H,[(I(!0),L(F,null,ya(f.value,e=>(I(),R(NB,{key:e.id,server:e,series:j(i)(e.id),now:j(r)},null,8,[`server`,`series`,`now`]))),128))])),B(Iz,{open:s.value,"onUpdate:open":n[8]||=e=>s.value=e},null,8,[`open`])]))}}),yH=N({__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=A(!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 Be(o),(e,t)=>(I(),R($,{variant:i.value?n.confirmVariant:n.variant,size:n.size,disabled:n.disabled,loading:n.loading,onClick:s},{default:M(()=>[V(O(i.value?n.confirmLabel:n.label),1)]),_:1},8,[`variant`,`size`,`disabled`,`loading`]))}}),bH={class:`min-w-0 flex-1`},xH={key:0,class:`text-xs font-semibold`},SH=N({__name:`Notice`,props:{tone:{default:`info`},title:{default:void 0},class:{default:void 0}},setup(e){let t=e,n={ok:Vv,warn:My,danger:uy,info:ty,neutral:ty,accent:Sy},r=U(()=>n[t.tone]);return(e,n)=>(I(),L(`div`,{class:D(j(Q)(`flex items-start gap-2 rounded-panel border px-3 py-2`,j(vP)[t.tone],t.class))},[(I(),R(ha(r.value),{class:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`})),z(`div`,bH,[t.title?(I(),L(`p`,xH,O(t.title),1)):H(``,!0),z(`div`,{class:D(j(Q)(`text-xs leading-relaxed text-ink/85`,t.title&&`mt-0.5`))},[P(e.$slots,`default`)],2)])],2))}}),CH={class:`space-y-2`},wH={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},TH=N({__name:`AuthenticationSection`,props:Ba({view:{},dirty:{type:Boolean}},{auth:{required:!0},authModifiers:{}}),emits:Ba([`reset`],[`update:auth`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`auth`),a=WR(()=>i.value.sessionTtlMs,e=>i.value.sessionTtlMs=e,6048e5),o=WR(()=>i.value.maxLoginAttempts,e=>i.value.maxLoginAttempts=e,5),s=WR(()=>i.value.lockoutMs,e=>i.value.lockoutMs=e,6e4),c=U(()=>n.view?.auth.passwordSet===!0),l=U(()=>n.view?.auth.apiTokenSet===!0),u=U(()=>n.view?.auth.blockedReason??null),d=U(()=>n.view?.auth.exposed===!0),f=U(()=>n.view?.auth.usingDefaultPassword===!0),p=U(()=>i.value.enabled&&!c.value),{setPassword:m,clearPassword:h}=Jj(),g=A(``),_=A(``),v=A(``),y=A(null),b=A(null),x=A(!1),S=U(()=>v.value.length>0&&v.value!==_.value),C=U(()=>_.value.length>0&&_.value.length<8),w=U(()=>_.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)=>(I(),L(F,null,[B(cz,{title:`Access policy`,description:`Authentication applies whether the panel is on loopback or exposed to the network.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[10]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(Sz,{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`]),B(mz,{modelValue:j(a),"onUpdate:modelValue":t[2]||=e=>k(a)?a.value=e:null,label:`Session lifetime (ms)`,min:6e4,hint:`604800000 is one week.`},null,8,[`modelValue`]),B(_L,{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`]),B(Sz,{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`]),B(mz,{modelValue:j(o),"onUpdate:modelValue":t[5]||=e=>k(o)?o.value=e:null,label:`Max login attempts`,min:1,hint:`Failures before a temporary lockout.`},null,8,[`modelValue`]),B(mz,{modelValue:j(s),"onUpdate:modelValue":t[6]||=e=>k(s)?s.value=e:null,label:`Lockout (ms)`,min:1e3},null,8,[`modelValue`])]),_:1}),z(`div`,CH,[B(SH,{tone:l.value?`info`:`neutral`,title:l.value?`An API token is set`:`No API token`},{default:M(()=>[l.value?(I(),L(F,{key:0},[t[11]||=V(` Scripts can call the API with `,-1),t[12]||=z(`code`,null,`Authorization: Bearer …`,-1),t[13]||=V(` instead of signing in. `,-1)],64)):(I(),L(F,{key:1},[t[14]||=V(` For shell scripts and agents, generate one with `,-1),t[15]||=z(`code`,null,`home-hosted set-token --generate`,-1),t[16]||=V(`. `,-1)],64))]),_:1},8,[`tone`,`title`]),f.value?(I(),R(SH,{key:0,tone:`warn`,title:`The default password is still in use`},{default:M(()=>[...t[17]||=[V(` Set your own password below. Binding beyond `,-1),z(`code`,null,`127.0.0.1`,-1),V(` stays refused until you do. `,-1)]]),_:1})):H(``,!0),u.value?(I(),R(SH,{key:1,tone:`danger`,title:`This listener is being refused`},{default:M(()=>[V(O(u.value),1)]),_:1})):p.value?(I(),R(SH,{key:2,tone:`warn`,title:`Authentication is on but no password is set`},{default:M(()=>[...t[18]||=[V(` Nothing is actually required yet, and binding beyond `,-1),z(`code`,null,`127.0.0.1`,-1),V(` stays refused until a password exists. `,-1)]]),_:1})):d.value?(I(),R(SH,{key:3,tone:`warn`,title:`Reachable beyond 127.0.0.1`},{default:M(()=>[...t[19]||=[V(` Keep the password strong, or put a TLS-terminating proxy in front of the panel. `,-1)]]),_:1})):H(``,!0)]),z(`form`,{class:`mt-3`,onSubmit:uu(T,[`prevent`])},[B(cz,{title:c.value?`Change password`:`Set a password`,description:`Stored as a scrypt hash in the secrets file, never in the config.`},{default:M(()=>[c.value?(I(),R(yz,{key:0,modelValue:g.value,"onUpdate:modelValue":t[7]||=e=>g.value=e,type:`password`,autocomplete:`current-password`,label:`Current password`},null,8,[`modelValue`])):H(``,!0),B(yz,{modelValue:_.value,"onUpdate:modelValue":t[8]||=e=>_.value=e,type:`password`,autocomplete:`new-password`,label:`New password`},null,8,[`modelValue`]),B(yz,{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`]),z(`div`,wH,[B($,{type:`submit`,variant:`primary`,disabled:!w.value,loading:x.value},{default:M(()=>[V(O(c.value?`Update password`:`Set password and enable auth`),1)]),_:1},8,[`disabled`,`loading`]),c.value?(I(),R(yH,{key:0,label:`Clear password`,"confirm-label":`Confirm clear`,"confirm-variant":`danger`,disabled:x.value,onConfirm:ee},null,8,[`disabled`])):H(``,!0)]),C.value||b.value||y.value?(I(),L(F,{key:1},[C.value?(I(),R(SH,{key:0,tone:`warn`,title:`That is a short password`,class:`sm:col-span-2`},{default:M(()=>[...t[20]||=[V(` It is allowed, but longer is the only thing standing between the network and this panel. `,-1)]]),_:1})):H(``,!0),b.value?(I(),R(SH,{key:1,tone:`danger`,class:`sm:col-span-2`},{default:M(()=>[V(O(b.value),1)]),_:1})):H(``,!0),y.value?(I(),R(SH,{key:2,tone:`ok`,class:`sm:col-span-2`},{default:M(()=>[V(O(y.value),1)]),_:1})):H(``,!0)],64)):H(``,!0)]),_:1},8,[`title`])],32)],64))}}),EH=[`disabled`],DH={class:`min-w-0`},OH={class:`text-ink`},kH=N({__name:`CheckField`,props:Ba({label:{},hint:{default:void 0},disabled:{type:Boolean,default:!1}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=co(e,`modelValue`);return(e,r)=>(I(),L(`label`,{class:D(j(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`))},[xr(z(`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,EH),[[Xl,n.value]]),z(`span`,DH,[z(`span`,OH,O(t.label),1),t.hint?(I(),L(`span`,{key:0,class:D([`mt-0.5 block`,[j(xF)]])},O(t.hint),3)):H(``,!0),P(e.$slots,`default`)])],2))}}),AH={class:`space-y-3`},jH={key:0,class:`sm:col-span-2`},MH={key:1,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`},PH={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},FH={class:`text-2xs leading-4 text-faint`},IH={key:0,class:`space-y-2 sm:col-span-2`},LH={key:1,class:`text-xs text-muted sm:col-span-2`},RH={key:2,class:`divide-y divide-line-soft sm:col-span-2`},zH={class:`min-w-0`},BH={class:`truncate font-mono text-xs text-ink`},VH={class:`mt-0.5 text-2xs leading-4 text-muted`},HH={class:`sm:col-span-2`},UH={key:0,class:`space-y-2 sm:col-span-2`},WH={key:1,class:`sm:col-span-2`},GH={key:2,class:`divide-y divide-line-soft sm:col-span-2`},KH={class:`min-w-0 flex-1`},qH={class:`flex items-center gap-2`},JH={class:`truncate font-mono text-xs text-ink`},YH={class:`mt-0.5 font-mono text-2xs tabular-nums text-muted`},XH={class:`flex items-center gap-1.5`},ZH=[`href`],QH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},$H={key:0,class:`font-mono text-2xs text-muted`},eU={class:`sm:col-span-2`},tU={key:0,class:`sm:col-span-2`},nU={class:`mt-2`},rU={class:`mt-2 max-w-sm`},iU={class:`mt-2`},aU={class:`mt-2`},oU={class:`mt-1 max-h-64 space-y-0.5 overflow-auto`},sU={class:`mt-2 flex flex-wrap items-center gap-2`},cU={class:`mt-2`},lU={class:`mt-2`},uU={key:1,class:`space-y-2 sm:col-span-2`},dU=N({__name:`BackupsSection`,props:Ba({state:{},policy:{},configPath:{},dirty:{type:Boolean}},{form:{required:!0},formModifiers:{}}),emits:Ba([`reset`],[`update:form`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`form`),a=jM(),o=WR(()=>i.value.keep,e=>i.value.keep=e,5),s=A(!1),c=A(null),l=A(null),u=A(``),d=A(null),f=A(null),p=A(``),m=A(null),h=U(()=>n.state?.files??[]),g=U(()=>n.state?.paths??[]),_=U(()=>d.value?.items.filter(e=>e.selected).length??0),v=U(()=>d.value?.items.some(e=>e.id===`config`&&e.selected)??!1),y=Q(SF,`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`,yF);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 Cj(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 wj(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 Oj(f.value,!1,T())):(m.value={kind:`stored`,name:e},d.value=await Dj(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 te(){let e=m.value;e!==null&&await ee(e.kind===`stored`?e.name:void 0)}async function ne(){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 Dj(e.name,!0,n):f.value===null?null:await Oj(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)=>(I(),L(`div`,AH,[B(cz,{title:`Policy`,description:`What a backup captures, and how many archives are kept.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[9]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(Sz,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Allow backups`,hint:`Off stops new archives; whatever is already on disk stays downloadable and restorable.`,wide:``},null,8,[`modelValue`]),i.value.enabled?H(``,!0):(I(),L(`div`,jH,[B(SH,{tone:`warn`,title:`Backups are off`},{default:M(()=>[...t[10]||=[V(` Nothing new is archived until this is back on. The archives below can still be downloaded, restored and deleted. `,-1)]]),_:1})])),B(mz,{modelValue:j(o),"onUpdate:modelValue":t[2]||=e=>k(o)?o.value=e:null,label:`Keep`,min:1,hint:`Older archives are pruned after each backup.`},null,8,[`modelValue`]),B(yz,{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?H(``,!0):(I(),L(`div`,MH,[t[13]||=z(`span`,{class:`text-xs font-medium text-muted`},`Archive directory`,-1),z(`div`,NH,[z(`span`,PH,O(n.policy.dir),1),B(BV,{value:n.policy.dir,label:`Copy the archive directory`},null,8,[`value`])]),z(`p`,FH,[t[11]||=V(` Changing it is a file-level decision: edit `,-1),z(`code`,null,O(n.configPath??`the config file`),1),t[12]||=V(`. `,-1)])]))]),_:1}),B(cz,{title:`Declared paths`,description:`Config, secrets and TLS are always captured. A path already covered by a declared parent is skipped.`},{default:M(()=>[n.state===null?(I(),L(`div`,IH,[B(vL,{class:`h-4 w-full`})])):g.value.length===0?(I(),L(`p`,LH,[...t[14]||=[V(` No data paths are declared yet. Add `,-1),z(`code`,null,`dataEnvs`,-1),V(` or `,-1),z(`code`,null,`backupPaths`,-1),V(` to a server to capture its data. `,-1)]])):(I(),L(`ul`,RH,[(I(!0),L(F,null,ya(g.value,e=>(I(),L(`li`,{key:`${e.origin}:${e.path}`,class:`flex items-start justify-between gap-3 py-1.5`},[z(`div`,zH,[z(`p`,BH,O(e.path),1),z(`p`,VH,[V(O(e.included?`from ${e.origin}`:e.note??`not captured`)+` `,1),e.included&&e.ignoreGenerated?(I(),L(F,{key:0},[V(` · generated directories skipped `)],64)):H(``,!0)])]),B(BF,{tone:e.included?`ok`:`neutral`,plain:``},{default:M(()=>[V(O(e.included?`included`:`skipped`),1)]),_:2},1032,[`tone`])]))),128))]))]),_:1}),i.value.enabled?(I(),R(cz,{key:0,title:`Create a backup now`,description:`Optional password encrypts the archive; restoring it will ask for the same password.`},{default:M(()=>[B(yz,{modelValue:u.value,"onUpdate:modelValue":t[4]||=e=>u.value=e,type:`password`,autocomplete:`new-password`,label:`Password (optional)`,wide:``},null,8,[`modelValue`]),z(`div`,HH,[B($,{variant:`primary`,disabled:s.value,loading:s.value,onClick:S},{default:M(()=>[...t[15]||=[V(` Create backup now `,-1)]]),_:1},8,[`disabled`,`loading`])])]),_:1})):H(``,!0),B(cz,{title:`Archives`,description:`Stored in the backup directory and downloadable at any time.`},{default:M(()=>[n.state===null?(I(),L(`div`,UH,[B(vL,{class:`h-4 w-full`}),B(vL,{class:`h-4 w-2/3`})])):h.value.length===0?(I(),L(`div`,WH,[B(oL,{compact:``,title:`No archives yet`,description:i.value.enabled?`Create one now to capture the config, secrets and every declared data path.`:`Nothing has been archived yet, and backups are off.`},ba({icon:M(()=>[B(j(Nv),{class:`size-4`})]),_:2},[i.value.enabled?{name:`action`,fn:M(()=>[B($,{size:`sm`,variant:`primary`,disabled:s.value,onClick:S},{default:M(()=>[...t[16]||=[V(` Create backup now `,-1)]]),_:1},8,[`disabled`])]),key:`0`}:void 0]),1032,[`description`])])):(I(),L(`ul`,GH,[(I(!0),L(F,null,ya(h.value,e=>(I(),L(`li`,{key:e.name,class:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 first:pt-0 last:pb-0`},[z(`div`,KH,[z(`div`,qH,[z(`span`,JH,O(e.name),1),e.encrypted?(I(),R(BF,{key:0,tone:`warn`,plain:``},{default:M(()=>[...t[17]||=[V(` encrypted `,-1)]]),_:1})):H(``,!0)]),z(`p`,YH,O(j(OI)(e.sizeBytes))+` · `+O(j(CI)(e.createdAt)),1)]),z(`div`,XH,[z(`a`,{href:Tj(e.name),class:D(j(b))},[B(j(Jv),{class:`size-3`,"aria-hidden":`true`}),t[18]||=V(` Download `,-1)],10,ZH),B($,{size:`xs`,variant:`secondary`,disabled:s.value,onClick:t=>ee(e.name)},{default:M(()=>[B(j(_y),{class:`size-3`,"aria-hidden":`true`}),t[19]||=V(` Restore `,-1)]),_:1},8,[`disabled`,`onClick`]),B(yH,{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}),B(cz,{title:`Restore`,description:`Nothing is written until the plan is applied.`},{default:M(()=>[z(`div`,QH,[z(`label`,{class:D(j(bF)),for:`restore-upload`},`Restore from an uploaded .zip`,2),z(`input`,{id:`restore-upload`,type:`file`,accept:`.zip,application/zip`,class:D(j(y)),onChange:w},null,34),f.value?(I(),L(`p`,$H,O(f.value.name),1)):H(``,!0)]),z(`div`,eU,[B($,{variant:`secondary`,disabled:s.value||f.value===null,onClick:t[5]||=e=>ee()},{default:M(()=>[...t[20]||=[V(` Check the upload `,-1)]]),_:1},8,[`disabled`])]),d.value?(I(),L(`div`,tU,[B(SH,{tone:`warn`,title:d.value.dryRun?`Nothing has changed yet`:`Applied`},{default:M(()=>[z(`p`,null,[m.value?.kind===`stored`?(I(),L(F,{key:0},[t[21]||=V(` Archive `,-1),z(`code`,null,O(m.value.name),1),t[22]||=V(`. `,-1)],64)):(I(),L(F,{key:1},[V(` The uploaded archive. `)],64))]),d.value.needsPassword?(I(),L(F,{key:0},[z(`p`,nU,O(d.value.error??`This backup is password-protected.`),1),z(`div`,rU,[B(yz,{modelValue:p.value,"onUpdate:modelValue":t[6]||=e=>p.value=e,type:`password`,autocomplete:`off`,label:`Password`},null,8,[`modelValue`])]),z(`div`,iU,[B($,{size:`sm`,variant:`secondary`,disabled:s.value,onClick:te},{default:M(()=>[...t[23]||=[V(` Check again with the password `,-1)]]),_:1},8,[`disabled`])])],64)):(I(),L(F,{key:1},[z(`p`,aU,` Choose what to restore — `+O(_.value)+` of `+O(d.value.items.length)+` selected. `,1),z(`ul`,oU,[(I(!0),L(F,null,ya(d.value.items,e=>(I(),L(`li`,{key:e.id},[B(kH,{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))]),z(`div`,sU,[B($,{size:`xs`,variant:`ghost`,disabled:s.value,onClick:t[7]||=e=>x(!0)},{default:M(()=>[...t[24]||=[V(` Select all `,-1)]]),_:1},8,[`disabled`]),B($,{size:`xs`,variant:`ghost`,disabled:s.value,onClick:t[8]||=e=>x(!1)},{default:M(()=>[...t[25]||=[V(` Select none `,-1)]]),_:1},8,[`disabled`])]),z(`p`,cU,[V(` Will restore: `+O(d.value.applied.join(`, `)||`nothing`)+`. `,1),d.value.skipped.length?(I(),L(F,{key:0},[V(` Skipped: `+O(d.value.skipped.join(`, `))+`. `,1)],64)):H(``,!0),d.value.restartRequired?(I(),L(F,{key:1},[V(` The panel's own settings differ, so restart the panel afterwards. `)],64)):v.value?(I(),L(F,{key:2},[V(` Restored servers are reloaded immediately; entries marked autostart start on their own. `)],64)):H(``,!0)]),z(`div`,lU,[B($,{size:`sm`,variant:`danger`,disabled:s.value||_.value===0,loading:s.value,onClick:ne},{default:M(()=>[V(O(m.value?.kind===`stored`?`Apply this restore`:`Restore the upload`),1)]),_:1},8,[`disabled`,`loading`])])],64))]),_:1},8,[`title`])])):H(``,!0),l.value||c.value?(I(),L(`div`,uU,[l.value?(I(),R(SH,{key:0,tone:`danger`},{default:M(()=>[V(O(l.value),1)]),_:1})):H(``,!0),c.value?(I(),R(SH,{key:1,tone:`ok`},{default:M(()=>[V(O(c.value),1)]),_:1})):H(``,!0)])):H(``,!0)]),_:1})]))}}),fU={class:`mt-3 space-y-3`},pU=N({__name:`DefaultsSection`,props:Ba({dirty:{type:Boolean}},{defaults:{required:!0},defaultsModifiers:{}}),emits:Ba([`reset`],[`update:defaults`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`defaults`),a=WR(()=>i.value.logBufferLines,e=>i.value.logBufferLines=e,500);return(e,t)=>(I(),L(F,null,[B(cz,{title:`Server defaults`,description:`Applied to every entry that does not set its own value.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[9]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(Sz,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Enabled`,hint:`New entries start enabled.`,wide:``},null,8,[`modelValue`]),B(Sz,{modelValue:i.value.autostart,"onUpdate:modelValue":t[2]||=e=>i.value.autostart=e,label:`Autostart with the panel`},null,8,[`modelValue`]),B(_L,{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`]),B(_L,{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`},{value:`kill`,label:`Kill whatever holds the port`}]},null,8,[`modelValue`]),B(mz,{modelValue:j(a),"onUpdate:modelValue":t[5]||=e=>k(a)?a.value=e:null,label:`Log buffer lines`,min:50,max:1e5,hint:`Kept in memory per server.`},null,8,[`modelValue`])]),_:1}),z(`div`,fU,[B(Cz,{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))}}),mU={key:0,class:`mt-3 flex flex-wrap items-center gap-1.5`},hU={key:1,class:`mt-3 text-xs text-muted`},gU=N({__name:`HostSection`,props:Ba({config:{},alerts:{},dirty:{type:Boolean}},{host:{required:!0},hostModifiers:{}}),emits:Ba([`reset`],[`update:host`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`host`),a=WR(()=>i.value.intervalMs,e=>i.value.intervalMs=e,15e3),o=WR(()=>i.value.diskUsedPercent,e=>i.value.diskUsedPercent=e,90),s=WR(()=>i.value.memoryUsedPercent,e=>i.value.memoryUsedPercent=e,90),c=WR(()=>i.value.swapUsedPercent,e=>i.value.swapUsedPercent=e,50),l=WR(()=>i.value.loadPerCpu,e=>i.value.loadPerCpu=e,2),u=WR(()=>i.value.tempCelsius,e=>i.value.tempCelsius=e,85);return(e,t)=>(I(),L(F,null,[B(cz,{title:`Thresholds`,description:`A threshold of 0 disables that alert. Breaches notify once, and once more on recovery.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[9]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(Sz,{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.`,wide:``},null,8,[`modelValue`]),B(mz,{modelValue:j(a),"onUpdate:modelValue":t[2]||=e=>k(a)?a.value=e:null,label:`Interval (ms)`,min:5e3,hint:`How often the host is sampled and alerts are checked.`},null,8,[`modelValue`]),B(yz,{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`]),B(mz,{modelValue:j(o),"onUpdate:modelValue":t[4]||=e=>k(o)?o.value=e:null,label:`Disk used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),B(mz,{modelValue:j(s),"onUpdate:modelValue":t[5]||=e=>k(s)?s.value=e:null,label:`Memory used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),B(mz,{modelValue:j(c),"onUpdate:modelValue":t[6]||=e=>k(c)?c.value=e:null,label:`Swap used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),B(mz,{modelValue:j(l),"onUpdate:modelValue":t[7]||=e=>k(l)?l.value=e:null,label:`Load per CPU`,min:0,hint:`1-minute load average divided by the core count.`},null,8,[`modelValue`]),B(mz,{modelValue:j(u),"onUpdate:modelValue":t[8]||=e=>k(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?(I(),L(`div`,mU,[t[10]||=z(`span`,{class:`text-xs text-muted`},`Breaching now:`,-1),(I(!0),L(F,null,ya(n.alerts,e=>(I(),R(BF,{key:e,tone:`danger`,dot:``},{default:M(()=>[V(O(e),1)]),_:2},1024))),128))])):i.value.enabled?(I(),L(`p`,hU,` Nothing is breaching right now. `)):H(``,!0)],64))}}),_U={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},vU={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},yU={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},bU={class:`text-2xs leading-4 text-faint`},xU={key:0},SU={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},CU=[`disabled`],wU=N({__name:`InterfaceSection`,props:Ba({ui:{},labelDirty:{type:Boolean}},{label:{required:!0},labelModifiers:{}}),emits:Ba([`changed`,`resetLabel`],[`update:label`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`label`),a=A(null),o=A(!1),s=A(null),c=A(null),l=A(!1),u=U(()=>{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=U(()=>{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 Nj(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 Pj();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)=>(I(),R(cz,{title:`Interface`,description:`The panel is a static site: keep the stock one, or serve your own build from the state directory.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.labelDirty,onClick:h[1]||=e=>r(`resetLabel`)},{default:M(()=>[...h[4]||=[V(` Reset name `,-1)]]),_:1},8,[`disabled`]),e.ui?.custom?(I(),R($,{key:0,size:`xs`,variant:`ghost`,disabled:o.value,onClick:m},{default:M(()=>[V(O(l.value?`Confirm revert`:`Revert to stock`),1)]),_:1},8,[`disabled`])):H(``,!0),B($,{size:`xs`,variant:`primary`,disabled:o.value||a.value===null,onClick:p},{default:M(()=>[...h[5]||=[V(` Install UI `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[z(`div`,_U,[h[2]||=z(`span`,{class:`text-xs font-medium text-muted`},`Currently serving`,-1),z(`div`,vU,[z(`span`,yU,O(u.value),1),B(BV,{value:e.ui?.dir??``,label:`Copy the UI directory`},null,8,[`value`])]),z(`p`,bU,[d.value?(I(),L(`span`,xU,O(d.value)+` · `,1)):H(``,!0),z(`code`,null,O(e.ui?.dir??`—`),1)])]),B(yz,{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`]),z(`label`,SU,[h[3]||=z(`span`,{class:`text-xs font-medium text-muted`},`Upload a UI build (.zip with an index.html)`,-1),z(`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,CU)]),c.value?(I(),R(SH,{key:0,tone:`warn`,title:c.value},null,8,[`title`])):s.value?(I(),R(SH,{key:1,tone:`ok`,title:s.value},null,8,[`title`])):H(``,!0),h[6]||=z(`p`,{class:`text-2xs leading-4 text-faint sm:col-span-2`},[V(` See `),z(`code`,null,`docs/UI_CREATION.md`),V(` for the API contract. If a custom UI breaks the panel, `),z(`code`,null,`home-hosted ui-revert`),V(` puts the stock one back from the terminal. `)],-1)]),_:1}))}}),TU={class:`flex min-w-0 flex-col gap-1`},EU={class:`text-2xs leading-4 text-faint`},DU={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},OU={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},kU={class:`min-w-0 flex-1 truncate font-mono text-xs tabular-nums text-ink`},AU=N({__name:`ListenerSection`,props:Ba({view:{},dirty:{type:Boolean}},{control:{required:!0},controlModifiers:{}}),emits:Ba([`reset`],[`update:control`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`control`),a=WR(()=>i.value.port,e=>i.value.port=e,3999),o=[`local`,`lan`],s=U({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=U(()=>{if(s.value===`custom`&&Wk(i.value.host)===null)return`Enter an IPv4 address, for example 192.168.1.20.`}),l=U(()=>n.view?.url??`—`);return(e,t)=>(I(),R(cz,{title:`Listener`,description:`Where the panel answers. Moving this restarts the panel and sends this page to the new address.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[5]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(mz,{modelValue:j(a),"onUpdate:modelValue":t[1]||=e=>k(a)?a.value=e:null,label:`Control port`,min:1,max:65535,hint:`Default 3999.`},null,8,[`modelValue`]),z(`div`,TU,[t[6]||=z(`span`,{class:`text-xs font-medium text-muted`},`Bind`,-1),B(RI,{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`]),z(`p`,EU,O(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`?(I(),R(yz,{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`])):H(``,!0),B(Sz,{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`]),z(`div`,DU,[t[8]||=z(`span`,{class:`text-xs font-medium text-muted`},`Live address`,-1),z(`div`,OU,[z(`span`,kU,O(l.value),1),n.view?.restartRequired?(I(),R(BF,{key:0,tone:`warn`,dot:``},{default:M(()=>[...t[7]||=[V(` restart required `,-1)]]),_:1})):H(``,!0),B(BV,{value:l.value,label:`Copy the live address`},null,8,[`value`])]),t[9]||=z(`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}))}}),jU={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},MU={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`},PU={class:`text-2xs leading-4 text-faint`},FU=N({__name:`LogsSection`,props:Ba({logsDir:{},dirty:{type:Boolean}},{logs:{required:!0},logsModifiers:{}}),emits:Ba([`reset`],[`update:logs`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`logs`),a=WR(()=>i.value.maxBytes,e=>i.value.maxBytes=e,2e6),o=WR(()=>i.value.keep,e=>i.value.keep=e,3),s=U(()=>n.logsDir??`—`);return(e,t)=>{let c=pa(`RouterLink`);return I(),R(cz,{title:`Retention`,description:`The live view always comes from memory; these files survive a restart and feed the Logs page.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[4]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(Sz,{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`]),B(mz,{modelValue:j(a),"onUpdate:modelValue":t[2]||=e=>k(a)?a.value=e:null,label:`Rotate at (bytes)`,min:1e4,max:1e8,hint:`Per server, before rolling to .1, .2, …`},null,8,[`modelValue`]),B(mz,{modelValue:j(o),"onUpdate:modelValue":t[3]||=e=>k(o)?o.value=e:null,label:`Keep rotated files`,min:1,max:10},null,8,[`modelValue`]),z(`div`,jU,[t[8]||=z(`span`,{class:`text-xs font-medium text-muted`},`Logs directory`,-1),z(`div`,MU,[z(`span`,NU,O(s.value),1),B(BV,{value:s.value,label:`Copy the logs directory`},null,8,[`value`])]),z(`p`,PU,[t[6]||=V(` Browse and download these files on the `,-1),B(c,{to:`/logs`,class:`text-accent underline decoration-accent/40 underline-offset-2 hover:decoration-accent`},{default:M(()=>[...t[5]||=[V(` Logs `,-1)]]),_:1}),t[7]||=V(` page. `,-1)])])]),_:1})}}}),IU={class:`flex items-center gap-2 border-t border-line-soft pt-3 sm:col-span-2`},LU={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},RU={key:0,class:`sm:col-span-2`},zU={class:`flex flex-wrap gap-1.5`},BU={key:1,class:`sm:col-span-2`},VU={class:`text-2xs leading-4 text-faint`},HU={key:2,class:`space-y-2 sm:col-span-2`},UU=N({__name:`NotificationsSection`,props:Ba({status:{},dirty:{type:Boolean}},{telegram:{required:!0},telegramModifiers:{}}),emits:Ba([`reset`],[`update:telegram`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`telegram`),a=jM(),o=WR(()=>i.value.cooldownMs,e=>i.value.cooldownMs=e,12e4),s=A(``),c=A(null),l=A(null),u=A([]),d=A(!1),f=U(()=>n.status?.tokenSet===!0),p=U(()=>n.status?.lastResult??null),m=U(()=>n.status?.lastResultAt??null),h=U(()=>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 kj(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 Aj(),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 Mj(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 jj({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)=>(I(),R(cz,{title:`Telegram`,description:`Policy lives in the config; the bot token is a secret and never comes back from the server.`},{actions:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[10]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(Sz,{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.`,wide:``},null,8,[`modelValue`]),B(yz,{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`]),B(mz,{modelValue:j(o),"onUpdate:modelValue":t[3]||=e=>k(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`]),B(Sz,{modelValue:i.value.onCrash,"onUpdate:modelValue":t[4]||=e=>i.value.onCrash=e,label:`Retries exhausted`},null,8,[`modelValue`]),B(Sz,{modelValue:i.value.onUnhealthy,"onUpdate:modelValue":t[5]||=e=>i.value.onUnhealthy=e,label:`Port unhealthy`},null,8,[`modelValue`]),B(Sz,{modelValue:i.value.onForcedRestart,"onUpdate:modelValue":t[6]||=e=>i.value.onForcedRestart=e,label:`Forced restart`},null,8,[`modelValue`]),B(Sz,{modelValue:i.value.onRecovered,"onUpdate:modelValue":t[7]||=e=>i.value.onRecovered=e,label:`Recovered`},null,8,[`modelValue`]),B(Sz,{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`]),z(`div`,IU,[t[11]||=z(`span`,{class:`text-xs font-medium text-muted`},`Bot token`,-1),B(BF,{tone:f.value?`ok`:`warn`,dot:``},{default:M(()=>[V(O(f.value?`token set`:`no token`),1)]),_:1},8,[`tone`]),t[12]||=z(`span`,{class:`text-2xs text-faint`},`From @BotFather — a secret, never in servers.config.json.`,-1)]),B(yz,{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`]),z(`div`,LU,[B($,{variant:`primary`,disabled:d.value||s.value.trim().length===0,loading:d.value&&s.value.trim().length>0,onClick:g},{default:M(()=>[...t[13]||=[V(` Save token `,-1)]]),_:1},8,[`disabled`,`loading`]),B($,{variant:`secondary`,disabled:d.value,onClick:v},{default:M(()=>[...t[14]||=[V(` Detect chats `,-1)]]),_:1},8,[`disabled`]),B($,{variant:`secondary`,disabled:d.value,onClick:y},{default:M(()=>[...t[15]||=[V(` Send test `,-1)]]),_:1},8,[`disabled`]),f.value?(I(),R(yH,{key:0,label:`Remove token`,"confirm-label":`Confirm remove`,"confirm-variant":`danger`,disabled:d.value,onConfirm:_},null,8,[`disabled`])):H(``,!0)]),u.value.length>0?(I(),L(`div`,RU,[t[16]||=z(`p`,{class:`mb-1.5 text-xs text-muted`},` Chats the bot has seen: `,-1),z(`div`,zU,[(I(!0),L(F,null,ya(u.value,e=>(I(),R($,{key:String(e.id),size:`xs`,variant:`secondary`,onClick:t=>i.value.chatId=String(e.id)},{default:M(()=>[V(O(e.title)+` (`+O(e.id)+`) `,1)]),_:2},1032,[`onClick`]))),128))])])):H(``,!0),p.value?(I(),L(`div`,BU,[z(`p`,VU,` Last send: `+O(p.value)+O(m.value?` · ${j(DI)(m.value,j(a).now.value)}`:``),1)])):H(``,!0),l.value||c.value?(I(),L(`div`,HU,[l.value?(I(),R(SH,{key:0,tone:`danger`},{default:M(()=>[V(O(l.value),1)]),_:1})):H(``,!0),c.value?(I(),R(SH,{key:1,tone:`ok`},{default:M(()=>[V(O(c.value),1)]),_:1})):H(``,!0)])):H(``,!0)]),_:1}))}}),WU={class:`divide-y divide-line-soft sm:col-span-2`},GU={class:`min-w-0`},KU={class:`text-xs font-medium text-ink`},qU={class:`mt-0.5 text-2xs leading-4 text-faint`},JU={class:`flex min-w-0 flex-1 items-center justify-end gap-1.5`},YU={class:`min-w-0 truncate font-mono text-xs text-ink`},XU=N({__name:`PathsSection`,props:{configPath:{},dataRoot:{},logsDir:{},projectDir:{},panelUrl:{}},setup(e){let t=e,n=U(()=>[{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)=>(I(),R(cz,{title:`Where things live`,description:`Read-only. Copy a path straight into a shell or an editor.`},{default:M(()=>[z(`ul`,WU,[(I(!0),L(F,null,ya(n.value,e=>(I(),L(`li`,{key:e.key,class:`flex items-start justify-between gap-3 py-2 first:pt-0 last:pb-0`},[z(`div`,GU,[z(`p`,KU,O(e.label),1),z(`p`,qU,O(e.hint),1)]),z(`div`,JU,[z(`span`,YU,O(e.value),1),B(BV,{value:e.value,label:`Copy ${e.label.toLowerCase()}`},null,8,[`value`,`label`])])]))),128))])]),_:1}))}}),ZU={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},QU={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},$U={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},eW={key:0,class:`sm:col-span-2`},tW={key:1,class:`space-y-3 sm:col-span-2`},nW={class:`divide-y divide-line-soft text-xs`},rW={class:`flex items-start justify-between gap-4 py-1.5`},iW={class:`min-w-0 text-right font-mono text-xs text-ink`},aW={class:`flex items-start justify-between gap-4 py-1.5`},oW={class:`min-w-0 text-right font-mono text-xs text-ink`},sW={class:`flex items-start justify-between gap-4 py-1.5`},cW={class:`font-mono text-xs tabular-nums text-ink`},lW={class:`flex items-center justify-between gap-4 py-1.5`},uW={class:`flex items-start justify-between gap-4 py-1.5`},dW={class:`flex min-w-0 items-center gap-1.5`},fW={class:`min-w-0 truncate font-mono text-2xs text-ink`},pW={key:2,class:`sm:col-span-2`},mW={class:`flex min-w-0 flex-col gap-1`},hW={class:`flex min-w-0 flex-col gap-1`},gW={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},_W={key:3,class:`space-y-2 sm:col-span-2`},vW=N({__name:`TlsSection`,props:Ba({view:{},dirty:{type:Boolean}},{tlsEnabled:{type:Boolean,required:!0},tlsEnabledModifiers:{}}),emits:Ba([`reset`],[`update:tlsEnabled`]),setup(e,{emit:t}){let n=e,r=t,i=co(e,`tlsEnabled`),a=jM(),o=A(``),s=A(``),c=A(null),l=A(null),u=A(!1),d=U(()=>n.view?.tls??null),f=U(()=>n.view?`${n.view.protocol}://${n.view.bindHost}:${n.view.port}`:`—`),p=U(()=>o.value.trim().length>0&&s.value.trim().length>0&&!u.value),m=Q(SF,`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 Fj(o.value,s.value);o.value=``,s.value=``,c.value=`Certificate stored.`,await a.refresh();let t=await GR(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 Ij();c.value=`Certificate removed.`,await a.refresh();let t=await GR(e);t!==null&&(l.value=t)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}return(e,t)=>(I(),L(F,null,[B(cz,{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:M(()=>[B($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[6]||=[V(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[B(Sz,{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`]),z(`div`,ZU,[t[7]||=z(`span`,{class:`text-xs font-medium text-muted`},`Live address`,-1),z(`div`,QU,[z(`span`,$U,O(f.value),1),B(BV,{value:f.value,label:`Copy the live address`},null,8,[`value`])])])]),_:1}),B(cz,{class:`mt-3`,title:`Certificate`,description:`PEM-encoded certificate and its private key. Both stay in the secrets file.`},{default:M(()=>[d.value?.error?(I(),L(`div`,eW,[B(SH,{tone:`danger`,title:`The stored certificate cannot be used`},{default:M(()=>[V(O(d.value.error),1)]),_:1})])):d.value?.certPresent?(I(),L(`div`,tW,[z(`dl`,nW,[z(`div`,rW,[t[8]||=z(`dt`,{class:`text-muted`},` Subject `,-1),z(`dd`,iW,O(d.value.subject??`—`),1)]),z(`div`,aW,[t[9]||=z(`dt`,{class:`text-muted`},` Issuer `,-1),z(`dd`,oW,O(d.value.issuer??`—`),1)]),z(`div`,sW,[t[10]||=z(`dt`,{class:`text-muted`},` Valid until `,-1),z(`dd`,cW,[V(O(d.value.validTo?d.value.validTo.slice(0,10):`—`)+` `,1),d.value.daysRemaining===null?H(``,!0):(I(),L(`span`,{key:0,class:D(j(Q)(`ml-1.5`,d.value.daysRemaining<14?`text-warn`:`text-faint`))},` (`+O(d.value.daysRemaining)+` days) `,3))])]),z(`div`,lW,[t[11]||=z(`dt`,{class:`text-muted`},` Private key `,-1),z(`dd`,null,[B(BF,{tone:d.value.keyMatches?`ok`:`danger`,dot:``},{default:M(()=>[V(O(d.value.keyMatches?`matches the certificate`:`does not match`),1)]),_:1},8,[`tone`])])]),z(`div`,uW,[t[12]||=z(`dt`,{class:`text-muted`},` Fingerprint `,-1),z(`dd`,dW,[z(`span`,fW,O(d.value.fingerprint??`—`),1),d.value.fingerprint?(I(),R(BV,{key:0,value:d.value.fingerprint,label:`Copy the fingerprint`},null,8,[`value`])):H(``,!0)])])])])):(I(),L(`div`,pW,[B(SH,{tone:`info`,title:`No certificate uploaded`},{default:M(()=>[...t[13]||=[V(` Upload a PEM certificate and key below, then save. HTTPS is not served until a certificate is present. `,-1)]]),_:1})])),z(`div`,mW,[z(`label`,{class:D(j(bF)),for:`tls-cert-file`},`Certificate file (.pem, .crt)`,2),z(`input`,{id:`tls-cert-file`,type:`file`,accept:`.pem,.crt,.cer,text/plain`,class:D(j(m)),onChange:t[2]||=e=>h(e,`cert`)},null,34)]),z(`div`,hW,[z(`label`,{class:D(j(bF)),for:`tls-key-file`},`Private key file (.pem, .key)`,2),z(`input`,{id:`tls-key-file`,type:`file`,accept:`.pem,.key,text/plain`,class:D(j(m)),onChange:t[3]||=e=>h(e,`key`)},null,34)]),B(Mz,{modelValue:o.value,"onUpdate:modelValue":t[4]||=e=>o.value=e,label:`Or paste the certificate`,rows:4,placeholder:`-----BEGIN CERTIFICATE-----`},null,8,[`modelValue`]),B(Mz,{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`]),z(`div`,gW,[B($,{variant:`primary`,disabled:!p.value,loading:u.value,onClick:g},{default:M(()=>[...t[14]||=[V(` Save certificate `,-1)]]),_:1},8,[`disabled`,`loading`]),d.value?.certPresent?(I(),R(yH,{key:0,label:`Remove certificate`,"confirm-label":`Confirm remove`,"confirm-variant":`danger`,disabled:u.value,onConfirm:_},null,8,[`disabled`])):H(``,!0)]),l.value||c.value?(I(),L(`div`,_W,[l.value?(I(),R(SH,{key:0,tone:`danger`},{default:M(()=>[V(O(l.value),1)]),_:1})):H(``,!0),c.value?(I(),R(SH,{key:1,tone:`ok`},{default:M(()=>[V(O(c.value),1)]),_:1})):H(``,!0)])):H(``,!0)]),_:1})],64))}}),yW={class:`min-h-full`},bW={class:`mx-auto w-full max-w-5xl px-4 pb-6 pt-5 sm:px-6`},xW={class:`lg:grid lg:grid-cols-[11rem_minmax(0,1fr)] lg:gap-8`},SW={"aria-label":`Settings sections`,class:`hidden lg:block`},CW={class:`sticky top-6 space-y-0.5 border-l border-line`},wW=[`aria-current`,`onClick`],TW={class:`space-y-6`},EW={id:`listener`,class:`scroll-mt-5`},DW={id:`authentication`,class:`scroll-mt-5`},OW={id:`defaults`,class:`scroll-mt-5`},kW={id:`logs`,class:`scroll-mt-5`},AW={id:`notifications`,class:`scroll-mt-5`},jW={id:`host`,class:`scroll-mt-5`},MW={id:`backups`,class:`scroll-mt-5`},NW={id:`tls`,class:`scroll-mt-5`},PW={id:`interface`,class:`scroll-mt-5`},FW={id:`paths`,class:`scroll-mt-5`},IW={class:`sticky bottom-0 z-30 border-t border-line bg-panel/95 backdrop-blur`},LW={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`},RW={class:`min-w-0 flex-1`},zW={class:`text-xs text-muted`},BW={class:`font-mono tabular-nums text-ink`},VW={key:0,class:`mt-0.5 text-xs text-danger`},HW={key:1,class:`mt-0.5 text-xs text-ok`},UW={class:`flex shrink-0 items-center gap-2`},WW={class:`max-h-[60dvh] overflow-auto px-4 py-3`},GW={key:0,class:`divide-y divide-line-soft`},KW={class:`font-mono text-xs text-ink`},qW={class:`ml-auto font-mono text-xs text-muted line-through`},JW={class:`font-mono text-xs text-accent`},YW={key:1,class:`text-xs text-muted`},XW={class:`flex items-center justify-end gap-2 border-t border-line px-4 py-3`},ZW=N({__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=Bg(),r=zg(),i=jM(),a=$j(),o=tn(ER()),s=A(`listener`),c=A(!1),l=A(null),u=A(null),d=A(null),f=A(null),p=U(()=>i.control.value),m=U(()=>i.defaults.value),h=U(()=>i.logsConfig.value),g=U(()=>i.notifications.value?.telegram??null),_=U(()=>i.host.value?.alerts??[]),v=U(()=>f.value?.host??null),y=U(()=>f.value?.backups??null),b=U(()=>f.value?.ui??null),x=U(()=>i.backups.value),S=U(()=>i.appState.value?.configPath??null),C=U(()=>{let e={},t=p.value,n=m.value,r=h.value,i=g.value;if(t!==null){let n=FR(t,o);Object.keys(n).length>0&&(e.control=n)}if(n!==null){let t=IR(n,o.defaults);Object.keys(t).length>0&&(e.defaults=t)}if(r!==null){let t=LR(r,o.logs);Object.keys(t).length>0&&(e.logs=t)}if(i!==null){let t=RR(i,o.telegram);Object.keys(t).length>0&&(e.notifications=t)}let a=v.value;if(a!==null){let t=NR(a,o.host);Object.keys(t).length>0&&(e.host=t)}let s=y.value;if(s!==null){let t=PR(s,o.backups);Object.keys(t).length>0&&(e.backups=t)}return e}),w=U(()=>bR(C.value)),T=U(()=>{let e=p.value,t=g.value,n=v.value,r=y.value;return{control:e===null?{}:{...OR(e),auth:DR(e.auth)},defaults:m.value??{},logs:h.value??{},notifications:t===null?{}:{telegram:kR(t)},host:n??{},backups:r===null?{}:{enabled:r.enabled,keep:r.keep,includePaths:r.includePaths}}}),ee=U(()=>yR(C.value,T.value)),te=A(!1),ne=U(()=>p.value!==null&&VR(p.value,o)),re=U(()=>p.value!==null&&HR(p.value,o)),ie=U(()=>p.value!==null&&UR(p.value,o)),ae=U(()=>m.value!==null&&Object.keys(IR(m.value,o.defaults)).length>0),oe=U(()=>h.value!==null&&Object.keys(LR(h.value,o.logs)).length>0),se=U(()=>g.value!==null&&Object.keys(RR(g.value,o.telegram)).length>0),ce=U(()=>v.value!==null&&Object.keys(NR(v.value,o.host)).length>0),le=U(()=>y.value!==null&&Object.keys(PR(y.value,o.backups)).length>0),E={};function ue(){let e=(e,t)=>{BR(o,E,e)||(t(),E[e]=zR(o,e))},t=p.value;t!==null&&e(`control`,()=>{Object.assign(o.control,OR(t)),Object.assign(o.auth,DR(t.auth))});let n=h.value;n!==null&&e(`logs`,()=>Object.assign(o.logs,n));let r=g.value;r!==null&&e(`telegram`,()=>Object.assign(o.telegram,kR(r)));let i=v.value;i!==null&&e(`host`,()=>Object.assign(o.host,jR(i)));let a=y.value;a!==null&&e(`backups`,()=>Object.assign(o.backups,MR(a)));let s=m.value;s!==null&&e(`defaults`,()=>{o.defaults.enabled=s.enabled,o.defaults.autostart=s.autostart,o.defaults.bind=s.bind,o.defaults.onPortConflict=s.onPortConflict,o.defaults.logBufferLines=s.logBufferLines,o.defaults.restart={...s.restart},o.defaults.health=TR(s.health),o.defaults.stop={...s.stop}})}function de(){for(let e of Object.keys(E))delete E[e]}function fe(e){E[e]=zR(o,e)}jr([p,m,h,g,f],()=>{ue()},{immediate:!0});async function pe(){d.value=null;try{f.value=await _j()}catch(e){d.value=e instanceof Error?e.message:String(e)}}na(()=>{pe()});async function me(){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 pe(),de(),ue();let n=await GR(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 he(){l.value=null,u.value=null,de(),ue()}function ge(){v.value!==null&&Object.assign(o.host,jR(v.value)),fe(`host`)}function _e(){y.value!==null&&Object.assign(o.backups,MR(y.value)),fe(`backups`)}function ve(){if(p.value!==null){let e=OR(p.value);o.control.label=e.label,o.control.port=e.port,o.control.host=e.host,o.control.openBrowser=e.openBrowser}fe(`control`)}function ye(){p.value!==null&&Object.assign(o.auth,DR(p.value.auth)),fe(`control`)}function be(){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=TR(e.health),o.defaults.stop={...e.stop},fe(`defaults`))}function xe(){h.value!==null&&Object.assign(o.logs,h.value),fe(`logs`)}function Se(){g.value!==null&&Object.assign(o.telegram,kR(g.value)),fe(`telegram`)}function Ce(){p.value!==null&&(o.control.tlsEnabled=p.value.tls.enabled),fe(`control`)}function we(e){rr(()=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})})}function Te(e){s.value=e,n.query.section!==e&&r.replace({query:{...n.query,section:e}}),we(e)}jr(()=>n.query.section,e=>{let n=typeof e==`string`?e:``;t.some(e=>e.id===n)&&(s.value=n,we(n))},{immediate:!0});let Ee=null;return na(()=>{Ee=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&&Ee.observe(t)}}),aa(()=>Ee?.disconnect()),(e,n)=>(I(),L(F,null,[z(`div`,yW,[z(`div`,bW,[n[24]||=z(`header`,{class:`mb-5`},[z(`h1`,{class:`text-xl font-semibold tracking-tight text-ink`},` Settings `),z(`p`,{class:`mt-1 text-xs text-muted`},` Listener, access, defaults, retention, alerts, backups and paths for this panel. `)],-1),j(i).configError.value?(I(),R(SH,{key:0,tone:`danger`,title:`The config file could not be read`,class:`mb-4`},{default:M(()=>[z(`p`,null,O(j(i).configError.value),1),n[13]||=z(`p`,{class:`mt-1`},` The panel keeps running the config it already had; fixing the file reloads it on its own. `,-1)]),_:1})):d.value?(I(),R(SH,{key:1,tone:`warn`,title:`Some file-only values could not be loaded`,class:`mb-4`},{default:M(()=>[V(O(d.value),1)]),_:1})):H(``,!0),z(`div`,xW,[z(`nav`,SW,[z(`ul`,CW,[(I(),L(F,null,ya(t,e=>z(`li`,{key:e.id},[z(`button`,{type:`button`,"aria-current":s.value===e.id?`true`:void 0,class:D(j(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=>Te(e.id)},O(e.title),11,wW)])),64))])]),z(`div`,TW,[z(`section`,EW,[n[14]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Listener `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Where the control panel listens and how it announces itself. `)],-1),B(AU,{control:o.control,"onUpdate:control":n[0]||=e=>o.control=e,view:p.value,dirty:ne.value,onReset:ve},null,8,[`control`,`view`,`dirty`])]),z(`section`,DW,[n[15]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Authentication `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Who may sign in, and how a session is trusted. `)],-1),B(TH,{auth:o.auth,"onUpdate:auth":n[1]||=e=>o.auth=e,view:p.value,dirty:ie.value,onReset:ye},null,8,[`auth`,`view`,`dirty`])]),z(`section`,OW,[n[16]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Server defaults `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Applied to every entry that does not set its own value. `)],-1),B(pU,{defaults:o.defaults,"onUpdate:defaults":n[2]||=e=>o.defaults=e,dirty:ae.value,onReset:be},null,8,[`defaults`,`dirty`])]),z(`section`,kW,[n[17]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Logs `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` How much output is kept on disk and for how long. `)],-1),B(FU,{logs:o.logs,"onUpdate:logs":n[3]||=e=>o.logs=e,"logs-dir":j(i).appState.value?.logsDir??null,dirty:oe.value,onReset:xe},null,8,[`logs`,`logs-dir`,`dirty`])]),z(`section`,AW,[n[18]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Notifications `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Crash and health alerts sent to a Telegram chat. `)],-1),B(UU,{telegram:o.telegram,"onUpdate:telegram":n[4]||=e=>o.telegram=e,status:g.value,dirty:se.value,onReset:Se},null,8,[`telegram`,`status`,`dirty`])]),z(`section`,jW,[n[19]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Host vitals `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Alert thresholds for this machine's own resources. `)],-1),B(gU,{host:o.host,"onUpdate:host":n[5]||=e=>o.host=e,config:v.value,alerts:_.value,dirty:ce.value,onReset:ge},null,8,[`host`,`config`,`alerts`,`dirty`])]),z(`section`,MW,[n[20]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Backups `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Archives of config, secrets and declared data paths. `)],-1),B(dU,{form:o.backups,"onUpdate:form":n[6]||=e=>o.backups=e,state:x.value,policy:y.value,"config-path":S.value,dirty:le.value,onReset:_e},null,8,[`form`,`state`,`policy`,`config-path`,`dirty`])]),z(`section`,NW,[n[21]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` TLS `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Serve the panel over HTTPS with your own certificate. `)],-1),B(vW,{"tls-enabled":o.control.tlsEnabled,"onUpdate:tlsEnabled":n[7]||=e=>o.control.tlsEnabled=e,view:p.value,dirty:re.value,onReset:Ce},null,8,[`tls-enabled`,`view`,`dirty`])]),z(`section`,PW,[n[22]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Interface `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Serve your own panel UI instead of the stock one. `)],-1),B(wU,{label:o.control.label,"onUpdate:label":n[8]||=e=>o.control.label=e,ui:b.value,"label-dirty":ne.value,onChanged:pe,onResetLabel:ve},null,8,[`label`,`ui`,`label-dirty`])]),z(`section`,FW,[n[23]||=z(`header`,{class:`mb-3`},[z(`h2`,{class:`text-lg font-semibold text-ink`},` Paths `),z(`p`,{class:`mt-0.5 text-xs text-muted`},` Where home-hosted keeps its files. `)],-1),B(XU,{"config-path":S.value,"data-root":j(i).appState.value?.dataRoot??null,"logs-dir":j(i).appState.value?.logsDir??null,"project-dir":j(i).appState.value?.projectDir??null,"panel-url":p.value?.url??null},null,8,[`config-path`,`data-root`,`logs-dir`,`project-dir`,`panel-url`])])])])]),z(`div`,IW,[z(`div`,LW,[z(`div`,RW,[z(`p`,zW,[w.value>0?(I(),L(`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=>te.value=!0},[z(`span`,BW,O(w.value),1),V(` field`+O(w.value===1?``:`s`)+` changed `,1)])):(I(),L(F,{key:1},[V(` No unsaved changes `)],64))]),l.value?(I(),L(`p`,VW,O(l.value),1)):u.value?(I(),L(`p`,HW,O(u.value),1)):H(``,!0)]),z(`div`,UW,[B($,{variant:`ghost`,disabled:w.value===0||c.value,onClick:he},{default:M(()=>[...n[25]||=[V(` Discard changes `,-1)]]),_:1},8,[`disabled`]),B($,{variant:`primary`,disabled:w.value===0,loading:c.value,onClick:me},{default:M(()=>[...n[26]||=[V(` Save settings `,-1)]]),_:1},8,[`disabled`,`loading`])])])])]),B(dL,{open:te.value,"onUpdate:open":n[12]||=e=>te.value=e,title:`Unsaved changes`,description:`What Save would write to servers.config.json.`,width:`w-[min(92vw,42rem)]`},{default:M(()=>[z(`div`,WW,[ee.value.length>0?(I(),L(`ul`,GW,[(I(!0),L(F,null,ya(ee.value,e=>(I(),L(`li`,{key:e.path,class:`flex flex-wrap items-baseline gap-x-3 gap-y-1 py-2 first:pt-0`},[z(`code`,KW,O(e.path),1),z(`span`,qW,O(j(jI)(e.from)),1),n[27]||=z(`span`,{class:`text-2xs text-faint`},`→`,-1),z(`span`,JW,O(j(jI)(e.to)),1)]))),128))])):(I(),L(`p`,YW,` Nothing to save. `))]),z(`footer`,XW,[B($,{size:`sm`,variant:`ghost`,onClick:n[10]||=e=>te.value=!1},{default:M(()=>[...n[28]||=[V(` Close `,-1)]]),_:1}),B($,{size:`sm`,variant:`primary`,disabled:ee.value.length===0||c.value,loading:c.value,onClick:n[11]||=e=>{me(),te.value=!1}},{default:M(()=>[V(` Save `+O(ee.value.length)+` change`+O(ee.value.length===1?``:`s`),1)]),_:1},8,[`disabled`,`loading`])])]),_:1},8,[`open`])],64))}}),QW=Cv({history:G_(),routes:[{path:`/`,name:`overview`,component:wV,meta:{title:`Overview`}},{path:`/servers`,name:`servers`,component:vH,meta:{title:`Servers`}},{path:`/servers/:id`,name:`server-detail`,component:fH,meta:{title:`Server`}},{path:`/logs`,name:`logs`,component:BL,meta:{title:`Logs`}},{path:`/settings`,name:`settings`,component:ZW,meta:{title:`Settings`}},{path:`/login`,name:`login`,component:lI,meta:{title:`Sign in`}},{path:`/:pathMatch(.*)*`,redirect:`/`}]});QW.beforeEach(async e=>{let{session:t,refresh:n}=Jj();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}),bu(RF).use(QW).mount(`#app`);