{ "version": 3, "sources": ["recursive_typography_controller-bac159aa.js"], "sourcesContent": ["import { Controller } from \"@hotwired/stimulus\"\nimport balanceText from \"balance-text\"\n\nexport default class extends Controller {\n static values = {\n matchElementTypes: { type: Array, default: [\"div\"] }\n }\n \n connect() {\n this.typographize(this.element)\n }\n \n typographize(element) {\n if (element.children.length > 0) {\n for (const childElement of element.children) {\n this.typographize(childElement)\n }\n }\n \n if (this.shouldApplyTypographyToElement(element)) {\n balanceText(element, { watch: true })\n }\n }\n \n elementIsMatchType(element) {\n const elementType = element.nodeName.toLowerCase()\n return this.matchElementTypesValue.includes(elementType)\n }\n \n shouldApplyTypographyToElement(element) {\n return (this.elementIsMatchType(element) && !this.elementHasMatchingChildren(element))\n }\n \n elementHasMatchingChildren(element) {\n const children = element.children\n \n let matchFound = false\n let i = 0\n \n while (!matchFound && (i < children.length)) {\n let child = children[i]\n matchFound = this.elementIsMatchType(child)\n i++\n }\n \n return matchFound\n }\n}\n"], "mappings": "wKAAA,gDACA,4BAEA,qBAAO,SAAsB,EAAW,CAKtC,SAAU,CACR,KAAK,aAAa,KAAK,OAAO,CAChC,CAEA,aAAa,EAAS,CACpB,GAAI,EAAQ,SAAS,OAAS,EAC5B,SAAW,KAAgB,GAAQ,SACjC,KAAK,aAAa,CAAY,EAIlC,AAAI,KAAK,+BAA+B,CAAO,GAC7C,EAAY,EAAS,CAAE,MAAO,EAAK,CAAC,CAExC,CAEA,mBAAmB,EAAS,CAC1B,KAAM,GAAc,EAAQ,SAAS,YAAY,EACjD,MAAO,MAAK,uBAAuB,SAAS,CAAW,CACzD,CAEA,+BAA+B,EAAS,CACtC,MAAQ,MAAK,mBAAmB,CAAO,GAAK,CAAC,KAAK,2BAA2B,CAAO,CACtF,CAEA,2BAA2B,EAAS,CAClC,KAAM,GAAW,EAAQ,SAEzB,GAAI,GAAa,GACb,EAAI,EAER,KAAO,CAAC,GAAe,EAAI,EAAS,QAAS,CAC3C,GAAI,GAAQ,EAAS,GACrB,EAAa,KAAK,mBAAmB,CAAK,EAC1C,GACF,CAEA,MAAO,EACT,CACF,CA3CS,EADT,EACS,SAAS,CACd,kBAAmB,CAAE,KAAM,MAAO,QAAS,CAAC,KAAK,CAAE,CACrD", "names": [] }