{"version":3,"file":"lithentFTags.cjs","sources":["../src/index.ts"],"sourcesContent":["import { h, Fragment, isPropType, lmountComponentSet } from 'lithent';\nimport type {\n  Props,\n  WDom,\n  FragmentFunction,\n  MiddleStateWDom,\n  Component,\n  LComponent,\n  TagFunction,\n} from 'lithent';\n\ntype FFunction = (...param: (Props | MiddleStateWDom)[]) => WDom;\ntype FTags = {\n  [tagName: string]: FFunction;\n};\n\nexport const fTags: FTags = new Proxy(\n  {},\n  {\n    get(_: {}, tagName: string) {\n      return (...param: (Props | MiddleStateWDom)[]) => {\n        const props = param[0];\n        const childrens = param.slice(1);\n\n        if (isPropType(props)) {\n          return h(tagName, props || {}, ...childrens);\n        } else if (props !== undefined) {\n          return h(tagName, {}, props, ...childrens);\n        }\n\n        return h(tagName, {}, ...childrens);\n      };\n    },\n  }\n);\n\nexport const fFragment = (...children: MiddleStateWDom[]) => {\n  return h(Fragment as FragmentFunction, {}, ...children);\n};\n\nexport const fMount = <T>(component: Component<T>) => {\n  const tagFunction = (_props: T, _children: WDom[]) => component;\n\n  return (\n    ...param: unknown extends T\n      ? (Props | MiddleStateWDom)[]\n      : [T, ...MiddleStateWDom[]]\n  ) => {\n    const props = param[0];\n    const children = param.slice(1) as MiddleStateWDom[];\n\n    if (isPropType(props)) {\n      return h(tagFunction as TagFunction, props || {}, ...children);\n    } else if (props !== undefined) {\n      return h(tagFunction as TagFunction, {}, props, ...children);\n    }\n\n    return h(tagFunction as TagFunction, {}, ...children);\n  };\n};\n\nexport const flMount = <T>(component: LComponent<T>) => {\n  const tagFunction = (_props: T, _children: WDom[]) => component;\n\n  // Register component in lmountComponentSet for automatic state management\n  lmountComponentSet.add(component);\n\n  return (\n    ...param: unknown extends T\n      ? (Props | MiddleStateWDom)[]\n      : [T, ...MiddleStateWDom[]]\n  ) => {\n    const props = param[0];\n    const children = param.slice(1) as MiddleStateWDom[];\n\n    if (isPropType(props)) {\n      return h(tagFunction as unknown as TagFunction, props || {}, ...children);\n    } else if (props !== undefined) {\n      return h(tagFunction as unknown as TagFunction, {}, props, ...children);\n    }\n\n    return h(tagFunction as unknown as TagFunction, {}, ...children);\n  };\n};\n"],"names":["fTags","_","tagName","param","props","childrens","isPropType","h","fFragment","children","Fragment","fMount","component","tagFunction","_props","_children","flMount","lmountComponentSet"],"mappings":"2GAgBaA,EAAe,IAAI,MAC9B,CAAC,EACD,CACE,IAAIC,EAAOC,EAAiB,CAC1B,MAAO,IAAIC,IAAuC,CAC1C,MAAAC,EAAQD,EAAM,CAAC,EACfE,EAAYF,EAAM,MAAM,CAAC,EAE3B,OAAAG,EAAAA,WAAWF,CAAK,EACXG,EAAAA,EAAEL,EAASE,GAAS,CAAA,EAAI,GAAGC,CAAS,EAClCD,IAAU,OACZG,EAAAA,EAAEL,EAAS,CAAA,EAAIE,EAAO,GAAGC,CAAS,EAGpCE,EAAE,EAAAL,EAAS,GAAI,GAAGG,CAAS,CAAA,CAEtC,CACF,CACF,EAEaG,EAAY,IAAIC,IACpBF,EAAE,EAAAG,EAAA,SAA8B,GAAI,GAAGD,CAAQ,EAG3CE,EAAaC,GAA4B,CAC9C,MAAAC,EAAc,CAACC,EAAWC,IAAsBH,EAEtD,MAAO,IACFT,IAGA,CACG,MAAAC,EAAQD,EAAM,CAAC,EACfM,EAAWN,EAAM,MAAM,CAAC,EAE1B,OAAAG,EAAAA,WAAWF,CAAK,EACXG,EAAAA,EAAEM,EAA4BT,GAAS,CAAA,EAAI,GAAGK,CAAQ,EACpDL,IAAU,OACZG,EAAAA,EAAEM,EAA4B,CAAA,EAAIT,EAAO,GAAGK,CAAQ,EAGtDF,EAAE,EAAAM,EAA4B,GAAI,GAAGJ,CAAQ,CAAA,CAExD,EAEaO,EAAcJ,GAA6B,CAChD,MAAAC,EAAc,CAACC,EAAWC,IAAsBH,EAGtDK,OAAAA,qBAAmB,IAAIL,CAAS,EAEzB,IACFT,IAGA,CACG,MAAAC,EAAQD,EAAM,CAAC,EACfM,EAAWN,EAAM,MAAM,CAAC,EAE1B,OAAAG,EAAAA,WAAWF,CAAK,EACXG,EAAAA,EAAEM,EAAuCT,GAAS,CAAA,EAAI,GAAGK,CAAQ,EAC/DL,IAAU,OACZG,EAAAA,EAAEM,EAAuC,CAAA,EAAIT,EAAO,GAAGK,CAAQ,EAGjEF,EAAE,EAAAM,EAAuC,GAAI,GAAGJ,CAAQ,CAAA,CAEnE"}