{"version":3,"file":"profiles.cjs","names":["isScalar","isMap","parseProfileSettings","isTimeZone","isSeq","parseDocument","parseYaml","PROFILE_SIDECAR_FILE","YAMLMap","parseProfileLayer"],"sources":["../src/services/profileEdit/index.ts"],"sourcesContent":["import { isTimeZone } from '@agimon-ai/po-core/personTimeZone';\nimport { type Document, YAMLMap, isMap, isScalar, isSeq, parseDocument, parse as parseYaml } from 'yaml';\n\nimport { PROFILE_SIDECAR_FILE, parseProfileLayer, parseProfileSettings, parseProfileSidecar } from '../profiles/core';\nimport type {\n  ProfileDefaultEditInput,\n  ProfileEntryEditInput,\n  ProfileSettingsEdit,\n  ProfileSidecarEditInput,\n  ProfileWakeEdit,\n} from './type';\n\n/**\n * One-file text edits for personal profile configuration. Each function takes the current file text and returns the\n * next text, or undefined when the edit changes nothing, so the caller writes only a real change. Nothing here reads\n * or writes a file: the caller owns confinement, the revision check and the atomic replace.\n *\n * Edits keep comments, key order and every key they were not asked to change. Values are validated by the same\n * parsers the loader uses, the result is parsed again, and anything the edit was not meant to touch must be equal\n * before and after, so a refused edit never produces text. Errors name the profile or file but never echo a value.\n */\n\nconst SETTING_KEYS = ['preset', 'domains', 'wake', 'timezone'] as const;\ntype SettingKey = (typeof SETTING_KEYS)[number];\nconst SIDECAR_VERSION = 1;\nconst MAX_DEFAULT_NAME_LENGTH = 128;\nconst CATALOG_KEYS = ['roots', 'entries'] as const;\n/** Any control character, newlines and tabs included: names and ids are one visible line. */\nconst CONTROL_CHARACTER = /\\p{Cc}/u;\n/** Long text stays on one line and `[a, b]` keeps its spacing, so only the edited lines differ. */\nconst YAML_OUTPUT = { lineWidth: 0, flowCollectionPadding: false } as const;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction sameValue(left: unknown, right: unknown): boolean {\n  if (Object.is(left, right)) return true;\n  if (Array.isArray(left)) {\n    return (\n      Array.isArray(right) &&\n      left.length === right.length &&\n      left.every((entry, index) => sameValue(entry, right[index]))\n    );\n  }\n  if (!isRecord(left) || !isRecord(right)) return false;\n  const keys = Object.keys(left);\n  return (\n    keys.length === Object.keys(right).length &&\n    keys.every((key) => Object.hasOwn(right, key) && sameValue(left[key], right[key]))\n  );\n}\n\nfunction hasControlCharacter(value: string): boolean {\n  return CONTROL_CHARACTER.test(value);\n}\n\nfunction usesCatalogShape(profiles: Record<string, unknown>): boolean {\n  return CATALOG_KEYS.some((key) => Object.hasOwn(profiles, key));\n}\n\nfunction renderedDocument(document: Document): string {\n  return document.toString(YAML_OUTPUT);\n}\n\n/** Replaces a scalar in place, so a comment beside the old value stays with the key. */\nfunction setScalar(mapping: YAMLMap, key: string, value: string): void {\n  const node = mapping.get(key, true);\n  if (isScalar(node)) node.value = value;\n  else mapping.set(key, value);\n}\n\nfunction writeScalar(mapping: YAMLMap, key: string, value: string | undefined): void {\n  if (value === undefined) mapping.delete(key);\n  else setScalar(mapping, key, value);\n}\n\nfunction writeWake(document: Document, mapping: YAMLMap, wake: ProfileWakeEdit): void {\n  const period = wake.period.trim();\n  const prompt = wake.prompt?.trim();\n  const current = mapping.get('wake', true);\n  if (!isMap(current)) {\n    mapping.set('wake', document.createNode(prompt === undefined ? { period } : { period, prompt }));\n    return;\n  }\n  setScalar(current, 'period', period);\n  writeScalar(current, 'prompt', prompt);\n}\n\n/** Validates the settings that would result from `edit`, then writes only the keys it names. */\nfunction applySettingsEdit(document: Document, mapping: YAMLMap, name: string, edit: ProfileSettingsEdit): void {\n  if (Object.keys(edit).some((key) => !SETTING_KEYS.includes(key as SettingKey))) {\n    throw new Error(`Profile \"${name}\" settings can only change preset, domains, wake and timezone`);\n  }\n  const current = mapping.toJSON() as Record<string, unknown>;\n  const next: Record<string, unknown> = {};\n  for (const key of SETTING_KEYS) {\n    const value = edit[key];\n    next[key] = value === undefined ? current[key] : (value ?? undefined);\n  }\n  const settings = parseProfileSettings(name, next);\n  if (next.timezone !== undefined && !isTimeZone(next.timezone)) {\n    throw new Error(`Profile \"${name}\" timezone must be an IANA zone such as Australia/Sydney`);\n  }\n\n  if (edit.preset !== undefined) writeScalar(mapping, 'preset', settings.preset);\n  if (edit.timezone !== undefined) writeScalar(mapping, 'timezone', edit.timezone ?? undefined);\n  if (edit.domains !== undefined) {\n    if (settings.domains === undefined) mapping.delete('domains');\n    else {\n      const previous = mapping.get('domains', true);\n      const domains = document.createNode(settings.domains);\n      domains.flow = isSeq(previous) ? previous.flow : true;\n      mapping.set('domains', domains);\n    }\n  }\n  if (edit.wake !== undefined) {\n    if (edit.wake === null) mapping.delete('wake');\n    else writeWake(document, mapping, edit.wake);\n  }\n}\n\nfunction editedKeys(edit: ProfileSettingsEdit): SettingKey[] {\n  return SETTING_KEYS.filter((key) => edit[key] !== undefined);\n}\n\nfunction withoutKeys(record: Record<string, unknown>, keys: readonly string[]): Record<string, unknown> {\n  const copy = { ...record };\n  for (const key of keys) delete copy[key];\n  return copy;\n}\n\nfunction entryRecord(value: unknown, name: string): Record<string, unknown> | undefined {\n  if (!isRecord(value) || !isRecord(value.profiles)) return undefined;\n  const container = usesCatalogShape(value.profiles) ? value.profiles.entries : value.profiles;\n  if (!isRecord(container) || !Object.hasOwn(container, name)) return undefined;\n  const entry = container[name];\n  return isRecord(entry) ? entry : undefined;\n}\n\n/** A copy of the file with the edited keys removed from one entry, to compare what an edit must not change. */\nfunction withoutEntryKeys(value: unknown, name: string, keys: readonly string[]): unknown {\n  const copy = structuredClone(value);\n  const entry = entryRecord(copy, name);\n  if (entry) for (const key of keys) delete entry[key];\n  return copy;\n}\n\nfunction entryMapping(document: Document, name: string): YAMLMap {\n  const profiles = document.get('profiles', true);\n  if (!isMap(profiles)) throw new Error(`Profile \"${name}\" is not declared in a profiles mapping`);\n  const container = CATALOG_KEYS.some((key) => profiles.has(key)) ? profiles.get('entries', true) : profiles;\n  const entry = isMap(container) ? container.get(name, true) : undefined;\n  if (!isMap(entry)) throw new Error(`Profile \"${name}\" is not an explicit entry in this file`);\n  return entry;\n}\n\n/**\n * Applies `edit` to the explicit entry `name` of a profiles.yaml. The entry must already exist: this edits a\n * profile's settings and never declares one. Returns undefined when the settings already hold the requested values.\n */\nexport function editProfileEntryText(input: ProfileEntryEditInput): string | undefined {\n  const { text, filePath, baseDirectory, name, edit } = input;\n  const document = parseDocument(text);\n  if (document.errors.length > 0) throw new Error(`${filePath} is not valid YAML`);\n  parseProfileLayer({ filePath, baseDirectory, document: document.toJS() });\n  applySettingsEdit(document, entryMapping(document, name), name, edit);\n\n  const output = renderedDocument(document);\n  const before: unknown = parseYaml(text);\n  const after: unknown = parseYaml(output);\n  if (sameValue(before, after)) return undefined;\n  parseProfileLayer({ filePath, baseDirectory, document: after });\n\n  const keys = editedKeys(edit);\n  if (\n    !entryRecord(after, name) ||\n    !sameValue(withoutEntryKeys(before, name, keys), withoutEntryKeys(after, name, keys))\n  ) {\n    throw new Error(`Profile \"${name}\" could not be edited without changing something else`);\n  }\n  return output;\n}\n\n/**\n * Applies `edit` to the `profile.yaml` sidecar of a discovered profile, creating it as `version: 1` when the profile\n * has none. An existing sidecar that does not parse is never rewritten. Returns undefined when nothing changes.\n */\nexport function editProfileSidecarText(input: ProfileSidecarEditInput): string | undefined {\n  const { text, name, edit } = input;\n  if (text !== undefined) parseProfileSidecar(name, text);\n  const source = text ?? `version: ${SIDECAR_VERSION}\\n`;\n  const document = parseDocument(source);\n  if (document.errors.length > 0 || !isMap(document.contents)) {\n    throw new Error(`Profile \"${name}\" ${PROFILE_SIDECAR_FILE} is not valid YAML`);\n  }\n  applySettingsEdit(document, document.contents, name, edit);\n\n  const output = renderedDocument(document);\n  const before = parseYaml(source) as Record<string, unknown>;\n  const after: unknown = parseYaml(output);\n  if (sameValue(before, after)) return undefined;\n  parseProfileSidecar(name, output);\n\n  const keys = editedKeys(edit);\n  if (!isRecord(after) || !sameValue(withoutKeys(before, keys), withoutKeys(after, keys))) {\n    throw new Error(`Profile \"${name}\" ${PROFILE_SIDECAR_FILE} could not be edited without changing something else`);\n  }\n  return output;\n}\n\nfunction checkedDefaultName(value: string): string {\n  const name = value.trim();\n  if (name.length === 0 || name.length > MAX_DEFAULT_NAME_LENGTH || hasControlCharacter(name)) {\n    throw new Error(`The default profile must be one line of 1 to ${MAX_DEFAULT_NAME_LENGTH} characters`);\n  }\n  return name;\n}\n\n/** The catalog form of a layer without its default, so the rest of a file can be compared across an edit. */\nfunction withoutDefault(value: unknown): unknown {\n  if (!isRecord(value) || !isRecord(value.profiles)) return value;\n  const profiles = value.profiles;\n  const catalog: Record<string, unknown> = usesCatalogShape(profiles) ? { ...profiles } : { entries: profiles };\n  delete catalog.defaultProfile;\n  return { ...value, profiles: catalog };\n}\n\n/**\n * Sets or clears `defaultProfile` in a personal profiles.yaml. A missing or empty file is created in the catalog\n * form, and a flat-form file moves under `entries` so the default can be declared. Whether the named profile exists\n * is the caller's concern: a name a plugin source may still deliver is a valid request. Returns undefined when the\n * file already declares what was asked.\n */\nexport function editDefaultProfileText(input: ProfileDefaultEditInput): string | undefined {\n  const { text, filePath, baseDirectory } = input;\n  const profile = input.profile === null ? null : checkedDefaultName(input.profile);\n  const document = parseDocument(text ?? '');\n  if (document.errors.length > 0) throw new Error(`${filePath} is not valid YAML`);\n  const current: unknown = document.toJS();\n  const empty = current === null || current === undefined;\n  if (!empty) parseProfileLayer({ filePath, baseDirectory, document: current });\n  if (profile === null && empty) return undefined;\n\n  if (empty) {\n    document.set('profiles', document.createNode({ entries: {}, defaultProfile: profile }));\n  } else {\n    const profiles = document.get('profiles', true);\n    if (!isMap(profiles)) throw new Error(`${filePath} must contain a profiles mapping`);\n    const catalog = CATALOG_KEYS.some((key) => profiles.has(key));\n    if (profile === null) {\n      if (!catalog || !profiles.has('defaultProfile')) return undefined;\n      profiles.delete('defaultProfile');\n    } else if (catalog) {\n      setScalar(profiles, 'defaultProfile', profile);\n    } else if (profiles.items.length === 0) {\n      profiles.set('entries', document.createNode({}));\n      profiles.set('defaultProfile', profile);\n    } else {\n      const wrapped = new YAMLMap<string, unknown>();\n      wrapped.set('entries', profiles);\n      wrapped.set('defaultProfile', profile);\n      document.set('profiles', wrapped);\n    }\n  }\n\n  const output = renderedDocument(document);\n  const after: unknown = parseYaml(output);\n  if (sameValue(current, after)) return undefined;\n  const layer = parseProfileLayer({ filePath, baseDirectory, document: after });\n  if (layer.defaultProfile !== (profile ?? undefined)) {\n    throw new Error(`${filePath} could not be edited to declare the requested default profile`);\n  }\n  if (!empty && !sameValue(withoutDefault(current), withoutDefault(after))) {\n    throw new Error(`${filePath} could not be edited without changing something else`);\n  }\n  return output;\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAM,eAAe;CAAC;CAAU;CAAW;CAAQ;AAAU;AAE7D,MAAM,kBAAkB;AACxB,MAAM,0BAA0B;AAChC,MAAM,eAAe,CAAC,SAAS,SAAS;;AAExC,MAAM,oBAAoB;;AAE1B,MAAM,cAAc;CAAE,WAAW;CAAG,uBAAuB;AAAM;AAEjE,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,UAAU,MAAe,OAAyB;CACzD,IAAI,OAAO,GAAG,MAAM,KAAK,GAAG,OAAO;CACnC,IAAI,MAAM,QAAQ,IAAI,GACpB,OACE,MAAM,QAAQ,KAAK,KACnB,KAAK,WAAW,MAAM,UACtB,KAAK,OAAO,OAAO,UAAU,UAAU,OAAO,MAAM,MAAM,CAAC;CAG/D,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,KAAK,GAAG,OAAO;CAChD,MAAM,OAAO,OAAO,KAAK,IAAI;CAC7B,OACE,KAAK,WAAW,OAAO,KAAK,KAAK,CAAC,CAAC,UACnC,KAAK,OAAO,QAAQ,OAAO,OAAO,OAAO,GAAG,KAAK,UAAU,KAAK,MAAM,MAAM,IAAI,CAAC;AAErF;AAEA,SAAS,oBAAoB,OAAwB;CACnD,OAAO,kBAAkB,KAAK,KAAK;AACrC;AAE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