/* SPDX-License-Identifier: AGPL-3.0-or-later */
import type AjaxResponse from "./AjaxResponse.js";
import type AjaxSettings from "./AjaxSettings.js";
import type Pod from "./Pod.js";
import PodsClassName from "./podsClassName.js";
import type State from "./State.js";
import type SubPod from "./SubPod.js";
export default (
AjaxSettings: AjaxSettings,
AjaxResponse: AjaxResponse
): string =>
`
${
// Wolfram Alpha does have some limitations when it comes to processing certain types of input.
// When "input" is an empty string,
// the "pods" property will not be present in the "queryresult" object.
// To see an example of an empty input string,
// visit the following URL:
// https://www.wolframalpha.com/input?i=
Object.freeze(AjaxResponse) === undefined
? (console.warn({ AjaxResponse }), "")
: AjaxResponse.queryresult === undefined
? (console.warn({ AjaxResponse }), "")
: AjaxResponse.queryresult.pods === undefined
? "" // console.warn
: AjaxResponse.queryresult.pods.map(buildPod).join("")
}
Technical information
If you have programming knowledge, feel free to explore the technical information provided below:
`
}
${
// In most cases, pods are stateless and do not have specific states.
// As a result, the "states" property of "pod" is typically undefined.
pod.states === undefined
? "" // console.warn
: pod.states.map(buildSelectElement).join("")
}
${
pod.subpods === undefined
? (console.warn({ pod }), "")
: pod.subpods.map(buildSubpod).join("")
}
`;
const buildSelectElement = (state: State): string =>
// Although it is possible to handle the scenario where the "states" property is undefined,
// implementing the necessary logic may result in a cluttered user interface.
// This challenge is primarily due to my limited expertise in front-end design.
// Consequently, the current implementation of the parsing logic is still insufficient in addressing the situation where the "states" property is undefined.
state.states === undefined
? "" // console.warn
: `
`;
const buildOption = (state: { name?: string }): string =>
state.name === undefined
? (console.warn({ state }), "")
: `
`;
const buildSubpod = (subpod: SubPod): string =>
`
${
subpod.img === undefined
? (console.warn({ subpod }), "")
: `