// ../../node_modules/.pnpm/ufo@1.6.4/node_modules/ufo/dist/index.mjs
var r = String.fromCharCode;
var PLUS_RE = /\+/g;
function decode(text = "") {
  try {
    return decodeURIComponent("" + text);
  } catch {
    return "" + text;
  }
}
function decodeQueryKey(text) {
  return decode(text.replace(PLUS_RE, " "));
}
function decodeQueryValue(text) {
  return decode(text.replace(PLUS_RE, " "));
}
function parseQuery(parametersString = "") {
  const object = /* @__PURE__ */ Object.create(null);
  if (parametersString[0] === "?") {
    parametersString = parametersString.slice(1);
  }
  for (const parameter of parametersString.split("&")) {
    const s = parameter.match(/([^=]+)=?(.*)/) || [];
    if (s.length < 2) {
      continue;
    }
    const key = decodeQueryKey(s[1]);
    if (key === "__proto__" || key === "constructor") {
      continue;
    }
    const value = decodeQueryValue(s[2] || "");
    if (object[key] === void 0) {
      object[key] = value;
    } else if (Array.isArray(object[key])) {
      object[key].push(value);
    } else {
      object[key] = [object[key], value];
    }
  }
  return object;
}
var PROTOCOL_STRICT_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/;
var PROTOCOL_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{2})?/;
var PROTOCOL_RELATIVE_REGEX = /^([/\\]\s*){2,}[^/\\]/;
function hasProtocol(inputString, opts = {}) {
  if (typeof opts === "boolean") {
    opts = { acceptRelative: opts };
  }
  if (opts.strict) {
    return PROTOCOL_STRICT_REGEX.test(inputString);
  }
  return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);
}
function getQuery(input) {
  return parseQuery(parseURL(input).search);
}
var protocolRelative = /* @__PURE__ */ Symbol.for("ufo:protocolRelative");
function parseURL(input = "", defaultProto) {
  const _specialProtoMatch = input.match(
    /^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i
  );
  if (_specialProtoMatch) {
    const [, _proto, _pathname = ""] = _specialProtoMatch;
    return {
      protocol: _proto.toLowerCase(),
      pathname: _pathname,
      href: _proto + _pathname,
      auth: "",
      host: "",
      search: "",
      hash: ""
    };
  }
  if (!hasProtocol(input, { acceptRelative: true })) {
    return defaultProto ? parseURL(defaultProto + input) : parsePath(input);
  }
  const [, protocol = "", auth, hostAndPath = ""] = input.replace(/\\/g, "/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || [];
  let [, host = "", path = ""] = hostAndPath.match(/([^#/?]*)(.*)?/) || [];
  if (protocol === "file:") {
    path = path.replace(/\/(?=[A-Za-z]:)/, "");
  }
  const { pathname, search, hash } = parsePath(path);
  return {
    protocol: protocol.toLowerCase(),
    auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : "",
    host,
    pathname,
    search,
    hash,
    [protocolRelative]: !protocol
  };
}
function parsePath(input = "") {
  const [pathname = "", search = "", hash = ""] = (input.match(/([^#?]*)(\?[^#]*)?(#.*)?/) || []).splice(1);
  return {
    pathname,
    search,
    hash
  };
}

// ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs
function isPlainObject(value) {
  if (value === null || typeof value !== "object") {
    return false;
  }
  const prototype = Object.getPrototypeOf(value);
  if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
    return false;
  }
  if (Symbol.iterator in value) {
    return false;
  }
  if (Symbol.toStringTag in value) {
    return Object.prototype.toString.call(value) === "[object Module]";
  }
  return true;
}
function _defu(baseObject, defaults, namespace = ".", merger) {
  if (!isPlainObject(defaults)) {
    return _defu(baseObject, {}, namespace, merger);
  }
  const object = { ...defaults };
  for (const key of Object.keys(baseObject)) {
    if (key === "__proto__" || key === "constructor") {
      continue;
    }
    const value = baseObject[key];
    if (value === null || value === void 0) {
      continue;
    }
    if (merger && merger(object, key, value, namespace)) {
      continue;
    }
    if (Array.isArray(value) && Array.isArray(object[key])) {
      object[key] = [...value, ...object[key]];
    } else if (isPlainObject(value) && isPlainObject(object[key])) {
      object[key] = _defu(
        value,
        object[key],
        (namespace ? `${namespace}.` : "") + key.toString(),
        merger
      );
    } else {
      object[key] = value;
    }
  }
  return object;
}
function createDefu(merger) {
  return (...arguments_) => (
    // eslint-disable-next-line unicorn/no-array-reduce
    arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
  );
}
var defu = createDefu();
var defuFn = createDefu((object, key, currentValue) => {
  if (object[key] !== void 0 && typeof currentValue === "function") {
    object[key] = currentValue(object[key]);
    return true;
  }
});
var defuArrayFn = createDefu((object, key, currentValue) => {
  if (Array.isArray(object[key]) && typeof currentValue === "function") {
    object[key] = currentValue(object[key]);
    return true;
  }
});

// ../../node_modules/.pnpm/h3@1.15.11/node_modules/h3/dist/index.mjs
function getQuery2(event) {
  return getQuery(event.path || "");
}
function getRouterParams(event, opts = {}) {
  let params = event.context.params || {};
  if (opts.decode) {
    params = { ...params };
    for (const key in params) {
      params[key] = decode(params[key]);
    }
  }
  return params;
}
var H3Headers = globalThis.Headers;
var H3Response = globalThis.Response;

// index.ts
var index_default = ({ log, publicSettings }) => ({
  settings: {},
  manifest: {
    name: "Example",
    author: "lesion",
    url: "https://framagit.org/les/gancio",
    description: "An example plugin to show how to create a plugin for Gancio",
    // define your plugin settings schema, this will be used to generate the settings form in the admin panel
    settings: {
      my_plugin_string_setting: {
        type: "TEXT",
        description: "My plugin string setting",
        required: true,
        hint: "My plugin setting support <strong>html too</strong>"
      },
      enable_this_feature_in_my_plugin: {
        type: "CHECK",
        description: "My plugin best feature",
        hint: "This feature is super dupe, enable it!"
      },
      min_post: {
        type: "NUMBER",
        description: "it supports number too"
      },
      my_default_language: {
        description: "My default language",
        type: "LIST",
        items: ["it", "en", "fr"],
        default: publicSettings.instance_locale || "en"
      }
    }
  },
  // when the plugin is enabled, this function is called, you can do some initialization here like
  // starting a Task with services.TaskManager or setting up some data in db, initialize external API connection, etc...
  // settings are available with this.settings, they are automatically updated when the settings are changed in the admin panel
  load() {
    log.debug("Example plugin loaded with settings:", this.settings);
  },
  // this function can be called from the admin panel to test the plugin without enabling it,
  // useful for example if you want to test the connection to an external API with the provided settings before enabling the plugin
  onTest(settings) {
    log.debug("Example plugin onTest called with settings:", settings);
  },
  // these functions are called when an event is created, deleted or updated in Gancio,
  // you can use them to do some custom actions like sending a notification to an external service, etc...
  onEventCreate(event) {
    log.debug("Example plugin onEventCreate called with event:", event);
  },
  onEventDelete(event) {
    log.debug("Example plugin onEventDelete called with event:", event);
  },
  onEventUpdate(event) {
    log.debug("Example plugin onEventUpdate called with event:", event);
  },
  // called when the plugin is disabled, you can do some cleanup here like stopping a Task with services.TaskManager
  unload() {
    log.debug("Example plugin unloaded");
  },
  onCLI(args) {
    log.debug("Example plugin onCLI called with args:", args);
  },
  routeAPI(evt) {
    log.debug("Example plugin routeAPI called with event:");
    return {
      message: "Hello from example plugin API route!",
      query: getQuery2(evt),
      params: getRouterParams(evt)
    };
  }
});
export {
  index_default as default
};
