import { umbUrlPatternToString } from '../utils/path/url-pattern-to-string.function.js';
export class UmbPathPattern {
    #local;
    #base;
    constructor(localPattern, basePath) {
        this.#local = localPattern;
        // Use toAbsolutePatternString() for UmbPathPattern to preserve the full path chain
        const baseString = basePath instanceof UmbPathPattern ? basePath.toAbsolutePatternString() : (basePath?.toString() ?? '');
        this.#base = baseString.length > 0 && !baseString.endsWith('/') ? baseString + '/' : baseString;
    }
    generateLocal(params) {
        return umbUrlPatternToString(this.#local, params);
    }
    /**
     * generate an absolute path from the path pattern
     * @param params
     * @param baseParams
     * @returns
     */
    generateAbsolute(params) {
        return ((this.#base.indexOf(':') !== -1 ? umbUrlPatternToString(this.#base, params) : this.#base) +
            umbUrlPatternToString(this.#local, params));
    }
    /**
     * Get the full absolute pattern string including base path.
     * Use this when chaining patterns to preserve the full path.
     * @returns The complete pattern string (base + local)
     */
    toAbsolutePatternString() {
        return this.#base + this.#local;
    }
    toString() {
        return this.#local;
    }
}
