home-hosted 0.7.2 → 0.7.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}`,Yw=(e,t)=>`The intersection of two ordered unions is indeterminate:
36
36
  Left: ${e}
37
37
  Right: ${t}`,Xw={implementation:_S({kind:`unit`,hasAssociatedError:!0,keys:{unit:{preserveUndefined:!0,serialize:e=>e instanceof Date?e.toISOString():hS(e)}},normalize:e=>e,defaults:{description:e=>Dx(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)=>VS.init(`unit`,e,t),...hw(`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:J.intrinsic.object;if(e.domain!==t.domain){let n=e.domain===`undefined`||e.domain===`null`||e.domain===`boolean`?e.domain:J.intrinsic[e.domain];return VS.init(`domain`,n,t)}}return VS.init(`assignability`,e,t.hasKind(`intersection`)?t.children.find(t=>!t.allows(e.unit)):t)})}}),Node:class extends Sw{compiledValue=this.json.unit;serializedValue=typeof this.unit==`string`||this.unit instanceof Date?JSON.stringify(this.compiledValue):`${this.compiledValue}`;compiledCondition=Zw(this.unit,this.serializedValue);compiledNegation=Zw(this.unit,this.serializedValue,`negated`);expression=Dx(this.unit);domain=Zy(this.unit);get defaultShortDescription(){return this.domain===`object`?Qy.object:this.description}innerToJsonSchema(e){return this.unit===null?{type:`null`}:J.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}},Zw=(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}`},Qw={implementation:_S({kind:`index`,hasAssociatedError:!1,intersectionIsOpen:!0,keys:{signature:{child:!0,parse:(e,t)=>{let n=t.$.parseSchema(e);if(!n.extends(J.intrinsic.key))return q(eT(n.expression));let r=n.branches.filter(e=>e.hasKind(`unit`));return r.length?q($w(r.map(e=>Dx(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=JS(e.value,t.value,n),i=r instanceof VS?J.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 $S{impliedBasis=J.intrinsic.object.internal;expression=`[${this.signature.expression}]: ${this.value.expression}`;flatRefs=Wy(this.value.flatRefs.map(e=>LS([this.signature,...e.path],e.node)),LS([this.signature],this.value));traverseAllows=(e,t)=>hb(e).every(e=>!this.signature.traverseAllows(e[0],t)||AS(e[0],()=>this.value.traverseAllows(e[1],t),t));traverseApply=(e,t)=>{for(let n of hb(e))this.signature.traverseAllows(n[0],t)&&AS(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(){}}},$w=e=>`Index keys ${e.join(`, `)} should be specified as named props.`,eT=e=>`Indexed key definition '${e}' must be a string or symbol`,tT={implementation:_S({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:XC,optional:XC}}),Node:class extends ZC{expression=`${this.compiledKey}: ${this.value.expression}`;errorContext=Object.freeze({code:`required`,missingValueDescription:this.value.defaultShortDescription,relativePath:[this.key],meta:this.meta});compiledErrorContext=gS(this.errorContext)}},nT=_S({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 rw(n,e[1],null),[n,e[1]]})},serialize:e=>e.map(e=>[e[0].collapsibleJson,hS(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 q(uT);if(e.optionals?.length||e.defaultables?.length)return q(lT)}return e.minVariadicLength&&!e.variadic?q(`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} = ${Dx(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=dT({l:e.tuple,r:t.tuple,disjoint:new VS,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`,cT(i[0].result)):n.$.node(`union`,i.map(e=>({proto:Array,sequence:cT(e.result)})))}}}),rT=class extends $S{impliedBasis=J.intrinsic.Array.internal;tuple=sT(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=Gy(this.variadic&&[this.variadic],this.postfix);flatRefs=this.addFlatRefs();addFlatRefs(){return zS(this.flatRefs,this.prevariadic.flatMap((e,t)=>Wy(e.node.flatRefs.map(e=>LS([`${t}`,...e.path],e.node)),LS([`${t}`],e.node)))),zS(this.flatRefs,this.variadicOrPostfix.flatMap(e=>Wy(e.flatRefs.map(e=>LS([J.intrinsic.nonNegativeIntegerString.internal,...e.path],e.node)),LS([J.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=aT(this);defaultValueMorphsReference=this.defaultValueMorphs.length?Gx(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??tb(`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++)AS(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(J.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=J.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}},iT={},aT=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(nw(i,r,a)),n+=`${i}: ${r.id} = ${hS(a)}, `}return n+=`]`,iT[n]??=t},oT={implementation:nT,Node:rT},sT=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},cT=e=>e.reduce((e,t)=>(t.kind===`variadic`?e.variadic=t.node:t.kind===`defaultables`?e.defaultables=Wy(e.defaultables,[[t.node,t.default]]):e[t.kind]=Wy(e[t.kind],t.node),e),{}),lT=`A postfix required element cannot follow an optional or defaultable element`,uT=`A postfix element requires a variadic element`,dT=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=dT({...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=dT({...e,fixedVariants:[],l:n.map(e=>({...e,kind:`prefix`}))});t.disjoint.length===0&&e.fixedVariants.push(t)}let c=JS(t.node,r.node,e.ctx);if(c instanceof VS){if(s===`prefix`||s===`postfix`)e.disjoint.push(...c.withPrefixKey(s===`prefix`?e.result.length:`-${n.length+1}`,fT(t)&&fT(r)?`required`:`optional`)),e.result=[...e.result,{kind:s,node:J.intrinsic.never.internal}];else if(s===`optionals`||s===`defaultables`)return e;else return dT({...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&&q(QC(t.default,r.default)),e.result=[...e.result,{kind:s,node:c,default:t.kind===`defaultables`?t.default:r.kind===`defaultables`?r.default:tb(`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),dT(e)},fT=e=>e.kind===`prefix`||e.kind===`postfix`,pT=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??`{}`},mT=pT(`description`),hT=pT(`expression`),gT=(e,t,n)=>{let r=e.required?`required`:`optional`;if(!t.signature.allows(e.key))return null;let i=KS(e.value,t.value,n);return i instanceof VS?r===`optional`?n.node(`optional`,{key:e.key,value:J.intrinsic.never.internal}):i.withPrefixKey(e.key,e.kind):null},_T=_S({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:tC(`required`),reduceIo:(e,t,n)=>{t.required=Wy(t.required,n.map(t=>e===`in`?t.rawIn:t.rawOut))}},optional:{child:!0,parse:tC(`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]=Wy(t[e.outProp.kind],e.outProp.rawOut)}},index:{child:!0,parse:tC(`index`)},sequence:{child:!0,parse:tC(`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:mT},intersections:{structure:(e,t,n)=>{let r={...e.inner},i={...t.inner},a=new VS;if(e.undeclared){let r=e.keyof();for(let e of t.requiredKeys)r.allows(e)||a.add(`presence`,J.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=KS(r,e.signature,n.$);if(t instanceof VS)return[];let a=ET(t,e.value,n.$);return a.required&&(i.required=Gy(i.required,a.required)),a.optional&&(i.optional=Gy(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,J.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=KS(i,e.signature,n.$);if(t instanceof VS)return[];let a=ET(t,e.value,n.$);return a.required&&(r.required=Gy(r.required,a.required)),a.optional&&(r.optional=Gy(r.optional,a.optional)),a.index??[]})}let o={};(e.undeclared||t.undeclared)&&(o.undeclared=e.undeclared===`reject`||t.undeclared===`reject`?`reject`:`delete`);let s=nC({kind:`structure`,baseInner:o,l:rC(r),r:rC(i),roots:[],ctx:n});return s instanceof VS&&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&&q(kT(i.key)),n[i.key]=!0,e.index)for(let n of e.index){let e=gT(i,n,t);if(e instanceof VS)return e}}if(e.optional)for(let a=0;a<e.optional.length;a++){let o=e.optional[a];if(o.key in n&&q(kT(o.key)),n[o.key]=!0,e.index)for(let n of e.index){let e=gT(o,n,t);if(e instanceof VS)return e;e!==null&&(i[a]=e,r=!0)}}if(r)return t.node(`structure`,{...e,optional:i},{prereduced:!0})}}),vT=class extends $S{impliedBasis=J.intrinsic.object.internal;impliedSiblings=this.children.flatMap(e=>e.impliedSiblings??[]);props=Gy(this.required,this.optional);propsByKey=ab(this.props,(e,t)=>[t.key,t]);propsByKeyReference=Gx(this.propsByKey);expression=hT(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(tS(t))return t.kind!==`required`&&t.kind!==`optional`?q(`Map result must have kind "required" or "optional" (was ${t.kind})`):(e[t.kind]=Wy(e[t.kind],t),e);let r=t.kind??n?.kind??`required`,i=ab(t,(e,t)=>e in $C.implementation.keys?[e,t]:[]);return e[r]=Wy(e[r],this.$.node(r,i)),e},{}))}assertHasKeys(e){let t=e.filter(e=>!dw(e,this.keyof()));if(t.length)return q(OT(this.expression,t))}get(e,...t){let n,r=!1,i=wT(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)dw(i,e.signature)&&(n=n?.and(e.value)??e.value);if(this.sequence&&dw(i,J.intrinsic.nonNegativeIntegerString)){if(eS(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&&eS(i,`root`)&&i.extends(J.intrinsic.number)?q(TT(i.expression,this.sequence.expression)):q(OT(this.expression,[i]));let a=n.get(...t);return r?a:a.or(J.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=Wy(t.required,e.required)),e.optional&&(t.optional=Wy(t.optional,e.optional)),e.index&&(t.index=Wy(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=>dw(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(!AS(o,()=>i.value.traverseAllows(t[o],n),n))return!1}else if(AS(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&&J.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`,xT(this))}structuralMorphRef=this.structuralMorph&&Gx(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([`),ST(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 vS.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=J.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(J.intrinsic.string)){e.additionalProperties=r;continue}for(let i of n.signature.branches){if(!i.extends(J.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 tb(`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}},yT={},bT=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+=sE.nonNegativeIntegerString.id;else for(let n=0;n<e.sequence.tuple.length;n++)t+=n+` | `}t+=`)`}return t},xT=e=>{let t=bT(e);return t?yT[t]?yT[t]:yT[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},ST=(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`)})},CT={implementation:_T,Node:vT},wT=e=>(eS(e,`root`)&&e.hasKind(`unit`)&&(e=e.unit),typeof e==`number`&&(e=`${e}`),e),TT=(e,t)=>`${e} is not allowed as an array index on ${t}. Use the 'nonNegativeIntegerString' keyword instead.`,ET=(e,t,n)=>{let[r,i]=By(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]=Wy(a[r.kind],r)}return i.length&&(a.index=n.node(`index`,{signature:i,value:t})),a},DT=e=>eS(e,`root`)?e.expression:Dx(e),OT=(e,t)=>`Key${t.length===1?``:`s`} ${t.map(DT).join(`, `)} ${t.length===1?`does`:`do`} not exist on ${e}`,kT=e=>`Duplicate key ${qx(e)}`,AT={...FC,alias:xw.implementation,domain:Cw.implementation,unit:Xw.implementation,proto:kw.implementation,union:zw.implementation,morph:Dw.implementation,intersection:ww.implementation,divisor:fC.implementation,pattern:LC.implementation,predicate:dC.implementation,required:tT.implementation,optional:$C.implementation,index:Qw.implementation,sequence:oT.implementation,structure:CT.implementation};J.defaultConfig=_b(Object.assign(ab(AT,(e,t)=>[e,t.defaults]),{jitless:Bb(),clone:Pb,onUndeclaredKey:`ignore`,exactOptionalPropertyTypes:!0,numberAllowsNaN:!1,dateAllowsInvalid:!1,onFail:null,keywords:{},toJsonSchema:vS.defaultConfig})),J.resolvedConfig=yS(J.defaultConfig,J.config);var jT={...IC,alias:xw.Node,domain:Cw.Node,unit:Xw.Node,proto:kw.Node,union:zw.Node,morph:Dw.Node,intersection:ww.Node,divisor:fC.Node,pattern:LC.Node,predicate:dC.Node,required:tT.Node,optional:$C.Node,index:Qw.Node,sequence:oT.Node,structure:CT.Node},MT=class extends lb{get[$x](){return`module`}},NT=(e,t)=>new MT(ab(e,(e,n)=>[e,eS(n,`module`)?NT(n,t):t.bindReference(n)])),PT=e=>Db(e)?e:`branches`in e&&Db(e.branches)?e.branches:void 0,FT=(e,t)=>q(`Node of kind ${t} is not valid as a ${e} definition`),IT=e=>`#${e} duplicates public alias ${e}`,LT={};J.ambient??={};var RT,zT=`function $`,BT=e=>VT(e,HT(e)),VT=(e,t,n)=>{let r=t.write(zT,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)},HT=e=>new Kx().return(e.reduce((e,t)=>{let n=new Zx({kind:`Allows`}).indent();t.compile(n);let r=n.write(`${t.id}Allows`),i=new Zx({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 Zx({kind:`Allows`,optimistic:!0}).indent();return t.compile(o),`${a}${o.write(`${t.id}Optimistic`)},\n`},`{
38
38
  `)+`}`),UT=class{config;resolvedConfig;name;get[$x](){return`scope`}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor(e,t){this.config=yS(J.config,t),this.resolvedConfig=yS(J.resolvedConfig,t),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(LT).length}`,this.name in LT&&q(`A Scope already named ${this.name} already exists`),LT[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&&q(IT(n)),this.aliases[n]=t):(n in this.aliases&&q(IT(e)),this.aliases[n]=t,this.exportedNames.push(n)),!eS(t,`module`)&&!eS(t,`generic`)&&!Lb(t)){let e=this.preparseOwnDefinitionFormat(t,{alias:n});this.resolutions[n]=eS(e,`root`)?this.bindReference(e):this.createParseContext(e).id}}RT??=this.node(`union`,{branches:[`string`,`number`,`object`,`bigint`,`symbol`,{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[RT.hash]=this.node(`intersection`,{},{prereduced:!0}),this.intrinsic=J.intrinsic?ab(J.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 lC(e,r?new cC(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(RC(e),e,t);preparseNode(e,t,n){let r=typeof e==`string`?e:RC(t,e);if(tS(t)&&t.kind===r)return t;if(r===`alias`&&!n?.prereduced){let{reference:e}=xw.implementation.normalize(t,this);if(e.startsWith(`$`)){let n=this.resolveRoot(e.slice(1));t=n,r=n.kind}}else if(r===`union`&&Xy(t,`object`)){let e=PT(t);e?.length===1&&(t=e[0],r=RC(t))}if(tS(t)&&t.kind===r)return t;let i=AT[r].normalize?.(t,this)??t;return tS(i)?i.kind===r?i:FT(r,i.kind):{...n,$:this,kind:r,def:i,prefix:n.alias??r}}bindReference(e){let t;return t=tS(e)?e.$===this?e:new e.constructor(e.attachments,this):e.$===this?e:new lC(e.params,e.bodyDef,e.$,this,e.hkt),this.resolved||Object.assign(this.referencesById,t.referencesById),t}resolveRoot(e){return this.maybeResolveRoot(e)??q(ZT(e))}maybeResolveRoot(e){let t=this.maybeResolve(e);if(!eS(t,`generic`))return t}maybeResolveSubalias(e){return qT(this.aliases,e)??qT(this.ambient,e)}get ambient(){return J.ambient}maybeResolve(e){let t=this.resolutions[e];if(t){if(typeof t!=`string`)return this.bindReference(t);let n=UC[t];if(eS(n,`root`))return this.resolutions[e]=n;if(eS(n,`context`)){if(n.phase===`resolving`)return this.node(`alias`,{reference:`$${e}`},{prereduced:!0});if(n.phase===`resolved`)return tb(`Unexpected resolved context for was uncached by its scope: ${Dx(n)}`);n.phase=`resolving`;let t=this.bindReference(this.parseOwnDefinitionFormat(n.def,n));return n.phase=`resolved`,UC[t.id]=t,UC[n.id]=t,this.resolutions[e]=t}return tb(`Unexpected nodesById entry for ${t}: ${Dx(n)}`)}let n=this.aliases[e]??this.ambient?.[e];return n?(n=this.normalizeRootScopeValue(n),eS(n,`generic`)?this.resolutions[e]=this.bindReference(n):eS(n,`module`)?(n.root||q($T(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??WC(e.prefix);return UC[t]=Object.assign(e,{[$x]:`context`,$:this,id:t,phase:`unresolved`})}traversal(e){return new kS(e,this.resolvedConfig)}import(...e){return new MT(ab(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]=eS(t,`module`)?NT(t,this):GT(this.maybeResolve(e))}for(let e of this.lazyResolutions)e.resolution;if(this._exportedResolutions=XT(this,this._exports),this._json=KT(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let e=HT(this.references);this.precompilation=e.write(zT,4),VT(this.references,e,this)}this.resolved=!0}return new MT(ab(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(tS(r))return this.bindReference(r);let i=this.createParseContext(r),a=GC(i),o=this.bindReference(a);return UC[i.id]=o};parse=(e,t={})=>this.finalize(this.parseDefinition(e,t));parseDefinition(e,t={}){if(eS(e,`root`))return this.bindReference(e);let n=this.preparseOwnDefinitionFormat(e,t);if(eS(n,`root`))return this.bindReference(n);let r=this.createParseContext(n);UC[r.id]=r;let i=this.bindReference(this.parseOwnDefinitionFormat(e,r));return i.isCyclic&&(i=qC(i,r.id)),UC[r.id]=i,i}finalize(e){return GT(e),!e.precompilation&&!this.resolvedConfig.jitless&&BT(e.references),e}},WT=class extends UT{parseOwnDefinitionFormat(e,t){return GC(t)}preparseOwnDefinitionFormat(e,t){return this.preparseNode(RC(e),e,t)}preparseOwnAliasEntry(e,t){return[e,t]}normalizeRootScopeValue(e){return e}},GT=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},KT=e=>ab(e,(e,t)=>[e,eS(t,`root`)||eS(t,`generic`)?t.json:eS(t,`module`)?KT(t):tb(`Unexpected resolution ${Dx(t)}`)]),qT=(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(!eS(i,`module`))return q(QT(r));let a=t.slice(n+1),o=i[a];if(o===void 0)return qT(i,a);if(eS(o,`root`)||eS(o,`generic`))return o;if(eS(o,`module`))return o.root??q($T(t));tb(`Unexpected resolution for alias '${t}': ${Dx(o)}`)},JT=(e,t)=>new WT(e,t),YT=new WT({}),XT=(e,t)=>{let n={};for(let r in t){let i=t[r];if(eS(i,`module`)){let t=ab(XT(e,i),(e,t)=>[`${r}.${e}`,t]);Object.assign(n,t)}else eS(i,`root`)||eS(i,`generic`)?n[r]=i:tb(`Unexpected scope resolution ${Dx(i)}`)}return n},ZT=e=>`'${e}' is unresolvable`,QT=e=>`'${e}' must reference a module to be accessed using dot syntax`,$T=e=>`Reference to submodule '${e}' must specify an alias`;YT.export();var eE=YT.schema,tE=YT.node;YT.defineSchema;var nE=YT.generic,rE=`^(?:0|[1-9]\\d*)$`;Gx(new RegExp(rE));var iE=JT({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();J.intrinsic={...iE};var aE=JT({integer:{domain:`number`,divisor:1},lengthBoundable:[`string`,Array],key:[`string`,`symbol`],nonNegativeIntegerString:{domain:`string`,pattern:rE}},{prereducedAliases:!0}).export();Object.assign(J.intrinsic,aE);var oE=JT({jsonPrimitive:[`string`,`number`,{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:`object`,index:{signature:`string`,value:`$jsonData`}},jsonData:[`$jsonPrimitive`,`$jsonObject`]},{prereducedAliases:!0}).export(),sE={...iE,...aE,...oE,emptyStructure:tE(`structure`,{},{prereduced:!0})};J.intrinsic={...sE};var cE=((e,t)=>new RegExp(e,t));Object.assign(cE,{as:cE});var lE=e=>typeof e==`string`&&e[0]===`d`&&(e[1]===`'`||e[1]===`"`)&&e[e.length-1]===e[1],uE=e=>e.toString()!==`Invalid Date`,dE=e=>e.slice(2,-1),fE=e=>`'${e}' could not be parsed by the Date constructor`,pE=(e,t)=>mE(e,t),mE=(e,t)=>{let n=new Date(e);if(uE(n))return n;let r=mx(e);if(r!==void 0){let e=new Date(r);if(uE(e))return e}return t?q(t===!0?fE(e):t):void 0},hE=eE({proto:`Array`,sequence:`string`,required:{key:`groups`,value:[`object`,{unit:void 0}]}}),gE=(e,t)=>{let n=e.scanner.shiftUntilEscapable(SE[xE[t]]);if(e.scanner.lookahead===``)return e.error(wE(n,t));if(e.scanner.shift(),t in bE){let r;try{r=new RegExp(n)}catch(e){q(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:hE}))}else if(sb(t,_E))e.root=e.ctx.$.node(`unit`,{unit:n});else{let t=pE(n,fE(n));e.root=e.ctx.$.node(`unit`,{meta:n,unit:t})}},_E={"'":1,'"':1},vE={"/":1,"'":1,'"':1},yE={"d'":`'`,'d"':`"`,"'":`'`,'"':`"`},bE={"/":`/`,"x/":`/`},xE={...yE,...bE},SE={"'":e=>e.lookahead===`'`,'"':e=>e.lookahead===`"`,"/":e=>e.lookahead===`/`},CE={'"':`double-quote`,"'":`single-quote`,"/":`forward slash`},wE=(e,t)=>`${t}${e} requires a closing ${CE[xE[t]]}`,TE=e=>`Private type references should not include '#'. Use '${e}' instead.`,EE=`Optional definitions like 'string?' are only valid as properties in an object or tuple`,DE=`Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple`,OE={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...Jb},kE=(e,t)=>e===`>`?t[0]===`=`?t[1]===`=`:t.trimStart()===``||sb(t.trimStart()[0],OE):e===`=`?t[0]!==`=`:e===`,`||e===`?`,AE=(e,t,n)=>jE(e,t,n,[]),jE=(e,t,n,r)=>{let i=n.parseUntilFinalizer();return r.push(i.root),i.finalizer===`>`?r.length===t.params.length?r:n.error(ME(e,t.names,r.map(e=>e.expression))):i.finalizer===`,`?jE(e,t,n,r):i.error(Bx(`>`))},ME=(e,t,n)=>`${e}<${t.join(`, `)}> requires exactly ${t.length} args (got ${n.length}${n.length===0?``:`: ${n.join(`, `)}`})`,NE=e=>{let t=e.scanner.shiftUntilLookahead(OE);t===`keyof`?e.addPrefix(`keyof`):e.root=FE(e,t)},PE=(e,t,n)=>(n.scanner.shiftUntilNonWhitespace(),n.scanner.shift()===`<`?t(...AE(e,t,n)):n.error(ME(e,t.names,[]))),FE=(e,t)=>IE(e,t)??LE(e,t)??e.error(t===``?e.scanner.lookahead===`#`?TE(e.shiftedBy(1).scanner.shiftUntilLookahead(OE)):RE(e):ZT(t)),IE=(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(eS(n,`root`))return n;if(n!==void 0)return eS(n,`generic`)?PE(t,n,e):q(`Unexpected resolution ${Dx(n)}`)},LE=(e,t)=>{let n=hx(t);if(n!==void 0)return e.ctx.$.node(`unit`,{unit:n});let r=vx(t);if(r!==void 0)return e.ctx.$.node(`unit`,{unit:r})},RE=e=>{let t=e.previousOperator();return t?zE(t,e.scanner.unscanned):BE(e.scanner.unscanned)},zE=(e,t=``)=>`Token '${e}' requires a right operand${t?` before '${t}'`:``}`,BE=e=>`Expected an expression${e?` before '${e}'`:``}`,VE=e=>e.scanner.lookahead===``?e.error(RE(e)):e.scanner.lookahead===`(`?e.shiftedBy(1).reduceGroupOpen():e.scanner.lookaheadIsIn(vE)?gE(e,e.scanner.shift()):e.scanner.lookaheadIsIn(Jb)?VE(e.shiftedBy(1)):e.scanner.lookahead===`d`?e.scanner.nextLookahead in _E?gE(e,`${e.scanner.shift()}${e.scanner.shift()}`):NE(e):e.scanner.lookahead===`x`&&e.scanner.nextLookahead===`/`?e.shiftedBy(2)&&gE(e,`x/`):NE(e),HE={">":!0,">=":!0},UE={"<":!0,"<=":!0},WE={"<":`>`,">":`<`,"<=":`>=`,">=":`<=`,"==":`==`},GE=(e,t)=>`Left bounds are only valid when paired with right bounds (try ...${t}${e})`,KE=e=>`Left-bounded expressions must specify their limits using < or <= (was ${e})`,qE=(e,t,n,r)=>`An expression may have at most one left bound (parsed ${e}${WE[t]}, ${n}${WE[r]})`,JE=(e,t)=>{let n=XE(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 $E(e,n)},YE={"<":1,">":1,"=":1},XE=(e,t)=>e.scanner.lookaheadIs(`=`)?`${t}${e.scanner.shift()}`:t,ZE=(e,t,n,r)=>n.extends(J.intrinsic.number)?typeof t==`number`?e===`==`?[`min`,`max`]:e[0]===`>`?[`min`]:[`max`]:q(eD(e,t,r)):n.extends(J.intrinsic.lengthBoundable)?typeof t==`number`?e===`==`?[`exactLength`]:e[0]===`>`?[`minLength`]:[`maxLength`]:q(eD(e,t,r)):n.extends(J.intrinsic.Date)?e===`==`?[`after`,`before`]:e[0]===`>`?[`after`]:[`before`]:q(DC(n.expression)),QE=e=>({rule:lE(e.limit)?dE(e.limit):e.limit,exclusive:e.comparator.length===1}),$E=(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(eD(t,a,`right`));let o=i.unit,s=t.length===1,c=ZE(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(!sb(t,UE))return e.error(KE(t));let l=ZE(e.branches.leftBound.comparator,e.branches.leftBound.limit,n,`left`);e.constrainRoot(l[0],QE(e.branches.leftBound)),e.branches.leftBound=null},eD=(e,t,n)=>`Comparator ${n===`left`?WE[e]:e} must be ${n===`left`?`preceded`:`followed`} by a corresponding literal (was ${t})`,tD=e=>{e.scanner.shiftUntilNonWhitespace();let t=e.scanner.shiftUntilLookahead(OE);e.root=e.root.brand(t)},nD=e=>{e.scanner.shiftUntilNonWhitespace();let t=e.scanner.shiftUntilLookahead(OE),n=gx(t,{errorOnFail:rD(t)});n===0&&e.error(rD(0)),e.root=e.root.constrain(`divisor`,n)},rD=e=>`% operator must be followed by a non-zero integer literal (was ${e})`,iD=e=>{let t=e.scanner.shift();return t===``?e.finalize(``):t===`[`?e.scanner.shift()===`]`?e.setRoot(e.root.array()):e.error(oD):t===`|`?e.scanner.lookahead===`>`?e.shiftedBy(1).pushRootToBranch(`|>`):e.pushRootToBranch(t):t===`&`?e.pushRootToBranch(t):t===`)`?e.finalizeGroup():kE(t,e.scanner.unscanned)?e.finalize(t):sb(t,YE)?JE(e,t):t===`%`?nD(e):t===`#`?tD(e):t in Jb?iD(e):e.error(aD(t))},aD=(e,t=``)=>`'${e}' is not allowed here${t&&` (should be ${t})`}`,oD=`Missing expected ']'`,sD=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(cD(n.expression))},cD=e=>`Default value '${e}' must be a literal value`,lD=(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 pD(new Rx(e),t),i=uD(r);return r.finalizer===`>`&&q(aD(`>`)),i},uD=e=>{e.parseOperand();let t=dD(e).root;return t?(e.finalizer===`=`?t=sD(e):e.finalizer===`?`&&(t=[t,`?`]),e.scanner.shiftUntilNonWhitespace(),e.scanner.lookahead&&q(aD(e.scanner.lookahead)),t):tb(`Root was unexpectedly unset after parsing string '${e.scanner.scanned}'`)},dD=e=>{for(;e.finalizer===void 0;)fD(e);return e},fD=e=>e.hasRoot()?e.parseOperator():e.parseOperand(),pD=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 q(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(Bx(`)`));this.finalizeBranches(),this.finalizer=e}reduceLeftBound(e,t){let n=WE[t];if(!sb(n,HE))return this.error(KE(t));if(this.branches.leftBound)return this.error(qE(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(zx(`)`,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():tb(`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 dD(new e(this.scanner,this.ctx))}parseOperator(){return iD(this)}parseOperand(){return VE(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(GE(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}},mD=`An empty string is not a valid generic parameter name`,hD=(e,t,n)=>{e.shiftUntilNonWhitespace();let r=e.shiftUntilLookahead(OE);return r===``?e.lookahead===``&&t.length?t:q(mD):(e.shiftUntilNonWhitespace(),_D(e,r,t,n))},gD=`extends `,_D=(e,t,n,r)=>{if(e.shiftUntilNonWhitespace(),e.unscanned.startsWith(gD))e.jumpForward(8);else return e.lookahead===`,`&&e.shift(),n.push(t),hD(e,n,r);let i=dD(new pD(e,r));return n.push([t,i.root]),hD(e,n,r)},vD=class extends zb{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 q(bD);o=e.parse(t[n+1])}return e=>new yD(e,a,o)};super(t,{attach:{$:e,raw:t}})}},yD=class extends zb{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`}`}},bD=`":" must be followed by exactly one return type e.g:
39
- fn("string", ":", "number")(s => s.length)`,xD=class extends zb{$;constructor(e){super((...t)=>new SD(e)(...t),{bind:e}),this.$=e}in(e){return new SD(this.$,e===void 0?void 0:this.$.parse(e))}at(e,t){return new SD(this.$).at(e,t)}case(e,t){return new SD(this.$).case(e,t)}},SD=class extends zb{$;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&&q(TD),this.branches.length&&q(wD),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&&q(`default may only be specified as the last key of a switch definition`),this.default(r);if(typeof r!=`function`)return q(`Value for case "${n}" must be a function (was ${Zy(r)})`);this.caseEntry(n,r)}return this}default(e){typeof e==`function`&&this.case(sE.unknown,e);let t={branches:this.branches,ordered:!0};(e===`never`||e===`assert`)&&(t.meta={onFail:CD});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:CD},`self`)),this.$.finalize(r)}},CD=e=>e.throw(),wD=`A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')`,TD=`At most one key matcher may be specified per expression`,ED=(e,t)=>{if(Db(e)){if(e[1]===`=`)return[t.$.parseOwnDefinitionFormat(e[0],t),`=`,e[2]];if(e[1]===`?`)return[t.$.parseOwnDefinitionFormat(e[0],t),`?`]}return lO(e,t)},DD=`Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }`,OD=`Only required keys may specify default values, e.g. { value: 'number = 0' }`,kD=(e,t)=>{let n,r={},i=hb(e);for(let[e,a]of i){let i=ND(e);if(i.kind===`spread`){if(!mb(r))return q(MD);let e=t.$.parseOwnDefinitionFormat(a,t);if(e.equals(sE.object))continue;if(!e.hasKind(`intersection`)||!e.basis?.equals(sE.object))return q(PD(e.expression));n=e.structure;continue}if(i.kind===`undeclared`){a!==`reject`&&a!==`delete`&&a!==`ignore`&&q(jD(a)),r.undeclared=a;continue}let o=ED(a,t),s=i;if(i.kind===`required`){Db(o)?AD(r,`optional`,o[1]===`=`?{key:i.normalized,value:o[0],default:o[2]}:{key:i.normalized,value:o[0]},t):AD(r,`required`,{key:i.normalized,value:o},t);continue}if(Db(o)&&(o[1]===`?`&&q(DD),o[1]===`=`&&q(OD)),i.kind===`optional`){AD(r,`optional`,{key:i.normalized,value:o},t);continue}let c=ET(t.$.parseOwnDefinitionFormat(s.normalized,t),o,t.$);c.index&&(r.index=Wy(r.index,c.index)),c.required&&(r.required=Wy(r.required,c.required))}let a=t.$.node(`structure`,r);return t.$.parseSchema({domain:`object`,structure:n?.merge(a)??a})},AD=(e,t,n,r)=>{e[t]=Wy(e[t],r.$.node(t,n))},jD=e=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${Dx(e)})`,MD=`Spread operator may only be used as the first key in an object`,ND=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},PD=e=>`Spread operand must resolve to an object literal type (was ${e})`,FD=(e,t)=>YD(e)?JD[e[0]](e,t):qD(e)?KD[e[1]](e,t):null,ID=(e,t)=>t.$.parseOwnDefinitionFormat(e[1],t).keyof(),LD=(e,t)=>{if(e[2]===void 0)return q(zE(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]===`&`?KS(n,r,t.$):qS(n,r,t.$);return i instanceof VS?i.throw():i},RD=(e,t)=>t.$.parseOwnDefinitionFormat(e[0],t).array(),zD=(e,t)=>typeof e[2]==`function`?t.$.parseOwnDefinitionFormat(e[0],t).pipe(e[2]):q(BD(`=>`,e[2])),BD=(e,t)=>`${e===`:`?`Narrow`:`Morph`} expression requires a function following '${e}' (was ${typeof t})`,VD=(e,t)=>typeof e[2]==`function`?t.$.parseOwnDefinitionFormat(e[0],t).constrain(`predicate`,e[2]):q(BD(`:`,e[2])),HD=(e,t)=>t.$.parseOwnDefinitionFormat(e[0],t).configure(e[2],e[3]),UD=e=>e,WD=UD({"[]":RD,"?":()=>q(EE)}),GD=UD({"|":LD,"&":LD,":":VD,"=>":zD,"|>":LD,"@":HD,"=":()=>q(DE)}),KD={...WD,...GD},qD=e=>KD[e[1]]!==void 0,JD=(e=>e)({keyof:ID,instanceof:(e,t)=>{if(typeof e[1]!=`function`)return q(XD(Eb(e[1])));let n=e.slice(1).map(e=>typeof e==`function`?t.$.node(`proto`,{proto:e}):q(XD(Eb(e))));return n.length===1?n[0]:t.$.node(`union`,{branches:n})},"===":(e,t)=>t.$.units(e.slice(1))}),YD=e=>JD[e[0]]!==void 0,XD=e=>`Expected a constructor following 'instanceof' operator (was ${e})`,ZD=(e,t)=>{let n=[{}],r=0;for(;r<e.length;){let i=!1;e[r]===`...`&&r<e.length-1&&(i=!0,r++);let a=ED(e[r],t),[o,s,c]=Db(a)?a:[a];if(r++,i){if(!o.extends(J.intrinsic.Array))return q(rO(o.expression));n=n.flatMap(e=>o.distribute(t=>nO(Qx(e),t)))}else n=n.map(e=>s===`?`?$D(e,o):s===`=`?eO(e,o,c):QD(e,o))}return t.$.parseSchema(n.map(e=>mb(e)?{proto:Array,exactLength:0}:{proto:Array,sequence:e}))},QD=(e,t)=>e.defaultables||e.optionals?q(e.variadic?lT:aO):(e.variadic?e.postfix=Wy(e.postfix,t):e.prefix=Wy(e.prefix,t),e),$D=(e,t)=>e.variadic?q(oO):(e.optionals=Wy(e.optionals,t),e),eO=(e,t,n)=>e.variadic?q(oO):e.optionals?q(sO):(e.defaultables=Wy(e.defaultables,[[t,n]]),e),tO=(e,t)=>(e.postfix&&q(iO),e.variadic?e.variadic.equals(t)||q(iO):e.variadic=t.internal,e),nO=(e,t)=>{let n=t.select({method:`find`,kind:`sequence`});if(!n)return tO(e,J.intrinsic.unknown);if(n.prefix)for(let t of n.prefix)QD(e,t);if(n.optionals)for(let t of n.optionals)$D(e,t);if(n.variadic&&tO(e,n.variadic),n.postfix)for(let t of n.postfix)QD(e,t);return e},rO=e=>`Spread element must be an array (was ${e})`,iO=`A tuple may have at most one variadic element`,aO=`A required element may not follow an optional element`,oO=`An optional element may not follow a variadic element`,sO=`A defaultable element may not follow an optional element without a default`,cO={},lO=(e,t)=>{if(typeof e==`string`){if(t.args&&Object.keys(t.args).some(t=>e.includes(t)))return lD(e,t);let n=cO[t.$.name]??={};return n[e]??=lD(e,t)}return Xy(e,`object`)?uO(e,t):q(pO(Zy(e)))},uO=(e,t)=>{let n=Tb(e);switch(n){case void 0:return eS(e,`root`)?e:`~standard`in e?dO(e,t):kD(e,t);case`Array`:return fO(e,t);case`RegExp`:return t.$.node(`intersection`,{domain:`string`,pattern:e},{prereduced:!0});case`Function`:{let t=Lb(e)?e():e;return eS(t,`root`)?t:q(pO(`Function`))}default:return q(pO(n??Dx(e)))}},dO=(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:Wb(e),relativePath:t.map(e=>typeof e==`object`?e.key:e)}):n.error({message:e})}),fO=(e,t)=>FD(e,t)??ZD(e,t),pO=e=>`Type definitions must be strings or objects (was ${e})`,mO=class extends zb{constructor(e){let t=Object.assign({errors:ES,hkt:Vb,$: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 lC(e.parseGenericParams(n,{}),t[1],e,e,null)}return e.parse(t)},{attach:t})}},hO=J,gO=class e extends UT{get ambientAttachments(){if(hO.typeAttachments)return this.cacheGetter(`ambientAttachments`,ab(hO.typeAttachments,(e,t)=>[e,this.bindReference(t)]))}preparseOwnAliasEntry(e,t){let n=e.indexOf(`<`);if(n===-1){if(eS(t,`module`)||eS(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]!==`>`&&q(`'>' 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,()=>sC(this.parseGenericParams(i,{alias:r}),t,this)]}parseGenericParams(e,t){return hD(new Rx(e),[],this.createParseContext({...t,def:e,prefix:`generic`}))}normalizeRootScopeValue(e){return Lb(e)&&!eS(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=lO(e,t);if(Db(n)){if(n[1]===`=`)return q(DE);if(n[1]===`?`)return q(EE)}return n}unit=e=>this.units([e]);valueOf=e=>this.units(yb(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 vD(this);match=new xD(this);declare=()=>({type:this.type});define(e){return e}type=new mO(this);static scope=((t,n={})=>new e(t,n));static module=((e,t={})=>this.scope(e,t).export())},_O=Object.assign(gO.scope,{define:e=>e}),vO=gO,yO=class extends Vb{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'},bO=nE([`base`,sE.object],[`props`,sE.object])(e=>e.base.merge(e.props),yO),xO=vO.module({Key:sE.key,Merge:bO}),SO=class extends Vb{},CO=nE(`element`)(e=>{let t=e.element.exclude(sE.Array),n=t.array();return t.rawOr(n).pipe(zy).distribute(e=>e.assertHasKind(`morph`).declareOut(n),eE)},SO),wO=vO.module({root:sE.Array,readonly:`root`,index:sE.nonNegativeIntegerString,liftFrom:CO},{name:`Array`}),TO=eE([`string`,yx.FileConstructor]),EO=eE({meta:`an object representing parsed form data`,domain:`object`,index:{signature:`string`,value:TO.rawOr(TO.array())}}),DO=vO.module({root:[`instanceof`,FormData],value:TO,parsed:EO,parse:eE({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 yx.FileConstructor?t[n]=[e,r]:e.push(r)}else t[n]=r;return t},declaredOut:EO})},{name:`FormData`}),OO=vO.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`}),kO={Boolean:1,Number:1,String:1},AO=vO.module({...ab({...bb,...Sb},(e,t)=>e in kO?[]:[e,[`instanceof`,t]]),Array:wO,TypedArray:OO,FormData:DO}),jO=eE({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`}),MO=eE({domain:`number`,divisor:1}),NO=vO.module({root:sE.number,integer:MO,epoch:jO,safe:eE({domain:{domain:`number`,numberAllowsNaN:!1},min:-(2**53-1),max:2**53-1}),NaN:[`===`,NaN],Infinity:[`===`,1/0],NegativeInfinity:[`===`,-1/0]},{name:`number`}),PO=(e,t,n)=>{let r={domain:`string`,pattern:{rule:e.source,flags:e.flags,meta:t}};return n&&(r.meta={format:n}),tE(`intersection`,r)},FO=PO(ax,`a well-formed integer string`),IO=vO.module({root:FO,parse:eE({in:FO,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:sE.integer})},{name:`string.integer`}),LO=PO(/^[\dA-Fa-f]+$/,`hex characters only`),RO=vO.module({root:PO(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,`base64-encoded`),url:PO(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,`base64url-encoded`)},{name:`string.base64`}),zO=PO(/^[A-Z].*$/,`capitalized`),BO=vO.module({root:eE({in:`string`,morphs:e=>e.charAt(0).toUpperCase()+e.slice(1),declaredOut:zO}),preformatted:zO},{name:`string.capitalize`}),VO=eE({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)}}}),HO=/^([+-]?\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)?)?)?)?$/,UO=eE({domain:`string`,predicate:{meta:`a parsable date`,predicate:e=>!Number.isNaN(new Date(e).valueOf())}}).assertHasKind(`intersection`),WO=IO.root.internal.narrow((e,t)=>{let n=Number.parseInt(e),r=NO.epoch(n);return r instanceof ES?(t.errors.merge(r),!1):!0}).configure({description:`an integer string representing a safe Unix timestamp`},`self`).assertHasKind(`intersection`),GO=vO.module({root:WO,parse:eE({in:WO,morphs:e=>new Date(e),declaredOut:sE.Date})},{name:`string.date.epoch`}),KO=PO(HO,`an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date`).internal.assertHasKind(`intersection`),qO=vO.module({root:KO,parse:eE({in:KO,morphs:e=>new Date(e),declaredOut:sE.Date})},{name:`string.date.iso`}),JO=vO.module({root:UO,parse:eE({declaredIn:UO,in:`string`,morphs:(e,t)=>{let n=new Date(e);return Number.isNaN(n.valueOf())?t.error(`a parsable date`):n},declaredOut:sE.Date}),iso:qO,epoch:GO},{name:`string.date`}),YO=PO(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,`an email address`,`email`),XO=`(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])`,ZO=`(${XO}[.]){3}${XO}`,QO=RegExp(`^${ZO}$`),$O=`(?:[0-9a-fA-F]{1,4})`,ek=RegExp(`^((?:${$O}:){7}(?:${$O}|:)|(?:${$O}:){6}(?:${ZO}|:${$O}|:)|(?:${$O}:){5}(?::${ZO}|(:${$O}){1,2}|:)|(?:${$O}:){4}(?:(:${$O}){0,1}:${ZO}|(:${$O}){1,3}|:)|(?:${$O}:){3}(?:(:${$O}){0,2}:${ZO}|(:${$O}){1,4}|:)|(?:${$O}:){2}(?:(:${$O}){0,3}:${ZO}|(:${$O}){1,5}|:)|(?:${$O}:){1}(?:(:${$O}){0,4}:${ZO}|(:${$O}){1,6}|:)|(?::((?::${$O}){0,5}:${ZO}|(?::${$O}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?\$`),tk=vO.module({root:[`v4 | v6`,`@`,`an IP address`],v4:PO(QO,`an IPv4 address`,`ipv4`),v6:PO(ek,`an IPv6 address`,`ipv6`)},{name:`string.ip`}),nk=`a JSON string`,rk=e=>{if(!(e instanceof SyntaxError))throw e;return`must be ${nk} (${e})`},ik=eE({meta:nk,domain:`string`,predicate:{meta:nk,predicate:(e,t)=>{try{return JSON.parse(e),!0}catch(e){return t.reject({code:`predicate`,expected:nk,problem:rk(e)})}}}}),ak=vO.module({root:ik,parse:eE({meta:`safe JSON string parser`,in:`string`,morphs:(e,t)=>{if(e.length===0)return t.error({code:`predicate`,expected:nk,actual:`empty`});try{return JSON.parse(e)}catch(e){return t.error({code:`predicate`,expected:nk,problem:rk(e)})}},declaredOut:sE.jsonObject})},{name:`string.json`}),ok=PO(/^[a-z]*$/,`only lowercase letters`),sk=vO.module({root:eE({in:`string`,morphs:e=>e.toLowerCase(),declaredOut:ok}),preformatted:ok},{name:`string.lower`}),ck=[`NFC`,`NFD`,`NFKC`,`NFKD`],lk=ab(ck,(e,t)=>[t,eE({domain:`string`,predicate:e=>e.normalize(t)===e,meta:`${t}-normalized unicode`})]),uk=ab(ck,(e,t)=>[t,eE({in:`string`,morphs:e=>e.normalize(t),declaredOut:lk[t]})]),dk=vO.module({root:uk.NFC,preformatted:lk.NFC},{name:`string.normalize.NFC`}),fk=vO.module({root:uk.NFD,preformatted:lk.NFD},{name:`string.normalize.NFD`}),pk=vO.module({root:uk.NFKC,preformatted:lk.NFKC},{name:`string.normalize.NFKC`}),mk=vO.module({root:uk.NFKD,preformatted:lk.NFKD},{name:`string.normalize.NFKD`}),hk=vO.module({root:`NFC`,NFC:dk,NFD:fk,NFKC:pk,NFKD:mk},{name:`string.normalize`}),gk=PO(nx,`a well-formed numeric string`),_k=vO.module({root:gk,parse:eE({in:gk,morphs:e=>Number.parseFloat(e),declaredOut:sE.number})},{name:`string.numeric`}),vk=`a regex pattern`,yk=eE({domain:`string`,predicate:{meta:vk,predicate:(e,t)=>{try{return new RegExp(e),!0}catch(e){return t.reject({code:`predicate`,expected:vk,problem:String(e)})}}},meta:{format:`regex`}}),bk=PO(/^(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/)`),xk=PO(/^\S.*\S$|^\S?$/,`trimmed`),Sk=vO.module({root:eE({in:`string`,morphs:e=>e.trim(),declaredOut:xk}),preformatted:xk},{name:`string.trim`}),Ck=PO(/^[A-Z]*$/,`only uppercase letters`),wk=vO.module({root:eE({in:`string`,morphs:e=>e.toUpperCase(),declaredOut:Ck}),preformatted:Ck},{name:`string.upper`}),Tk=eE({domain:`string`,predicate:{meta:`a URL string`,predicate:e=>URL.canParse(e)},meta:{format:`uri`}}),Ek=vO.module({root:Tk,parse:eE({declaredIn:Tk,in:`string`,morphs:(e,t)=>{try{return new URL(e)}catch{return t.error(`a URL string`)}},declaredOut:eE(URL)})},{name:`string.url`}),Dk=vO.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:PO(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv1`),v2:PO(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv2`),v3:PO(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv3`),v4:PO(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv4`),v5:PO(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv5`),v6:PO(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv6`),v7:PO(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv7`),v8:PO(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv8`)},{name:`string.uuid`}),Ok=vO.module({root:sE.string,alpha:PO(/^[A-Za-z]*$/,`only letters`),alphanumeric:PO(/^[\dA-Za-z]*$/,`only letters and digits 0-9`),hex:LO,base64:RO,capitalize:BO,creditCard:VO,date:JO,digits:PO(/^\d*$/,`only digits 0-9`),email:YO,integer:IO,ip:tk,json:ak,lower:sk,normalize:hk,numeric:_k,regex:yk,semver:bk,trim:Sk,upper:wk,url:Ek,uuid:Dk},{name:`string`}),kk=vO.module({bigint:sE.bigint,boolean:sE.boolean,false:sE.false,never:sE.never,null:sE.null,number:sE.number,object:sE.object,string:sE.string,symbol:sE.symbol,true:sE.true,unknown:sE.unknown,undefined:sE.undefined}),Ak=vO.module({root:sE.unknown,any:sE.unknown},{name:`unknown`}),jk=vO.module({root:sE.jsonObject,stringify:tE(`morph`,{in:sE.jsonObject,morphs:e=>JSON.stringify(e),declaredOut:sE.string})},{name:`object.json`}),Mk=vO.module({root:sE.object,json:jk},{name:`object`}),Nk=class extends Vb{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'},Pk=nE([`K`,sE.key],`V`)(e=>({domain:`object`,index:{signature:e.K,value:e.V}}),Nk),Fk=class extends Vb{description='pick a set of properties from an object like `Pick(User, "name | age")`'},Ik=nE([`T`,sE.object],[`K`,sE.key])(e=>e.T.pick(e.K),Fk),Lk=class extends Vb{description='omit a set of properties from an object like `Omit(User, "age")`'},Rk=nE([`T`,sE.object],[`K`,sE.key])(e=>e.T.omit(e.K),Lk),zk=class extends Vb{description="make all named properties of an object optional like `Partial(User)`"},Bk=nE([`T`,sE.object])(e=>e.T.partial(),zk),Vk=class extends Vb{description="make all named properties of an object required like `Required(User)`"},Hk=nE([`T`,sE.object])(e=>e.T.required(),Vk),Uk=class extends Vb{description='exclude branches of a union like `Exclude("boolean", "true")`'},Wk=nE(`T`,`U`)(e=>e.T.exclude(e.U),Uk),Gk=class extends Vb{description='extract branches of a union like `Extract("0 | false | 1", "number")`'},Kk=nE(`T`,`U`)(e=>e.T.extract(e.U),Gk),qk=vO.module({Exclude:Wk,Extract:Kk,Omit:Rk,Partial:Bk,Pick:Ik,Record:Pk,Required:Hk}),Jk=_O({...kk,...qk,...AO,...xO,string:Ok,number:NO,object:Mk,unknown:Ak},{prereducedAliases:!0,name:`ark`}),Yk=Jk.export();Object.assign(hO.ambient,Yk),hO.typeAttachments={string:Yk.string.root,number:Yk.number.root,bigint:Yk.bigint,boolean:Yk.boolean,symbol:Yk.symbol,undefined:Yk.undefined,null:Yk.null,object:Yk.object.root,unknown:Yk.unknown.root,false:Yk.false,true:Yk.true,never:Yk.never,arrayIndex:Yk.Array.index,Key:Yk.Key,Record:Yk.Record,Array:Yk.Array.root,Date:Yk.Date};var Y=Object.assign(Jk.type,hO.typeAttachments);Jk.match,Jk.fn,Jk.generic,Jk.schema,Jk.define,Jk.declare;var Xk=Y(`"local" | "lan" | /^\\d{1,3}(?:\\.\\d{1,3}){3}$/`),Zk=Y(`/^[a-z0-9][a-z0-9_-]*$/`);Y({id:Zk,label:`1 <= string <= 60`}).onUndeclaredKey(`reject`),Y({"id?":Zk,"label?":`1 <= string <= 60`}).onUndeclaredKey(`reject`),Y({label:`1 <= string <= 60`}).onUndeclaredKey(`reject`);function Qk(e){let t=Xk(e);return t instanceof Y.errors?null:t}var $k=Y(`1 <= number.integer <= 65535 | null`),eA=Y.enumerated(`block`,`warn`,`follow`,`reclaim`,`kill`),tA=eA.default(`block`),nA=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`),rA=Y({path:`string = "/"`,method:`"GET" | "HEAD" = "GET"`,expectStatus:`number.integer | null?`,expectStatusBelow:`number.integer = 400`,expectBody:`string = ""`}).onUndeclaredKey(`reject`),iA=Y({maxRssBytes:`number.integer >= 0 = 0`}).onUndeclaredKey(`reject`),aA=Y({enabled:`boolean = true`,mode:`"port" | "http" = "port"`,http:rA.default(()=>({})),intervalMs:`number >= 500 = 5000`,timeoutMs:`number >= 100 = 1500`,unhealthyThreshold:`number.integer >= 1 = 3`,forceRestartAfterMs:`number >= 0 = 0`,startTimeoutMs:`number >= 0 = 20000`}).onUndeclaredKey(`reject`),oA=Y({signal:`"SIGTERM" | "SIGINT" | "SIGKILL" = "SIGTERM"`,killGroup:`boolean = true`,graceMs:`number >= 0 = 5000`,killPortHolders:`boolean = false`}).onUndeclaredKey(`reject`),sA=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`)),cA=Y(`50 <= number.integer <= 100000`),lA=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:sA.optional(),port:$k.optional(),bind:Xk.default(()=>`local`),onPortConflict:tA,restart:nA.default(()=>({})),health:aA.default(()=>({})),stop:oA.default(()=>({})),logBufferLines:cA.default(()=>500),dependsOn:Y(`string[]`).default(()=>[]),envFile:`string = ""`,resources:iA.default(()=>({})),backupPaths:Y(`string[]`).default(()=>[]),backupIgnoreGenerated:`boolean = true`}).onUndeclaredKey(`reject`),uA=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`,onDdns:`boolean = true`,cooldownMs:`number >= 0 = 120000`}).onUndeclaredKey(`reject`).default(()=>({}))}).onUndeclaredKey(`reject`);var dA=Y({persist:`boolean = true`,maxBytes:`10000 <= number <= 100000000 = 2000000`,keep:`1 <= number.integer <= 10 = 3`}).onUndeclaredKey(`reject`),fA=Y({enabled:`boolean = false`}).onUndeclaredKey(`reject`),pA=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`),mA=Y.enumerated(`A`,`AAAA`),hA=Y({id:`/^[a-z0-9][a-z0-9_-]*$/`,provider:`string >= 1`,label:`string = ""`}).onUndeclaredKey(`reject`),gA=Y({host:`/^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/`,account:`string >= 1`,types:mA.array().default(()=>[`A`]),zone:`string?`,ttl:`number.integer >= 1?`,proxied:`boolean = false`,enabled:`boolean = true`}).onUndeclaredKey(`reject`),_A=Y({enabled:`boolean = true`,url:`string = ""`}).onUndeclaredKey(`reject`),vA=Y({enabled:`boolean = false`,url:`string = ""`}).onUndeclaredKey(`reject`),yA=Y({enabled:`boolean = false`,intervalMs:`number >= 60000 = 300000`,ipv4:_A.default(()=>({})),ipv6:vA.default(()=>({})),ttl:`number.integer >= 1 = 1`,accounts:hA.array().default(()=>[]),domains:gA.array().default(()=>[])}).onUndeclaredKey(`reject`),bA=Y({enabled:`boolean`,running:`boolean`,lastRunAt:`number | null`,lastResult:`string | null`,ipv4:`string | null`,ipv6:`string | null`,records:Y({host:`string`,account:`string`,provider:`string`,type:mA,ip:`string | null`,state:Y(`"pending" | "ok" | "unchanged" | "error" | "skipped"`),message:`string | null`,updatedAt:`number | null`}).array()}),xA=Y({key:`string`,label:`string`,hint:`string = ""`,optional:`boolean = false`}),SA=Y({config:yA,status:bA,providers:Y({id:`string`,label:`string`,docsUrl:`string`,families:mA.array(),fields:xA.array(),ttl:`boolean`,proxied:`boolean`}).array(),credentials:Y(`string[]`)});Y({provider:`string >= 1`,credentials:Y(`Record<string, string>`)}).onUndeclaredKey(`reject`),Y({enabled:`boolean?`,intervalMs:`number >= 60000?`,ipv4:Y({enabled:`boolean?`,url:`string?`}).onUndeclaredKey(`reject`).optional(),ipv6:Y({enabled:`boolean?`,url:`string?`}).onUndeclaredKey(`reject`).optional(),ttl:`number.integer >= 1?`,accounts:hA.array().optional(),domains:gA.array().optional()}).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:Xk.default(()=>`local`),openBrowser:`boolean = false`,auth:uA.default(()=>({})),tls:fA.default(()=>({}))}).onUndeclaredKey(`reject`);var CA=Y({enabled:`boolean = true`,autostart:`boolean = false`,bind:Xk.default(()=>`local`),onPortConflict:tA,restart:nA.default(()=>({})),health:aA.default(()=>({})),stop:oA.default(()=>({})),logBufferLines:cA.default(()=>500)}).onUndeclaredKey(`reject`),wA=Y({enabled:`boolean?`,maxRetries:`number.integer >= 0?`,baseDelayMs:`number >= 0?`,factor:`number >= 1?`,maxDelayMs:`number >= 0?`,resetAfterMs:`number >= 0?`}).onUndeclaredKey(`reject`),TA=Y({path:`string?`,method:`"GET" | "HEAD"?`,expectStatus:`number.integer | null?`,expectStatusBelow:`number.integer?`,expectBody:`string?`}).onUndeclaredKey(`reject`),EA=Y({maxRssBytes:`number.integer >= 0?`}).onUndeclaredKey(`reject`),DA=Y({enabled:`boolean?`,mode:`"port" | "http"?`,http:TA.optional(),intervalMs:`number >= 500?`,timeoutMs:`number >= 100?`,unhealthyThreshold:`number.integer >= 1?`,forceRestartAfterMs:`number >= 0?`,startTimeoutMs:`number >= 0?`}).onUndeclaredKey(`reject`),OA=Y({signal:`"SIGTERM" | "SIGINT" | "SIGKILL"?`,killGroup:`boolean?`,graceMs:`number >= 0?`,killPortHolders:`boolean?`}).onUndeclaredKey(`reject`),kA=Y({enabled:`boolean?`,sessionTtlMs:`number >= 60000?`,cookieSecure:`"auto" | "always" | "never"?`,trustProxy:`boolean?`,maxLoginAttempts:`number.integer >= 1?`,lockoutMs:`number >= 1000?`}).onUndeclaredKey(`reject`),AA=Y({telegram:Y({enabled:`boolean?`,chatId:`string?`,onCrash:`boolean?`,onUnhealthy:`boolean?`,onForcedRestart:`boolean?`,onRecovered:`boolean?`,onHost:`boolean?`,onDdns:`boolean?`,cooldownMs:`number >= 0?`}).onUndeclaredKey(`reject`).optional()}).onUndeclaredKey(`reject`),jA=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`),MA=Y({enabled:`boolean?`,dir:`string?`,keep:`number.integer >= 1?`,includePaths:Y(`string[]`).optional()}).onUndeclaredKey(`reject`),NA=Y({persist:`boolean?`,maxBytes:`10000 <= number <= 100000000?`,keep:`1 <= number.integer <= 10?`}).onUndeclaredKey(`reject`),PA=Y({enabled:`boolean?`}).onUndeclaredKey(`reject`),FA=Y({label:`1 <= string <= 60?`,port:`1 <= number.integer <= 65535?`,host:Xk.optional(),openBrowser:`boolean?`,auth:kA.optional(),tls:PA.optional()}).onUndeclaredKey(`reject`),IA=Y({enabled:`boolean?`,autostart:`boolean?`,bind:Xk.optional(),onPortConflict:eA.optional(),restart:wA.optional(),health:DA.optional(),stop:OA.optional(),logBufferLines:cA.optional()}).onUndeclaredKey(`reject`),LA={label:`string?`,enabled:`boolean?`,autostart:`boolean?`,persistent:`boolean?`,command:`string?`,args:`string[]?`,cwd:`string?`,env:`Record<string, string>?`,dataEnvs:`Record<string, string>?`,bootstrap:sA.optional(),port:$k.optional(),bind:Xk.optional(),onPortConflict:eA.optional(),restart:wA.optional(),health:DA.optional(),stop:OA.optional(),logBufferLines:cA.optional(),dependsOn:Y(`string[]`).optional(),envFile:`string?`,resources:EA.optional(),backupPaths:Y(`string[]`).optional(),backupIgnoreGenerated:`boolean?`},RA=Y(LA).onUndeclaredKey(`reject`),zA=Y({id:`/^[a-z0-9][a-z0-9_-]*$/`,...LA,command:`string`}).onUndeclaredKey(`reject`);Y({serverId:`string`,command:`string`,args:`string[]`,cwd:`string`,env:`Record<string, string>`,logDir:`string`,logs:dA,stop:oA}).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 BA=Y({control:FA.optional(),host:jA.optional(),backups:MA.optional()}).onUndeclaredKey(`reject`),VA=Y({defaults:IA.optional(),logs:NA.optional(),notifications:AA.optional()}).onUndeclaredKey(`reject`),HA=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`}),UA=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`}),WA=Y.enumerated(`caddy`),GA=Y.enumerated(`server`,`panel`,`external`),KA=Y.enumerated(`auto`,`off`,`manual`),qA=Y({id:`/^[a-z0-9][a-z0-9_-]*$/`,host:`/^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*$/`,enabled:`boolean = true`,target:GA.default(()=>`server`),workspace:`string = ""`,server:`string = ""`,url:`string = ""`,path:`string = ""`,tls:KA.default(()=>`auto`)}).onUndeclaredKey(`reject`),JA=Y({id:`/^[a-z0-9][a-z0-9_-]*$/`,label:`string = ""`}).onUndeclaredKey(`reject`),YA=Y.enumerated(`off`,`local`,`uploaded`,`issued`,`pending`,`failed`),XA=Y({enabled:`boolean = false`,engine:WA.default(()=>`caddy`),httpPort:`1 <= number.integer <= 65535 = 80`,httpsPort:`1 <= number.integer <= 65535 = 443`,email:`string = ""`,staging:`boolean = false`,certificates:JA.array().default(()=>[]),routes:qA.array().default(()=>[])}).onUndeclaredKey(`reject`),ZA=Y({id:WA,installed:`boolean`,version:`string | null`,source:Y.enumerated(`downloaded`,`custom`).or(Y(`null`)),path:`string | null`,bytes:`number | null`,sha256:`string | null`,error:`string | null`}),QA=Y({id:WA,label:`string`,docsUrl:`string`,releaseUrl:`string`,acme:`boolean`,internalCa:`boolean`,dns01:`boolean`,tcp:`boolean`}),$A=Y({route:qA,status:Y.enumerated(`ok`,`disabled`,`no-upstream`,`error`),upstream:`string | null`,message:`string | null`,"certificate?":Y({state:YA,message:`string | null`})}),ej=Y({state:Y.enumerated(`off`,`stopped`,`starting`,`running`,`error`,`unsupported`),pid:`number | null`,urls:Y(`string[]`),certExpiryDays:`number | null`,since:`number | null`,lastError:`string | null`}),tj=Y({id:`string`,label:`string`,present:`boolean`,used:`boolean`,subject:`string | null`,issuer:`string | null`,validTo:`string | null`,daysRemaining:`number | null`,hosts:Y(`string[]`),error:`string | null`}),nj=Y({config:XA,engine:ZA,engines:QA.array(),status:ej,routes:$A.array(),certificates:tj.array()}),rj=Y({id:`string`,host:`string`,enabled:`boolean?`,target:GA.optional(),workspace:`string?`,server:`string?`,url:`string?`,path:`string?`,tls:KA.optional()}).onUndeclaredKey(`reject`),ij=Y({enabled:`boolean?`,engine:WA.optional(),httpPort:`1 <= number.integer <= 65535?`,httpsPort:`1 <= number.integer <= 65535?`,email:`string?`,staging:`boolean?`,certificates:JA.array().optional(),routes:rj.array().optional()}).onUndeclaredKey(`reject`),aj=Y({label:`string = ""`,certificate:`string >= 1`,privateKey:`string >= 1`}).onUndeclaredKey(`reject`);Y({version:`string = ""`}).onUndeclaredKey(`reject`);var oj=Y({telegram:Y({enabled:`boolean`,tokenSet:`boolean`,chatId:`string`,onCrash:`boolean`,onUnhealthy:`boolean`,onForcedRestart:`boolean`,onRecovered:`boolean`,onHost:`boolean`,onDdns:`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 sj=Y({password:`string`}).onUndeclaredKey(`reject`),cj=Y(`1 <= string <= 512`),lj=Y({currentPassword:`string?`,newPassword:cj}).onUndeclaredKey(`reject`),uj=Y(`"stopped" | "starting" | "running" | "stopping" | "backoff" | "crashed" | "conflict"`),dj=Y(`"disabled" | "unknown" | "healthy" | "unhealthy"`),fj=Y(`"unknown" | "free" | "in-use"`),pj=Y({ts:`number`,stream:Y(`"stdout" | "stderr" | "system"`),text:`string`}),mj=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()}),hj=Y({cpuPercent:`number | null`,rssBytes:`number | null`,processes:`number`,sampledAt:`number`}),gj=Y({path:`string`,totalBytes:`number`,freeBytes:`number`,usedPercent:`number`}),_j=Y({enabled:`boolean`,cpus:`number`,loadAvg:Y(`number[]`),uptimeMs:`number`,memoryUsedPercent:`number`,swapUsedPercent:`number`,tempCelsius:`number | null`,disks:gj.array(),alerts:Y(`string[]`),sampledAt:`number | null`}),vj=Y({name:`string`,sizeBytes:`number`,createdAt:`number`,encrypted:`boolean`}),yj=Y({id:`string`,label:`string`,kind:`"settings" | "secrets" | "tls" | "workspace"`,"workspaceId?":`string`,note:`string | null`,items:Y({id:`string`,label:`string`,kind:`"settings" | "servers" | "secrets" | "data"`,"path?":`string`,"origin?":`string`,included:`boolean`,note:`string | null`,"ignoreGenerated?":`boolean`}).array()}),bj=Y({enabled:`boolean`,dir:`string`,keep:`number`,includePaths:Y(`string[]`),entries:yj.array(),files:vj.array()});Y({dryRun:`boolean`,encrypted:`boolean`,needsPassword:`boolean`,items:Y({id:`string`,label:`string`,kind:`"settings" | "secrets" | "servers" | "tls" | "data"`,"workspaceId?":`string`,restorable:`boolean`,selected:`boolean`,note:`string | null`}).array(),applied:Y(`string[]`),skipped:Y(`string[]`),restartRequired:`boolean`,reloaded:`boolean`,error:`string?`}),Y({password:cj.optional(),include:Y(`string[] >= 1`).optional()}).onUndeclaredKey(`reject`),Y({name:`string?`,password:cj.optional(),include:Y(`string[]`).optional()}).onUndeclaredKey(`reject`);var xj=Y({id:`string`,"workspaceId?":`string`,config:lA,bindHost:`string`,url:`string | null`,status:uj,health:dj,portState:fj,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:mj,responseMs:`number | null`,resources:hj.or(Y(`null`))}),Sj=Y({label:`string`,port:`number`,host:`string`,bindHost:`string`,url:`string`,openBrowser:`boolean`,restartRequired:`boolean`,protocol:`string`,auth:HA,tls:UA}),Cj=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`))}),wj=Y({id:`string`,label:`string`,configPath:`string`,settingsPath:`string`,configError:`string | null`,"configWarnings?":Y(`string[]`),logsDir:`string`,defaults:CA,logs:dA,notifications:oj,"ddns?":bA,serverCount:`number`,runningCount:`number`,crashedCount:`number`,servers:xj.array()}),Tj=Y({control:Sj,host:_j,backups:bj,ui:Cj,workspaces:wj.array(),"proxy?":nj,projectDir:`string`,dataRoot:`string`,"version?":`string`}),Ej=Y({type:`"hello" | "state" | "log" | "server"`,ts:`number`,"workspaceId?":`string`,serverId:`string?`,state:Tj.optional(),server:xj.optional(),lines:pj.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 Dj=Y({servers:Y({serverId:`string`,label:`string`,status:uj,enabled:`boolean`,sizeBytes:`number`,files:Y({name:`string`,sizeBytes:`number`}).array()}).array()}),Oj=Y({serverId:`string`,enabled:`boolean`,sizeBytes:`number`,files:Y(`string[]`),searched:`number | null`,lines:pj.array()});Y({botToken:`string?`,chatId:`string?`}).onUndeclaredKey(`reject`),Y({botToken:`string >= 1`}).onUndeclaredKey(`reject`),Y({message:`string`,code:`string`,detail:`unknown`}).onUndeclaredKey(`reject`),Y({certificate:`string >= 1`,privateKey:`string >= 1`}).onUndeclaredKey(`reject`),Y({control:Sj,host:pA,backups:bj,ui:Cj}).and(Y({rebinding:`boolean`,targetUrl:`string | null`}));var kj=Y({id:`string`,label:`string`,settingsPath:`string`,configPath:`string`,configError:`string | null`,defaults:CA,logs:dA,notifications:oj}),Aj=/^[\w!#$%&'*.^`|~+-]+$/,jj=(e,t,n={})=>{if(!Aj.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},Mj=(e,t,n)=>(t=encodeURIComponent(t),jj(e,t,n)),Nj=(e,t)=>(e=e.replace(/\/+$/,``),e+=`/`,t=t.replace(/^\/+/,``),e+t),Pj=(e,t)=>{for(let[n,r]of Object.entries(t)){let t=RegExp(`/:`+n+`(?:{[^/]+})?\\??(?=/|$)`);e=e.replace(t,()=>r?`/${r}`:``)}return e},Fj=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},Ij=(e,t)=>{switch(t){case`ws`:return e.replace(/^http/,`ws`);case`http`:return e.replace(/^ws/,`http`)}},Lj=e=>/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(e)?e.replace(/\/index(?=\?|$)/,`/`):e.replace(/\/index(?=\?|$)/,``);function Rj(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function zj(e,t){if(!Rj(e)&&!Rj(t))return t;let n={...e};for(let e in t){let r=t[e];n[e]=Rj(n[e])&&Rj(r)?zj(n[e],r):r}return n}var Bj=(e,t)=>new Proxy(()=>{},{get(n,r){if(typeof r==`string`&&r!==`then`)return Bj(e,[...t,r])},apply(n,r,i){return e({path:t,args:i})}}),Vj=(e,t)=>{let n=t.toString();return n?`${e}?${n}`:e},Hj=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(Mj(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=Lj(a),a=Pj(a,this.pathParams),this.queryParams&&(a=Vj(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})}},Uj=((e,t)=>Bj(function n(r){let i=t?.buildSearchParams??Fj,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=Nj(e,a.join(`/`));if(s===`url`||s===`path`){let t=Lj(c);return r.args[0]&&(r.args[0].param&&(t=Pj(t,r.args[0].param)),r.args[0].query&&(t=Vj(t,i(r.args[0].query)))),s===`url`?new URL(t):t.slice(e.replace(/\/+$/,``).length).replace(/^\/?/,`/`)}if(s===`ws`){let e=Lj(c),n=Ij(r.args[0]?.param?Pj(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 Hj(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=zj(t,e);return l.fetch(r.args[0],a)}return l},[]))(typeof window>`u`?`http://127.0.0.1`:window.location.origin);Y({workspaces:wj.array()});var Wj=Y({workspace:wj}),Gj=Y({ok:`boolean`,removed:`unknown`}),Kj=class extends Error{name=`AuthRequiredError`;constructor(){super(`authentication required`)}};function qj(e){return typeof e==`object`&&!!e}function Jj(e){return e==null||e.length===0?``:`?workspace=${encodeURIComponent(e)}`}function Yj(e,t){return{param:{id:t},query:e.length>0?{workspace:e}:{}}}function Xj(e,t,n){let r=n??new URLSearchParams;t.length>0&&r.set(`workspace`,t);let i=r.toString();return i.length>0?`${e}?${i}`:e}async function Zj(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&&qj(i)&&i.code===`AUTH_REQUIRED`)throw new Kj;let e=qj(i)&&typeof i.message==`string`?i.message:qj(i)&&`error`in i?String(i.error):`request failed with ${n.status}`;throw Error(e)}return i}async function Qj(){let e=Tj(await Zj(`/api/state`));if(e instanceof Y.errors)throw Error(`state contract mismatch: ${e.summary}`);return e}function $j(){return Zj(`/api/auth/session`)}function eM(e){let t=sj({password:e});if(t instanceof Y.errors)throw Error(t.summary);return Zj(`/api/auth/login`,{method:`POST`,body:JSON.stringify(t)})}function tM(){return Zj(`/api/auth/logout`,{method:`POST`})}function nM(e,t){let n=lj(e===void 0?{newPassword:t}:{currentPassword:e,newPassword:t});if(n instanceof Y.errors)throw Error(n.summary);return Zj(`/api/auth/password`,{method:`POST`,body:JSON.stringify(n)})}function rM(){return Zj(`/api/auth/password`,{method:`DELETE`})}async function iM(e){let t=Wj(e);if(t instanceof Y.errors)throw Error(`workspace contract mismatch: ${t.summary}`);return t.workspace}async function aM(e){return iM(await Zj(`/api/workspaces`,{method:`POST`,body:JSON.stringify(e)}))}async function oM(e,t){return iM(await Zj(`/api/workspaces/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify({label:t})}))}async function sM(e){let t=Gj(await Zj(`/api/workspaces/${encodeURIComponent(e)}`,{method:`DELETE`}));if(t instanceof Y.errors)throw Error(`workspace removal contract mismatch: ${t.summary}`);return t}function cM(){return Zj(`/api/settings`)}function lM(e){let t=BA(e);if(t instanceof Y.errors)throw Error(t.summary);return Zj(`/api/settings`,{method:`PATCH`,body:JSON.stringify(t)})}async function uM(e,t){let n=VA(t);if(n instanceof Y.errors)throw Error(n.summary);let r=kj(await Zj(Xj(`/api/settings/workspace`,e),{method:`PATCH`,body:JSON.stringify(n)}));if(r instanceof Y.errors)throw Error(`workspace settings contract mismatch: ${r.summary}`);return r}async function dM(e){let t=Dj(await Zj(Xj(`/api/logs`,e)));if(t instanceof Y.errors)throw Error(`logs contract mismatch: ${t.summary}`);return t.servers}async function fM(e,t,n){let r=new URLSearchParams;n.tail!==void 0&&r.set(`tail`,String(n.tail)),n.search!==void 0&&n.search.length>0&&r.set(`search`,n.search),n.stream!==void 0&&n.stream.length>0&&r.set(`stream`,n.stream);let i=Oj(await Zj(Xj(`/api/logs/${encodeURIComponent(t)}`,e,r)));if(i instanceof Y.errors)throw Error(`log history contract mismatch: ${i.summary}`);return i}function pM(e,t){return Zj(Xj(`/api/logs/${encodeURIComponent(t)}`,e),{method:`DELETE`})}function mM(e,t,n){return Xj(`/api/logs/${encodeURIComponent(t)}/download`,e,new URLSearchParams({file:n}))}function hM(e,t){if(t!==void 0&&t.length===0)throw Error("nothing is selected: omit `include` to capture everything, or select at least one item");let n={};return e!==void 0&&e.length>0&&(n.password=e),t!==void 0&&(n.include=t),Zj(`/api/backups`,{method:`POST`,body:JSON.stringify(n)})}function gM(e){return Zj(`/api/backups/${encodeURIComponent(e)}`,{method:`DELETE`})}function _M(e){return`/api/backups/${encodeURIComponent(e)}/download`}function vM(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 yM(e,t,n={}){return Zj(`/api/backups/restore?confirm=${t}`,{method:`POST`,body:JSON.stringify({name:e,...vM(n)})})}async function bM(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 xM(e,t){return Zj(Xj(`/api/notifications/token`,e),{method:`PUT`,body:JSON.stringify({botToken:t})})}function SM(e){return Zj(Xj(`/api/notifications/token`,e),{method:`DELETE`})}function CM(e,t){return Zj(Xj(`/api/notifications/test`,e),{method:`POST`,body:JSON.stringify(t)})}function wM(e,t){return Zj(Xj(`/api/notifications/detect-chats`,e),{method:`POST`,body:JSON.stringify(t)})}async function TM(e){let t=SA(e);if(t instanceof Y.errors)throw Error(`ddns contract mismatch: ${t.summary}`);return t}async function EM(e){return TM(await Zj(Xj(`/api/ddns`,e)))}async function DM(e,t){return TM(await Zj(Xj(`/api/ddns`,e),{method:`PUT`,body:JSON.stringify(t)}))}async function OM(e,t,n,r){return TM(await Zj(Xj(`/api/ddns/credentials/${encodeURIComponent(t)}`,e),{method:`PUT`,body:JSON.stringify({provider:n,credentials:r})}))}async function kM(e,t){return TM(await Zj(Xj(`/api/ddns/credentials/${encodeURIComponent(t)}`,e),{method:`DELETE`}))}async function AM(e){return TM(await Zj(Xj(`/api/ddns/check`,e),{method:`POST`}))}async function jM(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 MM(){return Zj(`/api/settings/ui`,{method:`DELETE`})}function NM(e,t){return Zj(`/api/settings/tls`,{method:`POST`,body:JSON.stringify({certificate:e,privateKey:t})})}function PM(){return Zj(`/api/settings/tls`,{method:`DELETE`})}async function FM(e){let t=nj(e);if(t instanceof Y.errors)throw Error(`proxy contract mismatch: ${t.summary}`);return t}async function IM(){return FM(await Zj(`/api/proxy`))}async function LM(e){let t=ij(e);if(t instanceof Y.errors)throw Error(t.summary);return FM(await Zj(`/api/proxy`,{method:`PATCH`,body:JSON.stringify(t)}))}async function RM(e=``){return FM(await Zj(`/api/proxy/engine`,{method:`POST`,body:JSON.stringify({version:e})}))}function zM(e){return Zj(`/api/proxy/${e}`,{method:`POST`}).then(FM)}function BM(){return zM(`start`)}function VM(){return zM(`stop`)}function HM(){return zM(`apply`)}function UM(){return zM(`revert`)}async function WM(e,t,n,r){let i=aj({label:t,certificate:n,privateKey:r});if(i instanceof Y.errors)throw Error(i.summary);return FM(await Zj(`/api/proxy/certificates/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify(i)}))}async function GM(e){return FM(await Zj(`/api/proxy/certificates/${encodeURIComponent(e)}`,{method:`DELETE`}))}async function KM(e,t,n){let r=await Uj.api.servers[`:id`][n].$post(Yj(e,t)),i=await r.json().catch(()=>null);if(!r.ok)throw Error(i?.message??`request failed with ${r.status}`);return i??{ok:!0}}function qM(e){return Zj(Xj(`/api/servers/start-all`,e),{method:`POST`})}async function JM(e,t){let n=await Uj.api.servers[`:id`][`free-port`].$post(Yj(e,t)),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.message??`request failed with ${n.status}`);return r??{ok:!0,port:null,terminated:[],forced:[],skipped:[],free:!1}}function YM(e){return Zj(Xj(`/api/servers/stop-all`,e),{method:`POST`})}function XM(e,t){return Zj(Xj(`/api/servers/${encodeURIComponent(t)}/clear-logs`,e),{method:`POST`})}function ZM(e,t,n){return Zj(Xj(`/api/servers/${encodeURIComponent(t)}`,e),{method:`PATCH`,body:JSON.stringify(n)})}function QM(e,t){return Zj(Xj(`/api/servers/${encodeURIComponent(t)}`,e),{method:`DELETE`})}function $M(e,t){return Zj(Xj(`/api/servers`,e),{method:`POST`,body:JSON.stringify(t)})}var eN=A(null),tN=A(null);function nN(e){return e===null?`wait`:e.authRequired&&!e.authenticated?`login`:`connect`}function rN(){async function e(){try{eN.value=await $j()}catch{eN.value=null}}async function t(e){tN.value=null;try{return eN.value=await eM(e),!0}catch(e){return tN.value=e instanceof Error?e.message:String(e),!1}}async function n(){try{await tM()}finally{await e()}}function r(){eN.value={authenticated:!1,authRequired:!0,passwordSet:eN.value?.passwordSet??!0,apiTokenSet:eN.value?.apiTokenSet??!1,usingDefaultPassword:eN.value?.usingDefaultPassword??!1,defaultPassword:eN.value?.defaultPassword??null,sessionTtlMs:eN.value?.sessionTtlMs??0}}async function i(t,n){tN.value=null;try{return await nM(t,n),await e(),null}catch(e){return e instanceof Error?e.message:String(e)}}async function a(){tN.value=null;try{return await rM(),await e(),null}catch(e){return e instanceof Error?e.message:String(e)}}return{session:nn(eN),error:nn(tN),refresh:e,login:t,logout:n,requireLogin:r,setPassword:i,clearPassword:a}}var iN=A([]),aN=1;function oN(e){iN.value=iN.value.filter(t=>t.id!==e)}function sN(e,t=4800){let n=aN++;return iN.value=[...iN.value,{...e,id:n}],t>0&&setTimeout(oN,t,n),n}function cN(){return{toasts:nn(iN),dismiss:oN,push:sN,success:(e,t)=>sN({tone:`ok`,title:e,description:t}),failure:(e,t)=>sN({tone:`danger`,title:e,description:t},9e3),info:(e,t)=>sN({tone:`info`,title:e,description:t}),warn:(e,t)=>sN({tone:`warn`,title:e,description:t},7e3)}}var lN=4e3;function uN(){return en({ts:[],cpu:[],rss:[],probe:[],lastSampledAt:-1})}function dN(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 fN(e,t,n){let r=t.resources?.sampledAt??0,i=e.ts[e.ts.length-1]??0;if(!(r!==e.lastSampledAt||n-i>=lN)){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),dN(e)}function pN(e){let t=0;for(let n of e)n!==null&&n>t&&(t=n);return t}function mN(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n!=null)return n}return null}var hN=8e3,gN=A(null),_N=A(`connecting`),vN=A(null),yN=A(Date.now()),bN=new Map,xN=cN();function SN(e,t){return`${e}/${t}`}var CN=new Map,wN=A(0),TN=null,EN=null;function DN(e){let t=CN.get(e);if(t)return t;let n={lines:[],version:A(0),refs:0,source:null};return CN.set(e,n),n}function ON(e,t){let n=DN(e),r=n.lines.concat(t);n.lines=r.length>8e3?r.slice(r.length-hN):r,n.version.value+=1,wN.value+=1}function kN(e){return CN.get(e)?.lines??[]}function AN(e){let t=CN.get(e);t&&(t.lines=[],t.version.value+=1,wN.value+=1)}function jN(e){let t=bN.get(e);if(t)return t;let n=uN();return bN.set(e,n),n}function MN(e){e.workspaceId!==void 0&&fN(jN(SN(e.workspaceId,e.id)),e,Date.now())}function NN(e){let t=gN.value;if(!t)return;let n=e.workspaceId,r=n===void 0?t.workspaces.filter(t=>t.servers.some(t=>t.id===e.id)):t.workspaces.filter(e=>e.id===n);if(r.length!==1)return;let i=r[0],a=i.servers.find(t=>t.id===e.id),o=n===void 0?{...e,workspaceId:i.id}:e;i.servers=a===void 0?[...i.servers,o]:i.servers.map(t=>t.id===e.id?o:t)}function PN(e){let t;try{t=JSON.parse(e)}catch{return}let n=Ej(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){gN.value=n.state;for(let e of gN.value.workspaces)for(let t of e.servers)MN(t)}return}if(n.type===`server`&&n.server){let e=n.server;NN(e),MN(e);return}if(n.type===`log`&&n.serverId&&n.lines){let e=n.workspaceId;if(e===void 0)return;ON(SN(e,n.serverId),n.lines)}}function FN(e,t,n){let r=SN(e,t),i=new EventSource(`/api/servers/${encodeURIComponent(t)}/stream${Jj(e)}`),a=e=>{let t=e,n;try{n=JSON.parse(t.data)}catch{return}let i=Ej(n);if(i instanceof Y.errors){console.warn(`[home-hosted] ignored malformed SSE frame`,i.summary);return}if(i.type===`log`&&i.lines){ON(r,i.lines);return}i.type===`server`&&i.server&&NN(i.server)};for(let e of[`log`,`server`])i.addEventListener(e,a);i.onerror=()=>{},n.source=i}function IN(e,t){let n=DN(SN(e,t));n.refs+=1,n.source||FN(e,t,n)}function LN(e,t){let n=CN.get(SN(e,t));n&&(n.refs=Math.max(0,n.refs-1),n.refs===0&&(n.source?.close(),n.source=null))}function RN(){if(TN)return;EN??=setInterval(()=>{yN.value=Date.now()},1e3);let e=new EventSource(`/api/events?logs=0`);TN=e,_N.value=`connecting`,e.onopen=()=>{_N.value=`open`},e.onerror=()=>{_N.value=`closed`};for(let t of[`hello`,`state`,`server`,`log`])e.addEventListener(t,e=>{PN(e.data)})}function zN(){TN?.close(),TN=null,EN&&clearInterval(EN),EN=null}function BN(e,t){let n=G(()=>{let n=yn(e),r=yn(t);return n===null||r===null?null:SN(n,r)}),r=null;return N(n,e=>{if(r!==null&&r!==e){let[e,t]=r.split(`/`);e!==void 0&&t!==void 0&&LN(e,t)}if(r=e,e!==null){let[t,n]=e.split(`/`);t!==void 0&&n!==void 0&&IN(t,n)}},{immediate:!0}),ze(()=>{if(r!==null){let[e,t]=r.split(`/`);e!==void 0&&t!==void 0&&LN(e,t)}r=null}),{version:G(()=>{let e=n.value;return wN.value,e===null?0:CN.get(e)?.version.value??0}),lines(){let e=n.value;return e===null?[]:kN(e)},count:G(()=>{let e=n.value;return wN.value,e===null?0:CN.get(e)?.lines.length??0}),clear(){let e=n.value;e!==null&&AN(e)}}}function VN(){let e=G(()=>gN.value?.workspaces??[]),t=G(()=>e.value.flatMap(e=>e.servers.map(t=>({workspace:e,server:t})))),n=G(()=>gN.value?.control??null),r=G(()=>gN.value?.host??null),i=G(()=>gN.value?.backups??null),a=G(()=>gN.value?.proxy??null),o=G(()=>gN.value?.projectDir??null),s=G(()=>gN.value?.dataRoot??null),c=G(()=>gN.value?.version??null);function l(e){return gN.value?.workspaces.find(t=>t.id===e)}function u(e,t){return l(e)?.servers.find(e=>e.id===t)}function d(e,t){return jN(SN(e,t))}async function f(){if(gN.value===null)try{gN.value=await Qj()}catch(e){e instanceof Kj&&rN().requireLogin()}}async function p(e,t){vN.value=null;try{let n=await e();gN.value=await Qj();let r=typeof t.success==`function`?t.success(n):t.success;return r&&xN.success(r),n}catch(e){if(e instanceof Kj){rN().requireLogin();return}let n=e instanceof Error?e.message:String(e);vN.value=n,xN.failure(t.title,n);return}}return{appState:gN,workspaces:e,allServers:t,control:n,host:r,backups:i,proxy:a,projectDir:o,dataRoot:s,version:c,connection:nn(_N),lastError:nn(vN),now:nn(yN),workspaceById:l,ensureState:f,serverById:u,seriesOf:d,refresh:(e=`Refresh failed`)=>p(async()=>{},{title:e}),start:(e,t)=>p(()=>KM(e,t,`start`),{title:`Could not start ${t}`}),stop:(e,t)=>p(()=>KM(e,t,`stop`),{title:`Could not stop ${t}`}),restart:(e,t)=>p(()=>KM(e,t,`restart`),{title:`Could not restart ${t}`}),startAll:e=>p(()=>qM(e),{title:`Could not start every server`,success:`Starting every enabled server`}),stopAll:e=>p(()=>YM(e),{title:`Could not stop every server`,success:`Stopping every server`}),setAutostart:(e,t,n)=>p(()=>ZM(e,t,{autostart:n}),{title:`Could not change autostart for ${t}`}),setEnabled:(e,t,n)=>p(()=>ZM(e,t,{enabled:n}),{title:`Could not change ${t}`}),freePort:(e,t)=>p(()=>JM(e,t),{title:`Could not free the port for ${t}`,success:e=>e.free?`Port ${e.port} is free — start ${t} now`:`Port ${e.port} is still held`}),setBind:(e,t,n)=>{let r=Qk(n);return r===null?(xN.failure(`Could not change the bind for ${t}`,`"${n}" is not a bind value`),Promise.resolve(void 0)):p(()=>ZM(e,t,{bind:r}),{title:`Could not change the bind for ${t}`})},saveConfig:(e,t,n)=>p(()=>ZM(e,t,n),{title:`Could not save ${t}`,success:`${t} updated`}),saveGlobalSettings:e=>p(()=>lM(e),{title:`Could not save the settings`}),saveWorkspaceSettings:(e,t)=>p(()=>uM(e,t),{title:`Could not save the settings`}),clearLogs:(e,t)=>p(async()=>{await XM(e,t),AN(SN(e,t))},{title:`Could not clear the logs for ${t}`,success:`Buffer cleared`}),create:(e,t)=>p(()=>$M(e,t),{title:`Could not add the server`,success:`Server added`}),remove:(e,t)=>p(async()=>{await QM(e,t),LN(e,t),CN.delete(SN(e,t)),bN.delete(SN(e,t))},{title:`Could not remove ${t}`,success:`${t} removed`})}}var HN=`hh.theme`;function UN(){try{let e=localStorage.getItem(HN);if(e===`light`||e===`dark`||e===`system`)return e}catch{}return`system`}var WN=A(UN()),GN=A(typeof matchMedia<`u`&&matchMedia(`(prefers-color-scheme: dark)`).matches),KN=!1;function qN(){KN||typeof matchMedia>`u`||(KN=!0,matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,e=>{GN.value=e.matches,YN()}))}var JN=G(()=>WN.value===`system`?GN.value:WN.value===`dark`);function YN(){typeof document<`u`&&document.documentElement.classList.toggle(`dark`,JN.value)}function XN(){qN(),YN();function e(e){WN.value=e;try{localStorage.setItem(HN,e)}catch{}YN()}return{preference:WN,isDark:JN,setPreference:e,cycle(){e(WN.value===`light`?`dark`:WN.value===`dark`?`system`:`light`)}}}var ZN=`hh.workspace`;function QN(){try{return localStorage.getItem(ZN)}catch{return null}}function $N(e){try{e===null?localStorage.removeItem(ZN):localStorage.setItem(ZN,e)}catch{}}var eP=A(QN()),tP=A(!1);function nP(){let e=VN(),t=cN(),n=G(()=>e.appState.value?.workspaces??[]),r=G(()=>{let e=n.value;return e.find(e=>e.id===eP.value)??e[0]??null}),i=G(()=>r.value?.id??``);N([n,eP],()=>{let e=n.value;if(e.length===0)return;let t=e.find(e=>e.id===eP.value)?.id??e[0].id;t!==eP.value&&(eP.value=t,$N(t))},{immediate:!0});function a(e){eP.value=e,$N(e)}let o=G(()=>r.value?.servers??[]),s=G(()=>r.value?.defaults??null),c=G(()=>r.value?.logs??null),l=G(()=>r.value?.notifications??null),u=G(()=>r.value?.configError??null),d=G(()=>r.value?.configWarnings??[]),f=G(()=>r.value?.logsDir??null),p=G(()=>r.value?.serverCount??0),m=G(()=>r.value?.runningCount??0),h=G(()=>r.value?.crashedCount??0);function g(e){return o.value.find(t=>t.id===e)}function _(t){return e.seriesOf(i.value,t)}async function v(n){tP.value=!0;try{let r=await aM(n.trim().length>0?{label:n.trim()}:{});return await e.refresh(`Could not read the workspaces`),a(r.id),t.success(`Workspace “${r.label}” created`),r}catch(e){t.failure(`Could not create the workspace`,e instanceof Error?e.message:String(e));return}finally{tP.value=!1}}async function y(n,r){try{return await oM(n,r.trim()),await e.refresh(`Could not read the workspaces`),t.success(`Workspace renamed`),!0}catch(e){return t.failure(`Could not rename the workspace`,e instanceof Error?e.message:String(e)),!1}}async function b(n){try{return await sM(n),await e.refresh(`Could not read the workspaces`),t.success(`Workspace deleted`),!0}catch(e){return t.failure(`Could not delete the workspace`,e instanceof Error?e.message:String(e)),!1}}return{workspaces:n,selectedId:nn(eP),selected:r,activeId:i,creating:nn(tP),select:a,create:v,rename:y,remove:b,servers:o,serverById:g,seriesOf:_,defaults:s,logsConfig:c,notifications:l,configError:u,configWarnings:d,logsDir:f,serverCount:p,runningCount:m,crashedCount:h,refresh:e.refresh,start:t=>e.start(i.value,t),stop:t=>e.stop(i.value,t),restart:t=>e.restart(i.value,t),startAll:()=>e.startAll(i.value),stopAll:()=>e.stopAll(i.value),setEnabled:(t,n)=>e.setEnabled(i.value,t,n),setAutostart:(t,n)=>e.setAutostart(i.value,t,n),setBind:(t,n)=>e.setBind(i.value,t,n),freePort:t=>e.freePort(i.value,t),clearLogs:t=>e.clearLogs(i.value,t),saveConfig:(t,n)=>e.saveConfig(i.value,t,n),createServer:t=>e.create(i.value,t),removeServer:t=>e.remove(i.value,t)}}function rP(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=rP(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function iP(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=rP(e))&&(r&&(r+=` `),r+=t);return r}var aP=(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},oP=(e,t)=>({classGroupId:e,validator:t}),sP=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),cP=`-`,lP=[],uP=`arbitrary..`,dP=e=>{let t=mP(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return pP(e);let n=e.split(cP);return fP(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?aP(i,t):t:i||lP}return n[e]||lP}}},fP=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=fP(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(cP):e.slice(t).join(cP),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},pP=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?uP+r:void 0})(),mP=e=>{let{theme:t,classGroups:n}=e;return hP(n,t)},hP=(e,t)=>{let n=sP();for(let r in e){let i=e[r];gP(i,n,r,t)}return n},gP=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];_P(i,t,n,r)}},_P=(e,t,n,r)=>{if(typeof e==`string`){vP(e,t,n);return}if(typeof e==`function`){yP(e,t,n,r);return}bP(e,t,n,r)},vP=(e,t,n)=>{let r=e===``?t:xP(t,e);r.classGroupId=n},yP=(e,t,n,r)=>{if(SP(e)){gP(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(oP(n,e))},bP=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];gP(o,xP(t,a),n,r)}},xP=(e,t)=>{let n=e,r=t.split(cP),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=sP(),n.nextPart.set(t,i)),n=i}return n},SP=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,CP=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)}}},wP=`!`,TP=`:`,EP=[],DP=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),OP=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===TP){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(wP)?(c=s.slice(0,-1),l=!0):s.startsWith(wP)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return DP(t,l,c,u)};if(t){let e=t+TP,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):DP(EP,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},kP=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}},AP=e=>({cache:CP(e.cacheSize),parseClassName:OP(e),sortModifiers:kP(e),postfixLookupClassGroupIds:jP(e),...dP(e)}),jP=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},MP=/\s+/,NP=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(MP),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?_+wP:_,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},PP=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=FP(n))&&(i&&(i+=` `),i+=r);return i},FP=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=FP(e[r]))&&(n&&(n+=` `),n+=t);return n},IP=(e,...t)=>{let n,r,i,a,o=o=>(n=AP(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=NP(e,n);return i(e,a),a};return a=o,(...e)=>a(PP(...e))},LP=[],RP=e=>{let t=t=>t[e]||LP;return t.isThemeGetter=!0,t.themeKey=e,t},zP=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,BP=/^\((?:(\w[\w-]*):)?(.+)\)$/i,VP=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,HP=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,UP=/\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$/,WP=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,GP=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,KP=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,qP=e=>VP.test(e),JP=e=>!!e&&!Number.isNaN(Number(e)),YP=e=>!!e&&Number.isInteger(Number(e)),XP=e=>e.endsWith(`%`)&&JP(e.slice(0,-1)),ZP=e=>HP.test(e),QP=()=>!0,$P=e=>UP.test(e)&&!WP.test(e),eF=()=>!1,tF=e=>GP.test(e),nF=e=>KP.test(e),rF=e=>!X(e)&&!Z(e),iF=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)),aF=e=>bF(e,wF,eF),X=e=>zP.test(e),oF=e=>bF(e,TF,$P),sF=e=>bF(e,EF,JP),cF=e=>bF(e,OF,QP),lF=e=>bF(e,DF,eF),uF=e=>bF(e,SF,eF),dF=e=>bF(e,CF,nF),fF=e=>bF(e,kF,tF),Z=e=>BP.test(e),pF=e=>xF(e,TF),mF=e=>xF(e,DF),hF=e=>xF(e,SF),gF=e=>xF(e,wF),_F=e=>xF(e,CF),vF=e=>xF(e,kF,!0),yF=e=>xF(e,OF,!0),bF=(e,t,n)=>{let r=zP.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},xF=(e,t,n=!1)=>{let r=BP.exec(e);return r?r[1]?t(r[1]):n:!1},SF=e=>e===`position`||e===`percentage`,CF=e=>e===`image`||e===`url`,wF=e=>e===`length`||e===`size`||e===`bg-size`,TF=e=>e===`length`,EF=e=>e===`number`,DF=e=>e===`family-name`,OF=e=>e===`number`||e===`weight`,kF=e=>e===`shadow`,AF=IP(()=>{let e=RP(`color`),t=RP(`font`),n=RP(`text`),r=RP(`font-weight`),i=RP(`tracking`),a=RP(`leading`),o=RP(`breakpoint`),s=RP(`container`),c=RP(`spacing`),l=RP(`radius`),u=RP(`shadow`),d=RP(`inset-shadow`),f=RP(`text-shadow`),p=RP(`drop-shadow`),m=RP(`blur`),h=RP(`perspective`),g=RP(`aspect`),_=RP(`ease`),v=RP(`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=()=>[qP,`full`,`auto`,...w()],ee=()=>[YP,`none`,`subgrid`,Z,X],E=()=>[`auto`,{span:[`full`,YP,Z,X]},YP,Z,X],te=()=>[YP,`auto`,Z,X],ne=()=>[`auto`,`min`,`max`,`fr`,Z,X],re=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],ie=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],ae=()=>[`auto`,...w()],oe=()=>[qP,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],se=()=>[s,qP,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],ce=()=>[qP,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],D=()=>[e,Z,X],le=()=>[...b(),hF,uF,{position:[Z,X]}],ue=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],de=()=>[`auto`,`cover`,`contain`,gF,aF,{size:[Z,X]}],fe=()=>[XP,pF,oF],pe=()=>[``,`none`,`full`,l,Z,X],me=()=>[``,JP,pF,oF],he=()=>[`solid`,`dashed`,`dotted`,`double`],ge=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],_e=()=>[JP,XP,hF,uF],ve=()=>[``,`none`,m,Z,X],ye=()=>[`none`,JP,Z,X],be=()=>[`none`,JP,Z,X],O=()=>[JP,Z,X],xe=()=>[qP,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[ZP],breakpoint:[ZP],color:[QP],container:[ZP],"drop-shadow":[ZP],ease:[`in`,`out`,`in-out`],font:[rF],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[ZP],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[ZP],shadow:[ZP],spacing:[`px`,JP],text:[ZP],"text-shadow":[ZP],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,qP,X,Z,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,Z,X]}],"container-named":[iF],columns:[{columns:[JP,`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:[YP,`auto`,Z,X]}],basis:[{basis:[qP,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[JP,qP,`auto`,`initial`,`none`,X]}],grow:[{grow:[``,JP,Z,X]}],shrink:[{shrink:[``,JP,Z,X]}],order:[{order:[YP,`first`,`last`,`none`,Z,X]}],"grid-cols":[{"grid-cols":ee()}],"col-start-end":[{col:E()}],"col-start":[{"col-start":te()}],"col-end":[{"col-end":te()}],"grid-rows":[{"grid-rows":ee()}],"row-start-end":[{row:E()}],"row-start":[{"row-start":te()}],"row-end":[{"row-end":te()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":ne()}],"auto-rows":[{"auto-rows":ne()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...re(),`normal`]}],"justify-items":[{"justify-items":[...ie(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...ie()]}],"align-content":[{content:[`normal`,...re()]}],"align-items":[{items:[...ie(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...ie(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":re()}],"place-items":[{"place-items":[...ie(),`baseline`]}],"place-self":[{"place-self":[`auto`,...ie()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:ae()}],mx:[{mx:ae()}],my:[{my:ae()}],ms:[{ms:ae()}],me:[{me:ae()}],mbs:[{mbs:ae()}],mbe:[{mbe:ae()}],mt:[{mt:ae()}],mr:[{mr:ae()}],mb:[{mb:ae()}],ml:[{ml:ae()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:oe()}],"inline-size":[{inline:[`auto`,...se()]}],"min-inline-size":[{"min-inline":[`auto`,...se()]}],"max-inline-size":[{"max-inline":[`none`,...se()]}],"block-size":[{block:[`auto`,...ce()]}],"min-block-size":[{"min-block":[`auto`,...ce()]}],"max-block-size":[{"max-block":[`none`,...ce()]}],w:[{w:[s,`screen`,...oe()]}],"min-w":[{"min-w":[s,`screen`,`none`,...oe()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...oe()]}],h:[{h:[`screen`,`lh`,...oe()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...oe()]}],"max-h":[{"max-h":[`screen`,`lh`,`none`,...oe()]}],"font-size":[{text:[`base`,n,pF,oF]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,yF,cF]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,XP,X]}],"font-family":[{font:[mF,lF,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":[JP,`none`,Z,sF]}],leading:[{leading:[`none`,a,...w()]}],"list-image":[{"list-image":[`none`,Z,X]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,Z,X]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...he(),`wavy`]}],"text-decoration-thickness":[{decoration:[JP,`from-font`,`auto`,Z,oF]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[JP,`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:[YP,Z,X]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,Z,X]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,Z,X]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:le()}],"bg-repeat":[{bg:ue()}],"bg-size":[{bg:de()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},YP,Z,X],radial:[``,Z,X],conic:[``,YP,Z,X]},_F,dF]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:fe()}],"gradient-via-pos":[{via:fe()}],"gradient-to-pos":[{to:fe()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:pe()}],"rounded-s":[{"rounded-s":pe()}],"rounded-e":[{"rounded-e":pe()}],"rounded-t":[{"rounded-t":pe()}],"rounded-r":[{"rounded-r":pe()}],"rounded-b":[{"rounded-b":pe()}],"rounded-l":[{"rounded-l":pe()}],"rounded-ss":[{"rounded-ss":pe()}],"rounded-se":[{"rounded-se":pe()}],"rounded-ee":[{"rounded-ee":pe()}],"rounded-es":[{"rounded-es":pe()}],"rounded-tl":[{"rounded-tl":pe()}],"rounded-tr":[{"rounded-tr":pe()}],"rounded-br":[{"rounded-br":pe()}],"rounded-bl":[{"rounded-bl":pe()}],"border-w":[{border:me()}],"border-w-x":[{"border-x":me()}],"border-w-y":[{"border-y":me()}],"border-w-s":[{"border-s":me()}],"border-w-e":[{"border-e":me()}],"border-w-bs":[{"border-bs":me()}],"border-w-be":[{"border-be":me()}],"border-w-t":[{"border-t":me()}],"border-w-r":[{"border-r":me()}],"border-w-b":[{"border-b":me()}],"border-w-l":[{"border-l":me()}],"divide-x":[{"divide-x":me()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":me()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...he(),`hidden`,`none`]}],"divide-style":[{divide:[...he(),`hidden`,`none`]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...he(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[JP,Z,X]}],"outline-w":[{outline:[``,JP,pF,oF]}],"outline-color":[{outline:D()}],shadow:[{shadow:[``,`inner`,`none`,u,vF,fF]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":[`none`,d,vF,fF]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:me()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[JP,oF]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":me()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":[`none`,f,vF,fF]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[JP,Z,X]}],"mix-blend":[{"mix-blend":[...ge(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":ge()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[JP]}],"mask-image-linear-from-pos":[{"mask-linear-from":_e()}],"mask-image-linear-to-pos":[{"mask-linear-to":_e()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":_e()}],"mask-image-t-to-pos":[{"mask-t-to":_e()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":_e()}],"mask-image-r-to-pos":[{"mask-r-to":_e()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":_e()}],"mask-image-b-to-pos":[{"mask-b-to":_e()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":_e()}],"mask-image-l-to-pos":[{"mask-l-to":_e()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":_e()}],"mask-image-x-to-pos":[{"mask-x-to":_e()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":_e()}],"mask-image-y-to-pos":[{"mask-y-to":_e()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[Z,X]}],"mask-image-radial-from-pos":[{"mask-radial-from":_e()}],"mask-image-radial-to-pos":[{"mask-radial-to":_e()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[JP]}],"mask-image-conic-from-pos":[{"mask-conic-from":_e()}],"mask-image-conic-to-pos":[{"mask-conic-to":_e()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:le()}],"mask-repeat":[{mask:ue()}],"mask-size":[{mask:de()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,Z,X]}],filter:[{filter:[``,`none`,Z,X]}],blur:[{blur:ve()}],brightness:[{brightness:[JP,Z,X]}],contrast:[{contrast:[JP,Z,X]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,vF,fF]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:[``,JP,Z,X]}],"hue-rotate":[{"hue-rotate":[JP,Z,X]}],invert:[{invert:[``,JP,Z,X]}],saturate:[{saturate:[JP,Z,X]}],sepia:[{sepia:[``,JP,Z,X]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,Z,X]}],"backdrop-blur":[{"backdrop-blur":ve()}],"backdrop-brightness":[{"backdrop-brightness":[JP,Z,X]}],"backdrop-contrast":[{"backdrop-contrast":[JP,Z,X]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,JP,Z,X]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[JP,Z,X]}],"backdrop-invert":[{"backdrop-invert":[``,JP,Z,X]}],"backdrop-opacity":[{"backdrop-opacity":[JP,Z,X]}],"backdrop-saturate":[{"backdrop-saturate":[JP,Z,X]}],"backdrop-sepia":[{"backdrop-sepia":[``,JP,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:[JP,`initial`,Z,X]}],ease:[{ease:[`linear`,`initial`,_,Z,X]}],delay:[{delay:[JP,Z,X]}],animate:[{animate:[`none`,v,Z,X]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,Z,X]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:ye()}],"rotate-x":[{"rotate-x":ye()}],"rotate-y":[{"rotate-y":ye()}],"rotate-z":[{"rotate-z":ye()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":[`scale-3d`],skew:[{skew:O()}],"skew-x":[{"skew-x":O()}],"skew-y":[{"skew-y":O()}],transform:[{transform:[Z,X,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:xe()}],"translate-x":[{"translate-x":xe()}],"translate-y":[{"translate-y":xe()}],"translate-z":[{"translate-z":xe()}],"translate-none":[`translate-none`],zoom:[{zoom:[YP,Z,X]}],accent:[{accent:D()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,Z,X]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":D()}],"scrollbar-track-color":[{"scrollbar-track":D()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,Z,X]}],fill:[{fill:[`none`,...D()]}],"stroke-w":[{stroke:[JP,pF,oF,sF]}],stroke:[{stroke:[`none`,...D()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`start`,`end`,`right`,`left`],"inset-y":[`inset-bs`,`inset-be`,`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`ps`,`pe`,`pr`,`pl`],py:[`pbs`,`pbe`,`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`ms`,`me`,`mr`,`ml`],my:[`mbs`,`mbe`,`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-s`,`border-w-e`,`border-w-r`,`border-w-l`],"border-w-y":[`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-s`,`border-color-e`,`border-color-r`,`border-color-l`],"border-color-y":[`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-ms`,`scroll-me`,`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-ps`,`scroll-pe`,`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function Q(...e){return AF(iP(e))}var jF={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}},MF={disabled:{label:`Not checked`,tone:`neutral`},unknown:{label:`Not probed`,tone:`neutral`},healthy:{label:`Healthy`,tone:`ok`},unhealthy:{label:`Unhealthy`,tone:`danger`}},NF={ok:`text-ok`,warn:`text-warn`,danger:`text-danger`,info:`text-info`,neutral:`text-muted`,accent:`text-accent`},PF={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`},FF={ok:`bg-ok`,warn:`bg-warn`,danger:`bg-danger`,info:`bg-info`,neutral:`bg-faint`,accent:`bg-accent`};function IF(e,t){return e===`crashed`||e===`conflict`||t===`unhealthy`?`danger`:e===`starting`||e===`stopping`||e===`backoff`?`warn`:e===`running`?`ok`:`neutral`}var LF={start:`Started`,exit:`Exited`,crash:`Crashed`,"forced-restart":`Forced restart`,unhealthy:`Unhealthy`,recovered:`Recovered`},RF={start:`ok`,exit:`neutral`,crash:`danger`,"forced-restart":`warn`,unhealthy:`warn`,recovered:`info`},zF={viewBox:`0 0 80 80`,class:`size-full -rotate-0`},BF=[`stroke-dasharray`],VF=[`stroke-dasharray`],HF={class:`absolute inset-0 grid place-items-center`},UF={class:`font-mono text-sm font-semibold tabular-nums text-ink`},WF={class:`text-2xs font-medium text-faint`},GF=34,KF=.75,qF=P({__name:`Gauge`,props:{value:{},label:{},display:{default:void 0},size:{default:74},tone:{default:void 0},warnAt:{default:75},dangerAt:{default:90}},setup(e){let t=e,n=2*Math.PI*GF,r=G(()=>t.value===null||!Number.isFinite(t.value)?0:Math.min(1,Math.max(0,t.value/100))*KF),i=G(()=>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)=>(R(),z(`div`,{class:O(j(Q)(`flex flex-col items-center gap-1`))},[V(`div`,{class:`relative`,style:ge({width:`${t.size}px`,height:`${t.size}px`})},[(R(),z(`svg`,zF,[V(`circle`,{cx:`40`,cy:`40`,r:GF,fill:`none`,class:`stroke-line-soft`,"stroke-width":6,"stroke-dasharray":`${KF*n} ${n}`,transform:`rotate(135 40 40)`,"stroke-linecap":`round`},null,8,BF),V(`circle`,{cx:`40`,cy:`40`,r:GF,fill:`none`,class:O([a[i.value],`transition-[stroke-dasharray] duration-300 ease-out`]),"stroke-width":6,"stroke-dasharray":`${r.value*n} ${n}`,transform:`rotate(135 40 40)`,"stroke-linecap":`round`},null,10,VF)])),V(`div`,HF,[V(`span`,UF,k(t.display??(t.value===null?`—`:`${Math.round(t.value)}%`)),1)])],4),V(`span`,WF,k(t.label),1)],2))}}),JF=P({__name:`Meter`,props:{value:{},warnAt:{default:75},dangerAt:{default:90},height:{default:`h-1.5`},class:{default:void 0}},setup(e){let t=e,n=G(()=>t.value===null||!Number.isFinite(t.value)?0:Math.min(100,Math.max(0,t.value))),r=G(()=>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)=>(R(),z(`div`,{class:O(j(Q)(`w-full overflow-hidden rounded-full bg-line-soft`,t.height,t.class))},[V(`div`,{class:O(j(Q)(`h-full rounded-full transition-[width] duration-300 ease-out`,i[r.value])),style:ge({width:`${n.value}%`})},null,6)],2))}}),YF={key:0,class:`grid size-10 place-items-center rounded-full border border-line bg-panel-2 text-faint`},XF={class:`max-w-sm space-y-1`},ZF={class:`text-sm font-medium text-ink`},QF={key:0,class:`text-xs leading-relaxed text-muted`},$F={key:1,class:`flex items-center gap-2`},eI=P({__name:`EmptyState`,props:{title:{},description:{default:void 0},compact:{type:Boolean,default:!1}},setup(e){return(e,t)=>(R(),z(`div`,{class:O(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?(R(),z(`div`,YF,[I(e.$slots,`icon`)])):W(``,!0),V(`div`,XF,[V(`p`,ZF,k(e.$props.title),1),e.$props.description?(R(),z(`p`,QF,k(e.$props.description),1)):W(``,!0)]),e.$slots.action?(R(),z(`div`,$F,[I(e.$slots,`action`)])):W(``,!0)],2))}});function tI(e){let t=new Date(e);return`${t.toLocaleTimeString(void 0,{hour12:!1})}.${String(t.getMilliseconds()).padStart(3,`0`)}`}function nI(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 rI(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 iI(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 aI(e){return e===null?`—`:`${(e*100).toFixed(e>=.999?0:1)}%`}function oI(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 sI(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 cI(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 lI(e){return e===null||!Number.isFinite(e)?`—`:e>=100?`${Math.round(e)}%`:`${e.toFixed(1)}%`}function uI(e){return e===void 0?`unset`:typeof e==`string`?e:JSON.stringify(e)}var dI={key:1,class:`space-y-4`},fI={class:`grid grid-cols-2 gap-3 sm:grid-cols-4`},pI={class:`grid grid-cols-2 gap-x-4 gap-y-2 border-t border-line-soft pt-3 sm:grid-cols-4`},mI={class:`flex items-center gap-1 text-2xs text-faint`},hI={class:`font-mono text-xs text-ink`},gI={class:`font-mono text-xs tabular-nums text-ink`},_I={class:`flex items-center gap-1 text-2xs text-faint`},vI={class:`font-mono text-xs text-ink`},yI={class:`flex items-center gap-1 text-2xs text-faint`},bI={class:`font-mono text-xs text-ink`},xI={class:`space-y-2 border-t border-line-soft pt-3`},SI={class:`flex items-center gap-1.5 text-2xs font-medium text-faint`},CI={class:`flex items-baseline justify-between gap-2`},wI=[`title`],TI={class:`shrink-0 font-mono text-2xs tabular-nums text-faint`},EI={key:0,class:`space-y-1 rounded-control border border-danger/25 bg-danger-soft px-2.5 py-2`},DI=P({__name:`HostVitalsPanel`,props:{host:{},now:{}},setup(e){let t=e,n=G(()=>{let e=t.host;return e?(e.loadAvg[0]??0)/Math.max(1,e.cpus):null}),r=G(()=>t.host?.loadAvg.map(e=>e.toFixed(2)).join(` `)??`—`);return(e,i)=>!t.host||!t.host.enabled?(R(),B(eI,{key:0,compact:``,title:`Host sampling is off`,description:`Turn it on in Settings to collect load, memory, disk and temperature.`})):(R(),z(`div`,dI,[V(`div`,fI,[H(qF,{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`]),H(qF,{value:t.host.memoryUsedPercent,label:`Memory`,size:72},null,8,[`value`]),H(qF,{value:t.host.swapUsedPercent,label:`Swap`,size:72,"warn-at":50},null,8,[`value`]),H(qF,{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`])]),V(`dl`,pI,[V(`div`,null,[V(`dt`,mI,[H(j(qv),{class:`size-3`}),i[0]||=U(`CPUs `,-1)]),V(`dd`,hI,k(t.host.cpus),1)]),V(`div`,null,[i[1]||=V(`dt`,{class:`text-2xs text-faint`},` Load 1 / 5 / 15 `,-1),V(`dd`,gI,k(r.value),1)]),V(`div`,null,[V(`dt`,_I,[H(j(uy),{class:`size-3`}),i[2]||=U(`Memory used `,-1)]),V(`dd`,vI,k(t.host.memoryUsedPercent.toFixed(0))+`% `,1)]),V(`div`,null,[V(`dt`,yI,[H(j(Ny),{class:`size-3`}),i[3]||=U(`Sampled `,-1)]),V(`dd`,bI,k(j(oI)(t.host.sampledAt,t.now)),1)])]),V(`div`,xI,[V(`p`,SI,[H(j(ty),{class:`size-3`}),i[4]||=U(`Filesystems `,-1)]),(R(!0),z(L,null,F(t.host.disks,e=>(R(),z(`div`,{key:e.path,class:`space-y-1`},[V(`div`,CI,[V(`span`,{class:`truncate font-mono text-2xs text-muted`,title:e.path},k(e.path),9,wI),V(`span`,TI,k(j(sI)(e.totalBytes-e.freeBytes))+` / `+k(j(sI)(e.totalBytes))+` · `+k(e.usedPercent.toFixed(0))+`% `,1)]),H(JF,{value:e.usedPercent},null,8,[`value`])]))),128))]),t.host.alerts.length>0?(R(),z(`div`,EI,[i[5]||=V(`p`,{class:`text-2xs font-medium text-danger`},` Thresholds breached `,-1),(R(!0),z(L,null,F(t.host.alerts,e=>(R(),z(`p`,{key:e,class:`text-2xs text-danger`},k(e),1))),128))])):W(``,!0)]))}}),OI={key:1,class:`flex flex-col`},kI={class:`min-w-0 flex-1`},AI={class:`flex items-baseline gap-1.5`},jI={class:`truncate text-xs font-medium text-ink`},MI=[`title`],NI={key:0,class:`text-muted`},PI={class:`shrink-0 pt-0.5 text-2xs text-faint`},FI=P({__name:`ActivityFeed`,props:{servers:{},now:{},limit:{default:12},serverId:{default:void 0}},setup(e){let t=e,n={start:gy,exit:Ay,crash:Bv,"forced-restart":xy,unhealthy:Iy,recovered:Vv},r=G(()=>{let e=[];for(let n of t.servers)if(t.serverId===void 0||n.id===t.serverId)for(let t of n.history.events)e.push({...t,label:n.config.label??n.id});return e.sort((e,t)=>t.ts-e.ts).slice(0,t.limit)});return(e,i)=>{let a=fa(`RouterLink`);return r.value.length===0?(R(),B(eI,{key:0,compact:``,title:`No events in the last 24 hours`,description:`Starts, exits, crashes and recoveries show up here as they happen.`})):(R(),z(`ol`,OI,[(R(!0),z(L,null,F(r.value,(e,r)=>(R(),z(`li`,{key:`${e.serverId}-${e.ts}-${r}`,class:O([`flex items-start gap-2.5 border-line-soft py-2`,r>0&&`border-t`])},[(R(),B(ma(n[e.type]),{class:O(j(Q)(`mt-0.5 size-3.5 shrink-0`,j(NF)[j(RF)[e.type]]))},null,8,[`class`])),V(`div`,kI,[V(`p`,AI,[V(`span`,jI,k(j(LF)[e.type]),1),H(a,{to:`/servers/${e.serverId}`,class:`truncate text-2xs text-muted hover:text-accent`},{default:M(()=>[U(k(e.label),1)]),_:2},1032,[`to`])]),V(`p`,{class:`mt-0.5 truncate font-mono text-2xs text-faint`,title:e.detail},[U(k(e.detail)+` `,1),e.runtimeMs===void 0?W(``,!0):(R(),z(`span`,NI,` · ran `+k(j(rI)(e.runtimeMs)),1))],8,MI)]),V(`span`,PI,k(j(oI)(e.ts,t.now)),1)],2))),128))]))}}}),II=[`restart`,`health`,`stop`];function LI(e,t){return JSON.stringify(RI(e))===JSON.stringify(RI(t))}function RI(e){if(Array.isArray(e))return e.map(RI);if(typeof e==`object`&&e){let t={};for(let n of Object.keys(e).sort()){let r=e[n];r!=null&&(t[n]=RI(r))}return t}return e??null}function zI(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??{}))LI(t[e],r)||(n[e]=r);Object.keys(n).length>0&&(r[i]=n);continue}LI(e[i],a)||(r[i]=a)}return r}function BI(e,t){let n=e;return zI({...n,label:n.label??``},t,II)}function VI(e,t=``){return typeof e!=`object`||!e||Array.isArray(e)?[{path:t,value:e}]:Object.entries(e).flatMap(([e,n])=>VI(n,t.length===0?e:`${t}.${e}`))}function HI(e,t){let n=new Map(VI(t).map(e=>[e.path,e.value]));return VI(e).map(e=>({path:e.path,from:n.get(e.path),to:e.value}))}function UI(e){let t=0;for(let n of Object.values(e))t+=typeof n==`object`&&n&&!Array.isArray(n)?UI(n):1;return t}async function WI(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 GI={enabled:!0,maxRetries:3,baseDelayMs:1e3,factor:2,maxDelayMs:3e4,resetAfterMs:6e4},KI={enabled:!0,mode:`port`,http:{path:`/`,method:`GET`,expectStatusBelow:400,expectBody:``},intervalMs:5e3,timeoutMs:1500,unhealthyThreshold:3,forceRestartAfterMs:0,startTimeoutMs:2e4},qI={signal:`SIGTERM`,killGroup:!0,graceMs:5e3,killPortHolders:!1};function JI(e){return{...e,http:{...e.http}}}function YI(){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},host:{enabled:!0,intervalMs:15e3,diskPaths:`.`,diskUsedPercent:90,memoryUsedPercent:90,swapUsedPercent:50,loadPerCpu:2,tempCelsius:85},backups:{enabled:!0,keep:5,includePaths:``}}}function XI(){return{defaults:{enabled:!0,autostart:!1,bind:`local`,onPortConflict:`block`,logBufferLines:500,restart:{...GI},health:JI(KI),stop:{...qI}},logs:{persist:!0,maxBytes:2e6,keep:3},telegram:{enabled:!1,chatId:``,cooldownMs:12e4,onCrash:!0,onUnhealthy:!0,onForcedRestart:!0,onRecovered:!1,onHost:!0,onDdns:!0}}}function ZI(e){return{enabled:e.enabled,sessionTtlMs:e.sessionTtlMs,cookieSecure:e.cookieSecure,trustProxy:e.trustProxy,maxLoginAttempts:e.maxLoginAttempts,lockoutMs:e.lockoutMs}}function QI(e){return{label:e.label,port:e.port,host:e.host,openBrowser:e.openBrowser,tlsEnabled:e.tls.enabled}}function $I(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,onDdns:e.onDdns??!0}}function eL(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function tL(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 nL(e){return{enabled:e.enabled,keep:e.keep,includePaths:e.includePaths.join(`, `)}}function rL(e,t){return zI(e,{...t,diskPaths:eL(t.diskPaths)})}function iL(e,t){return zI(e,{...t,includePaths:eL(t.includePaths)})}function aL(e,t){return zI({label:e.label,port:e.port,host:e.host,openBrowser:e.openBrowser,auth:ZI(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 oL(e,t){return zI(e,t,[`restart`,`health`,`stop`])}function sL(e,t){return zI(e,t)}function cL(e,t){return zI({telegram:$I(e)},{telegram:{...t}},[`telegram`])}function lL(e,t){switch(t){case`control`:return{...e.control,auth:{...e.auth}};case`host`:return{...e.host};case`backups`:return{...e.backups}}}function uL(e,t){switch(t){case`defaults`:return{...e.defaults,restart:{...e.defaults.restart},health:JI(e.defaults.health),stop:{...e.defaults.stop}};case`logs`:return{...e.logs};case`telegram`:return{...e.telegram}}}function dL(e,t){return e!==void 0&&JSON.stringify(e)!==JSON.stringify(t)}function fL(e,t){return e.label!==t.control.label||e.port!==t.control.port||e.host!==t.control.host||e.openBrowser!==t.control.openBrowser}function pL(e,t){return e.tls.enabled!==t.control.tlsEnabled}function mL(e,t){return UI(zI({...ZI(e.auth)},{...t.auth}))>0}function hL(e,t,n){return G({get:e,set:e=>{t(e===null||Number.isNaN(e)?n:e)}})}async function gL(e){if(!e.rebinding)return null;let t=e.targetUrl??e.control.url;return t.length===0||t===window.location.origin?null:await WI(t)?(window.location.replace(t),null):`The control panel did not answer on ${t}. Check the console for the new listener.`}function _L(e){return e.split(`
40
- `).map(e=>e.trim()).filter(e=>e.length>0)}function vL(e){return Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`
41
- `)}function yL(e){let t={};for(let n of _L(e)){let e=n.indexOf(`=`);e<=0||(t[n.slice(0,e).trim()]=n.slice(e+1).trim())}return t}function bL(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}var xL=/^[a-z0-9][a-z0-9_-]*$/;function SL(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??GI},health:JI(e?.health??KI),stop:{...e?.stop??qI},bootstrapEnabled:!1,bootstrapCommand:``,bootstrapArgs:``,bootstrapEnv:``,bootstrapTimeoutMs:12e4,bootstrapRunOnce:!0}}function CL(e){return e!==null&&Number.isFinite(e)?e:0}function wL(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 TL(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 EL(e,t){let n=CL(e.maxRssMb),r=CL(e.bootstrapTimeoutMs),i=wL(t),a=zI({restart:t?.restart??GI,health:t?.health??KI,stop:t?.stop??qI},{restart:e.restart,health:e.health,stop:e.stop});return{...zI(i,{args:_L(e.args),cwd:e.cwd.trim().length>0?e.cwd.trim():`.`,env:yL(e.env),dataEnvs:yL(e.dataEnvs),dependsOn:bL(e.dependsOn),envFile:e.envFile.trim(),backupPaths:_L(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:CL(e.logBufferLines)>0?CL(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:_L(e.bootstrapArgs),env:yL(e.bootstrapEnv),timeoutMs:r>=1e3?r:12e4,runOnce:e.bootstrapRunOnce}}:{}}}function DL(e){return e.id.trim().length===0?`An id is required — it is the key this server lives under.`:xL.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.`:TL(e.port):`The id must start with a lowercase letter or digit and contain only lowercase letters, digits, dashes and underscores.`}var OL={class:`mb-3 flex items-start justify-between gap-3`},kL={class:`min-w-0`},AL={class:`text-xs font-semibold text-ink`},jL={key:0,class:`mt-0.5 text-2xs leading-4 text-muted`},ML={class:`flex shrink-0 items-center gap-2`},NL=P({__name:`FieldGroup`,props:{title:{},description:{default:void 0},columns:{default:2},dense:{type:Boolean,default:!1},class:{default:void 0}},setup(e){let t=e,n=G(()=>({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)=>(R(),z(`section`,{class:O(j(Q)(`rounded-panel border border-line bg-panel-2/40`,t.dense?`p-3`:`p-3.5`,t.class))},[V(`header`,OL,[V(`div`,kL,[V(`h3`,AL,k(t.title),1),t.description?(R(),z(`p`,jL,k(t.description),1)):W(``,!0)]),V(`div`,ML,[I(e.$slots,`actions`)])]),V(`div`,{class:O(j(Q)(`grid gap-3`,n.value))},[I(e.$slots,`default`)],2)],2))}});function PL(e){return e==null||Number.isNaN(e)?``:String(e)}function FL(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 IL=`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60 focus-visible:ring-offset-2 focus-visible:ring-offset-page`,LL=`text-xs font-medium text-muted`,RL=`text-2xs leading-4 text-faint`,zL=[`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(` `),BL=`${zL} font-mono text-xs`,VL=[`for`],HL=[`id`,`step`,`min`,`max`,`aria-invalid`],UL={key:1,class:`text-2xs text-danger`},WL=P({inheritAttrs:!1,__name:`NumberField`,props:Ra({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=oo(e,`modelValue`),r=li(),i=G({get:()=>PL(n.value),set:e=>{n.value=FL(e,t.nullable)}}),a=G(()=>n.value!==null&&Number.isNaN(n.value));return(e,n)=>(R(),z(`div`,{class:O(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(R(),z(`label`,{key:0,for:j(r),class:O(j(LL))},k(t.label),11,VL)):W(``,!0),xr(V(`input`,js({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(zL),`font-mono tabular-nums`,(t.error||a.value)&&`border-danger`),"aria-invalid":t.error||a.value?!0:void 0},e.$attrs),null,16,HL),[[ql,i.value]]),t.error?(R(),z(`p`,UL,k(t.error),1)):t.hint?(R(),z(`p`,{key:2,class:O(j(RL))},k(t.hint),3)):W(``,!0)],2))}}),GL=[`for`],KL={class:`relative`},qL=[`id`],JL=[`value`,`disabled`],YL={key:1,class:`text-2xs text-danger`},XL=P({inheritAttrs:!1,__name:`SelectField`,props:Ra({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=oo(e,`modelValue`),r=li();return(e,i)=>(R(),z(`div`,{class:O(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(R(),z(`label`,{key:0,for:j(r),class:O(j(LL))},k(t.label),11,GL)):W(``,!0),V(`div`,KL,[xr(V(`select`,js({id:j(r),"onUpdate:modelValue":i[0]||=e=>n.value=e,class:j(Q)(j(zL),`cursor-pointer appearance-none pr-7`,t.mono&&`font-mono text-xs`,t.error&&`border-danger`)},e.$attrs),[(R(!0),z(L,null,F(t.options,e=>(R(),z(`option`,{key:e.value,value:e.value,disabled:e.disabled},k(e.label),9,JL))),128))],16,qL),[[Zl,n.value]]),H(j(Fv),{class:`pointer-events-none absolute right-2 top-1/2 size-3.5 -translate-y-1/2 text-faint`,"aria-hidden":`true`})]),t.error?(R(),z(`p`,YL,k(t.error),1)):t.hint?(R(),z(`p`,{key:2,class:O(j(RL))},k(t.hint),3)):W(``,!0)],2))}}),ZL=[`for`],QL=[`id`,`aria-invalid`,`aria-describedby`],$L=[`id`],eR=[`id`],tR=P({inheritAttrs:!1,__name:`TextField`,props:Ra({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=oo(e,`modelValue`),r=li(),i=G(()=>t.hint||t.error?`${r}-hint`:void 0);return(e,a)=>(R(),z(`div`,{class:O(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(R(),z(`label`,{key:0,for:j(r),class:O(j(LL))},k(t.label),11,ZL)):W(``,!0),xr(V(`input`,js({id:j(r),"onUpdate:modelValue":a[0]||=e=>n.value=e,class:j(Q)(j(zL),t.error&&`border-danger`),"aria-invalid":t.error?!0:void 0,"aria-describedby":i.value},e.$attrs),null,16,QL),[[nu,n.value]]),t.error?(R(),z(`p`,{key:1,id:`${j(r)}-hint`,class:`text-2xs text-danger`},k(t.error),9,$L)):t.hint?(R(),z(`p`,{key:2,id:`${j(r)}-hint`,class:O(j(RL))},k(t.hint),11,eR)):W(``,!0)],2))}}),nR={key:0,class:`block text-2xs text-faint`},rR=P({__name:`ToggleSwitch`,props:Ra({label:{},hint:{default:void 0},disabled:{type:Boolean,default:!1},trailing:{type:Boolean,default:!1},wide:{type:Boolean,default:!1},srOnly:{type:Boolean,default:!1}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=oo(e,`modelValue`);return(e,r)=>(R(),z(`div`,{class:O(j(Q)(`flex items-center gap-2.5`,t.trailing&&`flex-row-reverse justify-end`,t.wide&&`sm:col-span-2`))},[H(j(sg),{modelValue:n.value,"onUpdate:modelValue":r[0]||=e=>n.value=e,disabled:t.disabled,class:O(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(IL)))},{default:M(()=>[H(j(cg),{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`]),V(`label`,{class:`min-w-0 cursor-pointer select-none`,onClick:r[1]||=e=>!t.disabled&&(n.value=!n.value)},[V(`span`,{class:O(j(Q)(`block text-xs text-ink`,t.srOnly&&`sr-only`))},k(t.label),3),t.hint?(R(),z(`span`,nR,k(t.hint),1)):W(``,!0)])],2))}}),iR=P({__name:`LifecycleFields`,props:Ra({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=oo(e,`restart`),n=oo(e,`health`),r=oo(e,`stop`);function i(e,t,n=0){return G({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=G({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)=>(R(),z(L,null,[H(NL,{title:`Restart policy`,description:`Backoff between attempts after a crash.`,columns:3},{default:M(()=>[H(rR,{modelValue:t.value.enabled,"onUpdate:modelValue":y[0]||=e=>t.value.enabled=e,label:`Restart on crash`,wide:``},null,8,[`modelValue`]),H(WL,{modelValue:j(a),"onUpdate:modelValue":y[1]||=e=>mn(a)?a.value=e:null,label:`Max retries`,min:0,hint:`Attempts before the server is left crashed.`},null,8,[`modelValue`]),H(WL,{modelValue:j(o),"onUpdate:modelValue":y[2]||=e=>mn(o)?o.value=e:null,label:`Base delay (ms)`,min:0},null,8,[`modelValue`]),H(WL,{modelValue:j(s),"onUpdate:modelValue":y[3]||=e=>mn(s)?s.value=e:null,label:`Backoff factor`,min:1,step:.1},null,8,[`modelValue`]),H(WL,{modelValue:j(c),"onUpdate:modelValue":y[4]||=e=>mn(c)?c.value=e:null,label:`Max delay (ms)`,min:0},null,8,[`modelValue`]),H(WL,{modelValue:j(l),"onUpdate:modelValue":y[5]||=e=>mn(l)?l.value=e:null,label:`Reset after (ms)`,min:0,hint:`A run this long clears the retry counter.`},null,8,[`modelValue`])]),_:1}),H(NL,{title:`Health check`,description:`How readiness is probed once the process is up.`,columns:3},{default:M(()=>[H(rR,{modelValue:n.value.enabled,"onUpdate:modelValue":y[6]||=e=>n.value.enabled=e,label:`Probe this server`,wide:``},null,8,[`modelValue`]),H(XL,{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`]),H(WL,{modelValue:j(u),"onUpdate:modelValue":y[8]||=e=>mn(u)?u.value=e:null,label:`Interval (ms)`,min:500,step:100},null,8,[`modelValue`]),H(WL,{modelValue:j(d),"onUpdate:modelValue":y[9]||=e=>mn(d)?d.value=e:null,label:`Timeout (ms)`,min:100,step:100},null,8,[`modelValue`]),H(WL,{modelValue:j(f),"onUpdate:modelValue":y[10]||=e=>mn(f)?f.value=e:null,label:`Unhealthy after`,min:1,hint:`Consecutive failed probes.`},null,8,[`modelValue`]),H(WL,{modelValue:j(p),"onUpdate:modelValue":y[11]||=e=>mn(p)?p.value=e:null,label:`Force restart after (ms)`,min:0,hint:`0 disables it.`},null,8,[`modelValue`]),H(WL,{modelValue:j(m),"onUpdate:modelValue":y[12]||=e=>mn(m)?m.value=e:null,label:`Start timeout (ms)`,min:0},null,8,[`modelValue`]),e.showHttp&&n.value.mode===`http`?(R(),z(L,{key:0},[H(tR,{modelValue:n.value.http.path,"onUpdate:modelValue":y[13]||=e=>n.value.http.path=e,label:`HTTP path`,placeholder:`/healthz`},null,8,[`modelValue`]),H(XL,{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`]),H(WL,{modelValue:h.value,"onUpdate:modelValue":y[15]||=e=>h.value=e,label:`Expect status`,nullable:``,hint:`Blank accepts anything below.`},null,8,[`modelValue`]),H(WL,{modelValue:j(g),"onUpdate:modelValue":y[16]||=e=>mn(g)?g.value=e:null,label:`Healthy below status`,min:100},null,8,[`modelValue`]),H(tR,{modelValue:n.value.http.expectBody,"onUpdate:modelValue":y[17]||=e=>n.value.http.expectBody=e,label:`Body must contain`,placeholder:`optional substring`,wide:``},null,8,[`modelValue`])],64)):W(``,!0)]),_:1}),H(NL,{title:`Stop behaviour`,description:`How the process tree is asked to go away.`,columns:3},{default:M(()=>[H(XL,{modelValue:r.value.signal,"onUpdate:modelValue":y[18]||=e=>r.value.signal=e,label:`Signal`,options:v},null,8,[`modelValue`]),H(WL,{modelValue:j(_),"onUpdate:modelValue":y[19]||=e=>mn(_)?_.value=e:null,label:`Grace period (ms)`,min:0},null,8,[`modelValue`]),H(rR,{modelValue:r.value.killGroup,"onUpdate:modelValue":y[20]||=e=>r.value.killGroup=e,label:`Kill the whole process group`},null,8,[`modelValue`]),H(rR,{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))}}),aR=[`type`,`disabled`,`aria-busy`],$=P({inheritAttrs:!1,__name:`AppButton`,props:{variant:{default:`secondary`},size:{default:`sm`},type:{default:`button`},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},block:{type:Boolean,default:!1}},setup(e){let t=e,n=Pa(),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=G(()=>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`,IL,n.class));return(e,r)=>(R(),z(`button`,js({...j(n),class:void 0},{type:t.type,class:a.value,disabled:t.disabled||t.loading,"aria-busy":t.loading||void 0}),[t.loading?(R(),B(j(oy),{key:0,class:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`})):W(``,!0),I(e.$slots,`default`)],16,aR))}}),oR=[`open`],sR={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`},cR={key:0,class:`ml-1 truncate text-2xs font-normal text-faint`},lR={class:`grid gap-3 border-t border-line-soft px-3 py-3`},uR=P({__name:`Disclosure`,props:{title:{},hint:{default:void 0},open:{type:Boolean,default:!1}},setup(e){let t=e;return(e,n)=>(R(),z(`details`,{class:`group rounded-panel border border-line bg-panel-2/40`,open:t.open},[V(`summary`,sR,[H(j(Lv),{class:`size-3.5 shrink-0 text-muted transition-transform duration-150 group-open:rotate-90`,"aria-hidden":`true`}),U(` `+k(t.title)+` `,1),t.hint?(R(),z(`span`,cR,k(t.hint),1)):W(``,!0)]),V(`div`,lR,[I(e.$slots,`default`)])],8,oR))}}),dR={class:`flex shrink-0 items-start justify-between gap-4 border-b border-line px-4 py-3`},fR={class:`min-w-0`},pR={class:`min-h-0 flex-1 overflow-y-auto px-4 py-3.5`},mR={key:0,class:`flex shrink-0 items-center justify-end gap-2 border-t border-line bg-panel-2 px-4 py-3`},hR=P({__name:`Modal`,props:Ra({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=oo(e,`open`);return(e,r)=>(R(),B(j(cf),{open:n.value,"onUpdate:open":r[0]||=e=>n.value=e},{default:M(()=>[H(j(Jf),null,{default:M(()=>[H(j(Kf),{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]`}),H(j(Uf),{class:O(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(()=>[V(`header`,dR,[V(`div`,fR,[H(j(Yf),{class:`text-sm font-semibold text-ink`},{default:M(()=>[U(k(t.title),1)]),_:1}),t.description?(R(),B(j(Wf),{key:0,class:`mt-0.5 text-xs text-muted`},{default:M(()=>[U(k(t.description),1)]),_:1})):W(``,!0)]),H(j(lf),{class:O(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(IL))),"aria-label":`Close`},{default:M(()=>[H(j(Ry),{class:`size-4`})]),_:1},8,[`class`])]),V(`div`,pR,[I(e.$slots,`default`)]),e.$slots.footer?(R(),z(`footer`,mR,[I(e.$slots,`footer`)])):W(``,!0)]),_:3},8,[`class`])]),_:3})]),_:3},8,[`open`]))}}),gR=[`for`],_R=[`id`,`rows`,`placeholder`],vR={key:1,class:`text-2xs text-danger`},yR=P({inheritAttrs:!1,__name:`TextAreaField`,props:Ra({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=oo(e,`modelValue`),r=li();return(e,i)=>(R(),z(`div`,{class:O(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(R(),z(`label`,{key:0,for:j(r),class:O(j(LL))},k(t.label),11,gR)):W(``,!0),xr(V(`textarea`,js({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(BL):`font-sans`,`resize-y leading-relaxed`,t.error&&`border-danger`)},e.$attrs),null,16,_R),[[ql,n.value]]),t.error?(R(),z(`p`,vR,k(t.error),1)):t.hint?(R(),z(`p`,{key:2,class:O(j(RL))},k(t.hint),3)):W(``,!0)],2))}}),bR={class:`rounded-panel border border-line-soft bg-panel-2/40 p-3`},xR={class:`mt-1.5 flex flex-wrap gap-1`},SR={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`},CR=P({__name:`AddServerDialog`,props:Ra({workspaceId:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:Ra([`created`],[`update:open`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`open`),a=VN(),o=A(!1),s=A(null),c=[`{port}`,`{host}`,`{home}`,`{projectDir}`,`{dataRoot}`,`{id}`,`{label}`,`{cwd}`,`{bind}`,`{lanIp}`],l=G(()=>a.workspaceById(n.workspaceId)?.defaults),u=G(()=>a.workspaceById(n.workspaceId)?.label??`this workspace`),d=en(SL(l.value)),f=G(()=>TL(d.port));function p(){Object.assign(d,SL(l.value)),s.value=null}N(i,e=>{e&&p()});async function m(){s.value=null;let e=DL(d);if(e!==null){s.value=e;return}let t=zA(EL(d,l.value));if(t instanceof Y.errors){s.value=t.summary;return}o.value=!0;try{if(await a.create(n.workspaceId,t),a.lastError.value!==null){s.value=a.lastError.value;return}r(`created`),i.value=!1,p()}finally{o.value=!1}}return(e,t)=>(R(),B(hR,{open:i.value,"onUpdate:open":t[29]||=e=>i.value=e,title:`Add a server`,description:`Appends an entry to ${u.value}'s servers.config.json; every policy you leave out is inherited from its defaults.`,width:`w-[min(94vw,40rem)]`},{footer:M(()=>[H($,{variant:`ghost`,onClick:t[28]||=e=>i.value=!1},{default:M(()=>[...t[32]||=[U(` Cancel `,-1)]]),_:1}),H($,{type:`submit`,form:`add-server-form`,variant:`primary`,loading:o.value},{default:M(()=>[...t[33]||=[U(` Add to servers.config.json `,-1)]]),_:1},8,[`loading`])]),default:M(()=>[V(`form`,{id:`add-server-form`,class:`flex flex-col gap-3`,onSubmit:cu(m,[`prevent`])},[H(NL,{title:`Identity`,columns:2,dense:``},{default:M(()=>[H(tR,{modelValue:d.id,"onUpdate:modelValue":t[0]||=e=>d.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`]),H(tR,{modelValue:d.label,"onUpdate:modelValue":t[1]||=e=>d.label=e,label:`Label`,placeholder:`My server`,hint:`Shown in the panel; defaults to the id.`},null,8,[`modelValue`])]),_:1}),H(NL,{title:`Process`,columns:2,dense:``},{default:M(()=>[H(tR,{modelValue:d.command,"onUpdate:modelValue":t[2]||=e=>d.command=e,label:`Command`,placeholder:`node`,hint:`Spawned without a shell.`,class:`font-mono text-xs`},null,8,[`modelValue`]),H(tR,{modelValue:d.cwd,"onUpdate:modelValue":t[3]||=e=>d.cwd=e,label:`Working directory`,placeholder:`.`,hint:`Relative paths resolve under projectDir.`,class:`font-mono text-xs`},null,8,[`modelValue`])]),_:1}),H(yR,{modelValue:d.args,"onUpdate:modelValue":t[4]||=e=>d.args=e,label:`Arguments`,rows:3,hint:`One argument per line; whitespace inside a line is preserved.`,placeholder:`-p
42
- {port}`},null,8,[`modelValue`]),H(NL,{title:`Port & lifecycle`,columns:2,dense:``},{default:M(()=>[H(WL,{modelValue:d.port,"onUpdate:modelValue":t[5]||=e=>d.port=e,label:`Port`,nullable:``,min:1,max:65535,error:f.value,hint:`Blank means the server has no port to probe or preflight.`},null,8,[`modelValue`,`error`]),H(XL,{modelValue:d.bind,"onUpdate:modelValue":t[6]||=e=>d.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`]),H(rR,{modelValue:d.autostart,"onUpdate:modelValue":t[7]||=e=>d.autostart=e,label:`Autostart with up`,hint:`Start it whenever the control plane comes up.`,wide:``},null,8,[`modelValue`]),H(rR,{modelValue:d.persistent,"onUpdate:modelValue":t[8]||=e=>d.persistent=e,label:`Persistent`,hint:"Keeps running when the panel stops; `down` reports it instead of stopping it.",wide:``},null,8,[`modelValue`])]),_:1}),H(uR,{title:`Advanced settings`,hint:`environment, backups, policy, lifecycle, bootstrap`},{default:M(()=>[H(NL,{title:`Environment`,columns:2,dense:``},{default:M(()=>[H(yR,{modelValue:d.env,"onUpdate:modelValue":t[9]||=e=>d.env=e,label:`Environment`,rows:3,hint:`KEY=value per line, exported to the process.`,placeholder:`NODE_ENV=production`},null,8,[`modelValue`]),H(yR,{modelValue:d.dataEnvs,"onUpdate:modelValue":t[10]||=e=>d.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`]),H(tR,{modelValue:d.envFile,"onUpdate:modelValue":t[11]||=e=>d.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`]),H(tR,{modelValue:d.dependsOn,"onUpdate:modelValue":t[12]||=e=>d.dependsOn=e,label:`Depends on`,placeholder:`postgres, redis`,hint:`Comma separated; started first, stopped last.`,class:`font-mono text-xs`},null,8,[`modelValue`])]),_:1}),H(NL,{title:`Backups`,columns:2,dense:``},{default:M(()=>[H(yR,{modelValue:d.backupPaths,"onUpdate:modelValue":t[13]||=e=>d.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`]),H(rR,{modelValue:d.backupIgnoreGenerated,"onUpdate:modelValue":t[14]||=e=>d.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}),H(iR,{restart:d.restart,"onUpdate:restart":t[15]||=e=>d.restart=e,health:d.health,"onUpdate:health":t[16]||=e=>d.health=e,stop:d.stop,"onUpdate:stop":t[17]||=e=>d.stop=e},null,8,[`restart`,`health`,`stop`]),H(NL,{title:`Bootstrap`,description:`A one-off command run before the first start.`,columns:2,dense:``},{default:M(()=>[H(rR,{modelValue:d.bootstrapEnabled,"onUpdate:modelValue":t[18]||=e=>d.bootstrapEnabled=e,label:`Run a bootstrap`,hint:`Installs, migrations, downloads — before the first start, not on every one.`,wide:``},null,8,[`modelValue`]),d.bootstrapEnabled?(R(),z(L,{key:0},[H(tR,{modelValue:d.bootstrapCommand,"onUpdate:modelValue":t[19]||=e=>d.bootstrapCommand=e,label:`Command`,placeholder:`./scripts/install.sh`,class:`font-mono text-xs`},null,8,[`modelValue`]),H(WL,{modelValue:d.bootstrapTimeoutMs,"onUpdate:modelValue":t[20]||=e=>d.bootstrapTimeoutMs=e,label:`Timeout (ms)`,min:1e3,step:1e3},null,8,[`modelValue`]),H(rR,{modelValue:d.bootstrapRunOnce,"onUpdate:modelValue":t[21]||=e=>d.bootstrapRunOnce=e,label:`Only once per session`,hint:`Off means every start re-runs it.`},null,8,[`modelValue`]),H(yR,{modelValue:d.bootstrapArgs,"onUpdate:modelValue":t[22]||=e=>d.bootstrapArgs=e,label:`Bootstrap arguments`,rows:2,hint:`One per line; same placeholders as the main arguments.`},null,8,[`modelValue`]),H(yR,{modelValue:d.bootstrapEnv,"onUpdate:modelValue":t[23]||=e=>d.bootstrapEnv=e,label:`Bootstrap environment`,rows:2,hint:`KEY=value per line, exported to the bootstrap process only.`},null,8,[`modelValue`])],64)):W(``,!0)]),_:1}),H(NL,{title:`Policy & resources`,columns:2,dense:``},{default:M(()=>[H(XL,{modelValue:d.onPortConflict,"onUpdate:modelValue":t[24]||=e=>d.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`]),H(WL,{modelValue:d.logBufferLines,"onUpdate:modelValue":t[25]||=e=>d.logBufferLines=e,label:`Log buffer lines`,min:50,max:1e5,step:50,hint:`Blank keeps the default.`},null,8,[`modelValue`]),H(WL,{modelValue:d.maxRssMb,"onUpdate:modelValue":t[26]||=e=>d.maxRssMb=e,label:`Max RSS (MB)`,min:0,hint:`Restart above this; blank or 0 disables it.`},null,8,[`modelValue`]),H(rR,{modelValue:d.enabled,"onUpdate:modelValue":t[27]||=e=>d.enabled=e,label:`Enabled`,hint:`Off keeps the entry in the config but refuses to start it.`,wide:``},null,8,[`modelValue`])]),_:1}),t[30]||=V(`p`,{class:`text-2xs leading-4 text-faint`},[U(` Restart, health and stop start out matching `),V(`span`,{class:`font-mono`},`Settings → Server defaults`),U(`; change one here and it is written into this entry instead of staying inherited. `)],-1)]),_:1}),V(`div`,bR,[t[31]||=V(`p`,{class:`text-2xs font-medium text-muted`},` Available argument placeholders `,-1),V(`div`,xR,[(R(),z(L,null,F(c,e=>V(`code`,{key:e,class:`rounded-control border border-line bg-raise px-1.5 py-0.5 font-mono text-2xs text-ink`},k(e),1)),64))])]),s.value?(R(),z(`p`,SR,k(s.value),1)):W(``,!0)],32)]),_:1},8,[`open`,`description`]))}}),wR={class:`text-xs font-semibold text-ink`},TR={class:`mt-2.5 flex justify-end gap-1.5`},ER=P({__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)=>(R(),B(j(Uh),{open:i.value,"onUpdate:open":t[0]||=e=>i.value=e},{default:M(()=>[H(j(Xh),{"as-child":``},{default:M(()=>[H($,{variant:`danger-ghost`,size:`xs`,loading:n.busy},{default:M(()=>[U(` Kill what holds port `+k(n.port),1)]),_:1},8,[`loading`])]),_:1}),H(j(Yh),null,{default:M(()=>[H(j(Jh),{"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(()=>[V(`p`,wR,` Kill the process on port `+k(n.port)+`? `,1),t[3]||=V(`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),V(`div`,TR,[H(j(Wh),{"as-child":``},{default:M(()=>[H($,{size:`xs`,variant:`ghost`},{default:M(()=>[...t[1]||=[U(` Keep it `,-1)]]),_:1})]),_:1}),H($,{size:`xs`,variant:`danger`,loading:n.busy,onClick:a},{default:M(()=>[...t[2]||=[U(` Kill it `,-1)]]),_:1},8,[`loading`])])]),_:1})]),_:1})]),_:1},8,[`open`]))}}),DR=[`viewBox`],OR=[`id`],kR=[`stop-color`],AR=[`stop-color`],jR=[`d`,`fill`],MR=[`d`,`stroke`,`stroke-width`],NR=[`x1`,`x2`,`y2`,`stroke`],PR=[`cx`,`cy`,`fill`],FR={key:0,class:`absolute inset-x-0 top-1/2 border-t border-dashed border-line`},IR=100,LR=P({__name:`Sparkline`,props:Ra({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=oo(e,`hoverIndex`),r=li(),i=A(null),a=G(()=>{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=G(()=>{let e=t.values,{bottom:n,ceiling:r}=a.value,i=r-n,o=e.length>1?IR/(e.length-1):IR,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=G(()=>n.value===null||t.values.length<2?null:n.value/(t.values.length-1)*IR),c=G(()=>{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)=>(R(),z(`div`,{ref_key:`track`,ref:i,class:O(j(Q)(`relative w-full`,t.class)),style:ge({height:`${t.height}px`}),onMousemove:l,onMouseleave:u},[(R(),z(`svg`,{viewBox:`0 0 ${IR} ${t.height}`,preserveAspectRatio:`none`,class:`block size-full overflow-visible`,role:`img`,"aria-hidden":`true`},[V(`defs`,null,[V(`linearGradient`,{id:j(r),x1:`0`,y1:`0`,x2:`0`,y2:`1`},[V(`stop`,{offset:`0%`,"stop-color":t.color??`currentColor`,"stop-opacity":`0.26`},null,8,kR),V(`stop`,{offset:`100%`,"stop-color":t.color??`currentColor`,"stop-opacity":`0`},null,8,AR)],8,OR)]),(R(!0),z(L,null,F(o.value,(e,n)=>(R(),z(L,{key:n},[t.fill?(R(),z(`path`,{key:0,d:e.area,fill:`url(#${j(r)})`,stroke:`none`},null,8,jR)):W(``,!0),V(`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,MR)],64))),128)),s.value===null?W(``,!0):(R(),z(`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,NR)),s.value!==null&&c.value!==null?(R(),z(`circle`,{key:1,cx:s.value,cy:c.value,r:`2`,fill:t.color??`currentColor`,"vector-effect":`non-scaling-stroke`},null,8,PR)):W(``,!0)],8,DR)),o.value.length===0?(R(),z(`div`,FR)):W(``,!0)],38))}}),RR={class:`min-w-0`},zR={class:`flex items-baseline justify-between gap-2`},BR={class:`truncate text-2xs font-medium text-faint`},VR={class:`flex shrink-0 items-baseline gap-1.5`},HR={key:0,class:`font-mono text-2xs text-faint`},UR=P({__name:`MetricSpark`,props:{label:{},values:{},format:{},max:{default:null},colorClass:{default:`text-accent`},height:{default:30},sampleMs:{default:5e3},emptyHint:{default:`collecting…`}},setup(e){let t=e,n=A(null),r=G(()=>mN(t.values)),i=G(()=>t.values.some(e=>e!==null)),a=G(()=>{let e=n.value;return e!==null&&t.values[e]!==void 0?t.values[e]??null:r.value}),o=G(()=>{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)=>(R(),z(`div`,RR,[V(`div`,zR,[V(`span`,BR,k(t.label),1),V(`span`,VR,[o.value?(R(),z(`span`,HR,k(o.value),1)):W(``,!0),V(`span`,{class:O(j(Q)(`font-mono text-xs font-medium tabular-nums`,i.value?`text-ink`:`text-faint`))},k(i.value?t.format(a.value):t.emptyHint),3)])]),H(LR,{"hover-index":n.value,"onUpdate:hoverIndex":r[0]||=e=>n.value=e,values:t.values,height:t.height,max:t.max,interactive:``,class:O(j(Q)(`mt-1`,t.colorClass))},null,8,[`hover-index`,`values`,`height`,`max`,`class`])]))}}),WR={class:`inline-flex flex-wrap items-center gap-1.5`},GR={class:`relative flex size-1.5`},KR={key:0,class:`absolute inset-0 rounded-full bg-current opacity-60`,style:{animation:`hh-pulse-ring 1.6s ease-out infinite`}},qR=P({__name:`StatusPill`,props:{status:{},health:{default:null},showHealth:{type:Boolean,default:!0}},setup(e){let t=e,n=G(()=>jF[t.status]),r=G(()=>t.health?MF[t.health]:null),i=G(()=>t.showHealth&&r.value!==null&&t.health!==`disabled`&&t.health!==`unknown`&&(r.value.tone===`danger`||r.value.tone===`warn`)),a=G(()=>n.value.transitional);return(e,t)=>(R(),z(`span`,WR,[V(`span`,{class:O(j(Q)(`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-2xs font-medium`,j(PF)[n.value.tone]))},[V(`span`,GR,[a.value?(R(),z(`span`,KR)):W(``,!0),V(`span`,{class:O(j(Q)(`relative size-1.5 rounded-full`,j(FF)[n.value.tone]))},null,2)]),U(` `+k(n.value.label),1)],2),i.value&&r.value?(R(),z(`span`,{key:0,class:O(j(Q)(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-2xs font-medium`,j(PF)[r.value.tone]))},k(r.value.label),3)):W(``,!0)]))}}),JR=P({__name:`Tip`,props:{label:{},side:{default:`top`},disabled:{type:Boolean,default:!1}},setup(e){return(t,n)=>(R(),B(j(hg),{"delay-duration":350},{default:M(()=>[H(j(bg),{"as-child":``},{default:M(()=>[I(t.$slots,`default`)]),_:3}),e.disabled?W(``,!0):(R(),B(j(yg),{key:0},{default:M(()=>[H(j(vg),{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(()=>[U(k(e.label),1)]),_:1},8,[`side`])]),_:1}))]),_:3}))}}),YR={class:`flex items-start justify-between gap-3 px-4 pb-2.5 pt-3.5`},XR={class:`min-w-0`},ZR={class:`flex items-center gap-2`},QR=[`href`,`title`,`aria-label`],$R={class:`mt-0.5 flex items-center gap-1.5 truncate font-mono text-2xs text-faint`},ez={class:`text-muted`},tz={key:1,class:`rounded bg-hover px-1 py-px text-muted`},nz={key:2,class:`rounded bg-accent-soft px-1 py-px text-accent`},rz=[`title`],iz={key:0,class:`space-y-2.5 border-y border-line-soft px-4 py-3`},az={class:`grid grid-cols-2 gap-x-4 gap-y-2`},oz={key:1,class:`flex flex-wrap items-center gap-x-3 gap-y-1 px-4 pt-2.5`},sz={class:`text-muted`},cz={class:`text-faint`},lz={key:2,class:`flex flex-col gap-1 px-4 pt-2.5`},uz={key:0,class:`flex items-start gap-1.5 text-2xs leading-4 text-danger`},dz={class:`min-w-0 break-words`},fz={key:2,class:`text-2xs leading-4 text-warn`},pz={key:3,class:`text-2xs leading-4 text-warn`},mz={class:`grid grid-cols-2 gap-x-4 gap-y-1 px-4 py-3 sm:grid-cols-4`},hz={class:`truncate text-2xs text-faint`},gz={class:`truncate font-mono text-xs tabular-nums text-ink capitalize`},_z={class:`mt-auto flex items-center gap-1.5 border-t border-line-soft px-4 py-2.5`},vz={class:`grid grid-cols-2 gap-2 text-xs`},yz={class:`font-mono text-ink`},bz={class:`text-ink capitalize`},xz=P({__name:`ServerCard`,props:{server:{},workspaceId:{},series:{},now:{},variant:{default:`default`}},setup(e){let t=e,n={start:gy,exit:Ay,crash:Bv,"forced-restart":xy,unhealthy:Iy,recovered:Vv},r=VN(),i=nP(),a=A(!1),o=A(!1),s=G(()=>t.server.config),c=G(()=>s.value.label&&s.value.label.length>0?s.value.label:t.server.id),l=G(()=>`${s.value.command} ${s.value.args.join(` `)}`.trim()),u=G(()=>IF(t.server.status,t.server.health)),d=G(()=>t.server.status===`running`),f=G(()=>s.value.enabled&&[`stopped`,`crashed`,`conflict`].includes(t.server.status)),p=G(()=>[`running`,`starting`,`backoff`].includes(t.server.status)),m=G(()=>t.server.startedAt===null||!d.value?`—`:rI(t.now-t.server.startedAt)),h=G(()=>t.server.nextRetryAt===null?null:iI(t.server.nextRetryAt,t.now)),g=G(()=>t.server.unhealthySince===null?null:rI(t.now-t.server.unhealthySince)),_=G(()=>t.series?.cpu??[]),v=G(()=>t.series?.rss??[]),y=G(()=>t.series?.probe??[]),b=G(()=>[...t.server.history.events].slice(-3).reverse()),x=G(()=>{let e=t.server,n=[{key:`pid`,label:`PID`,value:e.pid===null?`—`:String(e.pid)},{key:`uptime`,label:`Uptime`,value:m.value},{key:`restarts`,label:`Restarts`,value:`${e.restarts}/${e.maxRetries}`},{key:`port`,label:`Port`,value:e.portState},{key:`uptime24`,label:`24h up`,value:aI(e.history.uptimeRatio)},{key:`probe`,label:`Probe`,value:e.responseMs===null?`—`:`${e.responseMs} ms`},{key:`rss`,label:`RSS`,value:cI(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:oI(e.history.lastCrashAt,t.now)}),n});async function S(e){a.value=!0;try{await r[e](t.workspaceId,t.server.id)}finally{a.value=!1}}async function C(){a.value=!0;try{await r.freePort(t.workspaceId,t.server.id)}finally{a.value=!1}}async function w(e){let n=!(e===`enabled`?s.value.enabled:s.value.autostart);e===`enabled`?await r.setEnabled(t.workspaceId,t.server.id,n):await r.setAutostart(t.workspaceId,t.server.id,n)}async function T(){o.value=!1,await r.remove(t.workspaceId,t.server.id)}function ee(){i.select(t.workspaceId)}return(i,d)=>{let m=fa(`RouterLink`);return R(),z(`article`,{class:O(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`,!s.value.enabled&&`opacity-70`))},[V(`span`,{class:O(j(Q)(`absolute inset-y-3 left-0 w-0.5 rounded-full`,{"bg-ok":u.value===`ok`,"bg-warn":u.value===`warn`,"bg-danger":u.value===`danger`,"bg-faint/50":u.value===`neutral`,"bg-accent":u.value===`accent`||u.value===`info`}))},null,2),V(`header`,YR,[V(`div`,XR,[V(`div`,ZR,[H(m,{to:`/servers/${e.server.id}`,class:`truncate text-sm font-semibold tracking-tight text-ink hover:text-accent`,onClick:ee},{default:M(()=>[U(k(c.value),1)]),_:1},8,[`to`]),e.server.url?(R(),z(`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}`},[H(j(Xv),{class:`size-3.5`})],8,QR)):W(``,!0)]),V(`p`,$R,[V(`span`,null,k(e.server.id),1),s.value.port===null?W(``,!0):(R(),z(L,{key:0},[d[9]||=V(`span`,{"aria-hidden":`true`},`·`,-1),V(`span`,ez,`:`+k(s.value.port),1)],64)),d[10]||=V(`span`,{"aria-hidden":`true`},`·`,-1),V(`span`,null,k(e.server.bindHost),1),s.value.enabled?W(``,!0):(R(),z(`span`,tz,`disabled`)),s.value.autostart?(R(),z(`span`,nz,`autostart`)):W(``,!0)])]),H(qR,{status:e.server.status,health:e.server.health},null,8,[`status`,`health`]),e.server.adopted?(R(),B(JR,{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(()=>[...d[11]||=[V(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`detached`,-1)]]),_:1})):W(``,!0),s.value.persistent?(R(),B(JR,{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(()=>[...d[12]||=[V(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`persistent`,-1)]]),_:1})):W(``,!0)]),V(`p`,{class:`truncate px-4 pb-3 font-mono text-2xs text-muted`,title:l.value},k(l.value),9,rz),t.variant===`compact`?W(``,!0):(R(),z(`div`,iz,[V(`div`,az,[H(UR,{label:`CPU`,values:_.value,format:j(lI),max:100,"color-class":`text-cpu`},null,8,[`values`,`format`]),H(UR,{label:`Memory`,values:v.value,format:j(cI),"color-class":`text-mem`},null,8,[`values`,`format`])]),H(UR,{label:`Health probe`,values:y.value,format:e=>e===null?`—`:`${e} ms`,height:22,"color-class":`text-probe`,"empty-hint":`not probed`},null,8,[`values`,`format`])])),b.value.length>0?(R(),z(`div`,oz,[(R(!0),z(L,null,F(b.value,e=>(R(),z(`span`,{key:`${e.ts}`,class:`inline-flex items-center gap-1 text-2xs`},[(R(),B(ma(n[e.type]),{class:O(j(Q)(`size-3`,j(NF)[j(RF)[e.type]]))},null,8,[`class`])),V(`span`,sz,k(j(LF)[e.type]),1),V(`span`,cz,k(j(oI)(e.ts,t.now)),1)]))),128))])):W(``,!0),e.server.lastError||g.value||h.value?(R(),z(`div`,lz,[e.server.lastError?(R(),z(`p`,uz,[H(j(Bv),{class:`mt-0.5 size-3 shrink-0`}),V(`span`,dz,k(e.server.lastError),1)])):W(``,!0),e.server.status===`conflict`&&s.value.port!==null?(R(),B(ER,{key:1,port:s.value.port,busy:a.value,class:`self-start`,onConfirm:C},null,8,[`port`,`busy`])):W(``,!0),g.value?(R(),z(`p`,fz,` Unhealthy for `+k(g.value),1)):W(``,!0),h.value?(R(),z(`p`,pz,` Next attempt `+k(h.value),1)):W(``,!0)])):W(``,!0),V(`dl`,mz,[(R(!0),z(L,null,F(x.value,e=>(R(),z(`div`,{key:e.key,class:`min-w-0`},[V(`dt`,hz,k(e.label),1),V(`dd`,gz,k(e.value),1)]))),128))]),V(`div`,_z,[H($,{variant:`primary`,size:`xs`,disabled:a.value||!f.value,onClick:d[0]||=e=>S(`start`)},{default:M(()=>[H(j(gy),{class:`size-3`}),d[13]||=U(`Start `,-1)]),_:1},8,[`disabled`]),H($,{size:`xs`,disabled:a.value||!p.value,onClick:d[1]||=e=>S(`stop`)},{default:M(()=>[H(j(Ay),{class:`size-3`}),d[14]||=U(`Stop `,-1)]),_:1},8,[`disabled`]),H($,{size:`xs`,disabled:a.value||!s.value.enabled,onClick:d[2]||=e=>S(`restart`)},{default:M(()=>[H(j(xy),{class:`size-3`}),d[15]||=U(`Restart `,-1)]),_:1},8,[`disabled`]),H(JR,{label:`Live logs and full telemetry`},{default:M(()=>[H(m,{to:`/servers/${e.server.id}`,onClick:ee},{default:M(()=>[H($,{size:`xs`,variant:`ghost`},{default:M(()=>[H(j(Sy),{class:`size-3`}),d[16]||=U(`Details `,-1)]),_:1})]),_:1},8,[`to`])]),_:1}),H(j($h),null,{default:M(()=>[H(j(ig),{"as-child":``},{default:M(()=>[H($,{size:`icon-sm`,variant:`ghost`,class:`ml-auto`,"aria-label":`More actions for ${c.value}`},{default:M(()=>[H(j(Yv),{class:`size-4`})]),_:1},8,[`aria-label`])]),_:1}),H(j(ng),null,{default:M(()=>[H(j(eg),{"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(()=>[H(j(tg),{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:d[3]||=e=>w(`enabled`)},{default:M(()=>[H(j(vy),{class:`size-3.5`}),U(` `+k(s.value.enabled?`Disable server`:`Enable server`),1)]),_:1}),H(j(tg),{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:d[4]||=e=>w(`autostart`)},{default:M(()=>[H(j(gy),{class:`size-3.5`}),U(` `+k(s.value.autostart?`Remove from autostart`:`Autostart with the panel`),1)]),_:1}),H(j(tg),{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:d[5]||=t=>j(r).clearLogs(e.workspaceId,e.server.id)},{default:M(()=>[H(j(Sy),{class:`size-3.5`}),d[17]||=U(` Clear log buffer `,-1)]),_:1}),H(j(rg),{class:`my-1 h-px bg-line`}),H(j(tg),{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:d[6]||=e=>o.value=!0},{default:M(()=>[H(j(Fy),{class:`size-3.5`}),d[18]||=U(` Remove server `,-1)]),_:1})]),_:1})]),_:1})]),_:1})]),H(hR,{open:o.value,"onUpdate:open":d[8]||=e=>o.value=e,title:`Remove this server?`,description:`${c.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(()=>[H($,{variant:`ghost`,onClick:d[7]||=e=>o.value=!1},{default:M(()=>[...d[21]||=[U(` Keep it `,-1)]]),_:1}),H($,{variant:`danger`,onClick:T},{default:M(()=>[H(j(Fy),{class:`size-3.5`}),d[22]||=U(`Remove `,-1)]),_:1})]),default:M(()=>[V(`dl`,vz,[V(`div`,null,[d[19]||=V(`dt`,{class:`text-faint`},` id `,-1),V(`dd`,yz,k(e.server.id),1)]),V(`div`,null,[d[20]||=V(`dt`,{class:`text-faint`},` status `,-1),V(`dd`,bz,k(e.server.status),1)])])]),_:1},8,[`open`,`description`])],2)}}}),Sz={class:`flex flex-wrap items-start justify-between gap-3`},Cz={class:`min-w-0`},wz={class:`flex flex-wrap items-center gap-x-3 gap-y-1.5`},Tz={class:`text-2xl font-semibold tracking-tight text-ink`},Ez={key:1,class:`mt-1 max-w-2xl text-xs leading-relaxed text-muted`},Dz={class:`flex shrink-0 flex-wrap items-center gap-2`},Oz=P({__name:`PageHeader`,props:{title:{},description:{default:void 0},backTo:{default:void 0},backLabel:{default:`Back`}},setup(e){return(e,t)=>{let n=fa(`RouterLink`);return R(),z(`header`,Sz,[V(`div`,Cz,[e.$props.backTo?(R(),B(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(()=>[H(j(Iv),{class:`size-3`}),U(` `+k(e.$props.backLabel),1)]),_:1},8,[`to`])):W(``,!0),V(`div`,wz,[V(`h1`,Tz,k(e.$props.title),1),I(e.$slots,`badges`)]),e.$props.description?(R(),z(`p`,Ez,k(e.$props.description),1)):W(``,!0)]),V(`div`,Dz,[I(e.$slots,`actions`)])])}}}),kz={key:0,class:`mb-3 flex items-start justify-between gap-3`},Az={class:`min-w-0`},jz={class:`flex shrink-0 items-center gap-1.5`},Mz=P({__name:`Panel`,props:{padded:{type:Boolean,default:!0},class:{}},setup(e){return(e,t)=>(R(),z(`section`,{class:O(j(AF)(`rounded-panel border border-line bg-panel shadow-card`,e.$props.padded&&`p-4`,e.$props.class))},[e.$slots.header||e.$slots.actions?(R(),z(`header`,kz,[V(`div`,Az,[I(e.$slots,`header`)]),V(`div`,jz,[I(e.$slots,`actions`)])])):W(``,!0),I(e.$slots,`default`)],2))}}),Nz=P({__name:`Skeleton`,props:{class:{default:`h-4 w-24`},rounded:{default:`rounded`}},setup(e){return(t,n)=>(R(),z(`span`,{class:O(j(Q)(`block animate-pulse bg-line-soft`,e.rounded,t.$props.class)),style:{"animation-duration":`1.4s`},"aria-hidden":`true`},null,2))}}),Pz={class:`min-w-0`},Fz={class:`truncate text-2xs font-medium text-faint`},Iz={key:0,class:`mt-0.5 truncate text-2xs text-muted`},Lz=P({__name:`StatTile`,props:{label:{},value:{},hint:{default:void 0},tone:{default:`neutral`},mono:{type:Boolean,default:!0}},setup(e){return(e,t)=>(R(),z(`div`,Pz,[V(`p`,Fz,k(e.$props.label),1),V(`p`,{class:O(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(NF)[e.$props.tone]))},k(e.$props.value),3),e.$props.hint?(R(),z(`p`,Iz,k(e.$props.hint),1)):W(``,!0)]))}}),Rz=A(null),zz=A(`unknown`),Bz=null;async function Vz(){try{let e=await(await fetch(`/healthz`,{cache:`no-store`})).json();typeof e.uptimeMs==`number`&&(Rz.value=Date.now()-e.uptimeMs),zz.value=e.status===`degraded`?`degraded`:`ok`}catch{zz.value=`unknown`}}function Hz(){return Bz??=Vz().finally(()=>{Bz=null}),{startedAt:Rz,status:zz,refresh:Vz}}var Uz={class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},Wz={key:0,class:`grid grid-cols-2 gap-4 p-4 sm:grid-cols-3 lg:grid-cols-5`},Gz={key:1,class:`grid grid-cols-2 divide-line-soft sm:grid-cols-3 sm:divide-x lg:grid-cols-5`},Kz={class:`p-4`},qz={class:`p-4`},Jz={class:`p-4`},Yz={class:`p-4`},Xz={class:`p-4`},Zz={key:0,class:`flex items-start gap-2.5 rounded-panel border border-danger/25 bg-danger-soft px-3.5 py-3`},Qz={class:`min-w-0`},$z={class:`text-xs font-medium text-danger`},eB={class:`mt-0.5 flex flex-wrap gap-x-3 gap-y-1 text-2xs text-danger`},tB=[`onClick`],nB={class:`grid gap-4 lg:grid-cols-3`},rB={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},iB={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},aB={class:`flex flex-wrap items-center gap-x-3 gap-y-1.5`},oB={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},sB={class:`font-mono text-2xs font-normal text-faint`},cB={class:`text-2xs text-muted`},lB={class:`ml-auto flex items-center gap-1.5`},uB={key:0,class:`rounded-control border border-danger/25 bg-danger-soft px-3 py-2 text-2xs leading-4 text-danger`},dB={key:2,class:`grid gap-4 lg:grid-cols-2`},fB={class:`flex flex-wrap items-center gap-x-3 gap-y-1 text-2xs text-faint`},pB={class:`font-mono`},mB=P({__name:`GlobalOverviewView`,setup(e){let t=VN(),n=nP(),r=Hz(),i=Lg(),a=A(!1),o=A(``),s=G(()=>t.appState.value===null),c=G(()=>t.workspaces.value),l=G(()=>t.allServers.value.map(e=>e.server)),u=G(()=>l.value.filter(e=>e.status===`running`)),d=G(()=>l.value.filter(e=>e.status===`crashed`||e.status===`conflict`||e.health===`unhealthy`)),f=G(()=>t.host.value),p=G(()=>r.startedAt.value===null?`—`:rI(t.now.value-r.startedAt.value)),m=G(()=>f.value?.enabled?rI(f.value.uptimeMs):`—`);function h(e){o.value=e,a.value=!0}function g(e,t){n.select(e),i.push(_X(e,`servers`,t))}return ta(async()=>{await r.refresh()}),(e,_)=>(R(),z(`div`,Uz,[H(Oz,{title:`Global Overview`,description:`Host vitals and every server from every workspace, grouped by where it lives.`}),H(Mz,{class:`p-0`},{default:M(()=>[s.value?(R(),z(`div`,Wz,[(R(),z(L,null,F(5,e=>V(`div`,{key:e,class:`space-y-2`},[H(Nz,{class:`h-2.5 w-16`}),H(Nz,{class:`h-6 w-20`})])),64))])):(R(),z(`div`,Gz,[V(`div`,Kz,[H(Lz,{label:`Workspaces`,value:String(c.value.length),hint:`${l.value.length} servers in total`},null,8,[`value`,`hint`])]),V(`div`,qz,[H(Lz,{label:`Running`,value:`${u.value.length}/${l.value.length}`,tone:`ok`,hint:`${l.value.length-u.value.length} not up`},null,8,[`value`,`hint`])]),V(`div`,Jz,[H(Lz,{label:`Needs attention`,value:String(d.value.length),tone:d.value.length>0?`danger`:`ok`,hint:d.value.length===0?`nothing is broken`:`crashed or unhealthy`},null,8,[`value`,`tone`,`hint`])]),V(`div`,Yz,[H(Lz,{label:`Panel uptime`,value:p.value,hint:j(r).status.value===`degraded`?`degraded`:`serving`},null,8,[`value`,`hint`])]),V(`div`,Xz,[H(Lz,{label:`Host uptime`,value:m.value,hint:f.value?.enabled?`sampling on`:`sampling off`},null,8,[`value`,`hint`])])]))]),_:1}),d.value.length>0?(R(),z(`div`,Zz,[H(j(Bv),{class:`mt-0.5 size-4 shrink-0 text-danger`}),V(`div`,Qz,[V(`p`,$z,k(d.value.length)+` server`+k(d.value.length===1?``:`s`)+` need a look `,1),V(`p`,eB,[(R(!0),z(L,null,F(j(t).allServers.value.filter(e=>e.server.status===`crashed`||e.server.status===`conflict`||e.server.health===`unhealthy`),e=>(R(),z(`button`,{key:`${e.workspace.id}:${e.server.id}`,type:`button`,class:`font-mono underline decoration-danger/40 underline-offset-2 hover:decoration-danger`,onClick:t=>g(e.workspace.id,e.server.id)},k(e.workspace.label)+`/`+k(e.server.id),9,tB))),128))])])])):W(``,!0),V(`div`,nB,[H(Mz,{class:`lg:col-span-2`},{header:M(()=>[V(`h2`,rB,[H(j(qv),{class:`size-3.5 text-faint`}),_[1]||=U(` Host vitals `,-1)]),_[2]||=V(`p`,{class:`text-2xs text-muted`},` This machine, shared by every workspace. `,-1)]),default:M(()=>[H(DI,{host:f.value,now:j(t).now.value},null,8,[`host`,`now`])]),_:1}),H(Mz,null,{header:M(()=>[V(`h2`,iB,[H(j(Av),{class:`size-3.5 text-faint`}),_[3]||=U(` Recent activity `,-1)])]),default:M(()=>[H(FI,{servers:l.value,now:j(t).now.value,limit:12},null,8,[`servers`,`now`])]),_:1})]),!s.value&&l.value.length===0?(R(),B(eI,{key:1,title:`No servers anywhere yet`,description:`Pick a workspace in the header and add the first process it should keep alive.`},{icon:M(()=>[H(j(wy),{class:`size-4`})]),_:1})):W(``,!0),(R(!0),z(L,null,F(c.value,e=>(R(),z(`section`,{key:e.id,class:`space-y-3`},[V(`div`,aB,[V(`h2`,oB,[H(j(iy),{class:`size-3.5 text-faint`}),U(` `+k(e.label)+` `,1),V(`span`,sB,k(e.id),1)]),V(`span`,cB,k(e.runningCount)+`/`+k(e.serverCount)+` running`,1),V(`div`,lB,[H($,{size:`xs`,variant:`ghost`,onClick:t=>h(e.id)},{default:M(()=>[H(j(_y),{class:`size-3`}),_[4]||=U(`Add server `,-1)]),_:1},8,[`onClick`]),H($,{size:`xs`,variant:`ghost`,onClick:t=>{j(n).select(e.id),j(i).push(j(_X)(e.id,`overview`))}},{default:M(()=>[..._[5]||=[U(` Open workspace `,-1)]]),_:1},8,[`onClick`])])]),e.configError?(R(),z(`p`,uB,` The config could not be read: `+k(e.configError),1)):W(``,!0),e.servers.length===0?(R(),B(eI,{key:1,compact:``,title:`No servers in this workspace`,description:`Add one and it will show up here and on the workspace page.`},{action:M(()=>[H($,{size:`sm`,variant:`primary`,onClick:t=>h(e.id)},{default:M(()=>[H(j(_y),{class:`size-3.5`}),_[6]||=U(`Add a server `,-1)]),_:1},8,[`onClick`])]),_:2},1024)):(R(),z(`div`,dB,[(R(!0),z(L,null,F(e.servers,n=>(R(),B(xz,{key:n.id,server:n,"workspace-id":e.id,series:j(t).seriesOf(e.id,n.id),now:j(t).now.value},null,8,[`server`,`workspace-id`,`series`,`now`]))),128))]))]))),128)),V(`p`,fB,[_[7]||=V(`span`,null,`resource history is sampled every 5 s and kept for this session`,-1),V(`span`,pB,k(j(t).appState.value?.control.url),1)]),H(CR,{open:a.value,"onUpdate:open":_[0]||=e=>a.value=e,"workspace-id":o.value},null,8,[`open`,`workspace-id`])]))}}),hB=P({__name:`ConfirmButton`,props:{label:{},confirmLabel:{default:`Confirm`},variant:{default:`danger-ghost`},confirmVariant:{default:`danger`},size:{default:`sm`},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},emits:[`confirm`],setup(e,{emit:t}){let n=e,r=t,i=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 ze(o),(e,t)=>(R(),B($,{variant:i.value?n.confirmVariant:n.variant,size:n.size,disabled:n.disabled,loading:n.loading,onClick:s},{default:M(()=>[U(k(i.value?n.confirmLabel:n.label),1)]),_:1},8,[`variant`,`size`,`disabled`,`loading`]))}}),gB={class:`min-w-0 flex-1`},_B={key:0,class:`text-xs font-semibold`},vB=P({__name:`Notice`,props:{tone:{default:`info`},title:{default:void 0},class:{default:void 0}},setup(e){let t=e,n={ok:Vv,warn:Iy,danger:py,info:ny,neutral:ny,accent:Ey},r=G(()=>n[t.tone]);return(e,n)=>(R(),z(`div`,{class:O(j(Q)(`flex items-start gap-2 rounded-panel border px-3 py-2`,j(PF)[t.tone],t.class))},[(R(),B(ma(r.value),{class:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`})),V(`div`,gB,[t.title?(R(),z(`p`,_B,k(t.title),1)):W(``,!0),V(`div`,{class:O(j(Q)(`text-xs leading-relaxed text-ink/85`,t.title&&`mt-0.5`))},[I(e.$slots,`default`)],2)])],2))}}),yB={class:`space-y-2`},bB={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},xB=P({__name:`AuthenticationSection`,props:Ra({view:{},dirty:{type:Boolean}},{auth:{required:!0},authModifiers:{}}),emits:Ra([`reset`],[`update:auth`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`auth`),a=hL(()=>i.value.sessionTtlMs,e=>i.value.sessionTtlMs=e,6048e5),o=hL(()=>i.value.maxLoginAttempts,e=>i.value.maxLoginAttempts=e,5),s=hL(()=>i.value.lockoutMs,e=>i.value.lockoutMs=e,6e4),c=G(()=>n.view?.auth.passwordSet===!0),l=G(()=>n.view?.auth.apiTokenSet===!0),u=G(()=>n.view?.auth.blockedReason??null),d=G(()=>n.view?.auth.exposed===!0),f=G(()=>n.view?.auth.usingDefaultPassword===!0),p=G(()=>i.value.enabled&&!c.value),{setPassword:m,clearPassword:h}=rN(),g=A(``),_=A(``),v=A(``),y=A(null),b=A(null),x=A(!1),S=G(()=>v.value.length>0&&v.value!==_.value),C=G(()=>_.value.length>0&&_.value.length<8),w=G(()=>_.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)=>(R(),z(L,null,[H(NL,{title:`Access policy`,description:`Authentication applies whether the panel is on loopback or exposed to the network.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[10]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(rR,{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`]),H(WL,{modelValue:j(a),"onUpdate:modelValue":t[2]||=e=>mn(a)?a.value=e:null,label:`Session lifetime (ms)`,min:6e4,hint:`604800000 is one week.`},null,8,[`modelValue`]),H(XL,{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`]),H(rR,{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`]),H(WL,{modelValue:j(o),"onUpdate:modelValue":t[5]||=e=>mn(o)?o.value=e:null,label:`Max login attempts`,min:1,hint:`Failures before a temporary lockout.`},null,8,[`modelValue`]),H(WL,{modelValue:j(s),"onUpdate:modelValue":t[6]||=e=>mn(s)?s.value=e:null,label:`Lockout (ms)`,min:1e3},null,8,[`modelValue`])]),_:1}),V(`div`,yB,[H(vB,{tone:l.value?`info`:`neutral`,title:l.value?`An API token is set`:`No API token`},{default:M(()=>[l.value?(R(),z(L,{key:0},[t[11]||=U(` Scripts can call the API with `,-1),t[12]||=V(`code`,null,`Authorization: Bearer …`,-1),t[13]||=U(` instead of signing in. `,-1)],64)):(R(),z(L,{key:1},[t[14]||=U(` For shell scripts and agents, generate one with `,-1),t[15]||=V(`code`,null,`home-hosted set-token --generate`,-1),t[16]||=U(`. `,-1)],64))]),_:1},8,[`tone`,`title`]),f.value?(R(),B(vB,{key:0,tone:`warn`,title:`The default password is still in use`},{default:M(()=>[...t[17]||=[U(` Set your own password below. Binding beyond `,-1),V(`code`,null,`127.0.0.1`,-1),U(` stays refused until you do. `,-1)]]),_:1})):W(``,!0),u.value?(R(),B(vB,{key:1,tone:`danger`,title:`This listener is being refused`},{default:M(()=>[U(k(u.value),1)]),_:1})):p.value?(R(),B(vB,{key:2,tone:`warn`,title:`Authentication is on but no password is set`},{default:M(()=>[...t[18]||=[U(` Nothing is actually required yet, and binding beyond `,-1),V(`code`,null,`127.0.0.1`,-1),U(` stays refused until a password exists. `,-1)]]),_:1})):d.value?(R(),B(vB,{key:3,tone:`warn`,title:`Reachable beyond 127.0.0.1`},{default:M(()=>[...t[19]||=[U(` Keep the password strong, or put a TLS-terminating proxy in front of the panel. `,-1)]]),_:1})):W(``,!0)]),V(`form`,{class:`mt-3`,onSubmit:cu(T,[`prevent`])},[H(NL,{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?(R(),B(tR,{key:0,modelValue:g.value,"onUpdate:modelValue":t[7]||=e=>g.value=e,type:`password`,autocomplete:`current-password`,label:`Current password`},null,8,[`modelValue`])):W(``,!0),H(tR,{modelValue:_.value,"onUpdate:modelValue":t[8]||=e=>_.value=e,type:`password`,autocomplete:`new-password`,label:`New password`},null,8,[`modelValue`]),H(tR,{modelValue:v.value,"onUpdate:modelValue":t[9]||=e=>v.value=e,type:`password`,autocomplete:`new-password`,label:`Repeat new password`,error:S.value?`The two passwords do not match.`:null},null,8,[`modelValue`,`error`]),V(`div`,bB,[H($,{type:`submit`,variant:`primary`,disabled:!w.value,loading:x.value},{default:M(()=>[U(k(c.value?`Update password`:`Set password and enable auth`),1)]),_:1},8,[`disabled`,`loading`]),c.value?(R(),B(hB,{key:0,label:`Clear password`,"confirm-label":`Confirm clear`,"confirm-variant":`danger`,disabled:x.value,onConfirm:ee},null,8,[`disabled`])):W(``,!0)]),C.value||b.value||y.value?(R(),z(L,{key:1},[C.value?(R(),B(vB,{key:0,tone:`warn`,title:`That is a short password`,class:`sm:col-span-2`},{default:M(()=>[...t[20]||=[U(` It is allowed, but longer is the only thing standing between the network and this panel. `,-1)]]),_:1})):W(``,!0),b.value?(R(),B(vB,{key:1,tone:`danger`,class:`sm:col-span-2`},{default:M(()=>[U(k(b.value),1)]),_:1})):W(``,!0),y.value?(R(),B(vB,{key:2,tone:`ok`,class:`sm:col-span-2`},{default:M(()=>[U(k(y.value),1)]),_:1})):W(``,!0)],64)):W(``,!0)]),_:1},8,[`title`])],32)],64))}});function SB(e){return e.kind===`settings`?`Server defaults, log retention and notifications`:e.kind===`servers`?`Every entry in servers.config.json`:e.kind===`secrets`?`Telegram bot token and DDNS credentials`:e.path===void 0?e.note??`A declared data path`:e.origin===void 0?e.path:`${e.path} — from ${e.origin}`}function CB(e){return e.leaves.length>0&&e.leaves.every(e=>e.selected)}function wB(e){return e.note!==null&&e.note.length>0?e.note:e.kind===`settings`?`Listener, auth, host vitals and the backups policy`:e.kind===`secrets`?`Password hash and API token hash`:e.kind===`tls`?`The panel's own certificate pair`:`Its settings, servers, secrets and declared data paths`}function TB(e,t=[]){let n=new Map(t.map(e=>[e.id,e]));return e.map(e=>{let t=n.get(e.id);return{id:e.id,label:e.label,hint:wB(e),kind:e.kind,...e.workspaceId===void 0?{}:{workspaceId:e.workspaceId},selected:t?.selected??!0,leaves:e.items.map(e=>({id:e.id,label:e.label,hint:SB(e),kind:e.kind,selected:t?.leaves.find(t=>t.id===e.id)?.selected??!0}))}})}function EB(e){return e.kind===`workspace`?e.selected&&e.leaves.some(e=>e.selected):e.selected}function DB(e,t){for(let n of e){n.selected=t;for(let e of n.leaves)e.selected=t}}function OB(e){let t=e.filter(e=>EB(e));if(e.length>0&&t.length===e.length&&t.every(e=>e.kind!==`workspace`||CB(e)))return;let n=[];for(let e of t){if(e.kind!==`workspace`){n.push(e.id);continue}CB(e)?n.push(e.id):n.push(...e.leaves.filter(e=>e.selected).map(e=>e.id))}return n}function kB(e){let t=0,n=0;for(let r of e)EB(r)&&(n+=1,t+=r.kind===`workspace`?r.leaves.filter(e=>e.selected).length:1);return{entries:n,leaves:t}}var AB=[`disabled`],jB={class:`min-w-0`},MB={class:`text-ink`},NB=P({__name:`CheckField`,props:Ra({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=oo(e,`modelValue`);return(e,r)=>(R(),z(`label`,{class:O(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(V(`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,AB),[[Jl,n.value]]),V(`span`,jB,[V(`span`,MB,k(t.label),1),t.hint?(R(),z(`span`,{key:0,class:O([`mt-0.5 block`,[j(RL)]])},k(t.hint),3)):W(``,!0),I(e.$slots,`default`)])],2))}}),PB={class:`space-y-3`},FB={class:`flex items-center justify-between gap-2`},IB={class:`text-xs font-medium text-muted`},LB={class:`flex items-center gap-1.5`},RB={class:`max-h-80 space-y-1.5 overflow-auto`},zB={class:`flex items-start gap-2.5`},BB={class:`min-w-0 flex-1`},VB={key:0,class:`flex shrink-0 items-center gap-1.5 pt-0.5`},HB={class:`font-mono text-2xs text-faint`},UB={key:1,class:`shrink-0 rounded-control border border-line px-1.5 py-0.5 text-2xs text-faint`},WB={key:0,class:`mt-1 flex items-center gap-1 pl-6 text-2xs text-warn`},GB={class:`space-y-3`},KB={class:`flex items-center justify-between gap-2`},qB={class:`text-xs font-medium text-muted`},JB={class:`flex items-center gap-1.5`},YB={class:`max-h-72 space-y-1 overflow-auto`},XB={key:0,class:`text-xs text-muted`},ZB=P({__name:`BackupDialog`,props:Ra({state:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:Ra([`created`],[`update:open`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`open`),a=A(!1),o=A(null),s=A(``),c=A([]),l=A(!1),u=A(null),d=A({});function f(e){c.value=TB(n.state?.entries??[],e?c.value:[])}let p=G(()=>kB(c.value)),m=G(()=>c.value.find(e=>e.id===`global:settings`)?.selected??!1),h=G(()=>n.state!==null&&p.value.leaves>0&&!a.value),g=G(()=>u.value===null?0:u.value.leaves.filter(e=>d.value[e.id]===!0).length);N(i,e=>{e&&(s.value=``,o.value=null,f(!1))},{immediate:!0}),N(()=>n.state,()=>{i.value&&f(!0)});function _(e){u.value=e,d.value=Object.fromEntries(e.leaves.map(e=>[e.id,e.selected])),l.value=!0}function v(){let e=u.value;if(e!==null){for(let t of e.leaves)t.selected=d.value[t.id]===!0;e.leaves.some(e=>e.selected)&&(e.selected=!0),l.value=!1,u.value=null}}function y(e){let t=u.value;t!==null&&(d.value=Object.fromEntries(t.leaves.map(t=>[t.id,e])))}async function b(){if(h.value){a.value=!0,o.value=null;try{await hM(s.value,OB(c.value)),i.value=!1,r(`created`,`Backup created.`)}catch(e){o.value=e instanceof Error?e.message:String(e)}finally{a.value=!1}}}return(e,t)=>(R(),z(L,null,[H(hR,{open:i.value,"onUpdate:open":t[4]||=e=>i.value=e,title:`Create a backup`,description:`Pick what this archive captures. Nothing is written until you create it.`,width:`w-[min(92vw,40rem)]`},{footer:M(()=>[H($,{size:`sm`,variant:`ghost`,disabled:a.value,onClick:t[3]||=e=>i.value=!1},{default:M(()=>[...t[14]||=[U(` Cancel `,-1)]]),_:1},8,[`disabled`]),H($,{size:`sm`,variant:`primary`,disabled:!h.value,loading:a.value,onClick:b},{default:M(()=>[...t[15]||=[U(` Create backup `,-1)]]),_:1},8,[`disabled`,`loading`])]),default:M(()=>[V(`div`,PB,[V(`div`,FB,[V(`span`,IB,k(p.value.entries)+` entr`+k(p.value.entries===1?`y`:`ies`)+` · `+k(p.value.leaves)+` item`+k(p.value.leaves===1?``:`s`)+` selected `,1),V(`div`,LB,[H($,{size:`xs`,variant:`ghost`,disabled:a.value,onClick:t[0]||=e=>j(DB)(c.value,!0)},{default:M(()=>[...t[9]||=[U(` Select all `,-1)]]),_:1},8,[`disabled`]),H($,{size:`xs`,variant:`ghost`,disabled:a.value,onClick:t[1]||=e=>j(DB)(c.value,!1)},{default:M(()=>[...t[10]||=[U(` Select none `,-1)]]),_:1},8,[`disabled`])])]),V(`ul`,RB,[(R(!0),z(L,null,F(c.value,e=>(R(),z(`li`,{key:e.id,class:`rounded-control border border-line-soft bg-panel-2/30 px-2.5 py-2`},[V(`div`,zB,[V(`div`,BB,[H(NB,{modelValue:e.selected,"onUpdate:modelValue":t=>e.selected=t,label:e.label,hint:e.hint,disabled:a.value},null,8,[`modelValue`,`onUpdate:modelValue`,`label`,`hint`,`disabled`])]),e.kind===`workspace`?(R(),z(`div`,VB,[V(`span`,HB,k(e.leaves.filter(e=>e.selected).length)+`/`+k(e.leaves.length),1),H($,{size:`xs`,variant:`secondary`,disabled:a.value,onClick:t=>_(e)},{default:M(()=>[H(j(Nv),{class:`size-3`}),t[11]||=U(`Choose items `,-1)]),_:1},8,[`disabled`,`onClick`])])):(R(),z(`span`,UB,k(e.kind),1))]),e.kind===`workspace`&&e.selected&&!j(CB)(e)&&e.leaves.some(e=>e.selected)?(R(),z(`p`,WB,[H(j(iy),{class:`size-3`}),t[12]||=U(` Only the chosen items are captured. `,-1)])):W(``,!0)]))),128))]),m.value?W(``,!0):(R(),B(vB,{key:0,tone:`warn`},{default:M(()=>[...t[13]||=[U(` Without the global settings, a restore can only place a workspace where the target panel already declares it. `,-1)]]),_:1})),H(tR,{modelValue:s.value,"onUpdate:modelValue":t[2]||=e=>s.value=e,type:`password`,autocomplete:`new-password`,label:`Password (optional)`,hint:`Encrypts the archive; restoring it asks for the same password.`,wide:``},null,8,[`modelValue`]),o.value?(R(),B(vB,{key:1,tone:`danger`},{default:M(()=>[U(k(o.value),1)]),_:1})):W(``,!0)])]),_:1},8,[`open`]),H(hR,{open:l.value,"onUpdate:open":t[8]||=e=>l.value=e,title:u.value===null?`Choose items`:`${u.value.label} — choose items`,description:`A workspace can be captured whole or only its settings, servers, secrets and declared data paths.`,width:`w-[min(92vw,34rem)]`},{footer:M(()=>[H($,{size:`sm`,variant:`ghost`,onClick:t[7]||=e=>l.value=!1},{default:M(()=>[...t[18]||=[U(` Cancel `,-1)]]),_:1}),H($,{size:`sm`,variant:`primary`,onClick:v},{default:M(()=>[...t[19]||=[U(` Apply `,-1)]]),_:1})]),default:M(()=>[V(`div`,GB,[V(`div`,KB,[V(`span`,qB,k(g.value)+` of `+k(u.value?.leaves.length??0)+` selected`,1),V(`div`,JB,[H($,{size:`xs`,variant:`ghost`,onClick:t[5]||=e=>y(!0)},{default:M(()=>[...t[16]||=[U(` Select all `,-1)]]),_:1}),H($,{size:`xs`,variant:`ghost`,onClick:t[6]||=e=>y(!1)},{default:M(()=>[...t[17]||=[U(` Select none `,-1)]]),_:1})])]),V(`ul`,YB,[(R(!0),z(L,null,F(u.value?.leaves??[],e=>(R(),z(`li`,{key:e.id,class:`rounded-control px-2 py-1.5 hover:bg-hover`},[H(NB,{"model-value":d.value[e.id]===!0,label:e.label,hint:e.hint,"onUpdate:modelValue":t=>d.value[e.id]=t===!0},null,8,[`model-value`,`label`,`hint`,`onUpdate:modelValue`])]))),128))]),u.value?.leaves.length===0?(R(),z(`p`,XB,` This workspace declares nothing selectable yet. `)):W(``,!0)])]),_:1},8,[`open`,`title`])],64))}}),QB={class:`space-y-3`},$B={key:0,class:`flex min-w-0 flex-col gap-1`},eV=[`disabled`],tV={key:0,class:`font-mono text-2xs text-muted`},nV={class:`mt-2`},rV={class:`mt-2 max-w-sm`},iV={class:`mt-2`},aV={class:`mt-2`},oV={class:`mt-1 max-h-64 space-y-0.5 overflow-auto`},sV={class:`mt-2 flex flex-wrap items-center gap-2`},cV={class:`mt-2`},lV=`__upload__`,uV=P({__name:`RestoreDialog`,props:Ra({files:{},initial:{default:null}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:Ra([`applied`],[`update:open`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`open`),a=A(!1),o=A(null),s=A(null),c=A(null),l=A(``),u=A({kind:`upload`}),d=A(lV),f=G(()=>s.value?.items.filter(e=>e.selected).length??0),p=G(()=>s.value?.items.some(e=>e.id===`global:settings`&&e.selected)??!1),m=G(()=>s.value?.needsPassword===!0),h=G(()=>s.value!==null&&!m.value&&f.value>0&&!a.value),g=G(()=>[...n.files.map(e=>({value:e.name,label:e.encrypted?`${e.name} — encrypted`:e.name})),{value:lV,label:`Upload a file…`}]),_=Q(zL,`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`);function v(e){return e instanceof Error?e.message:String(e)}function y(){return l.value.length>0?{password:l.value}:{}}async function b(){let e=u.value;if(e.kind===`upload`&&c.value===null){s.value=null;return}a.value=!0,o.value=null,s.value=null;try{s.value=e.kind===`stored`?await yM(e.name,!1,y()):await bM(c.value,!1,y())}catch(e){o.value=v(e)}finally{a.value=!1}}function x(e){d.value=e,c.value=null,u.value=e===lV?{kind:`upload`}:{kind:`stored`,name:e},b()}function S(e){c.value=e.target.files?.[0]??null,b()}function C(e){for(let t of s.value?.items??[])t.restorable&&(t.selected=e)}async function w(){let e=s.value,t=u.value;if(e===null||!h.value)return;a.value=!0,o.value=null;let n={...y(),include:e.items.filter(e=>e.restorable&&e.selected).map(e=>e.id)};try{let e=t.kind===`stored`?await yM(t.name,!0,n):await bM(c.value,!0,n);i.value=!1,s.value=null,c.value=null,l.value=``;let a=[];e.reloaded&&a.push(`the restored servers are live, autostart entries starting`),e.restartRequired&&a.push(`restart the panel to apply its own settings`),r(`applied`,`Restored ${e.applied.length} item(s)${a.length===0?``:` — ${a.join(`; `)}`}.`)}catch(e){o.value=v(e)}finally{a.value=!1}}return N(i,e=>{if(!e){s.value=null,c.value=null,l.value=``,o.value=null;return}let t=n.files[0];u.value=n.initial??(t===void 0?{kind:`upload`}:{kind:`stored`,name:t.name}),d.value=u.value.kind===`stored`?u.value.name:lV,b()},{immediate:!0}),(e,t)=>(R(),B(hR,{open:i.value,"onUpdate:open":t[4]||=e=>i.value=e,title:`Restore a backup`,description:`Nothing is written until the plan is applied.`,width:`w-[min(92vw,38rem)]`},{footer:M(()=>[H($,{size:`sm`,variant:`ghost`,disabled:a.value,onClick:t[3]||=e=>i.value=!1},{default:M(()=>[...t[10]||=[U(` Cancel `,-1)]]),_:1},8,[`disabled`]),s.value&&!m.value?(R(),B($,{key:0,size:`sm`,variant:`danger`,disabled:!h.value,loading:a.value,onClick:w},{default:M(()=>[U(k(u.value.kind===`stored`?`Apply this restore`:`Restore the upload`),1)]),_:1},8,[`disabled`,`loading`])):W(``,!0)]),default:M(()=>[V(`div`,QB,[H(XL,{"model-value":d.value,label:`Archive`,hint:`A stored archive, or a .zip from this machine.`,options:g.value,disabled:a.value,wide:``,"onUpdate:modelValue":x},null,8,[`model-value`,`options`,`disabled`]),u.value.kind===`upload`?(R(),z(`div`,$B,[V(`label`,{class:O(j(LL)),for:`restore-upload`},`Archive file (.zip)`,2),V(`input`,{id:`restore-upload`,type:`file`,accept:`.zip,application/zip`,class:O(j(_)),disabled:a.value,onChange:S},null,42,eV),c.value?(R(),z(`p`,tV,k(c.value.name),1)):W(``,!0)])):W(``,!0),a.value?(R(),B(Nz,{key:1,class:`h-20 w-full`})):s.value?(R(),B(vB,{key:2,tone:`warn`,title:`Nothing has changed yet`},{default:M(()=>[V(`p`,null,[u.value.kind===`stored`?(R(),z(L,{key:0},[t[5]||=U(` Archive `,-1),V(`code`,null,k(u.value.name),1),t[6]||=U(`. `,-1)],64)):(R(),z(L,{key:1},[U(` The uploaded archive. `)],64))]),s.value.needsPassword?(R(),z(L,{key:0},[V(`p`,nV,k(s.value.error??`This backup is password-protected.`),1),V(`div`,rV,[H(tR,{modelValue:l.value,"onUpdate:modelValue":t[0]||=e=>l.value=e,type:`password`,autocomplete:`off`,label:`Password`},null,8,[`modelValue`])]),V(`div`,iV,[H($,{size:`sm`,variant:`secondary`,disabled:a.value,onClick:b},{default:M(()=>[...t[7]||=[U(` Check again with the password `,-1)]]),_:1},8,[`disabled`])])],64)):(R(),z(L,{key:1},[V(`p`,aV,` Choose what to restore — `+k(f.value)+` of `+k(s.value.items.length)+` selected. `,1),V(`ul`,oV,[(R(!0),z(L,null,F(s.value.items,e=>(R(),z(`li`,{key:e.id},[H(NB,{modelValue:e.selected,"onUpdate:modelValue":t=>e.selected=t,label:e.label,hint:[e.kind,e.workspaceId,e.note].filter(Boolean).join(` · `),disabled:!e.restorable||a.value},null,8,[`modelValue`,`onUpdate:modelValue`,`label`,`hint`,`disabled`])]))),128))]),V(`div`,sV,[H($,{size:`xs`,variant:`ghost`,disabled:a.value,onClick:t[1]||=e=>C(!0)},{default:M(()=>[...t[8]||=[U(` Select all `,-1)]]),_:1},8,[`disabled`]),H($,{size:`xs`,variant:`ghost`,disabled:a.value,onClick:t[2]||=e=>C(!1)},{default:M(()=>[...t[9]||=[U(` Select none `,-1)]]),_:1},8,[`disabled`])]),V(`p`,cV,[U(` Will restore: `+k(s.value.applied.join(`, `)||`nothing`)+`. `,1),s.value.skipped.length?(R(),z(L,{key:0},[U(` Skipped: `+k(s.value.skipped.join(`, `))+`. `,1)],64)):W(``,!0),s.value.restartRequired?(R(),z(L,{key:1},[U(` The panel's own settings differ, so restart the panel afterwards. `)],64)):p.value?(R(),z(L,{key:2},[U(` Restored workspaces are reloaded immediately; entries marked autostart start on their own. `)],64)):W(``,!0)])],64))]),_:1})):W(``,!0),o.value?(R(),B(vB,{key:3,tone:`danger`},{default:M(()=>[U(k(o.value),1)]),_:1})):W(``,!0)])]),_:1},8,[`open`]))}}),dV=[`aria-label`],fV=P({__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 ze(()=>{r&&clearTimeout(r)}),(e,r)=>(R(),z(`button`,{type:`button`,class:O(j(Q)(`inline-grid size-6 shrink-0 place-items-center rounded-control text-faint transition-colors duration-150 hover:bg-hover hover:text-ink`,j(IL),t.class)),"aria-label":n.value?`Copied`:t.label,onClick:i},[n.value?(R(),B(j(Pv),{key:0,class:`size-3.5 text-ok`})):(R(),B(j(Kv),{key:1,class:`size-3.5`}))],10,dV))}}),pV={key:0,class:`size-1.5 shrink-0 rounded-full bg-current`},mV=P({__name:`ToneBadge`,props:{tone:{default:`neutral`},dot:{type:Boolean,default:!1},mono:{type:Boolean,default:!1},plain:{type:Boolean,default:!1}},setup(e){let t=e,n=G(()=>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`,PF[t.tone].split(` `).filter(e=>e.startsWith(`text-`)).join(` `)):PF[t.tone],t.mono&&`font-mono`));return(e,r)=>(R(),z(`span`,{class:O(n.value)},[t.dot?(R(),z(`span`,pV)):W(``,!0),I(e.$slots,`default`)],2))}}),hV={class:`space-y-3`},gV={key:0,class:`sm:col-span-2`},_V={key:1,class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},vV={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},yV={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},bV={class:`text-2xs leading-4 text-faint`},xV={key:0,class:`space-y-2 sm:col-span-2`},SV={key:1,class:`text-xs text-muted sm:col-span-2`},CV={key:2,class:`divide-y divide-line-soft sm:col-span-2`},wV={class:`flex items-center gap-2`},TV={class:`min-w-0 flex-1 truncate text-xs font-medium text-ink`},EV={key:0,class:`font-mono text-2xs text-faint`},DV={key:0,class:`mt-0.5 text-2xs leading-4 text-muted`},OV={key:1,class:`mt-1 space-y-1`},kV={class:`min-w-0`},AV={class:`truncate font-mono text-2xs text-ink`},jV={class:`mt-0.5 text-2xs leading-4 text-faint`},MV={key:3,class:`text-2xs leading-4 text-faint sm:col-span-2`},NV={key:0,class:`space-y-2 sm:col-span-2`},PV={key:1,class:`sm:col-span-2`},FV={key:2,class:`divide-y divide-line-soft sm:col-span-2`},IV={class:`min-w-0 flex-1`},LV={class:`flex items-center gap-2`},RV={class:`truncate font-mono text-xs text-ink`},zV={class:`mt-0.5 font-mono text-2xs tabular-nums text-muted`},BV={class:`flex items-center gap-1.5`},VV=[`href`],HV={key:3,class:`space-y-2 sm:col-span-2`},UV=P({__name:`BackupsSection`,props:Ra({state:{},policy:{},configPath:{},workspaces:{},dirty:{type:Boolean}},{form:{required:!0},formModifiers:{}}),emits:Ra([`reset`],[`update:form`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`form`),a=VN(),o=hL(()=>i.value.keep,e=>i.value.keep=e,5),s=A(!1),c=A(null),l=A(null),u=A(!1),d=A(!1),f=A(null),p=G(()=>n.state?.files??[]),m=G(()=>n.state?.entries??[]),h={settings:`settings`,servers:`servers`,secrets:`secrets`,tls:`tls`,data:`data`},g=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`,IL);function _(e){f.value=e===void 0?null:{kind:`stored`,name:e},d.value=!0}function v(e){l.value=null,c.value=e,a.refresh()}function y(e){l.value=null,c.value=e,a.refresh()}async function b(e){s.value=!0,l.value=null,c.value=null;try{await gM(e),c.value=`Deleted ${e}.`,await a.refresh()}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{s.value=!1}}return(e,t)=>(R(),z(`div`,hV,[H(NL,{title:`Policy`,description:`How many archives the panel keeps, and the extra paths every one of them captures.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[9]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(rR,{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?W(``,!0):(R(),z(`div`,gV,[H(vB,{tone:`warn`,title:`Backups are off`},{default:M(()=>[...t[10]||=[U(` Nothing new is archived until this is back on. The archives below can still be downloaded, restored and deleted. `,-1)]]),_:1})])),H(WL,{modelValue:j(o),"onUpdate:modelValue":t[2]||=e=>mn(o)?o.value=e:null,label:`Keep`,min:1,hint:`Older archives are pruned after each backup.`},null,8,[`modelValue`]),H(tR,{modelValue:i.value.includePaths,"onUpdate:modelValue":t[3]||=e=>i.value.includePaths=e,label:`Extra paths`,hint:`Comma separated, captured in every archive on top of what each workspace declares.`,placeholder:`{home}/myapp-data`},null,8,[`modelValue`]),n.policy===null?W(``,!0):(R(),z(`div`,_V,[t[13]||=V(`span`,{class:`text-xs font-medium text-muted`},`Archive directory`,-1),V(`div`,vV,[V(`span`,yV,k(n.policy.dir),1),H(fV,{value:n.policy.dir,label:`Copy the archive directory`},null,8,[`value`])]),V(`p`,bV,[t[11]||=U(` Changing it is a file-level decision: edit `,-1),V(`code`,null,k(n.configPath??`the settings file`),1),t[12]||=U(`. `,-1)])]))]),_:1}),H(NL,{title:`What a backup captures`,description:`Pick these in the create dialog. A workspace can be taken whole or only its settings, servers, secrets and declared data paths.`},{default:M(()=>[n.state===null?(R(),z(`div`,xV,[H(Nz,{class:`h-4 w-full`}),H(Nz,{class:`h-4 w-2/3`})])):m.value.length===0?(R(),z(`p`,SV,` Nothing is selectable yet. `)):(R(),z(`ul`,CV,[(R(!0),z(L,null,F(m.value,e=>(R(),z(`li`,{key:e.id,class:`py-2 first:pt-0`},[V(`div`,wV,[V(`p`,TV,k(e.label),1),H(mV,{tone:`neutral`,plain:``},{default:M(()=>[U(k(h[e.kind]??e.kind),1)]),_:2},1024),e.workspaceId?(R(),z(`span`,EV,k(e.workspaceId),1)):W(``,!0)]),e.note?(R(),z(`p`,DV,k(e.note),1)):W(``,!0),e.items.length>0?(R(),z(`ul`,OV,[(R(!0),z(L,null,F(e.items,e=>(R(),z(`li`,{key:e.id,class:`flex items-start justify-between gap-3 rounded-control bg-panel-2/40 px-2 py-1`},[V(`div`,kV,[V(`p`,AV,k(e.path??e.label),1),V(`p`,jV,[U(k(e.included?e.origin?`from ${e.origin}`:e.note??`included`:e.note??`not captured`)+` `,1),e.included&&e.ignoreGenerated?(R(),z(L,{key:0},[U(` · generated directories skipped `)],64)):W(``,!0)])]),H(mV,{tone:e.included?`ok`:`neutral`,plain:``},{default:M(()=>[U(k(e.included?`included`:`skipped`),1)]),_:2},1032,[`tone`])]))),128))])):W(``,!0)]))),128))])),n.workspaces.length>1?(R(),z(`p`,MV,` This panel serves `+k(n.workspaces.length)+` workspaces; each is its own selectable entry. `,1)):W(``,!0)]),_:1}),H(NL,{title:`Archives`,description:`Stored in the backup directory and downloadable at any time.`},{actions:M(()=>[i.value.enabled?(R(),B($,{key:0,size:`xs`,variant:`primary`,disabled:n.state===null,onClick:t[4]||=e=>u.value=!0},{default:M(()=>[...t[14]||=[U(` Create backup… `,-1)]]),_:1},8,[`disabled`])):W(``,!0),H($,{size:`xs`,variant:`secondary`,disabled:n.state===null,onClick:t[5]||=e=>_()},{default:M(()=>[...t[15]||=[U(` Restore… `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[n.state===null?(R(),z(`div`,NV,[H(Nz,{class:`h-4 w-full`}),H(Nz,{class:`h-4 w-2/3`})])):p.value.length===0?(R(),z(`div`,PV,[H(eI,{compact:``,title:`No archives yet`,description:i.value.enabled?`Create one now to capture the panel and whichever workspaces you pick.`:`Nothing has been archived yet, and backups are off.`},va({icon:M(()=>[H(j(jv),{class:`size-4`})]),_:2},[i.value.enabled?{name:`action`,fn:M(()=>[H($,{size:`sm`,variant:`primary`,onClick:t[6]||=e=>u.value=!0},{default:M(()=>[...t[16]||=[U(` Create backup… `,-1)]]),_:1})]),key:`0`}:void 0]),1032,[`description`])])):(R(),z(`ul`,FV,[(R(!0),z(L,null,F(p.value,e=>(R(),z(`li`,{key:e.name,class:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 first:pt-0 last:pb-0`},[V(`div`,IV,[V(`div`,LV,[V(`span`,RV,k(e.name),1),e.encrypted?(R(),B(mV,{key:0,tone:`warn`,plain:``},{default:M(()=>[...t[17]||=[U(` encrypted `,-1)]]),_:1})):W(``,!0)]),V(`p`,zV,k(j(sI)(e.sizeBytes))+` · `+k(j(nI)(e.createdAt)),1)]),V(`div`,BV,[V(`a`,{href:_M(e.name),class:O(j(g))},[H(j(Jv),{class:`size-3`,"aria-hidden":`true`}),t[18]||=U(` Download `,-1)],10,VV),H($,{size:`xs`,variant:`secondary`,onClick:t=>_(e.name)},{default:M(()=>[H(j(by),{class:`size-3`,"aria-hidden":`true`}),t[19]||=U(` Restore `,-1)]),_:1},8,[`onClick`]),H(hB,{label:`Delete`,"confirm-label":`Confirm delete`,size:`xs`,variant:`ghost`,"confirm-variant":`danger`,disabled:s.value,onConfirm:t=>b(e.name)},null,8,[`disabled`,`onConfirm`])])]))),128))])),l.value||c.value?(R(),z(`div`,HV,[l.value?(R(),B(vB,{key:0,tone:`danger`},{default:M(()=>[U(k(l.value),1)]),_:1})):W(``,!0),c.value?(R(),B(vB,{key:1,tone:`ok`},{default:M(()=>[U(k(c.value),1)]),_:1})):W(``,!0)])):W(``,!0)]),_:1}),H(ZB,{open:u.value,"onUpdate:open":t[7]||=e=>u.value=e,state:n.state,onCreated:v},null,8,[`open`,`state`]),H(uV,{open:d.value,"onUpdate:open":t[8]||=e=>d.value=e,files:p.value,initial:f.value,onApplied:y},null,8,[`open`,`files`,`initial`])]))}}),WV={key:0,class:`mt-3 flex flex-wrap items-center gap-1.5`},GV={key:1,class:`mt-3 text-xs text-muted`},KV=P({__name:`HostSection`,props:Ra({config:{},alerts:{},dirty:{type:Boolean}},{host:{required:!0},hostModifiers:{}}),emits:Ra([`reset`],[`update:host`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`host`),a=hL(()=>i.value.intervalMs,e=>i.value.intervalMs=e,15e3),o=hL(()=>i.value.diskUsedPercent,e=>i.value.diskUsedPercent=e,90),s=hL(()=>i.value.memoryUsedPercent,e=>i.value.memoryUsedPercent=e,90),c=hL(()=>i.value.swapUsedPercent,e=>i.value.swapUsedPercent=e,50),l=hL(()=>i.value.loadPerCpu,e=>i.value.loadPerCpu=e,2),u=hL(()=>i.value.tempCelsius,e=>i.value.tempCelsius=e,85);return(e,t)=>(R(),z(L,null,[H(NL,{title:`Thresholds`,description:`A threshold of 0 disables that alert. Breaches notify once, and once more on recovery.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[9]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(rR,{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`]),H(WL,{modelValue:j(a),"onUpdate:modelValue":t[2]||=e=>mn(a)?a.value=e:null,label:`Interval (ms)`,min:5e3,hint:`How often the host is sampled and alerts are checked.`},null,8,[`modelValue`]),H(tR,{modelValue:i.value.diskPaths,"onUpdate:modelValue":t[3]||=e=>i.value.diskPaths=e,label:`Disk paths`,hint:`Comma separated; templates like {home} are expanded.`},null,8,[`modelValue`]),H(WL,{modelValue:j(o),"onUpdate:modelValue":t[4]||=e=>mn(o)?o.value=e:null,label:`Disk used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),H(WL,{modelValue:j(s),"onUpdate:modelValue":t[5]||=e=>mn(s)?s.value=e:null,label:`Memory used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),H(WL,{modelValue:j(c),"onUpdate:modelValue":t[6]||=e=>mn(c)?c.value=e:null,label:`Swap used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),H(WL,{modelValue:j(l),"onUpdate:modelValue":t[7]||=e=>mn(l)?l.value=e:null,label:`Load per CPU`,min:0,hint:`1-minute load average divided by the core count.`},null,8,[`modelValue`]),H(WL,{modelValue:j(u),"onUpdate:modelValue":t[8]||=e=>mn(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?(R(),z(`div`,WV,[t[10]||=V(`span`,{class:`text-xs text-muted`},`Breaching now:`,-1),(R(!0),z(L,null,F(n.alerts,e=>(R(),B(mV,{key:e,tone:`danger`,dot:``},{default:M(()=>[U(k(e),1)]),_:2},1024))),128))])):i.value.enabled?(R(),z(`p`,GV,` Nothing is breaching right now. `)):W(``,!0)],64))}}),qV={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},JV={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},YV={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},XV={class:`text-2xs leading-4 text-faint`},ZV={key:0},QV={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},$V={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},eH={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},tH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},nH=[`disabled`],rH=P({__name:`InterfaceSection`,props:Ra({ui:{},panelVersion:{},labelDirty:{type:Boolean}},{label:{required:!0},labelModifiers:{}}),emits:Ra([`changed`,`resetLabel`],[`update:label`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`label`),a=A(null),o=A(!1),s=A(null),c=A(null),l=A(!1),u=G(()=>{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??`unnamed`}${t.version==null?``:` ${t.version}`}`}),d=G(()=>{let e=n.ui?.meta;if(e==null)return null;let t=e.uploadedAt===void 0?null:new Date(e.uploadedAt).toLocaleString();return`${e.files??0} files${t===null?``:` · ${t}`}`});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 jM(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 MM();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)=>(R(),B(NL,{title:`Interface`,description:`The panel is a static site: keep the stock one, or serve your own build from the state directory.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.labelDirty,onClick:h[1]||=e=>r(`resetLabel`)},{default:M(()=>[...h[6]||=[U(` Reset name `,-1)]]),_:1},8,[`disabled`]),e.ui?.custom?(R(),B($,{key:0,size:`xs`,variant:`ghost`,disabled:o.value,onClick:m},{default:M(()=>[U(k(l.value?`Confirm revert`:`Revert to stock`),1)]),_:1},8,[`disabled`])):W(``,!0),H($,{size:`xs`,variant:`primary`,disabled:o.value||a.value===null,onClick:p},{default:M(()=>[...h[7]||=[U(` Install UI `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[V(`div`,qV,[h[2]||=V(`span`,{class:`text-xs font-medium text-muted`},`Currently serving`,-1),V(`div`,JV,[V(`span`,YV,k(u.value),1),H(fV,{value:e.ui?.dir??``,label:`Copy the UI directory`},null,8,[`value`])]),V(`p`,XV,[d.value?(R(),z(`span`,ZV,k(d.value)+` · `,1)):W(``,!0),V(`code`,null,k(e.ui?.dir??`—`),1)])]),V(`div`,QV,[h[3]||=V(`span`,{class:`text-xs font-medium text-muted`},`Panel version`,-1),V(`div`,$V,[V(`span`,eH,`home-hosted `+k(n.panelVersion??`unknown`),1),n.panelVersion?(R(),B(fV,{key:0,value:n.panelVersion,label:`Copy the panel version`},null,8,[`value`])):W(``,!0)]),h[4]||=V(`p`,{class:`text-2xs leading-4 text-faint`},[U(` The release this panel process is running — `),V(`code`,null,`home-hosted status`),U(` prints the same number. `)],-1)]),H(tR,{modelValue:i.value,"onUpdate:modelValue":h[0]||=e=>i.value=e,label:`Panel name`,hint:`Shown in the sidebar by the stock UI. A custom UI may show its own name instead.`,wide:``},null,8,[`modelValue`]),V(`label`,tH,[h[5]||=V(`span`,{class:`text-xs font-medium text-muted`},`Upload a UI build (.zip with an index.html)`,-1),V(`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,nH)]),c.value?(R(),B(vB,{key:0,tone:`warn`,title:c.value},null,8,[`title`])):s.value?(R(),B(vB,{key:1,tone:`ok`,title:s.value},null,8,[`title`])):W(``,!0),h[8]||=V(`p`,{class:`text-2xs leading-4 text-faint sm:col-span-2`},[U(` See `),V(`code`,null,`docs/UI_CREATION.md`),U(` for the API contract. If a custom UI breaks the panel, `),V(`code`,null,`home-hosted ui-revert`),U(` puts the stock one back from the terminal. `)],-1)]),_:1}))}}),iH={class:`inline-flex items-center gap-0.5 rounded-control border border-line bg-panel-2 p-0.5`},aH=[`aria-pressed`,`onClick`],oH=P({__name:`SegmentedControl`,props:Ra({options:{},size:{default:`sm`}},{modelValue:{default:``},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=oo(e,`modelValue`);return(e,r)=>(R(),z(`div`,iH,[(R(!0),z(L,null,F(t.options,e=>(R(),z(`button`,{key:e.value,type:`button`,class:O(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},k(e.label),11,aH))),128))]))}}),sH={class:`flex min-w-0 flex-col gap-1`},cH={class:`text-2xs leading-4 text-faint`},lH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},uH={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},dH={class:`min-w-0 flex-1 truncate font-mono text-xs tabular-nums text-ink`},fH=P({__name:`ListenerSection`,props:Ra({view:{},dirty:{type:Boolean}},{control:{required:!0},controlModifiers:{}}),emits:Ra([`reset`],[`update:control`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`control`),a=hL(()=>i.value.port,e=>i.value.port=e,3999),o=[`local`,`lan`],s=G({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`&&Qk(t)!==null;i.value.host=r?t:`127.0.0.1`}}),c=G(()=>{if(s.value===`custom`&&Qk(i.value.host)===null)return`Enter an IPv4 address, for example 192.168.1.20.`}),l=G(()=>n.view?.url??`—`);return(e,t)=>(R(),B(NL,{title:`Listener`,description:`Where the panel answers. Moving this restarts the panel and sends this page to the new address.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[5]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(WL,{modelValue:j(a),"onUpdate:modelValue":t[1]||=e=>mn(a)?a.value=e:null,label:`Control port`,min:1,max:65535,hint:`Default 3999.`},null,8,[`modelValue`]),V(`div`,sH,[t[6]||=V(`span`,{class:`text-xs font-medium text-muted`},`Bind`,-1),H(oH,{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`]),V(`p`,cH,k(s.value===`lan`?`0.0.0.0 — reachable from the whole network.`:s.value===`local`?`127.0.0.1 — this machine only.`:`A specific interface address you type in below.`),1)]),s.value===`custom`?(R(),B(tR,{key:0,modelValue:i.value.host,"onUpdate:modelValue":t[3]||=e=>i.value.host=e,label:`IPv4 address`,placeholder:`192.168.1.20`,error:c.value,hint:`Binding beyond 127.0.0.1 needs a real password.`},null,8,[`modelValue`,`error`])):W(``,!0),H(rR,{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`]),V(`div`,lH,[t[8]||=V(`span`,{class:`text-xs font-medium text-muted`},`Live address`,-1),V(`div`,uH,[V(`span`,dH,k(l.value),1),n.view?.restartRequired?(R(),B(mV,{key:0,tone:`warn`,dot:``},{default:M(()=>[...t[7]||=[U(` restart required `,-1)]]),_:1})):W(``,!0),H(fV,{value:l.value,label:`Copy the live address`},null,8,[`value`])]),t[9]||=V(`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}))}}),pH={class:`space-y-3`},mH={class:`divide-y divide-line-soft sm:col-span-2`},hH={class:`min-w-0`},gH={class:`text-xs font-medium text-ink`},_H={class:`mt-0.5 text-2xs leading-4 text-faint`},vH={class:`flex min-w-0 flex-1 items-center justify-end gap-1.5`},yH={class:`min-w-0 truncate font-mono text-xs text-ink`},bH={class:`flex items-center gap-2 text-xs font-medium text-ink`},xH={class:`font-mono text-2xs font-normal text-faint`},SH={class:`divide-y divide-line-soft`},CH={class:`min-w-0`},wH={class:`text-2xs font-medium text-ink`},TH={class:`mt-0.5 text-2xs leading-4 text-faint`},EH={class:`flex min-w-0 flex-1 items-center justify-end gap-1.5`},DH={class:`min-w-0 truncate font-mono text-2xs text-ink`},OH=P({__name:`PathsSection`,props:{dataRoot:{},projectDir:{},panelUrl:{},workspaces:{}},setup(e){let t=e,n=G(()=>t.dataRoot===null?null:`${t.dataRoot}/settings.json`),r=G(()=>[{key:`data`,label:`Data root`,hint:`HHOSTED_HOME — global settings, workspaces, TLS, backups and the UI.`,value:t.dataRoot??`—`},{key:`settings`,label:`Global settings`,hint:`settings.json — listener, auth, TLS policy, host vitals, backups.`,value:n.value??`—`},{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??`—`}]);function i(e){return[{key:`${e.id}:config`,label:`Servers config`,hint:`${e.label}'s servers.config.json.`,value:e.configPath},{key:`${e.id}:settings`,label:`Workspace settings`,hint:`Server defaults, log retention, notifications, DDNS.`,value:e.settingsPath},{key:`${e.id}:logs`,label:`Logs`,hint:`Persisted output for this workspace.`,value:e.logsDir}]}return(t,n)=>(R(),z(`div`,pH,[H(NL,{title:`Where things live`,description:`Read-only. Copy a path straight into a shell or an editor.`},{default:M(()=>[V(`ul`,mH,[(R(!0),z(L,null,F(r.value,e=>(R(),z(`li`,{key:e.key,class:`flex items-start justify-between gap-3 py-2 first:pt-0 last:pb-0`},[V(`div`,hH,[V(`p`,gH,k(e.label),1),V(`p`,_H,k(e.hint),1)]),V(`div`,vH,[V(`span`,yH,k(e.value),1),H(fV,{value:e.value,label:`Copy ${e.label.toLowerCase()}`},null,8,[`value`,`label`])])]))),128))])]),_:1}),H(NL,{title:`Workspace files`,description:`Each workspace owns its config, settings and log directory; nothing is shared between them.`},{default:M(()=>[(R(!0),z(L,null,F(e.workspaces,e=>(R(),z(`div`,{key:e.id,class:`space-y-2 sm:col-span-2`},[V(`p`,bH,[U(k(e.label)+` `,1),V(`span`,xH,k(e.id),1)]),V(`ul`,SH,[(R(!0),z(L,null,F(i(e),e=>(R(),z(`li`,{key:e.key,class:`flex items-start justify-between gap-3 py-1.5`},[V(`div`,CH,[V(`p`,wH,k(e.label),1),V(`p`,TH,k(e.hint),1)]),V(`div`,EH,[V(`span`,DH,k(e.value),1),H(fV,{value:e.value,label:`Copy ${e.label.toLowerCase()}`},null,8,[`value`,`label`])])]))),128))])]))),128))]),_:1})]))}}),kH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},AH={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},jH={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},MH={key:0,class:`sm:col-span-2`},NH={key:1,class:`space-y-3 sm:col-span-2`},PH={class:`divide-y divide-line-soft text-xs`},FH={class:`flex items-start justify-between gap-4 py-1.5`},IH={class:`min-w-0 text-right font-mono text-xs text-ink`},LH={class:`flex items-start justify-between gap-4 py-1.5`},RH={class:`min-w-0 text-right font-mono text-xs text-ink`},zH={class:`flex items-start justify-between gap-4 py-1.5`},BH={class:`font-mono text-xs tabular-nums text-ink`},VH={class:`flex items-center justify-between gap-4 py-1.5`},HH={class:`flex items-start justify-between gap-4 py-1.5`},UH={class:`flex min-w-0 items-center gap-1.5`},WH={class:`min-w-0 truncate font-mono text-2xs text-ink`},GH={key:2,class:`sm:col-span-2`},KH={class:`flex min-w-0 flex-col gap-1`},qH={class:`flex min-w-0 flex-col gap-1`},JH={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},YH={key:3,class:`space-y-2 sm:col-span-2`},XH=P({__name:`TlsSection`,props:Ra({view:{},dirty:{type:Boolean}},{tlsEnabled:{type:Boolean,required:!0},tlsEnabledModifiers:{}}),emits:Ra([`reset`],[`update:tlsEnabled`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`tlsEnabled`),a=VN(),o=A(``),s=A(``),c=A(null),l=A(null),u=A(!1),d=G(()=>n.view?.tls??null),f=G(()=>n.view?`${n.view.protocol}://${n.view.bindHost}:${n.view.port}`:`—`),p=G(()=>o.value.trim().length>0&&s.value.trim().length>0&&!u.value),m=Q(zL,`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 NM(o.value,s.value);o.value=``,s.value=``,c.value=`Certificate stored.`,await a.refresh();let t=await gL(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 PM();c.value=`Certificate removed.`,await a.refresh();let t=await gL(e);t!==null&&(l.value=t)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}return(e,t)=>(R(),z(L,null,[H(NL,{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(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[6]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(rR,{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`]),V(`div`,kH,[t[7]||=V(`span`,{class:`text-xs font-medium text-muted`},`Live address`,-1),V(`div`,AH,[V(`span`,jH,k(f.value),1),H(fV,{value:f.value,label:`Copy the live address`},null,8,[`value`])])])]),_:1}),H(NL,{class:`mt-3`,title:`Certificate`,description:`PEM-encoded certificate and its private key. Both stay in the secrets file.`},{default:M(()=>[d.value?.error?(R(),z(`div`,MH,[H(vB,{tone:`danger`,title:`The stored certificate cannot be used`},{default:M(()=>[U(k(d.value.error),1)]),_:1})])):d.value?.certPresent?(R(),z(`div`,NH,[V(`dl`,PH,[V(`div`,FH,[t[8]||=V(`dt`,{class:`text-muted`},` Subject `,-1),V(`dd`,IH,k(d.value.subject??`—`),1)]),V(`div`,LH,[t[9]||=V(`dt`,{class:`text-muted`},` Issuer `,-1),V(`dd`,RH,k(d.value.issuer??`—`),1)]),V(`div`,zH,[t[10]||=V(`dt`,{class:`text-muted`},` Valid until `,-1),V(`dd`,BH,[U(k(d.value.validTo?d.value.validTo.slice(0,10):`—`)+` `,1),d.value.daysRemaining===null?W(``,!0):(R(),z(`span`,{key:0,class:O(j(Q)(`ml-1.5`,d.value.daysRemaining<14?`text-warn`:`text-faint`))},` (`+k(d.value.daysRemaining)+` days) `,3))])]),V(`div`,VH,[t[11]||=V(`dt`,{class:`text-muted`},` Private key `,-1),V(`dd`,null,[H(mV,{tone:d.value.keyMatches?`ok`:`danger`,dot:``},{default:M(()=>[U(k(d.value.keyMatches?`matches the certificate`:`does not match`),1)]),_:1},8,[`tone`])])]),V(`div`,HH,[t[12]||=V(`dt`,{class:`text-muted`},` Fingerprint `,-1),V(`dd`,UH,[V(`span`,WH,k(d.value.fingerprint??`—`),1),d.value.fingerprint?(R(),B(fV,{key:0,value:d.value.fingerprint,label:`Copy the fingerprint`},null,8,[`value`])):W(``,!0)])])])])):(R(),z(`div`,GH,[H(vB,{tone:`info`,title:`No certificate uploaded`},{default:M(()=>[...t[13]||=[U(` Upload a PEM certificate and key below, then save. HTTPS is not served until a certificate is present. `,-1)]]),_:1})])),V(`div`,KH,[V(`label`,{class:O(j(LL)),for:`tls-cert-file`},`Certificate file (.pem, .crt)`,2),V(`input`,{id:`tls-cert-file`,type:`file`,accept:`.pem,.crt,.cer,text/plain`,class:O(j(m)),onChange:t[2]||=e=>h(e,`cert`)},null,34)]),V(`div`,qH,[V(`label`,{class:O(j(LL)),for:`tls-key-file`},`Private key file (.pem, .key)`,2),V(`input`,{id:`tls-key-file`,type:`file`,accept:`.pem,.key,text/plain`,class:O(j(m)),onChange:t[3]||=e=>h(e,`key`)},null,34)]),H(yR,{modelValue:o.value,"onUpdate:modelValue":t[4]||=e=>o.value=e,label:`Or paste the certificate`,rows:4,placeholder:`-----BEGIN CERTIFICATE-----`},null,8,[`modelValue`]),H(yR,{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`]),V(`div`,JH,[H($,{variant:`primary`,disabled:!p.value,loading:u.value,onClick:g},{default:M(()=>[...t[14]||=[U(` Save certificate `,-1)]]),_:1},8,[`disabled`,`loading`]),d.value?.certPresent?(R(),B(hB,{key:0,label:`Remove certificate`,"confirm-label":`Confirm remove`,"confirm-variant":`danger`,disabled:u.value,onConfirm:_},null,8,[`disabled`])):W(``,!0)]),l.value||c.value?(R(),z(`div`,YH,[l.value?(R(),B(vB,{key:0,tone:`danger`},{default:M(()=>[U(k(l.value),1)]),_:1})):W(``,!0),c.value?(R(),B(vB,{key:1,tone:`ok`},{default:M(()=>[U(k(c.value),1)]),_:1})):W(``,!0)])):W(``,!0)]),_:1})],64))}}),ZH={class:`min-h-full`},QH={class:`mx-auto w-full max-w-5xl px-4 pb-6 pt-5 sm:px-6`},$H={class:`lg:grid lg:grid-cols-[11rem_minmax(0,1fr)] lg:gap-8`},eU={"aria-label":`Global settings sections`,class:`hidden lg:block`},tU={class:`sticky top-6 space-y-0.5 border-l border-line`},nU=[`aria-current`,`onClick`],rU={class:`space-y-6`},iU={id:`listener`,class:`scroll-mt-5`},aU={id:`authentication`,class:`scroll-mt-5`},oU={id:`host`,class:`scroll-mt-5`},sU={id:`backups`,class:`scroll-mt-5`},cU={id:`tls`,class:`scroll-mt-5`},lU={id:`interface`,class:`scroll-mt-5`},uU={id:`paths`,class:`scroll-mt-5`},dU={class:`sticky bottom-0 z-30 border-t border-line bg-panel/95 backdrop-blur`},fU={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`},pU={class:`min-w-0 flex-1`},mU={class:`text-xs text-muted`},hU={class:`font-mono tabular-nums text-ink`},gU={key:0,class:`mt-0.5 text-xs text-danger`},_U={key:1,class:`mt-0.5 text-xs text-ok`},vU={class:`flex shrink-0 items-center gap-2`},yU={class:`max-h-[60dvh] overflow-auto px-4 py-3`},bU={key:0,class:`divide-y divide-line-soft`},xU={class:`font-mono text-xs text-ink`},SU={class:`ml-auto font-mono text-xs text-muted line-through`},CU={class:`font-mono text-xs text-accent`},wU={key:1,class:`text-xs text-muted`},TU={class:`flex items-center justify-end gap-2 border-t border-line px-4 py-3`},EU=P({__name:`GlobalSettingsView`,setup(e){let t=[{id:`listener`,title:`Listener`},{id:`authentication`,title:`Authentication`},{id:`host`,title:`Host vitals`},{id:`backups`,title:`Backups`},{id:`tls`,title:`TLS`},{id:`interface`,title:`Interface`},{id:`paths`,title:`Paths`}],n=Rg(),r=Lg(),i=VN(),a=cN(),o=en(YI()),s=A(`listener`),c=A(!1),l=A(null),u=A(null),d=A(null),f=A(null),p=G(()=>i.control.value),m=G(()=>i.host.value?.alerts??[]),h=G(()=>f.value?.host??null),g=G(()=>f.value?.backups??null),_=G(()=>i.backups.value),v=G(()=>f.value?.ui??null),y=G(()=>i.version.value),b=G(()=>i.dataRoot.value),x=G(()=>i.projectDir.value),S=G(()=>b.value===null?null:`${b.value}/settings.json`),C=G(()=>{let e={},t=p.value;if(t!==null){let n=aL(t,o);Object.keys(n).length>0&&(e.control=n)}let n=h.value;if(n!==null){let t=rL(n,o.host);Object.keys(t).length>0&&(e.host=t)}let r=g.value;if(r!==null){let t=iL(r,o.backups);Object.keys(t).length>0&&(e.backups=t)}return e}),w=G(()=>UI(C.value)),T=G(()=>{let e=p.value,t=h.value,n=g.value;return{control:e===null?{}:{...QI(e),auth:ZI(e.auth)},host:t??{},backups:n===null?{}:{enabled:n.enabled,keep:n.keep,includePaths:n.includePaths}}}),ee=G(()=>HI(C.value,T.value)),E=A(!1),te=G(()=>p.value!==null&&fL(p.value,o)),ne=G(()=>p.value!==null&&pL(p.value,o)),re=G(()=>p.value!==null&&mL(p.value,o)),ie=G(()=>h.value!==null&&Object.keys(rL(h.value,o.host)).length>0),ae=G(()=>g.value!==null&&Object.keys(iL(g.value,o.backups)).length>0),oe={};function se(){let e=(e,t)=>{dL(oe[e],lL(o,e))||(t(),oe[e]=lL(o,e))},t=p.value;t!==null&&e(`control`,()=>{Object.assign(o.control,QI(t)),Object.assign(o.auth,ZI(t.auth))});let n=h.value;n!==null&&e(`host`,()=>Object.assign(o.host,tL(n)));let r=g.value;r!==null&&e(`backups`,()=>Object.assign(o.backups,nL(r)))}function ce(){for(let e of Object.keys(oe))delete oe[e]}function D(e){oe[e]=lL(o,e)}N([p,f],()=>{se()},{immediate:!0});async function le(){d.value=null;try{f.value=await cM()}catch(e){d.value=e instanceof Error?e.message:String(e)}}ta(()=>{le()});async function ue(){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.saveGlobalSettings(e);if(!t){l.value=i.lastError.value??`The settings could not be saved.`;return}u.value=`Settings saved.`,a.success(`Settings saved`),await le(),ce(),se();let n=await gL(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 de(){l.value=null,u.value=null,ce(),se()}function fe(){h.value!==null&&Object.assign(o.host,tL(h.value)),D(`host`)}function pe(){g.value!==null&&Object.assign(o.backups,nL(g.value)),D(`backups`)}function me(){if(p.value!==null){let e=QI(p.value);o.control.label=e.label,o.control.port=e.port,o.control.host=e.host,o.control.openBrowser=e.openBrowser}D(`control`)}function he(){p.value!==null&&Object.assign(o.auth,ZI(p.value.auth)),D(`control`)}function ge(){p.value!==null&&(o.control.tlsEnabled=p.value.tls.enabled),D(`control`)}function _e(e){rr(()=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})})}function ve(e){s.value=e,n.query.section!==e&&r.replace({query:{...n.query,section:e}}),_e(e)}N(()=>n.query.section,e=>{let n=typeof e==`string`?e:``;t.some(e=>e.id===n)&&(s.value=n,_e(n))},{immediate:!0});let ye=null;return ta(()=>{ye=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&&ye.observe(t)}}),ia(()=>ye?.disconnect()),(e,n)=>(R(),z(L,null,[V(`div`,ZH,[V(`div`,QH,[n[17]||=V(`header`,{class:`mb-5`},[V(`h1`,{class:`text-xl font-semibold tracking-tight text-ink`},` Global settings `),V(`p`,{class:`mt-1 text-xs text-muted`},` Listener, access, host vitals, backups, TLS and paths for this panel — shared by every workspace. `)],-1),d.value?(R(),B(vB,{key:0,tone:`warn`,title:`Some file-only values could not be loaded`,class:`mb-4`},{default:M(()=>[U(k(d.value),1)]),_:1})):W(``,!0),V(`div`,$H,[V(`nav`,eU,[V(`ul`,tU,[(R(),z(L,null,F(t,e=>V(`li`,{key:e.id},[V(`button`,{type:`button`,"aria-current":s.value===e.id?`true`:void 0,class:O(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=>ve(e.id)},k(e.title),11,nU)])),64))])]),V(`div`,rU,[V(`section`,iU,[n[10]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Listener `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Where the control panel listens and how it announces itself. `)],-1),H(fH,{control:o.control,"onUpdate:control":n[0]||=e=>o.control=e,view:p.value,dirty:te.value,onReset:me},null,8,[`control`,`view`,`dirty`])]),V(`section`,aU,[n[11]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Authentication `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Who may sign in to this panel, and how a session is trusted. `)],-1),H(xB,{auth:o.auth,"onUpdate:auth":n[1]||=e=>o.auth=e,view:p.value,dirty:re.value,onReset:he},null,8,[`auth`,`view`,`dirty`])]),V(`section`,oU,[n[12]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Host vitals `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Alert thresholds for this machine's own resources. `)],-1),H(KV,{host:o.host,"onUpdate:host":n[2]||=e=>o.host=e,config:h.value,alerts:m.value,dirty:ie.value,onReset:fe},null,8,[`host`,`config`,`alerts`,`dirty`])]),V(`section`,sU,[n[13]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Backups `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` One archive per capture, covering the panel and any workspace you pick. `)],-1),H(UV,{form:o.backups,"onUpdate:form":n[3]||=e=>o.backups=e,state:_.value,policy:g.value,"config-path":S.value,workspaces:j(i).workspaces.value,dirty:ae.value,onReset:pe},null,8,[`form`,`state`,`policy`,`config-path`,`workspaces`,`dirty`])]),V(`section`,cU,[n[14]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` TLS `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Serve the panel over HTTPS with your own certificate. `)],-1),H(XH,{"tls-enabled":o.control.tlsEnabled,"onUpdate:tlsEnabled":n[4]||=e=>o.control.tlsEnabled=e,view:p.value,dirty:ne.value,onReset:ge},null,8,[`tls-enabled`,`view`,`dirty`])]),V(`section`,lU,[n[15]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Interface `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Serve your own panel UI instead of the stock one. `)],-1),H(rH,{label:o.control.label,"onUpdate:label":n[5]||=e=>o.control.label=e,ui:v.value,"panel-version":y.value,"label-dirty":te.value,onChanged:le,onResetLabel:me},null,8,[`label`,`ui`,`panel-version`,`label-dirty`])]),V(`section`,uU,[n[16]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Paths `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Where home-hosted keeps its files, globally and per workspace. `)],-1),H(OH,{"data-root":b.value,"project-dir":x.value,"panel-url":p.value?.url??null,workspaces:j(i).workspaces.value},null,8,[`data-root`,`project-dir`,`panel-url`,`workspaces`])])])])]),V(`div`,dU,[V(`div`,fU,[V(`div`,pU,[V(`p`,mU,[w.value>0?(R(),z(`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[6]||=e=>E.value=!0},[V(`span`,hU,k(w.value),1),U(` field`+k(w.value===1?``:`s`)+` changed `,1)])):(R(),z(L,{key:1},[U(` No unsaved changes `)],64))]),l.value?(R(),z(`p`,gU,k(l.value),1)):u.value?(R(),z(`p`,_U,k(u.value),1)):W(``,!0)]),V(`div`,vU,[H($,{variant:`ghost`,disabled:w.value===0||c.value,onClick:de},{default:M(()=>[...n[18]||=[U(` Discard changes `,-1)]]),_:1},8,[`disabled`]),H($,{variant:`primary`,disabled:w.value===0,loading:c.value,onClick:ue},{default:M(()=>[...n[19]||=[U(` Save settings `,-1)]]),_:1},8,[`disabled`,`loading`])])])])]),H(hR,{open:E.value,"onUpdate:open":n[9]||=e=>E.value=e,title:`Unsaved changes`,description:`What Save would write to the panel's settings file.`,width:`w-[min(92vw,42rem)]`},{default:M(()=>[V(`div`,yU,[ee.value.length>0?(R(),z(`ul`,bU,[(R(!0),z(L,null,F(ee.value,e=>(R(),z(`li`,{key:e.path,class:`flex flex-wrap items-baseline gap-x-3 gap-y-1 py-2 first:pt-0`},[V(`code`,xU,k(e.path),1),V(`span`,SU,k(j(uI)(e.from)),1),n[20]||=V(`span`,{class:`text-2xs text-faint`},`→`,-1),V(`span`,CU,k(j(uI)(e.to)),1)]))),128))])):(R(),z(`p`,wU,` Nothing to save. `))]),V(`footer`,TU,[H($,{size:`sm`,variant:`ghost`,onClick:n[7]||=e=>E.value=!1},{default:M(()=>[...n[21]||=[U(` Close `,-1)]]),_:1}),H($,{size:`sm`,variant:`primary`,disabled:ee.value.length===0||c.value,loading:c.value,onClick:n[8]||=e=>{ue(),E.value=!1}},{default:M(()=>[U(` Save `+k(ee.value.length)+` change`+k(ee.value.length===1?``:`s`),1)]),_:1},8,[`disabled`,`loading`])])]),_:1},8,[`open`])],64))}}),DU={class:`relative flex min-h-dvh items-center justify-center overflow-hidden bg-page px-4 py-10`},OU={class:`hh-enter relative w-full max-w-md`},kU={class:`rounded-panel border border-line bg-panel/95 p-5 shadow-float backdrop-blur-sm`},AU={class:`flex items-start justify-between gap-3`},jU={class:`min-w-0`},MU={class:`text-base font-semibold text-ink`},NU={class:`mt-1 text-xs leading-relaxed text-muted`},PU={class:`flex flex-col gap-1.5`},FU={class:`relative`},IU=[`type`],LU=[`aria-label`],RU={key:0,class:`rounded-control border border-danger/25 bg-danger-soft px-2.5 py-2 text-xs text-danger`},zU={key:1,class:`mt-5`},BU={class:`mt-4 space-y-2`},VU={key:0,class:`flex items-start gap-2 rounded-control border border-warn/25 bg-warn-soft px-2.5 py-2`},HU={class:`text-2xs leading-4 text-warn`},UU={class:`ml-1 rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},WU={key:1,class:`flex items-start gap-2 rounded-control border border-warn/25 bg-warn-soft px-2.5 py-2`},GU={key:2,class:`flex items-start gap-2 rounded-control border border-line-soft bg-panel-2 px-2.5 py-2`},KU={class:`text-2xs leading-4 text-muted`},qU={class:`mt-4 flex items-center justify-center gap-2 text-2xs text-faint`},JU={class:`font-mono`},YU=P({__name:`LoginView`,setup(e){let t=Rg(),n=Lg(),r=VN(),{session:i,error:a,login:o,refresh:s}=rN(),c=A(``),l=A(!1),u=A(!1),d=G(()=>i.value?.passwordSet===!1),f=G(()=>i.value!==null&&!i.value.authRequired),p=G(()=>i.value?.usingDefaultPassword===!0&&i.value.defaultPassword!==null),m=G(()=>r.control.value?.auth.exposed===!0),h=G(()=>r.control.value?.url??`—`),g=G(()=>d.value?`This panel has no password yet`:f.value?`Authentication is turned off`:`Sign in to continue`),_=G(()=>d.value?`Anything on this machine can reach it. Set a password right after you are in.`:f.value?`The panel only listens on loopback, which is the only thing protecting it right now.`:`The control panel is protected. Enter the password to continue.`);async function v(){l.value=!0;try{if(await o(c.value)){c.value=``;let e=typeof t.query.next==`string`?t.query.next:`/`;await n.push(e)}}finally{l.value=!1}}async function y(){await s(),await n.push(`/`)}return ta(async()=>{i.value===null&&await s()}),(e,t)=>(R(),z(`div`,DU,[t[11]||=V(`div`,{class:`bg-instrument pointer-events-none absolute inset-0 opacity-60`},null,-1),t[12]||=V(`div`,{class:`pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_at_center,transparent_15%,var(--page)_78%)]`},null,-1),V(`div`,OU,[t[10]||=Ds(`<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),V(`section`,kU,[V(`div`,AU,[V(`div`,jU,[V(`h1`,MU,k(g.value),1),V(`p`,NU,k(_.value),1)]),m.value?(R(),B(mV,{key:0,tone:`warn`,dot:``},{default:M(()=>[...t[2]||=[U(` Exposed `,-1)]]),_:1})):W(``,!0)]),f.value?(R(),z(`div`,zU,[H($,{variant:`primary`,size:`md`,block:``,onClick:y},{default:M(()=>[...t[4]||=[U(` Open the dashboard `,-1)]]),_:1})])):(R(),z(`form`,{key:0,class:`mt-5 space-y-3`,onSubmit:cu(v,[`prevent`])},[V(`div`,PU,[V(`label`,{for:`hh-password`,class:O(j(LL))},`Password`,2),V(`div`,FU,[xr(V(`input`,{id:`hh-password`,"onUpdate:modelValue":t[0]||=e=>c.value=e,type:u.value?`text`:`password`,autocomplete:`current-password`,autofocus:``,required:``,class:O(j(Q)(j(zL),`pr-9`))},null,10,IU),[[nu,c.value]]),V(`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?(R(),B(j(Zv),{key:0,class:`size-3.5`})):(R(),B(j(Qv),{key:1,class:`size-3.5`}))],8,LU)])]),j(a)?(R(),z(`p`,RU,k(j(a)),1)):W(``,!0),H($,{type:`submit`,variant:`primary`,size:`md`,block:``,loading:l.value},{default:M(()=>[H(j(sy),{class:`size-3.5`}),t[3]||=U(` Sign in `,-1)]),_:1},8,[`loading`])],32)),V(`div`,BU,[p.value?(R(),z(`div`,VU,[H(j(Ey),{class:`mt-0.5 size-3.5 shrink-0 text-warn`}),V(`p`,HU,[t[5]||=U(` Still on the default password `,-1),V(`code`,UU,k(j(i)?.defaultPassword),1),t[6]||=U(`. Change it under Settings — binding beyond 127.0.0.1 stays refused until you do. `,-1)])])):d.value?(R(),z(`div`,WU,[H(j(Oy),{class:`mt-0.5 size-3.5 shrink-0 text-warn`}),t[7]||=V(`p`,{class:`text-2xs leading-4 text-warn`},[U(` No password is set. Open Settings from this machine to add one, or run `),V(`code`,{class:`rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},`pnpm run auth:set-password`),U(`. `)],-1)])):(R(),z(`div`,GU,[H(j(Dy),{class:`mt-0.5 size-3.5 shrink-0 text-ok`}),V(`p`,KU,` Sessions last `+k(Math.round((j(i)?.sessionTtlMs??0)/864e5))+` days. Signing out clears this browser only. `,1)]))])]),V(`p`,qU,[V(`span`,JU,k(h.value),1),t[8]||=V(`span`,{"aria-hidden":`true`},`·`,-1),t[9]||=V(`span`,null,`served from this machine`,-1)])])]))}}),XU=[`#3f4a5c`,`#f07178`,`#7fd88f`,`#e6b673`,`#82aaff`,`#c792ea`,`#7fdbca`,`#c7d2e3`,`#5a6779`,`#ff8b92`,`#9ae6a8`,`#f2c98a`,`#9dbaff`,`#d7aef0`,`#9ce9dc`,`#eef3fb`],ZU=[`#4b5563`,`#c0392b`,`#1c7c3f`,`#9a6700`,`#2f5fe0`,`#7c3aed`,`#0b6f89`,`#334155`,`#6b7280`,`#d64535`,`#22854a`,`#a8620d`,`#3f6bff`,`#8b5cf6`,`#0e7d9c`,`#0f1722`],QU=/\u001B\[([0-9;]*)m/g,$U=/\u001B(?:\[[0-9;?]*[A-HJKSTfhilmnprsu]|\][^\u0007\u001B]*(?:\u0007|\u001B\\)?|[()][0-9A-Z])/g;function eW(e){return Math.max(0,Math.min(255,e))}function tW(e){return e===0?0:55+e*40}function nW(e,t){let n=t?XU:ZU;if(e<16)return n[e]??n[7];if(e<232){let t=e-16;return`rgb(${tW(Math.floor(t/36))} ${tW(Math.floor(t%36/6))} ${tW(t%6)})`}let r=8+(e-232)*10;return`rgb(${r} ${r} ${r})`}function rW(){return{fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1}}function iW(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,rW());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?XU:ZU)[i-30]??null;else if(i>=90&&i<=97)e.fg=(n?XU:ZU)[i-90+8]??null;else if(i>=40&&i<=47)e.bg=(n?XU:ZU)[i-40]??null;else if(i>=100&&i<=107)e.bg=(n?XU:ZU)[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]=nW(eW(r[t+2]),n),t+=2):o===2&&(e[a]=`rgb(${eW(r[t+2]??0)} ${eW(r[t+3]??0)} ${eW(r[t+4]??0)})`,t+=4)}}}function aW(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 oW(e){return e.includes(`\x1B`)}function sW(e,t=!0){if(!oW(e))return[{text:e,fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1}];let n=[],r=rW(),i=0;QU.lastIndex=0;let a=QU.exec(e);for(;a!==null;)aW(n,e.slice(i,a.index).replace($U,``),r),iW(r,a[1]??``,t),i=a.index+a[0].length,a=QU.exec(e);return aW(n,e.slice(i).replace($U,``),r),n}var cW={class:`flex h-5 w-max min-w-full items-center gap-2 whitespace-pre px-2 font-mono text-xs leading-5`},lW={key:0,class:`shrink-0 select-none text-faint`},uW={class:`min-w-0`},dW=P({__name:`LogRow`,props:{line:{},query:{},dark:{type:Boolean},showTime:{type:Boolean}},setup(e){let t=e,n=G(()=>sW(t.line.text,t.dark)),r=G(()=>{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)=>(R(),z(`div`,cW,[t.showTime?(R(),z(`span`,lW,k(j(tI)(t.line.ts)),1)):W(``,!0),V(`span`,{class:O([`h-3.5 w-0.5 shrink-0 rounded-full`,[i[t.line.stream]]]),"aria-hidden":`true`},null,2),V(`span`,uW,[(R(!0),z(L,null,F(r.value,(e,t)=>(R(),z(`span`,{key:t,style:ge(a(e))},k(e.text),5))),128))])]))}}),fW={class:`flex min-h-0 flex-col overflow-hidden rounded-panel border border-line bg-panel`},pW={class:`flex flex-wrap items-center gap-2 border-b border-line bg-panel-2/60 px-2.5 py-2`},mW={class:`relative min-w-40 flex-1 sm:max-w-72`},hW={class:`absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5`},gW={key:0,class:`px-1 font-mono text-2xs tabular-nums text-faint`},_W={class:`ml-auto flex items-center gap-1.5`},vW=[`href`,`download`],yW={class:`relative min-h-0 flex-1`},bW={key:0,class:`px-3 py-6 text-center text-xs text-faint`},xW={class:`flex items-center gap-3 border-t border-line bg-panel-2/60 px-2.5 py-1.5 text-2xs text-faint`},SW={class:`flex items-center gap-1.5`},CW={class:`font-mono tabular-nums`},wW={key:0,class:`font-mono tabular-nums`},TW=20,EW=12,DW=P({__name:`LogViewer`,props:{lines:{},version:{default:0},live:{type:Boolean,default:!1},emptyHint:{default:`No output yet.`},clearable:{type:Boolean,default:!1},downloadUrl:{default:void 0},downloadName:{default:void 0},minHeight:{default:`16rem`}},emits:[`clear`],setup(e,{emit:t}){let n=e,r=t,i=XN(),a=A(null),o=A(0),s=A(320),c=A(!0),l=A(`all`),u=A(``),d=A(!0),f=A(0),p=G(()=>{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=G(()=>p.value.length),h=G(()=>{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=G(()=>Math.max(0,Math.floor(o.value/TW)-EW)),_=G(()=>Math.min(m.value,Math.ceil((o.value+s.value)/TW)+EW)),v=G(()=>p.value.slice(g.value,_.value)),y=G(()=>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*TW-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]))}N(m,()=>{c.value&&(f.value=0,requestAnimationFrame(x))}),N(h,()=>{f.value=0,h.value.length>0&&u.value.trim().length>0&&requestAnimationFrame(()=>S(h.value[0]))}),N(l,()=>{c.value=!0,requestAnimationFrame(x)});let w=null;ta(()=>{let e=a.value;e&&(s.value=e.clientHeight,w=new ResizeObserver(()=>{a.value&&(s.value=a.value.clientHeight)}),w.observe(e),x())}),ze(()=>{w?.disconnect(),w=null});let T=[{value:`all`,label:`All`},{value:`stdout`,label:`out`},{value:`stderr`,label:`err`},{value:`system`,label:`sys`}];return(e,t)=>(R(),z(`div`,fW,[V(`header`,pW,[H(oH,{modelValue:l.value,"onUpdate:modelValue":t[0]||=e=>l.value=e,options:T},null,8,[`modelValue`]),V(`div`,mW,[H(j(Cy),{class:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),xr(V(`input`,{"onUpdate:modelValue":t[1]||=e=>u.value=e,type:`search`,placeholder:`Search this output`,class:O([`h-7 py-0 pl-7 text-xs`,[j(zL)]]),"aria-label":`Search the log output`,onKeydown:t[2]||=uu(cu(e=>C(e.shiftKey?-1:1),[`prevent`]),[`enter`])},null,34),[[ql,u.value]]),V(`div`,hW,[u.value.trim().length>0?(R(),z(`span`,gW,k(h.value.length===0?`0`:`${f.value+1}/${h.value.length}`),1)):W(``,!0),u.value.length>0?(R(),z(`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=``},[H(j(Ry),{class:`size-3`})])):W(``,!0),h.value.length>0?(R(),z(`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)},[H(j(Rv),{class:`size-3`})])):W(``,!0),h.value.length>0?(R(),z(`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)},[H(j(Fv),{class:`size-3`})])):W(``,!0)])]),V(`div`,_W,[H(JR,{label:d.value?`Hide timestamps`:`Show timestamps`},{default:M(()=>[H($,{size:`xs`,variant:`ghost`,onClick:t[6]||=e=>d.value=!d.value},{default:M(()=>[H(j(Uv),{class:O(j(Q)(`size-3`,d.value?`fill-accent text-accent`:`text-faint`))},null,8,[`class`]),t[9]||=U(` ts `,-1)]),_:1})]),_:1},8,[`label`]),H($,{size:`xs`,variant:c.value?`secondary`:`primary`,onClick:t[7]||=e=>c.value?c.value=!1:x()},{default:M(()=>[(R(),B(ma(c.value?j(my):j(gy)),{class:`size-3`})),U(` `+k(c.value?`Pause`:`Follow`),1)]),_:1},8,[`variant`]),n.clearable?(R(),B(JR,{key:0,label:`Clear the in-memory buffer`},{default:M(()=>[H($,{size:`icon-sm`,variant:`ghost`,"aria-label":`Clear the log buffer`,onClick:t[8]||=e=>r(`clear`)},{default:M(()=>[H(j(Fy),{class:`size-3.5`})]),_:1})]),_:1})):W(``,!0),n.downloadUrl?(R(),B(JR,{key:1,label:`Download the persisted file`},{default:M(()=>[V(`a`,{href:n.downloadUrl,download:n.downloadName},[H($,{size:`icon-sm`,variant:`ghost`,"aria-label":`Download the log file`},{default:M(()=>[H(j(Mv),{class:`size-3.5`})]),_:1})],8,vW)]),_:1})):W(``,!0)])]),V(`div`,yW,[V(`div`,{ref_key:`scroller`,ref:a,class:`h-full overflow-auto overscroll-contain bg-page/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/50`,style:ge({minHeight:n.minHeight}),tabindex:`0`,role:`log`,"aria-label":`Log output`,onScrollPassive:b},[m.value===0?(R(),z(`p`,bW,k(n.lines.length===0?n.emptyHint:`Nothing matches that search or stream filter.`),1)):(R(),z(`div`,{key:1,class:`relative w-full`,style:ge({height:`${m.value*TW}px`})},[(R(!0),z(L,null,F(v.value,(e,t)=>(R(),z(`div`,{key:g.value+t,class:O([`absolute left-0 top-0`,g.value+t===y.value&&`bg-warn/10`]),style:ge({transform:`translateY(${(g.value+t)*TW}px)`})},[H(dW,{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),H(Ec,{"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?(R(),z(`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},[H(j(Mv),{class:`size-3`}),t[10]||=U(` Jump to latest `,-1)])):W(``,!0)]),_:1})]),V(`footer`,xW,[V(`span`,SW,[V(`span`,{class:O(j(Q)(`size-1.5 rounded-full`,n.live?c.value?`bg-ok`:`bg-warn`:`bg-faint`))},null,2),U(` `+k(n.live?c.value?`streaming`:`paused`:`snapshot`),1)]),V(`span`,CW,k(m.value===n.lines.length?`${m.value} lines`:`${m.value} of ${n.lines.length} lines`),1),u.value.trim().length>0?(R(),z(`span`,wW,k(h.value.length)+` matches`,1)):W(``,!0),V(`span`,{class:`ml-auto hidden font-mono tabular-nums sm:inline`},`row height `+k(TW)+`px · windowed`)])]))}}),OW={class:`flex h-full min-h-0`},kW={class:`hidden w-64 shrink-0 flex-col border-r border-line bg-panel/40 md:flex`},AW={class:`border-b border-line px-3 py-2.5`},jW={class:`mt-0.5 text-2xs text-faint`},MW={class:`min-h-0 flex-1 overflow-y-auto p-1.5`},NW={key:0,class:`space-y-1.5 p-1.5`},PW=[`onClick`],FW={class:`min-w-0 flex-1`},IW={class:`block truncate font-mono text-2xs text-faint`},LW={class:`flex min-w-0 flex-1 flex-col`},RW={class:`flex flex-wrap items-center gap-2 border-b border-line bg-panel/40 px-3 py-2.5`},zW={class:`min-w-0`},BW={class:`truncate text-sm font-semibold text-ink`},VW={key:0,class:`ml-1.5 font-mono text-2xs font-normal text-faint`},HW={key:0,class:`flex flex-wrap items-center gap-1.5 border-b border-line-soft bg-panel-2/40 px-3 py-2`},UW=[`href`,`download`],WW={class:`text-faint`},GW={key:1,class:`text-2xs text-faint`},KW={key:2,class:`ml-auto font-mono text-2xs text-faint`},qW={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`},JW={class:`min-h-0 flex-1 p-3`},YW=P({__name:`LogsView`,setup(e){let t=Rg(),n=Lg(),r=nP(),i=A([]),a=A(null),o=A(`disk`),s=A(`2000`),c=A(!1),l=A(null),u=A([]),d=A(0),f=A(!1),p=A(!0),m=G(()=>i.value.find(e=>e.serverId===a.value)??null),h=BN(r.activeId,()=>o.value===`live`?a.value:null),g=h.version,_=G(()=>(g.value,h.lines())),v=G(()=>o.value===`live`?_.value:u.value),y=G(()=>o.value===`live`?g.value:d.value),b=[{value:`200`,label:`200 lines`},{value:`500`,label:`500 lines`},{value:`2000`,label:`2000 lines`},{value:`5000`,label:`5000 lines`}],x=G(()=>i.value.reduce((e,t)=>e+t.sizeBytes,0)),S=G(()=>i.value.filter(e=>e.files.length>0).length);async function C(){p.value=!0;try{i.value=await dM(r.activeId.value);let e=typeof t.query.server==`string`?t.query.server:null,n=e&&i.value.some(t=>t.serverId===e)?e:a.value&&i.value.some(e=>e.serverId===a.value)?a.value:i.value[0]?.serverId??null;a.value=n}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{p.value=!1}}async function w(){let e=a.value;if(e!==null&&o.value!==`live`){c.value=!0,l.value=null;try{let t=await fM(r.activeId.value,e,{tail:Number(s.value)});u.value=t.lines,d.value+=1}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{c.value=!1}}}async function T(){let e=a.value;if(e!==null){f.value=!1;try{await pM(r.activeId.value,e),u.value=[],d.value+=1,await C()}catch(e){l.value=e instanceof Error?e.message:String(e)}}}function ee(e){a.value=e,o.value===`live`&&(u.value=[]),n.replace({query:{...t.query,server:e}})}return N([a,s,o],()=>{o.value===`disk`&&w()},{immediate:!1}),N(()=>r.activeId.value,()=>{a.value=null,u.value=[],o.value=`disk`,C().then(()=>w())}),ta(async()=>{await C(),o.value===`disk`&&await w()}),(e,t)=>(R(),z(`div`,OW,[V(`aside`,kW,[V(`div`,AW,[t[5]||=V(`p`,{class:`text-xs font-semibold text-ink`},` Persisted logs `,-1),V(`p`,jW,k(j(r).selected.value?.label??`Workspace`)+` · `+k(S.value)+` of `+k(i.value.length)+` servers on disk · `+k(j(sI)(x.value)),1)]),V(`div`,MW,[p.value?(R(),z(`div`,NW,[(R(),z(L,null,F(5,e=>H(Nz,{key:e,class:`h-10 w-full`,rounded:`rounded-control`})),64))])):(R(!0),z(L,{key:1},F(i.value,e=>(R(),z(`button`,{key:e.serverId,type:`button`,class:O(j(Q)(`flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors duration-150`,e.serverId===a.value?`bg-accent-soft`:`hover:bg-hover`)),onClick:t=>ee(e.serverId)},[V(`span`,{class:O(j(Q)(`size-1.5 shrink-0 rounded-full`,j(FF)[j(jF)[e.status].tone]))},null,2),V(`span`,FW,[V(`span`,{class:O(j(Q)(`block truncate text-xs`,e.serverId===a.value?`font-medium text-accent`:`text-ink`))},k(e.label),3),V(`span`,IW,k(e.files.length>0?`${e.files.length} file${e.files.length===1?``:`s`} · ${j(sI)(e.sizeBytes)}`:`nothing persisted`),1)])],10,PW))),128)),!p.value&&i.value.length===0?(R(),B(eI,{key:2,compact:``,title:`No servers`,description:`Add one and its output will be persisted here.`})):W(``,!0)]),t[6]||=V(`div`,{class:`border-t border-line p-2.5`},[V(`p`,{class:`text-2xs leading-4 text-faint`},` Rotation and retention are set under Workspace settings → Logs. `)],-1)]),V(`div`,LW,[V(`header`,RW,[V(`div`,zW,[V(`h1`,BW,[U(k(m.value?.label??`Logs`)+` `,1),m.value?(R(),z(`span`,VW,k(m.value.serverId),1)):W(``,!0)])]),H(oH,{modelValue:o.value,"onUpdate:modelValue":t[0]||=e=>o.value=e,class:`ml-auto`,options:[{value:`disk`,label:`Persisted`},{value:`live`,label:`Live stream`}]},null,8,[`modelValue`]),o.value===`disk`?(R(),B(XL,{key:0,modelValue:s.value,"onUpdate:modelValue":t[1]||=e=>s.value=e,options:b,class:`w-32`,"aria-label":`Tail size`},null,8,[`modelValue`])):W(``,!0),o.value===`disk`?(R(),B($,{key:1,size:`sm`,loading:c.value,onClick:w},{default:M(()=>[H(j(yy),{class:`size-3.5`}),t[7]||=U(`Reload `,-1)]),_:1},8,[`loading`])):W(``,!0),o.value===`disk`?(R(),B($,{key:2,size:`sm`,variant:`ghost`,disabled:!m.value||m.value.files.length===0,onClick:t[2]||=e=>f.value=!0},{default:M(()=>[H(j(Fy),{class:`size-3.5`}),t[8]||=U(`Clear file `,-1)]),_:1},8,[`disabled`])):W(``,!0)]),m.value?(R(),z(`div`,HW,[H(j($v),{class:`size-3.5 shrink-0 text-faint`}),m.value.files.length>0?(R(!0),z(L,{key:0},F(m.value.files,e=>(R(),z(`a`,{key:e.name,href:mM(j(r).activeId.value,m.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`},[U(k(e.name)+` `,1),V(`span`,WW,k(j(sI)(e.sizeBytes)),1),H(j(Mv),{class:`size-3`})],8,UW))),128)):(R(),z(`span`,GW,` Nothing on disk for this server — persistence is off, or it has not written anything yet. `)),o.value===`disk`&&u.value.length>0?(R(),z(`span`,KW,` loaded `+k(u.value.length)+` lines `,1)):W(``,!0)])):W(``,!0),l.value?(R(),z(`p`,qW,[H(j(Bv),{class:`size-3.5`}),U(` `+k(l.value),1)])):W(``,!0),V(`div`,JW,[m.value?c.value&&v.value.length===0?(R(),B(Nz,{key:1,class:`h-full w-full`,rounded:`rounded-panel`})):(R(),B(DW,{key:2,lines:v.value,version:y.value,live:o.value===`live`,class:`h-full`,"empty-hint":o.value===`live`?`Connected — waiting for output.`:`The persisted file is empty.`,"min-height":`100%`},null,8,[`lines`,`version`,`live`,`empty-hint`])):(R(),B(eI,{key:0,title:`Pick a server`,description:`Persisted output and live streams are per server. Choose one from the list.`},{icon:M(()=>[H(j(Sy),{class:`size-4`})]),_:1}))])]),H(hR,{open:f.value,"onUpdate:open":t[4]||=e=>f.value=e,title:`Clear the persisted log file?`,description:`${m.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(()=>[H($,{variant:`ghost`,onClick:t[3]||=e=>f.value=!1},{default:M(()=>[...t[9]||=[U(` Keep it `,-1)]]),_:1}),H($,{variant:`danger`,onClick:T},{default:M(()=>[H(j(Fy),{class:`size-3.5`}),t[10]||=U(`Clear `,-1)]),_:1})]),default:M(()=>[t[11]||=V(`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`])]))}}),XW={class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},ZW={key:0,class:`grid grid-cols-2 gap-4 p-4 sm:grid-cols-3 lg:grid-cols-5`},QW={key:1,class:`grid grid-cols-2 divide-line-soft sm:grid-cols-3 sm:divide-x lg:grid-cols-5`},$W={class:`p-4`},eG={class:`p-4`},tG={class:`p-4`},nG={class:`p-4`},rG={class:`p-4`},iG={key:0,class:`flex items-start gap-2.5 rounded-panel border border-danger/25 bg-danger-soft px-3.5 py-3`},aG={class:`min-w-0`},oG={class:`text-xs font-medium text-danger`},sG={class:`mt-0.5 flex flex-wrap gap-x-2 text-2xs text-danger`},cG={class:`space-y-3`},lG={class:`flex items-center justify-between`},uG={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},dG={key:0,class:`grid gap-4 lg:grid-cols-2`},fG={key:2,class:`grid gap-4 lg:grid-cols-2`},pG={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},mG={class:`flex flex-wrap items-center gap-x-3 gap-y-1 text-2xs text-faint`},hG={class:`flex items-center gap-1`},gG={class:`font-mono`},_G=P({__name:`OverviewView`,setup(e){let t=VN(),n=nP(),r=A(!1),i=G(()=>t.appState.value===null),a=n.servers,o=G(()=>n.selected.value?.label??`Workspace`),s=G(()=>a.value.filter(e=>e.status===`running`)),c=G(()=>a.value.filter(e=>[`stopped`,`stopping`].includes(e.status))),l=G(()=>a.value.filter(e=>e.status===`crashed`||e.status===`conflict`||e.health===`unhealthy`)),u=G(()=>{let e=0;for(let t of s.value){let n=t.resources?.rssBytes;typeof n==`number`&&(e+=n)}return e}),d=G(()=>{let e=0;for(let t of a.value){let r=pN(n.seriesOf(t.id).rss);r>e&&(e=r)}return e}),f=G(()=>{let e=0;for(let t of s.value)e+=t.resources?.cpuPercent??0;return e}),p=G(()=>{let e=a.value.map(e=>e.startedAt).filter(e=>typeof e==`number`);return e.length===0?`—`:rI(t.now.value-Math.min(...e))});return(e,m)=>{let h=fa(`RouterLink`);return R(),z(`div`,XW,[H(Oz,{title:o.value,description:`Live state of every server in this workspace, refreshed over a single event stream.`},{actions:M(()=>[H($,{variant:`ghost`,onClick:m[0]||=e=>j(n).startAll()},{default:M(()=>[H(j(gy),{class:`size-3.5`}),m[5]||=U(`Start all `,-1)]),_:1}),H($,{variant:`ghost`,onClick:m[1]||=e=>j(n).stopAll()},{default:M(()=>[H(j(Ay),{class:`size-3.5`}),m[6]||=U(`Stop all `,-1)]),_:1}),H($,{variant:`primary`,onClick:m[2]||=e=>r.value=!0},{default:M(()=>[H(j(_y),{class:`size-3.5`}),m[7]||=U(`Add server `,-1)]),_:1})]),_:1},8,[`title`]),H(Mz,{class:`p-0`},{default:M(()=>[i.value?(R(),z(`div`,ZW,[(R(),z(L,null,F(5,e=>V(`div`,{key:e,class:`space-y-2`},[H(Nz,{class:`h-2.5 w-16`}),H(Nz,{class:`h-6 w-20`})])),64))])):(R(),z(`div`,QW,[V(`div`,$W,[H(Lz,{label:`Running`,value:`${s.value.length}/${j(a).length}`,tone:`ok`,hint:`${j(a).length-s.value.length} not up`},null,8,[`value`,`hint`])]),V(`div`,eG,[H(Lz,{label:`Stopped`,value:String(c.value.length),hint:`${j(a).filter(e=>e.config.enabled).length} enabled`},null,8,[`value`,`hint`])]),V(`div`,tG,[H(Lz,{label:`Needs attention`,value:String(l.value.length),tone:l.value.length>0?`danger`:`ok`,hint:l.value.length===0?`nothing is broken`:`crashed or unhealthy`},null,8,[`value`,`tone`,`hint`])]),V(`div`,nG,[H(Lz,{label:`Process memory`,value:j(cI)(u.value),hint:d.value>0?`peak ${j(cI)(d.value)}`:`across the tree`},null,8,[`value`,`hint`])]),V(`div`,rG,[H(Lz,{label:`Longest uptime`,value:p.value,hint:s.value.length>0?`${f.value.toFixed(1)}% cpu now`:`nothing running`},null,8,[`value`,`hint`])])]))]),_:1}),l.value.length>0?(R(),z(`div`,iG,[H(j(Bv),{class:`mt-0.5 size-4 shrink-0 text-danger`}),V(`div`,aG,[V(`p`,oG,k(l.value.length)+` server`+k(l.value.length===1?``:`s`)+` need a look `,1),V(`p`,sG,[(R(!0),z(L,null,F(l.value,e=>(R(),B(h,{key:e.id,to:`/servers/${e.id}`,class:`font-mono underline-offset-2 hover:underline`},{default:M(()=>[U(k(e.id),1)]),_:2},1032,[`to`]))),128))])])])):W(``,!0),V(`section`,cG,[V(`div`,lG,[V(`h2`,uG,[H(j(wy),{class:`size-3.5 text-faint`}),m[8]||=U(` Servers `,-1)]),H(h,{to:j(_X)(j(n).activeId.value,`servers`),class:`text-2xs text-muted transition-colors duration-150 hover:text-accent`},{default:M(()=>[...m[9]||=[U(` Open the full list `,-1)]]),_:1},8,[`to`])]),i.value?(R(),z(`div`,dG,[(R(),z(L,null,F(4,e=>H(Nz,{key:e,class:`h-64 w-full`,rounded:`rounded-panel`})),64))])):j(a).length===0?(R(),B(eI,{key:1,title:`No servers in this workspace`,description:`Add the first process this workspace should keep alive.`},{icon:M(()=>[H(j(wy),{class:`size-4`})]),action:M(()=>[H($,{variant:`primary`,onClick:m[3]||=e=>r.value=!0},{default:M(()=>[H(j(_y),{class:`size-3.5`}),m[10]||=U(`Add a server `,-1)]),_:1})]),_:1})):(R(),z(`div`,fG,[(R(!0),z(L,null,F(j(a),e=>(R(),B(xz,{key:e.id,server:e,"workspace-id":j(n).activeId.value,series:j(n).seriesOf(e.id),now:j(t).now.value},null,8,[`server`,`workspace-id`,`series`,`now`]))),128))]))]),H(Mz,null,{header:M(()=>[V(`h2`,pG,[H(j(Av),{class:`size-3.5 text-faint`}),m[11]||=U(` Recent activity `,-1)])]),actions:M(()=>[H(h,{to:j(_X)(j(n).activeId.value,`logs`),class:`text-2xs text-muted transition-colors duration-150 hover:text-accent`},{default:M(()=>[...m[12]||=[U(` Logs `,-1)]]),_:1},8,[`to`])]),default:M(()=>[H(FI,{servers:j(a),now:j(t).now.value,limit:10},null,8,[`servers`,`now`])]),_:1}),V(`p`,mG,[V(`span`,hG,[H(j(Py),{class:`size-3`}),m[13]||=U(`resource history is sampled every 5 s and kept for this session`,-1)]),V(`span`,gG,k(j(n).selected.value?.configPath),1),V(`span`,{class:O(j(Q)(`flex items-center gap-1`))},[m[14]||=V(`span`,{class:`size-1.5 rounded-full bg-ok`},null,-1),U(` workspace `+k(j(n).activeId.value),1)],2)]),H(CR,{open:r.value,"onUpdate:open":m[4]||=e=>r.value=e,"workspace-id":j(n).activeId.value},null,8,[`open`,`workspace-id`])])}}}),vG=4480,yG=4443,bG=/^[a-z0-9][a-z0-9_-]*$/,xG=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)*$/i,SG=/^\d{1,3}(?:\.\d{1,3}){3}$/,CG=[`.localhost`,`.local`,`.internal`,`.home.arpa`,`.lan`,`.home`,`.test`,`.invalid`,`.example`],wG=[{value:`server`,label:`A supervised server`},{value:`panel`,label:`This control panel`},{value:`external`,label:`A literal upstream`}],TG=[{value:`auto`,label:`Automatic — the engine decides`},{value:`off`,label:`Off — plain HTTP`},{value:`manual`,label:`Uploaded certificate`}],EG={off:{label:`Off`,tone:`neutral`,transitional:!1},stopped:{label:`Stopped`,tone:`neutral`,transitional:!1},starting:{label:`Starting`,tone:`warn`,transitional:!0},running:{label:`Running`,tone:`ok`,transitional:!1},error:{label:`Error`,tone:`danger`,transitional:!1},unsupported:{label:`Unsupported`,tone:`warn`,transitional:!1}},DG={ok:{label:`Serving`,tone:`ok`},disabled:{label:`Disabled`,tone:`neutral`},"no-upstream":{label:`No upstream`,tone:`warn`},error:{label:`Error`,tone:`danger`}},OG={off:null,local:{label:`engine CA`,tone:`neutral`},uploaded:{label:`uploaded pair`,tone:`info`},issued:{label:`certificate ready`,tone:`ok`},pending:{label:`waiting for the CA`,tone:`warn`},failed:{label:`certificate failed`,tone:`danger`}};function kG(e){let t=e.certificate;if(t===void 0)return null;let n=OG[t.state];return n===null?null:{...n,message:t.message}}function AG(e){return e.label.trim().length>0?e.label:e.id}var jG=/^(?:[a-z][a-z0-9+.-]*:\/\/)?(?<authority>[^/?#]+)/i,MG=0;function NG(){return MG+=1,`proxy-route-${MG}`}function PG(e){let t=e.trim().toLowerCase();return t.length===0||t===`localhost`||!t.includes(`.`)||CG.some(e=>t.endsWith(e))?!1:!SG.test(t)}function FG(e){return e>0&&e<1024}function IG(e){return e.httpPort===4480&&e.httpsPort===4443}function LG(e){return{enabled:e.enabled,httpPort:e.httpPort,httpsPort:e.httpsPort,email:e.email,staging:e.staging}}function RG(e){return{...LG(e)}}function zG(e){return structuredClone(un(e)).map(e=>({...e,key:NG()}))}function BG(e){return{id:e.id,host:e.host,enabled:e.enabled,target:e.target,workspace:e.workspace,server:e.server,url:e.url,path:e.path,tls:e.tls}}function VG(e){return e.map(BG)}function HG(e,t){return JSON.stringify(BG(e))===JSON.stringify(BG(t))}function UG(e,t){return e.length===t.length&&e.every((e,n)=>HG(e,t[n]))}function WG(e,t){return UG(e,t)?null:VG(t)}function GG(e,t){let n={};return e.enabled!==t.enabled&&(n.enabled=t.enabled),e.httpPort!==t.httpPort&&(n.httpPort=t.httpPort),e.httpsPort!==t.httpsPort&&(n.httpsPort=t.httpsPort),e.email!==t.email&&(n.email=t.email),e.staging!==t.staging&&(n.staging=t.staging),n}function KG(e,t,n){let r=GG(e,t),i=WG(e.routes,n);return i!==null&&(r.routes=i),Object.keys(r).length===0?null:r}function qG(e,t){return e.staging||e.email.trim().length>0?!1:t.some(e=>e.tls!==`off`&&PG(e.host))}function JG(e){return e.find(e=>e.tls!==`off`&&PG(e.host))?.host??null}function YG(e,t){let n=e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40).replace(/-+$/,``);return n.length===0?t:/^[a-z0-9]/.test(n)?n:`r-${n}`}function XG(e,t){let n=new Set(t);if(!n.has(e))return e;let r=2;for(;n.has(`${e}-${r}`);)r+=1;return`${e}-${r}`}function ZG(e){return YG(e,`route`)}function QG(e,t){return XG(e,t)}function $G(e){return YG(e,`certificate`)}function eK(e,t){return XG(e,t)}function tK(){return{key:NG(),id:`route`,host:``,enabled:!0,target:`server`,workspace:``,server:``,url:``,path:``,tls:`auto`}}function nK(e){let t=e.trim();if(t.length===0)return null;let n=jG.exec(t)?.groups?.authority;if(n===void 0||n.length===0)return null;let r=n.lastIndexOf(`:`);if(r<=0||r===n.length-1)return null;let i=n.slice(r+1);return/^\d{1,5}$/.test(i)?{host:n.slice(0,r),port:i}:null}function rK(e,t){let n={},r=e.host.trim();if(r.length===0?n.host=`a hostname is required`:xG.test(r)?t.others.some(t=>t.host.trim().toLowerCase()===r.toLowerCase()&&t.path===e.path)&&(n.host=`"${r}" is already routed for this path`):n.host=`a hostname of letters, digits, dots and dashes, e.g. home.example.com`,e.path.length>0&&!e.path.startsWith(`/`)?n.path=`a path prefix starts with /`:/\s/.test(e.path)&&(n.path=`a path prefix cannot contain a space`),bG.test(e.id)?t.others.some(t=>t.id===e.id)&&(n.id=`route id "${e.id}" is used twice`):n.id=`the id must start with a letter or digit, then letters, digits, dash or underscore`,e.target===`server`){let r=t.workspaces.find(t=>t.id===e.workspace);e.workspace.length===0||r===void 0?n.workspace=`pick the workspace that owns the server`:(e.server.length===0||!r.servers.some(t=>t.id===e.server))&&(n.server=`pick a server in that workspace`)}e.target===`external`&&nK(e.url)===null&&(n.url=`an upstream like http://10.0.0.5:8080`);let i=qA({...BG(e),host:r});return i instanceof Y.errors&&Object.keys(n).length===0&&(n.form=i.summary),n}function iK(e,t){return e.target===`panel`?`control panel`:e.target===`external`?e.url.trim().length>0?e.url.trim():`no upstream`:e.workspace.length===0||e.server.length===0?`no server picked`:`${t.find(t=>t.id===e.workspace)?.label??e.workspace} / ${e.server}`}function aK(e){return e.tls===`off`?`plain HTTP`:e.tls===`manual`?`uploaded certificate`:PG(e.host)?`Let’s Encrypt`:`engine CA (local)`}function oK(e){if(e===null||e<=0)return`—`;let t=[`B`,`KiB`,`MiB`,`GiB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(r===0?0:1)} ${t[r]}`}var sK={class:`grid gap-3 sm:grid-cols-2`},cK={class:`grid gap-3 sm:grid-cols-2`},lK={class:`flex min-w-0 flex-col gap-1`},uK={class:`flex min-w-0 flex-col gap-1`},dK=P({__name:`CertificateDialog`,props:Ra({taken:{},busy:{type:Boolean},error:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:Ra([`submit`],[`update:open`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`open`),a=A(``),o=A(``),s=A(``),c=A(``),l=A({}),u=A(!1),d=Q(zL,`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`),f=G(()=>eK($G(a.value),n.taken)),p=G(()=>!n.busy&&a.value.trim().length>0&&s.value.trim().length>0&&c.value.trim().length>0);function m(e){o.value=e,u.value=e.trim().length>0}N([a,()=>n.taken],()=>{u.value||(o.value=f.value)},{immediate:!0}),N(i,e=>{e&&(a.value=``,o.value=``,s.value=``,c.value=``,l.value={},u.value=!1)});async function h(e,t){let n=e.target.files?.[0];if(!n)return;let r=await n.text();t===`cert`?s.value=r:c.value=r}function g(){let e=a.value.trim(),t=o.value.trim(),i={};e.length===0&&(i.label=`a label is required`),bG.test(t)?n.taken.includes(t)&&(i.id=`"${t}" is already used by another certificate`):i.id=`the id must start with a letter or digit, then letters, digits, dash or underscore`,s.value.trim().length===0&&(i.certificate=`paste or choose the certificate`),c.value.trim().length===0&&(i.privateKey=`paste or choose the private key`),l.value=i,!(Object.keys(i).length>0)&&r(`submit`,{id:t,label:e,certificate:s.value,privateKey:c.value})}return(e,t)=>(R(),B(hR,{open:i.value,"onUpdate:open":t[6]||=e=>i.value=e,title:`Add a certificate`,description:`The pair is stored on disk under its id, and a route set to “Uploaded certificate” can serve it.`},{footer:M(()=>[H($,{variant:`ghost`,disabled:n.busy,onClick:t[5]||=e=>i.value=!1},{default:M(()=>[...t[7]||=[U(` Cancel `,-1)]]),_:1},8,[`disabled`]),H($,{variant:`primary`,disabled:!p.value,loading:n.busy,onClick:g},{default:M(()=>[...t[8]||=[U(` Store the certificate `,-1)]]),_:1},8,[`disabled`,`loading`])]),default:M(()=>[V(`form`,{class:`space-y-3`,onSubmit:cu(g,[`prevent`])},[V(`div`,sK,[H(tR,{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Label`,placeholder:`Home wildcard`,error:l.value.label},null,8,[`modelValue`,`error`]),H(tR,{"model-value":o.value,label:`Id`,hint:`names the files on disk`,error:l.value.id,"onUpdate:modelValue":m},null,8,[`model-value`,`error`])]),V(`div`,cK,[V(`div`,lK,[V(`label`,{class:O(j(LL)),for:`proxy-cert-file`},`Certificate file (.pem, .crt)`,2),V(`input`,{id:`proxy-cert-file`,type:`file`,accept:`.pem,.crt,.cer,text/plain`,class:O(j(d)),onChange:t[1]||=e=>h(e,`cert`)},null,34)]),V(`div`,uK,[V(`label`,{class:O(j(LL)),for:`proxy-cert-key`},`Private key file (.pem, .key)`,2),V(`input`,{id:`proxy-cert-key`,type:`file`,accept:`.pem,.key,text/plain`,class:O(j(d)),onChange:t[2]||=e=>h(e,`key`)},null,34)])]),H(yR,{modelValue:s.value,"onUpdate:modelValue":t[3]||=e=>s.value=e,label:`Or paste the certificate`,rows:4,placeholder:`-----BEGIN CERTIFICATE-----`,error:l.value.certificate},null,8,[`modelValue`,`error`]),H(yR,{modelValue:c.value,"onUpdate:modelValue":t[4]||=e=>c.value=e,label:`Or paste the private key`,rows:4,placeholder:`-----BEGIN PRIVATE KEY-----`,error:l.value.privateKey},null,8,[`modelValue`,`error`]),n.error?(R(),B(vB,{key:0,tone:`danger`},{default:M(()=>[U(k(n.error),1)]),_:1})):W(``,!0)],32)]),_:1},8,[`open`]))}}),fK={key:0,class:`sm:col-span-2`},pK={key:1,class:`space-y-2 sm:col-span-2`},mK={class:`flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`},hK={class:`min-w-0 text-xs font-medium text-ink`},gK={class:`ml-1.5 font-mono text-2xs text-faint`},_K={key:0,class:`mt-2`},vK={key:1,class:`mt-2 divide-y divide-line-soft text-2xs`},yK={class:`flex items-start justify-between gap-4 py-1`},bK={class:`min-w-0 text-right font-mono text-ink`},xK={class:`flex items-start justify-between gap-4 py-1`},SK={class:`min-w-0 text-right font-mono text-ink`},CK={class:`flex items-start justify-between gap-4 py-1`},wK={class:`font-mono text-ink`},TK={class:`flex items-start justify-between gap-4 py-1`},EK={class:`min-w-0 text-right font-mono text-ink`},DK={key:1,class:`text-faint`},OK={class:`mt-2 flex justify-end`},kK={class:`text-xs font-semibold text-ink`},AK={class:`mt-2.5 flex justify-end gap-1.5`},jK={key:2,class:`space-y-2 sm:col-span-2`},MK=P({__name:`CertificatePanel`,props:{certificates:{},disabled:{type:Boolean}},emits:[`changed`],setup(e,{emit:t}){let n=e,r=t,i=A(!1),a=A(!1),o=A(null),s=A(null),c=A(null),l=G(()=>n.certificates.map(e=>e.id));async function u(e,t){a.value=!0,o.value=null,s.value=null;try{return r(`changed`,await e()),s.value=t,!0}catch(e){return o.value=e instanceof Error?e.message:String(e),!1}finally{a.value=!1}}async function d(e){await u(()=>WM(e.id,e.label,e.certificate,e.privateKey),`“${e.label}” stored.`)&&(i.value=!1)}function f(e){c.value=null,u(()=>GM(e.id),`“${AG(e)}” removed.`)}return(e,t)=>(R(),B(NL,{title:`Uploaded certificates`,description:`Served by routes set to “Uploaded certificate”. Everything else — public or local — is certified by the engine on its own.`},{actions:M(()=>[H($,{size:`xs`,variant:`secondary`,disabled:n.disabled||a.value,onClick:t[0]||=e=>i.value=!0},{default:M(()=>[H(j(_y),{class:`size-3.5`}),t[3]||=U(` Add certificate `,-1)]),_:1},8,[`disabled`])]),default:M(()=>[n.certificates.length===0?(R(),z(`div`,fK,[H(eI,{compact:``,title:`No certificate uploaded`,description:`A route set to “Uploaded certificate” needs a pair covering its hostname, or the engine has nothing to serve for it.`},{icon:M(()=>[H(j(ry),{class:`size-5`})]),action:M(()=>[H($,{variant:`primary`,disabled:n.disabled||a.value,onClick:t[1]||=e=>i.value=!0},{default:M(()=>[...t[4]||=[U(` Add a certificate `,-1)]]),_:1},8,[`disabled`])]),_:1})])):(R(),z(`ul`,pK,[(R(!0),z(L,null,F(n.certificates,e=>(R(),z(`li`,{key:e.id,class:`rounded-panel border border-line bg-page/40 p-3`},[V(`div`,mK,[V(`p`,hK,[U(k(j(AG)(e))+` `,1),V(`span`,gK,k(e.id),1)]),e.daysRemaining===null?W(``,!0):(R(),z(`span`,{key:0,class:O([`text-2xs tabular-nums`,e.daysRemaining<14?`text-warn`:`text-faint`])},k(e.daysRemaining)+` days left `,3))]),e.error?(R(),z(`div`,_K,[H(vB,{tone:`danger`},{default:M(()=>[U(k(e.error),1)]),_:2},1024)])):(R(),z(`dl`,vK,[V(`div`,yK,[t[5]||=V(`dt`,{class:`text-muted`},` Subject `,-1),V(`dd`,bK,k(e.subject??`—`),1)]),V(`div`,xK,[t[6]||=V(`dt`,{class:`text-muted`},` Issuer `,-1),V(`dd`,SK,k(e.issuer??`—`),1)]),V(`div`,CK,[t[7]||=V(`dt`,{class:`text-muted`},` Valid until `,-1),V(`dd`,wK,k(e.validTo?e.validTo.slice(0,10):`—`),1)]),V(`div`,TK,[t[8]||=V(`dt`,{class:`shrink-0 text-muted`},` Covers `,-1),V(`dd`,EK,[e.hosts.length>0?(R(),z(L,{key:0},[U(k(e.hosts.join(`, `)),1)],64)):(R(),z(`span`,DK,`no hostnames in its SANs`))])])])),V(`div`,OK,[H(j(Uh),{open:c.value===e.id,"onUpdate:open":t=>c.value=t?e.id:null},{default:M(()=>[H(j(Xh),{"as-child":``},{default:M(()=>[H($,{size:`xs`,variant:`danger-ghost`,disabled:a.value,"aria-label":`Remove ${j(AG)(e)}`},{default:M(()=>[H(j(Fy),{class:`size-3.5`}),t[9]||=U(` Remove `,-1)]),_:1},8,[`disabled`,`aria-label`])]),_:2},1024),H(j(Yh),null,{default:M(()=>[H(j(Jh),{"side-offset":6,align:`end`,class:O(j(Q)(`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(()=>[V(`p`,kK,` Remove “`+k(j(AG)(e))+`”? `,1),t[12]||=V(`p`,{class:`mt-1 text-2xs leading-4 text-muted`},` The pair is deleted from disk. A route still set to “Uploaded certificate” keeps serving the engine's own certificate until you change it, and the panel refuses this while one still serves it. `,-1),V(`div`,AK,[H(j(Wh),{"as-child":``},{default:M(()=>[H($,{size:`xs`,variant:`ghost`},{default:M(()=>[...t[10]||=[U(` Keep it `,-1)]]),_:1})]),_:1}),H($,{size:`xs`,variant:`danger`,loading:a.value,onClick:t=>f(e)},{default:M(()=>[...t[11]||=[U(` Remove it `,-1)]]),_:1},8,[`loading`,`onClick`])])]),_:2},1032,[`class`])]),_:2},1024)]),_:2},1032,[`open`,`onUpdate:open`])])]))),128))])),o.value||s.value?(R(),z(`div`,jK,[o.value?(R(),B(vB,{key:0,tone:`danger`},{default:M(()=>[U(k(o.value),1)]),_:1})):W(``,!0),s.value?(R(),B(vB,{key:1,tone:`ok`},{default:M(()=>[U(k(s.value),1)]),_:1})):W(``,!0)])):W(``,!0),H(dK,{open:i.value,"onUpdate:open":t[2]||=e=>i.value=e,taken:l.value,busy:a.value,error:o.value,onSubmit:d},null,8,[`open`,`taken`,`busy`,`error`])]),_:1}))}}),NK={key:0,class:`sm:col-span-2`},PK={key:0,class:`sm:col-span-2`},FK={key:1,class:`sm:col-span-2`},IK={class:`divide-y divide-line-soft text-xs sm:col-span-2`},LK={class:`flex items-start justify-between gap-4 py-1.5`},RK={class:`font-mono text-xs text-ink`},zK={class:`flex items-start justify-between gap-4 py-1.5`},BK={class:`text-right text-xs text-ink`},VK={key:0,class:`flex items-start justify-between gap-4 py-1.5`},HK={class:`font-mono text-xs tabular-nums text-ink`},UK={key:1,class:`flex items-start justify-between gap-4 py-1.5`},WK={class:`flex min-w-0 items-center gap-1.5`},GK={class:`min-w-0 truncate font-mono text-2xs text-ink`},KK={key:2,class:`flex items-start justify-between gap-4 py-1.5`},qK={class:`flex min-w-0 items-center gap-1.5`},JK={class:`min-w-0 truncate font-mono text-2xs text-ink`},YK={class:`flex items-start justify-between gap-4 py-1.5`},XK={class:`text-right font-mono text-xs text-ink`},ZK={class:`flex items-start justify-between gap-4 py-1.5`},QK={class:`font-mono text-xs tabular-nums text-ink`},$K={class:`flex items-start justify-between gap-4 py-1.5`},eq={class:`text-xs text-ink`},tq={class:`flex flex-wrap gap-1.5 sm:col-span-2`},nq=[`href`],rq={key:3,class:`sm:col-span-2`},iq={key:4,class:`text-2xs leading-4 text-faint sm:col-span-2`},aq={class:`rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},oq={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},sq=P({__name:`EnginePanel`,props:{view:{},busy:{}},emits:[`act`],setup(e,{emit:t}){let n=e,r=t,i=G(()=>n.view?.engine??null),a=G(()=>n.view?.status??null),o=G(()=>n.view?.engines[0]??null),s=G(()=>a.value===null?null:EG[a.value.state]),c=G(()=>i.value?.installed===!0),l=G(()=>i.value?.path??null),u=G(()=>l.value===null?null:`sudo setcap 'cap_net_bind_service=+ep' ${l.value}`),d=[{key:`acme`,label:`ACME certificates`},{key:`internalCa`,label:`Local CA`},{key:`dns01`,label:`DNS-01`},{key:`tcp`,label:`TCP/UDP`}];return(e,t)=>(R(),B(NL,{title:`Engine`,description:`The reverse proxy itself. The panel downloads a pinned build, supervises it and applies its configuration through the engine's own admin API.`},{actions:M(()=>[s.value?(R(),B(mV,{key:0,tone:s.value.tone,dot:``},{default:M(()=>[U(k(s.value.label),1)]),_:1},8,[`tone`])):W(``,!0)]),default:M(()=>[i.value===null?(R(),z(`div`,NK,[H(vB,{tone:`info`},{default:M(()=>[...t[6]||=[U(` The proxy state is not in this panel's frame yet. `,-1)]]),_:1})])):(R(),z(L,{key:1},[i.value.error?(R(),z(`div`,PK,[H(vB,{tone:`danger`,title:`The engine could not be read`},{default:M(()=>[U(k(i.value.error),1)]),_:1})])):W(``,!0),c.value?(R(),z(L,{key:2},[V(`dl`,IK,[V(`div`,LK,[t[7]||=V(`dt`,{class:`text-muted`},` Version `,-1),V(`dd`,RK,k(i.value.version??`not probed yet`),1)]),V(`div`,zK,[t[8]||=V(`dt`,{class:`text-muted`},` Source `,-1),V(`dd`,BK,k(i.value.source===`custom`?`a path configured by hand`:`downloaded by the panel`),1)]),i.value.bytes===null?W(``,!0):(R(),z(`div`,VK,[t[9]||=V(`dt`,{class:`text-muted`},` Size `,-1),V(`dd`,HK,k(j(oK)(i.value.bytes)),1)])),i.value.sha256?(R(),z(`div`,UK,[t[10]||=V(`dt`,{class:`text-muted`},` SHA-256 `,-1),V(`dd`,WK,[V(`span`,GK,k(i.value.sha256),1),H(fV,{value:i.value.sha256,label:`Copy the checksum`},null,8,[`value`])])])):W(``,!0),l.value?(R(),z(`div`,KK,[t[11]||=V(`dt`,{class:`text-muted`},` Binary `,-1),V(`dd`,qK,[V(`span`,JK,k(l.value),1),H(fV,{value:l.value,label:`Copy the binary path`},null,8,[`value`])])])):W(``,!0),V(`div`,YK,[t[12]||=V(`dt`,{class:`text-muted`},` Live address `,-1),V(`dd`,XK,k(a.value&&a.value.urls.length>0?a.value.urls.join(`, `):`—`),1)]),V(`div`,ZK,[t[13]||=V(`dt`,{class:`text-muted`},` Process `,-1),V(`dd`,QK,k(a.value?.pid??`—`),1)]),V(`div`,$K,[t[14]||=V(`dt`,{class:`text-muted`},` Certificates `,-1),V(`dd`,eq,k(a.value?.certExpiryDays===null||a.value?.certExpiryDays===void 0?`no public certificate yet`:`soonest expires in ${a.value.certExpiryDays} days`),1)])]),V(`div`,tq,[(R(),z(L,null,F(d,e=>H(mV,{key:e.key,tone:o.value?.[e.key]?`ok`:`neutral`},{default:M(()=>[U(k(o.value?.[e.key]?`✓`:`✗`)+` `+k(e.label),1)]),_:2},1032,[`tone`])),64)),o.value?(R(),z(`a`,{key:0,class:`ml-1 self-center text-2xs text-accent underline decoration-line underline-offset-2`,href:o.value.docsUrl,target:`_blank`,rel:`noreferrer`},k(o.value.label)+` documentation`,9,nq)):W(``,!0)])],64)):(R(),z(`div`,FK,[H(vB,{tone:`info`,title:`No engine installed`},{default:M(()=>[U(` Installing downloads the pinned `+k(o.value?.label??i.value.id)+` build the panel supervises — about 46 MB, once. Nothing is exposed until a route is added and the proxy is switched on. `,1)]),_:1})])),a.value?.lastError?(R(),z(`div`,rq,[H(vB,{tone:`danger`,title:`The engine reported a failure`},{default:M(()=>[U(k(a.value.lastError),1)]),_:1})])):W(``,!0),c.value&&u.value?(R(),z(`p`,iq,[t[15]||=U(` A privileged port (below 1024) needs this once on Linux: `,-1),V(`code`,aq,k(u.value),1),H(fV,{value:u.value,label:`Copy the command`,class:`ml-1 align-middle`},null,8,[`value`])])):W(``,!0)],64)),V(`div`,oq,[c.value?(R(),z(L,{key:1},[H($,{variant:`primary`,disabled:n.busy!==null||a.value?.state===`running`,loading:n.busy===`start`,onClick:t[1]||=e=>r(`act`,`start`)},{default:M(()=>[...t[17]||=[U(` Start `,-1)]]),_:1},8,[`disabled`,`loading`]),H($,{variant:`secondary`,disabled:n.busy!==null||a.value?.state===`off`||a.value?.state===`stopped`,loading:n.busy===`stop`,onClick:t[2]||=e=>r(`act`,`stop`)},{default:M(()=>[...t[18]||=[U(` Stop `,-1)]]),_:1},8,[`disabled`,`loading`]),H($,{variant:`secondary`,disabled:n.busy!==null||a.value?.state!==`running`,loading:n.busy===`apply`,onClick:t[3]||=e=>r(`act`,`apply`)},{default:M(()=>[...t[19]||=[U(` Apply configuration `,-1)]]),_:1},8,[`disabled`,`loading`]),H($,{variant:`ghost`,disabled:n.busy!==null||a.value?.state!==`running`,loading:n.busy===`revert`,title:`Go back to the configuration that applied before the last one`,onClick:t[4]||=e=>r(`act`,`revert`)},{default:M(()=>[...t[20]||=[U(` Revert `,-1)]]),_:1},8,[`disabled`,`loading`]),H($,{variant:`ghost`,disabled:n.busy!==null,loading:n.busy===`install`,onClick:t[5]||=e=>r(`act`,`install`)},{default:M(()=>[...t[21]||=[U(` Update engine `,-1)]]),_:1},8,[`disabled`,`loading`])],64)):(R(),B($,{key:0,variant:`primary`,loading:n.busy===`install`,disabled:n.busy!==null,onClick:t[0]||=e=>r(`act`,`install`)},{default:M(()=>[...t[16]||=[U(` Install engine `,-1)]]),_:1},8,[`loading`,`disabled`]))])]),_:1}))}}),cq={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},lq={key:0,class:`text-2xs text-faint`},uq={key:0,class:`sm:col-span-2`},dq={key:0,class:`rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},fq={key:1},pq={key:1,class:`sm:col-span-2`},mq=P({__name:`ListenerPanel`,props:Ra({emailHost:{},enginePath:{}},{form:{required:!0},formModifiers:{}}),emits:[`update:form`],setup(e){let t=e,n=oo(e,`form`),r=G(()=>IG(n.value)),i=G(()=>t.enginePath===null?null:`sudo setcap 'cap_net_bind_service=+ep' ${t.enginePath}`),a=G(()=>FG(n.value.httpPort)||FG(n.value.httpsPort));function o(){n.value.httpPort=vG,n.value.httpsPort=yG}function s(){n.value.httpPort=80,n.value.httpsPort=443}return(e,c)=>(R(),B(NL,{title:`Listener & certificates`,description:`Where the proxy listens. 80 and 443 are what a router forwards and what an ACME challenge expects; a port below 1024 needs a privileged bind.`},{actions:M(()=>[r.value?(R(),B(mV,{key:0,tone:`info`},{default:M(()=>[...c[5]||=[U(` unprivileged ports `,-1)]]),_:1})):W(``,!0)]),default:M(()=>[H(rR,{modelValue:n.value.enabled,"onUpdate:modelValue":c[0]||=e=>n.value.enabled=e,label:`Run the reverse proxy`,hint:`Saved with Save settings; the panel starts or stops the engine to match.`,wide:``},null,8,[`modelValue`]),H(WL,{modelValue:n.value.httpPort,"onUpdate:modelValue":c[1]||=e=>n.value.httpPort=e,label:`HTTP port`,min:1,max:65535,hint:`ACME HTTP-01 challenges and the redirect to HTTPS.`},null,8,[`modelValue`]),H(WL,{modelValue:n.value.httpsPort,"onUpdate:modelValue":c[2]||=e=>n.value.httpsPort=e,label:`HTTPS port`,min:1,max:65535,hint:`Where certificates are served.`},null,8,[`modelValue`]),V(`div`,cq,[H($,{size:`xs`,variant:`secondary`,onClick:o},{default:M(()=>[U(` Use `+k(j(vG))+` / `+k(j(yG)),1)]),_:1}),H($,{size:`xs`,variant:`ghost`,onClick:s},{default:M(()=>[...c[6]||=[U(` Use 80 / 443 `,-1)]]),_:1}),r.value?(R(),z(`span`,lq,` Running unprivileged — forward 80 and 443 to these ports on your router. `)):W(``,!0)]),a.value?(R(),z(`div`,uq,[H(vB,{tone:`warn`,title:`A port below 1024 needs a privileged bind`},{default:M(()=>[c[8]||=U(` Running the panel as your own user cannot bind 80 or 443 without permission. Either grant it once `,-1),i.value?(R(),z(`code`,dq,k(i.value),1)):(R(),z(`span`,fq,[...c[7]||=[U(`with `,-1),V(`code`,{class:`rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},`setcap`,-1),U(` on the engine binary`,-1)]])),i.value?(R(),B(fV,{key:2,value:i.value,label:`Copy the command`,class:`ml-1 align-middle`},null,8,[`value`])):W(``,!0),U(` and restart the engine, or keep `+k(j(vG))+`/`+k(j(yG))+` and forward 80/443 from your router. On Windows the port is free to bind, but something else may hold it. `,1)]),_:1})])):W(``,!0),H(tR,{modelValue:n.value.email,"onUpdate:modelValue":c[3]||=e=>n.value.email=e,label:`ACME account e-mail`,placeholder:`you@example.com`,hint:`Let's Encrypt uses it to warn you about an expiring certificate. A local-only name gets the engine's own CA and needs none.`,wide:``},null,8,[`modelValue`]),t.emailHost===null?W(``,!0):(R(),z(`div`,pq,[H(vB,{tone:`warn`,title:`An e-mail is needed for automatic HTTPS`},{default:M(()=>[U(` “`+k(t.emailHost)+`” is a public hostname, so the engine asks a CA for a certificate and the account address is required. Fill it in, switch the route's TLS off, or turn on the staging endpoint while you try things out. `,1)]),_:1})])),H(rR,{modelValue:n.value.staging,"onUpdate:modelValue":c[4]||=e=>n.value.staging=e,label:`Use the ACME staging endpoint`,hint:`Untrusted certificates and no rate-limit burn while you try things out.`,wide:``},null,8,[`modelValue`]),c[9]||=V(`p`,{class:`text-2xs leading-4 text-faint sm:col-span-2`},` A public name whose certificate is still being issued is reachable in the meantime — over HTTPS with a temporary untrusted certificate, or over plain HTTP with a page naming the ports to forward. `,-1)]),_:1}))}}),hq={class:`space-y-3`},gq={key:2,class:`text-2xs leading-4 text-warn sm:col-span-2`},_q=P({__name:`RouteDialog`,props:Ra({draft:{},others:{},workspaces:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:Ra([`save`],[`update:open`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`open`),a=A(tK()),o=A({}),s=G(()=>n.draft!==null),c=G(()=>(n.workspaces.find(e=>e.id===a.value.workspace)?.servers??[]).map(e=>({value:e.id,label:e.id}))),l=G(()=>a.value.tls===`off`?`Plain HTTP: no certificate is served for this hostname.`:a.value.tls===`manual`?`Serves the certificate pair uploaded below.`:a.value.host.trim().length===0?`A public hostname gets an ACME certificate; a local-only name gets the engine’s own CA.`:PG(a.value.host)?`A public hostname, so the engine asks a CA for a certificate — an ACME account e-mail is needed.`:`A local-only name, so the engine signs it with its own locally-trusted CA.`);N(i,e=>{e&&(a.value=n.draft===null?tK():structuredClone(un(n.draft)),a.value.workspace.length===0&&(a.value.workspace=n.workspaces[0]?.id??``),o.value={})}),N(()=>a.value.workspace,()=>{c.value.some(e=>e.value===a.value.server)||(a.value.server=c.value[0]?.value??``)});function u(){let e=a.value.host.trim().toLowerCase(),t={...a.value,host:e,id:QG(ZG(e),n.others.map(e=>e.id)),workspace:a.value.target===`server`?a.value.workspace:``,server:a.value.target===`server`?a.value.server:``,url:a.value.target===`external`?a.value.url.trim():``},s=rK(t,{others:n.others,workspaces:n.workspaces});o.value=s,!(Object.keys(s).length>0)&&(r(`save`,t),i.value=!1)}return(e,t)=>(R(),B(hR,{open:i.value,"onUpdate:open":t[8]||=e=>i.value=e,title:s.value?`Edit route`:`Add route`,description:`A hostname, what it forwards to, and how it is served over TLS.`,width:`w-[min(92vw,34rem)]`},{footer:M(()=>[H($,{size:`sm`,variant:`ghost`,onClick:t[7]||=e=>i.value=!1},{default:M(()=>[...t[10]||=[U(` Cancel `,-1)]]),_:1}),H($,{size:`sm`,variant:`primary`,onClick:u},{default:M(()=>[U(k(s.value?`Save route`:`Add route`),1)]),_:1})]),default:M(()=>[V(`div`,hq,[H(tR,{modelValue:a.value.host,"onUpdate:modelValue":t[0]||=e=>a.value.host=e,label:`Hostname`,placeholder:`gitea.example.com`,autocomplete:`off`,spellcheck:`false`,error:o.value.host,wide:``},null,8,[`modelValue`,`error`]),H(tR,{modelValue:a.value.path,"onUpdate:modelValue":t[1]||=e=>a.value.path=e,label:`Path prefix`,placeholder:`/optional`,hint:`Empty serves the whole host.`,spellcheck:`false`,error:o.value.path,wide:``},null,8,[`modelValue`,`error`]),H(XL,{modelValue:a.value.target,"onUpdate:modelValue":t[2]||=e=>a.value.target=e,label:`Target`,options:j(wG)},null,8,[`modelValue`,`options`]),H(XL,{modelValue:a.value.tls,"onUpdate:modelValue":t[3]||=e=>a.value.tls=e,label:`TLS`,options:j(TG),hint:l.value},null,8,[`modelValue`,`options`,`hint`]),a.value.target===`server`?(R(),z(L,{key:0},[H(XL,{modelValue:a.value.workspace,"onUpdate:modelValue":t[4]||=e=>a.value.workspace=e,label:`Workspace`,options:n.workspaces.map(e=>({value:e.id,label:e.label})),error:o.value.workspace},null,8,[`modelValue`,`options`,`error`]),H(XL,{modelValue:a.value.server,"onUpdate:modelValue":t[5]||=e=>a.value.server=e,label:`Server`,options:c.value,disabled:c.value.length===0,error:o.value.server??(c.value.length===0?`this workspace has no servers`:null)},null,8,[`modelValue`,`options`,`disabled`,`error`]),t[9]||=V(`p`,{class:`text-2xs leading-4 text-faint sm:col-span-2`},` A server that is stopped is not routed: the row shows “No upstream” until it runs again. `,-1)],64)):W(``,!0),a.value.target===`external`?(R(),B(tR,{key:1,modelValue:a.value.url,"onUpdate:modelValue":t[6]||=e=>a.value.url=e,label:`Upstream`,placeholder:`http://10.0.0.5:8080`,hint:`A literal address, including the port. A scheme is optional.`,spellcheck:`false`,error:o.value.url,wide:``},null,8,[`modelValue`,`error`])):W(``,!0),a.value.target===`panel`?(R(),z(`p`,gq,` Serving the control panel needs authentication on and a password that is not the default — the panel refuses the save otherwise. `)):W(``,!0),o.value.form?(R(),B(vB,{key:3,tone:`danger`},{default:M(()=>[U(k(o.value.form),1)]),_:1})):W(``,!0)])]),_:1},8,[`open`,`title`]))}}),vq={key:0,class:`sm:col-span-2`},yq={class:`list-disc space-y-0.5 pl-4`},bq={key:1,class:`sm:col-span-2`},xq={key:2,class:`overflow-x-auto sm:col-span-2`},Sq={class:`w-full text-left text-xs`},Cq={class:`py-1.5 pr-3`},wq={class:`font-mono text-xs text-ink`},Tq={key:0,class:`text-accent`},Eq={class:`font-mono text-2xs text-faint`},Dq={class:`py-1.5 pr-3 text-2xs text-muted`},Oq={class:`py-1.5 pr-3 font-mono text-2xs text-muted`},kq={class:`py-1.5 pr-3 text-2xs text-muted`},Aq={key:0,class:`mt-0.5`},jq={class:`py-1.5 pr-3`},Mq={class:`py-1.5 pr-3`},Nq={class:`py-1.5`},Pq={class:`flex items-center justify-end gap-1`},Fq=P({__name:`RouteTable`,props:{routes:{},views:{},workspaces:{},disabled:{type:Boolean}},emits:[`add`,`edit`,`remove`,`toggle`],setup(e,{emit:t}){let n=e,r=t,i=G(()=>n.routes.map(e=>{let t=n.views.find(t=>t.route.id===e.id)??null;return{route:e,view:t,meta:t===null?null:DG[t.status],target:iK(e,n.workspaces),tls:aK(e),certificate:t===null?null:kG(t)}})),a=G(()=>i.value.filter(e=>e.view?.status===`error`));return(e,t)=>(R(),B(NL,{title:`Routes`,description:`One public hostname per service. A route may point at a supervised server in any workspace, at this panel, or at a literal upstream.`},{actions:M(()=>[H($,{size:`xs`,variant:`secondary`,disabled:n.disabled,onClick:t[0]||=e=>r(`add`)},{default:M(()=>[H(j(_y),{class:`size-3.5`}),t[2]||=U(` Add route `,-1)]),_:1},8,[`disabled`])]),default:M(()=>[a.value.length>0?(R(),z(`div`,vq,[H(vB,{tone:`danger`,title:`These routes cannot be saved as they stand`},{default:M(()=>[V(`ul`,yq,[(R(!0),z(L,null,F(a.value,e=>(R(),z(`li`,{key:e.route.id},k(e.view?.message??`${e.route.host} cannot be routed`),1))),128))])]),_:1})])):W(``,!0),i.value.length===0?(R(),z(`div`,bq,[H(eI,{compact:``,title:`No routes yet`,description:`Add one to expose a server through a domain — the engine gets the certificate on its own.`},{icon:M(()=>[H(j(Ly),{class:`size-5`})]),action:M(()=>[H($,{variant:`primary`,disabled:n.disabled,onClick:t[1]||=e=>r(`add`)},{default:M(()=>[...t[3]||=[U(` Add the first route `,-1)]]),_:1},8,[`disabled`])]),_:1})])):(R(),z(`div`,xq,[V(`table`,Sq,[t[5]||=V(`thead`,null,[V(`tr`,{class:`text-2xs text-faint`},[V(`th`,{class:`py-1 pr-3 font-medium`},` Hostname `),V(`th`,{class:`py-1 pr-3 font-medium`},` Target `),V(`th`,{class:`py-1 pr-3 font-medium`},` Upstream `),V(`th`,{class:`py-1 pr-3 font-medium`},` TLS `),V(`th`,{class:`py-1 pr-3 font-medium`},` State `),V(`th`,{class:`py-1 pr-3 font-medium`},` On `),V(`th`,{class:`py-1 font-medium`},[V(`span`,{class:`sr-only`},`Actions`)])])],-1),V(`tbody`,null,[(R(!0),z(L,null,F(i.value,e=>(R(),z(`tr`,{key:e.route.key,class:`border-t border-line-soft align-top`},[V(`td`,Cq,[V(`p`,wq,[U(k(e.route.host.trim().length>0?e.route.host:`no hostname yet`)+` `,1),e.route.path.length>0?(R(),z(`span`,Tq,k(e.route.path),1)):W(``,!0)]),V(`p`,Eq,k(e.route.id),1)]),V(`td`,Dq,k(e.target),1),V(`td`,Oq,k(e.view?.upstream??`—`),1),V(`td`,kq,[U(k(e.tls)+` `,1),e.certificate?(R(),z(`div`,Aq,[H(mV,{tone:e.certificate.tone,dot:``},{default:M(()=>[U(k(e.certificate.label),1)]),_:2},1032,[`tone`]),e.certificate.message?(R(),z(`p`,{key:0,class:O([`mt-0.5 text-2xs`,e.certificate.tone===`danger`?`text-danger`:`text-faint`])},k(e.certificate.message),3)):W(``,!0)])):W(``,!0)]),V(`td`,jq,[e.meta?(R(),B(mV,{key:0,tone:e.meta.tone,dot:``},{default:M(()=>[U(k(e.meta.label),1)]),_:2},1032,[`tone`])):(R(),B(mV,{key:1,tone:`info`,dot:``},{default:M(()=>[...t[4]||=[U(` Not applied yet `,-1)]]),_:1})),e.view?.message?(R(),z(`p`,{key:2,class:O([`mt-0.5 text-2xs`,e.view.status===`error`?`text-danger`:`text-warn`])},k(e.view.message),3)):W(``,!0)]),V(`td`,Mq,[H(rR,{"model-value":e.route.enabled,label:`Route ${e.route.host||e.route.id}`,"sr-only":``,disabled:n.disabled,"onUpdate:modelValue":t=>r(`toggle`,e.route,t)},null,8,[`model-value`,`label`,`disabled`,`onUpdate:modelValue`])]),V(`td`,Nq,[V(`span`,Pq,[H($,{size:`xs`,variant:`ghost`,disabled:n.disabled,"aria-label":`Edit ${e.route.host||e.route.id}`,onClick:t=>r(`edit`,e.route)},{default:M(()=>[H(j(hy),{class:`size-3.5`})]),_:1},8,[`disabled`,`aria-label`,`onClick`]),H($,{size:`xs`,variant:`danger-ghost`,disabled:n.disabled,"aria-label":`Remove ${e.route.host||e.route.id}`,onClick:t=>r(`remove`,e.route)},{default:M(()=>[H(j(Fy),{class:`size-3.5`})]),_:1},8,[`disabled`,`aria-label`,`onClick`])])])]))),128))])])]))]),_:1}))}}),Iq={class:`min-h-full`},Lq={class:`mx-auto w-full max-w-5xl px-4 pb-6 pt-5 sm:px-6`},Rq={key:2,class:`space-y-6`},zq={key:0,class:`sticky bottom-0 z-30 border-t border-line bg-panel/95 backdrop-blur`},Bq={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`},Vq={class:`min-w-0 flex-1`},Hq={class:`text-xs text-muted`},Uq={class:`font-mono tabular-nums text-ink`},Wq={key:0,class:`mt-0.5 text-xs text-danger`},Gq={key:1,class:`mt-0.5 text-xs text-danger`},Kq={key:2,class:`mt-0.5 text-xs text-ok`},qq={class:`flex shrink-0 items-center gap-2`},Jq=P({__name:`ProxyView`,setup(e){let t=VN(),n=cN(),r=A(null),i=A(null),a=A(null),o=A(!1),s=A(null),c=A({enabled:!1,httpPort:80,httpsPort:443,email:``,staging:!1}),l=A([]),u=A(!1),d=A(null),f=G(()=>t.proxy.value??r.value),p=G(()=>f.value?.config??null),m=G(()=>f.value?.engine.path??null),h=G(()=>t.workspaces.value.map(e=>({id:e.id,label:e.label,servers:e.servers.map(e=>({id:e.id}))}))),g=G(()=>qG(c.value,l.value)?JG(l.value):null),_=G(()=>p.value!==null&&WG(p.value.routes,l.value)!==null),v=G(()=>{if(p.value===null)return 0;let e=KG(p.value,c.value,l.value);return e===null?0:Object.keys(e).filter(e=>e!==`routes`).length+(e.routes===void 0?0:1)}),y=G(()=>(f.value?.routes??[]).filter(e=>e.status===`error`)),b=G(()=>_.value?[]:y.value.map(e=>e.message??`${e.route.host} cannot be routed`)),x={};function S(){let e=p.value;if(e===null)return;dL(x.listener,{...c.value})||(Object.assign(c.value,RG(e)),x.listener={...c.value});let t=VG(l.value);dL(x.routes,t)||(l.value=zG(e.routes),x.routes=VG(l.value))}N(f,S,{immediate:!0});async function C(){i.value=null;try{r.value=await IM()}catch(e){i.value=e instanceof Error?e.message:String(e)}}ta(()=>{t.proxy.value===null&&C()});let w={install:()=>RM(),start:BM,stop:VM,apply:HM,revert:UM},T={install:`Engine installed`,start:`Engine starting`,stop:`Engine stopping`,apply:`Configuration applied`,revert:`Configuration reverted`};async function ee(e){if(s.value===null){s.value=e,a.value=null;try{r.value=await w[e](),n.success(T[e]),await t.refresh()}catch(e){a.value=e instanceof Error?e.message:String(e)}finally{s.value=null}}}let E=A(null),te=A(null);async function ne(){let e=p.value,i=e===null?null:KG(e,c.value,l.value);if(!(i===null||o.value||b.value.length>0)){o.value=!0,E.value=null,te.value=null;try{r.value=await LM(i),await t.refresh(),te.value=`Settings saved.`,n.success(`Settings saved`),delete x.listener,delete x.routes,S()}catch(e){E.value=e instanceof Error?e.message:String(e)}finally{o.value=!1}}}function re(){E.value=null,te.value=null,delete x.listener,delete x.routes,S()}function ie(){d.value=null,u.value=!0}function ae(e){d.value=e,u.value=!0}function oe(e){l.value=d.value===null?[...l.value,e]:l.value.map(t=>t.key===d.value?.key?e:t),d.value=null}function se(e){l.value=l.value.filter(t=>t.key!==e.key)}function ce(e,t){e.enabled=t}async function D(e){r.value=e,await t.refresh()}return(e,t)=>(R(),z(`div`,Iq,[V(`div`,Lq,[t[3]||=V(`header`,{class:`mb-5`},[V(`h1`,{class:`text-xl font-semibold tracking-tight text-ink`},` Reverse Proxy `),V(`p`,{class:`mt-1 text-xs text-muted`},` Expose your servers through domains, with certificates the engine obtains and renews on its own. Panel-wide: a route may point at any workspace's servers. `)],-1),i.value?(R(),B(vB,{key:0,tone:`danger`,title:`The reverse proxy could not be read`,class:`mb-4`},{default:M(()=>[U(k(i.value),1)]),_:1})):W(``,!0),f.value===null&&i.value===null?(R(),B(vB,{key:1,tone:`info`,class:`mb-4`},{default:M(()=>[...t[2]||=[U(` Reading the reverse proxy… `,-1)]]),_:1})):W(``,!0),f.value===null?W(``,!0):(R(),z(`div`,Rq,[H(sq,{view:f.value,busy:s.value,onAct:ee},null,8,[`view`,`busy`]),a.value?(R(),B(vB,{key:0,tone:`danger`},{default:M(()=>[U(k(a.value),1)]),_:1})):W(``,!0),H(mq,{form:c.value,"onUpdate:form":t[0]||=e=>c.value=e,"engine-path":m.value,"email-host":g.value},null,8,[`form`,`engine-path`,`email-host`]),H(Fq,{routes:l.value,views:f.value.routes,workspaces:h.value,disabled:o.value,onAdd:ie,onEdit:ae,onRemove:se,onToggle:ce},null,8,[`routes`,`views`,`workspaces`,`disabled`]),H(MK,{certificates:f.value.certificates,disabled:o.value,onChanged:D},null,8,[`certificates`,`disabled`])]))]),f.value===null?W(``,!0):(R(),z(`div`,zq,[V(`div`,Bq,[V(`div`,Vq,[V(`p`,Hq,[v.value>0?(R(),z(L,{key:0},[V(`span`,Uq,k(v.value),1),U(` field`+k(v.value===1?``:`s`)+` changed `,1)],64)):(R(),z(L,{key:1},[U(` No unsaved changes `)],64))]),b.value.length>0?(R(),z(`p`,Wq,k(b.value.join(` · `)),1)):E.value?(R(),z(`p`,Gq,k(E.value),1)):te.value?(R(),z(`p`,Kq,k(te.value),1)):W(``,!0)]),V(`div`,qq,[H($,{variant:`ghost`,disabled:v.value===0||o.value,onClick:re},{default:M(()=>[...t[4]||=[U(` Discard changes `,-1)]]),_:1},8,[`disabled`]),H($,{variant:`primary`,disabled:v.value===0||b.value.length>0,loading:o.value,onClick:ne},{default:M(()=>[...t[5]||=[U(` Save settings `,-1)]]),_:1},8,[`disabled`,`loading`])])])])),H(_q,{open:u.value,"onUpdate:open":t[1]||=e=>u.value=e,draft:d.value,others:l.value.filter(e=>e.key!==d.value?.key),workspaces:h.value,onSave:oe},null,8,[`open`,`draft`,`others`,`workspaces`])]))}}),Yq={class:`mb-4 flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`},Xq={class:`flex items-center gap-2`},Zq={class:`font-mono tabular-nums`},Qq={key:1,class:`text-2xs text-faint`},$q={class:`flex flex-col gap-3`},eJ={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`},tJ={class:`mt-4 flex items-center justify-end gap-2 border-t border-line pt-3.5`},nJ={class:`max-h-[60dvh] overflow-auto`},rJ={key:0,class:`divide-y divide-line-soft`},iJ={class:`font-mono text-xs text-ink`},aJ={class:`ml-auto font-mono text-xs text-muted line-through`},oJ={class:`font-mono text-xs text-accent`},sJ={key:1,class:`text-xs text-muted`},cJ=P({__name:`ServerConfigEditor`,props:{serverId:{},workspaceId:{},config:{}},emits:[`saved`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=[`restart`,`health`,`stop`],a=VN(),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
- `),env:vL(e.env),dataEnvs:vL(e.dataEnvs),backupPaths:e.backupPaths.join(`
39
+ fn("string", ":", "number")(s => s.length)`,xD=class extends zb{$;constructor(e){super((...t)=>new SD(e)(...t),{bind:e}),this.$=e}in(e){return new SD(this.$,e===void 0?void 0:this.$.parse(e))}at(e,t){return new SD(this.$).at(e,t)}case(e,t){return new SD(this.$).case(e,t)}},SD=class extends zb{$;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&&q(TD),this.branches.length&&q(wD),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&&q(`default may only be specified as the last key of a switch definition`),this.default(r);if(typeof r!=`function`)return q(`Value for case "${n}" must be a function (was ${Zy(r)})`);this.caseEntry(n,r)}return this}default(e){typeof e==`function`&&this.case(sE.unknown,e);let t={branches:this.branches,ordered:!0};(e===`never`||e===`assert`)&&(t.meta={onFail:CD});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:CD},`self`)),this.$.finalize(r)}},CD=e=>e.throw(),wD=`A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')`,TD=`At most one key matcher may be specified per expression`,ED=(e,t)=>{if(Db(e)){if(e[1]===`=`)return[t.$.parseOwnDefinitionFormat(e[0],t),`=`,e[2]];if(e[1]===`?`)return[t.$.parseOwnDefinitionFormat(e[0],t),`?`]}return lO(e,t)},DD=`Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }`,OD=`Only required keys may specify default values, e.g. { value: 'number = 0' }`,kD=(e,t)=>{let n,r={},i=hb(e);for(let[e,a]of i){let i=ND(e);if(i.kind===`spread`){if(!mb(r))return q(MD);let e=t.$.parseOwnDefinitionFormat(a,t);if(e.equals(sE.object))continue;if(!e.hasKind(`intersection`)||!e.basis?.equals(sE.object))return q(PD(e.expression));n=e.structure;continue}if(i.kind===`undeclared`){a!==`reject`&&a!==`delete`&&a!==`ignore`&&q(jD(a)),r.undeclared=a;continue}let o=ED(a,t),s=i;if(i.kind===`required`){Db(o)?AD(r,`optional`,o[1]===`=`?{key:i.normalized,value:o[0],default:o[2]}:{key:i.normalized,value:o[0]},t):AD(r,`required`,{key:i.normalized,value:o},t);continue}if(Db(o)&&(o[1]===`?`&&q(DD),o[1]===`=`&&q(OD)),i.kind===`optional`){AD(r,`optional`,{key:i.normalized,value:o},t);continue}let c=ET(t.$.parseOwnDefinitionFormat(s.normalized,t),o,t.$);c.index&&(r.index=Wy(r.index,c.index)),c.required&&(r.required=Wy(r.required,c.required))}let a=t.$.node(`structure`,r);return t.$.parseSchema({domain:`object`,structure:n?.merge(a)??a})},AD=(e,t,n,r)=>{e[t]=Wy(e[t],r.$.node(t,n))},jD=e=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${Dx(e)})`,MD=`Spread operator may only be used as the first key in an object`,ND=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},PD=e=>`Spread operand must resolve to an object literal type (was ${e})`,FD=(e,t)=>YD(e)?JD[e[0]](e,t):qD(e)?KD[e[1]](e,t):null,ID=(e,t)=>t.$.parseOwnDefinitionFormat(e[1],t).keyof(),LD=(e,t)=>{if(e[2]===void 0)return q(zE(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]===`&`?KS(n,r,t.$):qS(n,r,t.$);return i instanceof VS?i.throw():i},RD=(e,t)=>t.$.parseOwnDefinitionFormat(e[0],t).array(),zD=(e,t)=>typeof e[2]==`function`?t.$.parseOwnDefinitionFormat(e[0],t).pipe(e[2]):q(BD(`=>`,e[2])),BD=(e,t)=>`${e===`:`?`Narrow`:`Morph`} expression requires a function following '${e}' (was ${typeof t})`,VD=(e,t)=>typeof e[2]==`function`?t.$.parseOwnDefinitionFormat(e[0],t).constrain(`predicate`,e[2]):q(BD(`:`,e[2])),HD=(e,t)=>t.$.parseOwnDefinitionFormat(e[0],t).configure(e[2],e[3]),UD=e=>e,WD=UD({"[]":RD,"?":()=>q(EE)}),GD=UD({"|":LD,"&":LD,":":VD,"=>":zD,"|>":LD,"@":HD,"=":()=>q(DE)}),KD={...WD,...GD},qD=e=>KD[e[1]]!==void 0,JD=(e=>e)({keyof:ID,instanceof:(e,t)=>{if(typeof e[1]!=`function`)return q(XD(Eb(e[1])));let n=e.slice(1).map(e=>typeof e==`function`?t.$.node(`proto`,{proto:e}):q(XD(Eb(e))));return n.length===1?n[0]:t.$.node(`union`,{branches:n})},"===":(e,t)=>t.$.units(e.slice(1))}),YD=e=>JD[e[0]]!==void 0,XD=e=>`Expected a constructor following 'instanceof' operator (was ${e})`,ZD=(e,t)=>{let n=[{}],r=0;for(;r<e.length;){let i=!1;e[r]===`...`&&r<e.length-1&&(i=!0,r++);let a=ED(e[r],t),[o,s,c]=Db(a)?a:[a];if(r++,i){if(!o.extends(J.intrinsic.Array))return q(rO(o.expression));n=n.flatMap(e=>o.distribute(t=>nO(Qx(e),t)))}else n=n.map(e=>s===`?`?$D(e,o):s===`=`?eO(e,o,c):QD(e,o))}return t.$.parseSchema(n.map(e=>mb(e)?{proto:Array,exactLength:0}:{proto:Array,sequence:e}))},QD=(e,t)=>e.defaultables||e.optionals?q(e.variadic?lT:aO):(e.variadic?e.postfix=Wy(e.postfix,t):e.prefix=Wy(e.prefix,t),e),$D=(e,t)=>e.variadic?q(oO):(e.optionals=Wy(e.optionals,t),e),eO=(e,t,n)=>e.variadic?q(oO):e.optionals?q(sO):(e.defaultables=Wy(e.defaultables,[[t,n]]),e),tO=(e,t)=>(e.postfix&&q(iO),e.variadic?e.variadic.equals(t)||q(iO):e.variadic=t.internal,e),nO=(e,t)=>{let n=t.select({method:`find`,kind:`sequence`});if(!n)return tO(e,J.intrinsic.unknown);if(n.prefix)for(let t of n.prefix)QD(e,t);if(n.optionals)for(let t of n.optionals)$D(e,t);if(n.variadic&&tO(e,n.variadic),n.postfix)for(let t of n.postfix)QD(e,t);return e},rO=e=>`Spread element must be an array (was ${e})`,iO=`A tuple may have at most one variadic element`,aO=`A required element may not follow an optional element`,oO=`An optional element may not follow a variadic element`,sO=`A defaultable element may not follow an optional element without a default`,cO={},lO=(e,t)=>{if(typeof e==`string`){if(t.args&&Object.keys(t.args).some(t=>e.includes(t)))return lD(e,t);let n=cO[t.$.name]??={};return n[e]??=lD(e,t)}return Xy(e,`object`)?uO(e,t):q(pO(Zy(e)))},uO=(e,t)=>{let n=Tb(e);switch(n){case void 0:return eS(e,`root`)?e:`~standard`in e?dO(e,t):kD(e,t);case`Array`:return fO(e,t);case`RegExp`:return t.$.node(`intersection`,{domain:`string`,pattern:e},{prereduced:!0});case`Function`:{let t=Lb(e)?e():e;return eS(t,`root`)?t:q(pO(`Function`))}default:return q(pO(n??Dx(e)))}},dO=(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:Wb(e),relativePath:t.map(e=>typeof e==`object`?e.key:e)}):n.error({message:e})}),fO=(e,t)=>FD(e,t)??ZD(e,t),pO=e=>`Type definitions must be strings or objects (was ${e})`,mO=class extends zb{constructor(e){let t=Object.assign({errors:ES,hkt:Vb,$: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 lC(e.parseGenericParams(n,{}),t[1],e,e,null)}return e.parse(t)},{attach:t})}},hO=J,gO=class e extends UT{get ambientAttachments(){if(hO.typeAttachments)return this.cacheGetter(`ambientAttachments`,ab(hO.typeAttachments,(e,t)=>[e,this.bindReference(t)]))}preparseOwnAliasEntry(e,t){let n=e.indexOf(`<`);if(n===-1){if(eS(t,`module`)||eS(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]!==`>`&&q(`'>' 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,()=>sC(this.parseGenericParams(i,{alias:r}),t,this)]}parseGenericParams(e,t){return hD(new Rx(e),[],this.createParseContext({...t,def:e,prefix:`generic`}))}normalizeRootScopeValue(e){return Lb(e)&&!eS(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=lO(e,t);if(Db(n)){if(n[1]===`=`)return q(DE);if(n[1]===`?`)return q(EE)}return n}unit=e=>this.units([e]);valueOf=e=>this.units(yb(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 vD(this);match=new xD(this);declare=()=>({type:this.type});define(e){return e}type=new mO(this);static scope=((t,n={})=>new e(t,n));static module=((e,t={})=>this.scope(e,t).export())},_O=Object.assign(gO.scope,{define:e=>e}),vO=gO,yO=class extends Vb{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'},bO=nE([`base`,sE.object],[`props`,sE.object])(e=>e.base.merge(e.props),yO),xO=vO.module({Key:sE.key,Merge:bO}),SO=class extends Vb{},CO=nE(`element`)(e=>{let t=e.element.exclude(sE.Array),n=t.array();return t.rawOr(n).pipe(zy).distribute(e=>e.assertHasKind(`morph`).declareOut(n),eE)},SO),wO=vO.module({root:sE.Array,readonly:`root`,index:sE.nonNegativeIntegerString,liftFrom:CO},{name:`Array`}),TO=eE([`string`,yx.FileConstructor]),EO=eE({meta:`an object representing parsed form data`,domain:`object`,index:{signature:`string`,value:TO.rawOr(TO.array())}}),DO=vO.module({root:[`instanceof`,FormData],value:TO,parsed:EO,parse:eE({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 yx.FileConstructor?t[n]=[e,r]:e.push(r)}else t[n]=r;return t},declaredOut:EO})},{name:`FormData`}),OO=vO.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`}),kO={Boolean:1,Number:1,String:1},AO=vO.module({...ab({...bb,...Sb},(e,t)=>e in kO?[]:[e,[`instanceof`,t]]),Array:wO,TypedArray:OO,FormData:DO}),jO=eE({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`}),MO=eE({domain:`number`,divisor:1}),NO=vO.module({root:sE.number,integer:MO,epoch:jO,safe:eE({domain:{domain:`number`,numberAllowsNaN:!1},min:-(2**53-1),max:2**53-1}),NaN:[`===`,NaN],Infinity:[`===`,1/0],NegativeInfinity:[`===`,-1/0]},{name:`number`}),PO=(e,t,n)=>{let r={domain:`string`,pattern:{rule:e.source,flags:e.flags,meta:t}};return n&&(r.meta={format:n}),tE(`intersection`,r)},FO=PO(ax,`a well-formed integer string`),IO=vO.module({root:FO,parse:eE({in:FO,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:sE.integer})},{name:`string.integer`}),LO=PO(/^[\dA-Fa-f]+$/,`hex characters only`),RO=vO.module({root:PO(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,`base64-encoded`),url:PO(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,`base64url-encoded`)},{name:`string.base64`}),zO=PO(/^[A-Z].*$/,`capitalized`),BO=vO.module({root:eE({in:`string`,morphs:e=>e.charAt(0).toUpperCase()+e.slice(1),declaredOut:zO}),preformatted:zO},{name:`string.capitalize`}),VO=eE({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)}}}),HO=/^([+-]?\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)?)?)?)?$/,UO=eE({domain:`string`,predicate:{meta:`a parsable date`,predicate:e=>!Number.isNaN(new Date(e).valueOf())}}).assertHasKind(`intersection`),WO=IO.root.internal.narrow((e,t)=>{let n=Number.parseInt(e),r=NO.epoch(n);return r instanceof ES?(t.errors.merge(r),!1):!0}).configure({description:`an integer string representing a safe Unix timestamp`},`self`).assertHasKind(`intersection`),GO=vO.module({root:WO,parse:eE({in:WO,morphs:e=>new Date(e),declaredOut:sE.Date})},{name:`string.date.epoch`}),KO=PO(HO,`an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date`).internal.assertHasKind(`intersection`),qO=vO.module({root:KO,parse:eE({in:KO,morphs:e=>new Date(e),declaredOut:sE.Date})},{name:`string.date.iso`}),JO=vO.module({root:UO,parse:eE({declaredIn:UO,in:`string`,morphs:(e,t)=>{let n=new Date(e);return Number.isNaN(n.valueOf())?t.error(`a parsable date`):n},declaredOut:sE.Date}),iso:qO,epoch:GO},{name:`string.date`}),YO=PO(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,`an email address`,`email`),XO=`(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])`,ZO=`(${XO}[.]){3}${XO}`,QO=RegExp(`^${ZO}$`),$O=`(?:[0-9a-fA-F]{1,4})`,ek=RegExp(`^((?:${$O}:){7}(?:${$O}|:)|(?:${$O}:){6}(?:${ZO}|:${$O}|:)|(?:${$O}:){5}(?::${ZO}|(:${$O}){1,2}|:)|(?:${$O}:){4}(?:(:${$O}){0,1}:${ZO}|(:${$O}){1,3}|:)|(?:${$O}:){3}(?:(:${$O}){0,2}:${ZO}|(:${$O}){1,4}|:)|(?:${$O}:){2}(?:(:${$O}){0,3}:${ZO}|(:${$O}){1,5}|:)|(?:${$O}:){1}(?:(:${$O}){0,4}:${ZO}|(:${$O}){1,6}|:)|(?::((?::${$O}){0,5}:${ZO}|(?::${$O}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?\$`),tk=vO.module({root:[`v4 | v6`,`@`,`an IP address`],v4:PO(QO,`an IPv4 address`,`ipv4`),v6:PO(ek,`an IPv6 address`,`ipv6`)},{name:`string.ip`}),nk=`a JSON string`,rk=e=>{if(!(e instanceof SyntaxError))throw e;return`must be ${nk} (${e})`},ik=eE({meta:nk,domain:`string`,predicate:{meta:nk,predicate:(e,t)=>{try{return JSON.parse(e),!0}catch(e){return t.reject({code:`predicate`,expected:nk,problem:rk(e)})}}}}),ak=vO.module({root:ik,parse:eE({meta:`safe JSON string parser`,in:`string`,morphs:(e,t)=>{if(e.length===0)return t.error({code:`predicate`,expected:nk,actual:`empty`});try{return JSON.parse(e)}catch(e){return t.error({code:`predicate`,expected:nk,problem:rk(e)})}},declaredOut:sE.jsonObject})},{name:`string.json`}),ok=PO(/^[a-z]*$/,`only lowercase letters`),sk=vO.module({root:eE({in:`string`,morphs:e=>e.toLowerCase(),declaredOut:ok}),preformatted:ok},{name:`string.lower`}),ck=[`NFC`,`NFD`,`NFKC`,`NFKD`],lk=ab(ck,(e,t)=>[t,eE({domain:`string`,predicate:e=>e.normalize(t)===e,meta:`${t}-normalized unicode`})]),uk=ab(ck,(e,t)=>[t,eE({in:`string`,morphs:e=>e.normalize(t),declaredOut:lk[t]})]),dk=vO.module({root:uk.NFC,preformatted:lk.NFC},{name:`string.normalize.NFC`}),fk=vO.module({root:uk.NFD,preformatted:lk.NFD},{name:`string.normalize.NFD`}),pk=vO.module({root:uk.NFKC,preformatted:lk.NFKC},{name:`string.normalize.NFKC`}),mk=vO.module({root:uk.NFKD,preformatted:lk.NFKD},{name:`string.normalize.NFKD`}),hk=vO.module({root:`NFC`,NFC:dk,NFD:fk,NFKC:pk,NFKD:mk},{name:`string.normalize`}),gk=PO(nx,`a well-formed numeric string`),_k=vO.module({root:gk,parse:eE({in:gk,morphs:e=>Number.parseFloat(e),declaredOut:sE.number})},{name:`string.numeric`}),vk=`a regex pattern`,yk=eE({domain:`string`,predicate:{meta:vk,predicate:(e,t)=>{try{return new RegExp(e),!0}catch(e){return t.reject({code:`predicate`,expected:vk,problem:String(e)})}}},meta:{format:`regex`}}),bk=PO(/^(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/)`),xk=PO(/^\S.*\S$|^\S?$/,`trimmed`),Sk=vO.module({root:eE({in:`string`,morphs:e=>e.trim(),declaredOut:xk}),preformatted:xk},{name:`string.trim`}),Ck=PO(/^[A-Z]*$/,`only uppercase letters`),wk=vO.module({root:eE({in:`string`,morphs:e=>e.toUpperCase(),declaredOut:Ck}),preformatted:Ck},{name:`string.upper`}),Tk=eE({domain:`string`,predicate:{meta:`a URL string`,predicate:e=>URL.canParse(e)},meta:{format:`uri`}}),Ek=vO.module({root:Tk,parse:eE({declaredIn:Tk,in:`string`,morphs:(e,t)=>{try{return new URL(e)}catch{return t.error(`a URL string`)}},declaredOut:eE(URL)})},{name:`string.url`}),Dk=vO.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:PO(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv1`),v2:PO(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv2`),v3:PO(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv3`),v4:PO(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv4`),v5:PO(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv5`),v6:PO(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv6`),v7:PO(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv7`),v8:PO(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv8`)},{name:`string.uuid`}),Ok=vO.module({root:sE.string,alpha:PO(/^[A-Za-z]*$/,`only letters`),alphanumeric:PO(/^[\dA-Za-z]*$/,`only letters and digits 0-9`),hex:LO,base64:RO,capitalize:BO,creditCard:VO,date:JO,digits:PO(/^\d*$/,`only digits 0-9`),email:YO,integer:IO,ip:tk,json:ak,lower:sk,normalize:hk,numeric:_k,regex:yk,semver:bk,trim:Sk,upper:wk,url:Ek,uuid:Dk},{name:`string`}),kk=vO.module({bigint:sE.bigint,boolean:sE.boolean,false:sE.false,never:sE.never,null:sE.null,number:sE.number,object:sE.object,string:sE.string,symbol:sE.symbol,true:sE.true,unknown:sE.unknown,undefined:sE.undefined}),Ak=vO.module({root:sE.unknown,any:sE.unknown},{name:`unknown`}),jk=vO.module({root:sE.jsonObject,stringify:tE(`morph`,{in:sE.jsonObject,morphs:e=>JSON.stringify(e),declaredOut:sE.string})},{name:`object.json`}),Mk=vO.module({root:sE.object,json:jk},{name:`object`}),Nk=class extends Vb{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'},Pk=nE([`K`,sE.key],`V`)(e=>({domain:`object`,index:{signature:e.K,value:e.V}}),Nk),Fk=class extends Vb{description='pick a set of properties from an object like `Pick(User, "name | age")`'},Ik=nE([`T`,sE.object],[`K`,sE.key])(e=>e.T.pick(e.K),Fk),Lk=class extends Vb{description='omit a set of properties from an object like `Omit(User, "age")`'},Rk=nE([`T`,sE.object],[`K`,sE.key])(e=>e.T.omit(e.K),Lk),zk=class extends Vb{description="make all named properties of an object optional like `Partial(User)`"},Bk=nE([`T`,sE.object])(e=>e.T.partial(),zk),Vk=class extends Vb{description="make all named properties of an object required like `Required(User)`"},Hk=nE([`T`,sE.object])(e=>e.T.required(),Vk),Uk=class extends Vb{description='exclude branches of a union like `Exclude("boolean", "true")`'},Wk=nE(`T`,`U`)(e=>e.T.exclude(e.U),Uk),Gk=class extends Vb{description='extract branches of a union like `Extract("0 | false | 1", "number")`'},Kk=nE(`T`,`U`)(e=>e.T.extract(e.U),Gk),qk=vO.module({Exclude:Wk,Extract:Kk,Omit:Rk,Partial:Bk,Pick:Ik,Record:Pk,Required:Hk}),Jk=_O({...kk,...qk,...AO,...xO,string:Ok,number:NO,object:Mk,unknown:Ak},{prereducedAliases:!0,name:`ark`}),Yk=Jk.export();Object.assign(hO.ambient,Yk),hO.typeAttachments={string:Yk.string.root,number:Yk.number.root,bigint:Yk.bigint,boolean:Yk.boolean,symbol:Yk.symbol,undefined:Yk.undefined,null:Yk.null,object:Yk.object.root,unknown:Yk.unknown.root,false:Yk.false,true:Yk.true,never:Yk.never,arrayIndex:Yk.Array.index,Key:Yk.Key,Record:Yk.Record,Array:Yk.Array.root,Date:Yk.Date};var Y=Object.assign(Jk.type,hO.typeAttachments);Jk.match,Jk.fn,Jk.generic,Jk.schema,Jk.define,Jk.declare;var Xk=Y(`"local" | "lan" | /^\\d{1,3}(?:\\.\\d{1,3}){3}$/`),Zk=Y(`/^[a-z0-9][a-z0-9_-]*$/`);Y({id:Zk,label:`1 <= string <= 60`}).onUndeclaredKey(`reject`),Y({"id?":Zk,"label?":`1 <= string <= 60`}).onUndeclaredKey(`reject`),Y({label:`1 <= string <= 60`}).onUndeclaredKey(`reject`);function Qk(e){let t=Xk(e);return t instanceof Y.errors?null:t}var $k=Y(`1 <= number.integer <= 65535 | null`),eA=Y.enumerated(`block`,`warn`,`follow`,`reclaim`,`kill`),tA=eA.default(`block`),nA=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`),rA=Y({path:`string = "/"`,method:`"GET" | "HEAD" = "GET"`,expectStatus:`number.integer | null?`,expectStatusBelow:`number.integer = 400`,expectBody:`string = ""`}).onUndeclaredKey(`reject`),iA=Y({maxRssBytes:`number.integer >= 0 = 0`}).onUndeclaredKey(`reject`),aA=Y({enabled:`boolean = true`,mode:`"port" | "http" = "port"`,http:rA.default(()=>({})),intervalMs:`number >= 500 = 5000`,timeoutMs:`number >= 100 = 1500`,unhealthyThreshold:`number.integer >= 1 = 3`,forceRestartAfterMs:`number >= 0 = 0`,startTimeoutMs:`number >= 0 = 20000`}).onUndeclaredKey(`reject`),oA=Y({signal:`"SIGTERM" | "SIGINT" | "SIGKILL" = "SIGTERM"`,killGroup:`boolean = true`,graceMs:`number >= 0 = 5000`,killPortHolders:`boolean = false`}).onUndeclaredKey(`reject`),sA=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`)),cA=Y(`50 <= number.integer <= 100000`),lA=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:sA.optional(),port:$k.optional(),bind:Xk.default(()=>`local`),onPortConflict:tA,restart:nA.default(()=>({})),health:aA.default(()=>({})),stop:oA.default(()=>({})),logBufferLines:cA.default(()=>500),dependsOn:Y(`string[]`).default(()=>[]),envFile:`string = ""`,resources:iA.default(()=>({})),backupPaths:Y(`string[]`).default(()=>[]),backupIgnoreGenerated:`boolean = true`}).onUndeclaredKey(`reject`),uA=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`,onDdns:`boolean = true`,cooldownMs:`number >= 0 = 120000`}).onUndeclaredKey(`reject`).default(()=>({}))}).onUndeclaredKey(`reject`);var dA=Y({persist:`boolean = true`,maxBytes:`10000 <= number <= 100000000 = 2000000`,keep:`1 <= number.integer <= 10 = 3`}).onUndeclaredKey(`reject`),fA=Y({enabled:`boolean = false`}).onUndeclaredKey(`reject`),pA=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`),mA=Y.enumerated(`A`,`AAAA`),hA=Y({id:`/^[a-z0-9][a-z0-9_-]*$/`,provider:`string >= 1`,label:`string = ""`}).onUndeclaredKey(`reject`),gA=Y({host:`/^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/`,account:`string >= 1`,types:mA.array().default(()=>[`A`]),zone:`string?`,ttl:`number.integer >= 1?`,proxied:`boolean = false`,enabled:`boolean = true`}).onUndeclaredKey(`reject`),_A=Y({enabled:`boolean = true`,url:`string = ""`}).onUndeclaredKey(`reject`),vA=Y({enabled:`boolean = false`,url:`string = ""`}).onUndeclaredKey(`reject`),yA=Y({enabled:`boolean = false`,intervalMs:`number >= 60000 = 300000`,ipv4:_A.default(()=>({})),ipv6:vA.default(()=>({})),ttl:`number.integer >= 1 = 1`,accounts:hA.array().default(()=>[]),domains:gA.array().default(()=>[])}).onUndeclaredKey(`reject`),bA=Y({enabled:`boolean`,running:`boolean`,lastRunAt:`number | null`,lastResult:`string | null`,ipv4:`string | null`,ipv6:`string | null`,records:Y({host:`string`,account:`string`,provider:`string`,type:mA,ip:`string | null`,state:Y(`"pending" | "ok" | "unchanged" | "error" | "skipped"`),message:`string | null`,updatedAt:`number | null`}).array()}),xA=Y({key:`string`,label:`string`,hint:`string = ""`,optional:`boolean = false`}),SA=Y({config:yA,status:bA,providers:Y({id:`string`,label:`string`,docsUrl:`string`,families:mA.array(),fields:xA.array(),ttl:`boolean`,proxied:`boolean`,txt:`boolean`}).array(),credentials:Y(`string[]`)});Y({provider:`string >= 1`,credentials:Y(`Record<string, string>`)}).onUndeclaredKey(`reject`),Y({enabled:`boolean?`,intervalMs:`number >= 60000?`,ipv4:Y({enabled:`boolean?`,url:`string?`}).onUndeclaredKey(`reject`).optional(),ipv6:Y({enabled:`boolean?`,url:`string?`}).onUndeclaredKey(`reject`).optional(),ttl:`number.integer >= 1?`,accounts:hA.array().optional(),domains:gA.array().optional()}).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:Xk.default(()=>`local`),openBrowser:`boolean = false`,auth:uA.default(()=>({})),tls:fA.default(()=>({}))}).onUndeclaredKey(`reject`);var CA=Y({enabled:`boolean = true`,autostart:`boolean = false`,bind:Xk.default(()=>`local`),onPortConflict:tA,restart:nA.default(()=>({})),health:aA.default(()=>({})),stop:oA.default(()=>({})),logBufferLines:cA.default(()=>500)}).onUndeclaredKey(`reject`),wA=Y({enabled:`boolean?`,maxRetries:`number.integer >= 0?`,baseDelayMs:`number >= 0?`,factor:`number >= 1?`,maxDelayMs:`number >= 0?`,resetAfterMs:`number >= 0?`}).onUndeclaredKey(`reject`),TA=Y({path:`string?`,method:`"GET" | "HEAD"?`,expectStatus:`number.integer | null?`,expectStatusBelow:`number.integer?`,expectBody:`string?`}).onUndeclaredKey(`reject`),EA=Y({maxRssBytes:`number.integer >= 0?`}).onUndeclaredKey(`reject`),DA=Y({enabled:`boolean?`,mode:`"port" | "http"?`,http:TA.optional(),intervalMs:`number >= 500?`,timeoutMs:`number >= 100?`,unhealthyThreshold:`number.integer >= 1?`,forceRestartAfterMs:`number >= 0?`,startTimeoutMs:`number >= 0?`}).onUndeclaredKey(`reject`),OA=Y({signal:`"SIGTERM" | "SIGINT" | "SIGKILL"?`,killGroup:`boolean?`,graceMs:`number >= 0?`,killPortHolders:`boolean?`}).onUndeclaredKey(`reject`),kA=Y({enabled:`boolean?`,sessionTtlMs:`number >= 60000?`,cookieSecure:`"auto" | "always" | "never"?`,trustProxy:`boolean?`,maxLoginAttempts:`number.integer >= 1?`,lockoutMs:`number >= 1000?`}).onUndeclaredKey(`reject`),AA=Y({telegram:Y({enabled:`boolean?`,chatId:`string?`,onCrash:`boolean?`,onUnhealthy:`boolean?`,onForcedRestart:`boolean?`,onRecovered:`boolean?`,onHost:`boolean?`,onDdns:`boolean?`,cooldownMs:`number >= 0?`}).onUndeclaredKey(`reject`).optional()}).onUndeclaredKey(`reject`),jA=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`),MA=Y({enabled:`boolean?`,dir:`string?`,keep:`number.integer >= 1?`,includePaths:Y(`string[]`).optional()}).onUndeclaredKey(`reject`),NA=Y({persist:`boolean?`,maxBytes:`10000 <= number <= 100000000?`,keep:`1 <= number.integer <= 10?`}).onUndeclaredKey(`reject`),PA=Y({enabled:`boolean?`}).onUndeclaredKey(`reject`),FA=Y({label:`1 <= string <= 60?`,port:`1 <= number.integer <= 65535?`,host:Xk.optional(),openBrowser:`boolean?`,auth:kA.optional(),tls:PA.optional()}).onUndeclaredKey(`reject`),IA=Y({enabled:`boolean?`,autostart:`boolean?`,bind:Xk.optional(),onPortConflict:eA.optional(),restart:wA.optional(),health:DA.optional(),stop:OA.optional(),logBufferLines:cA.optional()}).onUndeclaredKey(`reject`),LA={label:`string?`,enabled:`boolean?`,autostart:`boolean?`,persistent:`boolean?`,command:`string?`,args:`string[]?`,cwd:`string?`,env:`Record<string, string>?`,dataEnvs:`Record<string, string>?`,bootstrap:sA.optional(),port:$k.optional(),bind:Xk.optional(),onPortConflict:eA.optional(),restart:wA.optional(),health:DA.optional(),stop:OA.optional(),logBufferLines:cA.optional(),dependsOn:Y(`string[]`).optional(),envFile:`string?`,resources:EA.optional(),backupPaths:Y(`string[]`).optional(),backupIgnoreGenerated:`boolean?`},RA=Y(LA).onUndeclaredKey(`reject`),zA=Y({id:`/^[a-z0-9][a-z0-9_-]*$/`,...LA,command:`string`}).onUndeclaredKey(`reject`);Y({serverId:`string`,command:`string`,args:`string[]`,cwd:`string`,env:`Record<string, string>`,logDir:`string`,logs:dA,stop:oA}).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 BA=Y({control:FA.optional(),host:jA.optional(),backups:MA.optional()}).onUndeclaredKey(`reject`),VA=Y({defaults:IA.optional(),logs:NA.optional(),notifications:AA.optional()}).onUndeclaredKey(`reject`),HA=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`}),UA=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`}),WA=Y.enumerated(`caddy`),GA=Y.enumerated(`server`,`panel`,`external`),KA=Y.enumerated(`auto`,`off`,`manual`),qA=Y({id:`/^[a-z0-9][a-z0-9_-]*$/`,host:`/^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*$/`,enabled:`boolean = true`,target:GA.default(()=>`server`),workspace:`string = ""`,server:`string = ""`,url:`string = ""`,path:`string = ""`,tls:KA.default(()=>`auto`),dnsAccount:`string = ""`}).onUndeclaredKey(`reject`),JA=Y({id:`/^[a-z0-9][a-z0-9_-]*$/`,label:`string = ""`}).onUndeclaredKey(`reject`),YA=Y.enumerated(`off`,`local`,`uploaded`,`issued`,`pending`,`failed`,`fallback`),XA=Y({enabled:`boolean = false`,resolvers:Y(`string[]`).default(()=>[])}).onUndeclaredKey(`reject`),ZA=Y({enabled:`boolean = false`,engine:WA.default(()=>`caddy`),httpPort:`1 <= number.integer <= 65535 = 80`,httpsPort:`1 <= number.integer <= 65535 = 443`,email:`string = ""`,staging:`boolean = false`,dns01:XA.default(()=>({})),certificates:JA.array().default(()=>[]),routes:qA.array().default(()=>[])}).onUndeclaredKey(`reject`),QA=Y({id:WA,installed:`boolean`,version:`string | null`,source:Y.enumerated(`downloaded`,`custom`).or(Y(`null`)),path:`string | null`,bytes:`number | null`,error:`string | null`}),$A=Y({id:WA,label:`string`,docsUrl:`string`,releaseUrl:`string`,acme:`boolean`,internalCa:`boolean`,dns01:`boolean`,tcp:`boolean`}),ej=Y({route:qA,status:Y.enumerated(`ok`,`disabled`,`no-upstream`,`error`),upstream:`string | null`,message:`string | null`,"certificate?":Y({state:YA,message:`string | null`,"retryInMinutes?":`number`})}),tj=Y({state:Y.enumerated(`off`,`stopped`,`starting`,`running`,`error`,`unsupported`),pid:`number | null`,urls:Y(`string[]`),certExpiryDays:`number | null`,since:`number | null`,lastError:`string | null`}),nj=Y({id:`string`,label:`string`,present:`boolean`,used:`boolean`,subject:`string | null`,issuer:`string | null`,validTo:`string | null`,daysRemaining:`number | null`,hosts:Y(`string[]`),error:`string | null`}),rj=Y({workspace:`string`,account:`string`,provider:`string`,label:`string`,writesTxt:`boolean`,hasCredentials:`boolean`}),ij=Y({config:ZA,engine:QA,engines:$A.array(),status:tj,routes:ej.array(),certificates:nj.array(),"dnsAccounts?":rj.array()}),aj=Y({id:`string`,host:`string`,enabled:`boolean?`,target:GA.optional(),workspace:`string?`,server:`string?`,url:`string?`,path:`string?`,tls:KA.optional(),dnsAccount:`string?`}).onUndeclaredKey(`reject`),oj=Y({enabled:`boolean?`,engine:WA.optional(),httpPort:`1 <= number.integer <= 65535?`,httpsPort:`1 <= number.integer <= 65535?`,email:`string?`,staging:`boolean?`,dns01:Y({enabled:`boolean | null?`,resolvers:`string[] | null?`}).onUndeclaredKey(`reject`).optional(),certificates:JA.array().optional(),routes:aj.array().optional()}).onUndeclaredKey(`reject`),sj=Y({label:`string = ""`,certificate:`string >= 1`,privateKey:`string >= 1`}).onUndeclaredKey(`reject`);Y({version:`string = ""`}).onUndeclaredKey(`reject`);var cj=Y({telegram:Y({enabled:`boolean`,tokenSet:`boolean`,chatId:`string`,onCrash:`boolean`,onUnhealthy:`boolean`,onForcedRestart:`boolean`,onRecovered:`boolean`,onHost:`boolean`,onDdns:`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 lj=Y({password:`string`}).onUndeclaredKey(`reject`),uj=Y(`1 <= string <= 512`),dj=Y({currentPassword:`string?`,newPassword:uj}).onUndeclaredKey(`reject`),fj=Y(`"stopped" | "starting" | "running" | "stopping" | "backoff" | "crashed" | "conflict"`),pj=Y(`"disabled" | "unknown" | "healthy" | "unhealthy"`),mj=Y(`"unknown" | "free" | "in-use"`),hj=Y({ts:`number`,stream:Y(`"stdout" | "stderr" | "system"`),text:`string`}),gj=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()}),_j=Y({cpuPercent:`number | null`,rssBytes:`number | null`,processes:`number`,sampledAt:`number`}),vj=Y({path:`string`,totalBytes:`number`,freeBytes:`number`,usedPercent:`number`}),yj=Y({enabled:`boolean`,cpus:`number`,loadAvg:Y(`number[]`),uptimeMs:`number`,memoryUsedPercent:`number`,swapUsedPercent:`number`,tempCelsius:`number | null`,disks:vj.array(),alerts:Y(`string[]`),sampledAt:`number | null`}),bj=Y({name:`string`,sizeBytes:`number`,createdAt:`number`,encrypted:`boolean`}),xj=Y({id:`string`,label:`string`,kind:`"settings" | "secrets" | "tls" | "workspace"`,"workspaceId?":`string`,note:`string | null`,items:Y({id:`string`,label:`string`,kind:`"settings" | "servers" | "secrets" | "data"`,"path?":`string`,"origin?":`string`,included:`boolean`,note:`string | null`,"ignoreGenerated?":`boolean`}).array()}),Sj=Y({enabled:`boolean`,dir:`string`,keep:`number`,includePaths:Y(`string[]`),entries:xj.array(),files:bj.array()});Y({dryRun:`boolean`,encrypted:`boolean`,needsPassword:`boolean`,items:Y({id:`string`,label:`string`,kind:`"settings" | "secrets" | "servers" | "tls" | "data"`,"workspaceId?":`string`,restorable:`boolean`,selected:`boolean`,note:`string | null`}).array(),applied:Y(`string[]`),skipped:Y(`string[]`),restartRequired:`boolean`,reloaded:`boolean`,error:`string?`}),Y({password:uj.optional(),include:Y(`string[] >= 1`).optional()}).onUndeclaredKey(`reject`),Y({name:`string?`,password:uj.optional(),include:Y(`string[]`).optional()}).onUndeclaredKey(`reject`);var Cj=Y({id:`string`,"workspaceId?":`string`,config:lA,bindHost:`string`,url:`string | null`,status:fj,health:pj,portState:mj,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:gj,responseMs:`number | null`,resources:_j.or(Y(`null`))}),wj=Y({label:`string`,port:`number`,host:`string`,bindHost:`string`,url:`string`,openBrowser:`boolean`,restartRequired:`boolean`,protocol:`string`,auth:HA,tls:UA}),Tj=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`))}),Ej=Y({id:`string`,label:`string`,configPath:`string`,settingsPath:`string`,configError:`string | null`,"configWarnings?":Y(`string[]`),logsDir:`string`,defaults:CA,logs:dA,notifications:cj,"ddns?":bA,serverCount:`number`,runningCount:`number`,crashedCount:`number`,servers:Cj.array()}),Dj=Y({control:wj,host:yj,backups:Sj,ui:Tj,workspaces:Ej.array(),"proxy?":ij,projectDir:`string`,dataRoot:`string`,"version?":`string`}),Oj=Y({type:`"hello" | "state" | "log" | "server"`,ts:`number`,"workspaceId?":`string`,serverId:`string?`,state:Dj.optional(),server:Cj.optional(),lines:hj.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 kj=Y({servers:Y({serverId:`string`,label:`string`,status:fj,enabled:`boolean`,sizeBytes:`number`,files:Y({name:`string`,sizeBytes:`number`}).array()}).array()}),Aj=Y({serverId:`string`,enabled:`boolean`,sizeBytes:`number`,files:Y(`string[]`),searched:`number | null`,lines:hj.array()});Y({botToken:`string?`,chatId:`string?`}).onUndeclaredKey(`reject`),Y({botToken:`string >= 1`}).onUndeclaredKey(`reject`),Y({message:`string`,code:`string`,detail:`unknown`}).onUndeclaredKey(`reject`),Y({certificate:`string >= 1`,privateKey:`string >= 1`}).onUndeclaredKey(`reject`),Y({control:wj,host:pA,backups:Sj,ui:Tj}).and(Y({rebinding:`boolean`,targetUrl:`string | null`}));var jj=Y({id:`string`,label:`string`,settingsPath:`string`,configPath:`string`,configError:`string | null`,defaults:CA,logs:dA,notifications:cj}),Mj=/^[\w!#$%&'*.^`|~+-]+$/,Nj=(e,t,n={})=>{if(!Mj.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},Pj=(e,t,n)=>(t=encodeURIComponent(t),Nj(e,t,n)),Fj=(e,t)=>(e=e.replace(/\/+$/,``),e+=`/`,t=t.replace(/^\/+/,``),e+t),Ij=(e,t)=>{for(let[n,r]of Object.entries(t)){let t=RegExp(`/:`+n+`(?:{[^/]+})?\\??(?=/|$)`);e=e.replace(t,()=>r?`/${r}`:``)}return e},Lj=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},Rj=(e,t)=>{switch(t){case`ws`:return e.replace(/^http/,`ws`);case`http`:return e.replace(/^ws/,`http`)}},zj=e=>/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(e)?e.replace(/\/index(?=\?|$)/,`/`):e.replace(/\/index(?=\?|$)/,``);function Bj(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Vj(e,t){if(!Bj(e)&&!Bj(t))return t;let n={...e};for(let e in t){let r=t[e];n[e]=Bj(n[e])&&Bj(r)?Vj(n[e],r):r}return n}var Hj=(e,t)=>new Proxy(()=>{},{get(n,r){if(typeof r==`string`&&r!==`then`)return Hj(e,[...t,r])},apply(n,r,i){return e({path:t,args:i})}}),Uj=(e,t)=>{let n=t.toString();return n?`${e}?${n}`:e},Wj=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(Pj(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=zj(a),a=Ij(a,this.pathParams),this.queryParams&&(a=Uj(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})}},Gj=((e,t)=>Hj(function n(r){let i=t?.buildSearchParams??Lj,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=Fj(e,a.join(`/`));if(s===`url`||s===`path`){let t=zj(c);return r.args[0]&&(r.args[0].param&&(t=Ij(t,r.args[0].param)),r.args[0].query&&(t=Uj(t,i(r.args[0].query)))),s===`url`?new URL(t):t.slice(e.replace(/\/+$/,``).length).replace(/^\/?/,`/`)}if(s===`ws`){let e=zj(c),n=Rj(r.args[0]?.param?Ij(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 Wj(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=Vj(t,e);return l.fetch(r.args[0],a)}return l},[]))(typeof window>`u`?`http://127.0.0.1`:window.location.origin);Y({workspaces:Ej.array()});var Kj=Y({workspace:Ej}),qj=Y({ok:`boolean`,removed:`unknown`}),Jj=class extends Error{name=`AuthRequiredError`;constructor(){super(`authentication required`)}};function Yj(e){return typeof e==`object`&&!!e}function Xj(e){return e==null||e.length===0?``:`?workspace=${encodeURIComponent(e)}`}function Zj(e,t){return{param:{id:t},query:e.length>0?{workspace:e}:{}}}function Qj(e,t,n){let r=n??new URLSearchParams;t.length>0&&r.set(`workspace`,t);let i=r.toString();return i.length>0?`${e}?${i}`:e}async function $j(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&&Yj(i)&&i.code===`AUTH_REQUIRED`)throw new Jj;let e=Yj(i)&&typeof i.message==`string`?i.message:Yj(i)&&`error`in i?String(i.error):`request failed with ${n.status}`;throw Error(e)}return i}async function eM(){let e=Dj(await $j(`/api/state`));if(e instanceof Y.errors)throw Error(`state contract mismatch: ${e.summary}`);return e}function tM(){return $j(`/api/auth/session`)}function nM(e){let t=lj({password:e});if(t instanceof Y.errors)throw Error(t.summary);return $j(`/api/auth/login`,{method:`POST`,body:JSON.stringify(t)})}function rM(){return $j(`/api/auth/logout`,{method:`POST`})}function iM(e,t){let n=dj(e===void 0?{newPassword:t}:{currentPassword:e,newPassword:t});if(n instanceof Y.errors)throw Error(n.summary);return $j(`/api/auth/password`,{method:`POST`,body:JSON.stringify(n)})}function aM(){return $j(`/api/auth/password`,{method:`DELETE`})}async function oM(e){let t=Kj(e);if(t instanceof Y.errors)throw Error(`workspace contract mismatch: ${t.summary}`);return t.workspace}async function sM(e){return oM(await $j(`/api/workspaces`,{method:`POST`,body:JSON.stringify(e)}))}async function cM(e,t){return oM(await $j(`/api/workspaces/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify({label:t})}))}async function lM(e){let t=qj(await $j(`/api/workspaces/${encodeURIComponent(e)}`,{method:`DELETE`}));if(t instanceof Y.errors)throw Error(`workspace removal contract mismatch: ${t.summary}`);return t}function uM(){return $j(`/api/settings`)}function dM(e){let t=BA(e);if(t instanceof Y.errors)throw Error(t.summary);return $j(`/api/settings`,{method:`PATCH`,body:JSON.stringify(t)})}async function fM(e,t){let n=VA(t);if(n instanceof Y.errors)throw Error(n.summary);let r=jj(await $j(Qj(`/api/settings/workspace`,e),{method:`PATCH`,body:JSON.stringify(n)}));if(r instanceof Y.errors)throw Error(`workspace settings contract mismatch: ${r.summary}`);return r}async function pM(e){let t=kj(await $j(Qj(`/api/logs`,e)));if(t instanceof Y.errors)throw Error(`logs contract mismatch: ${t.summary}`);return t.servers}async function mM(e,t,n){let r=new URLSearchParams;n.tail!==void 0&&r.set(`tail`,String(n.tail)),n.search!==void 0&&n.search.length>0&&r.set(`search`,n.search),n.stream!==void 0&&n.stream.length>0&&r.set(`stream`,n.stream);let i=Aj(await $j(Qj(`/api/logs/${encodeURIComponent(t)}`,e,r)));if(i instanceof Y.errors)throw Error(`log history contract mismatch: ${i.summary}`);return i}function hM(e,t){return $j(Qj(`/api/logs/${encodeURIComponent(t)}`,e),{method:`DELETE`})}function gM(e,t,n){return Qj(`/api/logs/${encodeURIComponent(t)}/download`,e,new URLSearchParams({file:n}))}function _M(e,t){if(t!==void 0&&t.length===0)throw Error("nothing is selected: omit `include` to capture everything, or select at least one item");let n={};return e!==void 0&&e.length>0&&(n.password=e),t!==void 0&&(n.include=t),$j(`/api/backups`,{method:`POST`,body:JSON.stringify(n)})}function vM(e){return $j(`/api/backups/${encodeURIComponent(e)}`,{method:`DELETE`})}function yM(e){return`/api/backups/${encodeURIComponent(e)}/download`}function bM(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 xM(e,t,n={}){return $j(`/api/backups/restore?confirm=${t}`,{method:`POST`,body:JSON.stringify({name:e,...bM(n)})})}async function SM(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 CM(e,t){return $j(Qj(`/api/notifications/token`,e),{method:`PUT`,body:JSON.stringify({botToken:t})})}function wM(e){return $j(Qj(`/api/notifications/token`,e),{method:`DELETE`})}function TM(e,t){return $j(Qj(`/api/notifications/test`,e),{method:`POST`,body:JSON.stringify(t)})}function EM(e,t){return $j(Qj(`/api/notifications/detect-chats`,e),{method:`POST`,body:JSON.stringify(t)})}async function DM(e){let t=SA(e);if(t instanceof Y.errors)throw Error(`ddns contract mismatch: ${t.summary}`);return t}async function OM(e){return DM(await $j(Qj(`/api/ddns`,e)))}async function kM(e,t){return DM(await $j(Qj(`/api/ddns`,e),{method:`PUT`,body:JSON.stringify(t)}))}async function AM(e,t,n,r){return DM(await $j(Qj(`/api/ddns/credentials/${encodeURIComponent(t)}`,e),{method:`PUT`,body:JSON.stringify({provider:n,credentials:r})}))}async function jM(e,t){return DM(await $j(Qj(`/api/ddns/credentials/${encodeURIComponent(t)}`,e),{method:`DELETE`}))}async function MM(e){return DM(await $j(Qj(`/api/ddns/check`,e),{method:`POST`}))}async function NM(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 PM(){return $j(`/api/settings/ui`,{method:`DELETE`})}function FM(e,t){return $j(`/api/settings/tls`,{method:`POST`,body:JSON.stringify({certificate:e,privateKey:t})})}function IM(){return $j(`/api/settings/tls`,{method:`DELETE`})}async function LM(e){let t=ij(e);if(t instanceof Y.errors)throw Error(`proxy contract mismatch: ${t.summary}`);return t}async function RM(){return LM(await $j(`/api/proxy`))}async function zM(e){let t=oj(e);if(t instanceof Y.errors)throw Error(t.summary);return LM(await $j(`/api/proxy`,{method:`PATCH`,body:JSON.stringify(t)}))}async function BM(e){return LM(await $j(`/api/proxy/routes/${encodeURIComponent(e)}/retry-certificate`,{method:`POST`}))}async function VM(e=``){return LM(await $j(`/api/proxy/engine`,{method:`POST`,body:JSON.stringify({version:e})}))}function HM(e){return $j(`/api/proxy/${e}`,{method:`POST`}).then(LM)}function UM(){return HM(`start`)}function WM(){return HM(`stop`)}function GM(){return HM(`apply`)}function KM(){return HM(`revert`)}async function qM(e,t,n,r){let i=sj({label:t,certificate:n,privateKey:r});if(i instanceof Y.errors)throw Error(i.summary);return LM(await $j(`/api/proxy/certificates/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify(i)}))}async function JM(e){return LM(await $j(`/api/proxy/certificates/${encodeURIComponent(e)}`,{method:`DELETE`}))}async function YM(e,t,n){let r=await Gj.api.servers[`:id`][n].$post(Zj(e,t)),i=await r.json().catch(()=>null);if(!r.ok)throw Error(i?.message??`request failed with ${r.status}`);return i??{ok:!0}}function XM(e){return $j(Qj(`/api/servers/start-all`,e),{method:`POST`})}async function ZM(e,t){let n=await Gj.api.servers[`:id`][`free-port`].$post(Zj(e,t)),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.message??`request failed with ${n.status}`);return r??{ok:!0,port:null,terminated:[],forced:[],skipped:[],free:!1}}function QM(e){return $j(Qj(`/api/servers/stop-all`,e),{method:`POST`})}function $M(e,t){return $j(Qj(`/api/servers/${encodeURIComponent(t)}/clear-logs`,e),{method:`POST`})}function eN(e,t,n){return $j(Qj(`/api/servers/${encodeURIComponent(t)}`,e),{method:`PATCH`,body:JSON.stringify(n)})}function tN(e,t){return $j(Qj(`/api/servers/${encodeURIComponent(t)}`,e),{method:`DELETE`})}function nN(e,t){return $j(Qj(`/api/servers`,e),{method:`POST`,body:JSON.stringify(t)})}var rN=A(null),iN=A(null);function aN(e){return e===null?`wait`:e.authRequired&&!e.authenticated?`login`:`connect`}function oN(){async function e(){try{rN.value=await tM()}catch{rN.value=null}}async function t(e){iN.value=null;try{return rN.value=await nM(e),!0}catch(e){return iN.value=e instanceof Error?e.message:String(e),!1}}async function n(){try{await rM()}finally{await e()}}function r(){rN.value={authenticated:!1,authRequired:!0,passwordSet:rN.value?.passwordSet??!0,apiTokenSet:rN.value?.apiTokenSet??!1,usingDefaultPassword:rN.value?.usingDefaultPassword??!1,defaultPassword:rN.value?.defaultPassword??null,sessionTtlMs:rN.value?.sessionTtlMs??0}}async function i(t,n){iN.value=null;try{return await iM(t,n),await e(),null}catch(e){return e instanceof Error?e.message:String(e)}}async function a(){iN.value=null;try{return await aM(),await e(),null}catch(e){return e instanceof Error?e.message:String(e)}}return{session:nn(rN),error:nn(iN),refresh:e,login:t,logout:n,requireLogin:r,setPassword:i,clearPassword:a}}var sN=A([]),cN=1;function lN(e){sN.value=sN.value.filter(t=>t.id!==e)}function uN(e,t=4800){let n=cN++;return sN.value=[...sN.value,{...e,id:n}],t>0&&setTimeout(lN,t,n),n}function dN(){return{toasts:nn(sN),dismiss:lN,push:uN,success:(e,t)=>uN({tone:`ok`,title:e,description:t}),failure:(e,t)=>uN({tone:`danger`,title:e,description:t},9e3),info:(e,t)=>uN({tone:`info`,title:e,description:t}),warn:(e,t)=>uN({tone:`warn`,title:e,description:t},7e3)}}var fN=4e3;function pN(){return en({ts:[],cpu:[],rss:[],probe:[],lastSampledAt:-1})}function mN(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 hN(e,t,n){let r=t.resources?.sampledAt??0,i=e.ts[e.ts.length-1]??0;if(!(r!==e.lastSampledAt||n-i>=fN)){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),mN(e)}function gN(e){let t=0;for(let n of e)n!==null&&n>t&&(t=n);return t}function _N(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n!=null)return n}return null}var vN=8e3,yN=A(null),bN=A(`connecting`),xN=A(null),SN=A(Date.now()),CN=new Map,wN=dN();function TN(e,t){return`${e}/${t}`}var EN=new Map,DN=A(0),ON=null,kN=null;function AN(e){let t=EN.get(e);if(t)return t;let n={lines:[],version:A(0),refs:0,source:null};return EN.set(e,n),n}function jN(e,t){let n=AN(e),r=n.lines.concat(t);n.lines=r.length>8e3?r.slice(r.length-vN):r,n.version.value+=1,DN.value+=1}function MN(e){return EN.get(e)?.lines??[]}function NN(e){let t=EN.get(e);t&&(t.lines=[],t.version.value+=1,DN.value+=1)}function PN(e){let t=CN.get(e);if(t)return t;let n=pN();return CN.set(e,n),n}function FN(e){e.workspaceId!==void 0&&hN(PN(TN(e.workspaceId,e.id)),e,Date.now())}function IN(e){let t=yN.value;if(!t)return;let n=e.workspaceId,r=n===void 0?t.workspaces.filter(t=>t.servers.some(t=>t.id===e.id)):t.workspaces.filter(e=>e.id===n);if(r.length!==1)return;let i=r[0],a=i.servers.find(t=>t.id===e.id),o=n===void 0?{...e,workspaceId:i.id}:e;i.servers=a===void 0?[...i.servers,o]:i.servers.map(t=>t.id===e.id?o:t)}function LN(e){let t;try{t=JSON.parse(e)}catch{return}let n=Oj(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){yN.value=n.state;for(let e of yN.value.workspaces)for(let t of e.servers)FN(t)}return}if(n.type===`server`&&n.server){let e=n.server;IN(e),FN(e);return}if(n.type===`log`&&n.serverId&&n.lines){let e=n.workspaceId;if(e===void 0)return;jN(TN(e,n.serverId),n.lines)}}function RN(e,t,n){let r=TN(e,t),i=new EventSource(`/api/servers/${encodeURIComponent(t)}/stream${Xj(e)}`),a=e=>{let t=e,n;try{n=JSON.parse(t.data)}catch{return}let i=Oj(n);if(i instanceof Y.errors){console.warn(`[home-hosted] ignored malformed SSE frame`,i.summary);return}if(i.type===`log`&&i.lines){jN(r,i.lines);return}i.type===`server`&&i.server&&IN(i.server)};for(let e of[`log`,`server`])i.addEventListener(e,a);i.onerror=()=>{},n.source=i}function zN(e,t){let n=AN(TN(e,t));n.refs+=1,n.source||RN(e,t,n)}function BN(e,t){let n=EN.get(TN(e,t));n&&(n.refs=Math.max(0,n.refs-1),n.refs===0&&(n.source?.close(),n.source=null))}function VN(){if(ON)return;kN??=setInterval(()=>{SN.value=Date.now()},1e3);let e=new EventSource(`/api/events?logs=0`);ON=e,bN.value=`connecting`,e.onopen=()=>{bN.value=`open`},e.onerror=()=>{bN.value=`closed`};for(let t of[`hello`,`state`,`server`,`log`])e.addEventListener(t,e=>{LN(e.data)})}function HN(){ON?.close(),ON=null,kN&&clearInterval(kN),kN=null}function UN(e,t){let n=G(()=>{let n=yn(e),r=yn(t);return n===null||r===null?null:TN(n,r)}),r=null;return N(n,e=>{if(r!==null&&r!==e){let[e,t]=r.split(`/`);e!==void 0&&t!==void 0&&BN(e,t)}if(r=e,e!==null){let[t,n]=e.split(`/`);t!==void 0&&n!==void 0&&zN(t,n)}},{immediate:!0}),ze(()=>{if(r!==null){let[e,t]=r.split(`/`);e!==void 0&&t!==void 0&&BN(e,t)}r=null}),{version:G(()=>{let e=n.value;return DN.value,e===null?0:EN.get(e)?.version.value??0}),lines(){let e=n.value;return e===null?[]:MN(e)},count:G(()=>{let e=n.value;return DN.value,e===null?0:EN.get(e)?.lines.length??0}),clear(){let e=n.value;e!==null&&NN(e)}}}function WN(){let e=G(()=>yN.value?.workspaces??[]),t=G(()=>e.value.flatMap(e=>e.servers.map(t=>({workspace:e,server:t})))),n=G(()=>yN.value?.control??null),r=G(()=>yN.value?.host??null),i=G(()=>yN.value?.backups??null),a=G(()=>yN.value?.proxy??null),o=G(()=>yN.value?.projectDir??null),s=G(()=>yN.value?.dataRoot??null),c=G(()=>yN.value?.version??null);function l(e){return yN.value?.workspaces.find(t=>t.id===e)}function u(e,t){return l(e)?.servers.find(e=>e.id===t)}function d(e,t){return PN(TN(e,t))}async function f(){if(yN.value===null)try{yN.value=await eM()}catch(e){e instanceof Jj&&oN().requireLogin()}}async function p(e,t){xN.value=null;try{let n=await e();yN.value=await eM();let r=typeof t.success==`function`?t.success(n):t.success;return r&&wN.success(r),n}catch(e){if(e instanceof Jj){oN().requireLogin();return}let n=e instanceof Error?e.message:String(e);xN.value=n,wN.failure(t.title,n);return}}return{appState:yN,workspaces:e,allServers:t,control:n,host:r,backups:i,proxy:a,projectDir:o,dataRoot:s,version:c,connection:nn(bN),lastError:nn(xN),now:nn(SN),workspaceById:l,ensureState:f,serverById:u,seriesOf:d,refresh:(e=`Refresh failed`)=>p(async()=>{},{title:e}),start:(e,t)=>p(()=>YM(e,t,`start`),{title:`Could not start ${t}`}),stop:(e,t)=>p(()=>YM(e,t,`stop`),{title:`Could not stop ${t}`}),restart:(e,t)=>p(()=>YM(e,t,`restart`),{title:`Could not restart ${t}`}),startAll:e=>p(()=>XM(e),{title:`Could not start every server`,success:`Starting every enabled server`}),stopAll:e=>p(()=>QM(e),{title:`Could not stop every server`,success:`Stopping every server`}),setAutostart:(e,t,n)=>p(()=>eN(e,t,{autostart:n}),{title:`Could not change autostart for ${t}`}),setEnabled:(e,t,n)=>p(()=>eN(e,t,{enabled:n}),{title:`Could not change ${t}`}),freePort:(e,t)=>p(()=>ZM(e,t),{title:`Could not free the port for ${t}`,success:e=>e.free?`Port ${e.port} is free — start ${t} now`:`Port ${e.port} is still held`}),setBind:(e,t,n)=>{let r=Qk(n);return r===null?(wN.failure(`Could not change the bind for ${t}`,`"${n}" is not a bind value`),Promise.resolve(void 0)):p(()=>eN(e,t,{bind:r}),{title:`Could not change the bind for ${t}`})},saveConfig:(e,t,n)=>p(()=>eN(e,t,n),{title:`Could not save ${t}`,success:`${t} updated`}),saveGlobalSettings:e=>p(()=>dM(e),{title:`Could not save the settings`}),saveWorkspaceSettings:(e,t)=>p(()=>fM(e,t),{title:`Could not save the settings`}),clearLogs:(e,t)=>p(async()=>{await $M(e,t),NN(TN(e,t))},{title:`Could not clear the logs for ${t}`,success:`Buffer cleared`}),create:(e,t)=>p(()=>nN(e,t),{title:`Could not add the server`,success:`Server added`}),remove:(e,t)=>p(async()=>{await tN(e,t),BN(e,t),EN.delete(TN(e,t)),CN.delete(TN(e,t))},{title:`Could not remove ${t}`,success:`${t} removed`})}}var GN=`hh.theme`;function KN(){try{let e=localStorage.getItem(GN);if(e===`light`||e===`dark`||e===`system`)return e}catch{}return`system`}var qN=A(KN()),JN=A(typeof matchMedia<`u`&&matchMedia(`(prefers-color-scheme: dark)`).matches),YN=!1;function XN(){YN||typeof matchMedia>`u`||(YN=!0,matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,e=>{JN.value=e.matches,QN()}))}var ZN=G(()=>qN.value===`system`?JN.value:qN.value===`dark`);function QN(){typeof document<`u`&&document.documentElement.classList.toggle(`dark`,ZN.value)}function $N(){XN(),QN();function e(e){qN.value=e;try{localStorage.setItem(GN,e)}catch{}QN()}return{preference:qN,isDark:ZN,setPreference:e,cycle(){e(qN.value===`light`?`dark`:qN.value===`dark`?`system`:`light`)}}}var eP=`hh.workspace`;function tP(){try{return localStorage.getItem(eP)}catch{return null}}function nP(e){try{e===null?localStorage.removeItem(eP):localStorage.setItem(eP,e)}catch{}}var rP=A(tP()),iP=A(!1);function aP(){let e=WN(),t=dN(),n=G(()=>e.appState.value?.workspaces??[]),r=G(()=>{let e=n.value;return e.find(e=>e.id===rP.value)??e[0]??null}),i=G(()=>r.value?.id??``);N([n,rP],()=>{let e=n.value;if(e.length===0)return;let t=e.find(e=>e.id===rP.value)?.id??e[0].id;t!==rP.value&&(rP.value=t,nP(t))},{immediate:!0});function a(e){rP.value=e,nP(e)}let o=G(()=>r.value?.servers??[]),s=G(()=>r.value?.defaults??null),c=G(()=>r.value?.logs??null),l=G(()=>r.value?.notifications??null),u=G(()=>r.value?.configError??null),d=G(()=>r.value?.configWarnings??[]),f=G(()=>r.value?.logsDir??null),p=G(()=>r.value?.serverCount??0),m=G(()=>r.value?.runningCount??0),h=G(()=>r.value?.crashedCount??0);function g(e){return o.value.find(t=>t.id===e)}function _(t){return e.seriesOf(i.value,t)}async function v(n){iP.value=!0;try{let r=await sM(n.trim().length>0?{label:n.trim()}:{});return await e.refresh(`Could not read the workspaces`),a(r.id),t.success(`Workspace “${r.label}” created`),r}catch(e){t.failure(`Could not create the workspace`,e instanceof Error?e.message:String(e));return}finally{iP.value=!1}}async function y(n,r){try{return await cM(n,r.trim()),await e.refresh(`Could not read the workspaces`),t.success(`Workspace renamed`),!0}catch(e){return t.failure(`Could not rename the workspace`,e instanceof Error?e.message:String(e)),!1}}async function b(n){try{return await lM(n),await e.refresh(`Could not read the workspaces`),t.success(`Workspace deleted`),!0}catch(e){return t.failure(`Could not delete the workspace`,e instanceof Error?e.message:String(e)),!1}}return{workspaces:n,selectedId:nn(rP),selected:r,activeId:i,creating:nn(iP),select:a,create:v,rename:y,remove:b,servers:o,serverById:g,seriesOf:_,defaults:s,logsConfig:c,notifications:l,configError:u,configWarnings:d,logsDir:f,serverCount:p,runningCount:m,crashedCount:h,refresh:e.refresh,start:t=>e.start(i.value,t),stop:t=>e.stop(i.value,t),restart:t=>e.restart(i.value,t),startAll:()=>e.startAll(i.value),stopAll:()=>e.stopAll(i.value),setEnabled:(t,n)=>e.setEnabled(i.value,t,n),setAutostart:(t,n)=>e.setAutostart(i.value,t,n),setBind:(t,n)=>e.setBind(i.value,t,n),freePort:t=>e.freePort(i.value,t),clearLogs:t=>e.clearLogs(i.value,t),saveConfig:(t,n)=>e.saveConfig(i.value,t,n),createServer:t=>e.create(i.value,t),removeServer:t=>e.remove(i.value,t)}}function oP(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=oP(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function sP(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=oP(e))&&(r&&(r+=` `),r+=t);return r}var cP=(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},lP=(e,t)=>({classGroupId:e,validator:t}),uP=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),dP=`-`,fP=[],pP=`arbitrary..`,mP=e=>{let t=_P(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return gP(e);let n=e.split(dP);return hP(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?cP(i,t):t:i||fP}return n[e]||fP}}},hP=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=hP(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(dP):e.slice(t).join(dP),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},gP=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?pP+r:void 0})(),_P=e=>{let{theme:t,classGroups:n}=e;return vP(n,t)},vP=(e,t)=>{let n=uP();for(let r in e){let i=e[r];yP(i,n,r,t)}return n},yP=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];bP(i,t,n,r)}},bP=(e,t,n,r)=>{if(typeof e==`string`){xP(e,t,n);return}if(typeof e==`function`){SP(e,t,n,r);return}CP(e,t,n,r)},xP=(e,t,n)=>{let r=e===``?t:wP(t,e);r.classGroupId=n},SP=(e,t,n,r)=>{if(TP(e)){yP(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(lP(n,e))},CP=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];yP(o,wP(t,a),n,r)}},wP=(e,t)=>{let n=e,r=t.split(dP),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=uP(),n.nextPart.set(t,i)),n=i}return n},TP=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,EP=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)}}},DP=`!`,OP=`:`,kP=[],AP=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),jP=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===OP){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(DP)?(c=s.slice(0,-1),l=!0):s.startsWith(DP)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return AP(t,l,c,u)};if(t){let e=t+OP,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):AP(kP,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},MP=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}},NP=e=>({cache:EP(e.cacheSize),parseClassName:jP(e),sortModifiers:MP(e),postfixLookupClassGroupIds:PP(e),...mP(e)}),PP=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},FP=/\s+/,IP=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(FP),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?_+DP:_,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},LP=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=RP(n))&&(i&&(i+=` `),i+=r);return i},RP=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=RP(e[r]))&&(n&&(n+=` `),n+=t);return n},zP=(e,...t)=>{let n,r,i,a,o=o=>(n=NP(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=IP(e,n);return i(e,a),a};return a=o,(...e)=>a(LP(...e))},BP=[],VP=e=>{let t=t=>t[e]||BP;return t.isThemeGetter=!0,t.themeKey=e,t},HP=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,UP=/^\((?:(\w[\w-]*):)?(.+)\)$/i,WP=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,GP=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,KP=/\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$/,qP=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,JP=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,YP=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,XP=e=>WP.test(e),ZP=e=>!!e&&!Number.isNaN(Number(e)),QP=e=>!!e&&Number.isInteger(Number(e)),$P=e=>e.endsWith(`%`)&&ZP(e.slice(0,-1)),eF=e=>GP.test(e),tF=()=>!0,nF=e=>KP.test(e)&&!qP.test(e),rF=()=>!1,iF=e=>JP.test(e),aF=e=>YP.test(e),oF=e=>!X(e)&&!Z(e),sF=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)),cF=e=>CF(e,DF,rF),X=e=>HP.test(e),lF=e=>CF(e,OF,nF),uF=e=>CF(e,kF,ZP),dF=e=>CF(e,jF,tF),fF=e=>CF(e,AF,rF),pF=e=>CF(e,TF,rF),mF=e=>CF(e,EF,aF),hF=e=>CF(e,MF,iF),Z=e=>UP.test(e),gF=e=>wF(e,OF),_F=e=>wF(e,AF),vF=e=>wF(e,TF),yF=e=>wF(e,DF),bF=e=>wF(e,EF),xF=e=>wF(e,MF,!0),SF=e=>wF(e,jF,!0),CF=(e,t,n)=>{let r=HP.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},wF=(e,t,n=!1)=>{let r=UP.exec(e);return r?r[1]?t(r[1]):n:!1},TF=e=>e===`position`||e===`percentage`,EF=e=>e===`image`||e===`url`,DF=e=>e===`length`||e===`size`||e===`bg-size`,OF=e=>e===`length`,kF=e=>e===`number`,AF=e=>e===`family-name`,jF=e=>e===`number`||e===`weight`,MF=e=>e===`shadow`,NF=zP(()=>{let e=VP(`color`),t=VP(`font`),n=VP(`text`),r=VP(`font-weight`),i=VP(`tracking`),a=VP(`leading`),o=VP(`breakpoint`),s=VP(`container`),c=VP(`spacing`),l=VP(`radius`),u=VP(`shadow`),d=VP(`inset-shadow`),f=VP(`text-shadow`),p=VP(`drop-shadow`),m=VP(`blur`),h=VP(`perspective`),g=VP(`aspect`),_=VP(`ease`),v=VP(`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=()=>[XP,`full`,`auto`,...w()],ee=()=>[QP,`none`,`subgrid`,Z,X],E=()=>[`auto`,{span:[`full`,QP,Z,X]},QP,Z,X],te=()=>[QP,`auto`,Z,X],ne=()=>[`auto`,`min`,`max`,`fr`,Z,X],re=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],ie=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],ae=()=>[`auto`,...w()],oe=()=>[XP,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],se=()=>[s,XP,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],ce=()=>[XP,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],D=()=>[e,Z,X],le=()=>[...b(),vF,pF,{position:[Z,X]}],ue=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],de=()=>[`auto`,`cover`,`contain`,yF,cF,{size:[Z,X]}],fe=()=>[$P,gF,lF],pe=()=>[``,`none`,`full`,l,Z,X],me=()=>[``,ZP,gF,lF],he=()=>[`solid`,`dashed`,`dotted`,`double`],ge=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],_e=()=>[ZP,$P,vF,pF],ve=()=>[``,`none`,m,Z,X],ye=()=>[`none`,ZP,Z,X],be=()=>[`none`,ZP,Z,X],O=()=>[ZP,Z,X],xe=()=>[XP,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[eF],breakpoint:[eF],color:[tF],container:[eF],"drop-shadow":[eF],ease:[`in`,`out`,`in-out`],font:[oF],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[eF],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[eF],shadow:[eF],spacing:[`px`,ZP],text:[eF],"text-shadow":[eF],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,XP,X,Z,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,Z,X]}],"container-named":[sF],columns:[{columns:[ZP,`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:[QP,`auto`,Z,X]}],basis:[{basis:[XP,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[ZP,XP,`auto`,`initial`,`none`,X]}],grow:[{grow:[``,ZP,Z,X]}],shrink:[{shrink:[``,ZP,Z,X]}],order:[{order:[QP,`first`,`last`,`none`,Z,X]}],"grid-cols":[{"grid-cols":ee()}],"col-start-end":[{col:E()}],"col-start":[{"col-start":te()}],"col-end":[{"col-end":te()}],"grid-rows":[{"grid-rows":ee()}],"row-start-end":[{row:E()}],"row-start":[{"row-start":te()}],"row-end":[{"row-end":te()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":ne()}],"auto-rows":[{"auto-rows":ne()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...re(),`normal`]}],"justify-items":[{"justify-items":[...ie(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...ie()]}],"align-content":[{content:[`normal`,...re()]}],"align-items":[{items:[...ie(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...ie(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":re()}],"place-items":[{"place-items":[...ie(),`baseline`]}],"place-self":[{"place-self":[`auto`,...ie()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:ae()}],mx:[{mx:ae()}],my:[{my:ae()}],ms:[{ms:ae()}],me:[{me:ae()}],mbs:[{mbs:ae()}],mbe:[{mbe:ae()}],mt:[{mt:ae()}],mr:[{mr:ae()}],mb:[{mb:ae()}],ml:[{ml:ae()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:oe()}],"inline-size":[{inline:[`auto`,...se()]}],"min-inline-size":[{"min-inline":[`auto`,...se()]}],"max-inline-size":[{"max-inline":[`none`,...se()]}],"block-size":[{block:[`auto`,...ce()]}],"min-block-size":[{"min-block":[`auto`,...ce()]}],"max-block-size":[{"max-block":[`none`,...ce()]}],w:[{w:[s,`screen`,...oe()]}],"min-w":[{"min-w":[s,`screen`,`none`,...oe()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...oe()]}],h:[{h:[`screen`,`lh`,...oe()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...oe()]}],"max-h":[{"max-h":[`screen`,`lh`,`none`,...oe()]}],"font-size":[{text:[`base`,n,gF,lF]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,SF,dF]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,$P,X]}],"font-family":[{font:[_F,fF,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":[ZP,`none`,Z,uF]}],leading:[{leading:[`none`,a,...w()]}],"list-image":[{"list-image":[`none`,Z,X]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,Z,X]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...he(),`wavy`]}],"text-decoration-thickness":[{decoration:[ZP,`from-font`,`auto`,Z,lF]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[ZP,`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:[QP,Z,X]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,Z,X]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,Z,X]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:le()}],"bg-repeat":[{bg:ue()}],"bg-size":[{bg:de()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},QP,Z,X],radial:[``,Z,X],conic:[``,QP,Z,X]},bF,mF]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:fe()}],"gradient-via-pos":[{via:fe()}],"gradient-to-pos":[{to:fe()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:pe()}],"rounded-s":[{"rounded-s":pe()}],"rounded-e":[{"rounded-e":pe()}],"rounded-t":[{"rounded-t":pe()}],"rounded-r":[{"rounded-r":pe()}],"rounded-b":[{"rounded-b":pe()}],"rounded-l":[{"rounded-l":pe()}],"rounded-ss":[{"rounded-ss":pe()}],"rounded-se":[{"rounded-se":pe()}],"rounded-ee":[{"rounded-ee":pe()}],"rounded-es":[{"rounded-es":pe()}],"rounded-tl":[{"rounded-tl":pe()}],"rounded-tr":[{"rounded-tr":pe()}],"rounded-br":[{"rounded-br":pe()}],"rounded-bl":[{"rounded-bl":pe()}],"border-w":[{border:me()}],"border-w-x":[{"border-x":me()}],"border-w-y":[{"border-y":me()}],"border-w-s":[{"border-s":me()}],"border-w-e":[{"border-e":me()}],"border-w-bs":[{"border-bs":me()}],"border-w-be":[{"border-be":me()}],"border-w-t":[{"border-t":me()}],"border-w-r":[{"border-r":me()}],"border-w-b":[{"border-b":me()}],"border-w-l":[{"border-l":me()}],"divide-x":[{"divide-x":me()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":me()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...he(),`hidden`,`none`]}],"divide-style":[{divide:[...he(),`hidden`,`none`]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...he(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[ZP,Z,X]}],"outline-w":[{outline:[``,ZP,gF,lF]}],"outline-color":[{outline:D()}],shadow:[{shadow:[``,`inner`,`none`,u,xF,hF]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":[`none`,d,xF,hF]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:me()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[ZP,lF]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":me()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":[`none`,f,xF,hF]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[ZP,Z,X]}],"mix-blend":[{"mix-blend":[...ge(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":ge()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[ZP]}],"mask-image-linear-from-pos":[{"mask-linear-from":_e()}],"mask-image-linear-to-pos":[{"mask-linear-to":_e()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":_e()}],"mask-image-t-to-pos":[{"mask-t-to":_e()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":_e()}],"mask-image-r-to-pos":[{"mask-r-to":_e()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":_e()}],"mask-image-b-to-pos":[{"mask-b-to":_e()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":_e()}],"mask-image-l-to-pos":[{"mask-l-to":_e()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":_e()}],"mask-image-x-to-pos":[{"mask-x-to":_e()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":_e()}],"mask-image-y-to-pos":[{"mask-y-to":_e()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[Z,X]}],"mask-image-radial-from-pos":[{"mask-radial-from":_e()}],"mask-image-radial-to-pos":[{"mask-radial-to":_e()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[ZP]}],"mask-image-conic-from-pos":[{"mask-conic-from":_e()}],"mask-image-conic-to-pos":[{"mask-conic-to":_e()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:le()}],"mask-repeat":[{mask:ue()}],"mask-size":[{mask:de()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,Z,X]}],filter:[{filter:[``,`none`,Z,X]}],blur:[{blur:ve()}],brightness:[{brightness:[ZP,Z,X]}],contrast:[{contrast:[ZP,Z,X]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,xF,hF]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:[``,ZP,Z,X]}],"hue-rotate":[{"hue-rotate":[ZP,Z,X]}],invert:[{invert:[``,ZP,Z,X]}],saturate:[{saturate:[ZP,Z,X]}],sepia:[{sepia:[``,ZP,Z,X]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,Z,X]}],"backdrop-blur":[{"backdrop-blur":ve()}],"backdrop-brightness":[{"backdrop-brightness":[ZP,Z,X]}],"backdrop-contrast":[{"backdrop-contrast":[ZP,Z,X]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,ZP,Z,X]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ZP,Z,X]}],"backdrop-invert":[{"backdrop-invert":[``,ZP,Z,X]}],"backdrop-opacity":[{"backdrop-opacity":[ZP,Z,X]}],"backdrop-saturate":[{"backdrop-saturate":[ZP,Z,X]}],"backdrop-sepia":[{"backdrop-sepia":[``,ZP,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:[ZP,`initial`,Z,X]}],ease:[{ease:[`linear`,`initial`,_,Z,X]}],delay:[{delay:[ZP,Z,X]}],animate:[{animate:[`none`,v,Z,X]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,Z,X]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:ye()}],"rotate-x":[{"rotate-x":ye()}],"rotate-y":[{"rotate-y":ye()}],"rotate-z":[{"rotate-z":ye()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":[`scale-3d`],skew:[{skew:O()}],"skew-x":[{"skew-x":O()}],"skew-y":[{"skew-y":O()}],transform:[{transform:[Z,X,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:xe()}],"translate-x":[{"translate-x":xe()}],"translate-y":[{"translate-y":xe()}],"translate-z":[{"translate-z":xe()}],"translate-none":[`translate-none`],zoom:[{zoom:[QP,Z,X]}],accent:[{accent:D()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,Z,X]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":D()}],"scrollbar-track-color":[{"scrollbar-track":D()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,Z,X]}],fill:[{fill:[`none`,...D()]}],"stroke-w":[{stroke:[ZP,gF,lF,uF]}],stroke:[{stroke:[`none`,...D()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`start`,`end`,`right`,`left`],"inset-y":[`inset-bs`,`inset-be`,`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`ps`,`pe`,`pr`,`pl`],py:[`pbs`,`pbe`,`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`ms`,`me`,`mr`,`ml`],my:[`mbs`,`mbe`,`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-s`,`border-w-e`,`border-w-r`,`border-w-l`],"border-w-y":[`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-s`,`border-color-e`,`border-color-r`,`border-color-l`],"border-color-y":[`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-ms`,`scroll-me`,`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-ps`,`scroll-pe`,`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function Q(...e){return NF(sP(e))}var PF={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}},FF={disabled:{label:`Not checked`,tone:`neutral`},unknown:{label:`Not probed`,tone:`neutral`},healthy:{label:`Healthy`,tone:`ok`},unhealthy:{label:`Unhealthy`,tone:`danger`}},IF={ok:`text-ok`,warn:`text-warn`,danger:`text-danger`,info:`text-info`,neutral:`text-muted`,accent:`text-accent`},LF={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`},RF={ok:`bg-ok`,warn:`bg-warn`,danger:`bg-danger`,info:`bg-info`,neutral:`bg-faint`,accent:`bg-accent`};function zF(e,t){return e===`crashed`||e===`conflict`||t===`unhealthy`?`danger`:e===`starting`||e===`stopping`||e===`backoff`?`warn`:e===`running`?`ok`:`neutral`}var BF={start:`Started`,exit:`Exited`,crash:`Crashed`,"forced-restart":`Forced restart`,unhealthy:`Unhealthy`,recovered:`Recovered`},VF={start:`ok`,exit:`neutral`,crash:`danger`,"forced-restart":`warn`,unhealthy:`warn`,recovered:`info`},HF={viewBox:`0 0 80 80`,class:`size-full -rotate-0`},UF=[`stroke-dasharray`],WF=[`stroke-dasharray`],GF={class:`absolute inset-0 grid place-items-center`},KF={class:`font-mono text-sm font-semibold tabular-nums text-ink`},qF={class:`text-2xs font-medium text-faint`},JF=34,YF=.75,XF=P({__name:`Gauge`,props:{value:{},label:{},display:{default:void 0},size:{default:74},tone:{default:void 0},warnAt:{default:75},dangerAt:{default:90}},setup(e){let t=e,n=2*Math.PI*JF,r=G(()=>t.value===null||!Number.isFinite(t.value)?0:Math.min(1,Math.max(0,t.value/100))*YF),i=G(()=>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)=>(R(),z(`div`,{class:O(j(Q)(`flex flex-col items-center gap-1`))},[V(`div`,{class:`relative`,style:ge({width:`${t.size}px`,height:`${t.size}px`})},[(R(),z(`svg`,HF,[V(`circle`,{cx:`40`,cy:`40`,r:JF,fill:`none`,class:`stroke-line-soft`,"stroke-width":6,"stroke-dasharray":`${YF*n} ${n}`,transform:`rotate(135 40 40)`,"stroke-linecap":`round`},null,8,UF),V(`circle`,{cx:`40`,cy:`40`,r:JF,fill:`none`,class:O([a[i.value],`transition-[stroke-dasharray] duration-300 ease-out`]),"stroke-width":6,"stroke-dasharray":`${r.value*n} ${n}`,transform:`rotate(135 40 40)`,"stroke-linecap":`round`},null,10,WF)])),V(`div`,GF,[V(`span`,KF,k(t.display??(t.value===null?`—`:`${Math.round(t.value)}%`)),1)])],4),V(`span`,qF,k(t.label),1)],2))}}),ZF=P({__name:`Meter`,props:{value:{},warnAt:{default:75},dangerAt:{default:90},height:{default:`h-1.5`},class:{default:void 0}},setup(e){let t=e,n=G(()=>t.value===null||!Number.isFinite(t.value)?0:Math.min(100,Math.max(0,t.value))),r=G(()=>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)=>(R(),z(`div`,{class:O(j(Q)(`w-full overflow-hidden rounded-full bg-line-soft`,t.height,t.class))},[V(`div`,{class:O(j(Q)(`h-full rounded-full transition-[width] duration-300 ease-out`,i[r.value])),style:ge({width:`${n.value}%`})},null,6)],2))}}),QF={key:0,class:`grid size-10 place-items-center rounded-full border border-line bg-panel-2 text-faint`},$F={class:`max-w-sm space-y-1`},eI={class:`text-sm font-medium text-ink`},tI={key:0,class:`text-xs leading-relaxed text-muted`},nI={key:1,class:`flex items-center gap-2`},rI=P({__name:`EmptyState`,props:{title:{},description:{default:void 0},compact:{type:Boolean,default:!1}},setup(e){return(e,t)=>(R(),z(`div`,{class:O(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?(R(),z(`div`,QF,[I(e.$slots,`icon`)])):W(``,!0),V(`div`,$F,[V(`p`,eI,k(e.$props.title),1),e.$props.description?(R(),z(`p`,tI,k(e.$props.description),1)):W(``,!0)]),e.$slots.action?(R(),z(`div`,nI,[I(e.$slots,`action`)])):W(``,!0)],2))}});function iI(e){let t=new Date(e);return`${t.toLocaleTimeString(void 0,{hour12:!1})}.${String(t.getMilliseconds()).padStart(3,`0`)}`}function aI(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 oI(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 sI(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 cI(e){return e===null?`—`:`${(e*100).toFixed(e>=.999?0:1)}%`}function lI(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 uI(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 dI(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 fI(e){return e===null||!Number.isFinite(e)?`—`:e>=100?`${Math.round(e)}%`:`${e.toFixed(1)}%`}function pI(e){return e===void 0?`unset`:typeof e==`string`?e:JSON.stringify(e)}var mI={key:1,class:`space-y-4`},hI={class:`grid grid-cols-2 gap-3 sm:grid-cols-4`},gI={class:`grid grid-cols-2 gap-x-4 gap-y-2 border-t border-line-soft pt-3 sm:grid-cols-4`},_I={class:`flex items-center gap-1 text-2xs text-faint`},vI={class:`font-mono text-xs text-ink`},yI={class:`font-mono text-xs tabular-nums text-ink`},bI={class:`flex items-center gap-1 text-2xs text-faint`},xI={class:`font-mono text-xs text-ink`},SI={class:`flex items-center gap-1 text-2xs text-faint`},CI={class:`font-mono text-xs text-ink`},wI={class:`space-y-2 border-t border-line-soft pt-3`},TI={class:`flex items-center gap-1.5 text-2xs font-medium text-faint`},EI={class:`flex items-baseline justify-between gap-2`},DI=[`title`],OI={class:`shrink-0 font-mono text-2xs tabular-nums text-faint`},kI={key:0,class:`space-y-1 rounded-control border border-danger/25 bg-danger-soft px-2.5 py-2`},AI=P({__name:`HostVitalsPanel`,props:{host:{},now:{}},setup(e){let t=e,n=G(()=>{let e=t.host;return e?(e.loadAvg[0]??0)/Math.max(1,e.cpus):null}),r=G(()=>t.host?.loadAvg.map(e=>e.toFixed(2)).join(` `)??`—`);return(e,i)=>!t.host||!t.host.enabled?(R(),B(rI,{key:0,compact:``,title:`Host sampling is off`,description:`Turn it on in Settings to collect load, memory, disk and temperature.`})):(R(),z(`div`,mI,[V(`div`,hI,[H(XF,{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`]),H(XF,{value:t.host.memoryUsedPercent,label:`Memory`,size:72},null,8,[`value`]),H(XF,{value:t.host.swapUsedPercent,label:`Swap`,size:72,"warn-at":50},null,8,[`value`]),H(XF,{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`])]),V(`dl`,gI,[V(`div`,null,[V(`dt`,_I,[H(j(qv),{class:`size-3`}),i[0]||=U(`CPUs `,-1)]),V(`dd`,vI,k(t.host.cpus),1)]),V(`div`,null,[i[1]||=V(`dt`,{class:`text-2xs text-faint`},` Load 1 / 5 / 15 `,-1),V(`dd`,yI,k(r.value),1)]),V(`div`,null,[V(`dt`,bI,[H(j(uy),{class:`size-3`}),i[2]||=U(`Memory used `,-1)]),V(`dd`,xI,k(t.host.memoryUsedPercent.toFixed(0))+`% `,1)]),V(`div`,null,[V(`dt`,SI,[H(j(Ny),{class:`size-3`}),i[3]||=U(`Sampled `,-1)]),V(`dd`,CI,k(j(lI)(t.host.sampledAt,t.now)),1)])]),V(`div`,wI,[V(`p`,TI,[H(j(ty),{class:`size-3`}),i[4]||=U(`Filesystems `,-1)]),(R(!0),z(L,null,F(t.host.disks,e=>(R(),z(`div`,{key:e.path,class:`space-y-1`},[V(`div`,EI,[V(`span`,{class:`truncate font-mono text-2xs text-muted`,title:e.path},k(e.path),9,DI),V(`span`,OI,k(j(uI)(e.totalBytes-e.freeBytes))+` / `+k(j(uI)(e.totalBytes))+` · `+k(e.usedPercent.toFixed(0))+`% `,1)]),H(ZF,{value:e.usedPercent},null,8,[`value`])]))),128))]),t.host.alerts.length>0?(R(),z(`div`,kI,[i[5]||=V(`p`,{class:`text-2xs font-medium text-danger`},` Thresholds breached `,-1),(R(!0),z(L,null,F(t.host.alerts,e=>(R(),z(`p`,{key:e,class:`text-2xs text-danger`},k(e),1))),128))])):W(``,!0)]))}}),jI={key:1,class:`flex flex-col`},MI={class:`min-w-0 flex-1`},NI={class:`flex items-baseline gap-1.5`},PI={class:`truncate text-xs font-medium text-ink`},FI=[`title`],II={key:0,class:`text-muted`},LI={class:`shrink-0 pt-0.5 text-2xs text-faint`},RI=P({__name:`ActivityFeed`,props:{servers:{},now:{},limit:{default:12},serverId:{default:void 0}},setup(e){let t=e,n={start:gy,exit:Ay,crash:Bv,"forced-restart":xy,unhealthy:Iy,recovered:Vv},r=G(()=>{let e=[];for(let n of t.servers)if(t.serverId===void 0||n.id===t.serverId)for(let t of n.history.events)e.push({...t,label:n.config.label??n.id});return e.sort((e,t)=>t.ts-e.ts).slice(0,t.limit)});return(e,i)=>{let a=fa(`RouterLink`);return r.value.length===0?(R(),B(rI,{key:0,compact:``,title:`No events in the last 24 hours`,description:`Starts, exits, crashes and recoveries show up here as they happen.`})):(R(),z(`ol`,jI,[(R(!0),z(L,null,F(r.value,(e,r)=>(R(),z(`li`,{key:`${e.serverId}-${e.ts}-${r}`,class:O([`flex items-start gap-2.5 border-line-soft py-2`,r>0&&`border-t`])},[(R(),B(ma(n[e.type]),{class:O(j(Q)(`mt-0.5 size-3.5 shrink-0`,j(IF)[j(VF)[e.type]]))},null,8,[`class`])),V(`div`,MI,[V(`p`,NI,[V(`span`,PI,k(j(BF)[e.type]),1),H(a,{to:`/servers/${e.serverId}`,class:`truncate text-2xs text-muted hover:text-accent`},{default:M(()=>[U(k(e.label),1)]),_:2},1032,[`to`])]),V(`p`,{class:`mt-0.5 truncate font-mono text-2xs text-faint`,title:e.detail},[U(k(e.detail)+` `,1),e.runtimeMs===void 0?W(``,!0):(R(),z(`span`,II,` · ran `+k(j(oI)(e.runtimeMs)),1))],8,FI)]),V(`span`,LI,k(j(lI)(e.ts,t.now)),1)],2))),128))]))}}}),zI=[`restart`,`health`,`stop`];function BI(e,t){return JSON.stringify(VI(e))===JSON.stringify(VI(t))}function VI(e){if(Array.isArray(e))return e.map(VI);if(typeof e==`object`&&e){let t={};for(let n of Object.keys(e).sort()){let r=e[n];r!=null&&(t[n]=VI(r))}return t}return e??null}function HI(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??{}))BI(t[e],r)||(n[e]=r);Object.keys(n).length>0&&(r[i]=n);continue}BI(e[i],a)||(r[i]=a)}return r}function UI(e,t){let n=e;return HI({...n,label:n.label??``},t,zI)}function WI(e,t=``){return typeof e!=`object`||!e||Array.isArray(e)?[{path:t,value:e}]:Object.entries(e).flatMap(([e,n])=>WI(n,t.length===0?e:`${t}.${e}`))}function GI(e,t){let n=new Map(WI(t).map(e=>[e.path,e.value]));return WI(e).map(e=>({path:e.path,from:n.get(e.path),to:e.value}))}function KI(e){let t=0;for(let n of Object.values(e))t+=typeof n==`object`&&n&&!Array.isArray(n)?KI(n):1;return t}async function qI(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 JI={enabled:!0,maxRetries:3,baseDelayMs:1e3,factor:2,maxDelayMs:3e4,resetAfterMs:6e4},YI={enabled:!0,mode:`port`,http:{path:`/`,method:`GET`,expectStatusBelow:400,expectBody:``},intervalMs:5e3,timeoutMs:1500,unhealthyThreshold:3,forceRestartAfterMs:0,startTimeoutMs:2e4},XI={signal:`SIGTERM`,killGroup:!0,graceMs:5e3,killPortHolders:!1};function ZI(e){return{...e,http:{...e.http}}}function QI(){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},host:{enabled:!0,intervalMs:15e3,diskPaths:`.`,diskUsedPercent:90,memoryUsedPercent:90,swapUsedPercent:50,loadPerCpu:2,tempCelsius:85},backups:{enabled:!0,keep:5,includePaths:``}}}function $I(){return{defaults:{enabled:!0,autostart:!1,bind:`local`,onPortConflict:`block`,logBufferLines:500,restart:{...JI},health:ZI(YI),stop:{...XI}},logs:{persist:!0,maxBytes:2e6,keep:3},telegram:{enabled:!1,chatId:``,cooldownMs:12e4,onCrash:!0,onUnhealthy:!0,onForcedRestart:!0,onRecovered:!1,onHost:!0,onDdns:!0}}}function eL(e){return{enabled:e.enabled,sessionTtlMs:e.sessionTtlMs,cookieSecure:e.cookieSecure,trustProxy:e.trustProxy,maxLoginAttempts:e.maxLoginAttempts,lockoutMs:e.lockoutMs}}function tL(e){return{label:e.label,port:e.port,host:e.host,openBrowser:e.openBrowser,tlsEnabled:e.tls.enabled}}function nL(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,onDdns:e.onDdns??!0}}function rL(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function iL(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 aL(e){return{enabled:e.enabled,keep:e.keep,includePaths:e.includePaths.join(`, `)}}function oL(e,t){return HI(e,{...t,diskPaths:rL(t.diskPaths)})}function sL(e,t){return HI(e,{...t,includePaths:rL(t.includePaths)})}function cL(e,t){return HI({label:e.label,port:e.port,host:e.host,openBrowser:e.openBrowser,auth:eL(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 lL(e,t){return HI(e,t,[`restart`,`health`,`stop`])}function uL(e,t){return HI(e,t)}function dL(e,t){return HI({telegram:nL(e)},{telegram:{...t}},[`telegram`])}function fL(e,t){switch(t){case`control`:return{...e.control,auth:{...e.auth}};case`host`:return{...e.host};case`backups`:return{...e.backups}}}function pL(e,t){switch(t){case`defaults`:return{...e.defaults,restart:{...e.defaults.restart},health:ZI(e.defaults.health),stop:{...e.defaults.stop}};case`logs`:return{...e.logs};case`telegram`:return{...e.telegram}}}function mL(e,t){return e!==void 0&&JSON.stringify(e)!==JSON.stringify(t)}function hL(e,t){return e.label!==t.control.label||e.port!==t.control.port||e.host!==t.control.host||e.openBrowser!==t.control.openBrowser}function gL(e,t){return e.tls.enabled!==t.control.tlsEnabled}function _L(e,t){return KI(HI({...eL(e.auth)},{...t.auth}))>0}function vL(e,t,n){return G({get:e,set:e=>{t(e===null||Number.isNaN(e)?n:e)}})}async function yL(e){if(!e.rebinding)return null;let t=e.targetUrl??e.control.url;return t.length===0||t===window.location.origin?null:await qI(t)?(window.location.replace(t),null):`The control panel did not answer on ${t}. Check the console for the new listener.`}function bL(e){return e.split(`
40
+ `).map(e=>e.trim()).filter(e=>e.length>0)}function xL(e){return Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`
41
+ `)}function SL(e){let t={};for(let n of bL(e)){let e=n.indexOf(`=`);e<=0||(t[n.slice(0,e).trim()]=n.slice(e+1).trim())}return t}function CL(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}var wL=/^[a-z0-9][a-z0-9_-]*$/;function TL(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??JI},health:ZI(e?.health??YI),stop:{...e?.stop??XI},bootstrapEnabled:!1,bootstrapCommand:``,bootstrapArgs:``,bootstrapEnv:``,bootstrapTimeoutMs:12e4,bootstrapRunOnce:!0}}function EL(e){return e!==null&&Number.isFinite(e)?e:0}function DL(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 OL(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 kL(e,t){let n=EL(e.maxRssMb),r=EL(e.bootstrapTimeoutMs),i=DL(t),a=HI({restart:t?.restart??JI,health:t?.health??YI,stop:t?.stop??XI},{restart:e.restart,health:e.health,stop:e.stop});return{...HI(i,{args:bL(e.args),cwd:e.cwd.trim().length>0?e.cwd.trim():`.`,env:SL(e.env),dataEnvs:SL(e.dataEnvs),dependsOn:CL(e.dependsOn),envFile:e.envFile.trim(),backupPaths:bL(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:EL(e.logBufferLines)>0?EL(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:bL(e.bootstrapArgs),env:SL(e.bootstrapEnv),timeoutMs:r>=1e3?r:12e4,runOnce:e.bootstrapRunOnce}}:{}}}function AL(e){return e.id.trim().length===0?`An id is required — it is the key this server lives under.`:wL.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.`:OL(e.port):`The id must start with a lowercase letter or digit and contain only lowercase letters, digits, dashes and underscores.`}var jL={class:`mb-3 flex items-start justify-between gap-3`},ML={class:`min-w-0`},NL={class:`text-xs font-semibold text-ink`},PL={key:0,class:`mt-0.5 text-2xs leading-4 text-muted`},FL={class:`flex shrink-0 items-center gap-2`},IL=P({__name:`FieldGroup`,props:{title:{},description:{default:void 0},columns:{default:2},dense:{type:Boolean,default:!1},class:{default:void 0}},setup(e){let t=e,n=G(()=>({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)=>(R(),z(`section`,{class:O(j(Q)(`rounded-panel border border-line bg-panel-2/40`,t.dense?`p-3`:`p-3.5`,t.class))},[V(`header`,jL,[V(`div`,ML,[V(`h3`,NL,k(t.title),1),t.description?(R(),z(`p`,PL,k(t.description),1)):W(``,!0)]),V(`div`,FL,[I(e.$slots,`actions`)])]),V(`div`,{class:O(j(Q)(`grid gap-3`,n.value))},[I(e.$slots,`default`)],2)],2))}});function LL(e){return e==null||Number.isNaN(e)?``:String(e)}function RL(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 zL=`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60 focus-visible:ring-offset-2 focus-visible:ring-offset-page`,BL=`text-xs font-medium text-muted`,VL=`text-2xs leading-4 text-faint`,HL=[`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(` `),UL=`${HL} font-mono text-xs`,WL=[`for`],GL=[`id`,`step`,`min`,`max`,`aria-invalid`],KL={key:1,class:`text-2xs text-danger`},qL=P({inheritAttrs:!1,__name:`NumberField`,props:Ra({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=oo(e,`modelValue`),r=li(),i=G({get:()=>LL(n.value),set:e=>{n.value=RL(e,t.nullable)}}),a=G(()=>n.value!==null&&Number.isNaN(n.value));return(e,n)=>(R(),z(`div`,{class:O(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(R(),z(`label`,{key:0,for:j(r),class:O(j(BL))},k(t.label),11,WL)):W(``,!0),xr(V(`input`,js({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(HL),`font-mono tabular-nums`,(t.error||a.value)&&`border-danger`),"aria-invalid":t.error||a.value?!0:void 0},e.$attrs),null,16,GL),[[ql,i.value]]),t.error?(R(),z(`p`,KL,k(t.error),1)):t.hint?(R(),z(`p`,{key:2,class:O(j(VL))},k(t.hint),3)):W(``,!0)],2))}}),JL=[`for`],YL={class:`relative`},XL=[`id`],ZL=[`value`,`disabled`],QL={key:1,class:`text-2xs text-danger`},$L=P({inheritAttrs:!1,__name:`SelectField`,props:Ra({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=oo(e,`modelValue`),r=li();return(e,i)=>(R(),z(`div`,{class:O(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(R(),z(`label`,{key:0,for:j(r),class:O(j(BL))},k(t.label),11,JL)):W(``,!0),V(`div`,YL,[xr(V(`select`,js({id:j(r),"onUpdate:modelValue":i[0]||=e=>n.value=e,class:j(Q)(j(HL),`cursor-pointer appearance-none pr-7`,t.mono&&`font-mono text-xs`,t.error&&`border-danger`)},e.$attrs),[(R(!0),z(L,null,F(t.options,e=>(R(),z(`option`,{key:e.value,value:e.value,disabled:e.disabled},k(e.label),9,ZL))),128))],16,XL),[[Zl,n.value]]),H(j(Fv),{class:`pointer-events-none absolute right-2 top-1/2 size-3.5 -translate-y-1/2 text-faint`,"aria-hidden":`true`})]),t.error?(R(),z(`p`,QL,k(t.error),1)):t.hint?(R(),z(`p`,{key:2,class:O(j(VL))},k(t.hint),3)):W(``,!0)],2))}}),eR=[`for`],tR=[`id`,`aria-invalid`,`aria-describedby`],nR=[`id`],rR=[`id`],iR=P({inheritAttrs:!1,__name:`TextField`,props:Ra({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=oo(e,`modelValue`),r=li(),i=G(()=>t.hint||t.error?`${r}-hint`:void 0);return(e,a)=>(R(),z(`div`,{class:O(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(R(),z(`label`,{key:0,for:j(r),class:O(j(BL))},k(t.label),11,eR)):W(``,!0),xr(V(`input`,js({id:j(r),"onUpdate:modelValue":a[0]||=e=>n.value=e,class:j(Q)(j(HL),t.error&&`border-danger`),"aria-invalid":t.error?!0:void 0,"aria-describedby":i.value},e.$attrs),null,16,tR),[[nu,n.value]]),t.error?(R(),z(`p`,{key:1,id:`${j(r)}-hint`,class:`text-2xs text-danger`},k(t.error),9,nR)):t.hint?(R(),z(`p`,{key:2,id:`${j(r)}-hint`,class:O(j(VL))},k(t.hint),11,rR)):W(``,!0)],2))}}),aR={key:0,class:`block text-2xs text-faint`},oR=P({__name:`ToggleSwitch`,props:Ra({label:{},hint:{default:void 0},disabled:{type:Boolean,default:!1},trailing:{type:Boolean,default:!1},wide:{type:Boolean,default:!1},srOnly:{type:Boolean,default:!1}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=oo(e,`modelValue`);return(e,r)=>(R(),z(`div`,{class:O(j(Q)(`flex items-center gap-2.5`,t.trailing&&`flex-row-reverse justify-end`,t.wide&&`sm:col-span-2`))},[H(j(sg),{modelValue:n.value,"onUpdate:modelValue":r[0]||=e=>n.value=e,disabled:t.disabled,class:O(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(zL)))},{default:M(()=>[H(j(cg),{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`]),V(`label`,{class:`min-w-0 cursor-pointer select-none`,onClick:r[1]||=e=>!t.disabled&&(n.value=!n.value)},[V(`span`,{class:O(j(Q)(`block text-xs text-ink`,t.srOnly&&`sr-only`))},k(t.label),3),t.hint?(R(),z(`span`,aR,k(t.hint),1)):W(``,!0)])],2))}}),sR=P({__name:`LifecycleFields`,props:Ra({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=oo(e,`restart`),n=oo(e,`health`),r=oo(e,`stop`);function i(e,t,n=0){return G({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=G({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)=>(R(),z(L,null,[H(IL,{title:`Restart policy`,description:`Backoff between attempts after a crash.`,columns:3},{default:M(()=>[H(oR,{modelValue:t.value.enabled,"onUpdate:modelValue":y[0]||=e=>t.value.enabled=e,label:`Restart on crash`,wide:``},null,8,[`modelValue`]),H(qL,{modelValue:j(a),"onUpdate:modelValue":y[1]||=e=>mn(a)?a.value=e:null,label:`Max retries`,min:0,hint:`Attempts before the server is left crashed.`},null,8,[`modelValue`]),H(qL,{modelValue:j(o),"onUpdate:modelValue":y[2]||=e=>mn(o)?o.value=e:null,label:`Base delay (ms)`,min:0},null,8,[`modelValue`]),H(qL,{modelValue:j(s),"onUpdate:modelValue":y[3]||=e=>mn(s)?s.value=e:null,label:`Backoff factor`,min:1,step:.1},null,8,[`modelValue`]),H(qL,{modelValue:j(c),"onUpdate:modelValue":y[4]||=e=>mn(c)?c.value=e:null,label:`Max delay (ms)`,min:0},null,8,[`modelValue`]),H(qL,{modelValue:j(l),"onUpdate:modelValue":y[5]||=e=>mn(l)?l.value=e:null,label:`Reset after (ms)`,min:0,hint:`A run this long clears the retry counter.`},null,8,[`modelValue`])]),_:1}),H(IL,{title:`Health check`,description:`How readiness is probed once the process is up.`,columns:3},{default:M(()=>[H(oR,{modelValue:n.value.enabled,"onUpdate:modelValue":y[6]||=e=>n.value.enabled=e,label:`Probe this server`,wide:``},null,8,[`modelValue`]),H($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`]),H(qL,{modelValue:j(u),"onUpdate:modelValue":y[8]||=e=>mn(u)?u.value=e:null,label:`Interval (ms)`,min:500,step:100},null,8,[`modelValue`]),H(qL,{modelValue:j(d),"onUpdate:modelValue":y[9]||=e=>mn(d)?d.value=e:null,label:`Timeout (ms)`,min:100,step:100},null,8,[`modelValue`]),H(qL,{modelValue:j(f),"onUpdate:modelValue":y[10]||=e=>mn(f)?f.value=e:null,label:`Unhealthy after`,min:1,hint:`Consecutive failed probes.`},null,8,[`modelValue`]),H(qL,{modelValue:j(p),"onUpdate:modelValue":y[11]||=e=>mn(p)?p.value=e:null,label:`Force restart after (ms)`,min:0,hint:`0 disables it.`},null,8,[`modelValue`]),H(qL,{modelValue:j(m),"onUpdate:modelValue":y[12]||=e=>mn(m)?m.value=e:null,label:`Start timeout (ms)`,min:0},null,8,[`modelValue`]),e.showHttp&&n.value.mode===`http`?(R(),z(L,{key:0},[H(iR,{modelValue:n.value.http.path,"onUpdate:modelValue":y[13]||=e=>n.value.http.path=e,label:`HTTP path`,placeholder:`/healthz`},null,8,[`modelValue`]),H($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`]),H(qL,{modelValue:h.value,"onUpdate:modelValue":y[15]||=e=>h.value=e,label:`Expect status`,nullable:``,hint:`Blank accepts anything below.`},null,8,[`modelValue`]),H(qL,{modelValue:j(g),"onUpdate:modelValue":y[16]||=e=>mn(g)?g.value=e:null,label:`Healthy below status`,min:100},null,8,[`modelValue`]),H(iR,{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)):W(``,!0)]),_:1}),H(IL,{title:`Stop behaviour`,description:`How the process tree is asked to go away.`,columns:3},{default:M(()=>[H($L,{modelValue:r.value.signal,"onUpdate:modelValue":y[18]||=e=>r.value.signal=e,label:`Signal`,options:v},null,8,[`modelValue`]),H(qL,{modelValue:j(_),"onUpdate:modelValue":y[19]||=e=>mn(_)?_.value=e:null,label:`Grace period (ms)`,min:0},null,8,[`modelValue`]),H(oR,{modelValue:r.value.killGroup,"onUpdate:modelValue":y[20]||=e=>r.value.killGroup=e,label:`Kill the whole process group`},null,8,[`modelValue`]),H(oR,{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))}}),cR=[`type`,`disabled`,`aria-busy`],$=P({inheritAttrs:!1,__name:`AppButton`,props:{variant:{default:`secondary`},size:{default:`sm`},type:{default:`button`},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},block:{type:Boolean,default:!1}},setup(e){let t=e,n=Pa(),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=G(()=>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`,zL,n.class));return(e,r)=>(R(),z(`button`,js({...j(n),class:void 0},{type:t.type,class:a.value,disabled:t.disabled||t.loading,"aria-busy":t.loading||void 0}),[t.loading?(R(),B(j(oy),{key:0,class:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`})):W(``,!0),I(e.$slots,`default`)],16,cR))}}),lR=[`open`],uR={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`},dR={key:0,class:`ml-1 truncate text-2xs font-normal text-faint`},fR={class:`grid gap-3 border-t border-line-soft px-3 py-3`},pR=P({__name:`Disclosure`,props:{title:{},hint:{default:void 0},open:{type:Boolean,default:!1}},setup(e){let t=e;return(e,n)=>(R(),z(`details`,{class:`group rounded-panel border border-line bg-panel-2/40`,open:t.open},[V(`summary`,uR,[H(j(Lv),{class:`size-3.5 shrink-0 text-muted transition-transform duration-150 group-open:rotate-90`,"aria-hidden":`true`}),U(` `+k(t.title)+` `,1),t.hint?(R(),z(`span`,dR,k(t.hint),1)):W(``,!0)]),V(`div`,fR,[I(e.$slots,`default`)])],8,lR))}}),mR={class:`flex shrink-0 items-start justify-between gap-4 border-b border-line px-4 py-3`},hR={class:`min-w-0`},gR={class:`min-h-0 flex-1 overflow-y-auto px-4 py-3.5`},_R={key:0,class:`flex shrink-0 items-center justify-end gap-2 border-t border-line bg-panel-2 px-4 py-3`},vR=P({__name:`Modal`,props:Ra({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=oo(e,`open`);return(e,r)=>(R(),B(j(cf),{open:n.value,"onUpdate:open":r[0]||=e=>n.value=e},{default:M(()=>[H(j(Jf),null,{default:M(()=>[H(j(Kf),{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]`}),H(j(Uf),{class:O(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(()=>[V(`header`,mR,[V(`div`,hR,[H(j(Yf),{class:`text-sm font-semibold text-ink`},{default:M(()=>[U(k(t.title),1)]),_:1}),t.description?(R(),B(j(Wf),{key:0,class:`mt-0.5 text-xs text-muted`},{default:M(()=>[U(k(t.description),1)]),_:1})):W(``,!0)]),H(j(lf),{class:O(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(zL))),"aria-label":`Close`},{default:M(()=>[H(j(Ry),{class:`size-4`})]),_:1},8,[`class`])]),V(`div`,gR,[I(e.$slots,`default`)]),e.$slots.footer?(R(),z(`footer`,_R,[I(e.$slots,`footer`)])):W(``,!0)]),_:3},8,[`class`])]),_:3})]),_:3},8,[`open`]))}}),yR=[`for`],bR=[`id`,`rows`,`placeholder`],xR={key:1,class:`text-2xs text-danger`},SR=P({inheritAttrs:!1,__name:`TextAreaField`,props:Ra({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=oo(e,`modelValue`),r=li();return(e,i)=>(R(),z(`div`,{class:O(j(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(R(),z(`label`,{key:0,for:j(r),class:O(j(BL))},k(t.label),11,yR)):W(``,!0),xr(V(`textarea`,js({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(UL):`font-sans`,`resize-y leading-relaxed`,t.error&&`border-danger`)},e.$attrs),null,16,bR),[[ql,n.value]]),t.error?(R(),z(`p`,xR,k(t.error),1)):t.hint?(R(),z(`p`,{key:2,class:O(j(VL))},k(t.hint),3)):W(``,!0)],2))}}),CR={class:`rounded-panel border border-line-soft bg-panel-2/40 p-3`},wR={class:`mt-1.5 flex flex-wrap gap-1`},TR={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`},ER=P({__name:`AddServerDialog`,props:Ra({workspaceId:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:Ra([`created`],[`update:open`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`open`),a=WN(),o=A(!1),s=A(null),c=[`{port}`,`{host}`,`{home}`,`{projectDir}`,`{dataRoot}`,`{id}`,`{label}`,`{cwd}`,`{bind}`,`{lanIp}`],l=G(()=>a.workspaceById(n.workspaceId)?.defaults),u=G(()=>a.workspaceById(n.workspaceId)?.label??`this workspace`),d=en(TL(l.value)),f=G(()=>OL(d.port));function p(){Object.assign(d,TL(l.value)),s.value=null}N(i,e=>{e&&p()});async function m(){s.value=null;let e=AL(d);if(e!==null){s.value=e;return}let t=zA(kL(d,l.value));if(t instanceof Y.errors){s.value=t.summary;return}o.value=!0;try{if(await a.create(n.workspaceId,t),a.lastError.value!==null){s.value=a.lastError.value;return}r(`created`),i.value=!1,p()}finally{o.value=!1}}return(e,t)=>(R(),B(vR,{open:i.value,"onUpdate:open":t[29]||=e=>i.value=e,title:`Add a server`,description:`Appends an entry to ${u.value}'s servers.config.json; every policy you leave out is inherited from its defaults.`,width:`w-[min(94vw,40rem)]`},{footer:M(()=>[H($,{variant:`ghost`,onClick:t[28]||=e=>i.value=!1},{default:M(()=>[...t[32]||=[U(` Cancel `,-1)]]),_:1}),H($,{type:`submit`,form:`add-server-form`,variant:`primary`,loading:o.value},{default:M(()=>[...t[33]||=[U(` Add to servers.config.json `,-1)]]),_:1},8,[`loading`])]),default:M(()=>[V(`form`,{id:`add-server-form`,class:`flex flex-col gap-3`,onSubmit:cu(m,[`prevent`])},[H(IL,{title:`Identity`,columns:2,dense:``},{default:M(()=>[H(iR,{modelValue:d.id,"onUpdate:modelValue":t[0]||=e=>d.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`]),H(iR,{modelValue:d.label,"onUpdate:modelValue":t[1]||=e=>d.label=e,label:`Label`,placeholder:`My server`,hint:`Shown in the panel; defaults to the id.`},null,8,[`modelValue`])]),_:1}),H(IL,{title:`Process`,columns:2,dense:``},{default:M(()=>[H(iR,{modelValue:d.command,"onUpdate:modelValue":t[2]||=e=>d.command=e,label:`Command`,placeholder:`node`,hint:`Spawned without a shell.`,class:`font-mono text-xs`},null,8,[`modelValue`]),H(iR,{modelValue:d.cwd,"onUpdate:modelValue":t[3]||=e=>d.cwd=e,label:`Working directory`,placeholder:`.`,hint:`Relative paths resolve under projectDir.`,class:`font-mono text-xs`},null,8,[`modelValue`])]),_:1}),H(SR,{modelValue:d.args,"onUpdate:modelValue":t[4]||=e=>d.args=e,label:`Arguments`,rows:3,hint:`One argument per line; whitespace inside a line is preserved.`,placeholder:`-p
42
+ {port}`},null,8,[`modelValue`]),H(IL,{title:`Port & lifecycle`,columns:2,dense:``},{default:M(()=>[H(qL,{modelValue:d.port,"onUpdate:modelValue":t[5]||=e=>d.port=e,label:`Port`,nullable:``,min:1,max:65535,error:f.value,hint:`Blank means the server has no port to probe or preflight.`},null,8,[`modelValue`,`error`]),H($L,{modelValue:d.bind,"onUpdate:modelValue":t[6]||=e=>d.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`]),H(oR,{modelValue:d.autostart,"onUpdate:modelValue":t[7]||=e=>d.autostart=e,label:`Autostart with up`,hint:`Start it whenever the control plane comes up.`,wide:``},null,8,[`modelValue`]),H(oR,{modelValue:d.persistent,"onUpdate:modelValue":t[8]||=e=>d.persistent=e,label:`Persistent`,hint:"Keeps running when the panel stops; `down` reports it instead of stopping it.",wide:``},null,8,[`modelValue`])]),_:1}),H(pR,{title:`Advanced settings`,hint:`environment, backups, policy, lifecycle, bootstrap`},{default:M(()=>[H(IL,{title:`Environment`,columns:2,dense:``},{default:M(()=>[H(SR,{modelValue:d.env,"onUpdate:modelValue":t[9]||=e=>d.env=e,label:`Environment`,rows:3,hint:`KEY=value per line, exported to the process.`,placeholder:`NODE_ENV=production`},null,8,[`modelValue`]),H(SR,{modelValue:d.dataEnvs,"onUpdate:modelValue":t[10]||=e=>d.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`]),H(iR,{modelValue:d.envFile,"onUpdate:modelValue":t[11]||=e=>d.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`]),H(iR,{modelValue:d.dependsOn,"onUpdate:modelValue":t[12]||=e=>d.dependsOn=e,label:`Depends on`,placeholder:`postgres, redis`,hint:`Comma separated; started first, stopped last.`,class:`font-mono text-xs`},null,8,[`modelValue`])]),_:1}),H(IL,{title:`Backups`,columns:2,dense:``},{default:M(()=>[H(SR,{modelValue:d.backupPaths,"onUpdate:modelValue":t[13]||=e=>d.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`]),H(oR,{modelValue:d.backupIgnoreGenerated,"onUpdate:modelValue":t[14]||=e=>d.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}),H(sR,{restart:d.restart,"onUpdate:restart":t[15]||=e=>d.restart=e,health:d.health,"onUpdate:health":t[16]||=e=>d.health=e,stop:d.stop,"onUpdate:stop":t[17]||=e=>d.stop=e},null,8,[`restart`,`health`,`stop`]),H(IL,{title:`Bootstrap`,description:`A one-off command run before the first start.`,columns:2,dense:``},{default:M(()=>[H(oR,{modelValue:d.bootstrapEnabled,"onUpdate:modelValue":t[18]||=e=>d.bootstrapEnabled=e,label:`Run a bootstrap`,hint:`Installs, migrations, downloads — before the first start, not on every one.`,wide:``},null,8,[`modelValue`]),d.bootstrapEnabled?(R(),z(L,{key:0},[H(iR,{modelValue:d.bootstrapCommand,"onUpdate:modelValue":t[19]||=e=>d.bootstrapCommand=e,label:`Command`,placeholder:`./scripts/install.sh`,class:`font-mono text-xs`},null,8,[`modelValue`]),H(qL,{modelValue:d.bootstrapTimeoutMs,"onUpdate:modelValue":t[20]||=e=>d.bootstrapTimeoutMs=e,label:`Timeout (ms)`,min:1e3,step:1e3},null,8,[`modelValue`]),H(oR,{modelValue:d.bootstrapRunOnce,"onUpdate:modelValue":t[21]||=e=>d.bootstrapRunOnce=e,label:`Only once per session`,hint:`Off means every start re-runs it.`},null,8,[`modelValue`]),H(SR,{modelValue:d.bootstrapArgs,"onUpdate:modelValue":t[22]||=e=>d.bootstrapArgs=e,label:`Bootstrap arguments`,rows:2,hint:`One per line; same placeholders as the main arguments.`},null,8,[`modelValue`]),H(SR,{modelValue:d.bootstrapEnv,"onUpdate:modelValue":t[23]||=e=>d.bootstrapEnv=e,label:`Bootstrap environment`,rows:2,hint:`KEY=value per line, exported to the bootstrap process only.`},null,8,[`modelValue`])],64)):W(``,!0)]),_:1}),H(IL,{title:`Policy & resources`,columns:2,dense:``},{default:M(()=>[H($L,{modelValue:d.onPortConflict,"onUpdate:modelValue":t[24]||=e=>d.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`]),H(qL,{modelValue:d.logBufferLines,"onUpdate:modelValue":t[25]||=e=>d.logBufferLines=e,label:`Log buffer lines`,min:50,max:1e5,step:50,hint:`Blank keeps the default.`},null,8,[`modelValue`]),H(qL,{modelValue:d.maxRssMb,"onUpdate:modelValue":t[26]||=e=>d.maxRssMb=e,label:`Max RSS (MB)`,min:0,hint:`Restart above this; blank or 0 disables it.`},null,8,[`modelValue`]),H(oR,{modelValue:d.enabled,"onUpdate:modelValue":t[27]||=e=>d.enabled=e,label:`Enabled`,hint:`Off keeps the entry in the config but refuses to start it.`,wide:``},null,8,[`modelValue`])]),_:1}),t[30]||=V(`p`,{class:`text-2xs leading-4 text-faint`},[U(` Restart, health and stop start out matching `),V(`span`,{class:`font-mono`},`Settings → Server defaults`),U(`; change one here and it is written into this entry instead of staying inherited. `)],-1)]),_:1}),V(`div`,CR,[t[31]||=V(`p`,{class:`text-2xs font-medium text-muted`},` Available argument placeholders `,-1),V(`div`,wR,[(R(),z(L,null,F(c,e=>V(`code`,{key:e,class:`rounded-control border border-line bg-raise px-1.5 py-0.5 font-mono text-2xs text-ink`},k(e),1)),64))])]),s.value?(R(),z(`p`,TR,k(s.value),1)):W(``,!0)],32)]),_:1},8,[`open`,`description`]))}}),DR={class:`text-xs font-semibold text-ink`},OR={class:`mt-2.5 flex justify-end gap-1.5`},kR=P({__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)=>(R(),B(j(Uh),{open:i.value,"onUpdate:open":t[0]||=e=>i.value=e},{default:M(()=>[H(j(Xh),{"as-child":``},{default:M(()=>[H($,{variant:`danger-ghost`,size:`xs`,loading:n.busy},{default:M(()=>[U(` Kill what holds port `+k(n.port),1)]),_:1},8,[`loading`])]),_:1}),H(j(Yh),null,{default:M(()=>[H(j(Jh),{"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(()=>[V(`p`,DR,` Kill the process on port `+k(n.port)+`? `,1),t[3]||=V(`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),V(`div`,OR,[H(j(Wh),{"as-child":``},{default:M(()=>[H($,{size:`xs`,variant:`ghost`},{default:M(()=>[...t[1]||=[U(` Keep it `,-1)]]),_:1})]),_:1}),H($,{size:`xs`,variant:`danger`,loading:n.busy,onClick:a},{default:M(()=>[...t[2]||=[U(` Kill it `,-1)]]),_:1},8,[`loading`])])]),_:1})]),_:1})]),_:1},8,[`open`]))}}),AR=[`viewBox`],jR=[`id`],MR=[`stop-color`],NR=[`stop-color`],PR=[`d`,`fill`],FR=[`d`,`stroke`,`stroke-width`],IR=[`x1`,`x2`,`y2`,`stroke`],LR=[`cx`,`cy`,`fill`],RR={key:0,class:`absolute inset-x-0 top-1/2 border-t border-dashed border-line`},zR=100,BR=P({__name:`Sparkline`,props:Ra({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=oo(e,`hoverIndex`),r=li(),i=A(null),a=G(()=>{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=G(()=>{let e=t.values,{bottom:n,ceiling:r}=a.value,i=r-n,o=e.length>1?zR/(e.length-1):zR,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=G(()=>n.value===null||t.values.length<2?null:n.value/(t.values.length-1)*zR),c=G(()=>{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)=>(R(),z(`div`,{ref_key:`track`,ref:i,class:O(j(Q)(`relative w-full`,t.class)),style:ge({height:`${t.height}px`}),onMousemove:l,onMouseleave:u},[(R(),z(`svg`,{viewBox:`0 0 ${zR} ${t.height}`,preserveAspectRatio:`none`,class:`block size-full overflow-visible`,role:`img`,"aria-hidden":`true`},[V(`defs`,null,[V(`linearGradient`,{id:j(r),x1:`0`,y1:`0`,x2:`0`,y2:`1`},[V(`stop`,{offset:`0%`,"stop-color":t.color??`currentColor`,"stop-opacity":`0.26`},null,8,MR),V(`stop`,{offset:`100%`,"stop-color":t.color??`currentColor`,"stop-opacity":`0`},null,8,NR)],8,jR)]),(R(!0),z(L,null,F(o.value,(e,n)=>(R(),z(L,{key:n},[t.fill?(R(),z(`path`,{key:0,d:e.area,fill:`url(#${j(r)})`,stroke:`none`},null,8,PR)):W(``,!0),V(`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,FR)],64))),128)),s.value===null?W(``,!0):(R(),z(`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,IR)),s.value!==null&&c.value!==null?(R(),z(`circle`,{key:1,cx:s.value,cy:c.value,r:`2`,fill:t.color??`currentColor`,"vector-effect":`non-scaling-stroke`},null,8,LR)):W(``,!0)],8,AR)),o.value.length===0?(R(),z(`div`,RR)):W(``,!0)],38))}}),VR={class:`min-w-0`},HR={class:`flex items-baseline justify-between gap-2`},UR={class:`truncate text-2xs font-medium text-faint`},WR={class:`flex shrink-0 items-baseline gap-1.5`},GR={key:0,class:`font-mono text-2xs text-faint`},KR=P({__name:`MetricSpark`,props:{label:{},values:{},format:{},max:{default:null},colorClass:{default:`text-accent`},height:{default:30},sampleMs:{default:5e3},emptyHint:{default:`collecting…`}},setup(e){let t=e,n=A(null),r=G(()=>_N(t.values)),i=G(()=>t.values.some(e=>e!==null)),a=G(()=>{let e=n.value;return e!==null&&t.values[e]!==void 0?t.values[e]??null:r.value}),o=G(()=>{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)=>(R(),z(`div`,VR,[V(`div`,HR,[V(`span`,UR,k(t.label),1),V(`span`,WR,[o.value?(R(),z(`span`,GR,k(o.value),1)):W(``,!0),V(`span`,{class:O(j(Q)(`font-mono text-xs font-medium tabular-nums`,i.value?`text-ink`:`text-faint`))},k(i.value?t.format(a.value):t.emptyHint),3)])]),H(BR,{"hover-index":n.value,"onUpdate:hoverIndex":r[0]||=e=>n.value=e,values:t.values,height:t.height,max:t.max,interactive:``,class:O(j(Q)(`mt-1`,t.colorClass))},null,8,[`hover-index`,`values`,`height`,`max`,`class`])]))}}),qR={class:`inline-flex flex-wrap items-center gap-1.5`},JR={class:`relative flex size-1.5`},YR={key:0,class:`absolute inset-0 rounded-full bg-current opacity-60`,style:{animation:`hh-pulse-ring 1.6s ease-out infinite`}},XR=P({__name:`StatusPill`,props:{status:{},health:{default:null},showHealth:{type:Boolean,default:!0}},setup(e){let t=e,n=G(()=>PF[t.status]),r=G(()=>t.health?FF[t.health]:null),i=G(()=>t.showHealth&&r.value!==null&&t.health!==`disabled`&&t.health!==`unknown`&&(r.value.tone===`danger`||r.value.tone===`warn`)),a=G(()=>n.value.transitional);return(e,t)=>(R(),z(`span`,qR,[V(`span`,{class:O(j(Q)(`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-2xs font-medium`,j(LF)[n.value.tone]))},[V(`span`,JR,[a.value?(R(),z(`span`,YR)):W(``,!0),V(`span`,{class:O(j(Q)(`relative size-1.5 rounded-full`,j(RF)[n.value.tone]))},null,2)]),U(` `+k(n.value.label),1)],2),i.value&&r.value?(R(),z(`span`,{key:0,class:O(j(Q)(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-2xs font-medium`,j(LF)[r.value.tone]))},k(r.value.label),3)):W(``,!0)]))}}),ZR=P({__name:`Tip`,props:{label:{},side:{default:`top`},disabled:{type:Boolean,default:!1}},setup(e){return(t,n)=>(R(),B(j(hg),{"delay-duration":350},{default:M(()=>[H(j(bg),{"as-child":``},{default:M(()=>[I(t.$slots,`default`)]),_:3}),e.disabled?W(``,!0):(R(),B(j(yg),{key:0},{default:M(()=>[H(j(vg),{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(()=>[U(k(e.label),1)]),_:1},8,[`side`])]),_:1}))]),_:3}))}}),QR={class:`flex items-start justify-between gap-3 px-4 pb-2.5 pt-3.5`},$R={class:`min-w-0`},ez={class:`flex items-center gap-2`},tz=[`href`,`title`,`aria-label`],nz={class:`mt-0.5 flex items-center gap-1.5 truncate font-mono text-2xs text-faint`},rz={class:`text-muted`},iz={key:1,class:`rounded bg-hover px-1 py-px text-muted`},az={key:2,class:`rounded bg-accent-soft px-1 py-px text-accent`},oz=[`title`],sz={key:0,class:`space-y-2.5 border-y border-line-soft px-4 py-3`},cz={class:`grid grid-cols-2 gap-x-4 gap-y-2`},lz={key:1,class:`flex flex-wrap items-center gap-x-3 gap-y-1 px-4 pt-2.5`},uz={class:`text-muted`},dz={class:`text-faint`},fz={key:2,class:`flex flex-col gap-1 px-4 pt-2.5`},pz={key:0,class:`flex items-start gap-1.5 text-2xs leading-4 text-danger`},mz={class:`min-w-0 break-words`},hz={key:2,class:`text-2xs leading-4 text-warn`},gz={key:3,class:`text-2xs leading-4 text-warn`},_z={class:`grid grid-cols-2 gap-x-4 gap-y-1 px-4 py-3 sm:grid-cols-4`},vz={class:`truncate text-2xs text-faint`},yz={class:`truncate font-mono text-xs tabular-nums text-ink capitalize`},bz={class:`mt-auto flex items-center gap-1.5 border-t border-line-soft px-4 py-2.5`},xz={class:`grid grid-cols-2 gap-2 text-xs`},Sz={class:`font-mono text-ink`},Cz={class:`text-ink capitalize`},wz=P({__name:`ServerCard`,props:{server:{},workspaceId:{},series:{},now:{},variant:{default:`default`}},setup(e){let t=e,n={start:gy,exit:Ay,crash:Bv,"forced-restart":xy,unhealthy:Iy,recovered:Vv},r=WN(),i=aP(),a=A(!1),o=A(!1),s=G(()=>t.server.config),c=G(()=>s.value.label&&s.value.label.length>0?s.value.label:t.server.id),l=G(()=>`${s.value.command} ${s.value.args.join(` `)}`.trim()),u=G(()=>zF(t.server.status,t.server.health)),d=G(()=>t.server.status===`running`),f=G(()=>s.value.enabled&&[`stopped`,`crashed`,`conflict`].includes(t.server.status)),p=G(()=>[`running`,`starting`,`backoff`].includes(t.server.status)),m=G(()=>t.server.startedAt===null||!d.value?`—`:oI(t.now-t.server.startedAt)),h=G(()=>t.server.nextRetryAt===null?null:sI(t.server.nextRetryAt,t.now)),g=G(()=>t.server.unhealthySince===null?null:oI(t.now-t.server.unhealthySince)),_=G(()=>t.series?.cpu??[]),v=G(()=>t.series?.rss??[]),y=G(()=>t.series?.probe??[]),b=G(()=>[...t.server.history.events].slice(-3).reverse()),x=G(()=>{let e=t.server,n=[{key:`pid`,label:`PID`,value:e.pid===null?`—`:String(e.pid)},{key:`uptime`,label:`Uptime`,value:m.value},{key:`restarts`,label:`Restarts`,value:`${e.restarts}/${e.maxRetries}`},{key:`port`,label:`Port`,value:e.portState},{key:`uptime24`,label:`24h up`,value:cI(e.history.uptimeRatio)},{key:`probe`,label:`Probe`,value:e.responseMs===null?`—`:`${e.responseMs} ms`},{key:`rss`,label:`RSS`,value:dI(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:lI(e.history.lastCrashAt,t.now)}),n});async function S(e){a.value=!0;try{await r[e](t.workspaceId,t.server.id)}finally{a.value=!1}}async function C(){a.value=!0;try{await r.freePort(t.workspaceId,t.server.id)}finally{a.value=!1}}async function w(e){let n=!(e===`enabled`?s.value.enabled:s.value.autostart);e===`enabled`?await r.setEnabled(t.workspaceId,t.server.id,n):await r.setAutostart(t.workspaceId,t.server.id,n)}async function T(){o.value=!1,await r.remove(t.workspaceId,t.server.id)}function ee(){i.select(t.workspaceId)}return(i,d)=>{let m=fa(`RouterLink`);return R(),z(`article`,{class:O(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`,!s.value.enabled&&`opacity-70`))},[V(`span`,{class:O(j(Q)(`absolute inset-y-3 left-0 w-0.5 rounded-full`,{"bg-ok":u.value===`ok`,"bg-warn":u.value===`warn`,"bg-danger":u.value===`danger`,"bg-faint/50":u.value===`neutral`,"bg-accent":u.value===`accent`||u.value===`info`}))},null,2),V(`header`,QR,[V(`div`,$R,[V(`div`,ez,[H(m,{to:`/servers/${e.server.id}`,class:`truncate text-sm font-semibold tracking-tight text-ink hover:text-accent`,onClick:ee},{default:M(()=>[U(k(c.value),1)]),_:1},8,[`to`]),e.server.url?(R(),z(`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}`},[H(j(Xv),{class:`size-3.5`})],8,tz)):W(``,!0)]),V(`p`,nz,[V(`span`,null,k(e.server.id),1),s.value.port===null?W(``,!0):(R(),z(L,{key:0},[d[9]||=V(`span`,{"aria-hidden":`true`},`·`,-1),V(`span`,rz,`:`+k(s.value.port),1)],64)),d[10]||=V(`span`,{"aria-hidden":`true`},`·`,-1),V(`span`,null,k(e.server.bindHost),1),s.value.enabled?W(``,!0):(R(),z(`span`,iz,`disabled`)),s.value.autostart?(R(),z(`span`,az,`autostart`)):W(``,!0)])]),H(XR,{status:e.server.status,health:e.server.health},null,8,[`status`,`health`]),e.server.adopted?(R(),B(ZR,{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(()=>[...d[11]||=[V(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`detached`,-1)]]),_:1})):W(``,!0),s.value.persistent?(R(),B(ZR,{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(()=>[...d[12]||=[V(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`persistent`,-1)]]),_:1})):W(``,!0)]),V(`p`,{class:`truncate px-4 pb-3 font-mono text-2xs text-muted`,title:l.value},k(l.value),9,oz),t.variant===`compact`?W(``,!0):(R(),z(`div`,sz,[V(`div`,cz,[H(KR,{label:`CPU`,values:_.value,format:j(fI),max:100,"color-class":`text-cpu`},null,8,[`values`,`format`]),H(KR,{label:`Memory`,values:v.value,format:j(dI),"color-class":`text-mem`},null,8,[`values`,`format`])]),H(KR,{label:`Health probe`,values:y.value,format:e=>e===null?`—`:`${e} ms`,height:22,"color-class":`text-probe`,"empty-hint":`not probed`},null,8,[`values`,`format`])])),b.value.length>0?(R(),z(`div`,lz,[(R(!0),z(L,null,F(b.value,e=>(R(),z(`span`,{key:`${e.ts}`,class:`inline-flex items-center gap-1 text-2xs`},[(R(),B(ma(n[e.type]),{class:O(j(Q)(`size-3`,j(IF)[j(VF)[e.type]]))},null,8,[`class`])),V(`span`,uz,k(j(BF)[e.type]),1),V(`span`,dz,k(j(lI)(e.ts,t.now)),1)]))),128))])):W(``,!0),e.server.lastError||g.value||h.value?(R(),z(`div`,fz,[e.server.lastError?(R(),z(`p`,pz,[H(j(Bv),{class:`mt-0.5 size-3 shrink-0`}),V(`span`,mz,k(e.server.lastError),1)])):W(``,!0),e.server.status===`conflict`&&s.value.port!==null?(R(),B(kR,{key:1,port:s.value.port,busy:a.value,class:`self-start`,onConfirm:C},null,8,[`port`,`busy`])):W(``,!0),g.value?(R(),z(`p`,hz,` Unhealthy for `+k(g.value),1)):W(``,!0),h.value?(R(),z(`p`,gz,` Next attempt `+k(h.value),1)):W(``,!0)])):W(``,!0),V(`dl`,_z,[(R(!0),z(L,null,F(x.value,e=>(R(),z(`div`,{key:e.key,class:`min-w-0`},[V(`dt`,vz,k(e.label),1),V(`dd`,yz,k(e.value),1)]))),128))]),V(`div`,bz,[H($,{variant:`primary`,size:`xs`,disabled:a.value||!f.value,onClick:d[0]||=e=>S(`start`)},{default:M(()=>[H(j(gy),{class:`size-3`}),d[13]||=U(`Start `,-1)]),_:1},8,[`disabled`]),H($,{size:`xs`,disabled:a.value||!p.value,onClick:d[1]||=e=>S(`stop`)},{default:M(()=>[H(j(Ay),{class:`size-3`}),d[14]||=U(`Stop `,-1)]),_:1},8,[`disabled`]),H($,{size:`xs`,disabled:a.value||!s.value.enabled,onClick:d[2]||=e=>S(`restart`)},{default:M(()=>[H(j(xy),{class:`size-3`}),d[15]||=U(`Restart `,-1)]),_:1},8,[`disabled`]),H(ZR,{label:`Live logs and full telemetry`},{default:M(()=>[H(m,{to:`/servers/${e.server.id}`,onClick:ee},{default:M(()=>[H($,{size:`xs`,variant:`ghost`},{default:M(()=>[H(j(Sy),{class:`size-3`}),d[16]||=U(`Details `,-1)]),_:1})]),_:1},8,[`to`])]),_:1}),H(j($h),null,{default:M(()=>[H(j(ig),{"as-child":``},{default:M(()=>[H($,{size:`icon-sm`,variant:`ghost`,class:`ml-auto`,"aria-label":`More actions for ${c.value}`},{default:M(()=>[H(j(Yv),{class:`size-4`})]),_:1},8,[`aria-label`])]),_:1}),H(j(ng),null,{default:M(()=>[H(j(eg),{"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(()=>[H(j(tg),{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:d[3]||=e=>w(`enabled`)},{default:M(()=>[H(j(vy),{class:`size-3.5`}),U(` `+k(s.value.enabled?`Disable server`:`Enable server`),1)]),_:1}),H(j(tg),{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:d[4]||=e=>w(`autostart`)},{default:M(()=>[H(j(gy),{class:`size-3.5`}),U(` `+k(s.value.autostart?`Remove from autostart`:`Autostart with the panel`),1)]),_:1}),H(j(tg),{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:d[5]||=t=>j(r).clearLogs(e.workspaceId,e.server.id)},{default:M(()=>[H(j(Sy),{class:`size-3.5`}),d[17]||=U(` Clear log buffer `,-1)]),_:1}),H(j(rg),{class:`my-1 h-px bg-line`}),H(j(tg),{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:d[6]||=e=>o.value=!0},{default:M(()=>[H(j(Fy),{class:`size-3.5`}),d[18]||=U(` Remove server `,-1)]),_:1})]),_:1})]),_:1})]),_:1})]),H(vR,{open:o.value,"onUpdate:open":d[8]||=e=>o.value=e,title:`Remove this server?`,description:`${c.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(()=>[H($,{variant:`ghost`,onClick:d[7]||=e=>o.value=!1},{default:M(()=>[...d[21]||=[U(` Keep it `,-1)]]),_:1}),H($,{variant:`danger`,onClick:T},{default:M(()=>[H(j(Fy),{class:`size-3.5`}),d[22]||=U(`Remove `,-1)]),_:1})]),default:M(()=>[V(`dl`,xz,[V(`div`,null,[d[19]||=V(`dt`,{class:`text-faint`},` id `,-1),V(`dd`,Sz,k(e.server.id),1)]),V(`div`,null,[d[20]||=V(`dt`,{class:`text-faint`},` status `,-1),V(`dd`,Cz,k(e.server.status),1)])])]),_:1},8,[`open`,`description`])],2)}}}),Tz={class:`flex flex-wrap items-start justify-between gap-3`},Ez={class:`min-w-0`},Dz={class:`flex flex-wrap items-center gap-x-3 gap-y-1.5`},Oz={class:`text-2xl font-semibold tracking-tight text-ink`},kz={key:1,class:`mt-1 max-w-2xl text-xs leading-relaxed text-muted`},Az={class:`flex shrink-0 flex-wrap items-center gap-2`},jz=P({__name:`PageHeader`,props:{title:{},description:{default:void 0},backTo:{default:void 0},backLabel:{default:`Back`}},setup(e){return(e,t)=>{let n=fa(`RouterLink`);return R(),z(`header`,Tz,[V(`div`,Ez,[e.$props.backTo?(R(),B(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(()=>[H(j(Iv),{class:`size-3`}),U(` `+k(e.$props.backLabel),1)]),_:1},8,[`to`])):W(``,!0),V(`div`,Dz,[V(`h1`,Oz,k(e.$props.title),1),I(e.$slots,`badges`)]),e.$props.description?(R(),z(`p`,kz,k(e.$props.description),1)):W(``,!0)]),V(`div`,Az,[I(e.$slots,`actions`)])])}}}),Mz={key:0,class:`mb-3 flex items-start justify-between gap-3`},Nz={class:`min-w-0`},Pz={class:`flex shrink-0 items-center gap-1.5`},Fz=P({__name:`Panel`,props:{padded:{type:Boolean,default:!0},class:{}},setup(e){return(e,t)=>(R(),z(`section`,{class:O(j(NF)(`rounded-panel border border-line bg-panel shadow-card`,e.$props.padded&&`p-4`,e.$props.class))},[e.$slots.header||e.$slots.actions?(R(),z(`header`,Mz,[V(`div`,Nz,[I(e.$slots,`header`)]),V(`div`,Pz,[I(e.$slots,`actions`)])])):W(``,!0),I(e.$slots,`default`)],2))}}),Iz=P({__name:`Skeleton`,props:{class:{default:`h-4 w-24`},rounded:{default:`rounded`}},setup(e){return(t,n)=>(R(),z(`span`,{class:O(j(Q)(`block animate-pulse bg-line-soft`,e.rounded,t.$props.class)),style:{"animation-duration":`1.4s`},"aria-hidden":`true`},null,2))}}),Lz={class:`min-w-0`},Rz={class:`truncate text-2xs font-medium text-faint`},zz={key:0,class:`mt-0.5 truncate text-2xs text-muted`},Bz=P({__name:`StatTile`,props:{label:{},value:{},hint:{default:void 0},tone:{default:`neutral`},mono:{type:Boolean,default:!0}},setup(e){return(e,t)=>(R(),z(`div`,Lz,[V(`p`,Rz,k(e.$props.label),1),V(`p`,{class:O(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(IF)[e.$props.tone]))},k(e.$props.value),3),e.$props.hint?(R(),z(`p`,zz,k(e.$props.hint),1)):W(``,!0)]))}}),Vz=A(null),Hz=A(`unknown`),Uz=null;async function Wz(){try{let e=await(await fetch(`/healthz`,{cache:`no-store`})).json();typeof e.uptimeMs==`number`&&(Vz.value=Date.now()-e.uptimeMs),Hz.value=e.status===`degraded`?`degraded`:`ok`}catch{Hz.value=`unknown`}}function Gz(){return Uz??=Wz().finally(()=>{Uz=null}),{startedAt:Vz,status:Hz,refresh:Wz}}var Kz={class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},qz={key:0,class:`grid grid-cols-2 gap-4 p-4 sm:grid-cols-3 lg:grid-cols-5`},Jz={key:1,class:`grid grid-cols-2 divide-line-soft sm:grid-cols-3 sm:divide-x lg:grid-cols-5`},Yz={class:`p-4`},Xz={class:`p-4`},Zz={class:`p-4`},Qz={class:`p-4`},$z={class:`p-4`},eB={key:0,class:`flex items-start gap-2.5 rounded-panel border border-danger/25 bg-danger-soft px-3.5 py-3`},tB={class:`min-w-0`},nB={class:`text-xs font-medium text-danger`},rB={class:`mt-0.5 flex flex-wrap gap-x-3 gap-y-1 text-2xs text-danger`},iB=[`onClick`],aB={class:`grid gap-4 lg:grid-cols-3`},oB={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},sB={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},cB={class:`flex flex-wrap items-center gap-x-3 gap-y-1.5`},lB={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},uB={class:`font-mono text-2xs font-normal text-faint`},dB={class:`text-2xs text-muted`},fB={class:`ml-auto flex items-center gap-1.5`},pB={key:0,class:`rounded-control border border-danger/25 bg-danger-soft px-3 py-2 text-2xs leading-4 text-danger`},mB={key:2,class:`grid gap-4 lg:grid-cols-2`},hB={class:`flex flex-wrap items-center gap-x-3 gap-y-1 text-2xs text-faint`},gB={class:`font-mono`},_B=P({__name:`GlobalOverviewView`,setup(e){let t=WN(),n=aP(),r=Gz(),i=Lg(),a=A(!1),o=A(``),s=G(()=>t.appState.value===null),c=G(()=>t.workspaces.value),l=G(()=>t.allServers.value.map(e=>e.server)),u=G(()=>l.value.filter(e=>e.status===`running`)),d=G(()=>l.value.filter(e=>e.status===`crashed`||e.status===`conflict`||e.health===`unhealthy`)),f=G(()=>t.host.value),p=G(()=>r.startedAt.value===null?`—`:oI(t.now.value-r.startedAt.value)),m=G(()=>f.value?.enabled?oI(f.value.uptimeMs):`—`);function h(e){o.value=e,a.value=!0}function g(e,t){n.select(e),i.push(NX(e,`servers`,t))}return ta(async()=>{await r.refresh()}),(e,_)=>(R(),z(`div`,Kz,[H(jz,{title:`Global Overview`,description:`Host vitals and every server from every workspace, grouped by where it lives.`}),H(Fz,{class:`p-0`},{default:M(()=>[s.value?(R(),z(`div`,qz,[(R(),z(L,null,F(5,e=>V(`div`,{key:e,class:`space-y-2`},[H(Iz,{class:`h-2.5 w-16`}),H(Iz,{class:`h-6 w-20`})])),64))])):(R(),z(`div`,Jz,[V(`div`,Yz,[H(Bz,{label:`Workspaces`,value:String(c.value.length),hint:`${l.value.length} servers in total`},null,8,[`value`,`hint`])]),V(`div`,Xz,[H(Bz,{label:`Running`,value:`${u.value.length}/${l.value.length}`,tone:`ok`,hint:`${l.value.length-u.value.length} not up`},null,8,[`value`,`hint`])]),V(`div`,Zz,[H(Bz,{label:`Needs attention`,value:String(d.value.length),tone:d.value.length>0?`danger`:`ok`,hint:d.value.length===0?`nothing is broken`:`crashed or unhealthy`},null,8,[`value`,`tone`,`hint`])]),V(`div`,Qz,[H(Bz,{label:`Panel uptime`,value:p.value,hint:j(r).status.value===`degraded`?`degraded`:`serving`},null,8,[`value`,`hint`])]),V(`div`,$z,[H(Bz,{label:`Host uptime`,value:m.value,hint:f.value?.enabled?`sampling on`:`sampling off`},null,8,[`value`,`hint`])])]))]),_:1}),d.value.length>0?(R(),z(`div`,eB,[H(j(Bv),{class:`mt-0.5 size-4 shrink-0 text-danger`}),V(`div`,tB,[V(`p`,nB,k(d.value.length)+` server`+k(d.value.length===1?``:`s`)+` need a look `,1),V(`p`,rB,[(R(!0),z(L,null,F(j(t).allServers.value.filter(e=>e.server.status===`crashed`||e.server.status===`conflict`||e.server.health===`unhealthy`),e=>(R(),z(`button`,{key:`${e.workspace.id}:${e.server.id}`,type:`button`,class:`font-mono underline decoration-danger/40 underline-offset-2 hover:decoration-danger`,onClick:t=>g(e.workspace.id,e.server.id)},k(e.workspace.label)+`/`+k(e.server.id),9,iB))),128))])])])):W(``,!0),V(`div`,aB,[H(Fz,{class:`lg:col-span-2`},{header:M(()=>[V(`h2`,oB,[H(j(qv),{class:`size-3.5 text-faint`}),_[1]||=U(` Host vitals `,-1)]),_[2]||=V(`p`,{class:`text-2xs text-muted`},` This machine, shared by every workspace. `,-1)]),default:M(()=>[H(AI,{host:f.value,now:j(t).now.value},null,8,[`host`,`now`])]),_:1}),H(Fz,null,{header:M(()=>[V(`h2`,sB,[H(j(Av),{class:`size-3.5 text-faint`}),_[3]||=U(` Recent activity `,-1)])]),default:M(()=>[H(RI,{servers:l.value,now:j(t).now.value,limit:12},null,8,[`servers`,`now`])]),_:1})]),!s.value&&l.value.length===0?(R(),B(rI,{key:1,title:`No servers anywhere yet`,description:`Pick a workspace in the header and add the first process it should keep alive.`},{icon:M(()=>[H(j(wy),{class:`size-4`})]),_:1})):W(``,!0),(R(!0),z(L,null,F(c.value,e=>(R(),z(`section`,{key:e.id,class:`space-y-3`},[V(`div`,cB,[V(`h2`,lB,[H(j(iy),{class:`size-3.5 text-faint`}),U(` `+k(e.label)+` `,1),V(`span`,uB,k(e.id),1)]),V(`span`,dB,k(e.runningCount)+`/`+k(e.serverCount)+` running`,1),V(`div`,fB,[H($,{size:`xs`,variant:`ghost`,onClick:t=>h(e.id)},{default:M(()=>[H(j(_y),{class:`size-3`}),_[4]||=U(`Add server `,-1)]),_:1},8,[`onClick`]),H($,{size:`xs`,variant:`ghost`,onClick:t=>{j(n).select(e.id),j(i).push(j(NX)(e.id,`overview`))}},{default:M(()=>[..._[5]||=[U(` Open workspace `,-1)]]),_:1},8,[`onClick`])])]),e.configError?(R(),z(`p`,pB,` The config could not be read: `+k(e.configError),1)):W(``,!0),e.servers.length===0?(R(),B(rI,{key:1,compact:``,title:`No servers in this workspace`,description:`Add one and it will show up here and on the workspace page.`},{action:M(()=>[H($,{size:`sm`,variant:`primary`,onClick:t=>h(e.id)},{default:M(()=>[H(j(_y),{class:`size-3.5`}),_[6]||=U(`Add a server `,-1)]),_:1},8,[`onClick`])]),_:2},1024)):(R(),z(`div`,mB,[(R(!0),z(L,null,F(e.servers,n=>(R(),B(wz,{key:n.id,server:n,"workspace-id":e.id,series:j(t).seriesOf(e.id,n.id),now:j(t).now.value},null,8,[`server`,`workspace-id`,`series`,`now`]))),128))]))]))),128)),V(`p`,hB,[_[7]||=V(`span`,null,`resource history is sampled every 5 s and kept for this session`,-1),V(`span`,gB,k(j(t).appState.value?.control.url),1)]),H(ER,{open:a.value,"onUpdate:open":_[0]||=e=>a.value=e,"workspace-id":o.value},null,8,[`open`,`workspace-id`])]))}}),vB=P({__name:`ConfirmButton`,props:{label:{},confirmLabel:{default:`Confirm`},variant:{default:`danger-ghost`},confirmVariant:{default:`danger`},size:{default:`sm`},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},emits:[`confirm`],setup(e,{emit:t}){let n=e,r=t,i=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 ze(o),(e,t)=>(R(),B($,{variant:i.value?n.confirmVariant:n.variant,size:n.size,disabled:n.disabled,loading:n.loading,onClick:s},{default:M(()=>[U(k(i.value?n.confirmLabel:n.label),1)]),_:1},8,[`variant`,`size`,`disabled`,`loading`]))}}),yB={class:`min-w-0 flex-1`},bB={key:0,class:`text-xs font-semibold`},xB=P({__name:`Notice`,props:{tone:{default:`info`},title:{default:void 0},class:{default:void 0}},setup(e){let t=e,n={ok:Vv,warn:Iy,danger:py,info:ny,neutral:ny,accent:Ey},r=G(()=>n[t.tone]);return(e,n)=>(R(),z(`div`,{class:O(j(Q)(`flex items-start gap-2 rounded-panel border px-3 py-2`,j(LF)[t.tone],t.class))},[(R(),B(ma(r.value),{class:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`})),V(`div`,yB,[t.title?(R(),z(`p`,bB,k(t.title),1)):W(``,!0),V(`div`,{class:O(j(Q)(`text-xs leading-relaxed text-ink/85`,t.title&&`mt-0.5`))},[I(e.$slots,`default`)],2)])],2))}}),SB={class:`space-y-2`},CB={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},wB=P({__name:`AuthenticationSection`,props:Ra({view:{},dirty:{type:Boolean}},{auth:{required:!0},authModifiers:{}}),emits:Ra([`reset`],[`update:auth`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`auth`),a=vL(()=>i.value.sessionTtlMs,e=>i.value.sessionTtlMs=e,6048e5),o=vL(()=>i.value.maxLoginAttempts,e=>i.value.maxLoginAttempts=e,5),s=vL(()=>i.value.lockoutMs,e=>i.value.lockoutMs=e,6e4),c=G(()=>n.view?.auth.passwordSet===!0),l=G(()=>n.view?.auth.apiTokenSet===!0),u=G(()=>n.view?.auth.blockedReason??null),d=G(()=>n.view?.auth.exposed===!0),f=G(()=>n.view?.auth.usingDefaultPassword===!0),p=G(()=>i.value.enabled&&!c.value),{setPassword:m,clearPassword:h}=oN(),g=A(``),_=A(``),v=A(``),y=A(null),b=A(null),x=A(!1),S=G(()=>v.value.length>0&&v.value!==_.value),C=G(()=>_.value.length>0&&_.value.length<8),w=G(()=>_.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)=>(R(),z(L,null,[H(IL,{title:`Access policy`,description:`Authentication applies whether the panel is on loopback or exposed to the network.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[10]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(oR,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Require a password`,hint:`Every request needs a signed-in session.`,class:`sm:col-span-2`},null,8,[`modelValue`]),H(qL,{modelValue:j(a),"onUpdate:modelValue":t[2]||=e=>mn(a)?a.value=e:null,label:`Session lifetime (ms)`,min:6e4,hint:`604800000 is one week.`},null,8,[`modelValue`]),H($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`]),H(oR,{modelValue:i.value.trustProxy,"onUpdate:modelValue":t[4]||=e=>i.value.trustProxy=e,label:`Behind a trusted reverse proxy`,hint:`Trust x-forwarded-* headers for the client address and protocol.`,class:`sm:col-span-2`},null,8,[`modelValue`]),H(qL,{modelValue:j(o),"onUpdate:modelValue":t[5]||=e=>mn(o)?o.value=e:null,label:`Max login attempts`,min:1,hint:`Failures before a temporary lockout.`},null,8,[`modelValue`]),H(qL,{modelValue:j(s),"onUpdate:modelValue":t[6]||=e=>mn(s)?s.value=e:null,label:`Lockout (ms)`,min:1e3},null,8,[`modelValue`])]),_:1}),V(`div`,SB,[H(xB,{tone:l.value?`info`:`neutral`,title:l.value?`An API token is set`:`No API token`},{default:M(()=>[l.value?(R(),z(L,{key:0},[t[11]||=U(` Scripts can call the API with `,-1),t[12]||=V(`code`,null,`Authorization: Bearer …`,-1),t[13]||=U(` instead of signing in. `,-1)],64)):(R(),z(L,{key:1},[t[14]||=U(` For shell scripts and agents, generate one with `,-1),t[15]||=V(`code`,null,`home-hosted set-token --generate`,-1),t[16]||=U(`. `,-1)],64))]),_:1},8,[`tone`,`title`]),f.value?(R(),B(xB,{key:0,tone:`warn`,title:`The default password is still in use`},{default:M(()=>[...t[17]||=[U(` Set your own password below. Binding beyond `,-1),V(`code`,null,`127.0.0.1`,-1),U(` stays refused until you do. `,-1)]]),_:1})):W(``,!0),u.value?(R(),B(xB,{key:1,tone:`danger`,title:`This listener is being refused`},{default:M(()=>[U(k(u.value),1)]),_:1})):p.value?(R(),B(xB,{key:2,tone:`warn`,title:`Authentication is on but no password is set`},{default:M(()=>[...t[18]||=[U(` Nothing is actually required yet, and binding beyond `,-1),V(`code`,null,`127.0.0.1`,-1),U(` stays refused until a password exists. `,-1)]]),_:1})):d.value?(R(),B(xB,{key:3,tone:`warn`,title:`Reachable beyond 127.0.0.1`},{default:M(()=>[...t[19]||=[U(` Keep the password strong, or put a TLS-terminating proxy in front of the panel. `,-1)]]),_:1})):W(``,!0)]),V(`form`,{class:`mt-3`,onSubmit:cu(T,[`prevent`])},[H(IL,{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?(R(),B(iR,{key:0,modelValue:g.value,"onUpdate:modelValue":t[7]||=e=>g.value=e,type:`password`,autocomplete:`current-password`,label:`Current password`},null,8,[`modelValue`])):W(``,!0),H(iR,{modelValue:_.value,"onUpdate:modelValue":t[8]||=e=>_.value=e,type:`password`,autocomplete:`new-password`,label:`New password`},null,8,[`modelValue`]),H(iR,{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`]),V(`div`,CB,[H($,{type:`submit`,variant:`primary`,disabled:!w.value,loading:x.value},{default:M(()=>[U(k(c.value?`Update password`:`Set password and enable auth`),1)]),_:1},8,[`disabled`,`loading`]),c.value?(R(),B(vB,{key:0,label:`Clear password`,"confirm-label":`Confirm clear`,"confirm-variant":`danger`,disabled:x.value,onConfirm:ee},null,8,[`disabled`])):W(``,!0)]),C.value||b.value||y.value?(R(),z(L,{key:1},[C.value?(R(),B(xB,{key:0,tone:`warn`,title:`That is a short password`,class:`sm:col-span-2`},{default:M(()=>[...t[20]||=[U(` It is allowed, but longer is the only thing standing between the network and this panel. `,-1)]]),_:1})):W(``,!0),b.value?(R(),B(xB,{key:1,tone:`danger`,class:`sm:col-span-2`},{default:M(()=>[U(k(b.value),1)]),_:1})):W(``,!0),y.value?(R(),B(xB,{key:2,tone:`ok`,class:`sm:col-span-2`},{default:M(()=>[U(k(y.value),1)]),_:1})):W(``,!0)],64)):W(``,!0)]),_:1},8,[`title`])],32)],64))}});function TB(e){return e.kind===`settings`?`Server defaults, log retention and notifications`:e.kind===`servers`?`Every entry in servers.config.json`:e.kind===`secrets`?`Telegram bot token and DDNS credentials`:e.path===void 0?e.note??`A declared data path`:e.origin===void 0?e.path:`${e.path} — from ${e.origin}`}function EB(e){return e.leaves.length>0&&e.leaves.every(e=>e.selected)}function DB(e){return e.note!==null&&e.note.length>0?e.note:e.kind===`settings`?`Listener, auth, host vitals and the backups policy`:e.kind===`secrets`?`Password hash and API token hash`:e.kind===`tls`?`The panel's own certificate pair`:`Its settings, servers, secrets and declared data paths`}function OB(e,t=[]){let n=new Map(t.map(e=>[e.id,e]));return e.map(e=>{let t=n.get(e.id);return{id:e.id,label:e.label,hint:DB(e),kind:e.kind,...e.workspaceId===void 0?{}:{workspaceId:e.workspaceId},selected:t?.selected??!0,leaves:e.items.map(e=>({id:e.id,label:e.label,hint:TB(e),kind:e.kind,selected:t?.leaves.find(t=>t.id===e.id)?.selected??!0}))}})}function kB(e){return e.kind===`workspace`?e.selected&&e.leaves.some(e=>e.selected):e.selected}function AB(e,t){for(let n of e){n.selected=t;for(let e of n.leaves)e.selected=t}}function jB(e){let t=e.filter(e=>kB(e));if(e.length>0&&t.length===e.length&&t.every(e=>e.kind!==`workspace`||EB(e)))return;let n=[];for(let e of t){if(e.kind!==`workspace`){n.push(e.id);continue}EB(e)?n.push(e.id):n.push(...e.leaves.filter(e=>e.selected).map(e=>e.id))}return n}function MB(e){let t=0,n=0;for(let r of e)kB(r)&&(n+=1,t+=r.kind===`workspace`?r.leaves.filter(e=>e.selected).length:1);return{entries:n,leaves:t}}var NB=[`disabled`],PB={class:`min-w-0`},FB={class:`text-ink`},IB=P({__name:`CheckField`,props:Ra({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=oo(e,`modelValue`);return(e,r)=>(R(),z(`label`,{class:O(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(V(`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,NB),[[Jl,n.value]]),V(`span`,PB,[V(`span`,FB,k(t.label),1),t.hint?(R(),z(`span`,{key:0,class:O([`mt-0.5 block`,[j(VL)]])},k(t.hint),3)):W(``,!0),I(e.$slots,`default`)])],2))}}),LB={class:`space-y-3`},RB={class:`flex items-center justify-between gap-2`},zB={class:`text-xs font-medium text-muted`},BB={class:`flex items-center gap-1.5`},VB={class:`max-h-80 space-y-1.5 overflow-auto`},HB={class:`flex items-start gap-2.5`},UB={class:`min-w-0 flex-1`},WB={key:0,class:`flex shrink-0 items-center gap-1.5 pt-0.5`},GB={class:`font-mono text-2xs text-faint`},KB={key:1,class:`shrink-0 rounded-control border border-line px-1.5 py-0.5 text-2xs text-faint`},qB={key:0,class:`mt-1 flex items-center gap-1 pl-6 text-2xs text-warn`},JB={class:`space-y-3`},YB={class:`flex items-center justify-between gap-2`},XB={class:`text-xs font-medium text-muted`},ZB={class:`flex items-center gap-1.5`},QB={class:`max-h-72 space-y-1 overflow-auto`},$B={key:0,class:`text-xs text-muted`},eV=P({__name:`BackupDialog`,props:Ra({state:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:Ra([`created`],[`update:open`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`open`),a=A(!1),o=A(null),s=A(``),c=A([]),l=A(!1),u=A(null),d=A({});function f(e){c.value=OB(n.state?.entries??[],e?c.value:[])}let p=G(()=>MB(c.value)),m=G(()=>c.value.find(e=>e.id===`global:settings`)?.selected??!1),h=G(()=>n.state!==null&&p.value.leaves>0&&!a.value),g=G(()=>u.value===null?0:u.value.leaves.filter(e=>d.value[e.id]===!0).length);N(i,e=>{e&&(s.value=``,o.value=null,f(!1))},{immediate:!0}),N(()=>n.state,()=>{i.value&&f(!0)});function _(e){u.value=e,d.value=Object.fromEntries(e.leaves.map(e=>[e.id,e.selected])),l.value=!0}function v(){let e=u.value;if(e!==null){for(let t of e.leaves)t.selected=d.value[t.id]===!0;e.leaves.some(e=>e.selected)&&(e.selected=!0),l.value=!1,u.value=null}}function y(e){let t=u.value;t!==null&&(d.value=Object.fromEntries(t.leaves.map(t=>[t.id,e])))}async function b(){if(h.value){a.value=!0,o.value=null;try{await _M(s.value,jB(c.value)),i.value=!1,r(`created`,`Backup created.`)}catch(e){o.value=e instanceof Error?e.message:String(e)}finally{a.value=!1}}}return(e,t)=>(R(),z(L,null,[H(vR,{open:i.value,"onUpdate:open":t[4]||=e=>i.value=e,title:`Create a backup`,description:`Pick what this archive captures. Nothing is written until you create it.`,width:`w-[min(92vw,40rem)]`},{footer:M(()=>[H($,{size:`sm`,variant:`ghost`,disabled:a.value,onClick:t[3]||=e=>i.value=!1},{default:M(()=>[...t[14]||=[U(` Cancel `,-1)]]),_:1},8,[`disabled`]),H($,{size:`sm`,variant:`primary`,disabled:!h.value,loading:a.value,onClick:b},{default:M(()=>[...t[15]||=[U(` Create backup `,-1)]]),_:1},8,[`disabled`,`loading`])]),default:M(()=>[V(`div`,LB,[V(`div`,RB,[V(`span`,zB,k(p.value.entries)+` entr`+k(p.value.entries===1?`y`:`ies`)+` · `+k(p.value.leaves)+` item`+k(p.value.leaves===1?``:`s`)+` selected `,1),V(`div`,BB,[H($,{size:`xs`,variant:`ghost`,disabled:a.value,onClick:t[0]||=e=>j(AB)(c.value,!0)},{default:M(()=>[...t[9]||=[U(` Select all `,-1)]]),_:1},8,[`disabled`]),H($,{size:`xs`,variant:`ghost`,disabled:a.value,onClick:t[1]||=e=>j(AB)(c.value,!1)},{default:M(()=>[...t[10]||=[U(` Select none `,-1)]]),_:1},8,[`disabled`])])]),V(`ul`,VB,[(R(!0),z(L,null,F(c.value,e=>(R(),z(`li`,{key:e.id,class:`rounded-control border border-line-soft bg-panel-2/30 px-2.5 py-2`},[V(`div`,HB,[V(`div`,UB,[H(IB,{modelValue:e.selected,"onUpdate:modelValue":t=>e.selected=t,label:e.label,hint:e.hint,disabled:a.value},null,8,[`modelValue`,`onUpdate:modelValue`,`label`,`hint`,`disabled`])]),e.kind===`workspace`?(R(),z(`div`,WB,[V(`span`,GB,k(e.leaves.filter(e=>e.selected).length)+`/`+k(e.leaves.length),1),H($,{size:`xs`,variant:`secondary`,disabled:a.value,onClick:t=>_(e)},{default:M(()=>[H(j(Nv),{class:`size-3`}),t[11]||=U(`Choose items `,-1)]),_:1},8,[`disabled`,`onClick`])])):(R(),z(`span`,KB,k(e.kind),1))]),e.kind===`workspace`&&e.selected&&!j(EB)(e)&&e.leaves.some(e=>e.selected)?(R(),z(`p`,qB,[H(j(iy),{class:`size-3`}),t[12]||=U(` Only the chosen items are captured. `,-1)])):W(``,!0)]))),128))]),m.value?W(``,!0):(R(),B(xB,{key:0,tone:`warn`},{default:M(()=>[...t[13]||=[U(` Without the global settings, a restore can only place a workspace where the target panel already declares it. `,-1)]]),_:1})),H(iR,{modelValue:s.value,"onUpdate:modelValue":t[2]||=e=>s.value=e,type:`password`,autocomplete:`new-password`,label:`Password (optional)`,hint:`Encrypts the archive; restoring it asks for the same password.`,wide:``},null,8,[`modelValue`]),o.value?(R(),B(xB,{key:1,tone:`danger`},{default:M(()=>[U(k(o.value),1)]),_:1})):W(``,!0)])]),_:1},8,[`open`]),H(vR,{open:l.value,"onUpdate:open":t[8]||=e=>l.value=e,title:u.value===null?`Choose items`:`${u.value.label} — choose items`,description:`A workspace can be captured whole or only its settings, servers, secrets and declared data paths.`,width:`w-[min(92vw,34rem)]`},{footer:M(()=>[H($,{size:`sm`,variant:`ghost`,onClick:t[7]||=e=>l.value=!1},{default:M(()=>[...t[18]||=[U(` Cancel `,-1)]]),_:1}),H($,{size:`sm`,variant:`primary`,onClick:v},{default:M(()=>[...t[19]||=[U(` Apply `,-1)]]),_:1})]),default:M(()=>[V(`div`,JB,[V(`div`,YB,[V(`span`,XB,k(g.value)+` of `+k(u.value?.leaves.length??0)+` selected`,1),V(`div`,ZB,[H($,{size:`xs`,variant:`ghost`,onClick:t[5]||=e=>y(!0)},{default:M(()=>[...t[16]||=[U(` Select all `,-1)]]),_:1}),H($,{size:`xs`,variant:`ghost`,onClick:t[6]||=e=>y(!1)},{default:M(()=>[...t[17]||=[U(` Select none `,-1)]]),_:1})])]),V(`ul`,QB,[(R(!0),z(L,null,F(u.value?.leaves??[],e=>(R(),z(`li`,{key:e.id,class:`rounded-control px-2 py-1.5 hover:bg-hover`},[H(IB,{"model-value":d.value[e.id]===!0,label:e.label,hint:e.hint,"onUpdate:modelValue":t=>d.value[e.id]=t===!0},null,8,[`model-value`,`label`,`hint`,`onUpdate:modelValue`])]))),128))]),u.value?.leaves.length===0?(R(),z(`p`,$B,` This workspace declares nothing selectable yet. `)):W(``,!0)])]),_:1},8,[`open`,`title`])],64))}}),tV={class:`space-y-3`},nV={key:0,class:`flex min-w-0 flex-col gap-1`},rV=[`disabled`],iV={key:0,class:`font-mono text-2xs text-muted`},aV={class:`mt-2`},oV={class:`mt-2 max-w-sm`},sV={class:`mt-2`},cV={class:`mt-2`},lV={class:`mt-1 max-h-64 space-y-0.5 overflow-auto`},uV={class:`mt-2 flex flex-wrap items-center gap-2`},dV={class:`mt-2`},fV=`__upload__`,pV=P({__name:`RestoreDialog`,props:Ra({files:{},initial:{default:null}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:Ra([`applied`],[`update:open`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`open`),a=A(!1),o=A(null),s=A(null),c=A(null),l=A(``),u=A({kind:`upload`}),d=A(fV),f=G(()=>s.value?.items.filter(e=>e.selected).length??0),p=G(()=>s.value?.items.some(e=>e.id===`global:settings`&&e.selected)??!1),m=G(()=>s.value?.needsPassword===!0),h=G(()=>s.value!==null&&!m.value&&f.value>0&&!a.value),g=G(()=>[...n.files.map(e=>({value:e.name,label:e.encrypted?`${e.name} — encrypted`:e.name})),{value:fV,label:`Upload a file…`}]),_=Q(HL,`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`);function v(e){return e instanceof Error?e.message:String(e)}function y(){return l.value.length>0?{password:l.value}:{}}async function b(){let e=u.value;if(e.kind===`upload`&&c.value===null){s.value=null;return}a.value=!0,o.value=null,s.value=null;try{s.value=e.kind===`stored`?await xM(e.name,!1,y()):await SM(c.value,!1,y())}catch(e){o.value=v(e)}finally{a.value=!1}}function x(e){d.value=e,c.value=null,u.value=e===fV?{kind:`upload`}:{kind:`stored`,name:e},b()}function S(e){c.value=e.target.files?.[0]??null,b()}function C(e){for(let t of s.value?.items??[])t.restorable&&(t.selected=e)}async function w(){let e=s.value,t=u.value;if(e===null||!h.value)return;a.value=!0,o.value=null;let n={...y(),include:e.items.filter(e=>e.restorable&&e.selected).map(e=>e.id)};try{let e=t.kind===`stored`?await xM(t.name,!0,n):await SM(c.value,!0,n);i.value=!1,s.value=null,c.value=null,l.value=``;let a=[];e.reloaded&&a.push(`the restored servers are live, autostart entries starting`),e.restartRequired&&a.push(`restart the panel to apply its own settings`),r(`applied`,`Restored ${e.applied.length} item(s)${a.length===0?``:` — ${a.join(`; `)}`}.`)}catch(e){o.value=v(e)}finally{a.value=!1}}return N(i,e=>{if(!e){s.value=null,c.value=null,l.value=``,o.value=null;return}let t=n.files[0];u.value=n.initial??(t===void 0?{kind:`upload`}:{kind:`stored`,name:t.name}),d.value=u.value.kind===`stored`?u.value.name:fV,b()},{immediate:!0}),(e,t)=>(R(),B(vR,{open:i.value,"onUpdate:open":t[4]||=e=>i.value=e,title:`Restore a backup`,description:`Nothing is written until the plan is applied.`,width:`w-[min(92vw,38rem)]`},{footer:M(()=>[H($,{size:`sm`,variant:`ghost`,disabled:a.value,onClick:t[3]||=e=>i.value=!1},{default:M(()=>[...t[10]||=[U(` Cancel `,-1)]]),_:1},8,[`disabled`]),s.value&&!m.value?(R(),B($,{key:0,size:`sm`,variant:`danger`,disabled:!h.value,loading:a.value,onClick:w},{default:M(()=>[U(k(u.value.kind===`stored`?`Apply this restore`:`Restore the upload`),1)]),_:1},8,[`disabled`,`loading`])):W(``,!0)]),default:M(()=>[V(`div`,tV,[H($L,{"model-value":d.value,label:`Archive`,hint:`A stored archive, or a .zip from this machine.`,options:g.value,disabled:a.value,wide:``,"onUpdate:modelValue":x},null,8,[`model-value`,`options`,`disabled`]),u.value.kind===`upload`?(R(),z(`div`,nV,[V(`label`,{class:O(j(BL)),for:`restore-upload`},`Archive file (.zip)`,2),V(`input`,{id:`restore-upload`,type:`file`,accept:`.zip,application/zip`,class:O(j(_)),disabled:a.value,onChange:S},null,42,rV),c.value?(R(),z(`p`,iV,k(c.value.name),1)):W(``,!0)])):W(``,!0),a.value?(R(),B(Iz,{key:1,class:`h-20 w-full`})):s.value?(R(),B(xB,{key:2,tone:`warn`,title:`Nothing has changed yet`},{default:M(()=>[V(`p`,null,[u.value.kind===`stored`?(R(),z(L,{key:0},[t[5]||=U(` Archive `,-1),V(`code`,null,k(u.value.name),1),t[6]||=U(`. `,-1)],64)):(R(),z(L,{key:1},[U(` The uploaded archive. `)],64))]),s.value.needsPassword?(R(),z(L,{key:0},[V(`p`,aV,k(s.value.error??`This backup is password-protected.`),1),V(`div`,oV,[H(iR,{modelValue:l.value,"onUpdate:modelValue":t[0]||=e=>l.value=e,type:`password`,autocomplete:`off`,label:`Password`},null,8,[`modelValue`])]),V(`div`,sV,[H($,{size:`sm`,variant:`secondary`,disabled:a.value,onClick:b},{default:M(()=>[...t[7]||=[U(` Check again with the password `,-1)]]),_:1},8,[`disabled`])])],64)):(R(),z(L,{key:1},[V(`p`,cV,` Choose what to restore — `+k(f.value)+` of `+k(s.value.items.length)+` selected. `,1),V(`ul`,lV,[(R(!0),z(L,null,F(s.value.items,e=>(R(),z(`li`,{key:e.id},[H(IB,{modelValue:e.selected,"onUpdate:modelValue":t=>e.selected=t,label:e.label,hint:[e.kind,e.workspaceId,e.note].filter(Boolean).join(` · `),disabled:!e.restorable||a.value},null,8,[`modelValue`,`onUpdate:modelValue`,`label`,`hint`,`disabled`])]))),128))]),V(`div`,uV,[H($,{size:`xs`,variant:`ghost`,disabled:a.value,onClick:t[1]||=e=>C(!0)},{default:M(()=>[...t[8]||=[U(` Select all `,-1)]]),_:1},8,[`disabled`]),H($,{size:`xs`,variant:`ghost`,disabled:a.value,onClick:t[2]||=e=>C(!1)},{default:M(()=>[...t[9]||=[U(` Select none `,-1)]]),_:1},8,[`disabled`])]),V(`p`,dV,[U(` Will restore: `+k(s.value.applied.join(`, `)||`nothing`)+`. `,1),s.value.skipped.length?(R(),z(L,{key:0},[U(` Skipped: `+k(s.value.skipped.join(`, `))+`. `,1)],64)):W(``,!0),s.value.restartRequired?(R(),z(L,{key:1},[U(` The panel's own settings differ, so restart the panel afterwards. `)],64)):p.value?(R(),z(L,{key:2},[U(` Restored workspaces are reloaded immediately; entries marked autostart start on their own. `)],64)):W(``,!0)])],64))]),_:1})):W(``,!0),o.value?(R(),B(xB,{key:3,tone:`danger`},{default:M(()=>[U(k(o.value),1)]),_:1})):W(``,!0)])]),_:1},8,[`open`]))}}),mV=[`aria-label`],hV=P({__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 ze(()=>{r&&clearTimeout(r)}),(e,r)=>(R(),z(`button`,{type:`button`,class:O(j(Q)(`inline-grid size-6 shrink-0 place-items-center rounded-control text-faint transition-colors duration-150 hover:bg-hover hover:text-ink`,j(zL),t.class)),"aria-label":n.value?`Copied`:t.label,onClick:i},[n.value?(R(),B(j(Pv),{key:0,class:`size-3.5 text-ok`})):(R(),B(j(Kv),{key:1,class:`size-3.5`}))],10,mV))}}),gV={key:0,class:`size-1.5 shrink-0 rounded-full bg-current`},_V=P({__name:`ToneBadge`,props:{tone:{default:`neutral`},dot:{type:Boolean,default:!1},mono:{type:Boolean,default:!1},plain:{type:Boolean,default:!1}},setup(e){let t=e,n=G(()=>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`,LF[t.tone].split(` `).filter(e=>e.startsWith(`text-`)).join(` `)):LF[t.tone],t.mono&&`font-mono`));return(e,r)=>(R(),z(`span`,{class:O(n.value)},[t.dot?(R(),z(`span`,gV)):W(``,!0),I(e.$slots,`default`)],2))}}),vV={class:`space-y-3`},yV={key:0,class:`sm:col-span-2`},bV={key:1,class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},xV={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},SV={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},CV={class:`text-2xs leading-4 text-faint`},wV={key:0,class:`space-y-2 sm:col-span-2`},TV={key:1,class:`text-xs text-muted sm:col-span-2`},EV={key:2,class:`divide-y divide-line-soft sm:col-span-2`},DV={class:`flex items-center gap-2`},OV={class:`min-w-0 flex-1 truncate text-xs font-medium text-ink`},kV={key:0,class:`font-mono text-2xs text-faint`},AV={key:0,class:`mt-0.5 text-2xs leading-4 text-muted`},jV={key:1,class:`mt-1 space-y-1`},MV={class:`min-w-0`},NV={class:`truncate font-mono text-2xs text-ink`},PV={class:`mt-0.5 text-2xs leading-4 text-faint`},FV={key:3,class:`text-2xs leading-4 text-faint sm:col-span-2`},IV={key:0,class:`space-y-2 sm:col-span-2`},LV={key:1,class:`sm:col-span-2`},RV={key:2,class:`divide-y divide-line-soft sm:col-span-2`},zV={class:`min-w-0 flex-1`},BV={class:`flex items-center gap-2`},VV={class:`truncate font-mono text-xs text-ink`},HV={class:`mt-0.5 font-mono text-2xs tabular-nums text-muted`},UV={class:`flex items-center gap-1.5`},WV=[`href`],GV={key:3,class:`space-y-2 sm:col-span-2`},KV=P({__name:`BackupsSection`,props:Ra({state:{},policy:{},configPath:{},workspaces:{},dirty:{type:Boolean}},{form:{required:!0},formModifiers:{}}),emits:Ra([`reset`],[`update:form`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`form`),a=WN(),o=vL(()=>i.value.keep,e=>i.value.keep=e,5),s=A(!1),c=A(null),l=A(null),u=A(!1),d=A(!1),f=A(null),p=G(()=>n.state?.files??[]),m=G(()=>n.state?.entries??[]),h={settings:`settings`,servers:`servers`,secrets:`secrets`,tls:`tls`,data:`data`},g=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`,zL);function _(e){f.value=e===void 0?null:{kind:`stored`,name:e},d.value=!0}function v(e){l.value=null,c.value=e,a.refresh()}function y(e){l.value=null,c.value=e,a.refresh()}async function b(e){s.value=!0,l.value=null,c.value=null;try{await vM(e),c.value=`Deleted ${e}.`,await a.refresh()}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{s.value=!1}}return(e,t)=>(R(),z(`div`,vV,[H(IL,{title:`Policy`,description:`How many archives the panel keeps, and the extra paths every one of them captures.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[9]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(oR,{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?W(``,!0):(R(),z(`div`,yV,[H(xB,{tone:`warn`,title:`Backups are off`},{default:M(()=>[...t[10]||=[U(` Nothing new is archived until this is back on. The archives below can still be downloaded, restored and deleted. `,-1)]]),_:1})])),H(qL,{modelValue:j(o),"onUpdate:modelValue":t[2]||=e=>mn(o)?o.value=e:null,label:`Keep`,min:1,hint:`Older archives are pruned after each backup.`},null,8,[`modelValue`]),H(iR,{modelValue:i.value.includePaths,"onUpdate:modelValue":t[3]||=e=>i.value.includePaths=e,label:`Extra paths`,hint:`Comma separated, captured in every archive on top of what each workspace declares.`,placeholder:`{home}/myapp-data`},null,8,[`modelValue`]),n.policy===null?W(``,!0):(R(),z(`div`,bV,[t[13]||=V(`span`,{class:`text-xs font-medium text-muted`},`Archive directory`,-1),V(`div`,xV,[V(`span`,SV,k(n.policy.dir),1),H(hV,{value:n.policy.dir,label:`Copy the archive directory`},null,8,[`value`])]),V(`p`,CV,[t[11]||=U(` Changing it is a file-level decision: edit `,-1),V(`code`,null,k(n.configPath??`the settings file`),1),t[12]||=U(`. `,-1)])]))]),_:1}),H(IL,{title:`What a backup captures`,description:`Pick these in the create dialog. A workspace can be taken whole or only its settings, servers, secrets and declared data paths.`},{default:M(()=>[n.state===null?(R(),z(`div`,wV,[H(Iz,{class:`h-4 w-full`}),H(Iz,{class:`h-4 w-2/3`})])):m.value.length===0?(R(),z(`p`,TV,` Nothing is selectable yet. `)):(R(),z(`ul`,EV,[(R(!0),z(L,null,F(m.value,e=>(R(),z(`li`,{key:e.id,class:`py-2 first:pt-0`},[V(`div`,DV,[V(`p`,OV,k(e.label),1),H(_V,{tone:`neutral`,plain:``},{default:M(()=>[U(k(h[e.kind]??e.kind),1)]),_:2},1024),e.workspaceId?(R(),z(`span`,kV,k(e.workspaceId),1)):W(``,!0)]),e.note?(R(),z(`p`,AV,k(e.note),1)):W(``,!0),e.items.length>0?(R(),z(`ul`,jV,[(R(!0),z(L,null,F(e.items,e=>(R(),z(`li`,{key:e.id,class:`flex items-start justify-between gap-3 rounded-control bg-panel-2/40 px-2 py-1`},[V(`div`,MV,[V(`p`,NV,k(e.path??e.label),1),V(`p`,PV,[U(k(e.included?e.origin?`from ${e.origin}`:e.note??`included`:e.note??`not captured`)+` `,1),e.included&&e.ignoreGenerated?(R(),z(L,{key:0},[U(` · generated directories skipped `)],64)):W(``,!0)])]),H(_V,{tone:e.included?`ok`:`neutral`,plain:``},{default:M(()=>[U(k(e.included?`included`:`skipped`),1)]),_:2},1032,[`tone`])]))),128))])):W(``,!0)]))),128))])),n.workspaces.length>1?(R(),z(`p`,FV,` This panel serves `+k(n.workspaces.length)+` workspaces; each is its own selectable entry. `,1)):W(``,!0)]),_:1}),H(IL,{title:`Archives`,description:`Stored in the backup directory and downloadable at any time.`},{actions:M(()=>[i.value.enabled?(R(),B($,{key:0,size:`xs`,variant:`primary`,disabled:n.state===null,onClick:t[4]||=e=>u.value=!0},{default:M(()=>[...t[14]||=[U(` Create backup… `,-1)]]),_:1},8,[`disabled`])):W(``,!0),H($,{size:`xs`,variant:`secondary`,disabled:n.state===null,onClick:t[5]||=e=>_()},{default:M(()=>[...t[15]||=[U(` Restore… `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[n.state===null?(R(),z(`div`,IV,[H(Iz,{class:`h-4 w-full`}),H(Iz,{class:`h-4 w-2/3`})])):p.value.length===0?(R(),z(`div`,LV,[H(rI,{compact:``,title:`No archives yet`,description:i.value.enabled?`Create one now to capture the panel and whichever workspaces you pick.`:`Nothing has been archived yet, and backups are off.`},va({icon:M(()=>[H(j(jv),{class:`size-4`})]),_:2},[i.value.enabled?{name:`action`,fn:M(()=>[H($,{size:`sm`,variant:`primary`,onClick:t[6]||=e=>u.value=!0},{default:M(()=>[...t[16]||=[U(` Create backup… `,-1)]]),_:1})]),key:`0`}:void 0]),1032,[`description`])])):(R(),z(`ul`,RV,[(R(!0),z(L,null,F(p.value,e=>(R(),z(`li`,{key:e.name,class:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 first:pt-0 last:pb-0`},[V(`div`,zV,[V(`div`,BV,[V(`span`,VV,k(e.name),1),e.encrypted?(R(),B(_V,{key:0,tone:`warn`,plain:``},{default:M(()=>[...t[17]||=[U(` encrypted `,-1)]]),_:1})):W(``,!0)]),V(`p`,HV,k(j(uI)(e.sizeBytes))+` · `+k(j(aI)(e.createdAt)),1)]),V(`div`,UV,[V(`a`,{href:yM(e.name),class:O(j(g))},[H(j(Jv),{class:`size-3`,"aria-hidden":`true`}),t[18]||=U(` Download `,-1)],10,WV),H($,{size:`xs`,variant:`secondary`,onClick:t=>_(e.name)},{default:M(()=>[H(j(by),{class:`size-3`,"aria-hidden":`true`}),t[19]||=U(` Restore `,-1)]),_:1},8,[`onClick`]),H(vB,{label:`Delete`,"confirm-label":`Confirm delete`,size:`xs`,variant:`ghost`,"confirm-variant":`danger`,disabled:s.value,onConfirm:t=>b(e.name)},null,8,[`disabled`,`onConfirm`])])]))),128))])),l.value||c.value?(R(),z(`div`,GV,[l.value?(R(),B(xB,{key:0,tone:`danger`},{default:M(()=>[U(k(l.value),1)]),_:1})):W(``,!0),c.value?(R(),B(xB,{key:1,tone:`ok`},{default:M(()=>[U(k(c.value),1)]),_:1})):W(``,!0)])):W(``,!0)]),_:1}),H(eV,{open:u.value,"onUpdate:open":t[7]||=e=>u.value=e,state:n.state,onCreated:v},null,8,[`open`,`state`]),H(pV,{open:d.value,"onUpdate:open":t[8]||=e=>d.value=e,files:p.value,initial:f.value,onApplied:y},null,8,[`open`,`files`,`initial`])]))}}),qV={key:0,class:`mt-3 flex flex-wrap items-center gap-1.5`},JV={key:1,class:`mt-3 text-xs text-muted`},YV=P({__name:`HostSection`,props:Ra({config:{},alerts:{},dirty:{type:Boolean}},{host:{required:!0},hostModifiers:{}}),emits:Ra([`reset`],[`update:host`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`host`),a=vL(()=>i.value.intervalMs,e=>i.value.intervalMs=e,15e3),o=vL(()=>i.value.diskUsedPercent,e=>i.value.diskUsedPercent=e,90),s=vL(()=>i.value.memoryUsedPercent,e=>i.value.memoryUsedPercent=e,90),c=vL(()=>i.value.swapUsedPercent,e=>i.value.swapUsedPercent=e,50),l=vL(()=>i.value.loadPerCpu,e=>i.value.loadPerCpu=e,2),u=vL(()=>i.value.tempCelsius,e=>i.value.tempCelsius=e,85);return(e,t)=>(R(),z(L,null,[H(IL,{title:`Thresholds`,description:`A threshold of 0 disables that alert. Breaches notify once, and once more on recovery.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[9]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(oR,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Sample this machine`,hint:`Load, memory, swap, disk and CPU temperature, on the interval below.`,wide:``},null,8,[`modelValue`]),H(qL,{modelValue:j(a),"onUpdate:modelValue":t[2]||=e=>mn(a)?a.value=e:null,label:`Interval (ms)`,min:5e3,hint:`How often the host is sampled and alerts are checked.`},null,8,[`modelValue`]),H(iR,{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`]),H(qL,{modelValue:j(o),"onUpdate:modelValue":t[4]||=e=>mn(o)?o.value=e:null,label:`Disk used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),H(qL,{modelValue:j(s),"onUpdate:modelValue":t[5]||=e=>mn(s)?s.value=e:null,label:`Memory used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),H(qL,{modelValue:j(c),"onUpdate:modelValue":t[6]||=e=>mn(c)?c.value=e:null,label:`Swap used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),H(qL,{modelValue:j(l),"onUpdate:modelValue":t[7]||=e=>mn(l)?l.value=e:null,label:`Load per CPU`,min:0,hint:`1-minute load average divided by the core count.`},null,8,[`modelValue`]),H(qL,{modelValue:j(u),"onUpdate:modelValue":t[8]||=e=>mn(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?(R(),z(`div`,qV,[t[10]||=V(`span`,{class:`text-xs text-muted`},`Breaching now:`,-1),(R(!0),z(L,null,F(n.alerts,e=>(R(),B(_V,{key:e,tone:`danger`,dot:``},{default:M(()=>[U(k(e),1)]),_:2},1024))),128))])):i.value.enabled?(R(),z(`p`,JV,` Nothing is breaching right now. `)):W(``,!0)],64))}}),XV={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},ZV={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},QV={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},$V={class:`text-2xs leading-4 text-faint`},eH={key:0},tH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},nH={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},rH={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},iH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},aH=[`disabled`],oH=P({__name:`InterfaceSection`,props:Ra({ui:{},panelVersion:{},labelDirty:{type:Boolean}},{label:{required:!0},labelModifiers:{}}),emits:Ra([`changed`,`resetLabel`],[`update:label`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`label`),a=A(null),o=A(!1),s=A(null),c=A(null),l=A(!1),u=G(()=>{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??`unnamed`}${t.version==null?``:` ${t.version}`}`}),d=G(()=>{let e=n.ui?.meta;if(e==null)return null;let t=e.uploadedAt===void 0?null:new Date(e.uploadedAt).toLocaleString();return`${e.files??0} files${t===null?``:` · ${t}`}`});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 NM(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 PM();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)=>(R(),B(IL,{title:`Interface`,description:`The panel is a static site: keep the stock one, or serve your own build from the state directory.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.labelDirty,onClick:h[1]||=e=>r(`resetLabel`)},{default:M(()=>[...h[6]||=[U(` Reset name `,-1)]]),_:1},8,[`disabled`]),e.ui?.custom?(R(),B($,{key:0,size:`xs`,variant:`ghost`,disabled:o.value,onClick:m},{default:M(()=>[U(k(l.value?`Confirm revert`:`Revert to stock`),1)]),_:1},8,[`disabled`])):W(``,!0),H($,{size:`xs`,variant:`primary`,disabled:o.value||a.value===null,onClick:p},{default:M(()=>[...h[7]||=[U(` Install UI `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[V(`div`,XV,[h[2]||=V(`span`,{class:`text-xs font-medium text-muted`},`Currently serving`,-1),V(`div`,ZV,[V(`span`,QV,k(u.value),1),H(hV,{value:e.ui?.dir??``,label:`Copy the UI directory`},null,8,[`value`])]),V(`p`,$V,[d.value?(R(),z(`span`,eH,k(d.value)+` · `,1)):W(``,!0),V(`code`,null,k(e.ui?.dir??`—`),1)])]),V(`div`,tH,[h[3]||=V(`span`,{class:`text-xs font-medium text-muted`},`Panel version`,-1),V(`div`,nH,[V(`span`,rH,`home-hosted `+k(n.panelVersion??`unknown`),1),n.panelVersion?(R(),B(hV,{key:0,value:n.panelVersion,label:`Copy the panel version`},null,8,[`value`])):W(``,!0)]),h[4]||=V(`p`,{class:`text-2xs leading-4 text-faint`},[U(` The release this panel process is running — `),V(`code`,null,`home-hosted status`),U(` prints the same number. `)],-1)]),H(iR,{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`]),V(`label`,iH,[h[5]||=V(`span`,{class:`text-xs font-medium text-muted`},`Upload a UI build (.zip with an index.html)`,-1),V(`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,aH)]),c.value?(R(),B(xB,{key:0,tone:`warn`,title:c.value},null,8,[`title`])):s.value?(R(),B(xB,{key:1,tone:`ok`,title:s.value},null,8,[`title`])):W(``,!0),h[8]||=V(`p`,{class:`text-2xs leading-4 text-faint sm:col-span-2`},[U(` See `),V(`code`,null,`docs/UI_CREATION.md`),U(` for the API contract. If a custom UI breaks the panel, `),V(`code`,null,`home-hosted ui-revert`),U(` puts the stock one back from the terminal. `)],-1)]),_:1}))}}),sH={class:`inline-flex items-center gap-0.5 rounded-control border border-line bg-panel-2 p-0.5`},cH=[`aria-pressed`,`onClick`],lH=P({__name:`SegmentedControl`,props:Ra({options:{},size:{default:`sm`}},{modelValue:{default:``},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=oo(e,`modelValue`);return(e,r)=>(R(),z(`div`,sH,[(R(!0),z(L,null,F(t.options,e=>(R(),z(`button`,{key:e.value,type:`button`,class:O(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},k(e.label),11,cH))),128))]))}}),uH={class:`flex min-w-0 flex-col gap-1`},dH={class:`text-2xs leading-4 text-faint`},fH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},pH={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},mH={class:`min-w-0 flex-1 truncate font-mono text-xs tabular-nums text-ink`},hH=P({__name:`ListenerSection`,props:Ra({view:{},dirty:{type:Boolean}},{control:{required:!0},controlModifiers:{}}),emits:Ra([`reset`],[`update:control`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`control`),a=vL(()=>i.value.port,e=>i.value.port=e,3999),o=[`local`,`lan`],s=G({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`&&Qk(t)!==null;i.value.host=r?t:`127.0.0.1`}}),c=G(()=>{if(s.value===`custom`&&Qk(i.value.host)===null)return`Enter an IPv4 address, for example 192.168.1.20.`}),l=G(()=>n.view?.url??`—`);return(e,t)=>(R(),B(IL,{title:`Listener`,description:`Where the panel answers. Moving this restarts the panel and sends this page to the new address.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[5]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(qL,{modelValue:j(a),"onUpdate:modelValue":t[1]||=e=>mn(a)?a.value=e:null,label:`Control port`,min:1,max:65535,hint:`Default 3999.`},null,8,[`modelValue`]),V(`div`,uH,[t[6]||=V(`span`,{class:`text-xs font-medium text-muted`},`Bind`,-1),H(lH,{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`]),V(`p`,dH,k(s.value===`lan`?`0.0.0.0 — reachable from the whole network.`:s.value===`local`?`127.0.0.1 — this machine only.`:`A specific interface address you type in below.`),1)]),s.value===`custom`?(R(),B(iR,{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`])):W(``,!0),H(oR,{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`]),V(`div`,fH,[t[8]||=V(`span`,{class:`text-xs font-medium text-muted`},`Live address`,-1),V(`div`,pH,[V(`span`,mH,k(l.value),1),n.view?.restartRequired?(R(),B(_V,{key:0,tone:`warn`,dot:``},{default:M(()=>[...t[7]||=[U(` restart required `,-1)]]),_:1})):W(``,!0),H(hV,{value:l.value,label:`Copy the live address`},null,8,[`value`])]),t[9]||=V(`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}))}}),gH={class:`space-y-3`},_H={class:`divide-y divide-line-soft sm:col-span-2`},vH={class:`min-w-0`},yH={class:`text-xs font-medium text-ink`},bH={class:`mt-0.5 text-2xs leading-4 text-faint`},xH={class:`flex min-w-0 flex-1 items-center justify-end gap-1.5`},SH={class:`min-w-0 truncate font-mono text-xs text-ink`},CH={class:`flex items-center gap-2 text-xs font-medium text-ink`},wH={class:`font-mono text-2xs font-normal text-faint`},TH={class:`divide-y divide-line-soft`},EH={class:`min-w-0`},DH={class:`text-2xs font-medium text-ink`},OH={class:`mt-0.5 text-2xs leading-4 text-faint`},kH={class:`flex min-w-0 flex-1 items-center justify-end gap-1.5`},AH={class:`min-w-0 truncate font-mono text-2xs text-ink`},jH=P({__name:`PathsSection`,props:{dataRoot:{},projectDir:{},panelUrl:{},workspaces:{}},setup(e){let t=e,n=G(()=>t.dataRoot===null?null:`${t.dataRoot}/settings.json`),r=G(()=>[{key:`data`,label:`Data root`,hint:`HHOSTED_HOME — global settings, workspaces, TLS, backups and the UI.`,value:t.dataRoot??`—`},{key:`settings`,label:`Global settings`,hint:`settings.json — listener, auth, TLS policy, host vitals, backups.`,value:n.value??`—`},{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??`—`}]);function i(e){return[{key:`${e.id}:config`,label:`Servers config`,hint:`${e.label}'s servers.config.json.`,value:e.configPath},{key:`${e.id}:settings`,label:`Workspace settings`,hint:`Server defaults, log retention, notifications, DDNS.`,value:e.settingsPath},{key:`${e.id}:logs`,label:`Logs`,hint:`Persisted output for this workspace.`,value:e.logsDir}]}return(t,n)=>(R(),z(`div`,gH,[H(IL,{title:`Where things live`,description:`Read-only. Copy a path straight into a shell or an editor.`},{default:M(()=>[V(`ul`,_H,[(R(!0),z(L,null,F(r.value,e=>(R(),z(`li`,{key:e.key,class:`flex items-start justify-between gap-3 py-2 first:pt-0 last:pb-0`},[V(`div`,vH,[V(`p`,yH,k(e.label),1),V(`p`,bH,k(e.hint),1)]),V(`div`,xH,[V(`span`,SH,k(e.value),1),H(hV,{value:e.value,label:`Copy ${e.label.toLowerCase()}`},null,8,[`value`,`label`])])]))),128))])]),_:1}),H(IL,{title:`Workspace files`,description:`Each workspace owns its config, settings and log directory; nothing is shared between them.`},{default:M(()=>[(R(!0),z(L,null,F(e.workspaces,e=>(R(),z(`div`,{key:e.id,class:`space-y-2 sm:col-span-2`},[V(`p`,CH,[U(k(e.label)+` `,1),V(`span`,wH,k(e.id),1)]),V(`ul`,TH,[(R(!0),z(L,null,F(i(e),e=>(R(),z(`li`,{key:e.key,class:`flex items-start justify-between gap-3 py-1.5`},[V(`div`,EH,[V(`p`,DH,k(e.label),1),V(`p`,OH,k(e.hint),1)]),V(`div`,kH,[V(`span`,AH,k(e.value),1),H(hV,{value:e.value,label:`Copy ${e.label.toLowerCase()}`},null,8,[`value`,`label`])])]))),128))])]))),128))]),_:1})]))}}),MH={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={key:0,class:`sm:col-span-2`},IH={key:1,class:`space-y-3 sm:col-span-2`},LH={class:`divide-y divide-line-soft text-xs`},RH={class:`flex items-start justify-between gap-4 py-1.5`},zH={class:`min-w-0 text-right font-mono text-xs text-ink`},BH={class:`flex items-start justify-between gap-4 py-1.5`},VH={class:`min-w-0 text-right font-mono text-xs text-ink`},HH={class:`flex items-start justify-between gap-4 py-1.5`},UH={class:`font-mono text-xs tabular-nums text-ink`},WH={class:`flex items-center justify-between gap-4 py-1.5`},GH={class:`flex items-start justify-between gap-4 py-1.5`},KH={class:`flex min-w-0 items-center gap-1.5`},qH={class:`min-w-0 truncate font-mono text-2xs text-ink`},JH={key:2,class:`sm:col-span-2`},YH={class:`flex min-w-0 flex-col gap-1`},XH={class:`flex min-w-0 flex-col gap-1`},ZH={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},QH={key:3,class:`space-y-2 sm:col-span-2`},$H=P({__name:`TlsSection`,props:Ra({view:{},dirty:{type:Boolean}},{tlsEnabled:{type:Boolean,required:!0},tlsEnabledModifiers:{}}),emits:Ra([`reset`],[`update:tlsEnabled`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`tlsEnabled`),a=WN(),o=A(``),s=A(``),c=A(null),l=A(null),u=A(!1),d=G(()=>n.view?.tls??null),f=G(()=>n.view?`${n.view.protocol}://${n.view.bindHost}:${n.view.port}`:`—`),p=G(()=>o.value.trim().length>0&&s.value.trim().length>0&&!u.value),m=Q(HL,`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 FM(o.value,s.value);o.value=``,s.value=``,c.value=`Certificate stored.`,await a.refresh();let t=await yL(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 IM();c.value=`Certificate removed.`,await a.refresh();let t=await yL(e);t!==null&&(l.value=t)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}return(e,t)=>(R(),z(L,null,[H(IL,{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(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[6]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(oR,{modelValue:i.value,"onUpdate:modelValue":t[1]||=e=>i.value=e,label:`Serve the panel over HTTPS`,hint:`Saved with Save settings; the panel rebinds and this page follows it.`,class:`sm:col-span-2`},null,8,[`modelValue`]),V(`div`,MH,[t[7]||=V(`span`,{class:`text-xs font-medium text-muted`},`Live address`,-1),V(`div`,NH,[V(`span`,PH,k(f.value),1),H(hV,{value:f.value,label:`Copy the live address`},null,8,[`value`])])])]),_:1}),H(IL,{class:`mt-3`,title:`Certificate`,description:`PEM-encoded certificate and its private key. Both stay in the secrets file.`},{default:M(()=>[d.value?.error?(R(),z(`div`,FH,[H(xB,{tone:`danger`,title:`The stored certificate cannot be used`},{default:M(()=>[U(k(d.value.error),1)]),_:1})])):d.value?.certPresent?(R(),z(`div`,IH,[V(`dl`,LH,[V(`div`,RH,[t[8]||=V(`dt`,{class:`text-muted`},` Subject `,-1),V(`dd`,zH,k(d.value.subject??`—`),1)]),V(`div`,BH,[t[9]||=V(`dt`,{class:`text-muted`},` Issuer `,-1),V(`dd`,VH,k(d.value.issuer??`—`),1)]),V(`div`,HH,[t[10]||=V(`dt`,{class:`text-muted`},` Valid until `,-1),V(`dd`,UH,[U(k(d.value.validTo?d.value.validTo.slice(0,10):`—`)+` `,1),d.value.daysRemaining===null?W(``,!0):(R(),z(`span`,{key:0,class:O(j(Q)(`ml-1.5`,d.value.daysRemaining<14?`text-warn`:`text-faint`))},` (`+k(d.value.daysRemaining)+` days) `,3))])]),V(`div`,WH,[t[11]||=V(`dt`,{class:`text-muted`},` Private key `,-1),V(`dd`,null,[H(_V,{tone:d.value.keyMatches?`ok`:`danger`,dot:``},{default:M(()=>[U(k(d.value.keyMatches?`matches the certificate`:`does not match`),1)]),_:1},8,[`tone`])])]),V(`div`,GH,[t[12]||=V(`dt`,{class:`text-muted`},` Fingerprint `,-1),V(`dd`,KH,[V(`span`,qH,k(d.value.fingerprint??`—`),1),d.value.fingerprint?(R(),B(hV,{key:0,value:d.value.fingerprint,label:`Copy the fingerprint`},null,8,[`value`])):W(``,!0)])])])])):(R(),z(`div`,JH,[H(xB,{tone:`info`,title:`No certificate uploaded`},{default:M(()=>[...t[13]||=[U(` Upload a PEM certificate and key below, then save. HTTPS is not served until a certificate is present. `,-1)]]),_:1})])),V(`div`,YH,[V(`label`,{class:O(j(BL)),for:`tls-cert-file`},`Certificate file (.pem, .crt)`,2),V(`input`,{id:`tls-cert-file`,type:`file`,accept:`.pem,.crt,.cer,text/plain`,class:O(j(m)),onChange:t[2]||=e=>h(e,`cert`)},null,34)]),V(`div`,XH,[V(`label`,{class:O(j(BL)),for:`tls-key-file`},`Private key file (.pem, .key)`,2),V(`input`,{id:`tls-key-file`,type:`file`,accept:`.pem,.key,text/plain`,class:O(j(m)),onChange:t[3]||=e=>h(e,`key`)},null,34)]),H(SR,{modelValue:o.value,"onUpdate:modelValue":t[4]||=e=>o.value=e,label:`Or paste the certificate`,rows:4,placeholder:`-----BEGIN CERTIFICATE-----`},null,8,[`modelValue`]),H(SR,{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`]),V(`div`,ZH,[H($,{variant:`primary`,disabled:!p.value,loading:u.value,onClick:g},{default:M(()=>[...t[14]||=[U(` Save certificate `,-1)]]),_:1},8,[`disabled`,`loading`]),d.value?.certPresent?(R(),B(vB,{key:0,label:`Remove certificate`,"confirm-label":`Confirm remove`,"confirm-variant":`danger`,disabled:u.value,onConfirm:_},null,8,[`disabled`])):W(``,!0)]),l.value||c.value?(R(),z(`div`,QH,[l.value?(R(),B(xB,{key:0,tone:`danger`},{default:M(()=>[U(k(l.value),1)]),_:1})):W(``,!0),c.value?(R(),B(xB,{key:1,tone:`ok`},{default:M(()=>[U(k(c.value),1)]),_:1})):W(``,!0)])):W(``,!0)]),_:1})],64))}}),eU={class:`min-h-full`},tU={class:`mx-auto w-full max-w-5xl px-4 pb-6 pt-5 sm:px-6`},nU={class:`lg:grid lg:grid-cols-[11rem_minmax(0,1fr)] lg:gap-8`},rU={"aria-label":`Global settings sections`,class:`hidden lg:block`},iU={class:`sticky top-6 space-y-0.5 border-l border-line`},aU=[`aria-current`,`onClick`],oU={class:`space-y-6`},sU={id:`listener`,class:`scroll-mt-5`},cU={id:`authentication`,class:`scroll-mt-5`},lU={id:`host`,class:`scroll-mt-5`},uU={id:`backups`,class:`scroll-mt-5`},dU={id:`tls`,class:`scroll-mt-5`},fU={id:`interface`,class:`scroll-mt-5`},pU={id:`paths`,class:`scroll-mt-5`},mU={class:`sticky bottom-0 z-30 border-t border-line bg-panel/95 backdrop-blur`},hU={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`},gU={class:`min-w-0 flex-1`},_U={class:`text-xs text-muted`},vU={class:`font-mono tabular-nums text-ink`},yU={key:0,class:`mt-0.5 text-xs text-danger`},bU={key:1,class:`mt-0.5 text-xs text-ok`},xU={class:`flex shrink-0 items-center gap-2`},SU={class:`max-h-[60dvh] overflow-auto px-4 py-3`},CU={key:0,class:`divide-y divide-line-soft`},wU={class:`font-mono text-xs text-ink`},TU={class:`ml-auto font-mono text-xs text-muted line-through`},EU={class:`font-mono text-xs text-accent`},DU={key:1,class:`text-xs text-muted`},OU={class:`flex items-center justify-end gap-2 border-t border-line px-4 py-3`},kU=P({__name:`GlobalSettingsView`,setup(e){let t=[{id:`listener`,title:`Listener`},{id:`authentication`,title:`Authentication`},{id:`host`,title:`Host vitals`},{id:`backups`,title:`Backups`},{id:`tls`,title:`TLS`},{id:`interface`,title:`Interface`},{id:`paths`,title:`Paths`}],n=Rg(),r=Lg(),i=WN(),a=dN(),o=en(QI()),s=A(`listener`),c=A(!1),l=A(null),u=A(null),d=A(null),f=A(null),p=G(()=>i.control.value),m=G(()=>i.host.value?.alerts??[]),h=G(()=>f.value?.host??null),g=G(()=>f.value?.backups??null),_=G(()=>i.backups.value),v=G(()=>f.value?.ui??null),y=G(()=>i.version.value),b=G(()=>i.dataRoot.value),x=G(()=>i.projectDir.value),S=G(()=>b.value===null?null:`${b.value}/settings.json`),C=G(()=>{let e={},t=p.value;if(t!==null){let n=cL(t,o);Object.keys(n).length>0&&(e.control=n)}let n=h.value;if(n!==null){let t=oL(n,o.host);Object.keys(t).length>0&&(e.host=t)}let r=g.value;if(r!==null){let t=sL(r,o.backups);Object.keys(t).length>0&&(e.backups=t)}return e}),w=G(()=>KI(C.value)),T=G(()=>{let e=p.value,t=h.value,n=g.value;return{control:e===null?{}:{...tL(e),auth:eL(e.auth)},host:t??{},backups:n===null?{}:{enabled:n.enabled,keep:n.keep,includePaths:n.includePaths}}}),ee=G(()=>GI(C.value,T.value)),E=A(!1),te=G(()=>p.value!==null&&hL(p.value,o)),ne=G(()=>p.value!==null&&gL(p.value,o)),re=G(()=>p.value!==null&&_L(p.value,o)),ie=G(()=>h.value!==null&&Object.keys(oL(h.value,o.host)).length>0),ae=G(()=>g.value!==null&&Object.keys(sL(g.value,o.backups)).length>0),oe={};function se(){let e=(e,t)=>{mL(oe[e],fL(o,e))||(t(),oe[e]=fL(o,e))},t=p.value;t!==null&&e(`control`,()=>{Object.assign(o.control,tL(t)),Object.assign(o.auth,eL(t.auth))});let n=h.value;n!==null&&e(`host`,()=>Object.assign(o.host,iL(n)));let r=g.value;r!==null&&e(`backups`,()=>Object.assign(o.backups,aL(r)))}function ce(){for(let e of Object.keys(oe))delete oe[e]}function D(e){oe[e]=fL(o,e)}N([p,f],()=>{se()},{immediate:!0});async function le(){d.value=null;try{f.value=await uM()}catch(e){d.value=e instanceof Error?e.message:String(e)}}ta(()=>{le()});async function ue(){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.saveGlobalSettings(e);if(!t){l.value=i.lastError.value??`The settings could not be saved.`;return}u.value=`Settings saved.`,a.success(`Settings saved`),await le(),ce(),se();let n=await yL(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 de(){l.value=null,u.value=null,ce(),se()}function fe(){h.value!==null&&Object.assign(o.host,iL(h.value)),D(`host`)}function pe(){g.value!==null&&Object.assign(o.backups,aL(g.value)),D(`backups`)}function me(){if(p.value!==null){let e=tL(p.value);o.control.label=e.label,o.control.port=e.port,o.control.host=e.host,o.control.openBrowser=e.openBrowser}D(`control`)}function he(){p.value!==null&&Object.assign(o.auth,eL(p.value.auth)),D(`control`)}function ge(){p.value!==null&&(o.control.tlsEnabled=p.value.tls.enabled),D(`control`)}function _e(e){rr(()=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})})}function ve(e){s.value=e,n.query.section!==e&&r.replace({query:{...n.query,section:e}}),_e(e)}N(()=>n.query.section,e=>{let n=typeof e==`string`?e:``;t.some(e=>e.id===n)&&(s.value=n,_e(n))},{immediate:!0});let ye=null;return ta(()=>{ye=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&&ye.observe(t)}}),ia(()=>ye?.disconnect()),(e,n)=>(R(),z(L,null,[V(`div`,eU,[V(`div`,tU,[n[17]||=V(`header`,{class:`mb-5`},[V(`h1`,{class:`text-xl font-semibold tracking-tight text-ink`},` Global settings `),V(`p`,{class:`mt-1 text-xs text-muted`},` Listener, access, host vitals, backups, TLS and paths for this panel — shared by every workspace. `)],-1),d.value?(R(),B(xB,{key:0,tone:`warn`,title:`Some file-only values could not be loaded`,class:`mb-4`},{default:M(()=>[U(k(d.value),1)]),_:1})):W(``,!0),V(`div`,nU,[V(`nav`,rU,[V(`ul`,iU,[(R(),z(L,null,F(t,e=>V(`li`,{key:e.id},[V(`button`,{type:`button`,"aria-current":s.value===e.id?`true`:void 0,class:O(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=>ve(e.id)},k(e.title),11,aU)])),64))])]),V(`div`,oU,[V(`section`,sU,[n[10]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Listener `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Where the control panel listens and how it announces itself. `)],-1),H(hH,{control:o.control,"onUpdate:control":n[0]||=e=>o.control=e,view:p.value,dirty:te.value,onReset:me},null,8,[`control`,`view`,`dirty`])]),V(`section`,cU,[n[11]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Authentication `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Who may sign in to this panel, and how a session is trusted. `)],-1),H(wB,{auth:o.auth,"onUpdate:auth":n[1]||=e=>o.auth=e,view:p.value,dirty:re.value,onReset:he},null,8,[`auth`,`view`,`dirty`])]),V(`section`,lU,[n[12]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Host vitals `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Alert thresholds for this machine's own resources. `)],-1),H(YV,{host:o.host,"onUpdate:host":n[2]||=e=>o.host=e,config:h.value,alerts:m.value,dirty:ie.value,onReset:fe},null,8,[`host`,`config`,`alerts`,`dirty`])]),V(`section`,uU,[n[13]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Backups `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` One archive per capture, covering the panel and any workspace you pick. `)],-1),H(KV,{form:o.backups,"onUpdate:form":n[3]||=e=>o.backups=e,state:_.value,policy:g.value,"config-path":S.value,workspaces:j(i).workspaces.value,dirty:ae.value,onReset:pe},null,8,[`form`,`state`,`policy`,`config-path`,`workspaces`,`dirty`])]),V(`section`,dU,[n[14]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` TLS `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Serve the panel over HTTPS with your own certificate. `)],-1),H($H,{"tls-enabled":o.control.tlsEnabled,"onUpdate:tlsEnabled":n[4]||=e=>o.control.tlsEnabled=e,view:p.value,dirty:ne.value,onReset:ge},null,8,[`tls-enabled`,`view`,`dirty`])]),V(`section`,fU,[n[15]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Interface `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Serve your own panel UI instead of the stock one. `)],-1),H(oH,{label:o.control.label,"onUpdate:label":n[5]||=e=>o.control.label=e,ui:v.value,"panel-version":y.value,"label-dirty":te.value,onChanged:le,onResetLabel:me},null,8,[`label`,`ui`,`panel-version`,`label-dirty`])]),V(`section`,pU,[n[16]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Paths `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Where home-hosted keeps its files, globally and per workspace. `)],-1),H(jH,{"data-root":b.value,"project-dir":x.value,"panel-url":p.value?.url??null,workspaces:j(i).workspaces.value},null,8,[`data-root`,`project-dir`,`panel-url`,`workspaces`])])])])]),V(`div`,mU,[V(`div`,hU,[V(`div`,gU,[V(`p`,_U,[w.value>0?(R(),z(`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[6]||=e=>E.value=!0},[V(`span`,vU,k(w.value),1),U(` field`+k(w.value===1?``:`s`)+` changed `,1)])):(R(),z(L,{key:1},[U(` No unsaved changes `)],64))]),l.value?(R(),z(`p`,yU,k(l.value),1)):u.value?(R(),z(`p`,bU,k(u.value),1)):W(``,!0)]),V(`div`,xU,[H($,{variant:`ghost`,disabled:w.value===0||c.value,onClick:de},{default:M(()=>[...n[18]||=[U(` Discard changes `,-1)]]),_:1},8,[`disabled`]),H($,{variant:`primary`,disabled:w.value===0,loading:c.value,onClick:ue},{default:M(()=>[...n[19]||=[U(` Save settings `,-1)]]),_:1},8,[`disabled`,`loading`])])])])]),H(vR,{open:E.value,"onUpdate:open":n[9]||=e=>E.value=e,title:`Unsaved changes`,description:`What Save would write to the panel's settings file.`,width:`w-[min(92vw,42rem)]`},{default:M(()=>[V(`div`,SU,[ee.value.length>0?(R(),z(`ul`,CU,[(R(!0),z(L,null,F(ee.value,e=>(R(),z(`li`,{key:e.path,class:`flex flex-wrap items-baseline gap-x-3 gap-y-1 py-2 first:pt-0`},[V(`code`,wU,k(e.path),1),V(`span`,TU,k(j(pI)(e.from)),1),n[20]||=V(`span`,{class:`text-2xs text-faint`},`→`,-1),V(`span`,EU,k(j(pI)(e.to)),1)]))),128))])):(R(),z(`p`,DU,` Nothing to save. `))]),V(`footer`,OU,[H($,{size:`sm`,variant:`ghost`,onClick:n[7]||=e=>E.value=!1},{default:M(()=>[...n[21]||=[U(` Close `,-1)]]),_:1}),H($,{size:`sm`,variant:`primary`,disabled:ee.value.length===0||c.value,loading:c.value,onClick:n[8]||=e=>{ue(),E.value=!1}},{default:M(()=>[U(` Save `+k(ee.value.length)+` change`+k(ee.value.length===1?``:`s`),1)]),_:1},8,[`disabled`,`loading`])])]),_:1},8,[`open`])],64))}}),AU={class:`relative flex min-h-dvh items-center justify-center overflow-hidden bg-page px-4 py-10`},jU={class:`hh-enter relative w-full max-w-md`},MU={class:`rounded-panel border border-line bg-panel/95 p-5 shadow-float backdrop-blur-sm`},NU={class:`flex items-start justify-between gap-3`},PU={class:`min-w-0`},FU={class:`text-base font-semibold text-ink`},IU={class:`mt-1 text-xs leading-relaxed text-muted`},LU={class:`flex flex-col gap-1.5`},RU={class:`relative`},zU=[`type`],BU=[`aria-label`],VU={key:0,class:`rounded-control border border-danger/25 bg-danger-soft px-2.5 py-2 text-xs text-danger`},HU={key:1,class:`mt-5`},UU={class:`mt-4 space-y-2`},WU={key:0,class:`flex items-start gap-2 rounded-control border border-warn/25 bg-warn-soft px-2.5 py-2`},GU={class:`text-2xs leading-4 text-warn`},KU={class:`ml-1 rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},qU={key:1,class:`flex items-start gap-2 rounded-control border border-warn/25 bg-warn-soft px-2.5 py-2`},JU={key:2,class:`flex items-start gap-2 rounded-control border border-line-soft bg-panel-2 px-2.5 py-2`},YU={class:`text-2xs leading-4 text-muted`},XU={class:`mt-4 flex items-center justify-center gap-2 text-2xs text-faint`},ZU={class:`font-mono`},QU=P({__name:`LoginView`,setup(e){let t=Rg(),n=Lg(),r=WN(),{session:i,error:a,login:o,refresh:s}=oN(),c=A(``),l=A(!1),u=A(!1),d=G(()=>i.value?.passwordSet===!1),f=G(()=>i.value!==null&&!i.value.authRequired),p=G(()=>i.value?.usingDefaultPassword===!0&&i.value.defaultPassword!==null),m=G(()=>r.control.value?.auth.exposed===!0),h=G(()=>r.control.value?.url??`—`),g=G(()=>d.value?`This panel has no password yet`:f.value?`Authentication is turned off`:`Sign in to continue`),_=G(()=>d.value?`Anything on this machine can reach it. Set a password right after you are in.`:f.value?`The panel only listens on loopback, which is the only thing protecting it right now.`:`The control panel is protected. Enter the password to continue.`);async function v(){l.value=!0;try{if(await o(c.value)){c.value=``;let e=typeof t.query.next==`string`?t.query.next:`/`;await n.push(e)}}finally{l.value=!1}}async function y(){await s(),await n.push(`/`)}return ta(async()=>{i.value===null&&await s()}),(e,t)=>(R(),z(`div`,AU,[t[11]||=V(`div`,{class:`bg-instrument pointer-events-none absolute inset-0 opacity-60`},null,-1),t[12]||=V(`div`,{class:`pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_at_center,transparent_15%,var(--page)_78%)]`},null,-1),V(`div`,jU,[t[10]||=Ds(`<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),V(`section`,MU,[V(`div`,NU,[V(`div`,PU,[V(`h1`,FU,k(g.value),1),V(`p`,IU,k(_.value),1)]),m.value?(R(),B(_V,{key:0,tone:`warn`,dot:``},{default:M(()=>[...t[2]||=[U(` Exposed `,-1)]]),_:1})):W(``,!0)]),f.value?(R(),z(`div`,HU,[H($,{variant:`primary`,size:`md`,block:``,onClick:y},{default:M(()=>[...t[4]||=[U(` Open the dashboard `,-1)]]),_:1})])):(R(),z(`form`,{key:0,class:`mt-5 space-y-3`,onSubmit:cu(v,[`prevent`])},[V(`div`,LU,[V(`label`,{for:`hh-password`,class:O(j(BL))},`Password`,2),V(`div`,RU,[xr(V(`input`,{id:`hh-password`,"onUpdate:modelValue":t[0]||=e=>c.value=e,type:u.value?`text`:`password`,autocomplete:`current-password`,autofocus:``,required:``,class:O(j(Q)(j(HL),`pr-9`))},null,10,zU),[[nu,c.value]]),V(`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?(R(),B(j(Zv),{key:0,class:`size-3.5`})):(R(),B(j(Qv),{key:1,class:`size-3.5`}))],8,BU)])]),j(a)?(R(),z(`p`,VU,k(j(a)),1)):W(``,!0),H($,{type:`submit`,variant:`primary`,size:`md`,block:``,loading:l.value},{default:M(()=>[H(j(sy),{class:`size-3.5`}),t[3]||=U(` Sign in `,-1)]),_:1},8,[`loading`])],32)),V(`div`,UU,[p.value?(R(),z(`div`,WU,[H(j(Ey),{class:`mt-0.5 size-3.5 shrink-0 text-warn`}),V(`p`,GU,[t[5]||=U(` Still on the default password `,-1),V(`code`,KU,k(j(i)?.defaultPassword),1),t[6]||=U(`. Change it under Settings — binding beyond 127.0.0.1 stays refused until you do. `,-1)])])):d.value?(R(),z(`div`,qU,[H(j(Oy),{class:`mt-0.5 size-3.5 shrink-0 text-warn`}),t[7]||=V(`p`,{class:`text-2xs leading-4 text-warn`},[U(` No password is set. Open Settings from this machine to add one, or run `),V(`code`,{class:`rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},`pnpm run auth:set-password`),U(`. `)],-1)])):(R(),z(`div`,JU,[H(j(Dy),{class:`mt-0.5 size-3.5 shrink-0 text-ok`}),V(`p`,YU,` Sessions last `+k(Math.round((j(i)?.sessionTtlMs??0)/864e5))+` days. Signing out clears this browser only. `,1)]))])]),V(`p`,XU,[V(`span`,ZU,k(h.value),1),t[8]||=V(`span`,{"aria-hidden":`true`},`·`,-1),t[9]||=V(`span`,null,`served from this machine`,-1)])])]))}}),$U=[`#3f4a5c`,`#f07178`,`#7fd88f`,`#e6b673`,`#82aaff`,`#c792ea`,`#7fdbca`,`#c7d2e3`,`#5a6779`,`#ff8b92`,`#9ae6a8`,`#f2c98a`,`#9dbaff`,`#d7aef0`,`#9ce9dc`,`#eef3fb`],eW=[`#4b5563`,`#c0392b`,`#1c7c3f`,`#9a6700`,`#2f5fe0`,`#7c3aed`,`#0b6f89`,`#334155`,`#6b7280`,`#d64535`,`#22854a`,`#a8620d`,`#3f6bff`,`#8b5cf6`,`#0e7d9c`,`#0f1722`],tW=/\u001B\[([0-9;]*)m/g,nW=/\u001B(?:\[[0-9;?]*[A-HJKSTfhilmnprsu]|\][^\u0007\u001B]*(?:\u0007|\u001B\\)?|[()][0-9A-Z])/g;function rW(e){return Math.max(0,Math.min(255,e))}function iW(e){return e===0?0:55+e*40}function aW(e,t){let n=t?$U:eW;if(e<16)return n[e]??n[7];if(e<232){let t=e-16;return`rgb(${iW(Math.floor(t/36))} ${iW(Math.floor(t%36/6))} ${iW(t%6)})`}let r=8+(e-232)*10;return`rgb(${r} ${r} ${r})`}function oW(){return{fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1}}function sW(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,oW());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?$U:eW)[i-30]??null;else if(i>=90&&i<=97)e.fg=(n?$U:eW)[i-90+8]??null;else if(i>=40&&i<=47)e.bg=(n?$U:eW)[i-40]??null;else if(i>=100&&i<=107)e.bg=(n?$U:eW)[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]=aW(rW(r[t+2]),n),t+=2):o===2&&(e[a]=`rgb(${rW(r[t+2]??0)} ${rW(r[t+3]??0)} ${rW(r[t+4]??0)})`,t+=4)}}}function cW(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 lW(e){return e.includes(`\x1B`)}function uW(e,t=!0){if(!lW(e))return[{text:e,fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1}];let n=[],r=oW(),i=0;tW.lastIndex=0;let a=tW.exec(e);for(;a!==null;)cW(n,e.slice(i,a.index).replace(nW,``),r),sW(r,a[1]??``,t),i=a.index+a[0].length,a=tW.exec(e);return cW(n,e.slice(i).replace(nW,``),r),n}var dW={class:`flex h-5 w-max min-w-full items-center gap-2 whitespace-pre px-2 font-mono text-xs leading-5`},fW={key:0,class:`shrink-0 select-none text-faint`},pW={class:`min-w-0`},mW=P({__name:`LogRow`,props:{line:{},query:{},dark:{type:Boolean},showTime:{type:Boolean}},setup(e){let t=e,n=G(()=>uW(t.line.text,t.dark)),r=G(()=>{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)=>(R(),z(`div`,dW,[t.showTime?(R(),z(`span`,fW,k(j(iI)(t.line.ts)),1)):W(``,!0),V(`span`,{class:O([`h-3.5 w-0.5 shrink-0 rounded-full`,[i[t.line.stream]]]),"aria-hidden":`true`},null,2),V(`span`,pW,[(R(!0),z(L,null,F(r.value,(e,t)=>(R(),z(`span`,{key:t,style:ge(a(e))},k(e.text),5))),128))])]))}}),hW={class:`flex min-h-0 flex-col overflow-hidden rounded-panel border border-line bg-panel`},gW={class:`flex flex-wrap items-center gap-2 border-b border-line bg-panel-2/60 px-2.5 py-2`},_W={class:`relative min-w-40 flex-1 sm:max-w-72`},vW={class:`absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5`},yW={key:0,class:`px-1 font-mono text-2xs tabular-nums text-faint`},bW={class:`ml-auto flex items-center gap-1.5`},xW=[`href`,`download`],SW={class:`relative min-h-0 flex-1`},CW={key:0,class:`px-3 py-6 text-center text-xs text-faint`},wW={class:`flex items-center gap-3 border-t border-line bg-panel-2/60 px-2.5 py-1.5 text-2xs text-faint`},TW={class:`flex items-center gap-1.5`},EW={class:`font-mono tabular-nums`},DW={key:0,class:`font-mono tabular-nums`},OW=20,kW=12,AW=P({__name:`LogViewer`,props:{lines:{},version:{default:0},live:{type:Boolean,default:!1},emptyHint:{default:`No output yet.`},clearable:{type:Boolean,default:!1},downloadUrl:{default:void 0},downloadName:{default:void 0},minHeight:{default:`16rem`}},emits:[`clear`],setup(e,{emit:t}){let n=e,r=t,i=$N(),a=A(null),o=A(0),s=A(320),c=A(!0),l=A(`all`),u=A(``),d=A(!0),f=A(0),p=G(()=>{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=G(()=>p.value.length),h=G(()=>{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=G(()=>Math.max(0,Math.floor(o.value/OW)-kW)),_=G(()=>Math.min(m.value,Math.ceil((o.value+s.value)/OW)+kW)),v=G(()=>p.value.slice(g.value,_.value)),y=G(()=>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*OW-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]))}N(m,()=>{c.value&&(f.value=0,requestAnimationFrame(x))}),N(h,()=>{f.value=0,h.value.length>0&&u.value.trim().length>0&&requestAnimationFrame(()=>S(h.value[0]))}),N(l,()=>{c.value=!0,requestAnimationFrame(x)});let w=null;ta(()=>{let e=a.value;e&&(s.value=e.clientHeight,w=new ResizeObserver(()=>{a.value&&(s.value=a.value.clientHeight)}),w.observe(e),x())}),ze(()=>{w?.disconnect(),w=null});let T=[{value:`all`,label:`All`},{value:`stdout`,label:`out`},{value:`stderr`,label:`err`},{value:`system`,label:`sys`}];return(e,t)=>(R(),z(`div`,hW,[V(`header`,gW,[H(lH,{modelValue:l.value,"onUpdate:modelValue":t[0]||=e=>l.value=e,options:T},null,8,[`modelValue`]),V(`div`,_W,[H(j(Cy),{class:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),xr(V(`input`,{"onUpdate:modelValue":t[1]||=e=>u.value=e,type:`search`,placeholder:`Search this output`,class:O([`h-7 py-0 pl-7 text-xs`,[j(HL)]]),"aria-label":`Search the log output`,onKeydown:t[2]||=uu(cu(e=>C(e.shiftKey?-1:1),[`prevent`]),[`enter`])},null,34),[[ql,u.value]]),V(`div`,vW,[u.value.trim().length>0?(R(),z(`span`,yW,k(h.value.length===0?`0`:`${f.value+1}/${h.value.length}`),1)):W(``,!0),u.value.length>0?(R(),z(`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=``},[H(j(Ry),{class:`size-3`})])):W(``,!0),h.value.length>0?(R(),z(`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)},[H(j(Rv),{class:`size-3`})])):W(``,!0),h.value.length>0?(R(),z(`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)},[H(j(Fv),{class:`size-3`})])):W(``,!0)])]),V(`div`,bW,[H(ZR,{label:d.value?`Hide timestamps`:`Show timestamps`},{default:M(()=>[H($,{size:`xs`,variant:`ghost`,onClick:t[6]||=e=>d.value=!d.value},{default:M(()=>[H(j(Uv),{class:O(j(Q)(`size-3`,d.value?`fill-accent text-accent`:`text-faint`))},null,8,[`class`]),t[9]||=U(` ts `,-1)]),_:1})]),_:1},8,[`label`]),H($,{size:`xs`,variant:c.value?`secondary`:`primary`,onClick:t[7]||=e=>c.value?c.value=!1:x()},{default:M(()=>[(R(),B(ma(c.value?j(my):j(gy)),{class:`size-3`})),U(` `+k(c.value?`Pause`:`Follow`),1)]),_:1},8,[`variant`]),n.clearable?(R(),B(ZR,{key:0,label:`Clear the in-memory buffer`},{default:M(()=>[H($,{size:`icon-sm`,variant:`ghost`,"aria-label":`Clear the log buffer`,onClick:t[8]||=e=>r(`clear`)},{default:M(()=>[H(j(Fy),{class:`size-3.5`})]),_:1})]),_:1})):W(``,!0),n.downloadUrl?(R(),B(ZR,{key:1,label:`Download the persisted file`},{default:M(()=>[V(`a`,{href:n.downloadUrl,download:n.downloadName},[H($,{size:`icon-sm`,variant:`ghost`,"aria-label":`Download the log file`},{default:M(()=>[H(j(Mv),{class:`size-3.5`})]),_:1})],8,xW)]),_:1})):W(``,!0)])]),V(`div`,SW,[V(`div`,{ref_key:`scroller`,ref:a,class:`h-full overflow-auto overscroll-contain bg-page/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/50`,style:ge({minHeight:n.minHeight}),tabindex:`0`,role:`log`,"aria-label":`Log output`,onScrollPassive:b},[m.value===0?(R(),z(`p`,CW,k(n.lines.length===0?n.emptyHint:`Nothing matches that search or stream filter.`),1)):(R(),z(`div`,{key:1,class:`relative w-full`,style:ge({height:`${m.value*OW}px`})},[(R(!0),z(L,null,F(v.value,(e,t)=>(R(),z(`div`,{key:g.value+t,class:O([`absolute left-0 top-0`,g.value+t===y.value&&`bg-warn/10`]),style:ge({transform:`translateY(${(g.value+t)*OW}px)`})},[H(mW,{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),H(Ec,{"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?(R(),z(`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},[H(j(Mv),{class:`size-3`}),t[10]||=U(` Jump to latest `,-1)])):W(``,!0)]),_:1})]),V(`footer`,wW,[V(`span`,TW,[V(`span`,{class:O(j(Q)(`size-1.5 rounded-full`,n.live?c.value?`bg-ok`:`bg-warn`:`bg-faint`))},null,2),U(` `+k(n.live?c.value?`streaming`:`paused`:`snapshot`),1)]),V(`span`,EW,k(m.value===n.lines.length?`${m.value} lines`:`${m.value} of ${n.lines.length} lines`),1),u.value.trim().length>0?(R(),z(`span`,DW,k(h.value.length)+` matches`,1)):W(``,!0),V(`span`,{class:`ml-auto hidden font-mono tabular-nums sm:inline`},`row height `+k(OW)+`px · windowed`)])]))}}),jW={class:`flex h-full min-h-0`},MW={class:`hidden w-64 shrink-0 flex-col border-r border-line bg-panel/40 md:flex`},NW={class:`border-b border-line px-3 py-2.5`},PW={class:`mt-0.5 text-2xs text-faint`},FW={class:`min-h-0 flex-1 overflow-y-auto p-1.5`},IW={key:0,class:`space-y-1.5 p-1.5`},LW=[`onClick`],RW={class:`min-w-0 flex-1`},zW={class:`block truncate font-mono text-2xs text-faint`},BW={class:`flex min-w-0 flex-1 flex-col`},VW={class:`flex flex-wrap items-center gap-2 border-b border-line bg-panel/40 px-3 py-2.5`},HW={class:`min-w-0`},UW={class:`truncate text-sm font-semibold text-ink`},WW={key:0,class:`ml-1.5 font-mono text-2xs font-normal text-faint`},GW={key:0,class:`flex flex-wrap items-center gap-1.5 border-b border-line-soft bg-panel-2/40 px-3 py-2`},KW=[`href`,`download`],qW={class:`text-faint`},JW={key:1,class:`text-2xs text-faint`},YW={key:2,class:`ml-auto font-mono text-2xs text-faint`},XW={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`},ZW={class:`min-h-0 flex-1 p-3`},QW=P({__name:`LogsView`,setup(e){let t=Rg(),n=Lg(),r=aP(),i=A([]),a=A(null),o=A(`disk`),s=A(`2000`),c=A(!1),l=A(null),u=A([]),d=A(0),f=A(!1),p=A(!0),m=G(()=>i.value.find(e=>e.serverId===a.value)??null),h=UN(r.activeId,()=>o.value===`live`?a.value:null),g=h.version,_=G(()=>(g.value,h.lines())),v=G(()=>o.value===`live`?_.value:u.value),y=G(()=>o.value===`live`?g.value:d.value),b=[{value:`200`,label:`200 lines`},{value:`500`,label:`500 lines`},{value:`2000`,label:`2000 lines`},{value:`5000`,label:`5000 lines`}],x=G(()=>i.value.reduce((e,t)=>e+t.sizeBytes,0)),S=G(()=>i.value.filter(e=>e.files.length>0).length);async function C(){p.value=!0;try{i.value=await pM(r.activeId.value);let e=typeof t.query.server==`string`?t.query.server:null,n=e&&i.value.some(t=>t.serverId===e)?e:a.value&&i.value.some(e=>e.serverId===a.value)?a.value:i.value[0]?.serverId??null;a.value=n}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{p.value=!1}}async function w(){let e=a.value;if(e!==null&&o.value!==`live`){c.value=!0,l.value=null;try{let t=await mM(r.activeId.value,e,{tail:Number(s.value)});u.value=t.lines,d.value+=1}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{c.value=!1}}}async function T(){let e=a.value;if(e!==null){f.value=!1;try{await hM(r.activeId.value,e),u.value=[],d.value+=1,await C()}catch(e){l.value=e instanceof Error?e.message:String(e)}}}function ee(e){a.value=e,o.value===`live`&&(u.value=[]),n.replace({query:{...t.query,server:e}})}return N([a,s,o],()=>{o.value===`disk`&&w()},{immediate:!1}),N(()=>r.activeId.value,()=>{a.value=null,u.value=[],o.value=`disk`,C().then(()=>w())}),ta(async()=>{await C(),o.value===`disk`&&await w()}),(e,t)=>(R(),z(`div`,jW,[V(`aside`,MW,[V(`div`,NW,[t[5]||=V(`p`,{class:`text-xs font-semibold text-ink`},` Persisted logs `,-1),V(`p`,PW,k(j(r).selected.value?.label??`Workspace`)+` · `+k(S.value)+` of `+k(i.value.length)+` servers on disk · `+k(j(uI)(x.value)),1)]),V(`div`,FW,[p.value?(R(),z(`div`,IW,[(R(),z(L,null,F(5,e=>H(Iz,{key:e,class:`h-10 w-full`,rounded:`rounded-control`})),64))])):(R(!0),z(L,{key:1},F(i.value,e=>(R(),z(`button`,{key:e.serverId,type:`button`,class:O(j(Q)(`flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors duration-150`,e.serverId===a.value?`bg-accent-soft`:`hover:bg-hover`)),onClick:t=>ee(e.serverId)},[V(`span`,{class:O(j(Q)(`size-1.5 shrink-0 rounded-full`,j(RF)[j(PF)[e.status].tone]))},null,2),V(`span`,RW,[V(`span`,{class:O(j(Q)(`block truncate text-xs`,e.serverId===a.value?`font-medium text-accent`:`text-ink`))},k(e.label),3),V(`span`,zW,k(e.files.length>0?`${e.files.length} file${e.files.length===1?``:`s`} · ${j(uI)(e.sizeBytes)}`:`nothing persisted`),1)])],10,LW))),128)),!p.value&&i.value.length===0?(R(),B(rI,{key:2,compact:``,title:`No servers`,description:`Add one and its output will be persisted here.`})):W(``,!0)]),t[6]||=V(`div`,{class:`border-t border-line p-2.5`},[V(`p`,{class:`text-2xs leading-4 text-faint`},` Rotation and retention are set under Workspace settings → Logs. `)],-1)]),V(`div`,BW,[V(`header`,VW,[V(`div`,HW,[V(`h1`,UW,[U(k(m.value?.label??`Logs`)+` `,1),m.value?(R(),z(`span`,WW,k(m.value.serverId),1)):W(``,!0)])]),H(lH,{modelValue:o.value,"onUpdate:modelValue":t[0]||=e=>o.value=e,class:`ml-auto`,options:[{value:`disk`,label:`Persisted`},{value:`live`,label:`Live stream`}]},null,8,[`modelValue`]),o.value===`disk`?(R(),B($L,{key:0,modelValue:s.value,"onUpdate:modelValue":t[1]||=e=>s.value=e,options:b,class:`w-32`,"aria-label":`Tail size`},null,8,[`modelValue`])):W(``,!0),o.value===`disk`?(R(),B($,{key:1,size:`sm`,loading:c.value,onClick:w},{default:M(()=>[H(j(yy),{class:`size-3.5`}),t[7]||=U(`Reload `,-1)]),_:1},8,[`loading`])):W(``,!0),o.value===`disk`?(R(),B($,{key:2,size:`sm`,variant:`ghost`,disabled:!m.value||m.value.files.length===0,onClick:t[2]||=e=>f.value=!0},{default:M(()=>[H(j(Fy),{class:`size-3.5`}),t[8]||=U(`Clear file `,-1)]),_:1},8,[`disabled`])):W(``,!0)]),m.value?(R(),z(`div`,GW,[H(j($v),{class:`size-3.5 shrink-0 text-faint`}),m.value.files.length>0?(R(!0),z(L,{key:0},F(m.value.files,e=>(R(),z(`a`,{key:e.name,href:gM(j(r).activeId.value,m.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`},[U(k(e.name)+` `,1),V(`span`,qW,k(j(uI)(e.sizeBytes)),1),H(j(Mv),{class:`size-3`})],8,KW))),128)):(R(),z(`span`,JW,` Nothing on disk for this server — persistence is off, or it has not written anything yet. `)),o.value===`disk`&&u.value.length>0?(R(),z(`span`,YW,` loaded `+k(u.value.length)+` lines `,1)):W(``,!0)])):W(``,!0),l.value?(R(),z(`p`,XW,[H(j(Bv),{class:`size-3.5`}),U(` `+k(l.value),1)])):W(``,!0),V(`div`,ZW,[m.value?c.value&&v.value.length===0?(R(),B(Iz,{key:1,class:`h-full w-full`,rounded:`rounded-panel`})):(R(),B(AW,{key:2,lines:v.value,version:y.value,live:o.value===`live`,class:`h-full`,"empty-hint":o.value===`live`?`Connected — waiting for output.`:`The persisted file is empty.`,"min-height":`100%`},null,8,[`lines`,`version`,`live`,`empty-hint`])):(R(),B(rI,{key:0,title:`Pick a server`,description:`Persisted output and live streams are per server. Choose one from the list.`},{icon:M(()=>[H(j(Sy),{class:`size-4`})]),_:1}))])]),H(vR,{open:f.value,"onUpdate:open":t[4]||=e=>f.value=e,title:`Clear the persisted log file?`,description:`${m.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(()=>[H($,{variant:`ghost`,onClick:t[3]||=e=>f.value=!1},{default:M(()=>[...t[9]||=[U(` Keep it `,-1)]]),_:1}),H($,{variant:`danger`,onClick:T},{default:M(()=>[H(j(Fy),{class:`size-3.5`}),t[10]||=U(`Clear `,-1)]),_:1})]),default:M(()=>[t[11]||=V(`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`])]))}}),$W={class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},eG={key:0,class:`grid grid-cols-2 gap-4 p-4 sm:grid-cols-3 lg:grid-cols-5`},tG={key:1,class:`grid grid-cols-2 divide-line-soft sm:grid-cols-3 sm:divide-x lg:grid-cols-5`},nG={class:`p-4`},rG={class:`p-4`},iG={class:`p-4`},aG={class:`p-4`},oG={class:`p-4`},sG={key:0,class:`flex items-start gap-2.5 rounded-panel border border-danger/25 bg-danger-soft px-3.5 py-3`},cG={class:`min-w-0`},lG={class:`text-xs font-medium text-danger`},uG={class:`mt-0.5 flex flex-wrap gap-x-2 text-2xs text-danger`},dG={class:`space-y-3`},fG={class:`flex items-center justify-between`},pG={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},mG={key:0,class:`grid gap-4 lg:grid-cols-2`},hG={key:2,class:`grid gap-4 lg:grid-cols-2`},gG={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},_G={class:`flex flex-wrap items-center gap-x-3 gap-y-1 text-2xs text-faint`},vG={class:`flex items-center gap-1`},yG={class:`font-mono`},bG=P({__name:`OverviewView`,setup(e){let t=WN(),n=aP(),r=A(!1),i=G(()=>t.appState.value===null),a=n.servers,o=G(()=>n.selected.value?.label??`Workspace`),s=G(()=>a.value.filter(e=>e.status===`running`)),c=G(()=>a.value.filter(e=>[`stopped`,`stopping`].includes(e.status))),l=G(()=>a.value.filter(e=>e.status===`crashed`||e.status===`conflict`||e.health===`unhealthy`)),u=G(()=>{let e=0;for(let t of s.value){let n=t.resources?.rssBytes;typeof n==`number`&&(e+=n)}return e}),d=G(()=>{let e=0;for(let t of a.value){let r=gN(n.seriesOf(t.id).rss);r>e&&(e=r)}return e}),f=G(()=>{let e=0;for(let t of s.value)e+=t.resources?.cpuPercent??0;return e}),p=G(()=>{let e=a.value.map(e=>e.startedAt).filter(e=>typeof e==`number`);return e.length===0?`—`:oI(t.now.value-Math.min(...e))});return(e,m)=>{let h=fa(`RouterLink`);return R(),z(`div`,$W,[H(jz,{title:o.value,description:`Live state of every server in this workspace, refreshed over a single event stream.`},{actions:M(()=>[H($,{variant:`ghost`,onClick:m[0]||=e=>j(n).startAll()},{default:M(()=>[H(j(gy),{class:`size-3.5`}),m[5]||=U(`Start all `,-1)]),_:1}),H($,{variant:`ghost`,onClick:m[1]||=e=>j(n).stopAll()},{default:M(()=>[H(j(Ay),{class:`size-3.5`}),m[6]||=U(`Stop all `,-1)]),_:1}),H($,{variant:`primary`,onClick:m[2]||=e=>r.value=!0},{default:M(()=>[H(j(_y),{class:`size-3.5`}),m[7]||=U(`Add server `,-1)]),_:1})]),_:1},8,[`title`]),H(Fz,{class:`p-0`},{default:M(()=>[i.value?(R(),z(`div`,eG,[(R(),z(L,null,F(5,e=>V(`div`,{key:e,class:`space-y-2`},[H(Iz,{class:`h-2.5 w-16`}),H(Iz,{class:`h-6 w-20`})])),64))])):(R(),z(`div`,tG,[V(`div`,nG,[H(Bz,{label:`Running`,value:`${s.value.length}/${j(a).length}`,tone:`ok`,hint:`${j(a).length-s.value.length} not up`},null,8,[`value`,`hint`])]),V(`div`,rG,[H(Bz,{label:`Stopped`,value:String(c.value.length),hint:`${j(a).filter(e=>e.config.enabled).length} enabled`},null,8,[`value`,`hint`])]),V(`div`,iG,[H(Bz,{label:`Needs attention`,value:String(l.value.length),tone:l.value.length>0?`danger`:`ok`,hint:l.value.length===0?`nothing is broken`:`crashed or unhealthy`},null,8,[`value`,`tone`,`hint`])]),V(`div`,aG,[H(Bz,{label:`Process memory`,value:j(dI)(u.value),hint:d.value>0?`peak ${j(dI)(d.value)}`:`across the tree`},null,8,[`value`,`hint`])]),V(`div`,oG,[H(Bz,{label:`Longest uptime`,value:p.value,hint:s.value.length>0?`${f.value.toFixed(1)}% cpu now`:`nothing running`},null,8,[`value`,`hint`])])]))]),_:1}),l.value.length>0?(R(),z(`div`,sG,[H(j(Bv),{class:`mt-0.5 size-4 shrink-0 text-danger`}),V(`div`,cG,[V(`p`,lG,k(l.value.length)+` server`+k(l.value.length===1?``:`s`)+` need a look `,1),V(`p`,uG,[(R(!0),z(L,null,F(l.value,e=>(R(),B(h,{key:e.id,to:`/servers/${e.id}`,class:`font-mono underline-offset-2 hover:underline`},{default:M(()=>[U(k(e.id),1)]),_:2},1032,[`to`]))),128))])])])):W(``,!0),V(`section`,dG,[V(`div`,fG,[V(`h2`,pG,[H(j(wy),{class:`size-3.5 text-faint`}),m[8]||=U(` Servers `,-1)]),H(h,{to:j(NX)(j(n).activeId.value,`servers`),class:`text-2xs text-muted transition-colors duration-150 hover:text-accent`},{default:M(()=>[...m[9]||=[U(` Open the full list `,-1)]]),_:1},8,[`to`])]),i.value?(R(),z(`div`,mG,[(R(),z(L,null,F(4,e=>H(Iz,{key:e,class:`h-64 w-full`,rounded:`rounded-panel`})),64))])):j(a).length===0?(R(),B(rI,{key:1,title:`No servers in this workspace`,description:`Add the first process this workspace should keep alive.`},{icon:M(()=>[H(j(wy),{class:`size-4`})]),action:M(()=>[H($,{variant:`primary`,onClick:m[3]||=e=>r.value=!0},{default:M(()=>[H(j(_y),{class:`size-3.5`}),m[10]||=U(`Add a server `,-1)]),_:1})]),_:1})):(R(),z(`div`,hG,[(R(!0),z(L,null,F(j(a),e=>(R(),B(wz,{key:e.id,server:e,"workspace-id":j(n).activeId.value,series:j(n).seriesOf(e.id),now:j(t).now.value},null,8,[`server`,`workspace-id`,`series`,`now`]))),128))]))]),H(Fz,null,{header:M(()=>[V(`h2`,gG,[H(j(Av),{class:`size-3.5 text-faint`}),m[11]||=U(` Recent activity `,-1)])]),actions:M(()=>[H(h,{to:j(NX)(j(n).activeId.value,`logs`),class:`text-2xs text-muted transition-colors duration-150 hover:text-accent`},{default:M(()=>[...m[12]||=[U(` Logs `,-1)]]),_:1},8,[`to`])]),default:M(()=>[H(RI,{servers:j(a),now:j(t).now.value,limit:10},null,8,[`servers`,`now`])]),_:1}),V(`p`,_G,[V(`span`,vG,[H(j(Py),{class:`size-3`}),m[13]||=U(`resource history is sampled every 5 s and kept for this session`,-1)]),V(`span`,yG,k(j(n).selected.value?.configPath),1),V(`span`,{class:O(j(Q)(`flex items-center gap-1`))},[m[14]||=V(`span`,{class:`size-1.5 rounded-full bg-ok`},null,-1),U(` workspace `+k(j(n).activeId.value),1)],2)]),H(ER,{open:r.value,"onUpdate:open":m[4]||=e=>r.value=e,"workspace-id":j(n).activeId.value},null,8,[`open`,`workspace-id`])])}}}),xG=4480,SG=4443,CG=/^[a-z0-9][a-z0-9_-]*$/,wG=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)*$/i,TG=/^\d{1,3}(?:\.\d{1,3}){3}$/,EG=[`.localhost`,`.local`,`.internal`,`.home.arpa`,`.lan`,`.home`,`.test`,`.invalid`,`.example`],DG=[{value:`server`,label:`A supervised server`},{value:`panel`,label:`This control panel`},{value:`external`,label:`A literal upstream`}],OG=[{value:`auto`,label:`Automatic — the engine decides`},{value:`off`,label:`Off — plain HTTP`},{value:`manual`,label:`Uploaded certificate`}],kG={off:{label:`Off`,tone:`neutral`,transitional:!1},stopped:{label:`Stopped`,tone:`neutral`,transitional:!1},starting:{label:`Starting`,tone:`warn`,transitional:!0},running:{label:`Running`,tone:`ok`,transitional:!1},error:{label:`Error`,tone:`danger`,transitional:!1},unsupported:{label:`Unsupported`,tone:`warn`,transitional:!1}},AG={ok:{label:`Serving`,tone:`ok`},disabled:{label:`Disabled`,tone:`neutral`},"no-upstream":{label:`No upstream`,tone:`warn`},error:{label:`Error`,tone:`danger`}},jG={off:null,local:{label:`engine CA`,tone:`neutral`},uploaded:{label:`uploaded pair`,tone:`info`},issued:{label:`certificate ready`,tone:`ok`},pending:{label:`waiting for the CA`,tone:`warn`},failed:{label:`certificate failed`,tone:`danger`},fallback:{label:`Fell back to Local CA`,tone:`warn`}};function MG(e,t,n){let r=e.host.trim();if(r.length===0)return null;let i=e.tls===`off`,a=i?t:n,o=i?80:443,s=e.path.length===0||e.path.startsWith(`/`)?e.path:`/${e.path}`;return`${i?`http`:`https`}://${r}${a===o?``:`:${a}`}${s}`}function NG(e){if(e===null)return`~8 hours`;if(e<60)return`~${e} minute${e===1?``:`s`}`;let t=Math.max(1,Math.round(e/60));return`~${t} hour${t===1?``:`s`}`}function PG(e){let t=e.certificate;if(t===void 0)return null;let n=jG[t.state]??null;return n===null?null:{...n,message:t.message,retryInMinutes:t.retryInMinutes??null}}function FG(e){return e.label.trim().length>0?e.label:e.id}var IG=/^(?:[a-z][a-z0-9+.-]*:\/\/)?(?<authority>[^/?#]+)/i,LG=0;function RG(){return LG+=1,`proxy-route-${LG}`}function zG(e){let t=e.trim().toLowerCase();return t.length===0||t===`localhost`||!t.includes(`.`)||EG.some(e=>t.endsWith(e))?!1:!TG.test(t)}function BG(e){return e>0&&e<1024}function VG(e){return e.httpPort===4480&&e.httpsPort===4443}function HG(e){return{enabled:e.enabled,httpPort:e.httpPort,httpsPort:e.httpsPort,email:e.email,staging:e.staging,dns01:e.dns01.enabled,resolvers:e.dns01.resolvers.join(`, `)}}function UG(e){return e.split(/[\s,]+/).map(e=>e.trim()).filter(e=>e.length>0)}function WG(e){let t=[{value:``,label:`Automatic (the only account that can answer)`}];for(let n of e){let e=n.label.length>0?n.label:n.account,r=[n.writesTxt?null:`no TXT support`,n.writesTxt&&!n.hasCredentials?`no credentials`:null].filter(e=>e!==null);t.push({value:`${n.workspace}/${n.account}`,label:`${e} · ${n.provider} · ${n.workspace}${r.length>0?` (${r.join(`, `)})`:``}`})}return t}function GG(e){return{...HG(e)}}function KG(e){return structuredClone(un(e)).map(e=>({...e,key:RG()}))}function qG(e){return{id:e.id,host:e.host,enabled:e.enabled,target:e.target,workspace:e.workspace,server:e.server,url:e.url,path:e.path,tls:e.tls,dnsAccount:e.dnsAccount}}function JG(e){return e.map(qG)}function YG(e,t){return JSON.stringify(qG(e))===JSON.stringify(qG(t))}function XG(e,t){return e.length===t.length&&e.every((e,n)=>YG(e,t[n]))}function ZG(e,t){return XG(e,t)?null:JG(t)}function QG(e,t){let n={};e.enabled!==t.enabled&&(n.enabled=t.enabled),e.httpPort!==t.httpPort&&(n.httpPort=t.httpPort),e.httpsPort!==t.httpsPort&&(n.httpsPort=t.httpsPort),e.email!==t.email&&(n.email=t.email),e.staging!==t.staging&&(n.staging=t.staging);let r=UG(t.resolvers);return(e.dns01.enabled!==t.dns01||e.dns01.resolvers.join(`,`)!==r.join(`,`))&&(n.dns01={enabled:t.dns01,resolvers:r}),n}function $G(e,t,n){let r=QG(e,t),i=ZG(e.routes,n);return i!==null&&(r.routes=i),Object.keys(r).length===0?null:r}function eK(e,t){return e.staging||e.email.trim().length>0?!1:t.some(e=>e.tls!==`off`&&zG(e.host))}function tK(e){return e.find(e=>e.tls!==`off`&&zG(e.host))?.host??null}function nK(e,t){let n=e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40).replace(/-+$/,``);return n.length===0?t:/^[a-z0-9]/.test(n)?n:`r-${n}`}function rK(e,t){let n=new Set(t);if(!n.has(e))return e;let r=2;for(;n.has(`${e}-${r}`);)r+=1;return`${e}-${r}`}function iK(e){return nK(e,`route`)}function aK(e,t){return rK(e,t)}function oK(e){return nK(e,`certificate`)}function sK(e,t){return rK(e,t)}function cK(){return{key:RG(),id:`route`,host:``,enabled:!0,target:`server`,workspace:``,server:``,url:``,path:``,tls:`auto`,dnsAccount:``}}function lK(e){let t=e.trim();if(t.length===0)return null;let n=IG.exec(t)?.groups?.authority;if(n===void 0||n.length===0)return null;let r=n.lastIndexOf(`:`);if(r<=0||r===n.length-1)return null;let i=n.slice(r+1);return/^\d{1,5}$/.test(i)?{host:n.slice(0,r),port:i}:null}function uK(e,t){let n={},r=e.host.trim();if(r.length===0?n.host=`a hostname is required`:wG.test(r)?t.others.some(t=>t.host.trim().toLowerCase()===r.toLowerCase()&&t.path===e.path)&&(n.host=`"${r}" is already routed for this path`):n.host=`a hostname of letters, digits, dots and dashes, e.g. home.example.com`,e.path.length>0&&!e.path.startsWith(`/`)?n.path=`a path prefix starts with /`:/\s/.test(e.path)&&(n.path=`a path prefix cannot contain a space`),CG.test(e.id)?t.others.some(t=>t.id===e.id)&&(n.id=`route id "${e.id}" is used twice`):n.id=`the id must start with a letter or digit, then letters, digits, dash or underscore`,e.target===`server`){let r=t.workspaces.find(t=>t.id===e.workspace);e.workspace.length===0||r===void 0?n.workspace=`pick the workspace that owns the server`:(e.server.length===0||!r.servers.some(t=>t.id===e.server))&&(n.server=`pick a server in that workspace`)}e.target===`external`&&lK(e.url)===null&&(n.url=`an upstream like http://10.0.0.5:8080`);let i=qA({...qG(e),host:r});return i instanceof Y.errors&&Object.keys(n).length===0&&(n.form=i.summary),n}function dK(e,t){return e.target===`panel`?`control panel`:e.target===`external`?e.url.trim().length>0?e.url.trim():`no upstream`:e.workspace.length===0||e.server.length===0?`no server picked`:`${t.find(t=>t.id===e.workspace)?.label??e.workspace} / ${e.server}`}function fK(e){return e.tls===`off`?`plain HTTP`:e.tls===`manual`?`uploaded certificate`:zG(e.host)?`Let’s Encrypt`:`engine CA (local)`}function pK(e){if(e===null||e<=0)return`—`;let t=[`B`,`KiB`,`MiB`,`GiB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n.toFixed(r===0?0:1)} ${t[r]}`}var mK={class:`grid gap-3 sm:grid-cols-2`},hK={class:`grid gap-3 sm:grid-cols-2`},gK={class:`flex min-w-0 flex-col gap-1`},_K={class:`flex min-w-0 flex-col gap-1`},vK=P({__name:`CertificateDialog`,props:Ra({taken:{},busy:{type:Boolean},error:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:Ra([`submit`],[`update:open`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`open`),a=A(``),o=A(``),s=A(``),c=A(``),l=A({}),u=A(!1),d=Q(HL,`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`),f=G(()=>sK(oK(a.value),n.taken)),p=G(()=>!n.busy&&a.value.trim().length>0&&s.value.trim().length>0&&c.value.trim().length>0);function m(e){o.value=e,u.value=e.trim().length>0}N([a,()=>n.taken],()=>{u.value||(o.value=f.value)},{immediate:!0}),N(i,e=>{e&&(a.value=``,o.value=``,s.value=``,c.value=``,l.value={},u.value=!1)});async function h(e,t){let n=e.target.files?.[0];if(!n)return;let r=await n.text();t===`cert`?s.value=r:c.value=r}function g(){let e=a.value.trim(),t=o.value.trim(),i={};e.length===0&&(i.label=`a label is required`),CG.test(t)?n.taken.includes(t)&&(i.id=`"${t}" is already used by another certificate`):i.id=`the id must start with a letter or digit, then letters, digits, dash or underscore`,s.value.trim().length===0&&(i.certificate=`paste or choose the certificate`),c.value.trim().length===0&&(i.privateKey=`paste or choose the private key`),l.value=i,!(Object.keys(i).length>0)&&r(`submit`,{id:t,label:e,certificate:s.value,privateKey:c.value})}return(e,t)=>(R(),B(vR,{open:i.value,"onUpdate:open":t[6]||=e=>i.value=e,title:`Add a certificate`,description:`The pair is stored on disk under its id, and a route set to “Uploaded certificate” can serve it.`},{footer:M(()=>[H($,{variant:`ghost`,disabled:n.busy,onClick:t[5]||=e=>i.value=!1},{default:M(()=>[...t[7]||=[U(` Cancel `,-1)]]),_:1},8,[`disabled`]),H($,{variant:`primary`,disabled:!p.value,loading:n.busy,onClick:g},{default:M(()=>[...t[8]||=[U(` Store the certificate `,-1)]]),_:1},8,[`disabled`,`loading`])]),default:M(()=>[V(`form`,{class:`space-y-3`,onSubmit:cu(g,[`prevent`])},[V(`div`,mK,[H(iR,{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Label`,placeholder:`Home wildcard`,error:l.value.label},null,8,[`modelValue`,`error`]),H(iR,{"model-value":o.value,label:`Id`,hint:`names the files on disk`,error:l.value.id,"onUpdate:modelValue":m},null,8,[`model-value`,`error`])]),V(`div`,hK,[V(`div`,gK,[V(`label`,{class:O(j(BL)),for:`proxy-cert-file`},`Certificate file (.pem, .crt)`,2),V(`input`,{id:`proxy-cert-file`,type:`file`,accept:`.pem,.crt,.cer,text/plain`,class:O(j(d)),onChange:t[1]||=e=>h(e,`cert`)},null,34)]),V(`div`,_K,[V(`label`,{class:O(j(BL)),for:`proxy-cert-key`},`Private key file (.pem, .key)`,2),V(`input`,{id:`proxy-cert-key`,type:`file`,accept:`.pem,.key,text/plain`,class:O(j(d)),onChange:t[2]||=e=>h(e,`key`)},null,34)])]),H(SR,{modelValue:s.value,"onUpdate:modelValue":t[3]||=e=>s.value=e,label:`Or paste the certificate`,rows:4,placeholder:`-----BEGIN CERTIFICATE-----`,error:l.value.certificate},null,8,[`modelValue`,`error`]),H(SR,{modelValue:c.value,"onUpdate:modelValue":t[4]||=e=>c.value=e,label:`Or paste the private key`,rows:4,placeholder:`-----BEGIN PRIVATE KEY-----`,error:l.value.privateKey},null,8,[`modelValue`,`error`]),n.error?(R(),B(xB,{key:0,tone:`danger`},{default:M(()=>[U(k(n.error),1)]),_:1})):W(``,!0)],32)]),_:1},8,[`open`]))}}),yK={key:0,class:`sm:col-span-2`},bK={key:1,class:`space-y-2 sm:col-span-2`},xK={class:`flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`},SK={class:`min-w-0 text-xs font-medium text-ink`},CK={class:`ml-1.5 font-mono text-2xs text-faint`},wK={key:0,class:`mt-2`},TK={key:1,class:`mt-2 divide-y divide-line-soft text-2xs`},EK={class:`flex items-start justify-between gap-4 py-1`},DK={class:`min-w-0 text-right font-mono text-ink`},OK={class:`flex items-start justify-between gap-4 py-1`},kK={class:`min-w-0 text-right font-mono text-ink`},AK={class:`flex items-start justify-between gap-4 py-1`},jK={class:`font-mono text-ink`},MK={class:`flex items-start justify-between gap-4 py-1`},NK={class:`min-w-0 text-right font-mono text-ink`},PK={key:1,class:`text-faint`},FK={class:`mt-2 flex justify-end`},IK={class:`text-xs font-semibold text-ink`},LK={class:`mt-2.5 flex justify-end gap-1.5`},RK={key:2,class:`space-y-2 sm:col-span-2`},zK=P({__name:`CertificatePanel`,props:{certificates:{},disabled:{type:Boolean}},emits:[`changed`],setup(e,{emit:t}){let n=e,r=t,i=A(!1),a=A(!1),o=A(null),s=A(null),c=A(null),l=G(()=>n.certificates.map(e=>e.id));async function u(e,t){a.value=!0,o.value=null,s.value=null;try{return r(`changed`,await e()),s.value=t,!0}catch(e){return o.value=e instanceof Error?e.message:String(e),!1}finally{a.value=!1}}async function d(e){await u(()=>qM(e.id,e.label,e.certificate,e.privateKey),`“${e.label}” stored.`)&&(i.value=!1)}function f(e){c.value=null,u(()=>JM(e.id),`“${FG(e)}” removed.`)}return(e,t)=>(R(),B(IL,{title:`Uploaded certificates`,description:`Served by routes set to “Uploaded certificate”. Everything else — public or local — is certified by the engine on its own.`},{actions:M(()=>[H($,{size:`xs`,variant:`secondary`,disabled:n.disabled||a.value,onClick:t[0]||=e=>i.value=!0},{default:M(()=>[H(j(_y),{class:`size-3.5`}),t[3]||=U(` Add certificate `,-1)]),_:1},8,[`disabled`])]),default:M(()=>[n.certificates.length===0?(R(),z(`div`,yK,[H(rI,{compact:``,title:`No certificate uploaded`,description:`A route set to “Uploaded certificate” needs a pair covering its hostname, or the engine has nothing to serve for it.`},{icon:M(()=>[H(j(ry),{class:`size-5`})]),action:M(()=>[H($,{variant:`primary`,disabled:n.disabled||a.value,onClick:t[1]||=e=>i.value=!0},{default:M(()=>[...t[4]||=[U(` Add a certificate `,-1)]]),_:1},8,[`disabled`])]),_:1})])):(R(),z(`ul`,bK,[(R(!0),z(L,null,F(n.certificates,e=>(R(),z(`li`,{key:e.id,class:`rounded-panel border border-line bg-page/40 p-3`},[V(`div`,xK,[V(`p`,SK,[U(k(j(FG)(e))+` `,1),V(`span`,CK,k(e.id),1)]),e.daysRemaining===null?W(``,!0):(R(),z(`span`,{key:0,class:O([`text-2xs tabular-nums`,e.daysRemaining<14?`text-warn`:`text-faint`])},k(e.daysRemaining)+` days left `,3))]),e.error?(R(),z(`div`,wK,[H(xB,{tone:`danger`},{default:M(()=>[U(k(e.error),1)]),_:2},1024)])):(R(),z(`dl`,TK,[V(`div`,EK,[t[5]||=V(`dt`,{class:`text-muted`},` Subject `,-1),V(`dd`,DK,k(e.subject??`—`),1)]),V(`div`,OK,[t[6]||=V(`dt`,{class:`text-muted`},` Issuer `,-1),V(`dd`,kK,k(e.issuer??`—`),1)]),V(`div`,AK,[t[7]||=V(`dt`,{class:`text-muted`},` Valid until `,-1),V(`dd`,jK,k(e.validTo?e.validTo.slice(0,10):`—`),1)]),V(`div`,MK,[t[8]||=V(`dt`,{class:`shrink-0 text-muted`},` Covers `,-1),V(`dd`,NK,[e.hosts.length>0?(R(),z(L,{key:0},[U(k(e.hosts.join(`, `)),1)],64)):(R(),z(`span`,PK,`no hostnames in its SANs`))])])])),V(`div`,FK,[H(j(Uh),{open:c.value===e.id,"onUpdate:open":t=>c.value=t?e.id:null},{default:M(()=>[H(j(Xh),{"as-child":``},{default:M(()=>[H($,{size:`xs`,variant:`danger-ghost`,disabled:a.value,"aria-label":`Remove ${j(FG)(e)}`},{default:M(()=>[H(j(Fy),{class:`size-3.5`}),t[9]||=U(` Remove `,-1)]),_:1},8,[`disabled`,`aria-label`])]),_:2},1024),H(j(Yh),null,{default:M(()=>[H(j(Jh),{"side-offset":6,align:`end`,class:O(j(Q)(`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(()=>[V(`p`,IK,` Remove “`+k(j(FG)(e))+`”? `,1),t[12]||=V(`p`,{class:`mt-1 text-2xs leading-4 text-muted`},` The pair is deleted from disk. A route still set to “Uploaded certificate” keeps serving the engine's own certificate until you change it, and the panel refuses this while one still serves it. `,-1),V(`div`,LK,[H(j(Wh),{"as-child":``},{default:M(()=>[H($,{size:`xs`,variant:`ghost`},{default:M(()=>[...t[10]||=[U(` Keep it `,-1)]]),_:1})]),_:1}),H($,{size:`xs`,variant:`danger`,loading:a.value,onClick:t=>f(e)},{default:M(()=>[...t[11]||=[U(` Remove it `,-1)]]),_:1},8,[`loading`,`onClick`])])]),_:2},1032,[`class`])]),_:2},1024)]),_:2},1032,[`open`,`onUpdate:open`])])]))),128))])),o.value||s.value?(R(),z(`div`,RK,[o.value?(R(),B(xB,{key:0,tone:`danger`},{default:M(()=>[U(k(o.value),1)]),_:1})):W(``,!0),s.value?(R(),B(xB,{key:1,tone:`ok`},{default:M(()=>[U(k(s.value),1)]),_:1})):W(``,!0)])):W(``,!0),H(vK,{open:i.value,"onUpdate:open":t[2]||=e=>i.value=e,taken:l.value,busy:a.value,error:o.value,onSubmit:d},null,8,[`open`,`taken`,`busy`,`error`])]),_:1}))}}),BK={key:0,class:`sm:col-span-2`},VK={key:0,class:`sm:col-span-2`},HK={key:1,class:`sm:col-span-2`},UK={class:`divide-y divide-line-soft text-xs sm:col-span-2`},WK={class:`flex items-start justify-between gap-4 py-1.5`},GK={class:`font-mono text-xs text-ink`},KK={class:`flex items-start justify-between gap-4 py-1.5`},qK={class:`text-right text-xs text-ink`},JK={key:0,class:`flex items-start justify-between gap-4 py-1.5`},YK={class:`font-mono text-xs tabular-nums text-ink`},XK={key:1,class:`flex items-start justify-between gap-4 py-1.5`},ZK={class:`flex min-w-0 items-center gap-1.5`},QK={class:`min-w-0 truncate font-mono text-2xs text-ink`},$K={class:`flex items-start justify-between gap-4 py-1.5`},eq={class:`flex flex-wrap items-center justify-end gap-x-2 gap-y-1 text-right font-mono text-xs`},tq=[`href`],nq={key:0,class:`text-ink`},rq={class:`flex items-start justify-between gap-4 py-1.5`},iq={class:`font-mono text-xs tabular-nums text-ink`},aq={class:`flex items-start justify-between gap-4 py-1.5`},oq={class:`text-xs text-ink`},sq={class:`flex flex-wrap gap-1.5 sm:col-span-2`},cq=[`href`],lq={key:3,class:`sm:col-span-2`},uq={key:4,class:`text-2xs leading-4 text-faint sm:col-span-2`},dq={class:`rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},fq={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},pq=P({__name:`EnginePanel`,props:{view:{},busy:{}},emits:[`act`],setup(e,{emit:t}){let n=e,r=t,i=G(()=>n.view?.engine??null),a=G(()=>n.view?.status??null),o=G(()=>n.view?.engines[0]??null),s=G(()=>a.value===null?null:kG[a.value.state]),c=G(()=>i.value?.installed===!0),l=G(()=>i.value?.path??null),u=G(()=>l.value===null?null:`sudo setcap 'cap_net_bind_service=+ep' ${l.value}`),d=[{key:`acme`,label:`ACME certificates`},{key:`internalCa`,label:`Local CA`},{key:`dns01`,label:`DNS-01`},{key:`tcp`,label:`TCP/UDP`}];return(e,t)=>(R(),B(IL,{title:`Engine`,description:`The reverse proxy itself. The panel downloads the current build, supervises it and applies its configuration through the engine's own admin API.`},{actions:M(()=>[s.value?(R(),B(_V,{key:0,tone:s.value.tone,dot:``},{default:M(()=>[U(k(s.value.label),1)]),_:1},8,[`tone`])):W(``,!0)]),default:M(()=>[i.value===null?(R(),z(`div`,BK,[H(xB,{tone:`info`},{default:M(()=>[...t[6]||=[U(` The proxy state is not in this panel's frame yet. `,-1)]]),_:1})])):(R(),z(L,{key:1},[i.value.error?(R(),z(`div`,VK,[H(xB,{tone:`danger`,title:`The engine could not be read`},{default:M(()=>[U(k(i.value.error),1)]),_:1})])):W(``,!0),c.value?(R(),z(L,{key:2},[V(`dl`,UK,[V(`div`,WK,[t[7]||=V(`dt`,{class:`text-muted`},` Version `,-1),V(`dd`,GK,k(i.value.version??`not probed yet`),1)]),V(`div`,KK,[t[8]||=V(`dt`,{class:`text-muted`},` Source `,-1),V(`dd`,qK,k(i.value.source===`custom`?`a path configured by hand`:`downloaded by the panel`),1)]),i.value.bytes===null?W(``,!0):(R(),z(`div`,JK,[t[9]||=V(`dt`,{class:`text-muted`},` Size `,-1),V(`dd`,YK,k(j(pK)(i.value.bytes)),1)])),l.value?(R(),z(`div`,XK,[t[10]||=V(`dt`,{class:`text-muted`},` Binary `,-1),V(`dd`,ZK,[V(`span`,QK,k(l.value),1),H(hV,{value:l.value,label:`Copy the binary path`},null,8,[`value`])])])):W(``,!0),V(`div`,$K,[t[11]||=V(`dt`,{class:`text-muted`},` Live address `,-1),V(`dd`,eq,[(R(!0),z(L,null,F(a.value?.urls??[],e=>(R(),z(`a`,{key:e,href:e,target:`_blank`,rel:`noreferrer`,class:`text-accent underline decoration-line underline-offset-2 hover:decoration-accent`},k(e),9,tq))),128)),!a.value||a.value.urls.length===0?(R(),z(`span`,nq,`—`)):W(``,!0)])]),V(`div`,rq,[t[12]||=V(`dt`,{class:`text-muted`},` Process `,-1),V(`dd`,iq,k(a.value?.pid??`—`),1)]),V(`div`,aq,[t[13]||=V(`dt`,{class:`text-muted`},` Certificates `,-1),V(`dd`,oq,k(a.value?.certExpiryDays===null||a.value?.certExpiryDays===void 0?`no public certificate yet`:`soonest expires in ${a.value.certExpiryDays} days`),1)])]),V(`div`,sq,[(R(),z(L,null,F(d,e=>H(_V,{key:e.key,tone:o.value?.[e.key]?`ok`:`neutral`},{default:M(()=>[U(k(o.value?.[e.key]?`✓`:`✗`)+` `+k(e.label),1)]),_:2},1032,[`tone`])),64)),o.value?(R(),z(`a`,{key:0,class:`ml-1 self-center text-2xs text-accent underline decoration-line underline-offset-2`,href:o.value.docsUrl,target:`_blank`,rel:`noreferrer`},k(o.value.label)+` documentation`,9,cq)):W(``,!0)])],64)):(R(),z(`div`,HK,[H(xB,{tone:`info`,title:`No engine installed`},{default:M(()=>[U(` Installing downloads the current `+k(o.value?.label??i.value.id)+` release the panel supervises — about 46 MB, once. Nothing is exposed until a route is added and the proxy is switched on. `,1)]),_:1})])),a.value?.lastError?(R(),z(`div`,lq,[H(xB,{tone:`danger`,title:`The engine reported a failure`},{default:M(()=>[U(k(a.value.lastError),1)]),_:1})])):W(``,!0),c.value&&u.value?(R(),z(`p`,uq,[t[14]||=U(` A privileged port (below 1024) needs this once on Linux: `,-1),V(`code`,dq,k(u.value),1),H(hV,{value:u.value,label:`Copy the command`,class:`ml-1 align-middle`},null,8,[`value`])])):W(``,!0)],64)),V(`div`,fq,[c.value?(R(),z(L,{key:1},[H($,{variant:`primary`,disabled:n.busy!==null||a.value?.state===`running`,loading:n.busy===`start`,onClick:t[1]||=e=>r(`act`,`start`)},{default:M(()=>[...t[16]||=[U(` Start `,-1)]]),_:1},8,[`disabled`,`loading`]),H($,{variant:`secondary`,disabled:n.busy!==null||a.value?.state===`off`||a.value?.state===`stopped`,loading:n.busy===`stop`,onClick:t[2]||=e=>r(`act`,`stop`)},{default:M(()=>[...t[17]||=[U(` Stop `,-1)]]),_:1},8,[`disabled`,`loading`]),H($,{variant:`secondary`,disabled:n.busy!==null||a.value?.state!==`running`,loading:n.busy===`apply`,onClick:t[3]||=e=>r(`act`,`apply`)},{default:M(()=>[...t[18]||=[U(` Apply configuration `,-1)]]),_:1},8,[`disabled`,`loading`]),H($,{variant:`ghost`,disabled:n.busy!==null||a.value?.state!==`running`,loading:n.busy===`revert`,title:`Go back to the configuration that applied before the last one`,onClick:t[4]||=e=>r(`act`,`revert`)},{default:M(()=>[...t[19]||=[U(` Revert `,-1)]]),_:1},8,[`disabled`,`loading`]),H($,{variant:`ghost`,disabled:n.busy!==null,loading:n.busy===`install`,onClick:t[5]||=e=>r(`act`,`install`)},{default:M(()=>[...t[20]||=[U(` Update engine `,-1)]]),_:1},8,[`disabled`,`loading`])],64)):(R(),B($,{key:0,variant:`primary`,loading:n.busy===`install`,disabled:n.busy!==null,onClick:t[0]||=e=>r(`act`,`install`)},{default:M(()=>[...t[15]||=[U(` Install engine `,-1)]]),_:1},8,[`loading`,`disabled`]))])]),_:1}))}}),mq={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},hq={key:0,class:`text-2xs text-faint`},gq={key:0,class:`sm:col-span-2`},_q={key:0,class:`rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},vq={key:1},yq={key:1,class:`sm:col-span-2`},bq={key:3,class:`sm:col-span-2`},xq={key:4,class:`sm:col-span-2`},Sq={key:5,class:`text-2xs leading-4 text-faint sm:col-span-2`},Cq=P({__name:`ListenerPanel`,props:Ra({emailHost:{},enginePath:{},dnsAccounts:{}},{form:{required:!0},formModifiers:{}}),emits:[`update:form`],setup(e){let t=e,n=oo(e,`form`),r=G(()=>t.dnsAccounts.filter(e=>e.writesTxt&&e.hasCredentials)),i=G(()=>VG(n.value)),a=G(()=>t.enginePath===null?null:`sudo setcap 'cap_net_bind_service=+ep' ${t.enginePath}`),o=G(()=>BG(n.value.httpPort)||BG(n.value.httpsPort));function s(){n.value.httpPort=xG,n.value.httpsPort=SG}function c(){n.value.httpPort=80,n.value.httpsPort=443}return(e,l)=>(R(),B(IL,{title:`Listener & certificates`,description:`Where the proxy listens. 80 and 443 are what a router forwards and what an ACME challenge expects; a port below 1024 needs a privileged bind.`},{actions:M(()=>[i.value?(R(),B(_V,{key:0,tone:`info`},{default:M(()=>[...l[7]||=[U(` unprivileged ports `,-1)]]),_:1})):W(``,!0)]),default:M(()=>[H(oR,{modelValue:n.value.enabled,"onUpdate:modelValue":l[0]||=e=>n.value.enabled=e,label:`Run the reverse proxy`,hint:`Saved with Save settings; the panel starts or stops the engine to match.`,wide:``},null,8,[`modelValue`]),H(qL,{modelValue:n.value.httpPort,"onUpdate:modelValue":l[1]||=e=>n.value.httpPort=e,label:`HTTP port`,min:1,max:65535,hint:`ACME HTTP-01 challenges and the redirect to HTTPS.`},null,8,[`modelValue`]),H(qL,{modelValue:n.value.httpsPort,"onUpdate:modelValue":l[2]||=e=>n.value.httpsPort=e,label:`HTTPS port`,min:1,max:65535,hint:`Where certificates are served.`},null,8,[`modelValue`]),V(`div`,mq,[H($,{size:`xs`,variant:`secondary`,onClick:s},{default:M(()=>[U(` Use `+k(j(xG))+` / `+k(j(SG)),1)]),_:1}),H($,{size:`xs`,variant:`ghost`,onClick:c},{default:M(()=>[...l[8]||=[U(` Use 80 / 443 `,-1)]]),_:1}),i.value?(R(),z(`span`,hq,` Running unprivileged — forward 80 and 443 to these ports on your router. `)):W(``,!0)]),o.value?(R(),z(`div`,gq,[H(xB,{tone:`warn`,title:`A port below 1024 needs a privileged bind`},{default:M(()=>[l[10]||=U(` Running the panel as your own user cannot bind 80 or 443 without permission. Either grant it once `,-1),a.value?(R(),z(`code`,_q,k(a.value),1)):(R(),z(`span`,vq,[...l[9]||=[U(`with `,-1),V(`code`,{class:`rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},`setcap`,-1),U(` on the engine binary`,-1)]])),a.value?(R(),B(hV,{key:2,value:a.value,label:`Copy the command`,class:`ml-1 align-middle`},null,8,[`value`])):W(``,!0),U(` and restart the engine, or keep `+k(j(xG))+`/`+k(j(SG))+` and forward 80/443 from your router. On Windows the port is free to bind, but something else may hold it. `,1)]),_:1})])):W(``,!0),H(iR,{modelValue:n.value.email,"onUpdate:modelValue":l[3]||=e=>n.value.email=e,label:`ACME account e-mail`,placeholder:`you@example.com`,hint:`Let's Encrypt uses it to warn you about an expiring certificate. A local-only name gets the engine's own CA and needs none.`,wide:``},null,8,[`modelValue`]),t.emailHost===null?W(``,!0):(R(),z(`div`,yq,[H(xB,{tone:`warn`,title:`An e-mail is needed for automatic HTTPS`},{default:M(()=>[U(` “`+k(t.emailHost)+`” is a public hostname, so the engine asks a CA for a certificate and the account address is required. Fill it in, switch the route's TLS off, or turn on the staging endpoint while you try things out. `,1)]),_:1})])),H(oR,{modelValue:n.value.staging,"onUpdate:modelValue":l[4]||=e=>n.value.staging=e,label:`Use the ACME staging endpoint`,hint:`Untrusted certificates and no rate-limit burn while you try things out.`,wide:``},null,8,[`modelValue`]),H(oR,{modelValue:n.value.dns01,"onUpdate:modelValue":l[5]||=e=>n.value.dns01=e,label:`Answer challenges with DNS-01`,hint:`The panel writes the challenge record through a route's DNS account, so no inbound port is needed to get a certificate.`,wide:``},null,8,[`modelValue`]),n.value.dns01?(R(),B(iR,{key:2,modelValue:n.value.resolvers,"onUpdate:modelValue":l[6]||=e=>n.value.resolvers=e,label:`Check the record against`,placeholder:`1.1.1.1, 8.8.8.8`,hint:`Nameservers the engine reads the record from; empty uses its own. Needed where split-horizon DNS shows it a different view.`,spellcheck:`false`,wide:``},null,8,[`modelValue`])):W(``,!0),n.value.dns01&&r.value.length===0?(R(),z(`div`,bq,[H(xB,{tone:`warn`,title:`No DNS account can answer a challenge`},{default:M(()=>[...l[11]||=[U(` DNS-01 is on, but no account has credentials it can use. Add one under Workspace Settings → Dynamic DNS, or public names stay on the port challenges and wait for a CA that cannot reach them. `,-1)]]),_:1})])):n.value.dns01&&r.value.length>1?(R(),z(`div`,xq,[H(xB,{tone:`info`,title:`Each public route has to pick an account`},{default:M(()=>[...l[12]||=[U(` More than one account can answer, so “Automatic” cannot choose. Pick one per route, or those names stay on the port challenges. `,-1)]]),_:1})])):W(``,!0),n.value.dns01?(R(),z(`p`,Sq,` Each route picks its own account, so names in different zones each get the right one. A route left on “Automatic” uses the only account the table names. A name no account answers stays on the port challenges. `)):W(``,!0),l[13]||=V(`p`,{class:`text-2xs leading-4 text-faint sm:col-span-2`},` A public name whose certificate is still being issued is reachable in the meantime — over HTTPS with a temporary untrusted certificate, or over plain HTTP with a page naming the ports to forward. `,-1)]),_:1}))}}),wq={class:`space-y-3`},Tq={key:1,class:`text-2xs leading-4 text-faint sm:col-span-2`},Eq={key:4,class:`text-2xs leading-4 text-warn sm:col-span-2`},Dq=P({__name:`RouteDialog`,props:Ra({draft:{},others:{},workspaces:{},dnsAccounts:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:Ra([`save`],[`update:open`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`open`),a=A(cK()),o=A({}),s=G(()=>n.draft!==null),c=G(()=>(n.workspaces.find(e=>e.id===a.value.workspace)?.servers??[]).map(e=>({value:e.id,label:e.id}))),l=G(()=>a.value.tls===`off`?`Plain HTTP: no certificate is served for this hostname.`:a.value.tls===`manual`?`Serves the certificate pair uploaded below.`:a.value.host.trim().length===0?`A public hostname gets an ACME certificate; a local-only name gets the engine’s own CA.`:zG(a.value.host)?`A public hostname, so the engine asks a CA for a certificate — an ACME account e-mail is needed.`:`A local-only name, so the engine signs it with its own locally-trusted CA.`),u=G(()=>a.value.tls===`auto`&&zG(a.value.host)),d=G(()=>WG(n.dnsAccounts)),f=G(()=>n.dnsAccounts.find(e=>`${e.workspace}/${e.account}`===a.value.dnsAccount)),p=G(()=>f.value===void 0?a.value.dnsAccount.length>0?`That account is no longer configured.`:`DNS-01 writes the challenge record here. Empty uses the only account that can answer a challenge, when there is one.`:f.value.writesTxt?f.value.hasCredentials?`The challenge is written through this ${f.value.provider} account.`:`No credentials are stored for this ${f.value.provider} account yet.`:`A ${f.value.provider} account cannot write TXT records, so it cannot answer a DNS-01 challenge.`);N(i,e=>{e&&(a.value=n.draft===null?cK():structuredClone(un(n.draft)),a.value.workspace.length===0&&(a.value.workspace=n.workspaces[0]?.id??``),o.value={})}),N(()=>a.value.workspace,()=>{c.value.some(e=>e.value===a.value.server)||(a.value.server=c.value[0]?.value??``)});function m(){let e=a.value.host.trim().toLowerCase(),t={...a.value,host:e,id:aK(iK(e),n.others.map(e=>e.id)),workspace:a.value.target===`server`?a.value.workspace:``,server:a.value.target===`server`?a.value.server:``,url:a.value.target===`external`?a.value.url.trim():``},s=uK(t,{others:n.others,workspaces:n.workspaces});o.value=s,!(Object.keys(s).length>0)&&(r(`save`,t),i.value=!1)}return(e,t)=>(R(),B(vR,{open:i.value,"onUpdate:open":t[9]||=e=>i.value=e,title:s.value?`Edit route`:`Add route`,description:`A hostname, what it forwards to, and how it is served over TLS.`,width:`w-[min(92vw,34rem)]`},{footer:M(()=>[H($,{size:`sm`,variant:`ghost`,onClick:t[8]||=e=>i.value=!1},{default:M(()=>[...t[11]||=[U(` Cancel `,-1)]]),_:1}),H($,{size:`sm`,variant:`primary`,onClick:m},{default:M(()=>[U(k(s.value?`Save route`:`Add route`),1)]),_:1})]),default:M(()=>[V(`div`,wq,[H(iR,{modelValue:a.value.host,"onUpdate:modelValue":t[0]||=e=>a.value.host=e,label:`Hostname`,placeholder:`gitea.example.com`,autocomplete:`off`,spellcheck:`false`,error:o.value.host,wide:``},null,8,[`modelValue`,`error`]),H(iR,{modelValue:a.value.path,"onUpdate:modelValue":t[1]||=e=>a.value.path=e,label:`Path prefix`,placeholder:`/optional`,hint:`Empty serves the whole host.`,spellcheck:`false`,error:o.value.path,wide:``},null,8,[`modelValue`,`error`]),H($L,{modelValue:a.value.target,"onUpdate:modelValue":t[2]||=e=>a.value.target=e,label:`Target`,options:j(DG)},null,8,[`modelValue`,`options`]),H($L,{modelValue:a.value.tls,"onUpdate:modelValue":t[3]||=e=>a.value.tls=e,label:`TLS`,options:j(OG),hint:l.value},null,8,[`modelValue`,`options`,`hint`]),u.value?(R(),B($L,{key:0,modelValue:a.value.dnsAccount,"onUpdate:modelValue":t[4]||=e=>a.value.dnsAccount=e,label:`DNS account`,options:d.value,hint:p.value},null,8,[`modelValue`,`options`,`hint`])):a.value.tls===`auto`?(R(),z(`p`,Tq,` A local-only name is signed by the engine's own CA, so no DNS account is involved. `)):W(``,!0),a.value.target===`server`?(R(),z(L,{key:2},[H($L,{modelValue:a.value.workspace,"onUpdate:modelValue":t[5]||=e=>a.value.workspace=e,label:`Workspace`,options:n.workspaces.map(e=>({value:e.id,label:e.label})),error:o.value.workspace},null,8,[`modelValue`,`options`,`error`]),H($L,{modelValue:a.value.server,"onUpdate:modelValue":t[6]||=e=>a.value.server=e,label:`Server`,options:c.value,disabled:c.value.length===0,error:o.value.server??(c.value.length===0?`this workspace has no servers`:null)},null,8,[`modelValue`,`options`,`disabled`,`error`]),t[10]||=V(`p`,{class:`text-2xs leading-4 text-faint sm:col-span-2`},` A server that is stopped is not routed: the row shows “No upstream” until it runs again. `,-1)],64)):W(``,!0),a.value.target===`external`?(R(),B(iR,{key:3,modelValue:a.value.url,"onUpdate:modelValue":t[7]||=e=>a.value.url=e,label:`Upstream`,placeholder:`http://10.0.0.5:8080`,hint:`A literal address, including the port. A scheme is optional.`,spellcheck:`false`,error:o.value.url,wide:``},null,8,[`modelValue`,`error`])):W(``,!0),a.value.target===`panel`?(R(),z(`p`,Eq,` Serving the control panel needs authentication on and a password that is not the default — the panel refuses the save otherwise. `)):W(``,!0),o.value.form?(R(),B(xB,{key:5,tone:`danger`},{default:M(()=>[U(k(o.value.form),1)]),_:1})):W(``,!0)])]),_:1},8,[`open`,`title`]))}}),Oq={class:`text-xs font-semibold text-ink`},kq={class:`mt-1 text-2xs leading-4 text-muted`},Aq={class:`mt-2.5 flex justify-end gap-1.5`},jq=P({__name:`RetryCertificateButton`,props:{host:{},retryIn:{},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)=>(R(),B(j(Uh),{open:i.value,"onUpdate:open":t[0]||=e=>i.value=e},{default:M(()=>[H(j(Xh),{"as-child":``},{default:M(()=>[H($,{size:`xs`,variant:`secondary`,loading:n.busy,disabled:n.busy},{default:M(()=>[...t[1]||=[U(` Force retry certificate `,-1)]]),_:1},8,[`loading`,`disabled`])]),_:1}),H(j(Yh),null,{default:M(()=>[H(j(Jh),{"side-offset":6,align:`end`,class:`z-50 w-72 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(()=>[V(`p`,Oq,` Ask the CA again for `+k(n.host)+`? `,1),V(`p`,kq,` The engine failed to obtain a CA certificate for this hostname previously and is using its local CA. It retries automatically every `+k(n.retryIn)+`. `,1),t[4]||=V(`p`,{class:`mt-1 text-2xs leading-4 text-warn`},` Retrying now will kill this route and make it unavailable for a bit, are you sure to continue? `,-1),V(`div`,Aq,[H(j(Wh),{"as-child":``},{default:M(()=>[H($,{size:`xs`,variant:`ghost`},{default:M(()=>[...t[2]||=[U(` Leave it `,-1)]]),_:1})]),_:1}),H($,{size:`xs`,variant:`primary`,loading:n.busy,onClick:a},{default:M(()=>[...t[3]||=[U(` Retry now `,-1)]]),_:1},8,[`loading`])])]),_:1})]),_:1})]),_:1},8,[`open`]))}}),Mq={key:0,class:`sm:col-span-2`},Nq={class:`list-disc space-y-0.5 pl-4`},Pq={key:1,class:`sm:col-span-2`},Fq={key:2,class:`overflow-x-auto sm:col-span-2`},Iq={class:`w-full text-left text-xs`},Lq={class:`py-1.5 pr-3`},Rq={class:`font-mono text-xs text-ink`},zq=[`href`,`title`],Bq={key:2,class:`text-accent`},Vq={class:`font-mono text-2xs text-faint`},Hq={class:`py-1.5 pr-3 text-2xs text-muted`},Uq={class:`py-1.5 pr-3 font-mono text-2xs text-muted`},Wq={class:`py-1.5 pr-3 text-2xs text-muted`},Gq={key:0,class:`mt-0.5`},Kq={key:1,class:`mt-1`},qq={class:`py-1.5 pr-3`},Jq={class:`py-1.5 pr-3`},Yq={class:`py-1.5`},Xq={class:`flex items-center justify-end gap-1`},Zq=P({__name:`RouteTable`,props:{routes:{},views:{},workspaces:{},httpPort:{},httpsPort:{},disabled:{type:Boolean}},emits:[`add`,`edit`,`remove`,`retry`,`toggle`],setup(e,{emit:t}){let n=e,r=t;function i(e){return e===`fallback`}let a=G(()=>n.routes.map(e=>{let t=n.views.find(t=>t.route.id===e.id)??null;return{route:e,view:t,meta:t===null?null:AG[t.status],target:dK(e,n.workspaces),tls:fK(e),certificate:t===null?null:PG(t),url:MG(e,n.httpPort,n.httpsPort)}})),o=G(()=>a.value.filter(e=>e.view?.status===`error`));return(e,t)=>(R(),B(IL,{title:`Routes`,description:`One public hostname per service. A route may point at a supervised server in any workspace, at this panel, or at a literal upstream.`},{actions:M(()=>[H($,{size:`xs`,variant:`secondary`,disabled:n.disabled,onClick:t[0]||=e=>r(`add`)},{default:M(()=>[H(j(_y),{class:`size-3.5`}),t[2]||=U(` Add route `,-1)]),_:1},8,[`disabled`])]),default:M(()=>[o.value.length>0?(R(),z(`div`,Mq,[H(xB,{tone:`danger`,title:`These routes cannot be saved as they stand`},{default:M(()=>[V(`ul`,Nq,[(R(!0),z(L,null,F(o.value,e=>(R(),z(`li`,{key:e.route.id},k(e.view?.message??`${e.route.host} cannot be routed`),1))),128))])]),_:1})])):W(``,!0),a.value.length===0?(R(),z(`div`,Pq,[H(rI,{compact:``,title:`No routes yet`,description:`Add one to expose a server through a domain — the engine gets the certificate on its own.`},{icon:M(()=>[H(j(Ly),{class:`size-5`})]),action:M(()=>[H($,{variant:`primary`,disabled:n.disabled,onClick:t[1]||=e=>r(`add`)},{default:M(()=>[...t[3]||=[U(` Add the first route `,-1)]]),_:1},8,[`disabled`])]),_:1})])):(R(),z(`div`,Fq,[V(`table`,Iq,[t[5]||=V(`thead`,null,[V(`tr`,{class:`text-2xs text-faint`},[V(`th`,{class:`py-1 pr-3 font-medium`},` Hostname `),V(`th`,{class:`py-1 pr-3 font-medium`},` Target `),V(`th`,{class:`py-1 pr-3 font-medium`},` Upstream `),V(`th`,{class:`py-1 pr-3 font-medium`},` TLS `),V(`th`,{class:`py-1 pr-3 font-medium`},` State `),V(`th`,{class:`py-1 pr-3 font-medium`},` On `),V(`th`,{class:`py-1 font-medium`},[V(`span`,{class:`sr-only`},`Actions`)])])],-1),V(`tbody`,null,[(R(!0),z(L,null,F(a.value,e=>(R(),z(`tr`,{key:e.route.key,class:`border-t border-line-soft align-top`},[V(`td`,Lq,[V(`p`,Rq,[e.url!==null&&e.route.enabled?(R(),z(`a`,{key:0,href:e.url,target:`_blank`,rel:`noopener noreferrer`,class:`transition-colors duration-150 hover:text-accent hover:underline`,title:`Open ${e.url} in a new tab`},k(e.route.host),9,zq)):(R(),z(L,{key:1},[U(k(e.route.host.trim().length>0?e.route.host:`no hostname yet`),1)],64)),e.route.path.length>0?(R(),z(`span`,Bq,k(e.route.path),1)):W(``,!0)]),V(`p`,Vq,k(e.route.id),1)]),V(`td`,Hq,k(e.target),1),V(`td`,Uq,k(e.view?.upstream??`—`),1),V(`td`,Wq,[U(k(e.tls)+` `,1),e.certificate?(R(),z(`div`,Gq,[H(_V,{tone:e.certificate.tone,dot:``},{default:M(()=>[U(k(e.certificate.label),1)]),_:2},1032,[`tone`]),e.certificate.message?(R(),z(`p`,{key:0,class:O([`mt-0.5 text-2xs`,e.certificate.tone===`danger`?`text-danger`:`text-faint`])},k(e.certificate.message),3)):W(``,!0),i(e.view?.certificate?.state)?(R(),z(`div`,Kq,[H(jq,{host:e.route.host,"retry-in":j(NG)(e.certificate?.retryInMinutes??null),busy:n.disabled,onConfirm:t=>r(`retry`,e.route)},null,8,[`host`,`retry-in`,`busy`,`onConfirm`])])):W(``,!0)])):W(``,!0)]),V(`td`,qq,[e.meta?(R(),B(_V,{key:0,tone:e.meta.tone,dot:``},{default:M(()=>[U(k(e.meta.label),1)]),_:2},1032,[`tone`])):(R(),B(_V,{key:1,tone:`info`,dot:``},{default:M(()=>[...t[4]||=[U(` Not applied yet `,-1)]]),_:1})),e.view?.message?(R(),z(`p`,{key:2,class:O([`mt-0.5 text-2xs`,e.view.status===`error`?`text-danger`:`text-warn`])},k(e.view.message),3)):W(``,!0)]),V(`td`,Jq,[H(oR,{"model-value":e.route.enabled,label:`Route ${e.route.host||e.route.id}`,"sr-only":``,disabled:n.disabled,"onUpdate:modelValue":t=>r(`toggle`,e.route,t)},null,8,[`model-value`,`label`,`disabled`,`onUpdate:modelValue`])]),V(`td`,Yq,[V(`span`,Xq,[H($,{size:`xs`,variant:`ghost`,disabled:n.disabled,"aria-label":`Edit ${e.route.host||e.route.id}`,onClick:t=>r(`edit`,e.route)},{default:M(()=>[H(j(hy),{class:`size-3.5`})]),_:1},8,[`disabled`,`aria-label`,`onClick`]),H($,{size:`xs`,variant:`danger-ghost`,disabled:n.disabled,"aria-label":`Remove ${e.route.host||e.route.id}`,onClick:t=>r(`remove`,e.route)},{default:M(()=>[H(j(Fy),{class:`size-3.5`})]),_:1},8,[`disabled`,`aria-label`,`onClick`])])])]))),128))])])]))]),_:1}))}}),Qq={class:`min-h-full`},$q={class:`mx-auto w-full max-w-5xl px-4 pb-6 pt-5 sm:px-6`},eJ={key:2,class:`space-y-6`},tJ={key:0,class:`sticky bottom-0 z-30 border-t border-line bg-panel/95 backdrop-blur`},nJ={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`},rJ={class:`min-w-0 flex-1`},iJ={class:`text-xs text-muted`},aJ={class:`font-mono tabular-nums text-ink`},oJ={key:0,class:`mt-0.5 text-xs text-danger`},sJ={key:1,class:`mt-0.5 text-xs text-danger`},cJ={key:2,class:`mt-0.5 text-xs text-ok`},lJ={class:`flex shrink-0 items-center gap-2`},uJ=P({__name:`ProxyView`,setup(e){let t=WN(),n=dN(),r=A(null),i=A(null),a=A(null),o=A(!1),s=A(null),c=A({enabled:!1,httpPort:80,httpsPort:443,email:``,staging:!1,dns01:!1,resolvers:``}),l=A([]),u=A(!1),d=A(null),f=G(()=>t.proxy.value??r.value),p=G(()=>f.value?.config??null),m=G(()=>f.value?.engine.path??null),h=G(()=>t.workspaces.value.map(e=>({id:e.id,label:e.label,servers:e.servers.map(e=>({id:e.id}))}))),g=G(()=>eK(c.value,l.value)?tK(l.value):null),_=G(()=>p.value!==null&&ZG(p.value.routes,l.value)!==null),v=G(()=>{if(p.value===null)return 0;let e=$G(p.value,c.value,l.value);return e===null?0:Object.keys(e).filter(e=>e!==`routes`).length+(e.routes===void 0?0:1)}),y=G(()=>(f.value?.routes??[]).filter(e=>e.status===`error`)),b=G(()=>_.value?[]:y.value.map(e=>e.message??`${e.route.host} cannot be routed`)),x={};function S(){let e=p.value;if(e===null)return;mL(x.listener,{...c.value})||(Object.assign(c.value,GG(e)),x.listener={...c.value});let t=JG(l.value);mL(x.routes,t)||(l.value=KG(e.routes),x.routes=JG(l.value))}N(f,S,{immediate:!0});async function C(){i.value=null;try{r.value=await RM()}catch(e){i.value=e instanceof Error?e.message:String(e)}}ta(()=>{t.proxy.value===null&&C()});let w={install:()=>VM(),start:UM,stop:WM,apply:GM,revert:KM},T={install:`Engine installed`,start:`Engine starting`,stop:`Engine stopping`,apply:`Configuration applied`,revert:`Configuration reverted`};async function ee(e){if(s.value===null){s.value=e,a.value=null;try{r.value=await w[e](),n.success(T[e]),await t.refresh()}catch(e){a.value=e instanceof Error?e.message:String(e)}finally{s.value=null}}}let E=A(null),te=A(null);async function ne(){let e=p.value,i=e===null?null:$G(e,c.value,l.value);if(!(i===null||o.value||b.value.length>0)){o.value=!0,E.value=null,te.value=null;try{r.value=await zM(i),await t.refresh(),te.value=`Settings saved.`,n.success(`Settings saved`),delete x.listener,delete x.routes,S()}catch(e){E.value=e instanceof Error?e.message:String(e)}finally{o.value=!1}}}function re(){E.value=null,te.value=null,delete x.listener,delete x.routes,S()}function ie(){d.value=null,u.value=!0}function ae(e){d.value=e,u.value=!0}function oe(e){l.value=d.value===null?[...l.value,e]:l.value.map(t=>t.key===d.value?.key?e:t),d.value=null}function se(e){l.value=l.value.filter(t=>t.key!==e.key)}async function ce(e){s.value=`apply`;try{r.value=await BM(e.id),await t.refresh(),n.success(`asking the CA again for ${e.host}`)}catch(e){n.failure(`the retry failed`,e instanceof Error?e.message:String(e))}finally{s.value=null}}function D(e,t){e.enabled=t}async function le(e){r.value=e,await t.refresh()}return(e,t)=>(R(),z(`div`,Qq,[V(`div`,$q,[t[3]||=V(`header`,{class:`mb-5`},[V(`h1`,{class:`text-xl font-semibold tracking-tight text-ink`},` Reverse Proxy `),V(`p`,{class:`mt-1 text-xs text-muted`},` Expose your servers through domains, with automatic HTTPS via 80/443 or a DNS challenge. `),V(`p`,{class:`mt-1 text-2xs leading-4 text-faint`},` For DNS-01, add the domain's DNS provider to any workspace under Workspace Settings → Dynamic DNS; a route can then pick that account, from any workspace. `)],-1),i.value?(R(),B(xB,{key:0,tone:`danger`,title:`The reverse proxy could not be read`,class:`mb-4`},{default:M(()=>[U(k(i.value),1)]),_:1})):W(``,!0),f.value===null&&i.value===null?(R(),B(xB,{key:1,tone:`info`,class:`mb-4`},{default:M(()=>[...t[2]||=[U(` Reading the reverse proxy… `,-1)]]),_:1})):W(``,!0),f.value===null?W(``,!0):(R(),z(`div`,eJ,[H(pq,{view:f.value,busy:s.value,onAct:ee},null,8,[`view`,`busy`]),a.value?(R(),B(xB,{key:0,tone:`danger`},{default:M(()=>[U(k(a.value),1)]),_:1})):W(``,!0),H(Cq,{form:c.value,"onUpdate:form":t[0]||=e=>c.value=e,"engine-path":m.value,"email-host":g.value,"dns-accounts":f.value?.dnsAccounts??[]},null,8,[`form`,`engine-path`,`email-host`,`dns-accounts`]),H(Zq,{routes:l.value,views:f.value.routes,workspaces:h.value,"http-port":f.value.config.httpPort,"https-port":f.value.config.httpsPort,disabled:o.value,onAdd:ie,onEdit:ae,onRemove:se,onRetry:ce,onToggle:D},null,8,[`routes`,`views`,`workspaces`,`http-port`,`https-port`,`disabled`]),H(zK,{certificates:f.value.certificates,disabled:o.value,onChanged:le},null,8,[`certificates`,`disabled`])]))]),f.value===null?W(``,!0):(R(),z(`div`,tJ,[V(`div`,nJ,[V(`div`,rJ,[V(`p`,iJ,[v.value>0?(R(),z(L,{key:0},[V(`span`,aJ,k(v.value),1),U(` field`+k(v.value===1?``:`s`)+` changed `,1)],64)):(R(),z(L,{key:1},[U(` No unsaved changes `)],64))]),b.value.length>0?(R(),z(`p`,oJ,k(b.value.join(` · `)),1)):E.value?(R(),z(`p`,sJ,k(E.value),1)):te.value?(R(),z(`p`,cJ,k(te.value),1)):W(``,!0)]),V(`div`,lJ,[H($,{variant:`ghost`,disabled:v.value===0||o.value,onClick:re},{default:M(()=>[...t[4]||=[U(` Discard changes `,-1)]]),_:1},8,[`disabled`]),H($,{variant:`primary`,disabled:v.value===0||b.value.length>0,loading:o.value,onClick:ne},{default:M(()=>[...t[5]||=[U(` Save settings `,-1)]]),_:1},8,[`disabled`,`loading`])])])])),H(Dq,{open:u.value,"onUpdate:open":t[1]||=e=>u.value=e,draft:d.value,others:l.value.filter(e=>e.key!==d.value?.key),workspaces:h.value,"dns-accounts":f.value?.dnsAccounts??[],onSave:oe},null,8,[`open`,`draft`,`others`,`workspaces`,`dns-accounts`])]))}}),dJ={class:`mb-4 flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`},fJ={class:`flex items-center gap-2`},pJ={class:`font-mono tabular-nums`},mJ={key:1,class:`text-2xs text-faint`},hJ={class:`flex flex-col gap-3`},gJ={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`},_J={class:`mt-4 flex items-center justify-end gap-2 border-t border-line pt-3.5`},vJ={class:`max-h-[60dvh] overflow-auto`},yJ={key:0,class:`divide-y divide-line-soft`},bJ={class:`font-mono text-xs text-ink`},xJ={class:`ml-auto font-mono text-xs text-muted line-through`},SJ={class:`font-mono text-xs text-accent`},CJ={key:1,class:`text-xs text-muted`},wJ=P({__name:`ServerConfigEditor`,props:{serverId:{},workspaceId:{},config:{}},emits:[`saved`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=[`restart`,`health`,`stop`],a=WN(),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
+ `),env:xL(e.env),dataEnvs:xL(e.dataEnvs),backupPaths:e.backupPaths.join(`
44
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:vL(e.bootstrap?.env??{}),bootstrapTimeoutMs:e.bootstrap?.timeoutMs??12e4,bootstrapRunOnce:e.bootstrap?.runOnce??!0}}let u=en(l(n.config)),d=A({...n.config.restart}),f=A(JI(n.config.health)),p=A({...n.config.stop}),m=G(()=>{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:_L(u.args),env:yL(u.env),dataEnvs:yL(u.dataEnvs),backupPaths:_L(u.backupPaths),backupIgnoreGenerated:u.backupIgnoreGenerated,dependsOn:bL(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:JI(f.value),stop:{...p.value},bootstrap:u.bootstrapEnabled?{command:u.bootstrapCommand.trim(),args:_L(u.bootstrapArgs),env:yL(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 BI(n.config,e)}function v(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}let y=G(()=>_(h())),b=G(()=>UI(y.value)),x=G(()=>b.value>0),S=G(()=>HI(y.value,n.config)),C=A(!1),w=T(n.config);function T(e){return JSON.parse(JSON.stringify(e))}function ee(e){Object.assign(u,l(e)),d.value={...e.restart},f.value=JI(e.health),p.value={...e.stop},w=T(e),s.value=null}N(()=>n.config,e=>{v(e,w)||ee(e)});async function E(){s.value=null,o.value=!0;try{let e=h(),t=RA(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.workspaceId,n.serverId,i),a.lastError.value!==null){s.value=a.lastError.value;return}r(`saved`)}finally{o.value=!1}}return(e,t)=>(R(),z(L,null,[V(`form`,{class:`border-t border-line bg-page/40 px-4 py-4`,onSubmit:cu(E,[`prevent`])},[V(`header`,Yq,[t[32]||=V(`div`,{class:`min-w-0`},[V(`h2`,{class:`text-sm font-semibold text-ink`},` Edit configuration `),V(`p`,{class:`mt-0.5 text-2xs leading-4 text-muted`},[U(` Writes overrides to `),V(`span`,{class:`font-mono`},`servers.config.json`),U(`; anything left alone keeps inheriting the defaults. `)])],-1),V(`div`,Xq,[b.value>0?(R(),z(`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},[V(`span`,Zq,k(b.value),1),U(` unsaved `+k(b.value===1?`change`:`changes`),1)])):(R(),z(`span`,Qq,`in sync`))])]),V(`div`,$q,[H(NL,{title:`Process`,description:`What gets spawned, where, and with which environment.`,columns:2},{default:M(()=>[H(tR,{modelValue:u.label,"onUpdate:modelValue":t[1]||=e=>u.label=e,label:`Label`,placeholder:`falls back to the id`},null,8,[`modelValue`]),H(tR,{modelValue:u.command,"onUpdate:modelValue":t[2]||=e=>u.command=e,label:`Command`,placeholder:`node`,required:``,class:`font-mono text-xs`},null,8,[`modelValue`]),H(tR,{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`]),H(tR,{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`]),H(yR,{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`]),H(yR,{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`]),H(yR,{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`]),H(yR,{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`]),H(rR,{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`]),H(tR,{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`]),H(WL,{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}),H(NL,{title:`Port & binding`,description:`How the port is preflighted and where the process is reachable.`,columns:2},{default:M(()=>[H(WL,{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`]),H(XL,{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`]),H(XL,{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`]),H(WL,{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}),H(NL,{title:`Lifecycle`,description:`Whether the supervisor owns this entry at all.`,columns:3},{default:M(()=>[H(rR,{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`]),H(rR,{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`]),H(rR,{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}),H(iR,{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`]),H(NL,{title:`Bootstrap`,description:`A one-off command run before the first start — installs, migrations, downloads.`,columns:2},{default:M(()=>[H(rR,{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?(R(),z(L,{key:0},[H(tR,{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`]),H(WL,{modelValue:u.bootstrapTimeoutMs,"onUpdate:modelValue":t[24]||=e=>u.bootstrapTimeoutMs=e,label:`Timeout (ms)`,min:1e3,step:1e3},null,8,[`modelValue`]),H(rR,{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)):W(``,!0),u.bootstrapEnabled?(R(),B(yR,{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`])):W(``,!0),u.bootstrapEnabled?(R(),B(yR,{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`])):W(``,!0)]),_:1})]),s.value?(R(),z(`p`,eJ,k(s.value),1)):W(``,!0),V(`div`,tJ,[H($,{variant:`ghost`,onClick:t[28]||=e=>r(`cancel`)},{default:M(()=>[...t[33]||=[U(` Cancel `,-1)]]),_:1}),H($,{type:`submit`,variant:`primary`,disabled:o.value||!x.value,loading:o.value},{default:M(()=>[...t[34]||=[U(` Save to servers.config.json `,-1)]]),_:1},8,[`disabled`,`loading`])])],32),H(hR,{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(()=>[H($,{size:`sm`,variant:`ghost`,onClick:t[29]||=e=>C.value=!1},{default:M(()=>[...t[36]||=[U(` Close `,-1)]]),_:1}),H($,{size:`sm`,variant:`primary`,disabled:S.value.length===0||o.value,loading:o.value,onClick:t[30]||=e=>{E(),C.value=!1}},{default:M(()=>[U(` Save `+k(S.value.length)+` change`+k(S.value.length===1?``:`s`),1)]),_:1},8,[`disabled`,`loading`])]),default:M(()=>[V(`div`,nJ,[S.value.length>0?(R(),z(`ul`,rJ,[(R(!0),z(L,null,F(S.value,e=>(R(),z(`li`,{key:e.path,class:`flex flex-wrap items-baseline gap-x-3 gap-y-1 py-2 first:pt-0`},[V(`code`,iJ,k(e.path),1),V(`span`,aJ,k(j(uI)(e.from)),1),t[35]||=V(`span`,{class:`text-2xs text-faint`},`→`,-1),V(`span`,oJ,k(j(uI)(e.to)),1)]))),128))])):(R(),z(`p`,sJ,` Nothing to save. `))])]),_:1},8,[`open`])],64))}}),lJ={key:0,class:`mx-auto max-w-3xl p-4 sm:p-5`},uJ={key:1,class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},dJ={class:`font-mono text-xs text-faint`},fJ=[`href`],pJ={class:`px-2 py-1.5`},mJ={class:`flex flex-col gap-0.5`},hJ=[`onClick`],gJ={class:`space-y-2`},_J={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`},vJ={class:`min-w-0 flex-1 text-2xs leading-4 text-danger`},yJ={key:1,class:`rounded-control border border-warn/25 bg-warn-soft px-3 py-2 text-2xs leading-4 text-warn`},bJ={class:`grid grid-cols-2 gap-x-4 gap-y-3 p-4 sm:grid-cols-4 lg:grid-cols-6`},xJ={class:`truncate text-2xs text-faint`},SJ={class:`truncate font-mono text-xs tabular-nums text-ink capitalize`},CJ={class:`grid gap-4 sm:grid-cols-3`},wJ={class:`flex items-center justify-between gap-3`},TJ=[`title`],EJ={key:1,class:`space-y-4`},DJ={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`},OJ={key:1,class:`grid grid-cols-1 gap-x-6 gap-y-2 sm:grid-cols-2`},kJ={class:`text-2xs text-faint`},AJ=[`title`],jJ={key:2,class:`grid gap-4 lg:grid-cols-3`},MJ={key:0,class:`flex flex-wrap gap-1.5`},NJ={key:1,class:`text-xs text-muted`},PJ=P({__name:`ServerDetailView`,setup(e){let t=Rg(),n=VN(),r=nP(),i=G(()=>String(t.params.id??``));N([i,()=>n.appState.value],()=>{let e=i.value;if(e.length===0||r.serverById(e)!==void 0)return;let t=n.workspaces.value.filter(t=>t.servers.some(t=>t.id===e));t.length===1&&r.select(t[0].id)},{immediate:!0});let a=G(()=>r.serverById(i.value)),o=G(()=>a.value?.config),s=G(()=>{let e=o.value;return e?.label&&e.label.length>0?e.label:i.value}),c=A(`output`),l=A(!1),u=A(!1),d=A(!1),f=A(!1),p=BN(r.activeId,()=>a.value?i.value:null),m=p.version,h=G(()=>(m.value,p.lines())),g=G(()=>r.seriesOf(i.value)),_=n.now,v=G(()=>g.value.cpu),y=G(()=>g.value.rss),b=G(()=>g.value.probe),x=G(()=>{let e=a.value;return!e||e.startedAt===null||e.status!==`running`?`—`:rI(_.value-e.startedAt)}),S=G(()=>a.value?.status===`running`),C=G(()=>{let e=a.value;if(!e)return[];let t=[{key:`pid`,label:`PID`,value:e.pid===null?`—`:String(e.pid)},{key:`uptime`,label:`Uptime`,value:x.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:cI(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:aI(e.history.uptimeRatio)},{key:`crashes`,label:`24h crashes`,value:String(e.history.crashes)},{key:`lastcrash`,label:`Last crash`,value:oI(e.history.lastCrashAt,_.value)}];return e.nextRetryAt!==null&&t.push({key:`retry`,label:`Next attempt`,value:iI(e.nextRetryAt,_.value)}),e.unhealthySince!==null&&t.push({key:`unhealthy`,label:`Unhealthy for`,value:rI(_.value-e.unhealthySince)}),t}),w=G(()=>JSON.stringify(o.value??{},null,2)),T=G(()=>o.value?`${o.value.command} ${o.value.args.join(` `)}`.trim():``),ee=G(()=>{let e=o.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){f.value=!0;try{await n[e](r.activeId.value,i.value)}finally{f.value=!1}}async function te(){d.value=!1,await r.removeServer(i.value)}async function ne(){let e=a.value;if(e){f.value=!0;try{await r.freePort(e.id)}finally{f.value=!1}}}let re=G(()=>mM(r.activeId.value,i.value,`${i.value}.log`)),ie=[{value:`output`,label:`Live output`},{value:`config`,label:`Configuration`},{value:`history`,label:`History`}];return(e,t)=>{let n=fa(`RouterLink`);return a.value?(R(),z(`div`,uJ,[H(Oz,{title:s.value,"back-to":j(_X)(j(r).activeId.value,`servers`),"back-label":`All servers`},{badges:M(()=>[H(qR,{status:a.value.status,health:a.value.health},null,8,[`status`,`health`]),a.value.adopted?(R(),B(JR,{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]||=[V(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`detached`,-1)]]),_:1})):W(``,!0),a.value.config.persistent?(R(),B(JR,{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]||=[V(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`persistent`,-1)]]),_:1})):W(``,!0),V(`span`,dJ,k(a.value.id),1),a.value.url?(R(),z(`a`,{key:2,href:a.value.url,target:`_blank`,rel:`noreferrer`,class:`inline-flex items-center gap-1 font-mono text-xs text-accent hover:underline`},[U(k(a.value.url)+` `,1),H(j(Xv),{class:`size-3`})],8,fJ)):W(``,!0)]),actions:M(()=>[H($,{variant:`primary`,disabled:f.value||!o.value?.enabled||[`running`,`starting`].includes(a.value.status),onClick:t[0]||=e=>E(`start`)},{default:M(()=>[H(j(gy),{class:`size-3.5`}),t[18]||=U(`Start `,-1)]),_:1},8,[`disabled`]),H($,{disabled:f.value||a.value.status===`stopped`,onClick:t[1]||=e=>E(`stop`)},{default:M(()=>[H(j(Ay),{class:`size-3.5`}),t[19]||=U(`Stop `,-1)]),_:1},8,[`disabled`]),H($,{disabled:f.value||!o.value?.enabled,onClick:t[2]||=e=>E(`restart`)},{default:M(()=>[H(j(xy),{class:`size-3.5`}),t[20]||=U(`Restart `,-1)]),_:1},8,[`disabled`]),H(JR,{label:`Edit every field of this entry`},{default:M(()=>[H($,{variant:l.value?`secondary`:`ghost`,onClick:t[3]||=e=>{l.value=!l.value,c.value=`config`}},{default:M(()=>[H(j(hy),{class:`size-3.5`}),U(k(l.value?`Close editor`:`Edit`),1)]),_:1},8,[`variant`])]),_:1}),H(j($h),null,{default:M(()=>[H(j(ig),{"as-child":``},{default:M(()=>[H($,{variant:`ghost`,size:`icon-sm`,"aria-label":`More actions for ${s.value}`},{default:M(()=>[H(j(Yv),{class:`size-4`})]),_:1},8,[`aria-label`])]),_:1}),H(j(ng),null,{default:M(()=>[H(j(eg),{"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(()=>[H(j(tg),{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(r).setEnabled(a.value.id,!a.value.config.enabled)},{default:M(()=>[U(k(o.value?.enabled?`Disable server`:`Enable server`),1)]),_:1}),H(j(tg),{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(r).setAutostart(a.value.id,!a.value.config.autostart)},{default:M(()=>[U(k(o.value?.autostart?`Remove from autostart`:`Autostart with the panel`),1)]),_:1}),H(j(rg),{class:`my-1 h-px bg-line`}),V(`div`,pJ,[t[21]||=V(`p`,{class:`mb-1 text-2xs text-faint`},` Bind `,-1),V(`div`,mJ,[(R(!0),z(L,null,F(ee.value,e=>(R(),z(`button`,{key:e.value,type:`button`,class:O([`rounded-control px-2 py-1 text-left font-mono text-2xs transition-colors duration-150 hover:bg-hover`,e.value===o.value?.bind?`text-accent`:`text-muted`]),onClick:t=>j(r).setBind(a.value.id,e.value)},k(e.label),11,hJ))),128))])]),H(j(rg),{class:`my-1 h-px bg-line`}),H(j(tg),{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=>d.value=!0},{default:M(()=>[H(j(Fy),{class:`size-3.5`}),t[22]||=U(` Remove server `,-1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,[`title`,`back-to`]),V(`div`,gJ,[a.value.lastError?(R(),z(`div`,_J,[V(`p`,vJ,k(a.value.lastError),1),a.value.status===`conflict`&&a.value.config.port!==null?(R(),B(ER,{key:0,port:a.value.config.port,busy:f.value,onConfirm:ne},null,8,[`port`,`busy`])):W(``,!0)])):W(``,!0),a.value.health===`unhealthy`?(R(),z(`p`,yJ,[t[23]||=U(` The health probe has not passed `,-1),a.value.unhealthySince===null?W(``,!0):(R(),z(L,{key:0},[U(` for `+k(j(rI)(j(_)-a.value.unhealthySince)),1)],64)),t[24]||=U(`. `,-1)])):W(``,!0)]),H(Mz,{class:`p-0`},{default:M(()=>[V(`dl`,bJ,[(R(!0),z(L,null,F(C.value,e=>(R(),z(`div`,{key:e.key,class:`min-w-0`},[V(`dt`,xJ,k(e.label),1),V(`dd`,SJ,k(e.value),1)]))),128))])]),_:1}),H(Mz,null,{header:M(()=>[...t[25]||=[V(`h2`,{class:`text-sm font-semibold text-ink`},` Telemetry `,-1),V(`p`,{class:`text-2xs text-muted`},` Sampled every 5 s while this page is open. `,-1)]]),default:M(()=>[V(`div`,CJ,[H(UR,{label:`CPU`,values:v.value,format:j(lI),max:100,"color-class":`text-cpu`,height:40},null,8,[`values`,`format`]),H(UR,{label:`Memory (RSS)`,values:y.value,format:j(cI),"color-class":`text-mem`,height:40},null,8,[`values`,`format`]),H(UR,{label:`Health probe`,values:b.value,format:e=>e===null?`—`:`${e} ms`,"color-class":`text-probe`,height:40},null,8,[`values`,`format`])])]),_:1}),V(`div`,wJ,[H(oH,{modelValue:c.value,"onUpdate:modelValue":t[7]||=e=>c.value=e,options:ie,size:`md`},null,8,[`modelValue`]),V(`p`,{class:`hidden font-mono text-2xs text-faint sm:block`,title:T.value},k(T.value),9,TJ)]),c.value===`output`?(R(),B(DW,{key:0,lines:h.value,version:j(m),live:``,clearable:``,"download-url":a.value.config.logBufferLines>0?re.value:void 0,"download-name":`${a.value.id}.log`,"empty-hint":S.value?`Waiting for the first line…`:`This server has not written anything yet.`,"min-height":`22rem`,onClear:t[8]||=e=>j(r).clearLogs(a.value.id)},null,8,[`lines`,`version`,`download-url`,`download-name`,`empty-hint`])):c.value===`config`?(R(),z(`div`,EJ,[l.value?(R(),B(cJ,{key:0,"server-id":a.value.id,"workspace-id":j(r).activeId.value,config:a.value.config,onSaved:t[9]||=e=>l.value=!1,onCancel:t[10]||=e=>l.value=!1},null,8,[`server-id`,`workspace-id`,`config`])):(R(),B(Mz,{key:1},{header:M(()=>[...t[26]||=[V(`h2`,{class:`text-sm font-semibold text-ink`},` Effective configuration `,-1),V(`p`,{class:`text-2xs text-muted`},` Defaults from Settings are already merged into these values. `,-1)]]),actions:M(()=>[H($,{size:`xs`,variant:`ghost`,onClick:t[11]||=e=>u.value=!u.value},{default:M(()=>[H(j(Wv),{class:`size-3`}),U(k(u.value?`Fields`:`Raw JSON`),1)]),_:1}),H(fV,{value:w.value,label:`Copy the JSON config`},null,8,[`value`]),H($,{size:`xs`,variant:`primary`,onClick:t[12]||=e=>l.value=!0},{default:M(()=>[H(j(hy),{class:`size-3`}),t[27]||=U(`Edit `,-1)]),_:1})]),default:M(()=>[u.value?(R(),z(`pre`,DJ,k(w.value),1)):(R(),z(`dl`,OJ,[(R(!0),z(L,null,F([{label:`command`,value:o.value?.command},{label:`args`,value:o.value?.args.join(` `)||`—`},{label:`cwd`,value:o.value?.cwd},{label:`env`,value:Object.keys(o.value?.env??{}).join(`, `)||`—`},{label:`data envs`,value:Object.entries(o.value?.dataEnvs??{}).map(([e,t])=>`${e}=${t}`).join(`, `)||`—`},{label:`env file`,value:o.value?.envFile||`—`},{label:`port · bind`,value:`${o.value?.port??`none`} · ${o.value?.bind}`},{label:`on port conflict`,value:o.value?.onPortConflict},{label:`log buffer`,value:`${o.value?.logBufferLines} lines`},{label:`rtss limit`,value:o.value?.resources.maxRssBytes?j(cI)(o.value.resources.maxRssBytes):`none`},{label:`health`,value:o.value?.health.enabled?`${o.value.health.mode} every ${o.value.health.intervalMs} ms`:`off`},{label:`restart`,value:o.value?.restart.enabled?`${o.value.restart.maxRetries} retries, ×${o.value.restart.factor}`:`off`},{label:`stop`,value:o.value?`${o.value.stop.signal} after ${o.value.stop.graceMs} ms`:`—`},{label:`bootstrap`,value:o.value?.bootstrap?`${o.value.bootstrap.command} ${o.value.bootstrap.args.join(` `)}`:`none`},{label:`backup paths`,value:o.value?.backupPaths.join(`, `)||`—`},{label:`depends on`,value:o.value?.dependsOn.join(`, `)||`—`}],e=>(R(),z(`div`,{key:e.label,class:`min-w-0 border-b border-line-soft pb-1.5 last:border-0`},[V(`dt`,kJ,k(e.label),1),V(`dd`,{class:`truncate font-mono text-xs text-ink`,title:String(e.value)},k(e.value),9,AJ)]))),128))]))]),_:1}))])):(R(),z(`div`,jJ,[H(Mz,{class:`lg:col-span-2`},{header:M(()=>[...t[28]||=[V(`h2`,{class:`text-sm font-semibold text-ink`},` Event history `,-1),V(`p`,{class:`text-2xs text-muted`},` Kept by the panel for 24 hours. `,-1)]]),default:M(()=>[H(FI,{servers:[a.value],now:j(_),limit:30},null,8,[`servers`,`now`])]),_:1}),H(Mz,null,{header:M(()=>[...t[29]||=[V(`h2`,{class:`text-sm font-semibold text-ink`},` Dependencies `,-1)]]),default:M(()=>[o.value&&o.value.dependsOn.length>0?(R(),z(`div`,MJ,[(R(!0),z(L,null,F(o.value.dependsOn,e=>(R(),B(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(()=>[U(k(e),1)]),_:2},1032,[`to`]))),128))])):(R(),z(`p`,NJ,[...t[30]||=[U(` Starts on its own. Add ids under `,-1),V(`code`,null,`dependsOn`,-1),U(` to order it after other servers. `,-1)]]))]),_:1})])),H(hR,{open:d.value,"onUpdate:open":t[14]||=e=>d.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(()=>[H($,{variant:`ghost`,onClick:t[13]||=e=>d.value=!1},{default:M(()=>[...t[31]||=[U(` Keep it `,-1)]]),_:1}),H($,{variant:`danger`,onClick:te},{default:M(()=>[H(j(Fy),{class:`size-3.5`}),t[32]||=U(`Remove `,-1)]),_:1})]),default:M(()=>[t[33]||=V(`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`])])):(R(),z(`div`,lJ,[H(eI,{title:`That server is gone`,description:`${i.value} is not in servers.config.json any more. It may have been removed from another tab.`},{action:M(()=>[H(n,{to:j(_X)(j(r).activeId.value,`servers`)},{default:M(()=>[H($,{variant:`primary`},{default:M(()=>[...t[15]||=[U(` Back to servers `,-1)]]),_:1})]),_:1},8,[`to`])]),_:1},8,[`description`])]))}}}),FJ={class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},IJ={class:`flex flex-wrap items-center gap-2`},LJ={class:`relative ml-auto w-full sm:w-64`},RJ={key:0,class:`grid gap-4 lg:grid-cols-2`},zJ={key:3,class:`grid gap-4 lg:grid-cols-2`},BJ=P({__name:`ServersView`,setup(e){let t=VN(),n=nP(),{servers:r}=n,i=A(!1),a=A(``),o=A(`all`),s=[{value:`all`,label:`All`},{value:`running`,label:`Running`},{value:`stopped`,label:`Stopped`},{value:`attention`,label:`Attention`},{value:`disabled`,label:`Disabled`}],c=G(()=>t.appState.value===null),l=G(()=>{let e=a.value.trim().toLowerCase();return r.value.filter(t=>o.value===`running`&&t.status!==`running`||o.value===`stopped`&&![`stopped`,`stopping`].includes(t.status)||o.value===`disabled`&&t.config.enabled||o.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))}),u=G(()=>({all:r.value.length,running:r.value.filter(e=>e.status===`running`).length,attention:r.value.filter(e=>e.status===`crashed`||e.status===`conflict`||e.health===`unhealthy`).length}));return(e,d)=>(R(),z(`div`,FJ,[H(Oz,{title:`Servers`,description:`Every entry in ${j(n).selected.value?.label??`this workspace`}'s servers.config.json, with live resources, health and history.`},{actions:M(()=>[H($,{variant:`ghost`,onClick:d[0]||=e=>j(n).startAll()},{default:M(()=>[H(j(gy),{class:`size-3.5`}),d[9]||=U(`Start all `,-1)]),_:1}),H($,{variant:`ghost`,onClick:d[1]||=e=>j(n).stopAll()},{default:M(()=>[H(j(Ay),{class:`size-3.5`}),d[10]||=U(`Stop all `,-1)]),_:1}),H($,{variant:`primary`,onClick:d[2]||=e=>i.value=!0},{default:M(()=>[H(j(_y),{class:`size-3.5`}),d[11]||=U(`Add server `,-1)]),_:1})]),_:1},8,[`description`]),V(`div`,IJ,[H(oH,{modelValue:o.value,"onUpdate:modelValue":d[3]||=e=>o.value=e,options:s.map(e=>({...e,label:`${e.label}${e.value===`all`?` ${u.value.all}`:e.value===`running`?` ${u.value.running}`:e.value===`attention`&&u.value.attention>0?` ${u.value.attention}`:``}`}))},null,8,[`modelValue`,`options`]),V(`div`,LJ,[H(j(Cy),{class:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),xr(V(`input`,{"onUpdate:modelValue":d[4]||=e=>a.value=e,type:`search`,placeholder:`Filter by id, label, command or port`,class:O([`pl-8`,[j(zL)]]),"aria-label":`Filter servers`},null,2),[[ql,a.value]]),a.value.length>0?(R(),z(`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:d[5]||=e=>a.value=``},[H(j(Ry),{class:`size-3.5`})])):W(``,!0)])]),c.value?(R(),z(`div`,RJ,[(R(),z(L,null,F(4,e=>H(Nz,{key:e,class:`h-72 w-full`,rounded:`rounded-panel`})),64))])):j(r).length===0?(R(),B(eI,{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(()=>[H(j(wy),{class:`size-4`})]),action:M(()=>[H($,{variant:`primary`,onClick:d[6]||=e=>i.value=!0},{default:M(()=>[H(j(_y),{class:`size-3.5`}),d[12]||=U(`Add a server `,-1)]),_:1})]),_:1})):l.value.length===0?(R(),B(eI,{key:2,compact:``,title:`Nothing matches that filter`,description:`Try a different status or clear the search.`},{action:M(()=>[H($,{onClick:d[7]||=e=>{a.value=``,o.value=`all`}},{default:M(()=>[...d[13]||=[U(` Clear filters `,-1)]]),_:1})]),_:1})):(R(),z(`div`,zJ,[(R(!0),z(L,null,F(l.value,e=>(R(),B(xz,{key:e.id,server:e,"workspace-id":j(n).activeId.value,series:j(n).seriesOf(e.id),now:j(t).now.value},null,8,[`server`,`workspace-id`,`series`,`now`]))),128))])),H(CR,{open:i.value,"onUpdate:open":d[8]||=e=>i.value=e,"workspace-id":j(n).activeId.value},null,8,[`open`,`workspace-id`])]))}}),VJ=0;function HJ(){return VJ+=1,`ddns-row-${VJ}`}function UJ(){return HJ()}function WJ(e){let t=structuredClone(un(e));return t.domains=(t.domains??[]).map(e=>({...e,key:e.key??HJ()})),t}function GJ(e){let t=structuredClone(un(e));return{...t,domains:t.domains.map(({key:e,...t})=>t)}}function KJ(e,t){return e===null||t===null?e===t:JSON.stringify(GJ(e))===JSON.stringify(GJ(t))}var qJ={class:`space-y-3`},JJ={class:`rounded-panel border border-line bg-panel-2/40 p-3.5`},YJ={key:0,class:`divide-y divide-line-soft`},XJ={class:`min-w-0`},ZJ={class:`font-mono text-xs text-ink`},QJ={class:`text-2xs text-faint`},$J={key:0},eY={class:`ml-auto flex items-center gap-2`},tY={key:1,class:`text-2xs text-muted`},nY={class:`mt-3 grid gap-2 border-t border-line-soft pt-3 sm:grid-cols-[1fr_1fr_auto] sm:items-end`},rY={class:`rounded-panel border border-line bg-panel-2/40 p-3.5`},iY={key:0,class:`space-y-2`},aY={class:`flex flex-wrap items-end gap-2`},oY={class:`min-w-40 flex-1`},sY={class:`w-44 shrink-0`},cY={class:`mt-1 flex flex-wrap items-center gap-x-4 gap-y-1`},lY={key:1,class:`text-2xs text-muted`},uY={class:`mt-3 grid gap-2 border-t border-line-soft pt-3 sm:grid-cols-[1fr_1fr_auto] sm:items-end`},dY={key:1,class:`rounded-panel border border-line bg-panel-2/40 p-3.5`},fY={class:`mb-2 flex flex-wrap items-center gap-x-3 gap-y-1`},pY={key:0,class:`text-2xs text-muted`},mY={key:1,class:`font-mono text-2xs text-faint`},hY={key:2,class:`font-mono text-2xs text-faint`},gY={key:3,class:`ml-auto text-2xs text-faint`},_Y={class:`overflow-x-auto`},vY={class:`w-full text-left text-xs`},yY={class:`py-1.5 pr-3 font-mono text-2xs text-ink`},bY={class:`py-1.5 pr-3 text-2xs text-muted`},xY={class:`py-1.5 pr-3`},SY={class:`py-1.5 pr-3 font-mono text-2xs text-muted`},CY={class:`py-1.5 text-2xs text-faint`},wY={class:`space-y-3`},TY=[`href`],EY=P({__name:`DdnsSection`,props:{patch:{default:null},patchModifiers:{},baseline:{default:null},baselineModifiers:{}},emits:[`update:patch`,`update:baseline`],setup(e,{expose:t}){let n=oo(e,`patch`),r=oo(e,`baseline`),i={pending:{label:`Waiting`,tone:`neutral`},ok:{label:`Updated`,tone:`ok`},unchanged:{label:`Current`,tone:`neutral`},skipped:{label:`Skipped`,tone:`warn`},error:{label:`Failed`,tone:`danger`}},a=VN(),o=nP(),s=cN(),c=A(null),l=A(null),u=A(null),d=A(null),f=A(!1),p=en({id:``,provider:`cloudflare`}),m=en({host:``,account:``}),h=A(null),g=A({}),_=A(!1),v=A(null),y=G(()=>c.value?.providers??[]),b=G(()=>l.value?.accounts??[]),x=G(()=>l.value?.domains??[]),S=G(()=>b.value.map(e=>e.id).join(`,`)),C=G(()=>y.value.map(e=>({value:e.id,label:e.label}))),w=G(()=>b.value.map(e=>({value:e.id,label:e.id}))),T=G(()=>o.selected.value?.ddns??c.value?.status??null),ee=G(()=>l.value!==null&&r.value!==null&&!KJ(l.value,r.value)),E=G(()=>/^[a-z0-9][a-z0-9_-]*$/.test(p.id)&&!b.value.some(e=>e.id===p.id)),te=G(()=>m.host.includes(`.`)&&m.account.length>0&&!x.value.some(e=>e.host.toLowerCase()===m.host.trim().toLowerCase())),ne=G({get:()=>h.value!==null,set:e=>{e||(h.value=null)}}),re=G(()=>h.value===null?[]:ie(h.value.provider)?.fields??[]);function ie(e){return y.value.find(t=>t.id===e)??null}function ae(e){let t=b.value.find(t=>t.id===e.account);return t===void 0?null:ie(t.provider)}function oe(e){return ie(e.provider)?.label??e.provider}function se(e){return c.value?.credentials.includes(e)===!0}function ce(e){return x.value.filter(t=>t.account===e).length}function D(e,t,n){let r=n?[...new Set([...e.types,t])]:e.types.filter(e=>e!==t);e.types=r.length>0?r:e.types}function le(e,t,n){n==null||n===``?delete e[t]:e[t]=n}function ue(){n.value=l.value===null||r.value===null||KJ(l.value,r.value)?null:GJ(l.value)}function de(e,t=!1){c.value=e,r.value=WJ(e.config),t||(l.value=WJ(e.config)),ue()}async function fe(){u.value=null;try{de(await EM(o.activeId.value)),p.provider=C.value[0]?.value??`cloudflare`,m.account=b.value[0]?.id??``}catch(e){u.value=e instanceof Error?e.message:String(e)}}ta(()=>{fe()}),N(()=>o.activeId.value,(e,t)=>{e!==t&&e.length>0&&fe()}),N(l,ue,{deep:!0}),N(S,()=>{b.value.some(e=>e.id===m.account)||(m.account=b.value[0]?.id??``)});function pe(){E.value&&l.value!==null&&(l.value.accounts.push({id:p.id,provider:p.provider,label:``}),p.id=``)}function me(e){l.value===null||ce(e.id)>0||(l.value.accounts=l.value.accounts.filter(t=>t.id!==e.id))}function he(){te.value&&l.value!==null&&(l.value.domains.push({host:m.host.trim().toLowerCase(),account:m.account,types:[`A`],proxied:!1,enabled:!0,key:UJ()}),m.host=``)}function ge(e){l.value!==null&&(l.value.domains=l.value.domains.filter(t=>t!==e))}function _e(){r.value!==null&&(l.value=WJ(r.value)),d.value=null}async function ve(){if(!f.value){f.value=!0,d.value=null;try{de(await AM(o.activeId.value),!0),s.success(T.value?.lastResult??`Dynamic DNS pass finished`)}catch(e){d.value=e instanceof Error?e.message:String(e)}finally{f.value=!1}}}function ye(e){h.value=e,g.value=Object.fromEntries((ie(e.provider)?.fields??[]).map(e=>[e.key,``])),v.value=null}async function be(){let e=h.value;if(!(e===null||_.value)){_.value=!0,v.value=null;try{de(await OM(o.activeId.value,e.id,e.provider,g.value),!0),s.success(`Credentials saved for ${e.id}`),h.value=null}catch(e){v.value=e instanceof Error?e.message:String(e)}finally{_.value=!1}}}async function O(){let e=h.value;if(!(e===null||_.value)){_.value=!0,v.value=null;try{de(await kM(o.activeId.value,e.id),!0),s.success(`Credentials removed for ${e.id}`),h.value=null}catch(e){v.value=e instanceof Error?e.message:String(e)}finally{_.value=!1}}}return t({reload:fe}),(e,t)=>(R(),z(L,null,[V(`div`,qJ,[u.value?(R(),B(vB,{key:0,tone:`danger`,title:`Dynamic DNS settings could not be loaded`},{default:M(()=>[U(k(u.value),1)]),_:1})):W(``,!0),l.value===null?W(``,!0):(R(),z(L,{key:1},[H(NL,{title:`Dynamic DNS`,description:`Keep these hostnames pointed at this machine's public address. Credentials live in the secrets file, never in servers.config.json.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!ee.value,onClick:_e},{default:M(()=>[...t[11]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`]),T.value?.running?(R(),B(mV,{key:0,tone:`info`,dot:``},{default:M(()=>[...t[12]||=[U(` checking `,-1)]]),_:1})):T.value?.enabled?(R(),B(mV,{key:1,tone:T.value.records.some(e=>e.state===`error`)?`danger`:`ok`,dot:``},{default:M(()=>[U(k(T.value.records.some(e=>e.state===`error`)?`needs attention`:`watching`),1)]),_:1},8,[`tone`])):W(``,!0),H($,{size:`xs`,variant:`ghost`,loading:f.value,onClick:ve},{default:M(()=>[...t[13]||=[U(` Update now `,-1)]]),_:1},8,[`loading`])]),default:M(()=>[H(rR,{modelValue:l.value.enabled,"onUpdate:modelValue":t[0]||=e=>l.value.enabled=e,label:`Keep dynamic DNS updated`,hint:`A pass runs on the interval below; a provider is only called when the address actually changed.`,wide:``},null,8,[`modelValue`]),H(WL,{modelValue:l.value.intervalMs,"onUpdate:modelValue":t[1]||=e=>l.value.intervalMs=e,label:`Check every (ms)`,min:6e4,step:6e4,hint:`60000 is one minute; the default is five.`},null,8,[`modelValue`]),H(WL,{modelValue:l.value.ttl,"onUpdate:modelValue":t[2]||=e=>l.value.ttl=e,label:`TTL (s)`,min:1,hint:`1 means automatic where the provider supports it.`},null,8,[`modelValue`]),H(rR,{modelValue:l.value.ipv4.enabled,"onUpdate:modelValue":t[3]||=e=>l.value.ipv4.enabled=e,label:`Detect IPv4`,hint:`Needed for A records.`},null,8,[`modelValue`]),H(rR,{modelValue:l.value.ipv6.enabled,"onUpdate:modelValue":t[4]||=e=>l.value.ipv6.enabled=e,label:`Detect IPv6`,hint:`Needed for AAAA records.`},null,8,[`modelValue`])]),_:1}),d.value?(R(),B(vB,{key:0,tone:`danger`},{default:M(()=>[U(k(d.value),1)]),_:1})):W(``,!0),V(`section`,JJ,[t[17]||=V(`header`,{class:`mb-3`},[V(`h3`,{class:`text-xs font-semibold text-ink`},` Provider accounts `),V(`p`,{class:`mt-0.5 text-2xs leading-4 text-muted`},` One entry per API token. Credentials are stored on the server and never come back. `)],-1),b.value.length>0?(R(),z(`ul`,YJ,[(R(!0),z(L,null,F(b.value,e=>(R(),z(`li`,{key:e.id,class:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 first:pt-0`},[V(`div`,XJ,[V(`p`,ZJ,k(e.id),1),V(`p`,QJ,[U(k(oe(e))+` `,1),ce(e.id)>0?(R(),z(`span`,$J,` · `+k(ce(e.id))+` hostname`+k(ce(e.id)===1?``:`s`),1)):W(``,!0)])]),V(`div`,eY,[H(mV,{tone:se(e.id)?`ok`:`warn`,dot:``},{default:M(()=>[U(k(se(e.id)?`credentials saved`:`no credentials`),1)]),_:2},1032,[`tone`]),H($,{size:`xs`,variant:`secondary`,onClick:t=>ye(e)},{default:M(()=>[...t[14]||=[U(` Credentials `,-1)]]),_:1},8,[`onClick`]),H($,{size:`xs`,variant:`danger-ghost`,disabled:ce(e.id)>0,title:ce(e.id)>0?`Remove the hostnames using this account first`:void 0,onClick:t=>me(e)},{default:M(()=>[...t[15]||=[U(` Remove `,-1)]]),_:1},8,[`disabled`,`title`,`onClick`])])]))),128))])):(R(),z(`p`,tY,` No accounts yet. Pick a provider and add one. `)),V(`div`,nY,[H(XL,{modelValue:p.provider,"onUpdate:modelValue":t[5]||=e=>p.provider=e,label:`Provider`,options:C.value},null,8,[`modelValue`,`options`]),H(tR,{modelValue:p.id,"onUpdate:modelValue":t[6]||=e=>p.id=e,label:`Account id`,placeholder:`cloudflare-home`},null,8,[`modelValue`]),H($,{variant:`secondary`,disabled:!E.value,onClick:pe},{default:M(()=>[...t[16]||=[U(` Add `,-1)]]),_:1},8,[`disabled`])]),t[18]||=V(`p`,{class:`mt-1.5 text-2xs text-faint`}," The account id names the account and keys its stored credentials; lowercase letters, digits, `-` and `_`. ",-1)]),V(`section`,rY,[t[22]||=V(`header`,{class:`mb-3`},[V(`h3`,{class:`text-xs font-semibold text-ink`},` Hostnames `),V(`p`,{class:`mt-0.5 text-2xs leading-4 text-muted`},` The whole list to keep updated — suba.domain.com, domain.xyz and so on. `)],-1),x.value.length>0?(R(),z(`ul`,iY,[(R(!0),z(L,null,F(x.value,e=>(R(),z(`li`,{key:e.key,class:`rounded-control border border-line-soft bg-panel/50 p-2.5`},[V(`div`,aY,[V(`div`,oY,[H(tR,{modelValue:e.host,"onUpdate:modelValue":t=>e.host=t,label:`Hostname`},null,8,[`modelValue`,`onUpdate:modelValue`])]),V(`div`,sY,[H(XL,{modelValue:e.account,"onUpdate:modelValue":t=>e.account=t,label:`Account`,options:w.value},null,8,[`modelValue`,`onUpdate:modelValue`,`options`])]),H(NB,{modelValue:e.enabled,"onUpdate:modelValue":t=>e.enabled=t,label:`Enabled`},null,8,[`modelValue`,`onUpdate:modelValue`]),H($,{size:`xs`,variant:`danger-ghost`,onClick:t=>ge(e)},{default:M(()=>[...t[19]||=[U(` Remove `,-1)]]),_:1},8,[`onClick`])]),V(`div`,cY,[H(NB,{"model-value":e.types.includes(`A`),label:`A (IPv4)`,"onUpdate:modelValue":t=>D(e,`A`,t===!0)},null,8,[`model-value`,`onUpdate:modelValue`]),H(NB,{"model-value":e.types.includes(`AAAA`),label:`AAAA (IPv6)`,disabled:ae(e)?.families.includes(`AAAA`)===!1,hint:ae(e)?.families.includes(`AAAA`)===!1?`This provider cannot manage AAAA records.`:void 0,"onUpdate:modelValue":t=>D(e,`AAAA`,t===!0)},null,8,[`model-value`,`disabled`,`hint`,`onUpdate:modelValue`]),ae(e)?.proxied===!0?(R(),B(NB,{key:0,modelValue:e.proxied,"onUpdate:modelValue":t=>e.proxied=t,label:`Proxied`,hint:`Cloudflare serves this record through its own network.`},null,8,[`modelValue`,`onUpdate:modelValue`])):W(``,!0),e.types.includes(`AAAA`)&&!l.value.ipv6.enabled?(R(),B(mV,{key:1,tone:`warn`},{default:M(()=>[...t[20]||=[U(` IPv6 detection is off `,-1)]]),_:1})):W(``,!0)]),H(uR,{title:`Advanced`,hint:`registered domain and TTL override`,class:`mt-2`},{default:M(()=>[H(tR,{"model-value":e.zone??``,label:`Registered domain`,placeholder:`example.co.uk`,hint:`Only when the provider has to be told the apex, e.g. three-label domains.`,"onUpdate:modelValue":t=>le(e,`zone`,t)},null,8,[`model-value`,`onUpdate:modelValue`]),ae(e)?.ttl===!1?W(``,!0):(R(),B(WL,{key:0,"model-value":e.ttl??null,min:1,nullable:``,label:`TTL override (s)`,hint:`Blank uses the value above.`,"onUpdate:modelValue":t=>le(e,`ttl`,t)},null,8,[`model-value`,`onUpdate:modelValue`]))]),_:2},1024)]))),128))])):(R(),z(`p`,lY,` No hostnames yet. `)),V(`div`,uY,[H(tR,{modelValue:m.host,"onUpdate:modelValue":t[7]||=e=>m.host=e,label:`Hostname`,placeholder:`home.example.com`},null,8,[`modelValue`]),H(XL,{modelValue:m.account,"onUpdate:modelValue":t[8]||=e=>m.account=e,label:`Account`,options:w.value,disabled:b.value.length===0},null,8,[`modelValue`,`options`,`disabled`]),H($,{variant:`secondary`,disabled:!te.value,onClick:he},{default:M(()=>[...t[21]||=[U(` Add `,-1)]]),_:1},8,[`disabled`])])]),T.value!==null&&T.value.records.length>0?(R(),z(`section`,dY,[V(`header`,fY,[t[23]||=V(`h3`,{class:`text-xs font-semibold text-ink`},` Last pass `,-1),T.value.lastResult?(R(),z(`span`,pY,k(T.value.lastResult),1)):W(``,!0),T.value.ipv4?(R(),z(`span`,mY,`IPv4 `+k(T.value.ipv4),1)):W(``,!0),T.value.ipv6?(R(),z(`span`,hY,`IPv6 `+k(T.value.ipv6),1)):W(``,!0),T.value.lastRunAt?(R(),z(`span`,gY,k(j(oI)(T.value.lastRunAt,j(a).now.value)),1)):W(``,!0)]),V(`div`,_Y,[V(`table`,vY,[t[24]||=V(`thead`,null,[V(`tr`,{class:`text-2xs text-faint`},[V(`th`,{class:`py-1 pr-3 font-medium`},` Hostname `),V(`th`,{class:`py-1 pr-3 font-medium`},` Type `),V(`th`,{class:`py-1 pr-3 font-medium`},` State `),V(`th`,{class:`py-1 pr-3 font-medium`},` Address `),V(`th`,{class:`py-1 font-medium`},` Detail `)])],-1),V(`tbody`,null,[(R(!0),z(L,null,F(T.value.records,e=>(R(),z(`tr`,{key:`${e.host}|${e.type}`,class:`border-t border-line-soft align-top`},[V(`td`,yY,k(e.host),1),V(`td`,bY,k(e.type),1),V(`td`,xY,[H(mV,{tone:i[e.state].tone,dot:``},{default:M(()=>[U(k(i[e.state].label),1)]),_:2},1032,[`tone`])]),V(`td`,SY,k(e.ip??`—`),1),V(`td`,CY,k(e.message??`—`),1)]))),128))])])])])):W(``,!0)],64))]),H(hR,{open:ne.value,"onUpdate:open":t[10]||=e=>ne.value=e,title:`Provider credentials`,description:h.value===null?``:`${oe(h.value)} — ${h.value.id}`,width:`w-[min(92vw,32rem)]`},{footer:M(()=>[h.value!==null&&se(h.value.id)?(R(),B($,{key:0,size:`sm`,variant:`danger-ghost`,disabled:_.value,onClick:O},{default:M(()=>[...t[26]||=[U(` Forget `,-1)]]),_:1},8,[`disabled`])):W(``,!0),H($,{size:`sm`,variant:`ghost`,disabled:_.value,onClick:t[9]||=e=>ne.value=!1},{default:M(()=>[...t[27]||=[U(` Cancel `,-1)]]),_:1},8,[`disabled`]),H($,{size:`sm`,variant:`primary`,loading:_.value,disabled:Object.values(g.value).every(e=>e.trim().length===0),onClick:be},{default:M(()=>[...t[28]||=[U(` Save credentials `,-1)]]),_:1},8,[`loading`,`disabled`])]),default:M(()=>[V(`div`,wY,[t[25]||=V(`p`,{class:`text-2xs leading-4 text-muted`},` Saved fields are never sent back. Saving replaces every field for this account and runs a pass right away. `,-1),(R(!0),z(L,null,F(re.value,e=>(R(),B(tR,{key:e.key,modelValue:g.value[e.key],"onUpdate:modelValue":t=>g.value[e.key]=t,type:`password`,autocomplete:`off`,label:e.label,hint:`${e.hint}${e.optional?` Optional.`:``}`,wide:``},null,8,[`modelValue`,`onUpdate:modelValue`,`label`,`hint`]))),128)),h.value===null?W(``,!0):(R(),z(`a`,{key:0,class:`inline-block text-2xs text-accent underline decoration-line underline-offset-2`,href:ie(h.value.provider)?.docsUrl,target:`_blank`,rel:`noreferrer`},`Where to get these`,8,TY)),v.value?(R(),B(vB,{key:1,tone:`danger`},{default:M(()=>[U(k(v.value),1)]),_:1})):W(``,!0)])]),_:1},8,[`open`,`description`])],64))}}),DY={class:`mt-3 space-y-3`},OY=P({__name:`DefaultsSection`,props:Ra({dirty:{type:Boolean}},{defaults:{required:!0},defaultsModifiers:{}}),emits:Ra([`reset`],[`update:defaults`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`defaults`),a=hL(()=>i.value.logBufferLines,e=>i.value.logBufferLines=e,500);return(e,t)=>(R(),z(L,null,[H(NL,{title:`Server defaults`,description:`Applied to every entry that does not set its own value.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[9]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(rR,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Enabled`,hint:`New entries start enabled.`,wide:``},null,8,[`modelValue`]),H(rR,{modelValue:i.value.autostart,"onUpdate:modelValue":t[2]||=e=>i.value.autostart=e,label:`Autostart with the panel`},null,8,[`modelValue`]),H(XL,{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`]),H(XL,{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`]),H(WL,{modelValue:j(a),"onUpdate:modelValue":t[5]||=e=>mn(a)?a.value=e:null,label:`Log buffer lines`,min:50,max:1e5,hint:`Kept in memory per server.`},null,8,[`modelValue`])]),_:1}),V(`div`,DY,[H(iR,{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))}}),kY={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},AY={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},jY={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},MY={class:`text-2xs leading-4 text-faint`},NY=P({__name:`LogsSection`,props:Ra({logsDir:{},dirty:{type:Boolean}},{logs:{required:!0},logsModifiers:{}}),emits:Ra([`reset`],[`update:logs`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`logs`),a=nP(),o=hL(()=>i.value.maxBytes,e=>i.value.maxBytes=e,2e6),s=hL(()=>i.value.keep,e=>i.value.keep=e,3),c=G(()=>n.logsDir??`—`);return(e,t)=>{let l=fa(`RouterLink`);return R(),B(NL,{title:`Retention`,description:`The live view always comes from memory; these files survive a restart and feed the Logs page.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[4]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(rR,{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`]),H(WL,{modelValue:j(o),"onUpdate:modelValue":t[2]||=e=>mn(o)?o.value=e:null,label:`Rotate at (bytes)`,min:1e4,max:1e8,hint:`Per server, before rolling to .1, .2, …`},null,8,[`modelValue`]),H(WL,{modelValue:j(s),"onUpdate:modelValue":t[3]||=e=>mn(s)?s.value=e:null,label:`Keep rotated files`,min:1,max:10},null,8,[`modelValue`]),V(`div`,kY,[t[8]||=V(`span`,{class:`text-xs font-medium text-muted`},`Logs directory`,-1),V(`div`,AY,[V(`span`,jY,k(c.value),1),H(fV,{value:c.value,label:`Copy the logs directory`},null,8,[`value`])]),V(`p`,MY,[t[6]||=U(` Browse and download these files on the `,-1),H(l,{to:j(_X)(j(a).activeId.value,`logs`),class:`text-accent underline decoration-accent/40 underline-offset-2 hover:decoration-accent`},{default:M(()=>[...t[5]||=[U(` Logs `,-1)]]),_:1},8,[`to`]),t[7]||=U(` page. `,-1)])])]),_:1})}}}),PY={class:`flex items-center gap-2 border-t border-line-soft pt-3 sm:col-span-2`},FY={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},IY={key:0,class:`sm:col-span-2`},LY={class:`flex flex-wrap gap-1.5`},RY={key:1,class:`sm:col-span-2`},zY={class:`text-2xs leading-4 text-faint`},BY={key:2,class:`space-y-2 sm:col-span-2`},VY=P({__name:`NotificationsSection`,props:Ra({status:{},dirty:{type:Boolean}},{telegram:{required:!0},telegramModifiers:{}}),emits:Ra([`reset`],[`update:telegram`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`telegram`),a=VN(),o=nP(),s=hL(()=>i.value.cooldownMs,e=>i.value.cooldownMs=e,12e4),c=A(``),l=A(null),u=A(null),d=A([]),f=A(!1),p=G(()=>n.status?.tokenSet===!0),m=G(()=>n.status?.lastResult??null),h=G(()=>n.status?.lastResultAt??null),g=G(()=>p.value?`Saved — type a new token to replace it`:`123456789:AA…`);async function _(){f.value=!0,u.value=null,l.value=null;try{let e=await xM(o.activeId.value,c.value.trim());c.value=``,l.value=`Token saved${e.username?` for @${e.username}`:``}.`,await a.refresh()}catch(e){u.value=e instanceof Error?e.message:String(e)}finally{f.value=!1}}async function v(){f.value=!0,u.value=null,l.value=null;try{await SM(o.activeId.value),l.value=`Token removed.`,await a.refresh()}catch(e){u.value=e instanceof Error?e.message:String(e)}finally{f.value=!1}}async function y(){f.value=!0,u.value=null,l.value=null;try{let e=c.value.trim(),t=await wM(o.activeId.value,e.length>0?{botToken:e}:{});d.value=t.chats,t.chats.length===0&&(u.value=`No chats found. Send /start to the bot first, then detect again.`)}catch(e){u.value=e instanceof Error?e.message:String(e)}finally{f.value=!1}}async function b(){f.value=!0,u.value=null,l.value=null;try{let e=c.value.trim(),t=await CM(o.activeId.value,{chatId:i.value.chatId.length>0?i.value.chatId:void 0,...e.length>0?{botToken:e}:{}});t.ok?l.value=`Test message sent.`:u.value=t.error??`The test message failed.`,await a.refresh()}catch(e){u.value=e instanceof Error?e.message:String(e)}finally{f.value=!1}}return(e,t)=>(R(),B(NL,{title:`Telegram`,description:`Policy lives in the config; the bot token is a secret and never comes back from the server.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[11]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(rR,{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`]),H(tR,{modelValue:i.value.chatId,"onUpdate:modelValue":t[2]||=e=>i.value.chatId=e,label:`Chat id`,placeholder:`123456789 or @channel`,hint:`Use Detect chats to fill this from the bot's updates.`},null,8,[`modelValue`]),H(WL,{modelValue:j(s),"onUpdate:modelValue":t[3]||=e=>mn(s)?s.value=e:null,label:`Cooldown per event (ms)`,min:0,hint:`Per server and reason, so a flapping server cannot spam.`},null,8,[`modelValue`]),H(rR,{modelValue:i.value.onCrash,"onUpdate:modelValue":t[4]||=e=>i.value.onCrash=e,label:`Retries exhausted`},null,8,[`modelValue`]),H(rR,{modelValue:i.value.onUnhealthy,"onUpdate:modelValue":t[5]||=e=>i.value.onUnhealthy=e,label:`Port unhealthy`},null,8,[`modelValue`]),H(rR,{modelValue:i.value.onForcedRestart,"onUpdate:modelValue":t[6]||=e=>i.value.onForcedRestart=e,label:`Forced restart`},null,8,[`modelValue`]),H(rR,{modelValue:i.value.onRecovered,"onUpdate:modelValue":t[7]||=e=>i.value.onRecovered=e,label:`Recovered`},null,8,[`modelValue`]),H(rR,{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`]),H(rR,{modelValue:i.value.onDdns,"onUpdate:modelValue":t[9]||=e=>i.value.onDdns=e,label:`Dynamic DNS changed or failed`,hint:`One message per pass that changed a record, and one for a pass that failed.`,wide:``},null,8,[`modelValue`]),V(`div`,PY,[t[12]||=V(`span`,{class:`text-xs font-medium text-muted`},`Bot token`,-1),H(mV,{tone:p.value?`ok`:`warn`,dot:``},{default:M(()=>[U(k(p.value?`token set`:`no token`),1)]),_:1},8,[`tone`]),t[13]||=V(`span`,{class:`text-2xs text-faint`},`From @BotFather — a secret, never in servers.config.json.`,-1)]),H(tR,{modelValue:c.value,"onUpdate:modelValue":t[10]||=e=>c.value=e,type:`password`,autocomplete:`off`,label:`Bot token`,placeholder:g.value,wide:``},null,8,[`modelValue`,`placeholder`]),V(`div`,FY,[H($,{variant:`primary`,disabled:f.value||c.value.trim().length===0,loading:f.value&&c.value.trim().length>0,onClick:_},{default:M(()=>[...t[14]||=[U(` Save token `,-1)]]),_:1},8,[`disabled`,`loading`]),H($,{variant:`secondary`,disabled:f.value,onClick:y},{default:M(()=>[...t[15]||=[U(` Detect chats `,-1)]]),_:1},8,[`disabled`]),H($,{variant:`secondary`,disabled:f.value,onClick:b},{default:M(()=>[...t[16]||=[U(` Send test `,-1)]]),_:1},8,[`disabled`]),p.value?(R(),B(hB,{key:0,label:`Remove token`,"confirm-label":`Confirm remove`,"confirm-variant":`danger`,disabled:f.value,onConfirm:v},null,8,[`disabled`])):W(``,!0)]),d.value.length>0?(R(),z(`div`,IY,[t[17]||=V(`p`,{class:`mb-1.5 text-xs text-muted`},` Chats the bot has seen: `,-1),V(`div`,LY,[(R(!0),z(L,null,F(d.value,e=>(R(),B($,{key:String(e.id),size:`xs`,variant:`secondary`,onClick:t=>i.value.chatId=String(e.id)},{default:M(()=>[U(k(e.title)+` (`+k(e.id)+`) `,1)]),_:2},1032,[`onClick`]))),128))])])):W(``,!0),m.value?(R(),z(`div`,RY,[V(`p`,zY,` Last send: `+k(m.value)+k(h.value?` · ${j(oI)(h.value,j(a).now.value)}`:``),1)])):W(``,!0),u.value||l.value?(R(),z(`div`,BY,[u.value?(R(),B(vB,{key:0,tone:`danger`},{default:M(()=>[U(k(u.value),1)]),_:1})):W(``,!0),l.value?(R(),B(vB,{key:1,tone:`ok`},{default:M(()=>[U(k(l.value),1)]),_:1})):W(``,!0)])):W(``,!0)]),_:1}))}}),HY={class:`min-h-full`},UY={class:`mx-auto w-full max-w-5xl px-4 pb-6 pt-5 sm:px-6`},WY={class:`lg:grid lg:grid-cols-[11rem_minmax(0,1fr)] lg:gap-8`},GY={"aria-label":`Workspace settings sections`,class:`hidden lg:block`},KY={class:`sticky top-6 space-y-0.5 border-l border-line`},qY=[`aria-current`,`onClick`],JY={class:`space-y-6`},YY={id:`defaults`,class:`scroll-mt-5`},XY={id:`logs`,class:`scroll-mt-5`},ZY={id:`notifications`,class:`scroll-mt-5`},QY={id:`ddns`,class:`scroll-mt-5`},$Y={class:`sticky bottom-0 z-30 border-t border-line bg-panel/95 backdrop-blur`},eX={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`},tX={class:`min-w-0 flex-1`},nX={class:`text-xs text-muted`},rX={class:`font-mono tabular-nums text-ink`},iX={key:0,class:`mt-0.5 text-xs text-danger`},aX={key:1,class:`mt-0.5 text-xs text-ok`},oX={class:`flex shrink-0 items-center gap-2`},sX={class:`max-h-[60dvh] overflow-auto px-4 py-3`},cX={key:0,class:`divide-y divide-line-soft`},lX={class:`font-mono text-xs text-ink`},uX={class:`ml-auto font-mono text-xs text-muted line-through`},dX={class:`font-mono text-xs text-accent`},fX={key:1,class:`text-xs text-muted`},pX={class:`flex items-center justify-end gap-2 border-t border-line px-4 py-3`},mX=P({__name:`SettingsView`,setup(e){let t=[{id:`defaults`,title:`Server defaults`},{id:`logs`,title:`Logs`},{id:`notifications`,title:`Notifications`},{id:`ddns`,title:`Dynamic DNS`}],n=Rg(),r=Lg(),i=VN(),a=nP(),o=cN(),s=en(XI()),c=A(`defaults`),l=A(!1),u=A(null),d=A(null),f=A(null),p=A(null),m=A(null),h=G(()=>a.defaults.value),g=G(()=>a.logsConfig.value),_=G(()=>a.notifications.value?.telegram??null),v=G(()=>a.logsDir.value),y=G(()=>{let e={},t=h.value,n=g.value,r=_.value;if(t!==null){let n=oL(t,s.defaults);Object.keys(n).length>0&&(e.defaults=n)}if(n!==null){let t=sL(n,s.logs);Object.keys(t).length>0&&(e.logs=t)}if(r!==null){let t=cL(r,s.telegram);Object.keys(t).length>0&&(e.notifications=t)}return e}),b=G(()=>UI(y.value)+(f.value===null?0:UI(f.value))),x=G(()=>{let e=_.value;return{defaults:h.value??{},logs:g.value??{},notifications:e===null?{}:{telegram:$I(e)},ddns:p.value??{}}}),S=G(()=>HI({...y.value,...f.value===null?{}:{ddns:f.value}},x.value)),C=A(!1),w=G(()=>h.value!==null&&Object.keys(oL(h.value,s.defaults)).length>0),T=G(()=>g.value!==null&&Object.keys(sL(g.value,s.logs)).length>0),ee=G(()=>_.value!==null&&Object.keys(cL(_.value,s.telegram)).length>0),E={};function te(){let e=(e,t)=>{dL(E[e],uL(s,e))||(t(),E[e]=uL(s,e))},t=h.value;t!==null&&e(`defaults`,()=>{s.defaults.enabled=t.enabled,s.defaults.autostart=t.autostart,s.defaults.bind=t.bind,s.defaults.onPortConflict=t.onPortConflict,s.defaults.logBufferLines=t.logBufferLines,s.defaults.restart={...t.restart},s.defaults.health=JI(t.health),s.defaults.stop={...t.stop}});let n=g.value;n!==null&&e(`logs`,()=>Object.assign(s.logs,n));let r=_.value;r!==null&&e(`telegram`,()=>Object.assign(s.telegram,$I(r)))}function ne(){for(let e of Object.keys(E))delete E[e]}function re(e){E[e]=uL(s,e)}N([h,g,_],()=>{te()},{immediate:!0});async function ie(){let e=y.value,t=f.value,n=Object.keys(e).length>0;if(!(!n&&t===null||l.value||a.activeId.value.length===0)){l.value=!0,u.value=null,d.value=null;try{if(n&&!await i.saveWorkspaceSettings(a.activeId.value,e)){u.value=i.lastError.value??`The settings could not be saved.`;return}t!==null&&(await DM(a.activeId.value,t),await m.value?.reload()),d.value=`Workspace settings saved.`,o.success(`Workspace settings saved`),ne(),te()}catch(e){u.value=e instanceof Error?e.message:String(e)}finally{l.value=!1}}}function ae(){u.value=null,d.value=null,ne(),te(),m.value?.reload()}function oe(){let e=h.value;e!==null&&(s.defaults.enabled=e.enabled,s.defaults.autostart=e.autostart,s.defaults.bind=e.bind,s.defaults.onPortConflict=e.onPortConflict,s.defaults.logBufferLines=e.logBufferLines,s.defaults.restart={...e.restart},s.defaults.health=JI(e.health),s.defaults.stop={...e.stop},re(`defaults`))}function se(){g.value!==null&&Object.assign(s.logs,g.value),re(`logs`)}function ce(){_.value!==null&&Object.assign(s.telegram,$I(_.value)),re(`telegram`)}function D(e){rr(()=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})})}function le(e){c.value=e,n.query.section!==e&&r.replace({query:{...n.query,section:e}}),D(e)}N(()=>n.query.section,e=>{let n=typeof e==`string`?e:``;t.some(e=>e.id===n)&&(c.value=n,D(n))},{immediate:!0}),N(()=>a.activeId.value,()=>{ne(),te(),u.value=null,d.value=null});let ue=null;return ta(()=>{ue=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&&(c.value=t.target.id)},{rootMargin:`-72px 0px -62% 0px`,threshold:0});for(let e of t){let t=document.getElementById(e.id);t&&ue.observe(t)}}),ia(()=>ue?.disconnect()),(e,n)=>(R(),z(L,null,[V(`div`,HY,[V(`div`,UY,[H(Oz,{title:`Workspace settings`,description:`Server defaults, log retention, notifications and dynamic DNS for ${j(a).selected.value?.label??`this workspace`}.`},null,8,[`description`]),j(a).configError.value?(R(),B(vB,{key:0,tone:`danger`,title:`The workspace config could not be read`,class:`mb-4`},{default:M(()=>[V(`p`,null,k(j(a).configError.value),1),n[9]||=V(`p`,{class:`mt-1`},` The panel keeps supervising with the config it already had; fixing the file reloads it on its own. `,-1)]),_:1})):j(a).configWarnings.value.length>0?(R(),B(vB,{key:1,tone:`warn`,title:`Some keys in this workspace's config are not recognized`,class:`mb-4`},{default:M(()=>[(R(!0),z(L,null,F(j(a).configWarnings.value,e=>(R(),z(`p`,{key:e,class:`font-mono`},k(e),1))),128))]),_:1})):W(``,!0),V(`div`,WY,[V(`nav`,GY,[V(`ul`,KY,[(R(),z(L,null,F(t,e=>V(`li`,{key:e.id},[V(`button`,{type:`button`,"aria-current":c.value===e.id?`true`:void 0,class:O(j(Q)(`-ml-px block w-full border-l-2 py-1.5 pl-3 text-left text-xs transition-colors duration-150`,c.value===e.id?`border-accent font-medium text-accent`:`border-transparent text-muted hover:border-line hover:text-ink`)),onClick:t=>le(e.id)},k(e.title),11,qY)])),64))])]),V(`div`,JY,[V(`section`,YY,[n[10]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Server defaults `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Applied to every entry in this workspace that does not set its own value. `)],-1),H(OY,{defaults:s.defaults,"onUpdate:defaults":n[0]||=e=>s.defaults=e,dirty:w.value,onReset:oe},null,8,[`defaults`,`dirty`])]),V(`section`,XY,[n[11]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Logs `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` How much output this workspace keeps on disk and for how long. `)],-1),H(NY,{logs:s.logs,"onUpdate:logs":n[1]||=e=>s.logs=e,"logs-dir":v.value,dirty:T.value,onReset:se},null,8,[`logs`,`logs-dir`,`dirty`])]),V(`section`,ZY,[n[12]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Notifications `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Crash and health alerts for this workspace, sent to a Telegram chat. `)],-1),H(VY,{telegram:s.telegram,"onUpdate:telegram":n[2]||=e=>s.telegram=e,status:_.value,dirty:ee.value,onReset:ce},null,8,[`telegram`,`status`,`dirty`])]),V(`section`,QY,[n[13]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Dynamic DNS `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Keep hostnames pointed at this machine's public address, whichever registrar holds them. `)],-1),H(EY,{ref_key:`ddnsSection`,ref:m,patch:f.value,"onUpdate:patch":n[3]||=e=>f.value=e,baseline:p.value,"onUpdate:baseline":n[4]||=e=>p.value=e},null,8,[`patch`,`baseline`])])])])]),V(`div`,$Y,[V(`div`,eX,[V(`div`,tX,[V(`p`,nX,[b.value>0?(R(),z(`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[5]||=e=>C.value=!0},[V(`span`,rX,k(b.value),1),U(` field`+k(b.value===1?``:`s`)+` changed `,1)])):(R(),z(L,{key:1},[U(` No unsaved changes `)],64))]),u.value?(R(),z(`p`,iX,k(u.value),1)):d.value?(R(),z(`p`,aX,k(d.value),1)):W(``,!0)]),V(`div`,oX,[H($,{variant:`ghost`,disabled:b.value===0||l.value,onClick:ae},{default:M(()=>[...n[14]||=[U(` Discard changes `,-1)]]),_:1},8,[`disabled`]),H($,{variant:`primary`,disabled:b.value===0,loading:l.value,onClick:ie},{default:M(()=>[...n[15]||=[U(` Save settings `,-1)]]),_:1},8,[`disabled`,`loading`])])])])]),H(hR,{open:C.value,"onUpdate:open":n[8]||=e=>C.value=e,title:`Unsaved changes`,description:`What Save would write to ${j(a).selected.value?.label??`this workspace`}'s settings.`,width:`w-[min(92vw,42rem)]`},{default:M(()=>[V(`div`,sX,[S.value.length>0?(R(),z(`ul`,cX,[(R(!0),z(L,null,F(S.value,e=>(R(),z(`li`,{key:e.path,class:`flex flex-wrap items-baseline gap-x-3 gap-y-1 py-2 first:pt-0`},[V(`code`,lX,k(e.path),1),V(`span`,uX,k(j(uI)(e.from)),1),n[16]||=V(`span`,{class:`text-2xs text-faint`},`→`,-1),V(`span`,dX,k(j(uI)(e.to)),1)]))),128))])):(R(),z(`p`,fX,` Nothing to save. `))]),V(`footer`,pX,[H($,{size:`sm`,variant:`ghost`,onClick:n[6]||=e=>C.value=!1},{default:M(()=>[...n[17]||=[U(` Close `,-1)]]),_:1}),H($,{size:`sm`,variant:`primary`,disabled:S.value.length===0||l.value,loading:l.value,onClick:n[7]||=e=>{ie(),C.value=!1}},{default:M(()=>[U(` Save `+k(S.value.length)+` change`+k(S.value.length===1?``:`s`),1)]),_:1},8,[`disabled`,`loading`])])]),_:1},8,[`open`,`description`])],64))}}),hX=new Set([`overview`,`servers`,`server-detail`,`logs`,`settings`]),gX=xv({history:U_(),routes:[{path:`/w/:workspaceId`,name:`overview`,component:_G,meta:{title:`Overview`}},{path:`/w/:workspaceId/servers`,name:`servers`,component:BJ,meta:{title:`Servers`}},{path:`/w/:workspaceId/servers/:id`,name:`server-detail`,component:PJ,meta:{title:`Server`}},{path:`/w/:workspaceId/logs`,name:`logs`,component:YW,meta:{title:`Logs`}},{path:`/w/:workspaceId/settings`,name:`settings`,component:mX,meta:{title:`Workspace settings`}},{path:`/global/overview`,name:`global-overview`,component:mB,meta:{title:`Global Overview`}},{path:`/global/settings`,name:`global-settings`,component:EU,meta:{title:`Global settings`}},{path:`/proxy`,name:`proxy`,component:Jq,meta:{title:`Reverse Proxy`}},{path:`/login`,name:`login`,component:YU,meta:{title:`Sign in`}},{path:`/`,name:`home`,component:_G},{path:`/servers`,name:`legacy-servers`,component:BJ},{path:`/servers/:id`,name:`legacy-server-detail`,component:PJ},{path:`/logs`,name:`legacy-logs`,component:YW},{path:`/settings`,name:`legacy-settings`,component:mX},{path:`/global`,name:`legacy-global`,component:mB},{path:`/global-settings`,name:`legacy-global-settings`,component:EU},{path:`/:pathMatch(.*)*`,name:`not-found`,component:_G}]});function _X(e,t=`overview`,n){let r=`/w/${encodeURIComponent(e)}`;return t===`overview`?r:t===`servers`?n===void 0?`${r}/servers`:`${r}/servers/${encodeURIComponent(n)}`:`${r}/${t}`}gX.beforeEach(async e=>{let{session:t,refresh:n}=rN();t.value===null&&await n();let r=t.value?.authRequired===!0,i=t.value?.authenticated===!0;if(r&&!i&&e.name!==`login`)return{name:`login`,query:e.fullPath===`/`?void 0:{next:e.fullPath}};if(e.name===`login`&&(!r||i))return{name:`global-overview`,replace:!0};if(e.name===`login`||e.name===`global-overview`||e.name===`global-settings`||e.name===`proxy`)return!0;if(e.name===`legacy-global`)return{name:`global-overview`,query:e.query,replace:!0};if(e.name===`legacy-global-settings`)return{name:`global-settings`,query:e.query,replace:!0};if(e.name===`home`||e.name===`not-found`)return{name:`global-overview`,replace:!0};await VN().ensureState();let a=nP(),o=a.workspaces.value;if(o.length===0)return!0;let s=typeof e.params.workspaceId==`string`?e.params.workspaceId:``;if(s.length>0&&o.some(e=>e.id===s)&&(a.select(s),hX.has(String(e.name))))return!0;let c=a.activeId.value||o[0].id,l=String(e.name??``).replace(/^legacy-/,``),u=l===`server-detail`||l===`servers`&&`id`in e.params?`server-detail`:hX.has(l)?l:`overview`,d={...e.params,workspaceId:c};return u===`server-detail`&&d.id===void 0?{name:`servers`,params:{workspaceId:c},query:e.query,replace:!0}:{name:u,params:d,query:e.query,replace:!0}});var vX={class:`flex items-center gap-2.5 border-b border-line px-3.5`},yX={key:0,class:`px-3 py-8 text-center text-xs text-muted`},bX={class:`px-2.5 pb-1 pt-2.5 text-2xs font-medium text-faint`},xX=[`data-active`,`onMousemove`,`onClick`],SX={class:`min-w-0 flex-1 truncate text-sm`},CX={key:0,class:`shrink-0 font-mono text-2xs text-faint`},wX={class:`flex items-center gap-3 border-t border-line bg-panel-2 px-3.5 py-2 text-2xs text-faint`},TX={class:`ml-auto font-mono`},EX=P({__name:`CommandPalette`,props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:[`update:open`],setup(e){let t=oo(e,`open`),n=Lg(),r=VN(),i=nP(),a=XN(),o=A(``),s=A(0),c=A(null),l=A(null);function u(e){n.push(e)}function d(e){i.select(e);let t=String(n.currentRoute.value.name??``);t===`overview`||t===`servers`||t===`logs`||t===`settings`?u(_X(e,t)):t===`server-detail`&&u(_X(e,`servers`))}function f(e){e(),t.value=!1}let p=[`stopped`,`crashed`,`conflict`],m=[`running`,`starting`,`backoff`],h=G(()=>{let e=[],t=r.allServers.value;function n(e,t){i.select(e),u(t)}let o=e=>_X(i.activeId.value,e);for(let{workspace:i,server:a}of t){let t=a.config.label??a.id,o=jF[a.status].label;e.push({id:`open:${i.id}:${a.id}`,title:`Open ${t}`,group:`Servers`,icon:wy,detail:`${i.label} · ${a.id} · ${o}`,keywords:`server detail ${a.id} ${i.label} show`,run:()=>n(i.id,_X(i.id,`servers`,a.id))}),e.push({id:`logs:${i.id}:${a.id}`,title:`Logs for ${t}`,group:`Servers`,icon:My,detail:`${i.label} · ${a.id}`,keywords:`log tail output ${a.id} ${i.label}`,run:()=>n(i.id,`${_X(i.id,`logs`)}?server=${encodeURIComponent(a.id)}`)}),p.includes(a.status)&&a.config.enabled&&e.push({id:`start:${i.id}:${a.id}`,title:`Start ${t}`,group:`Actions`,icon:gy,detail:`${i.label} · ${a.id}`,keywords:`run launch ${a.id} ${i.label}`,run:()=>f(()=>void r.start(i.id,a.id))}),m.includes(a.status)&&e.push({id:`stop:${i.id}:${a.id}`,title:`Stop ${t}`,group:`Actions`,icon:Ay,detail:`${i.label} · ${a.id}`,keywords:`halt kill ${a.id} ${i.label}`,run:()=>f(()=>void r.stop(i.id,a.id))}),a.config.enabled&&e.push({id:`restart:${i.id}:${a.id}`,title:`Restart ${t}`,group:`Actions`,icon:xy,detail:`${i.label} · ${a.id}`,keywords:`bounce reload ${a.id} ${i.label}`,run:()=>f(()=>void r.restart(i.id,a.id))})}e.push({id:`nav:overview`,title:`Go to Overview`,group:`Navigate`,icon:ay,keywords:`dashboard home workspace`,run:()=>u(o(`overview`))},{id:`nav:global`,title:`Go to Global Overview`,group:`Navigate`,icon:ey,keywords:`dashboard home host vitals every workspace`,run:()=>u(`/global/overview`)},{id:`nav:global-settings`,title:`Go to Global settings`,group:`Navigate`,icon:ky,keywords:`panel listener auth tls backups host`,run:()=>u(`/global/settings`)},{id:`nav:proxy`,title:`Go to Reverse Proxy`,group:`Navigate`,icon:Ly,keywords:`caddy domain route acme certificate https expose`,run:()=>u(`/proxy`)},{id:`nav:servers`,title:`Go to Servers`,group:`Navigate`,icon:wy,keywords:`processes list workspace`,run:()=>u(o(`servers`))},{id:`nav:logs`,title:`Go to Logs`,group:`Navigate`,icon:Sy,keywords:`output files tail workspace`,run:()=>u(o(`logs`))},{id:`nav:settings`,title:`Go to Workspace settings`,group:`Navigate`,icon:Ty,keywords:`defaults notifications ddns config workspace`,run:()=>u(o(`settings`))},{id:`act:start-all`,title:`Start every enabled server here`,group:`Actions`,icon:gy,keywords:`boot all workspace`,run:()=>f(()=>void r.startAll(i.activeId.value))},{id:`act:stop-all`,title:`Stop every server here`,group:`Actions`,icon:Ay,keywords:`halt all workspace`,run:()=>f(()=>void r.stopAll(i.activeId.value))});for(let t of i.workspaces.value)e.push({id:`ws:${t.id}`,title:`Switch to ${t.label}`,group:`Workspaces`,icon:iy,detail:t.id,keywords:`workspace switch scope ${t.label}`,run:()=>f(()=>d(t.id))});for(let[t,n]of[[`listener`,`Listener`],[`authentication`,`Authentication`],[`host`,`Host vitals`],[`backups`,`Backups`],[`tls`,`TLS`],[`interface`,`Interface`],[`paths`,`Paths`]])e.push({id:`gset:${t}`,title:`Global setting: ${n}`,group:`Global settings`,icon:ey,keywords:`configure panel ${t}`,run:()=>u(`/global/settings?section=${t}`)});for(let[t,n]of[[`defaults`,`Server defaults`],[`logs`,`Log storage`],[`notifications`,`Telegram notifications`],[`ddns`,`Dynamic DNS`]])e.push({id:`wset:${t}`,title:`Workspace setting: ${n}`,group:`Workspace settings`,icon:Ty,keywords:`configure workspace ${t}`,run:()=>u(`${_X(i.activeId.value,`settings`)}?section=${t}`)});let s=[[`light`,`Light`,jy],[`dark`,`Dark`,fy],[`system`,`System`,dy]];for(let[t,n,r]of s)e.push({id:`theme:${t}`,title:`${n} theme`,group:`Appearance`,icon:r,keywords:`colour color dark light mode appearance`,run:()=>f(()=>a.setPreference(t))});return e}),g=G(()=>{let e=o.value.trim().toLowerCase().split(/\s+/).filter(Boolean);return e.length===0?h.value.slice(0,40):h.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)}),_=G(()=>{let e=new Map;for(let t of g.value){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return[...e.entries()]}),v=G(()=>_.value.flatMap(([,e])=>e));N(g,()=>{s.value=0}),N(t,async e=>{e&&(o.value=``,s.value=0,await rr(),c.value?.focus())});function y(e){let t=v.value.length;t!==0&&(s.value=(s.value+e+t)%t,rr(()=>{l.value?.querySelector(`[data-active="true"]`)?.scrollIntoView({block:`nearest`})}))}function b(e){e.key===`ArrowDown`?(e.preventDefault(),y(1)):e.key===`ArrowUp`?(e.preventDefault(),y(-1)):e.key===`Enter`&&(e.preventDefault(),v.value[s.value]?.run())}function x(e){(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),t.value=!t.value)}return ta(()=>window.addEventListener(`keydown`,x)),ze(()=>window.removeEventListener(`keydown`,x)),(e,n)=>(R(),B(j(cf),{open:t.value,"onUpdate:open":n[2]||=e=>t.value=e},{default:M(()=>[H(j(Jf),null,{default:M(()=>[H(j(Kf),{class:`fixed inset-0 z-50 bg-black/40 backdrop-blur-[1px] data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`}),H(j(Uf),{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]||=cu(()=>{},[`prevent`]),onKeydown:b},{default:M(()=>[H(j(Yf),{class:`sr-only`},{default:M(()=>[...n[3]||=[U(` Command palette `,-1)]]),_:1}),V(`div`,vX,[H(j(Cy),{class:`size-4 shrink-0 text-faint`}),xr(V(`input`,{ref_key:`input`,ref:c,"onUpdate:modelValue":n[0]||=e=>o.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),[[ql,o.value]]),n[4]||=V(`kbd`,{class:`shrink-0 rounded border border-line bg-page px-1.5 py-0.5 font-mono text-2xs text-faint`},`esc`,-1)]),V(`div`,{ref_key:`list`,ref:l,class:`max-h-[min(60vh,26rem)] overflow-y-auto p-1.5`},[v.value.length===0?(R(),z(`p`,yX,` Nothing matches “`+k(o.value)+`”. `,1)):W(``,!0),(R(!0),z(L,null,F(_.value,([e,t])=>(R(),z(L,{key:e},[V(`p`,bX,k(e),1),(R(!0),z(L,null,F(t,e=>(R(),z(`button`,{key:e.id,type:`button`,"data-active":v.value[s.value]?.id===e.id,class:O(j(Q)(`flex w-full items-center gap-2.5 rounded-control px-2.5 py-2 text-left transition-colors duration-100`,v.value[s.value]?.id===e.id?`bg-accent-soft text-ink`:`text-muted hover:bg-hover`)),onMousemove:t=>s.value=v.value.findIndex(t=>t.id===e.id),onClick:t=>e.run()},[(R(),B(ma(e.icon),{class:O([`size-4 shrink-0`,v.value[s.value]?.id===e.id?`text-accent`:`text-faint`])},null,8,[`class`])),V(`span`,SX,k(e.title),1),e.detail?(R(),z(`span`,CX,k(e.detail),1)):W(``,!0),H(j(Lv),{class:O([`size-3.5 shrink-0 text-faint opacity-0 transition-opacity duration-100`,{"opacity-100":v.value[s.value]?.id===e.id}])},null,8,[`class`])],42,xX))),128))],64))),128))],512),V(`div`,wX,[n[5]||=V(`span`,null,[V(`kbd`,{class:`font-mono`},`↑↓`),U(` navigate`)],-1),n[6]||=V(`span`,null,[V(`kbd`,{class:`font-mono`},`↵`),U(` run`)],-1),V(`span`,TX,k(v.value.length)+` results`,1)])]),_:1})]),_:1})]),_:1},8,[`open`]))}}),DX={class:`rounded-panel border border-line bg-panel-2/70 p-3`},OX={class:`mb-2 flex items-center justify-between`},kX={key:0,class:`text-2xs text-faint`},AX={key:0,class:`grid grid-cols-2 gap-x-1 gap-y-2`},jX={key:1,class:`py-3 text-center text-2xs text-faint`},MX={key:2,class:`mt-2 flex items-start gap-1.5 rounded-control bg-danger-soft px-2 py-1.5`},NX={class:`text-2xs leading-4 text-danger`},PX=2,FX=85,IX=P({__name:`InstrumentCluster`,props:{host:{}},setup(e){let t=e,n=G(()=>{let e=t.host;return e?(e.loadAvg[0]??0)/Math.max(1,e.cpus):null}),r=G(()=>n.value===null?null:n.value/PX*100),i=G(()=>n.value===null?`—`:n.value.toFixed(2)),a=G(()=>{let e=t.host?.disks??[];return e.length===0?null:Math.max(...e.map(e=>e.usedPercent))}),o=G(()=>{let e=t.host?.tempCelsius??null;return e===null?null:e/FX*100}),s=G(()=>{let e=t.host?.tempCelsius??null;return e===null?`n/a`:`${Math.round(e)}°`});return(e,n)=>(R(),z(`div`,DX,[V(`div`,OX,[n[0]||=V(`span`,{class:`text-2xs font-medium text-faint`},`Host vitals`,-1),t.host?.enabled===!1?(R(),z(`span`,kX,`off`)):W(``,!0)]),t.host?.enabled?(R(),z(`div`,AX,[H(qF,{value:r.value,label:`Load / cpu`,display:i.value,size:58,"warn-at":70,"danger-at":100},null,8,[`value`,`display`]),H(qF,{value:t.host?.memoryUsedPercent??null,label:`Memory`,size:58},null,8,[`value`]),H(qF,{value:a.value,label:`Disk`,size:58},null,8,[`value`]),H(qF,{value:o.value,label:`CPU temp`,display:s.value,size:58},null,8,[`value`,`display`])])):(R(),z(`p`,jX,` Sampling is disabled in Settings. `)),t.host&&t.host.alerts.length>0?(R(),z(`div`,MX,[n[1]||=V(`span`,{class:`mt-1 size-1.5 shrink-0 rounded-full bg-danger`},null,-1),V(`span`,NX,k(t.host.alerts.join(` · `)),1)])):W(``,!0)]))}}),LX={class:`flex h-full min-h-0 flex-col gap-3 overflow-y-auto p-3`},RX={class:`flex items-center gap-2 px-1 pt-1`},zX={class:`min-w-0`},BX=[`title`],VX={class:`flex flex-col gap-3`,"aria-label":`Navigation`},HX={class:`flex items-center gap-1 truncate px-2.5 pb-1 text-2xs font-medium text-faint`},UX={key:1,class:`text-muted`},WX={class:`mt-auto flex flex-col gap-3`},GX={class:`flex items-center gap-2 rounded-control border border-line bg-panel-2/70 px-2.5 py-2`},KX={class:`relative flex size-2 shrink-0`},qX={class:`text-2xs text-muted`},JX=[`title`],YX=P({__name:`SideNav`,props:{host:{},connection:{},panelLabel:{},panelVersion:{},planLabel:{},workspaceId:{},workspaceLabel:{},running:{},total:{}},emits:[`navigate`,`close`],setup(e,{emit:t}){let n=e,r=t,i=Rg(),a=G(()=>[{to:_X(n.workspaceId,`overview`),label:`Overview`,icon:ay,exact:!0,servers:!1},{to:_X(n.workspaceId,`servers`),label:`Servers`,icon:wy,exact:!1,servers:!0},{to:_X(n.workspaceId,`logs`),label:`Logs`,icon:Sy,exact:!1,servers:!1},{to:_X(n.workspaceId,`settings`),label:`Workspace settings`,icon:Ty,exact:!1,servers:!1}]),o=[{to:`/global/overview`,label:`Global Overview`,icon:ey,exact:!0,servers:!1},{to:`/global/settings`,label:`Global settings`,icon:ky,exact:!1,servers:!1}],s=[{to:`/proxy`,label:`Reverse Proxy`,icon:Ly,exact:!1,servers:!1}],c=G(()=>[{title:`Global`,label:``,icon:ey,items:o},{title:`Workspace`,label:n.workspaceLabel,icon:void 0,items:a.value},{title:`Others`,label:``,icon:Nv,items:s}]);function l(e){return e.exact?i.path===e.to:i.path===e.to||i.path.startsWith(`${e.to}/`)}let u=G(()=>n.panelVersion===null?n.panelLabel:`${n.panelLabel} · v${n.panelVersion}`),d=G(()=>({open:{label:`Live`,dot:`bg-ok`},connecting:{label:`Connecting`,dot:`bg-warn`},closed:{label:`Reconnecting`,dot:`bg-danger`}})[n.connection]);return(e,t)=>{let i=fa(`RouterLink`);return R(),z(`div`,LX,[V(`div`,RX,[t[3]||=Ds(`<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),V(`div`,zX,[t[2]||=V(`p`,{class:`truncate text-sm font-semibold tracking-tight text-ink`},` home-hosted `,-1),V(`p`,{class:`truncate text-2xs text-faint`,title:u.value},k(u.value),9,BX)]),V(`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`)},[H(j(Ry),{class:`size-4`})])]),V(`nav`,VX,[(R(!0),z(L,null,F(c.value,e=>(R(),z(`div`,{key:e.title,class:`flex min-h-0 flex-col gap-0.5`},[V(`p`,HX,[e.icon?(R(),B(ma(e.icon),{key:0,class:`size-3 shrink-0`})):W(``,!0),U(` `+k(e.label?`${e.title} · `:e.title),1),e.label?(R(),z(`span`,UX,k(e.label),1)):W(``,!0)]),(R(!0),z(L,null,F(e.items,e=>(R(),B(i,{key:e.to,to:e.to,class:O(j(Q)(`group flex items-center gap-2.5 rounded-control px-2.5 py-1.5 text-sm transition-colors duration-150`,l(e)?`bg-accent-soft font-medium text-accent`:`text-muted hover:bg-hover hover:text-ink`)),onClick:t[1]||=e=>r(`navigate`)},{default:M(()=>[(R(),B(ma(e.icon),{class:`size-4 shrink-0`,"stroke-width":l(e)?2.1:1.8},null,8,[`stroke-width`])),U(` `+k(e.label)+` `,1),e.servers?(R(),z(`span`,{key:0,class:O([`ml-auto font-mono text-2xs tabular-nums`,l(e)?`text-accent`:`text-faint`])},k(n.running)+`/`+k(n.total),3)):W(``,!0)]),_:2},1032,[`to`,`class`]))),128))]))),128))]),V(`div`,WX,[H(IX,{host:n.host},null,8,[`host`]),V(`div`,GX,[V(`span`,KX,[V(`span`,{class:O(j(Q)(`absolute inset-0 rounded-full`,d.value.dot,n.connection!==`open`&&`animate-ping opacity-60`))},null,2),V(`span`,{class:O(j(Q)(`relative size-2 rounded-full`,d.value.dot))},null,2)]),V(`span`,qX,k(d.value.label),1),V(`span`,{class:`ml-auto truncate font-mono text-2xs text-faint`,title:n.planLabel},k(n.planLabel),9,JX)])])])}}}),XX={key:0,class:`flex flex-col gap-px border-b border-line bg-panel/60`},ZX={class:`text-2xs leading-4`},QX={class:`font-medium`},$X={key:0,class:`opacity-80`},eZ=P({__name:`SystemNotices`,props:{control:{},configError:{},configPath:{}},setup(e){let t=e,n=G(()=>{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 Global 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 Global 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:Iy},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?(R(),z(`div`,XX,[(R(!0),z(L,null,F(n.value,e=>(R(),z(`div`,{key:e.id,class:O([`flex items-start gap-2 px-3 py-1.5 sm:px-4`,r[e.tone].wrap])},[(R(),B(ma(r[e.tone].icon),{class:`mt-0.5 size-3.5 shrink-0`})),V(`p`,ZX,[V(`span`,QX,k(e.text),1),e.hint?(R(),z(`span`,$X,k(e.hint),1)):W(``,!0)])],2))),128))])):W(``,!0)}}),tZ={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`},nZ={class:`min-w-0 flex-1`},rZ={class:`text-xs font-medium text-ink`},iZ={key:0,class:`mt-0.5 break-words text-2xs leading-4 text-muted`},aZ=[`onClick`],oZ=P({__name:`ToastStack`,setup(e){let{toasts:t,dismiss:n}=cN(),r={ok:Vv,danger:Hv,warn:Iy,info:ny,accent:ny,neutral:ny},i={ok:`text-ok`,danger:`text-danger`,warn:`text-warn`,info:`text-info`,neutral:`text-muted`,accent:`text-accent`},a=G(()=>t.value);return(e,t)=>(R(),z(`div`,tZ,[H(Fl,{"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(()=>[(R(!0),z(L,null,F(a.value,e=>(R(),z(`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`},[(R(),B(ma(r[e.tone]),{class:O(j(Q)(`mt-0.5 size-4 shrink-0`,i[e.tone]))},null,8,[`class`])),V(`div`,nZ,[V(`p`,rZ,k(e.title),1),e.description?(R(),z(`p`,iZ,k(e.description),1)):W(``,!0)]),V(`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)},[H(j(Ry),{class:`size-3.5`})],8,aZ)]))),128))]),_:1})]))}}),sZ={class:`space-y-3`},cZ={key:0,class:`rounded-control border border-danger/40 bg-danger-soft px-2.5 py-1.5 text-2xs leading-4 text-danger`},lZ=P({__name:`WorkspaceDialog`,props:Ra({mode:{},initial:{default:``},submit:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:[`update:open`],setup(e){let t=e,n=oo(e,`open`),r=A(t.initial),i=A(!1),a=A(null),o=G(()=>t.mode===`create`?`New workspace`:`Rename workspace`),s=G(()=>t.mode===`create`?`Create workspace`:`Rename`),c=G(()=>r.value.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40));N(n,e=>{e&&(r.value=t.initial,a.value=null)});async function l(){let e=r.value.trim();if(e.length===0){a.value=`A workspace needs a name.`;return}i.value=!0,a.value=null;try{await t.submit(e)&&(n.value=!1)}finally{i.value=!1}}return(t,u)=>(R(),B(hR,{open:n.value,"onUpdate:open":u[2]||=e=>n.value=e,title:o.value,description:e.mode===`create`?`Its own settings, servers, logs, secrets and backups entry — served by this same panel.`:`Only the name changes; the workspace id stays, so URLs and paths keep working.`,width:`w-[min(92vw,26rem)]`},{footer:M(()=>[H($,{variant:`ghost`,disabled:i.value,onClick:u[1]||=e=>n.value=!1},{default:M(()=>[...u[3]||=[U(` Cancel `,-1)]]),_:1},8,[`disabled`]),H($,{variant:`primary`,loading:i.value,onClick:l},{default:M(()=>[U(k(s.value),1)]),_:1},8,[`loading`])]),default:M(()=>[V(`div`,sZ,[H(tR,{modelValue:r.value,"onUpdate:modelValue":u[0]||=e=>r.value=e,label:`Name`,placeholder:`Home lab`,hint:e.mode===`create`&&c.value.length>0?`Shown in the header. Id: ${c.value}`:`Shown in the header.`,wide:``,onKeydown:uu(cu(l,[`prevent`]),[`enter`])},null,8,[`modelValue`,`hint`,`onKeydown`]),a.value?(R(),z(`p`,cZ,k(a.value),1)):W(``,!0)])]),_:1},8,[`open`,`title`,`description`]))}}),uZ=[`aria-label`],dZ={class:`min-w-0 truncate font-medium text-ink`},fZ={class:`hidden shrink-0 font-mono text-2xs text-faint sm:inline`},pZ={key:0,class:`max-h-64 overflow-y-auto`},mZ=[`onClick`],hZ={class:`min-w-0 flex-1`},gZ={class:`block truncate text-xs`},_Z={class:`block truncate font-mono text-2xs text-faint`},vZ={class:`shrink-0 font-mono text-2xs text-faint`},yZ={key:1,class:`px-2 py-2 text-xs text-muted`},bZ={class:`px-2 pt-1.5 text-xs font-semibold text-ink`},xZ={class:`mt-2 flex justify-end gap-1.5 px-1 pb-1`},SZ=P({__name:`WorkspacePicker`,props:{workspaces:{},selectedId:{}},emits:[`select`,`create`,`rename`,`remove`],setup(e,{emit:t}){let n=e,r=t,i=A(!1),a=A(!1),o=G(()=>n.workspaces.find(e=>e.id===n.selectedId)??null);function s(e){r(`select`,e),i.value=!1}function c(){a.value=!0}function l(){a.value=!1}function u(){let e=o.value;a.value=!1,i.value=!1,e!==null&&r(`remove`,e)}function d(){i.value=!1,r(`create`)}function f(){i.value=!1,o.value!==null&&r(`rename`,o.value)}async function p(e){i.value=e,e&&(a.value=!1,await rr())}return(t,n)=>(R(),B(j(Uh),{open:i.value,"onUpdate:open":p},{default:M(()=>[H(j(Xh),{"as-child":``},{default:M(()=>[V(`button`,{type:`button`,class:O(j(Q)(`flex h-8 max-w-36 items-center gap-1.5 rounded-control border border-line bg-panel-2 px-2 text-xs transition-colors duration-150 hover:border-line hover:text-ink sm:max-w-52`,j(IL))),"aria-label":`Workspace: ${o.value?.label??`none`}`},[H(j(iy),{class:`size-3.5 shrink-0 text-faint`}),V(`span`,dZ,k(o.value?.label??`No workspace`),1),V(`span`,fZ,k(o.value?.runningCount??0)+`/`+k(o.value?.serverCount??0),1),H(j(zv),{class:`size-3 shrink-0 text-faint`})],10,uZ)]),_:1}),H(j(Yh),null,{default:M(()=>[H(j(Jh),{"side-offset":6,align:`end`,class:`z-50 w-72 rounded-panel border border-line bg-raise p-1 shadow-float focus-visible:outline-none data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`},{default:M(()=>[a.value?(R(),z(L,{key:1},[V(`p`,bZ,` Delete “`+k(o.value?.label)+`”? `,1),n[5]||=V(`p`,{class:`mt-1 px-2 text-2xs leading-4 text-muted`},` Its servers are stopped, and its config, settings, logs, secrets and nanny state are removed from disk. A backup taken first is the only way back. `,-1),V(`div`,xZ,[H($,{size:`xs`,variant:`ghost`,onClick:l},{default:M(()=>[...n[3]||=[U(` Keep it `,-1)]]),_:1}),H($,{size:`xs`,variant:`danger`,onClick:u},{default:M(()=>[H(j(Fy),{class:`size-3`}),n[4]||=U(`Delete workspace `,-1)]),_:1})])],64)):(R(),z(L,{key:0},[n[1]||=V(`p`,{class:`px-2 pb-1 pt-1.5 text-2xs font-medium text-faint`},` Workspaces `,-1),e.workspaces.length>0?(R(),z(`ul`,pZ,[(R(!0),z(L,null,F(e.workspaces,t=>(R(),z(`li`,{key:t.id},[V(`button`,{type:`button`,class:O(j(Q)(`flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left transition-colors duration-100`,t.id===e.selectedId?`bg-accent-soft text-ink`:`text-muted hover:bg-hover`)),onClick:e=>s(t.id)},[H(j(Pv),{class:O([`size-3.5 shrink-0`,t.id===e.selectedId?`text-accent`:`opacity-0`])},null,8,[`class`]),V(`span`,hZ,[V(`span`,gZ,k(t.label),1),V(`span`,_Z,k(t.id),1)]),V(`span`,vZ,k(t.runningCount)+`/`+k(t.serverCount),1)],10,mZ)]))),128))])):(R(),z(`p`,yZ,` The panel serves no workspace yet. `)),n[2]||=V(`div`,{class:`my-1 h-px bg-line`},null,-1),V(`button`,{type:`button`,class:`flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-xs text-muted outline-none transition-colors duration-100 hover:bg-hover hover:text-ink`,onClick:d},[H(j(_y),{class:`size-3.5`}),n[0]||=U(` New workspace… `,-1)]),o.value?(R(),z(L,{key:2},[V(`button`,{type:`button`,class:`flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-xs text-muted outline-none transition-colors duration-100 hover:bg-hover hover:text-ink`,onClick:f},[H(j(hy),{class:`size-3.5`}),U(` Rename “`+k(o.value.label)+`”… `,1)]),V(`button`,{type:`button`,class:`flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-xs text-danger outline-none transition-colors duration-100 hover:bg-danger-soft`,onClick:c},[H(j(Fy),{class:`size-3.5`}),U(` Delete “`+k(o.value.label)+`”… `,1)])],64)):W(``,!0)],64))]),_:1})]),_:1})]),_:1},8,[`open`]))}}),CZ=P({__name:`WorkspaceSwitcher`,setup(e){let{workspaces:t,activeId:n,select:r,create:i,rename:a,remove:o}=nP(),s=Rg(),c=Lg(),l=A(!1),u=A(`create`),d=A(null);function f(e){r(e);let t=String(s.name??``);if(t===`overview`||t===`servers`||t===`logs`||t===`settings`){c.push(_X(e,t));return}t===`server-detail`&&c.push(_X(e,`servers`))}function p(){u.value=`create`,d.value=null,l.value=!0}function m(e){u.value=`rename`,d.value=e,l.value=!0}async function h(e){if(u.value===`create`)return await i(e)!==void 0;let t=d.value;return t!==null&&a(t.id,e)}async function g(e){let t=String(s.params.workspaceId??``)||n.value;if(!await o(e.id)||t!==e.id)return;let r=String(s.name??``);(r===`overview`||r===`servers`||r===`logs`||r===`settings`)&&c.push(_X(n.value,r))}return(e,r)=>(R(),z(L,null,[H(SZ,{workspaces:j(t),"selected-id":j(n),onSelect:f,onCreate:p,onRename:m,onRemove:g},null,8,[`workspaces`,`selected-id`]),H(lZ,{open:l.value,"onUpdate:open":r[0]||=e=>l.value=e,mode:u.value,initial:d.value?.label??``,submit:h},null,8,[`open`,`mode`,`initial`])],64))}}),wZ={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`},TZ={class:`min-w-0 flex-1 truncate text-sm font-semibold tracking-tight text-ink`},EZ={class:`flex shrink-0 items-center gap-1.5`},DZ={class:`hidden items-center gap-1.5 rounded-control border border-line bg-panel-2 px-2 py-1.5 md:flex`},OZ={class:`font-mono text-2xs text-muted`},kZ={class:`px-2 py-1.5`},AZ={class:`truncate font-mono text-2xs text-muted`},jZ=P({__name:`TopBar`,props:{panelUrl:{},connection:{},authenticated:{type:Boolean}},emits:[`menu`,`palette`,`signOut`],setup(e,{emit:t}){let n=e,r=t,i=Rg(),a=XN(),o=G(()=>i.name===`server-detail`?`Servers / ${String(i.params.id??``)}`:String(i.meta.title??`home-hosted`)),s=G(()=>a.preference.value===`dark`?fy:a.preference.value===`light`?jy:dy),c=G(()=>`Theme: ${a.preference.value}`),l=G(()=>({open:`bg-ok`,connecting:`bg-warn`,closed:`bg-danger`})[n.connection]),u=G(()=>({open:`Live updates`,connecting:`Connecting`,closed:`Reconnecting`})[n.connection]);return(t,i)=>(R(),z(`header`,wZ,[V(`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`)},[H(j(ly),{class:`size-4`})]),V(`h1`,TZ,k(o.value),1),V(`div`,EZ,[V(`button`,{type:`button`,class:O(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(IL))),onClick:i[1]||=e=>r(`palette`)},[H(j(Cy),{class:`size-3.5`}),i[5]||=V(`span`,{class:`pr-6`},`Search or run a command`,-1),i[6]||=V(`kbd`,{class:`rounded border border-line bg-page px-1 py-0.5 font-mono text-2xs text-faint`},`⌘K`,-1)],2),H(JR,{label:u.value},{default:M(()=>[V(`span`,DZ,[V(`span`,{class:O(j(Q)(`size-1.5 rounded-full`,l.value))},null,2),V(`span`,OZ,k(e.panelUrl),1)])]),_:1},8,[`label`]),H(JR,{label:c.value},{default:M(()=>[H($,{variant:`ghost`,size:`icon-sm`,"aria-label":c.value,onClick:i[2]||=e=>j(a).cycle()},{default:M(()=>[(R(),B(ma(s.value),{class:`size-4`}))]),_:1},8,[`aria-label`])]),_:1},8,[`label`]),n.authenticated?(R(),B(j($h),{key:0},{default:M(()=>[H(j(ig),{"as-child":``},{default:M(()=>[H($,{variant:`ghost`,size:`icon-sm`,"aria-label":`Account`},{default:M(()=>[...i[7]||=[V(`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}),H(j(ng),null,{default:M(()=>[H(j(eg),{"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(()=>[V(`div`,kZ,[i[8]||=V(`p`,{class:`text-2xs text-faint`},` Signed in `,-1),V(`p`,AZ,k(n.panelUrl),1)]),H(j(rg),{class:`my-1 h-px bg-line`}),H(j(tg),{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(()=>[H(j(cy),{class:`size-3.5`}),i[9]||=U(` Sign out `,-1)]),_:1})]),_:1})]),_:1})]),_:1})):W(``,!0),H(JR,{label:`Command palette`},{default:M(()=>[H($,{variant:`ghost`,size:`icon-sm`,class:`sm:hidden`,"aria-label":`Open the command palette`,onClick:i[4]||=e=>r(`palette`)},{default:M(()=>[H(j(Gv),{class:`size-4`})]),_:1})]),_:1}),H(CZ)])]))}}),MZ={key:1,class:`flex h-dvh overflow-hidden bg-page`},NZ={class:`hidden w-60 shrink-0 border-r border-line bg-panel/50 lg:block`},PZ={key:0,class:`fixed inset-y-0 left-0 z-40 w-64 border-r border-line bg-panel lg:hidden`},FZ={class:`flex min-w-0 flex-1 flex-col`};vu(P({__name:`App`,setup(e){let t=Rg(),n=Lg(),r=VN(),i=nP(),{session:a,logout:o}=rN(),s=A(!1),c=A(!1),l=G(()=>a.value?.authenticated===!0),u=G(()=>a.value?.authRequired===!0),d=G(()=>t.name===`login`),f=G(()=>t.name===`logs`),p=G(()=>i.runningCount.value),m=G(()=>i.serverCount.value),h=G(()=>r.control.value?.url??`—`),g=G(()=>r.host.value),_=G(()=>r.control.value?.label??`home-hosted`),v=G(()=>r.version.value),y=G(()=>i.selected.value?.label??`none`),b=G(()=>i.activeId.value);return N(G(()=>nN(a.value)),e=>{if(e!==`wait`){if(e===`login`){zN(),n.push({name:`login`});return}RN()}},{immediate:!0}),N(()=>t.fullPath,()=>{c.value=!1}),ta(async()=>{(!u.value||l.value)&&await r.refresh()}),ze(()=>zN()),(e,t)=>{let n=fa(`RouterView`);return R(),B(j(dg),{"delay-duration":300},{default:M(()=>[d.value?(R(),B(n,{key:0})):(R(),z(`div`,MZ,[V(`aside`,NZ,[H(YX,{host:g.value,connection:j(r).connection.value,"panel-label":_.value,"panel-version":v.value,"plan-label":h.value,"workspace-id":b.value,"workspace-label":y.value,running:p.value,total:m.value},null,8,[`host`,`connection`,`panel-label`,`panel-version`,`plan-label`,`workspace-id`,`workspace-label`,`running`,`total`])]),H(Ec,{"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(()=>[c.value?(R(),z(`div`,{key:0,class:`fixed inset-0 z-40 bg-black/45 lg:hidden`,onClick:t[0]||=e=>c.value=!1})):W(``,!0)]),_:1}),H(Ec,{"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(()=>[c.value?(R(),z(`aside`,PZ,[H(YX,{host:g.value,connection:j(r).connection.value,"panel-label":_.value,"panel-version":v.value,"plan-label":h.value,"workspace-id":b.value,"workspace-label":y.value,running:p.value,total:m.value,onNavigate:t[1]||=e=>c.value=!1,onClose:t[2]||=e=>c.value=!1},null,8,[`host`,`connection`,`panel-label`,`panel-version`,`plan-label`,`workspace-id`,`workspace-label`,`running`,`total`])])):W(``,!0)]),_:1}),V(`div`,FZ,[H(jZ,{"panel-url":h.value,connection:j(r).connection.value,authenticated:l.value,onMenu:t[3]||=e=>c.value=!0,onPalette:t[4]||=e=>s.value=!0,onSignOut:t[5]||=e=>j(o)()},null,8,[`panel-url`,`connection`,`authenticated`]),d.value?W(``,!0):(R(),B(eZ,{key:0,control:j(r).control.value,"config-error":j(i).configError.value,"config-path":j(i).selected.value?.configPath},null,8,[`control`,`config-error`,`config-path`])),V(`main`,{class:O(j(Q)(`relative min-h-0 flex-1`,f.value?`overflow-hidden`:`overflow-y-auto`))},[H(n)],2)])])),H(EX,{open:s.value,"onUpdate:open":t[6]||=e=>s.value=e},null,8,[`open`]),H(oZ)]),_:1})}}})).use(gX).mount(`#app`);
45
+ `),bootstrapEnv:xL(e.bootstrap?.env??{}),bootstrapTimeoutMs:e.bootstrap?.timeoutMs??12e4,bootstrapRunOnce:e.bootstrap?.runOnce??!0}}let u=en(l(n.config)),d=A({...n.config.restart}),f=A(ZI(n.config.health)),p=A({...n.config.stop}),m=G(()=>{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:bL(u.args),env:SL(u.env),dataEnvs:SL(u.dataEnvs),backupPaths:bL(u.backupPaths),backupIgnoreGenerated:u.backupIgnoreGenerated,dependsOn:CL(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:ZI(f.value),stop:{...p.value},bootstrap:u.bootstrapEnabled?{command:u.bootstrapCommand.trim(),args:bL(u.bootstrapArgs),env:SL(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 UI(n.config,e)}function v(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}let y=G(()=>_(h())),b=G(()=>KI(y.value)),x=G(()=>b.value>0),S=G(()=>GI(y.value,n.config)),C=A(!1),w=T(n.config);function T(e){return JSON.parse(JSON.stringify(e))}function ee(e){Object.assign(u,l(e)),d.value={...e.restart},f.value=ZI(e.health),p.value={...e.stop},w=T(e),s.value=null}N(()=>n.config,e=>{v(e,w)||ee(e)});async function E(){s.value=null,o.value=!0;try{let e=h(),t=RA(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.workspaceId,n.serverId,i),a.lastError.value!==null){s.value=a.lastError.value;return}r(`saved`)}finally{o.value=!1}}return(e,t)=>(R(),z(L,null,[V(`form`,{class:`border-t border-line bg-page/40 px-4 py-4`,onSubmit:cu(E,[`prevent`])},[V(`header`,dJ,[t[32]||=V(`div`,{class:`min-w-0`},[V(`h2`,{class:`text-sm font-semibold text-ink`},` Edit configuration `),V(`p`,{class:`mt-0.5 text-2xs leading-4 text-muted`},[U(` Writes overrides to `),V(`span`,{class:`font-mono`},`servers.config.json`),U(`; anything left alone keeps inheriting the defaults. `)])],-1),V(`div`,fJ,[b.value>0?(R(),z(`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},[V(`span`,pJ,k(b.value),1),U(` unsaved `+k(b.value===1?`change`:`changes`),1)])):(R(),z(`span`,mJ,`in sync`))])]),V(`div`,hJ,[H(IL,{title:`Process`,description:`What gets spawned, where, and with which environment.`,columns:2},{default:M(()=>[H(iR,{modelValue:u.label,"onUpdate:modelValue":t[1]||=e=>u.label=e,label:`Label`,placeholder:`falls back to the id`},null,8,[`modelValue`]),H(iR,{modelValue:u.command,"onUpdate:modelValue":t[2]||=e=>u.command=e,label:`Command`,placeholder:`node`,required:``,class:`font-mono text-xs`},null,8,[`modelValue`]),H(iR,{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`]),H(iR,{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`]),H(SR,{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`]),H(SR,{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`]),H(SR,{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`]),H(SR,{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`]),H(oR,{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`]),H(iR,{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`]),H(qL,{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}),H(IL,{title:`Port & binding`,description:`How the port is preflighted and where the process is reachable.`,columns:2},{default:M(()=>[H(qL,{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`]),H($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`]),H($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`]),H(qL,{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}),H(IL,{title:`Lifecycle`,description:`Whether the supervisor owns this entry at all.`,columns:3},{default:M(()=>[H(oR,{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`]),H(oR,{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`]),H(oR,{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}),H(sR,{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`]),H(IL,{title:`Bootstrap`,description:`A one-off command run before the first start — installs, migrations, downloads.`,columns:2},{default:M(()=>[H(oR,{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?(R(),z(L,{key:0},[H(iR,{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`]),H(qL,{modelValue:u.bootstrapTimeoutMs,"onUpdate:modelValue":t[24]||=e=>u.bootstrapTimeoutMs=e,label:`Timeout (ms)`,min:1e3,step:1e3},null,8,[`modelValue`]),H(oR,{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)):W(``,!0),u.bootstrapEnabled?(R(),B(SR,{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`])):W(``,!0),u.bootstrapEnabled?(R(),B(SR,{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`])):W(``,!0)]),_:1})]),s.value?(R(),z(`p`,gJ,k(s.value),1)):W(``,!0),V(`div`,_J,[H($,{variant:`ghost`,onClick:t[28]||=e=>r(`cancel`)},{default:M(()=>[...t[33]||=[U(` Cancel `,-1)]]),_:1}),H($,{type:`submit`,variant:`primary`,disabled:o.value||!x.value,loading:o.value},{default:M(()=>[...t[34]||=[U(` Save to servers.config.json `,-1)]]),_:1},8,[`disabled`,`loading`])])],32),H(vR,{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(()=>[H($,{size:`sm`,variant:`ghost`,onClick:t[29]||=e=>C.value=!1},{default:M(()=>[...t[36]||=[U(` Close `,-1)]]),_:1}),H($,{size:`sm`,variant:`primary`,disabled:S.value.length===0||o.value,loading:o.value,onClick:t[30]||=e=>{E(),C.value=!1}},{default:M(()=>[U(` Save `+k(S.value.length)+` change`+k(S.value.length===1?``:`s`),1)]),_:1},8,[`disabled`,`loading`])]),default:M(()=>[V(`div`,vJ,[S.value.length>0?(R(),z(`ul`,yJ,[(R(!0),z(L,null,F(S.value,e=>(R(),z(`li`,{key:e.path,class:`flex flex-wrap items-baseline gap-x-3 gap-y-1 py-2 first:pt-0`},[V(`code`,bJ,k(e.path),1),V(`span`,xJ,k(j(pI)(e.from)),1),t[35]||=V(`span`,{class:`text-2xs text-faint`},`→`,-1),V(`span`,SJ,k(j(pI)(e.to)),1)]))),128))])):(R(),z(`p`,CJ,` Nothing to save. `))])]),_:1},8,[`open`])],64))}}),TJ={key:0,class:`mx-auto max-w-3xl p-4 sm:p-5`},EJ={key:1,class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},DJ={class:`font-mono text-xs text-faint`},OJ=[`href`],kJ={class:`px-2 py-1.5`},AJ={class:`flex flex-col gap-0.5`},jJ=[`onClick`],MJ={class:`space-y-2`},NJ={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`},PJ={class:`min-w-0 flex-1 text-2xs leading-4 text-danger`},FJ={key:1,class:`rounded-control border border-warn/25 bg-warn-soft px-3 py-2 text-2xs leading-4 text-warn`},IJ={class:`grid grid-cols-2 gap-x-4 gap-y-3 p-4 sm:grid-cols-4 lg:grid-cols-6`},LJ={class:`truncate text-2xs text-faint`},RJ={class:`truncate font-mono text-xs tabular-nums text-ink capitalize`},zJ={class:`grid gap-4 sm:grid-cols-3`},BJ={class:`flex items-center justify-between gap-3`},VJ=[`title`],HJ={key:1,class:`space-y-4`},UJ={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`},WJ={key:1,class:`grid grid-cols-1 gap-x-6 gap-y-2 sm:grid-cols-2`},GJ={class:`text-2xs text-faint`},KJ=[`title`],qJ={key:2,class:`grid gap-4 lg:grid-cols-3`},JJ={key:0,class:`flex flex-wrap gap-1.5`},YJ={key:1,class:`text-xs text-muted`},XJ=P({__name:`ServerDetailView`,setup(e){let t=Rg(),n=WN(),r=aP(),i=G(()=>String(t.params.id??``));N([i,()=>n.appState.value],()=>{let e=i.value;if(e.length===0||r.serverById(e)!==void 0)return;let t=n.workspaces.value.filter(t=>t.servers.some(t=>t.id===e));t.length===1&&r.select(t[0].id)},{immediate:!0});let a=G(()=>r.serverById(i.value)),o=G(()=>a.value?.config),s=G(()=>{let e=o.value;return e?.label&&e.label.length>0?e.label:i.value}),c=A(`output`),l=A(!1),u=A(!1),d=A(!1),f=A(!1),p=UN(r.activeId,()=>a.value?i.value:null),m=p.version,h=G(()=>(m.value,p.lines())),g=G(()=>r.seriesOf(i.value)),_=n.now,v=G(()=>g.value.cpu),y=G(()=>g.value.rss),b=G(()=>g.value.probe),x=G(()=>{let e=a.value;return!e||e.startedAt===null||e.status!==`running`?`—`:oI(_.value-e.startedAt)}),S=G(()=>a.value?.status===`running`),C=G(()=>{let e=a.value;if(!e)return[];let t=[{key:`pid`,label:`PID`,value:e.pid===null?`—`:String(e.pid)},{key:`uptime`,label:`Uptime`,value:x.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:dI(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:cI(e.history.uptimeRatio)},{key:`crashes`,label:`24h crashes`,value:String(e.history.crashes)},{key:`lastcrash`,label:`Last crash`,value:lI(e.history.lastCrashAt,_.value)}];return e.nextRetryAt!==null&&t.push({key:`retry`,label:`Next attempt`,value:sI(e.nextRetryAt,_.value)}),e.unhealthySince!==null&&t.push({key:`unhealthy`,label:`Unhealthy for`,value:oI(_.value-e.unhealthySince)}),t}),w=G(()=>JSON.stringify(o.value??{},null,2)),T=G(()=>o.value?`${o.value.command} ${o.value.args.join(` `)}`.trim():``),ee=G(()=>{let e=o.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){f.value=!0;try{await n[e](r.activeId.value,i.value)}finally{f.value=!1}}async function te(){d.value=!1,await r.removeServer(i.value)}async function ne(){let e=a.value;if(e){f.value=!0;try{await r.freePort(e.id)}finally{f.value=!1}}}let re=G(()=>gM(r.activeId.value,i.value,`${i.value}.log`)),ie=[{value:`output`,label:`Live output`},{value:`config`,label:`Configuration`},{value:`history`,label:`History`}];return(e,t)=>{let n=fa(`RouterLink`);return a.value?(R(),z(`div`,EJ,[H(jz,{title:s.value,"back-to":j(NX)(j(r).activeId.value,`servers`),"back-label":`All servers`},{badges:M(()=>[H(XR,{status:a.value.status,health:a.value.health},null,8,[`status`,`health`]),a.value.adopted?(R(),B(ZR,{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]||=[V(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`detached`,-1)]]),_:1})):W(``,!0),a.value.config.persistent?(R(),B(ZR,{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]||=[V(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`persistent`,-1)]]),_:1})):W(``,!0),V(`span`,DJ,k(a.value.id),1),a.value.url?(R(),z(`a`,{key:2,href:a.value.url,target:`_blank`,rel:`noreferrer`,class:`inline-flex items-center gap-1 font-mono text-xs text-accent hover:underline`},[U(k(a.value.url)+` `,1),H(j(Xv),{class:`size-3`})],8,OJ)):W(``,!0)]),actions:M(()=>[H($,{variant:`primary`,disabled:f.value||!o.value?.enabled||[`running`,`starting`].includes(a.value.status),onClick:t[0]||=e=>E(`start`)},{default:M(()=>[H(j(gy),{class:`size-3.5`}),t[18]||=U(`Start `,-1)]),_:1},8,[`disabled`]),H($,{disabled:f.value||a.value.status===`stopped`,onClick:t[1]||=e=>E(`stop`)},{default:M(()=>[H(j(Ay),{class:`size-3.5`}),t[19]||=U(`Stop `,-1)]),_:1},8,[`disabled`]),H($,{disabled:f.value||!o.value?.enabled,onClick:t[2]||=e=>E(`restart`)},{default:M(()=>[H(j(xy),{class:`size-3.5`}),t[20]||=U(`Restart `,-1)]),_:1},8,[`disabled`]),H(ZR,{label:`Edit every field of this entry`},{default:M(()=>[H($,{variant:l.value?`secondary`:`ghost`,onClick:t[3]||=e=>{l.value=!l.value,c.value=`config`}},{default:M(()=>[H(j(hy),{class:`size-3.5`}),U(k(l.value?`Close editor`:`Edit`),1)]),_:1},8,[`variant`])]),_:1}),H(j($h),null,{default:M(()=>[H(j(ig),{"as-child":``},{default:M(()=>[H($,{variant:`ghost`,size:`icon-sm`,"aria-label":`More actions for ${s.value}`},{default:M(()=>[H(j(Yv),{class:`size-4`})]),_:1},8,[`aria-label`])]),_:1}),H(j(ng),null,{default:M(()=>[H(j(eg),{"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(()=>[H(j(tg),{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(r).setEnabled(a.value.id,!a.value.config.enabled)},{default:M(()=>[U(k(o.value?.enabled?`Disable server`:`Enable server`),1)]),_:1}),H(j(tg),{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(r).setAutostart(a.value.id,!a.value.config.autostart)},{default:M(()=>[U(k(o.value?.autostart?`Remove from autostart`:`Autostart with the panel`),1)]),_:1}),H(j(rg),{class:`my-1 h-px bg-line`}),V(`div`,kJ,[t[21]||=V(`p`,{class:`mb-1 text-2xs text-faint`},` Bind `,-1),V(`div`,AJ,[(R(!0),z(L,null,F(ee.value,e=>(R(),z(`button`,{key:e.value,type:`button`,class:O([`rounded-control px-2 py-1 text-left font-mono text-2xs transition-colors duration-150 hover:bg-hover`,e.value===o.value?.bind?`text-accent`:`text-muted`]),onClick:t=>j(r).setBind(a.value.id,e.value)},k(e.label),11,jJ))),128))])]),H(j(rg),{class:`my-1 h-px bg-line`}),H(j(tg),{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=>d.value=!0},{default:M(()=>[H(j(Fy),{class:`size-3.5`}),t[22]||=U(` Remove server `,-1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,[`title`,`back-to`]),V(`div`,MJ,[a.value.lastError?(R(),z(`div`,NJ,[V(`p`,PJ,k(a.value.lastError),1),a.value.status===`conflict`&&a.value.config.port!==null?(R(),B(kR,{key:0,port:a.value.config.port,busy:f.value,onConfirm:ne},null,8,[`port`,`busy`])):W(``,!0)])):W(``,!0),a.value.health===`unhealthy`?(R(),z(`p`,FJ,[t[23]||=U(` The health probe has not passed `,-1),a.value.unhealthySince===null?W(``,!0):(R(),z(L,{key:0},[U(` for `+k(j(oI)(j(_)-a.value.unhealthySince)),1)],64)),t[24]||=U(`. `,-1)])):W(``,!0)]),H(Fz,{class:`p-0`},{default:M(()=>[V(`dl`,IJ,[(R(!0),z(L,null,F(C.value,e=>(R(),z(`div`,{key:e.key,class:`min-w-0`},[V(`dt`,LJ,k(e.label),1),V(`dd`,RJ,k(e.value),1)]))),128))])]),_:1}),H(Fz,null,{header:M(()=>[...t[25]||=[V(`h2`,{class:`text-sm font-semibold text-ink`},` Telemetry `,-1),V(`p`,{class:`text-2xs text-muted`},` Sampled every 5 s while this page is open. `,-1)]]),default:M(()=>[V(`div`,zJ,[H(KR,{label:`CPU`,values:v.value,format:j(fI),max:100,"color-class":`text-cpu`,height:40},null,8,[`values`,`format`]),H(KR,{label:`Memory (RSS)`,values:y.value,format:j(dI),"color-class":`text-mem`,height:40},null,8,[`values`,`format`]),H(KR,{label:`Health probe`,values:b.value,format:e=>e===null?`—`:`${e} ms`,"color-class":`text-probe`,height:40},null,8,[`values`,`format`])])]),_:1}),V(`div`,BJ,[H(lH,{modelValue:c.value,"onUpdate:modelValue":t[7]||=e=>c.value=e,options:ie,size:`md`},null,8,[`modelValue`]),V(`p`,{class:`hidden font-mono text-2xs text-faint sm:block`,title:T.value},k(T.value),9,VJ)]),c.value===`output`?(R(),B(AW,{key:0,lines:h.value,version:j(m),live:``,clearable:``,"download-url":a.value.config.logBufferLines>0?re.value:void 0,"download-name":`${a.value.id}.log`,"empty-hint":S.value?`Waiting for the first line…`:`This server has not written anything yet.`,"min-height":`22rem`,onClear:t[8]||=e=>j(r).clearLogs(a.value.id)},null,8,[`lines`,`version`,`download-url`,`download-name`,`empty-hint`])):c.value===`config`?(R(),z(`div`,HJ,[l.value?(R(),B(wJ,{key:0,"server-id":a.value.id,"workspace-id":j(r).activeId.value,config:a.value.config,onSaved:t[9]||=e=>l.value=!1,onCancel:t[10]||=e=>l.value=!1},null,8,[`server-id`,`workspace-id`,`config`])):(R(),B(Fz,{key:1},{header:M(()=>[...t[26]||=[V(`h2`,{class:`text-sm font-semibold text-ink`},` Effective configuration `,-1),V(`p`,{class:`text-2xs text-muted`},` Defaults from Settings are already merged into these values. `,-1)]]),actions:M(()=>[H($,{size:`xs`,variant:`ghost`,onClick:t[11]||=e=>u.value=!u.value},{default:M(()=>[H(j(Wv),{class:`size-3`}),U(k(u.value?`Fields`:`Raw JSON`),1)]),_:1}),H(hV,{value:w.value,label:`Copy the JSON config`},null,8,[`value`]),H($,{size:`xs`,variant:`primary`,onClick:t[12]||=e=>l.value=!0},{default:M(()=>[H(j(hy),{class:`size-3`}),t[27]||=U(`Edit `,-1)]),_:1})]),default:M(()=>[u.value?(R(),z(`pre`,UJ,k(w.value),1)):(R(),z(`dl`,WJ,[(R(!0),z(L,null,F([{label:`command`,value:o.value?.command},{label:`args`,value:o.value?.args.join(` `)||`—`},{label:`cwd`,value:o.value?.cwd},{label:`env`,value:Object.keys(o.value?.env??{}).join(`, `)||`—`},{label:`data envs`,value:Object.entries(o.value?.dataEnvs??{}).map(([e,t])=>`${e}=${t}`).join(`, `)||`—`},{label:`env file`,value:o.value?.envFile||`—`},{label:`port · bind`,value:`${o.value?.port??`none`} · ${o.value?.bind}`},{label:`on port conflict`,value:o.value?.onPortConflict},{label:`log buffer`,value:`${o.value?.logBufferLines} lines`},{label:`rtss limit`,value:o.value?.resources.maxRssBytes?j(dI)(o.value.resources.maxRssBytes):`none`},{label:`health`,value:o.value?.health.enabled?`${o.value.health.mode} every ${o.value.health.intervalMs} ms`:`off`},{label:`restart`,value:o.value?.restart.enabled?`${o.value.restart.maxRetries} retries, ×${o.value.restart.factor}`:`off`},{label:`stop`,value:o.value?`${o.value.stop.signal} after ${o.value.stop.graceMs} ms`:`—`},{label:`bootstrap`,value:o.value?.bootstrap?`${o.value.bootstrap.command} ${o.value.bootstrap.args.join(` `)}`:`none`},{label:`backup paths`,value:o.value?.backupPaths.join(`, `)||`—`},{label:`depends on`,value:o.value?.dependsOn.join(`, `)||`—`}],e=>(R(),z(`div`,{key:e.label,class:`min-w-0 border-b border-line-soft pb-1.5 last:border-0`},[V(`dt`,GJ,k(e.label),1),V(`dd`,{class:`truncate font-mono text-xs text-ink`,title:String(e.value)},k(e.value),9,KJ)]))),128))]))]),_:1}))])):(R(),z(`div`,qJ,[H(Fz,{class:`lg:col-span-2`},{header:M(()=>[...t[28]||=[V(`h2`,{class:`text-sm font-semibold text-ink`},` Event history `,-1),V(`p`,{class:`text-2xs text-muted`},` Kept by the panel for 24 hours. `,-1)]]),default:M(()=>[H(RI,{servers:[a.value],now:j(_),limit:30},null,8,[`servers`,`now`])]),_:1}),H(Fz,null,{header:M(()=>[...t[29]||=[V(`h2`,{class:`text-sm font-semibold text-ink`},` Dependencies `,-1)]]),default:M(()=>[o.value&&o.value.dependsOn.length>0?(R(),z(`div`,JJ,[(R(!0),z(L,null,F(o.value.dependsOn,e=>(R(),B(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(()=>[U(k(e),1)]),_:2},1032,[`to`]))),128))])):(R(),z(`p`,YJ,[...t[30]||=[U(` Starts on its own. Add ids under `,-1),V(`code`,null,`dependsOn`,-1),U(` to order it after other servers. `,-1)]]))]),_:1})])),H(vR,{open:d.value,"onUpdate:open":t[14]||=e=>d.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(()=>[H($,{variant:`ghost`,onClick:t[13]||=e=>d.value=!1},{default:M(()=>[...t[31]||=[U(` Keep it `,-1)]]),_:1}),H($,{variant:`danger`,onClick:te},{default:M(()=>[H(j(Fy),{class:`size-3.5`}),t[32]||=U(`Remove `,-1)]),_:1})]),default:M(()=>[t[33]||=V(`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`])])):(R(),z(`div`,TJ,[H(rI,{title:`That server is gone`,description:`${i.value} is not in servers.config.json any more. It may have been removed from another tab.`},{action:M(()=>[H(n,{to:j(NX)(j(r).activeId.value,`servers`)},{default:M(()=>[H($,{variant:`primary`},{default:M(()=>[...t[15]||=[U(` Back to servers `,-1)]]),_:1})]),_:1},8,[`to`])]),_:1},8,[`description`])]))}}}),ZJ={class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},QJ={class:`flex flex-wrap items-center gap-2`},$J={class:`relative ml-auto w-full sm:w-64`},eY={key:0,class:`grid gap-4 lg:grid-cols-2`},tY={key:3,class:`grid gap-4 lg:grid-cols-2`},nY=P({__name:`ServersView`,setup(e){let t=WN(),n=aP(),{servers:r}=n,i=A(!1),a=A(``),o=A(`all`),s=[{value:`all`,label:`All`},{value:`running`,label:`Running`},{value:`stopped`,label:`Stopped`},{value:`attention`,label:`Attention`},{value:`disabled`,label:`Disabled`}],c=G(()=>t.appState.value===null),l=G(()=>{let e=a.value.trim().toLowerCase();return r.value.filter(t=>o.value===`running`&&t.status!==`running`||o.value===`stopped`&&![`stopped`,`stopping`].includes(t.status)||o.value===`disabled`&&t.config.enabled||o.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))}),u=G(()=>({all:r.value.length,running:r.value.filter(e=>e.status===`running`).length,attention:r.value.filter(e=>e.status===`crashed`||e.status===`conflict`||e.health===`unhealthy`).length}));return(e,d)=>(R(),z(`div`,ZJ,[H(jz,{title:`Servers`,description:`Every entry in ${j(n).selected.value?.label??`this workspace`}'s servers.config.json, with live resources, health and history.`},{actions:M(()=>[H($,{variant:`ghost`,onClick:d[0]||=e=>j(n).startAll()},{default:M(()=>[H(j(gy),{class:`size-3.5`}),d[9]||=U(`Start all `,-1)]),_:1}),H($,{variant:`ghost`,onClick:d[1]||=e=>j(n).stopAll()},{default:M(()=>[H(j(Ay),{class:`size-3.5`}),d[10]||=U(`Stop all `,-1)]),_:1}),H($,{variant:`primary`,onClick:d[2]||=e=>i.value=!0},{default:M(()=>[H(j(_y),{class:`size-3.5`}),d[11]||=U(`Add server `,-1)]),_:1})]),_:1},8,[`description`]),V(`div`,QJ,[H(lH,{modelValue:o.value,"onUpdate:modelValue":d[3]||=e=>o.value=e,options:s.map(e=>({...e,label:`${e.label}${e.value===`all`?` ${u.value.all}`:e.value===`running`?` ${u.value.running}`:e.value===`attention`&&u.value.attention>0?` ${u.value.attention}`:``}`}))},null,8,[`modelValue`,`options`]),V(`div`,$J,[H(j(Cy),{class:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),xr(V(`input`,{"onUpdate:modelValue":d[4]||=e=>a.value=e,type:`search`,placeholder:`Filter by id, label, command or port`,class:O([`pl-8`,[j(HL)]]),"aria-label":`Filter servers`},null,2),[[ql,a.value]]),a.value.length>0?(R(),z(`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:d[5]||=e=>a.value=``},[H(j(Ry),{class:`size-3.5`})])):W(``,!0)])]),c.value?(R(),z(`div`,eY,[(R(),z(L,null,F(4,e=>H(Iz,{key:e,class:`h-72 w-full`,rounded:`rounded-panel`})),64))])):j(r).length===0?(R(),B(rI,{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(()=>[H(j(wy),{class:`size-4`})]),action:M(()=>[H($,{variant:`primary`,onClick:d[6]||=e=>i.value=!0},{default:M(()=>[H(j(_y),{class:`size-3.5`}),d[12]||=U(`Add a server `,-1)]),_:1})]),_:1})):l.value.length===0?(R(),B(rI,{key:2,compact:``,title:`Nothing matches that filter`,description:`Try a different status or clear the search.`},{action:M(()=>[H($,{onClick:d[7]||=e=>{a.value=``,o.value=`all`}},{default:M(()=>[...d[13]||=[U(` Clear filters `,-1)]]),_:1})]),_:1})):(R(),z(`div`,tY,[(R(!0),z(L,null,F(l.value,e=>(R(),B(wz,{key:e.id,server:e,"workspace-id":j(n).activeId.value,series:j(n).seriesOf(e.id),now:j(t).now.value},null,8,[`server`,`workspace-id`,`series`,`now`]))),128))])),H(ER,{open:i.value,"onUpdate:open":d[8]||=e=>i.value=e,"workspace-id":j(n).activeId.value},null,8,[`open`,`workspace-id`])]))}}),rY=0;function iY(){return rY+=1,`ddns-row-${rY}`}function aY(){return iY()}function oY(e){let t=structuredClone(un(e));return t.domains=(t.domains??[]).map(e=>({...e,key:e.key??iY()})),t}function sY(e){let t=structuredClone(un(e));return{...t,domains:t.domains.map(({key:e,...t})=>t)}}function cY(e,t){return e===null||t===null?e===t:JSON.stringify(sY(e))===JSON.stringify(sY(t))}var lY={class:`space-y-3`},uY={class:`rounded-panel border border-line bg-panel-2/40 p-3.5`},dY={key:0,class:`divide-y divide-line-soft`},fY={class:`min-w-0`},pY={class:`font-mono text-xs text-ink`},mY={class:`text-2xs text-faint`},hY={key:0},gY={class:`ml-auto flex items-center gap-2`},_Y={key:1,class:`text-2xs text-muted`},vY={class:`mt-3 grid gap-2 border-t border-line-soft pt-3 sm:grid-cols-[1fr_1fr_auto] sm:items-end`},yY={class:`rounded-panel border border-line bg-panel-2/40 p-3.5`},bY={key:0,class:`space-y-2`},xY={class:`flex flex-wrap items-end gap-2`},SY={class:`min-w-40 flex-1`},CY={class:`w-44 shrink-0`},wY={class:`mt-1 flex flex-wrap items-center gap-x-4 gap-y-1`},TY={key:1,class:`text-2xs text-muted`},EY={class:`mt-3 grid gap-2 border-t border-line-soft pt-3 sm:grid-cols-[1fr_1fr_auto] sm:items-end`},DY={key:1,class:`rounded-panel border border-line bg-panel-2/40 p-3.5`},OY={class:`mb-2 flex flex-wrap items-center gap-x-3 gap-y-1`},kY={key:0,class:`text-2xs text-muted`},AY={key:1,class:`font-mono text-2xs text-faint`},jY={key:2,class:`font-mono text-2xs text-faint`},MY={key:3,class:`ml-auto text-2xs text-faint`},NY={class:`overflow-x-auto`},PY={class:`w-full text-left text-xs`},FY={class:`py-1.5 pr-3 font-mono text-2xs text-ink`},IY={class:`py-1.5 pr-3 text-2xs text-muted`},LY={class:`py-1.5 pr-3`},RY={class:`py-1.5 pr-3 font-mono text-2xs text-muted`},zY={class:`py-1.5 text-2xs text-faint`},BY={class:`space-y-3`},VY=[`href`],HY=P({__name:`DdnsSection`,props:{patch:{default:null},patchModifiers:{},baseline:{default:null},baselineModifiers:{}},emits:[`update:patch`,`update:baseline`],setup(e,{expose:t}){let n=oo(e,`patch`),r=oo(e,`baseline`),i={pending:{label:`Waiting`,tone:`neutral`},ok:{label:`Updated`,tone:`ok`},unchanged:{label:`Current`,tone:`neutral`},skipped:{label:`Skipped`,tone:`warn`},error:{label:`Failed`,tone:`danger`}},a=WN(),o=aP(),s=dN(),c=A(null),l=A(null),u=A(null),d=A(null),f=A(!1),p=en({id:``,provider:`cloudflare`}),m=en({host:``,account:``}),h=A(null),g=A({}),_=A(!1),v=A(null),y=G(()=>c.value?.providers??[]),b=G(()=>l.value?.accounts??[]),x=G(()=>l.value?.domains??[]),S=G(()=>b.value.map(e=>e.id).join(`,`)),C=G(()=>y.value.map(e=>({value:e.id,label:e.label}))),w=G(()=>b.value.map(e=>({value:e.id,label:e.id}))),T=G(()=>o.selected.value?.ddns??c.value?.status??null),ee=G(()=>l.value!==null&&r.value!==null&&!cY(l.value,r.value)),E=G(()=>/^[a-z0-9][a-z0-9_-]*$/.test(p.id)&&!b.value.some(e=>e.id===p.id)),te=G(()=>m.host.includes(`.`)&&m.account.length>0&&!x.value.some(e=>e.host.toLowerCase()===m.host.trim().toLowerCase())),ne=G({get:()=>h.value!==null,set:e=>{e||(h.value=null)}}),re=G(()=>h.value===null?[]:ie(h.value.provider)?.fields??[]);function ie(e){return y.value.find(t=>t.id===e)??null}function ae(e){let t=b.value.find(t=>t.id===e.account);return t===void 0?null:ie(t.provider)}function oe(e){return ie(e.provider)?.label??e.provider}function se(e){return c.value?.credentials.includes(e)===!0}function ce(e){return x.value.filter(t=>t.account===e).length}function D(e,t,n){let r=n?[...new Set([...e.types,t])]:e.types.filter(e=>e!==t);e.types=r.length>0?r:e.types}function le(e,t,n){n==null||n===``?delete e[t]:e[t]=n}function ue(){n.value=l.value===null||r.value===null||cY(l.value,r.value)?null:sY(l.value)}function de(e,t=!1){c.value=e,r.value=oY(e.config),t||(l.value=oY(e.config)),ue()}async function fe(){u.value=null;try{de(await OM(o.activeId.value)),p.provider=C.value[0]?.value??`cloudflare`,m.account=b.value[0]?.id??``}catch(e){u.value=e instanceof Error?e.message:String(e)}}ta(()=>{fe()}),N(()=>o.activeId.value,(e,t)=>{e!==t&&e.length>0&&fe()}),N(l,ue,{deep:!0}),N(S,()=>{b.value.some(e=>e.id===m.account)||(m.account=b.value[0]?.id??``)});function pe(){E.value&&l.value!==null&&(l.value.accounts.push({id:p.id,provider:p.provider,label:``}),p.id=``)}function me(e){l.value===null||ce(e.id)>0||(l.value.accounts=l.value.accounts.filter(t=>t.id!==e.id))}function he(){te.value&&l.value!==null&&(l.value.domains.push({host:m.host.trim().toLowerCase(),account:m.account,types:[`A`],proxied:!1,enabled:!0,key:aY()}),m.host=``)}function ge(e){l.value!==null&&(l.value.domains=l.value.domains.filter(t=>t!==e))}function _e(){r.value!==null&&(l.value=oY(r.value)),d.value=null}async function ve(){if(!f.value){f.value=!0,d.value=null;try{de(await MM(o.activeId.value),!0),s.success(T.value?.lastResult??`Dynamic DNS pass finished`)}catch(e){d.value=e instanceof Error?e.message:String(e)}finally{f.value=!1}}}function ye(e){h.value=e,g.value=Object.fromEntries((ie(e.provider)?.fields??[]).map(e=>[e.key,``])),v.value=null}async function be(){let e=h.value;if(!(e===null||_.value)){_.value=!0,v.value=null;try{de(await AM(o.activeId.value,e.id,e.provider,g.value),!0),s.success(`Credentials saved for ${e.id}`),h.value=null}catch(e){v.value=e instanceof Error?e.message:String(e)}finally{_.value=!1}}}async function O(){let e=h.value;if(!(e===null||_.value)){_.value=!0,v.value=null;try{de(await jM(o.activeId.value,e.id),!0),s.success(`Credentials removed for ${e.id}`),h.value=null}catch(e){v.value=e instanceof Error?e.message:String(e)}finally{_.value=!1}}}return t({reload:fe}),(e,t)=>(R(),z(L,null,[V(`div`,lY,[u.value?(R(),B(xB,{key:0,tone:`danger`,title:`Dynamic DNS settings could not be loaded`},{default:M(()=>[U(k(u.value),1)]),_:1})):W(``,!0),l.value===null?W(``,!0):(R(),z(L,{key:1},[H(IL,{title:`Dynamic DNS`,description:`Keep these hostnames pointed at this machine's public address. Credentials live in the secrets file, never in servers.config.json.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!ee.value,onClick:_e},{default:M(()=>[...t[11]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`]),T.value?.running?(R(),B(_V,{key:0,tone:`info`,dot:``},{default:M(()=>[...t[12]||=[U(` checking `,-1)]]),_:1})):T.value?.enabled?(R(),B(_V,{key:1,tone:T.value.records.some(e=>e.state===`error`)?`danger`:`ok`,dot:``},{default:M(()=>[U(k(T.value.records.some(e=>e.state===`error`)?`needs attention`:`watching`),1)]),_:1},8,[`tone`])):W(``,!0),H($,{size:`xs`,variant:`ghost`,loading:f.value,onClick:ve},{default:M(()=>[...t[13]||=[U(` Update now `,-1)]]),_:1},8,[`loading`])]),default:M(()=>[H(oR,{modelValue:l.value.enabled,"onUpdate:modelValue":t[0]||=e=>l.value.enabled=e,label:`Keep dynamic DNS updated`,hint:`A pass runs on the interval below; a provider is only called when the address actually changed.`,wide:``},null,8,[`modelValue`]),H(qL,{modelValue:l.value.intervalMs,"onUpdate:modelValue":t[1]||=e=>l.value.intervalMs=e,label:`Check every (ms)`,min:6e4,step:6e4,hint:`60000 is one minute; the default is five.`},null,8,[`modelValue`]),H(qL,{modelValue:l.value.ttl,"onUpdate:modelValue":t[2]||=e=>l.value.ttl=e,label:`TTL (s)`,min:1,hint:`1 means automatic where the provider supports it.`},null,8,[`modelValue`]),H(oR,{modelValue:l.value.ipv4.enabled,"onUpdate:modelValue":t[3]||=e=>l.value.ipv4.enabled=e,label:`Detect IPv4`,hint:`Needed for A records.`},null,8,[`modelValue`]),H(oR,{modelValue:l.value.ipv6.enabled,"onUpdate:modelValue":t[4]||=e=>l.value.ipv6.enabled=e,label:`Detect IPv6`,hint:`Needed for AAAA records.`},null,8,[`modelValue`])]),_:1}),d.value?(R(),B(xB,{key:0,tone:`danger`},{default:M(()=>[U(k(d.value),1)]),_:1})):W(``,!0),V(`section`,uY,[t[17]||=V(`header`,{class:`mb-3`},[V(`h3`,{class:`text-xs font-semibold text-ink`},` Provider accounts `),V(`p`,{class:`mt-0.5 text-2xs leading-4 text-muted`},` One entry per API token. Credentials are stored on the server and never come back. `)],-1),b.value.length>0?(R(),z(`ul`,dY,[(R(!0),z(L,null,F(b.value,e=>(R(),z(`li`,{key:e.id,class:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 first:pt-0`},[V(`div`,fY,[V(`p`,pY,k(e.id),1),V(`p`,mY,[U(k(oe(e))+` `,1),ce(e.id)>0?(R(),z(`span`,hY,` · `+k(ce(e.id))+` hostname`+k(ce(e.id)===1?``:`s`),1)):W(``,!0)])]),V(`div`,gY,[H(_V,{tone:se(e.id)?`ok`:`warn`,dot:``},{default:M(()=>[U(k(se(e.id)?`credentials saved`:`no credentials`),1)]),_:2},1032,[`tone`]),H($,{size:`xs`,variant:`secondary`,onClick:t=>ye(e)},{default:M(()=>[...t[14]||=[U(` Credentials `,-1)]]),_:1},8,[`onClick`]),H($,{size:`xs`,variant:`danger-ghost`,disabled:ce(e.id)>0,title:ce(e.id)>0?`Remove the hostnames using this account first`:void 0,onClick:t=>me(e)},{default:M(()=>[...t[15]||=[U(` Remove `,-1)]]),_:1},8,[`disabled`,`title`,`onClick`])])]))),128))])):(R(),z(`p`,_Y,` No accounts yet. Pick a provider and add one. `)),V(`div`,vY,[H($L,{modelValue:p.provider,"onUpdate:modelValue":t[5]||=e=>p.provider=e,label:`Provider`,options:C.value},null,8,[`modelValue`,`options`]),H(iR,{modelValue:p.id,"onUpdate:modelValue":t[6]||=e=>p.id=e,label:`Account id`,placeholder:`cloudflare-home`},null,8,[`modelValue`]),H($,{variant:`secondary`,disabled:!E.value,onClick:pe},{default:M(()=>[...t[16]||=[U(` Add `,-1)]]),_:1},8,[`disabled`])]),t[18]||=V(`p`,{class:`mt-1.5 text-2xs text-faint`}," The account id names the account and keys its stored credentials; lowercase letters, digits, `-` and `_`. ",-1)]),V(`section`,yY,[t[22]||=V(`header`,{class:`mb-3`},[V(`h3`,{class:`text-xs font-semibold text-ink`},` Hostnames `),V(`p`,{class:`mt-0.5 text-2xs leading-4 text-muted`},` The whole list to keep updated — suba.domain.com, domain.xyz and so on. `)],-1),x.value.length>0?(R(),z(`ul`,bY,[(R(!0),z(L,null,F(x.value,e=>(R(),z(`li`,{key:e.key,class:`rounded-control border border-line-soft bg-panel/50 p-2.5`},[V(`div`,xY,[V(`div`,SY,[H(iR,{modelValue:e.host,"onUpdate:modelValue":t=>e.host=t,label:`Hostname`},null,8,[`modelValue`,`onUpdate:modelValue`])]),V(`div`,CY,[H($L,{modelValue:e.account,"onUpdate:modelValue":t=>e.account=t,label:`Account`,options:w.value},null,8,[`modelValue`,`onUpdate:modelValue`,`options`])]),H(IB,{modelValue:e.enabled,"onUpdate:modelValue":t=>e.enabled=t,label:`Enabled`},null,8,[`modelValue`,`onUpdate:modelValue`]),H($,{size:`xs`,variant:`danger-ghost`,onClick:t=>ge(e)},{default:M(()=>[...t[19]||=[U(` Remove `,-1)]]),_:1},8,[`onClick`])]),V(`div`,wY,[H(IB,{"model-value":e.types.includes(`A`),label:`A (IPv4)`,"onUpdate:modelValue":t=>D(e,`A`,t===!0)},null,8,[`model-value`,`onUpdate:modelValue`]),H(IB,{"model-value":e.types.includes(`AAAA`),label:`AAAA (IPv6)`,disabled:ae(e)?.families.includes(`AAAA`)===!1,hint:ae(e)?.families.includes(`AAAA`)===!1?`This provider cannot manage AAAA records.`:void 0,"onUpdate:modelValue":t=>D(e,`AAAA`,t===!0)},null,8,[`model-value`,`disabled`,`hint`,`onUpdate:modelValue`]),ae(e)?.proxied===!0?(R(),B(IB,{key:0,modelValue:e.proxied,"onUpdate:modelValue":t=>e.proxied=t,label:`Proxied`,hint:`Cloudflare serves this record through its own network.`},null,8,[`modelValue`,`onUpdate:modelValue`])):W(``,!0),e.types.includes(`AAAA`)&&!l.value.ipv6.enabled?(R(),B(_V,{key:1,tone:`warn`},{default:M(()=>[...t[20]||=[U(` IPv6 detection is off `,-1)]]),_:1})):W(``,!0)]),H(pR,{title:`Advanced`,hint:`registered domain and TTL override`,class:`mt-2`},{default:M(()=>[H(iR,{"model-value":e.zone??``,label:`Registered domain`,placeholder:`example.co.uk`,hint:`Only when the provider has to be told the apex, e.g. three-label domains.`,"onUpdate:modelValue":t=>le(e,`zone`,t)},null,8,[`model-value`,`onUpdate:modelValue`]),ae(e)?.ttl===!1?W(``,!0):(R(),B(qL,{key:0,"model-value":e.ttl??null,min:1,nullable:``,label:`TTL override (s)`,hint:`Blank uses the value above.`,"onUpdate:modelValue":t=>le(e,`ttl`,t)},null,8,[`model-value`,`onUpdate:modelValue`]))]),_:2},1024)]))),128))])):(R(),z(`p`,TY,` No hostnames yet. `)),V(`div`,EY,[H(iR,{modelValue:m.host,"onUpdate:modelValue":t[7]||=e=>m.host=e,label:`Hostname`,placeholder:`home.example.com`},null,8,[`modelValue`]),H($L,{modelValue:m.account,"onUpdate:modelValue":t[8]||=e=>m.account=e,label:`Account`,options:w.value,disabled:b.value.length===0},null,8,[`modelValue`,`options`,`disabled`]),H($,{variant:`secondary`,disabled:!te.value,onClick:he},{default:M(()=>[...t[21]||=[U(` Add `,-1)]]),_:1},8,[`disabled`])])]),T.value!==null&&T.value.records.length>0?(R(),z(`section`,DY,[V(`header`,OY,[t[23]||=V(`h3`,{class:`text-xs font-semibold text-ink`},` Last pass `,-1),T.value.lastResult?(R(),z(`span`,kY,k(T.value.lastResult),1)):W(``,!0),T.value.ipv4?(R(),z(`span`,AY,`IPv4 `+k(T.value.ipv4),1)):W(``,!0),T.value.ipv6?(R(),z(`span`,jY,`IPv6 `+k(T.value.ipv6),1)):W(``,!0),T.value.lastRunAt?(R(),z(`span`,MY,k(j(lI)(T.value.lastRunAt,j(a).now.value)),1)):W(``,!0)]),V(`div`,NY,[V(`table`,PY,[t[24]||=V(`thead`,null,[V(`tr`,{class:`text-2xs text-faint`},[V(`th`,{class:`py-1 pr-3 font-medium`},` Hostname `),V(`th`,{class:`py-1 pr-3 font-medium`},` Type `),V(`th`,{class:`py-1 pr-3 font-medium`},` State `),V(`th`,{class:`py-1 pr-3 font-medium`},` Address `),V(`th`,{class:`py-1 font-medium`},` Detail `)])],-1),V(`tbody`,null,[(R(!0),z(L,null,F(T.value.records,e=>(R(),z(`tr`,{key:`${e.host}|${e.type}`,class:`border-t border-line-soft align-top`},[V(`td`,FY,k(e.host),1),V(`td`,IY,k(e.type),1),V(`td`,LY,[H(_V,{tone:i[e.state].tone,dot:``},{default:M(()=>[U(k(i[e.state].label),1)]),_:2},1032,[`tone`])]),V(`td`,RY,k(e.ip??`—`),1),V(`td`,zY,k(e.message??`—`),1)]))),128))])])])])):W(``,!0)],64))]),H(vR,{open:ne.value,"onUpdate:open":t[10]||=e=>ne.value=e,title:`Provider credentials`,description:h.value===null?``:`${oe(h.value)} — ${h.value.id}`,width:`w-[min(92vw,32rem)]`},{footer:M(()=>[h.value!==null&&se(h.value.id)?(R(),B($,{key:0,size:`sm`,variant:`danger-ghost`,disabled:_.value,onClick:O},{default:M(()=>[...t[26]||=[U(` Forget `,-1)]]),_:1},8,[`disabled`])):W(``,!0),H($,{size:`sm`,variant:`ghost`,disabled:_.value,onClick:t[9]||=e=>ne.value=!1},{default:M(()=>[...t[27]||=[U(` Cancel `,-1)]]),_:1},8,[`disabled`]),H($,{size:`sm`,variant:`primary`,loading:_.value,disabled:Object.values(g.value).every(e=>e.trim().length===0),onClick:be},{default:M(()=>[...t[28]||=[U(` Save credentials `,-1)]]),_:1},8,[`loading`,`disabled`])]),default:M(()=>[V(`div`,BY,[t[25]||=V(`p`,{class:`text-2xs leading-4 text-muted`},` Saved fields are never sent back. Saving replaces every field for this account and runs a pass right away. `,-1),(R(!0),z(L,null,F(re.value,e=>(R(),B(iR,{key:e.key,modelValue:g.value[e.key],"onUpdate:modelValue":t=>g.value[e.key]=t,type:`password`,autocomplete:`off`,label:e.label,hint:`${e.hint}${e.optional?` Optional.`:``}`,wide:``},null,8,[`modelValue`,`onUpdate:modelValue`,`label`,`hint`]))),128)),h.value===null?W(``,!0):(R(),z(`a`,{key:0,class:`inline-block text-2xs text-accent underline decoration-line underline-offset-2`,href:ie(h.value.provider)?.docsUrl,target:`_blank`,rel:`noreferrer`},`Where to get these`,8,VY)),v.value?(R(),B(xB,{key:1,tone:`danger`},{default:M(()=>[U(k(v.value),1)]),_:1})):W(``,!0)])]),_:1},8,[`open`,`description`])],64))}}),UY={class:`mt-3 space-y-3`},WY=P({__name:`DefaultsSection`,props:Ra({dirty:{type:Boolean}},{defaults:{required:!0},defaultsModifiers:{}}),emits:Ra([`reset`],[`update:defaults`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`defaults`),a=vL(()=>i.value.logBufferLines,e=>i.value.logBufferLines=e,500);return(e,t)=>(R(),z(L,null,[H(IL,{title:`Server defaults`,description:`Applied to every entry that does not set its own value.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[9]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(oR,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Enabled`,hint:`New entries start enabled.`,wide:``},null,8,[`modelValue`]),H(oR,{modelValue:i.value.autostart,"onUpdate:modelValue":t[2]||=e=>i.value.autostart=e,label:`Autostart with the panel`},null,8,[`modelValue`]),H($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`]),H($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`]),H(qL,{modelValue:j(a),"onUpdate:modelValue":t[5]||=e=>mn(a)?a.value=e:null,label:`Log buffer lines`,min:50,max:1e5,hint:`Kept in memory per server.`},null,8,[`modelValue`])]),_:1}),V(`div`,UY,[H(sR,{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))}}),GY={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},KY={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},qY={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},JY={class:`text-2xs leading-4 text-faint`},YY=P({__name:`LogsSection`,props:Ra({logsDir:{},dirty:{type:Boolean}},{logs:{required:!0},logsModifiers:{}}),emits:Ra([`reset`],[`update:logs`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`logs`),a=aP(),o=vL(()=>i.value.maxBytes,e=>i.value.maxBytes=e,2e6),s=vL(()=>i.value.keep,e=>i.value.keep=e,3),c=G(()=>n.logsDir??`—`);return(e,t)=>{let l=fa(`RouterLink`);return R(),B(IL,{title:`Retention`,description:`The live view always comes from memory; these files survive a restart and feed the Logs page.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[4]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(oR,{modelValue:i.value.persist,"onUpdate:modelValue":t[1]||=e=>i.value.persist=e,label:`Keep logs on disk`,hint:`Turn off to hold everything in memory only.`,class:`sm:col-span-2`},null,8,[`modelValue`]),H(qL,{modelValue:j(o),"onUpdate:modelValue":t[2]||=e=>mn(o)?o.value=e:null,label:`Rotate at (bytes)`,min:1e4,max:1e8,hint:`Per server, before rolling to .1, .2, …`},null,8,[`modelValue`]),H(qL,{modelValue:j(s),"onUpdate:modelValue":t[3]||=e=>mn(s)?s.value=e:null,label:`Keep rotated files`,min:1,max:10},null,8,[`modelValue`]),V(`div`,GY,[t[8]||=V(`span`,{class:`text-xs font-medium text-muted`},`Logs directory`,-1),V(`div`,KY,[V(`span`,qY,k(c.value),1),H(hV,{value:c.value,label:`Copy the logs directory`},null,8,[`value`])]),V(`p`,JY,[t[6]||=U(` Browse and download these files on the `,-1),H(l,{to:j(NX)(j(a).activeId.value,`logs`),class:`text-accent underline decoration-accent/40 underline-offset-2 hover:decoration-accent`},{default:M(()=>[...t[5]||=[U(` Logs `,-1)]]),_:1},8,[`to`]),t[7]||=U(` page. `,-1)])])]),_:1})}}}),XY={class:`flex items-center gap-2 border-t border-line-soft pt-3 sm:col-span-2`},ZY={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},QY={key:0,class:`sm:col-span-2`},$Y={class:`flex flex-wrap gap-1.5`},eX={key:1,class:`sm:col-span-2`},tX={class:`text-2xs leading-4 text-faint`},nX={key:2,class:`space-y-2 sm:col-span-2`},rX=P({__name:`NotificationsSection`,props:Ra({status:{},dirty:{type:Boolean}},{telegram:{required:!0},telegramModifiers:{}}),emits:Ra([`reset`],[`update:telegram`]),setup(e,{emit:t}){let n=e,r=t,i=oo(e,`telegram`),a=WN(),o=aP(),s=vL(()=>i.value.cooldownMs,e=>i.value.cooldownMs=e,12e4),c=A(``),l=A(null),u=A(null),d=A([]),f=A(!1),p=G(()=>n.status?.tokenSet===!0),m=G(()=>n.status?.lastResult??null),h=G(()=>n.status?.lastResultAt??null),g=G(()=>p.value?`Saved — type a new token to replace it`:`123456789:AA…`);async function _(){f.value=!0,u.value=null,l.value=null;try{let e=await CM(o.activeId.value,c.value.trim());c.value=``,l.value=`Token saved${e.username?` for @${e.username}`:``}.`,await a.refresh()}catch(e){u.value=e instanceof Error?e.message:String(e)}finally{f.value=!1}}async function v(){f.value=!0,u.value=null,l.value=null;try{await wM(o.activeId.value),l.value=`Token removed.`,await a.refresh()}catch(e){u.value=e instanceof Error?e.message:String(e)}finally{f.value=!1}}async function y(){f.value=!0,u.value=null,l.value=null;try{let e=c.value.trim(),t=await EM(o.activeId.value,e.length>0?{botToken:e}:{});d.value=t.chats,t.chats.length===0&&(u.value=`No chats found. Send /start to the bot first, then detect again.`)}catch(e){u.value=e instanceof Error?e.message:String(e)}finally{f.value=!1}}async function b(){f.value=!0,u.value=null,l.value=null;try{let e=c.value.trim(),t=await TM(o.activeId.value,{chatId:i.value.chatId.length>0?i.value.chatId:void 0,...e.length>0?{botToken:e}:{}});t.ok?l.value=`Test message sent.`:u.value=t.error??`The test message failed.`,await a.refresh()}catch(e){u.value=e instanceof Error?e.message:String(e)}finally{f.value=!1}}return(e,t)=>(R(),B(IL,{title:`Telegram`,description:`Policy lives in the config; the bot token is a secret and never comes back from the server.`},{actions:M(()=>[H($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:M(()=>[...t[11]||=[U(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:M(()=>[H(oR,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Send notifications`,hint:`One message per event, throttled by the cooldown below.`,wide:``},null,8,[`modelValue`]),H(iR,{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`]),H(qL,{modelValue:j(s),"onUpdate:modelValue":t[3]||=e=>mn(s)?s.value=e:null,label:`Cooldown per event (ms)`,min:0,hint:`Per server and reason, so a flapping server cannot spam.`},null,8,[`modelValue`]),H(oR,{modelValue:i.value.onCrash,"onUpdate:modelValue":t[4]||=e=>i.value.onCrash=e,label:`Retries exhausted`},null,8,[`modelValue`]),H(oR,{modelValue:i.value.onUnhealthy,"onUpdate:modelValue":t[5]||=e=>i.value.onUnhealthy=e,label:`Port unhealthy`},null,8,[`modelValue`]),H(oR,{modelValue:i.value.onForcedRestart,"onUpdate:modelValue":t[6]||=e=>i.value.onForcedRestart=e,label:`Forced restart`},null,8,[`modelValue`]),H(oR,{modelValue:i.value.onRecovered,"onUpdate:modelValue":t[7]||=e=>i.value.onRecovered=e,label:`Recovered`},null,8,[`modelValue`]),H(oR,{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`]),H(oR,{modelValue:i.value.onDdns,"onUpdate:modelValue":t[9]||=e=>i.value.onDdns=e,label:`Dynamic DNS changed or failed`,hint:`One message per pass that changed a record, and one for a pass that failed.`,wide:``},null,8,[`modelValue`]),V(`div`,XY,[t[12]||=V(`span`,{class:`text-xs font-medium text-muted`},`Bot token`,-1),H(_V,{tone:p.value?`ok`:`warn`,dot:``},{default:M(()=>[U(k(p.value?`token set`:`no token`),1)]),_:1},8,[`tone`]),t[13]||=V(`span`,{class:`text-2xs text-faint`},`From @BotFather — a secret, never in servers.config.json.`,-1)]),H(iR,{modelValue:c.value,"onUpdate:modelValue":t[10]||=e=>c.value=e,type:`password`,autocomplete:`off`,label:`Bot token`,placeholder:g.value,wide:``},null,8,[`modelValue`,`placeholder`]),V(`div`,ZY,[H($,{variant:`primary`,disabled:f.value||c.value.trim().length===0,loading:f.value&&c.value.trim().length>0,onClick:_},{default:M(()=>[...t[14]||=[U(` Save token `,-1)]]),_:1},8,[`disabled`,`loading`]),H($,{variant:`secondary`,disabled:f.value,onClick:y},{default:M(()=>[...t[15]||=[U(` Detect chats `,-1)]]),_:1},8,[`disabled`]),H($,{variant:`secondary`,disabled:f.value,onClick:b},{default:M(()=>[...t[16]||=[U(` Send test `,-1)]]),_:1},8,[`disabled`]),p.value?(R(),B(vB,{key:0,label:`Remove token`,"confirm-label":`Confirm remove`,"confirm-variant":`danger`,disabled:f.value,onConfirm:v},null,8,[`disabled`])):W(``,!0)]),d.value.length>0?(R(),z(`div`,QY,[t[17]||=V(`p`,{class:`mb-1.5 text-xs text-muted`},` Chats the bot has seen: `,-1),V(`div`,$Y,[(R(!0),z(L,null,F(d.value,e=>(R(),B($,{key:String(e.id),size:`xs`,variant:`secondary`,onClick:t=>i.value.chatId=String(e.id)},{default:M(()=>[U(k(e.title)+` (`+k(e.id)+`) `,1)]),_:2},1032,[`onClick`]))),128))])])):W(``,!0),m.value?(R(),z(`div`,eX,[V(`p`,tX,` Last send: `+k(m.value)+k(h.value?` · ${j(lI)(h.value,j(a).now.value)}`:``),1)])):W(``,!0),u.value||l.value?(R(),z(`div`,nX,[u.value?(R(),B(xB,{key:0,tone:`danger`},{default:M(()=>[U(k(u.value),1)]),_:1})):W(``,!0),l.value?(R(),B(xB,{key:1,tone:`ok`},{default:M(()=>[U(k(l.value),1)]),_:1})):W(``,!0)])):W(``,!0)]),_:1}))}}),iX={class:`min-h-full`},aX={class:`mx-auto w-full max-w-5xl px-4 pb-6 pt-5 sm:px-6`},oX={class:`lg:grid lg:grid-cols-[11rem_minmax(0,1fr)] lg:gap-8`},sX={"aria-label":`Workspace settings sections`,class:`hidden lg:block`},cX={class:`sticky top-6 space-y-0.5 border-l border-line`},lX=[`aria-current`,`onClick`],uX={class:`space-y-6`},dX={id:`defaults`,class:`scroll-mt-5`},fX={id:`logs`,class:`scroll-mt-5`},pX={id:`notifications`,class:`scroll-mt-5`},mX={id:`ddns`,class:`scroll-mt-5`},hX={class:`sticky bottom-0 z-30 border-t border-line bg-panel/95 backdrop-blur`},gX={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`},_X={class:`min-w-0 flex-1`},vX={class:`text-xs text-muted`},yX={class:`font-mono tabular-nums text-ink`},bX={key:0,class:`mt-0.5 text-xs text-danger`},xX={key:1,class:`mt-0.5 text-xs text-ok`},SX={class:`flex shrink-0 items-center gap-2`},CX={class:`max-h-[60dvh] overflow-auto px-4 py-3`},wX={key:0,class:`divide-y divide-line-soft`},TX={class:`font-mono text-xs text-ink`},EX={class:`ml-auto font-mono text-xs text-muted line-through`},DX={class:`font-mono text-xs text-accent`},OX={key:1,class:`text-xs text-muted`},kX={class:`flex items-center justify-end gap-2 border-t border-line px-4 py-3`},AX=P({__name:`SettingsView`,setup(e){let t=[{id:`defaults`,title:`Server defaults`},{id:`logs`,title:`Logs`},{id:`notifications`,title:`Notifications`},{id:`ddns`,title:`Dynamic DNS`}],n=Rg(),r=Lg(),i=WN(),a=aP(),o=dN(),s=en($I()),c=A(`defaults`),l=A(!1),u=A(null),d=A(null),f=A(null),p=A(null),m=A(null),h=G(()=>a.defaults.value),g=G(()=>a.logsConfig.value),_=G(()=>a.notifications.value?.telegram??null),v=G(()=>a.logsDir.value),y=G(()=>{let e={},t=h.value,n=g.value,r=_.value;if(t!==null){let n=lL(t,s.defaults);Object.keys(n).length>0&&(e.defaults=n)}if(n!==null){let t=uL(n,s.logs);Object.keys(t).length>0&&(e.logs=t)}if(r!==null){let t=dL(r,s.telegram);Object.keys(t).length>0&&(e.notifications=t)}return e}),b=G(()=>KI(y.value)+(f.value===null?0:KI(f.value))),x=G(()=>{let e=_.value;return{defaults:h.value??{},logs:g.value??{},notifications:e===null?{}:{telegram:nL(e)},ddns:p.value??{}}}),S=G(()=>GI({...y.value,...f.value===null?{}:{ddns:f.value}},x.value)),C=A(!1),w=G(()=>h.value!==null&&Object.keys(lL(h.value,s.defaults)).length>0),T=G(()=>g.value!==null&&Object.keys(uL(g.value,s.logs)).length>0),ee=G(()=>_.value!==null&&Object.keys(dL(_.value,s.telegram)).length>0),E={};function te(){let e=(e,t)=>{mL(E[e],pL(s,e))||(t(),E[e]=pL(s,e))},t=h.value;t!==null&&e(`defaults`,()=>{s.defaults.enabled=t.enabled,s.defaults.autostart=t.autostart,s.defaults.bind=t.bind,s.defaults.onPortConflict=t.onPortConflict,s.defaults.logBufferLines=t.logBufferLines,s.defaults.restart={...t.restart},s.defaults.health=ZI(t.health),s.defaults.stop={...t.stop}});let n=g.value;n!==null&&e(`logs`,()=>Object.assign(s.logs,n));let r=_.value;r!==null&&e(`telegram`,()=>Object.assign(s.telegram,nL(r)))}function ne(){for(let e of Object.keys(E))delete E[e]}function re(e){E[e]=pL(s,e)}N([h,g,_],()=>{te()},{immediate:!0});async function ie(){let e=y.value,t=f.value,n=Object.keys(e).length>0;if(!(!n&&t===null||l.value||a.activeId.value.length===0)){l.value=!0,u.value=null,d.value=null;try{if(n&&!await i.saveWorkspaceSettings(a.activeId.value,e)){u.value=i.lastError.value??`The settings could not be saved.`;return}t!==null&&(await kM(a.activeId.value,t),await m.value?.reload()),d.value=`Workspace settings saved.`,o.success(`Workspace settings saved`),ne(),te()}catch(e){u.value=e instanceof Error?e.message:String(e)}finally{l.value=!1}}}function ae(){u.value=null,d.value=null,ne(),te(),m.value?.reload()}function oe(){let e=h.value;e!==null&&(s.defaults.enabled=e.enabled,s.defaults.autostart=e.autostart,s.defaults.bind=e.bind,s.defaults.onPortConflict=e.onPortConflict,s.defaults.logBufferLines=e.logBufferLines,s.defaults.restart={...e.restart},s.defaults.health=ZI(e.health),s.defaults.stop={...e.stop},re(`defaults`))}function se(){g.value!==null&&Object.assign(s.logs,g.value),re(`logs`)}function ce(){_.value!==null&&Object.assign(s.telegram,nL(_.value)),re(`telegram`)}function D(e){rr(()=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})})}function le(e){c.value=e,n.query.section!==e&&r.replace({query:{...n.query,section:e}}),D(e)}N(()=>n.query.section,e=>{let n=typeof e==`string`?e:``;t.some(e=>e.id===n)&&(c.value=n,D(n))},{immediate:!0}),N(()=>a.activeId.value,()=>{ne(),te(),u.value=null,d.value=null});let ue=null;return ta(()=>{ue=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&&(c.value=t.target.id)},{rootMargin:`-72px 0px -62% 0px`,threshold:0});for(let e of t){let t=document.getElementById(e.id);t&&ue.observe(t)}}),ia(()=>ue?.disconnect()),(e,n)=>(R(),z(L,null,[V(`div`,iX,[V(`div`,aX,[H(jz,{title:`Workspace settings`,description:`Server defaults, log retention, notifications and dynamic DNS for ${j(a).selected.value?.label??`this workspace`}.`},null,8,[`description`]),j(a).configError.value?(R(),B(xB,{key:0,tone:`danger`,title:`The workspace config could not be read`,class:`mb-4`},{default:M(()=>[V(`p`,null,k(j(a).configError.value),1),n[9]||=V(`p`,{class:`mt-1`},` The panel keeps supervising with the config it already had; fixing the file reloads it on its own. `,-1)]),_:1})):j(a).configWarnings.value.length>0?(R(),B(xB,{key:1,tone:`warn`,title:`Some keys in this workspace's config are not recognized`,class:`mb-4`},{default:M(()=>[(R(!0),z(L,null,F(j(a).configWarnings.value,e=>(R(),z(`p`,{key:e,class:`font-mono`},k(e),1))),128))]),_:1})):W(``,!0),V(`div`,oX,[V(`nav`,sX,[V(`ul`,cX,[(R(),z(L,null,F(t,e=>V(`li`,{key:e.id},[V(`button`,{type:`button`,"aria-current":c.value===e.id?`true`:void 0,class:O(j(Q)(`-ml-px block w-full border-l-2 py-1.5 pl-3 text-left text-xs transition-colors duration-150`,c.value===e.id?`border-accent font-medium text-accent`:`border-transparent text-muted hover:border-line hover:text-ink`)),onClick:t=>le(e.id)},k(e.title),11,lX)])),64))])]),V(`div`,uX,[V(`section`,dX,[n[10]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Server defaults `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Applied to every entry in this workspace that does not set its own value. `)],-1),H(WY,{defaults:s.defaults,"onUpdate:defaults":n[0]||=e=>s.defaults=e,dirty:w.value,onReset:oe},null,8,[`defaults`,`dirty`])]),V(`section`,fX,[n[11]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Logs `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` How much output this workspace keeps on disk and for how long. `)],-1),H(YY,{logs:s.logs,"onUpdate:logs":n[1]||=e=>s.logs=e,"logs-dir":v.value,dirty:T.value,onReset:se},null,8,[`logs`,`logs-dir`,`dirty`])]),V(`section`,pX,[n[12]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Notifications `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Crash and health alerts for this workspace, sent to a Telegram chat. `)],-1),H(rX,{telegram:s.telegram,"onUpdate:telegram":n[2]||=e=>s.telegram=e,status:_.value,dirty:ee.value,onReset:ce},null,8,[`telegram`,`status`,`dirty`])]),V(`section`,mX,[n[13]||=V(`header`,{class:`mb-3`},[V(`h2`,{class:`text-lg font-semibold text-ink`},` Dynamic DNS `),V(`p`,{class:`mt-0.5 text-xs text-muted`},` Keep hostnames pointed at this machine's public address, whichever registrar holds them. `)],-1),H(HY,{ref_key:`ddnsSection`,ref:m,patch:f.value,"onUpdate:patch":n[3]||=e=>f.value=e,baseline:p.value,"onUpdate:baseline":n[4]||=e=>p.value=e},null,8,[`patch`,`baseline`])])])])]),V(`div`,hX,[V(`div`,gX,[V(`div`,_X,[V(`p`,vX,[b.value>0?(R(),z(`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[5]||=e=>C.value=!0},[V(`span`,yX,k(b.value),1),U(` field`+k(b.value===1?``:`s`)+` changed `,1)])):(R(),z(L,{key:1},[U(` No unsaved changes `)],64))]),u.value?(R(),z(`p`,bX,k(u.value),1)):d.value?(R(),z(`p`,xX,k(d.value),1)):W(``,!0)]),V(`div`,SX,[H($,{variant:`ghost`,disabled:b.value===0||l.value,onClick:ae},{default:M(()=>[...n[14]||=[U(` Discard changes `,-1)]]),_:1},8,[`disabled`]),H($,{variant:`primary`,disabled:b.value===0,loading:l.value,onClick:ie},{default:M(()=>[...n[15]||=[U(` Save settings `,-1)]]),_:1},8,[`disabled`,`loading`])])])])]),H(vR,{open:C.value,"onUpdate:open":n[8]||=e=>C.value=e,title:`Unsaved changes`,description:`What Save would write to ${j(a).selected.value?.label??`this workspace`}'s settings.`,width:`w-[min(92vw,42rem)]`},{default:M(()=>[V(`div`,CX,[S.value.length>0?(R(),z(`ul`,wX,[(R(!0),z(L,null,F(S.value,e=>(R(),z(`li`,{key:e.path,class:`flex flex-wrap items-baseline gap-x-3 gap-y-1 py-2 first:pt-0`},[V(`code`,TX,k(e.path),1),V(`span`,EX,k(j(pI)(e.from)),1),n[16]||=V(`span`,{class:`text-2xs text-faint`},`→`,-1),V(`span`,DX,k(j(pI)(e.to)),1)]))),128))])):(R(),z(`p`,OX,` Nothing to save. `))]),V(`footer`,kX,[H($,{size:`sm`,variant:`ghost`,onClick:n[6]||=e=>C.value=!1},{default:M(()=>[...n[17]||=[U(` Close `,-1)]]),_:1}),H($,{size:`sm`,variant:`primary`,disabled:S.value.length===0||l.value,loading:l.value,onClick:n[7]||=e=>{ie(),C.value=!1}},{default:M(()=>[U(` Save `+k(S.value.length)+` change`+k(S.value.length===1?``:`s`),1)]),_:1},8,[`disabled`,`loading`])])]),_:1},8,[`open`,`description`])],64))}}),jX=new Set([`overview`,`servers`,`server-detail`,`logs`,`settings`]),MX=xv({history:U_(),routes:[{path:`/w/:workspaceId`,name:`overview`,component:bG,meta:{title:`Overview`}},{path:`/w/:workspaceId/servers`,name:`servers`,component:nY,meta:{title:`Servers`}},{path:`/w/:workspaceId/servers/:id`,name:`server-detail`,component:XJ,meta:{title:`Server`}},{path:`/w/:workspaceId/logs`,name:`logs`,component:QW,meta:{title:`Logs`}},{path:`/w/:workspaceId/settings`,name:`settings`,component:AX,meta:{title:`Workspace settings`}},{path:`/global/overview`,name:`global-overview`,component:_B,meta:{title:`Global Overview`}},{path:`/global/settings`,name:`global-settings`,component:kU,meta:{title:`Global settings`}},{path:`/proxy`,name:`proxy`,component:uJ,meta:{title:`Reverse Proxy`}},{path:`/login`,name:`login`,component:QU,meta:{title:`Sign in`}},{path:`/`,name:`home`,component:bG},{path:`/servers`,name:`legacy-servers`,component:nY},{path:`/servers/:id`,name:`legacy-server-detail`,component:XJ},{path:`/logs`,name:`legacy-logs`,component:QW},{path:`/settings`,name:`legacy-settings`,component:AX},{path:`/global`,name:`legacy-global`,component:_B},{path:`/global-settings`,name:`legacy-global-settings`,component:kU},{path:`/:pathMatch(.*)*`,name:`not-found`,component:bG}]});function NX(e,t=`overview`,n){let r=`/w/${encodeURIComponent(e)}`;return t===`overview`?r:t===`servers`?n===void 0?`${r}/servers`:`${r}/servers/${encodeURIComponent(n)}`:`${r}/${t}`}MX.beforeEach(async e=>{let{session:t,refresh:n}=oN();t.value===null&&await n();let r=t.value?.authRequired===!0,i=t.value?.authenticated===!0;if(r&&!i&&e.name!==`login`)return{name:`login`,query:e.fullPath===`/`?void 0:{next:e.fullPath}};if(e.name===`login`&&(!r||i))return{name:`global-overview`,replace:!0};if(e.name===`login`||e.name===`global-overview`||e.name===`global-settings`||e.name===`proxy`)return!0;if(e.name===`legacy-global`)return{name:`global-overview`,query:e.query,replace:!0};if(e.name===`legacy-global-settings`)return{name:`global-settings`,query:e.query,replace:!0};if(e.name===`home`||e.name===`not-found`)return{name:`global-overview`,replace:!0};await WN().ensureState();let a=aP(),o=a.workspaces.value;if(o.length===0)return!0;let s=typeof e.params.workspaceId==`string`?e.params.workspaceId:``;if(s.length>0&&o.some(e=>e.id===s)&&(a.select(s),jX.has(String(e.name))))return!0;let c=a.activeId.value||o[0].id,l=String(e.name??``).replace(/^legacy-/,``),u=l===`server-detail`||l===`servers`&&`id`in e.params?`server-detail`:jX.has(l)?l:`overview`,d={...e.params,workspaceId:c};return u===`server-detail`&&d.id===void 0?{name:`servers`,params:{workspaceId:c},query:e.query,replace:!0}:{name:u,params:d,query:e.query,replace:!0}});var PX={class:`flex items-center gap-2.5 border-b border-line px-3.5`},FX={key:0,class:`px-3 py-8 text-center text-xs text-muted`},IX={class:`px-2.5 pb-1 pt-2.5 text-2xs font-medium text-faint`},LX=[`data-active`,`onMousemove`,`onClick`],RX={class:`min-w-0 flex-1 truncate text-sm`},zX={key:0,class:`shrink-0 font-mono text-2xs text-faint`},BX={class:`flex items-center gap-3 border-t border-line bg-panel-2 px-3.5 py-2 text-2xs text-faint`},VX={class:`ml-auto font-mono`},HX=P({__name:`CommandPalette`,props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:[`update:open`],setup(e){let t=oo(e,`open`),n=Lg(),r=WN(),i=aP(),a=$N(),o=A(``),s=A(0),c=A(null),l=A(null);function u(e){n.push(e)}function d(e){i.select(e);let t=String(n.currentRoute.value.name??``);t===`overview`||t===`servers`||t===`logs`||t===`settings`?u(NX(e,t)):t===`server-detail`&&u(NX(e,`servers`))}function f(e){e(),t.value=!1}let p=[`stopped`,`crashed`,`conflict`],m=[`running`,`starting`,`backoff`],h=G(()=>{let e=[],t=r.allServers.value;function n(e,t){i.select(e),u(t)}let o=e=>NX(i.activeId.value,e);for(let{workspace:i,server:a}of t){let t=a.config.label??a.id,o=PF[a.status].label;e.push({id:`open:${i.id}:${a.id}`,title:`Open ${t}`,group:`Servers`,icon:wy,detail:`${i.label} · ${a.id} · ${o}`,keywords:`server detail ${a.id} ${i.label} show`,run:()=>n(i.id,NX(i.id,`servers`,a.id))}),e.push({id:`logs:${i.id}:${a.id}`,title:`Logs for ${t}`,group:`Servers`,icon:My,detail:`${i.label} · ${a.id}`,keywords:`log tail output ${a.id} ${i.label}`,run:()=>n(i.id,`${NX(i.id,`logs`)}?server=${encodeURIComponent(a.id)}`)}),p.includes(a.status)&&a.config.enabled&&e.push({id:`start:${i.id}:${a.id}`,title:`Start ${t}`,group:`Actions`,icon:gy,detail:`${i.label} · ${a.id}`,keywords:`run launch ${a.id} ${i.label}`,run:()=>f(()=>void r.start(i.id,a.id))}),m.includes(a.status)&&e.push({id:`stop:${i.id}:${a.id}`,title:`Stop ${t}`,group:`Actions`,icon:Ay,detail:`${i.label} · ${a.id}`,keywords:`halt kill ${a.id} ${i.label}`,run:()=>f(()=>void r.stop(i.id,a.id))}),a.config.enabled&&e.push({id:`restart:${i.id}:${a.id}`,title:`Restart ${t}`,group:`Actions`,icon:xy,detail:`${i.label} · ${a.id}`,keywords:`bounce reload ${a.id} ${i.label}`,run:()=>f(()=>void r.restart(i.id,a.id))})}e.push({id:`nav:overview`,title:`Go to Overview`,group:`Navigate`,icon:ay,keywords:`dashboard home workspace`,run:()=>u(o(`overview`))},{id:`nav:global`,title:`Go to Global Overview`,group:`Navigate`,icon:ey,keywords:`dashboard home host vitals every workspace`,run:()=>u(`/global/overview`)},{id:`nav:global-settings`,title:`Go to Global settings`,group:`Navigate`,icon:ky,keywords:`panel listener auth tls backups host`,run:()=>u(`/global/settings`)},{id:`nav:proxy`,title:`Go to Reverse Proxy`,group:`Navigate`,icon:Ly,keywords:`caddy domain route acme certificate https expose`,run:()=>u(`/proxy`)},{id:`nav:servers`,title:`Go to Servers`,group:`Navigate`,icon:wy,keywords:`processes list workspace`,run:()=>u(o(`servers`))},{id:`nav:logs`,title:`Go to Logs`,group:`Navigate`,icon:Sy,keywords:`output files tail workspace`,run:()=>u(o(`logs`))},{id:`nav:settings`,title:`Go to Workspace settings`,group:`Navigate`,icon:Ty,keywords:`defaults notifications ddns config workspace`,run:()=>u(o(`settings`))},{id:`act:start-all`,title:`Start every enabled server here`,group:`Actions`,icon:gy,keywords:`boot all workspace`,run:()=>f(()=>void r.startAll(i.activeId.value))},{id:`act:stop-all`,title:`Stop every server here`,group:`Actions`,icon:Ay,keywords:`halt all workspace`,run:()=>f(()=>void r.stopAll(i.activeId.value))});for(let t of i.workspaces.value)e.push({id:`ws:${t.id}`,title:`Switch to ${t.label}`,group:`Workspaces`,icon:iy,detail:t.id,keywords:`workspace switch scope ${t.label}`,run:()=>f(()=>d(t.id))});for(let[t,n]of[[`listener`,`Listener`],[`authentication`,`Authentication`],[`host`,`Host vitals`],[`backups`,`Backups`],[`tls`,`TLS`],[`interface`,`Interface`],[`paths`,`Paths`]])e.push({id:`gset:${t}`,title:`Global setting: ${n}`,group:`Global settings`,icon:ey,keywords:`configure panel ${t}`,run:()=>u(`/global/settings?section=${t}`)});for(let[t,n]of[[`defaults`,`Server defaults`],[`logs`,`Log storage`],[`notifications`,`Telegram notifications`],[`ddns`,`Dynamic DNS`]])e.push({id:`wset:${t}`,title:`Workspace setting: ${n}`,group:`Workspace settings`,icon:Ty,keywords:`configure workspace ${t}`,run:()=>u(`${NX(i.activeId.value,`settings`)}?section=${t}`)});let s=[[`light`,`Light`,jy],[`dark`,`Dark`,fy],[`system`,`System`,dy]];for(let[t,n,r]of s)e.push({id:`theme:${t}`,title:`${n} theme`,group:`Appearance`,icon:r,keywords:`colour color dark light mode appearance`,run:()=>f(()=>a.setPreference(t))});return e}),g=G(()=>{let e=o.value.trim().toLowerCase().split(/\s+/).filter(Boolean);return e.length===0?h.value.slice(0,40):h.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)}),_=G(()=>{let e=new Map;for(let t of g.value){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return[...e.entries()]}),v=G(()=>_.value.flatMap(([,e])=>e));N(g,()=>{s.value=0}),N(t,async e=>{e&&(o.value=``,s.value=0,await rr(),c.value?.focus())});function y(e){let t=v.value.length;t!==0&&(s.value=(s.value+e+t)%t,rr(()=>{l.value?.querySelector(`[data-active="true"]`)?.scrollIntoView({block:`nearest`})}))}function b(e){e.key===`ArrowDown`?(e.preventDefault(),y(1)):e.key===`ArrowUp`?(e.preventDefault(),y(-1)):e.key===`Enter`&&(e.preventDefault(),v.value[s.value]?.run())}function x(e){(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),t.value=!t.value)}return ta(()=>window.addEventListener(`keydown`,x)),ze(()=>window.removeEventListener(`keydown`,x)),(e,n)=>(R(),B(j(cf),{open:t.value,"onUpdate:open":n[2]||=e=>t.value=e},{default:M(()=>[H(j(Jf),null,{default:M(()=>[H(j(Kf),{class:`fixed inset-0 z-50 bg-black/40 backdrop-blur-[1px] data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`}),H(j(Uf),{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]||=cu(()=>{},[`prevent`]),onKeydown:b},{default:M(()=>[H(j(Yf),{class:`sr-only`},{default:M(()=>[...n[3]||=[U(` Command palette `,-1)]]),_:1}),V(`div`,PX,[H(j(Cy),{class:`size-4 shrink-0 text-faint`}),xr(V(`input`,{ref_key:`input`,ref:c,"onUpdate:modelValue":n[0]||=e=>o.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),[[ql,o.value]]),n[4]||=V(`kbd`,{class:`shrink-0 rounded border border-line bg-page px-1.5 py-0.5 font-mono text-2xs text-faint`},`esc`,-1)]),V(`div`,{ref_key:`list`,ref:l,class:`max-h-[min(60vh,26rem)] overflow-y-auto p-1.5`},[v.value.length===0?(R(),z(`p`,FX,` Nothing matches “`+k(o.value)+`”. `,1)):W(``,!0),(R(!0),z(L,null,F(_.value,([e,t])=>(R(),z(L,{key:e},[V(`p`,IX,k(e),1),(R(!0),z(L,null,F(t,e=>(R(),z(`button`,{key:e.id,type:`button`,"data-active":v.value[s.value]?.id===e.id,class:O(j(Q)(`flex w-full items-center gap-2.5 rounded-control px-2.5 py-2 text-left transition-colors duration-100`,v.value[s.value]?.id===e.id?`bg-accent-soft text-ink`:`text-muted hover:bg-hover`)),onMousemove:t=>s.value=v.value.findIndex(t=>t.id===e.id),onClick:t=>e.run()},[(R(),B(ma(e.icon),{class:O([`size-4 shrink-0`,v.value[s.value]?.id===e.id?`text-accent`:`text-faint`])},null,8,[`class`])),V(`span`,RX,k(e.title),1),e.detail?(R(),z(`span`,zX,k(e.detail),1)):W(``,!0),H(j(Lv),{class:O([`size-3.5 shrink-0 text-faint opacity-0 transition-opacity duration-100`,{"opacity-100":v.value[s.value]?.id===e.id}])},null,8,[`class`])],42,LX))),128))],64))),128))],512),V(`div`,BX,[n[5]||=V(`span`,null,[V(`kbd`,{class:`font-mono`},`↑↓`),U(` navigate`)],-1),n[6]||=V(`span`,null,[V(`kbd`,{class:`font-mono`},`↵`),U(` run`)],-1),V(`span`,VX,k(v.value.length)+` results`,1)])]),_:1})]),_:1})]),_:1},8,[`open`]))}}),UX={class:`rounded-panel border border-line bg-panel-2/70 p-3`},WX={class:`mb-2 flex items-center justify-between`},GX={key:0,class:`text-2xs text-faint`},KX={key:0,class:`grid grid-cols-2 gap-x-1 gap-y-2`},qX={key:1,class:`py-3 text-center text-2xs text-faint`},JX={key:2,class:`mt-2 flex items-start gap-1.5 rounded-control bg-danger-soft px-2 py-1.5`},YX={class:`text-2xs leading-4 text-danger`},XX=2,ZX=85,QX=P({__name:`InstrumentCluster`,props:{host:{}},setup(e){let t=e,n=G(()=>{let e=t.host;return e?(e.loadAvg[0]??0)/Math.max(1,e.cpus):null}),r=G(()=>n.value===null?null:n.value/XX*100),i=G(()=>n.value===null?`—`:n.value.toFixed(2)),a=G(()=>{let e=t.host?.disks??[];return e.length===0?null:Math.max(...e.map(e=>e.usedPercent))}),o=G(()=>{let e=t.host?.tempCelsius??null;return e===null?null:e/ZX*100}),s=G(()=>{let e=t.host?.tempCelsius??null;return e===null?`n/a`:`${Math.round(e)}°`});return(e,n)=>(R(),z(`div`,UX,[V(`div`,WX,[n[0]||=V(`span`,{class:`text-2xs font-medium text-faint`},`Host vitals`,-1),t.host?.enabled===!1?(R(),z(`span`,GX,`off`)):W(``,!0)]),t.host?.enabled?(R(),z(`div`,KX,[H(XF,{value:r.value,label:`Load / cpu`,display:i.value,size:58,"warn-at":70,"danger-at":100},null,8,[`value`,`display`]),H(XF,{value:t.host?.memoryUsedPercent??null,label:`Memory`,size:58},null,8,[`value`]),H(XF,{value:a.value,label:`Disk`,size:58},null,8,[`value`]),H(XF,{value:o.value,label:`CPU temp`,display:s.value,size:58},null,8,[`value`,`display`])])):(R(),z(`p`,qX,` Sampling is disabled in Settings. `)),t.host&&t.host.alerts.length>0?(R(),z(`div`,JX,[n[1]||=V(`span`,{class:`mt-1 size-1.5 shrink-0 rounded-full bg-danger`},null,-1),V(`span`,YX,k(t.host.alerts.join(` · `)),1)])):W(``,!0)]))}}),$X={class:`flex h-full min-h-0 flex-col gap-3 overflow-y-auto p-3`},eZ={class:`flex items-center gap-2 px-1 pt-1`},tZ={class:`min-w-0`},nZ=[`title`],rZ={class:`flex flex-col gap-3`,"aria-label":`Navigation`},iZ={class:`flex items-center gap-1 truncate px-2.5 pb-1 text-2xs font-medium text-faint`},aZ={key:1,class:`text-muted`},oZ={class:`mt-auto flex flex-col gap-3`},sZ={class:`flex items-center gap-2 rounded-control border border-line bg-panel-2/70 px-2.5 py-2`},cZ={class:`relative flex size-2 shrink-0`},lZ={class:`text-2xs text-muted`},uZ=[`title`],dZ=P({__name:`SideNav`,props:{host:{},connection:{},panelLabel:{},panelVersion:{},planLabel:{},workspaceId:{},workspaceLabel:{},running:{},total:{}},emits:[`navigate`,`close`],setup(e,{emit:t}){let n=e,r=t,i=Rg(),a=G(()=>[{to:NX(n.workspaceId,`overview`),label:`Overview`,icon:ay,exact:!0,servers:!1},{to:NX(n.workspaceId,`servers`),label:`Servers`,icon:wy,exact:!1,servers:!0},{to:NX(n.workspaceId,`logs`),label:`Logs`,icon:Sy,exact:!1,servers:!1},{to:NX(n.workspaceId,`settings`),label:`Workspace settings`,icon:Ty,exact:!1,servers:!1}]),o=[{to:`/global/overview`,label:`Global Overview`,icon:ey,exact:!0,servers:!1},{to:`/global/settings`,label:`Global settings`,icon:ky,exact:!1,servers:!1}],s=[{to:`/proxy`,label:`Reverse Proxy`,icon:Ly,exact:!1,servers:!1}],c=G(()=>[{title:`Global`,label:``,icon:ey,items:o},{title:`Workspace`,label:n.workspaceLabel,icon:void 0,items:a.value},{title:`Others`,label:``,icon:Nv,items:s}]);function l(e){return e.exact?i.path===e.to:i.path===e.to||i.path.startsWith(`${e.to}/`)}let u=G(()=>n.panelVersion===null?n.panelLabel:`${n.panelLabel} · v${n.panelVersion}`),d=G(()=>({open:{label:`Live`,dot:`bg-ok`},connecting:{label:`Connecting`,dot:`bg-warn`},closed:{label:`Reconnecting`,dot:`bg-danger`}})[n.connection]);return(e,t)=>{let i=fa(`RouterLink`);return R(),z(`div`,$X,[V(`div`,eZ,[t[3]||=Ds(`<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),V(`div`,tZ,[t[2]||=V(`p`,{class:`truncate text-sm font-semibold tracking-tight text-ink`},` home-hosted `,-1),V(`p`,{class:`truncate text-2xs text-faint`,title:u.value},k(u.value),9,nZ)]),V(`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`)},[H(j(Ry),{class:`size-4`})])]),V(`nav`,rZ,[(R(!0),z(L,null,F(c.value,e=>(R(),z(`div`,{key:e.title,class:`flex min-h-0 flex-col gap-0.5`},[V(`p`,iZ,[e.icon?(R(),B(ma(e.icon),{key:0,class:`size-3 shrink-0`})):W(``,!0),U(` `+k(e.label?`${e.title} · `:e.title),1),e.label?(R(),z(`span`,aZ,k(e.label),1)):W(``,!0)]),(R(!0),z(L,null,F(e.items,e=>(R(),B(i,{key:e.to,to:e.to,class:O(j(Q)(`group flex items-center gap-2.5 rounded-control px-2.5 py-1.5 text-sm transition-colors duration-150`,l(e)?`bg-accent-soft font-medium text-accent`:`text-muted hover:bg-hover hover:text-ink`)),onClick:t[1]||=e=>r(`navigate`)},{default:M(()=>[(R(),B(ma(e.icon),{class:`size-4 shrink-0`,"stroke-width":l(e)?2.1:1.8},null,8,[`stroke-width`])),U(` `+k(e.label)+` `,1),e.servers?(R(),z(`span`,{key:0,class:O([`ml-auto font-mono text-2xs tabular-nums`,l(e)?`text-accent`:`text-faint`])},k(n.running)+`/`+k(n.total),3)):W(``,!0)]),_:2},1032,[`to`,`class`]))),128))]))),128))]),V(`div`,oZ,[H(QX,{host:n.host},null,8,[`host`]),V(`div`,sZ,[V(`span`,cZ,[V(`span`,{class:O(j(Q)(`absolute inset-0 rounded-full`,d.value.dot,n.connection!==`open`&&`animate-ping opacity-60`))},null,2),V(`span`,{class:O(j(Q)(`relative size-2 rounded-full`,d.value.dot))},null,2)]),V(`span`,lZ,k(d.value.label),1),V(`span`,{class:`ml-auto truncate font-mono text-2xs text-faint`,title:n.planLabel},k(n.planLabel),9,uZ)])])])}}}),fZ={key:0,class:`flex flex-col gap-px border-b border-line bg-panel/60`},pZ={class:`text-2xs leading-4`},mZ={class:`font-medium`},hZ={key:0,class:`opacity-80`},gZ=P({__name:`SystemNotices`,props:{control:{},configError:{},configPath:{}},setup(e){let t=e,n=G(()=>{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 Global 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 Global 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:Iy},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?(R(),z(`div`,fZ,[(R(!0),z(L,null,F(n.value,e=>(R(),z(`div`,{key:e.id,class:O([`flex items-start gap-2 px-3 py-1.5 sm:px-4`,r[e.tone].wrap])},[(R(),B(ma(r[e.tone].icon),{class:`mt-0.5 size-3.5 shrink-0`})),V(`p`,pZ,[V(`span`,mZ,k(e.text),1),e.hint?(R(),z(`span`,hZ,k(e.hint),1)):W(``,!0)])],2))),128))])):W(``,!0)}}),_Z={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`},vZ={class:`min-w-0 flex-1`},yZ={class:`text-xs font-medium text-ink`},bZ={key:0,class:`mt-0.5 break-words text-2xs leading-4 text-muted`},xZ=[`onClick`],SZ=P({__name:`ToastStack`,setup(e){let{toasts:t,dismiss:n}=dN(),r={ok:Vv,danger:Hv,warn:Iy,info:ny,accent:ny,neutral:ny},i={ok:`text-ok`,danger:`text-danger`,warn:`text-warn`,info:`text-info`,neutral:`text-muted`,accent:`text-accent`},a=G(()=>t.value);return(e,t)=>(R(),z(`div`,_Z,[H(Fl,{"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(()=>[(R(!0),z(L,null,F(a.value,e=>(R(),z(`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`},[(R(),B(ma(r[e.tone]),{class:O(j(Q)(`mt-0.5 size-4 shrink-0`,i[e.tone]))},null,8,[`class`])),V(`div`,vZ,[V(`p`,yZ,k(e.title),1),e.description?(R(),z(`p`,bZ,k(e.description),1)):W(``,!0)]),V(`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)},[H(j(Ry),{class:`size-3.5`})],8,xZ)]))),128))]),_:1})]))}}),CZ={class:`space-y-3`},wZ={key:0,class:`rounded-control border border-danger/40 bg-danger-soft px-2.5 py-1.5 text-2xs leading-4 text-danger`},TZ=P({__name:`WorkspaceDialog`,props:Ra({mode:{},initial:{default:``},submit:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:[`update:open`],setup(e){let t=e,n=oo(e,`open`),r=A(t.initial),i=A(!1),a=A(null),o=G(()=>t.mode===`create`?`New workspace`:`Rename workspace`),s=G(()=>t.mode===`create`?`Create workspace`:`Rename`),c=G(()=>r.value.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40));N(n,e=>{e&&(r.value=t.initial,a.value=null)});async function l(){let e=r.value.trim();if(e.length===0){a.value=`A workspace needs a name.`;return}i.value=!0,a.value=null;try{await t.submit(e)&&(n.value=!1)}finally{i.value=!1}}return(t,u)=>(R(),B(vR,{open:n.value,"onUpdate:open":u[2]||=e=>n.value=e,title:o.value,description:e.mode===`create`?`Its own settings, servers, logs, secrets and backups entry — served by this same panel.`:`Only the name changes; the workspace id stays, so URLs and paths keep working.`,width:`w-[min(92vw,26rem)]`},{footer:M(()=>[H($,{variant:`ghost`,disabled:i.value,onClick:u[1]||=e=>n.value=!1},{default:M(()=>[...u[3]||=[U(` Cancel `,-1)]]),_:1},8,[`disabled`]),H($,{variant:`primary`,loading:i.value,onClick:l},{default:M(()=>[U(k(s.value),1)]),_:1},8,[`loading`])]),default:M(()=>[V(`div`,CZ,[H(iR,{modelValue:r.value,"onUpdate:modelValue":u[0]||=e=>r.value=e,label:`Name`,placeholder:`Home lab`,hint:e.mode===`create`&&c.value.length>0?`Shown in the header. Id: ${c.value}`:`Shown in the header.`,wide:``,onKeydown:uu(cu(l,[`prevent`]),[`enter`])},null,8,[`modelValue`,`hint`,`onKeydown`]),a.value?(R(),z(`p`,wZ,k(a.value),1)):W(``,!0)])]),_:1},8,[`open`,`title`,`description`]))}}),EZ=[`aria-label`],DZ={class:`min-w-0 truncate font-medium text-ink`},OZ={class:`hidden shrink-0 font-mono text-2xs text-faint sm:inline`},kZ={key:0,class:`max-h-64 overflow-y-auto`},AZ=[`onClick`],jZ={class:`min-w-0 flex-1`},MZ={class:`block truncate text-xs`},NZ={class:`block truncate font-mono text-2xs text-faint`},PZ={class:`shrink-0 font-mono text-2xs text-faint`},FZ={key:1,class:`px-2 py-2 text-xs text-muted`},IZ={class:`px-2 pt-1.5 text-xs font-semibold text-ink`},LZ={class:`mt-2 flex justify-end gap-1.5 px-1 pb-1`},RZ=P({__name:`WorkspacePicker`,props:{workspaces:{},selectedId:{}},emits:[`select`,`create`,`rename`,`remove`],setup(e,{emit:t}){let n=e,r=t,i=A(!1),a=A(!1),o=G(()=>n.workspaces.find(e=>e.id===n.selectedId)??null);function s(e){r(`select`,e),i.value=!1}function c(){a.value=!0}function l(){a.value=!1}function u(){let e=o.value;a.value=!1,i.value=!1,e!==null&&r(`remove`,e)}function d(){i.value=!1,r(`create`)}function f(){i.value=!1,o.value!==null&&r(`rename`,o.value)}async function p(e){i.value=e,e&&(a.value=!1,await rr())}return(t,n)=>(R(),B(j(Uh),{open:i.value,"onUpdate:open":p},{default:M(()=>[H(j(Xh),{"as-child":``},{default:M(()=>[V(`button`,{type:`button`,class:O(j(Q)(`flex h-8 max-w-36 items-center gap-1.5 rounded-control border border-line bg-panel-2 px-2 text-xs transition-colors duration-150 hover:border-line hover:text-ink sm:max-w-52`,j(zL))),"aria-label":`Workspace: ${o.value?.label??`none`}`},[H(j(iy),{class:`size-3.5 shrink-0 text-faint`}),V(`span`,DZ,k(o.value?.label??`No workspace`),1),V(`span`,OZ,k(o.value?.runningCount??0)+`/`+k(o.value?.serverCount??0),1),H(j(zv),{class:`size-3 shrink-0 text-faint`})],10,EZ)]),_:1}),H(j(Yh),null,{default:M(()=>[H(j(Jh),{"side-offset":6,align:`end`,class:`z-50 w-72 rounded-panel border border-line bg-raise p-1 shadow-float focus-visible:outline-none data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`},{default:M(()=>[a.value?(R(),z(L,{key:1},[V(`p`,IZ,` Delete “`+k(o.value?.label)+`”? `,1),n[5]||=V(`p`,{class:`mt-1 px-2 text-2xs leading-4 text-muted`},` Its servers are stopped, and its config, settings, logs, secrets and nanny state are removed from disk. A backup taken first is the only way back. `,-1),V(`div`,LZ,[H($,{size:`xs`,variant:`ghost`,onClick:l},{default:M(()=>[...n[3]||=[U(` Keep it `,-1)]]),_:1}),H($,{size:`xs`,variant:`danger`,onClick:u},{default:M(()=>[H(j(Fy),{class:`size-3`}),n[4]||=U(`Delete workspace `,-1)]),_:1})])],64)):(R(),z(L,{key:0},[n[1]||=V(`p`,{class:`px-2 pb-1 pt-1.5 text-2xs font-medium text-faint`},` Workspaces `,-1),e.workspaces.length>0?(R(),z(`ul`,kZ,[(R(!0),z(L,null,F(e.workspaces,t=>(R(),z(`li`,{key:t.id},[V(`button`,{type:`button`,class:O(j(Q)(`flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left transition-colors duration-100`,t.id===e.selectedId?`bg-accent-soft text-ink`:`text-muted hover:bg-hover`)),onClick:e=>s(t.id)},[H(j(Pv),{class:O([`size-3.5 shrink-0`,t.id===e.selectedId?`text-accent`:`opacity-0`])},null,8,[`class`]),V(`span`,jZ,[V(`span`,MZ,k(t.label),1),V(`span`,NZ,k(t.id),1)]),V(`span`,PZ,k(t.runningCount)+`/`+k(t.serverCount),1)],10,AZ)]))),128))])):(R(),z(`p`,FZ,` The panel serves no workspace yet. `)),n[2]||=V(`div`,{class:`my-1 h-px bg-line`},null,-1),V(`button`,{type:`button`,class:`flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-xs text-muted outline-none transition-colors duration-100 hover:bg-hover hover:text-ink`,onClick:d},[H(j(_y),{class:`size-3.5`}),n[0]||=U(` New workspace… `,-1)]),o.value?(R(),z(L,{key:2},[V(`button`,{type:`button`,class:`flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-xs text-muted outline-none transition-colors duration-100 hover:bg-hover hover:text-ink`,onClick:f},[H(j(hy),{class:`size-3.5`}),U(` Rename “`+k(o.value.label)+`”… `,1)]),V(`button`,{type:`button`,class:`flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-xs text-danger outline-none transition-colors duration-100 hover:bg-danger-soft`,onClick:c},[H(j(Fy),{class:`size-3.5`}),U(` Delete “`+k(o.value.label)+`”… `,1)])],64)):W(``,!0)],64))]),_:1})]),_:1})]),_:1},8,[`open`]))}}),zZ=P({__name:`WorkspaceSwitcher`,setup(e){let{workspaces:t,activeId:n,select:r,create:i,rename:a,remove:o}=aP(),s=Rg(),c=Lg(),l=A(!1),u=A(`create`),d=A(null);function f(e){r(e);let t=String(s.name??``);if(t===`overview`||t===`servers`||t===`logs`||t===`settings`){c.push(NX(e,t));return}t===`server-detail`&&c.push(NX(e,`servers`))}function p(){u.value=`create`,d.value=null,l.value=!0}function m(e){u.value=`rename`,d.value=e,l.value=!0}async function h(e){if(u.value===`create`)return await i(e)!==void 0;let t=d.value;return t!==null&&a(t.id,e)}async function g(e){let t=String(s.params.workspaceId??``)||n.value;if(!await o(e.id)||t!==e.id)return;let r=String(s.name??``);(r===`overview`||r===`servers`||r===`logs`||r===`settings`)&&c.push(NX(n.value,r))}return(e,r)=>(R(),z(L,null,[H(RZ,{workspaces:j(t),"selected-id":j(n),onSelect:f,onCreate:p,onRename:m,onRemove:g},null,8,[`workspaces`,`selected-id`]),H(TZ,{open:l.value,"onUpdate:open":r[0]||=e=>l.value=e,mode:u.value,initial:d.value?.label??``,submit:h},null,8,[`open`,`mode`,`initial`])],64))}}),BZ={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`},VZ={class:`min-w-0 flex-1 truncate text-sm font-semibold tracking-tight text-ink`},HZ={class:`flex shrink-0 items-center gap-1.5`},UZ={class:`hidden items-center gap-1.5 rounded-control border border-line bg-panel-2 px-2 py-1.5 md:flex`},WZ={class:`font-mono text-2xs text-muted`},GZ={class:`px-2 py-1.5`},KZ={class:`truncate font-mono text-2xs text-muted`},qZ=P({__name:`TopBar`,props:{panelUrl:{},connection:{},authenticated:{type:Boolean}},emits:[`menu`,`palette`,`signOut`],setup(e,{emit:t}){let n=e,r=t,i=Rg(),a=$N(),o=G(()=>i.name===`server-detail`?`Servers / ${String(i.params.id??``)}`:String(i.meta.title??`home-hosted`)),s=G(()=>a.preference.value===`dark`?fy:a.preference.value===`light`?jy:dy),c=G(()=>`Theme: ${a.preference.value}`),l=G(()=>({open:`bg-ok`,connecting:`bg-warn`,closed:`bg-danger`})[n.connection]),u=G(()=>({open:`Live updates`,connecting:`Connecting`,closed:`Reconnecting`})[n.connection]);return(t,i)=>(R(),z(`header`,BZ,[V(`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`)},[H(j(ly),{class:`size-4`})]),V(`h1`,VZ,k(o.value),1),V(`div`,HZ,[V(`button`,{type:`button`,class:O(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(zL))),onClick:i[1]||=e=>r(`palette`)},[H(j(Cy),{class:`size-3.5`}),i[5]||=V(`span`,{class:`pr-6`},`Search or run a command`,-1),i[6]||=V(`kbd`,{class:`rounded border border-line bg-page px-1 py-0.5 font-mono text-2xs text-faint`},`⌘K`,-1)],2),H(ZR,{label:u.value},{default:M(()=>[V(`span`,UZ,[V(`span`,{class:O(j(Q)(`size-1.5 rounded-full`,l.value))},null,2),V(`span`,WZ,k(e.panelUrl),1)])]),_:1},8,[`label`]),H(ZR,{label:c.value},{default:M(()=>[H($,{variant:`ghost`,size:`icon-sm`,"aria-label":c.value,onClick:i[2]||=e=>j(a).cycle()},{default:M(()=>[(R(),B(ma(s.value),{class:`size-4`}))]),_:1},8,[`aria-label`])]),_:1},8,[`label`]),n.authenticated?(R(),B(j($h),{key:0},{default:M(()=>[H(j(ig),{"as-child":``},{default:M(()=>[H($,{variant:`ghost`,size:`icon-sm`,"aria-label":`Account`},{default:M(()=>[...i[7]||=[V(`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}),H(j(ng),null,{default:M(()=>[H(j(eg),{"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(()=>[V(`div`,GZ,[i[8]||=V(`p`,{class:`text-2xs text-faint`},` Signed in `,-1),V(`p`,KZ,k(n.panelUrl),1)]),H(j(rg),{class:`my-1 h-px bg-line`}),H(j(tg),{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(()=>[H(j(cy),{class:`size-3.5`}),i[9]||=U(` Sign out `,-1)]),_:1})]),_:1})]),_:1})]),_:1})):W(``,!0),H(ZR,{label:`Command palette`},{default:M(()=>[H($,{variant:`ghost`,size:`icon-sm`,class:`sm:hidden`,"aria-label":`Open the command palette`,onClick:i[4]||=e=>r(`palette`)},{default:M(()=>[H(j(Gv),{class:`size-4`})]),_:1})]),_:1}),H(zZ)])]))}}),JZ={key:1,class:`flex h-dvh overflow-hidden bg-page`},YZ={class:`hidden w-60 shrink-0 border-r border-line bg-panel/50 lg:block`},XZ={key:0,class:`fixed inset-y-0 left-0 z-40 w-64 border-r border-line bg-panel lg:hidden`},ZZ={class:`flex min-w-0 flex-1 flex-col`};vu(P({__name:`App`,setup(e){let t=Rg(),n=Lg(),r=WN(),i=aP(),{session:a,logout:o}=oN(),s=A(!1),c=A(!1),l=G(()=>a.value?.authenticated===!0),u=G(()=>a.value?.authRequired===!0),d=G(()=>t.name===`login`),f=G(()=>t.name===`logs`),p=G(()=>i.runningCount.value),m=G(()=>i.serverCount.value),h=G(()=>r.control.value?.url??`—`),g=G(()=>r.host.value),_=G(()=>r.control.value?.label??`home-hosted`),v=G(()=>r.version.value),y=G(()=>i.selected.value?.label??`none`),b=G(()=>i.activeId.value);return N(G(()=>aN(a.value)),e=>{if(e!==`wait`){if(e===`login`){HN(),n.push({name:`login`});return}VN()}},{immediate:!0}),N(()=>t.fullPath,()=>{c.value=!1}),ta(async()=>{(!u.value||l.value)&&await r.refresh()}),ze(()=>HN()),(e,t)=>{let n=fa(`RouterView`);return R(),B(j(dg),{"delay-duration":300},{default:M(()=>[d.value?(R(),B(n,{key:0})):(R(),z(`div`,JZ,[V(`aside`,YZ,[H(dZ,{host:g.value,connection:j(r).connection.value,"panel-label":_.value,"panel-version":v.value,"plan-label":h.value,"workspace-id":b.value,"workspace-label":y.value,running:p.value,total:m.value},null,8,[`host`,`connection`,`panel-label`,`panel-version`,`plan-label`,`workspace-id`,`workspace-label`,`running`,`total`])]),H(Ec,{"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(()=>[c.value?(R(),z(`div`,{key:0,class:`fixed inset-0 z-40 bg-black/45 lg:hidden`,onClick:t[0]||=e=>c.value=!1})):W(``,!0)]),_:1}),H(Ec,{"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(()=>[c.value?(R(),z(`aside`,XZ,[H(dZ,{host:g.value,connection:j(r).connection.value,"panel-label":_.value,"panel-version":v.value,"plan-label":h.value,"workspace-id":b.value,"workspace-label":y.value,running:p.value,total:m.value,onNavigate:t[1]||=e=>c.value=!1,onClose:t[2]||=e=>c.value=!1},null,8,[`host`,`connection`,`panel-label`,`panel-version`,`plan-label`,`workspace-id`,`workspace-label`,`running`,`total`])])):W(``,!0)]),_:1}),V(`div`,ZZ,[H(qZ,{"panel-url":h.value,connection:j(r).connection.value,authenticated:l.value,onMenu:t[3]||=e=>c.value=!0,onPalette:t[4]||=e=>s.value=!0,onSignOut:t[5]||=e=>j(o)()},null,8,[`panel-url`,`connection`,`authenticated`]),d.value?W(``,!0):(R(),B(gZ,{key:0,control:j(r).control.value,"config-error":j(i).configError.value,"config-path":j(i).selected.value?.configPath},null,8,[`control`,`config-error`,`config-path`])),V(`main`,{class:O(j(Q)(`relative min-h-0 flex-1`,f.value?`overflow-hidden`:`overflow-y-auto`))},[H(n)],2)])])),H(HX,{open:s.value,"onUpdate:open":t[6]||=e=>s.value=e},null,8,[`open`]),H(SZ)]),_:1})}}})).use(MX).mount(`#app`);