{"version":3,"file":"roost.mjs","names":[],"sources":["../src/roost.ts"],"sourcesContent":["import type { JHTML, JHTMLNode, Roost } from \"./roost_i\";\r\nexport * from \"./roost_i\";\r\nconst roost: Roost = {\r\n    convert: (jhtml?: JHTML): string => {\r\n        if (!jhtml) return \"\";\r\n        let html = \"\";\r\n\r\n        for (const element in jhtml) {\r\n            if (Object.prototype.hasOwnProperty.call(jhtml, element)) {\r\n                const [tag, rawId] = element.split(\"-\");\r\n                \r\n                const attributes = jhtml[element];\r\n                let content = \"\";\r\n\r\n                if (typeof attributes === \"object\" && attributes !== null) {\r\n                    if (\"child\" in attributes) {\r\n                        content = typeof attributes.child === \"object\" && attributes.child !== null\r\n                            ? roost.convert(attributes.child as JHTML) \r\n                            : String(attributes.child ?? \"\");\r\n                    }\r\n\r\n                    if (tag === \"\") {\r\n                        html += `${content}`;\r\n                    } else {\r\n                        let obj = `<${tag}`;\r\n                        let isClosed = false;\r\n\r\n                        for (const attribute in attributes) {\r\n                            if (attribute === \"child\") continue;\r\n\r\n                            if (attribute === \"closed\") {\r\n                                isClosed = true;\r\n                            } else if (Object.prototype.hasOwnProperty.call(attributes, attribute)) {\r\n                                const value = attributes[attribute];\r\n                                obj += ` ${attribute}=\"${String(value)}\"`;\r\n                            }\r\n                        }\r\n                        /*          if its closed    />  OR  >           if its closed </tag> or nothing*/\r\n                        html += `${obj}${isClosed ? \"/\" : \"\"}>${content}${!isClosed ? `</${tag}>` : \"\"}`;\r\n                    }\r\n                }\r\n            }\r\n        }\r\n        return html;\r\n    },\r\n    convertJSX: (tag: string | Function | null, props?: any, ...children: any[]): JHTML => {\r\n        const nodeAttributes: JHTMLNode = {};\r\n\r\n        if (props && typeof props === \"object\") {\r\n            for (const key in props) {\r\n                if (Object.prototype.hasOwnProperty.call(props, key)) {\r\n                    nodeAttributes[key] = props[key];\r\n                }\r\n            }\r\n        }\r\n\r\n        const validChildren = children.filter(child => child !== null && child !== undefined && child !== \"\");\r\n\r\n        if (validChildren.length > 0) {\r\n            if (validChildren.length === 1) {\r\n                const child = validChildren[0];\r\n                nodeAttributes.child = (typeof child === \"object\" && child !== null) ?\r\n                                            child\r\n                                        :\r\n                                            String(child);\r\n            } else {\r\n                const childMap: JHTML = {};\r\n                validChildren.forEach((child, idx) => {\r\n                    childMap[`-${idx}`] = {\r\n                        child: (typeof child === \"object\" && child !== null) ?\r\n                                    child \r\n                                : \r\n                                    String(child)\r\n                    };\r\n                });\r\n                nodeAttributes.child = childMap;\r\n            }\r\n        } else {\r\n            nodeAttributes.closed = true;\r\n        }\r\n\r\n        let actualTag = (typeof tag === \"string\") ? tag :\"\";\r\n        \r\n        const finalTagKey = actualTag === \"\" ? \"-0\" : (actualTag.includes(\"-\") ? actualTag : `${actualTag}-0`);\r\n\r\n        return {\r\n            [finalTagKey]: nodeAttributes\r\n        };\r\n    },\r\n    extensions: {}\r\n};\r\n\r\nexport default roost;"],"mappings":"AAEA,MAAM,EAAe,CACjB,QAAU,GAA0B,CAChC,GAAI,CAAC,EAAO,MAAO,GACnB,IAAI,EAAO,GAEX,IAAK,IAAM,KAAW,EAClB,GAAI,OAAO,UAAU,eAAe,KAAK,EAAO,CAAO,EAAG,CACtD,GAAM,CAAC,EAAK,GAAS,EAAQ,MAAM,GAAG,EAEhC,EAAa,EAAM,GACrB,EAAU,GAEd,GAAI,OAAO,GAAe,UAAY,EAOlC,GANI,UAAW,IACX,EAAU,OAAO,EAAW,OAAU,UAAY,EAAW,QAAU,KACjE,EAAM,QAAQ,EAAW,KAAc,EACvC,OAAO,EAAW,OAAS,EAAE,GAGnC,IAAQ,GACR,GAAQ,GAAG,QACR,CACH,IAAI,EAAM,IAAI,IACV,EAAW,GAEf,IAAK,IAAM,KAAa,EAChB,OAAc,QAElB,IAAI,IAAc,SACd,EAAW,QACR,GAAI,OAAO,UAAU,eAAe,KAAK,EAAY,CAAS,EAAG,CACpE,IAAM,EAAQ,EAAW,GACzB,GAAO,IAAI,EAAU,IAAI,OAAO,CAAK,EAAE,EA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