{"version":3,"sources":["webpack:///./js/utils/element.ts","webpack:///./js/components/init-tables.ts"],"names":["removeAttributesOnElement","element","attributes","forEach","attribute","removeAttribute","name","traverseChildren","callback","children","child","tagName","toLowerCase","setElementClassByContainerWith","classLarge","classSmall","checkWidth","widthChild","getBoundingClientRect","width","classList","add","remove","window","matchMedia","addEventListener","whenDomReady","then","tables","document","querySelectorAll","elements","config","wrapper","createElement","setAttribute","value","parentNode","insertBefore","appendChild","additional","wrapElements","table","ths","trsArray","thsArray","tr","td","index","innerText","childNodes","setCellLabels"],"mappings":"8GAAO,MAAMA,EAA6BC,IACnB,IAAIA,EAAQC,YACpBC,QAASC,GAAcH,EAAQI,gBAAgBD,EAAUE,QAE3DC,EAAmB,CAACN,EAASO,KACtCA,EAASP,GACQ,IAAIA,EAAQQ,UACpBN,QAASO,IAEsB,MAAhCA,EAAMC,QAAQC,eAIlBL,EAAiBG,EAAOF,MAyBnBK,EAAiC,CAACZ,EAASa,EAAYC,KAChE,MAAMC,EAAcf,IAAY,MAC5B,MAAMS,EAAK,UAAGT,EAAQQ,gBAAX,aAAG,EAAmB,GACjC,IAAKC,EACD,OACJ,MAAMO,EAAaP,EAAMQ,wBAAwBC,QAC5BlB,aAAA,EAAAA,EAASiB,wBAAwBC,QAAS,GAC5CF,GACfH,GAAcb,EAAQmB,UAAUC,IAAIP,GACpCC,GAAcd,EAAQmB,UAAUE,OAAOP,KAGvCA,GAAcd,EAAQmB,UAAUC,IAAIN,GACpCD,GAAcb,EAAQmB,UAAUE,OAAOR,KAG/CE,EAAWf,GACCsB,OAAOC,WAAW,uBAC1BC,iBAAiB,SAAU,IAAMT,EAAWf,KClBpDyB,cAAeC,MAhBf,WACI,MAAMC,EAASC,SAASC,iBAAiB,kBDPZC,QCQZH,EDPK,IAAIG,GACZ5B,QAASF,IAEmB,MAAlCA,EAAQU,QAAQC,eAKpBL,EAAiBN,EAASD,KAGN,EAAC+B,EAAUC,KACb,IAAID,GACZ5B,QAASF,IAAY,UAC/B,MAAMgC,EAAUJ,SAASK,cAAcF,EAAOrB,SAAW,OACzDqB,SAAA,UAAAA,EAAQ9B,kBAAR,SAAoBC,QAASC,GAAc6B,EAAQE,aAAa/B,EAAUE,KAAMF,EAAUgC,QAC1F,UAAAnC,EAAQoC,kBAAR,SAAoBC,aAAaL,EAAShC,GAC1CgC,EAAQM,YAAYtC,GACpB+B,EAAOxB,UAAYwB,EAAOxB,SAASyB,EAASD,aAAzB,YAAyBA,EAAQQ,kBAAjC,aAAyB,EAAoB1B,eCVpE2B,CAAab,EAAQ,CACjBjB,QAAS,MACTT,WAAY,CAAC,CACLI,KAAM,QACN8B,MAAO,UAEf5B,SAAUK,EACV2B,WAAY,CACR1B,WAAY,kBA/BDc,KACC,IAAIA,GACZzB,QAASuC,IACjB,MAAMC,EAAMD,EAAMZ,iBAAiB,MAE7Bc,EAAW,IADLF,EAAMZ,iBAAiB,OAE7Be,EAAW,IAAIF,GACrBC,EAASzC,QAAS2C,IAEG,IADLA,EAAGhB,iBAAiB,OAEvB3B,QAAQ,CAAC4C,EAAIC,KAClBD,EAAGZ,aAAa,aAAcU,EAASG,GAAOC,WAC9C,MAAMxC,EAAW,IAAIsC,EAAGG,YAClBjB,EAAUJ,SAASK,cAAc,OACvCa,EAAGR,YAAYN,GACfxB,EAASN,QAASO,GAAUuB,EAAQM,YAAY7B,WAmB5DyC,CAAcvB","file":"53-047a870cc6f45c74e86d.js","sourcesContent":["export const removeAttributesOnElement = (element) => {\r\n const attributes = [...element.attributes];\r\n attributes.forEach((attribute) => element.removeAttribute(attribute.name));\r\n};\r\nexport const traverseChildren = (element, callback) => {\r\n callback(element);\r\n const children = [...element.children];\r\n children.forEach((child) => {\r\n // Check if the element is a link\r\n if (child.tagName.toLowerCase() === 'a') {\r\n // Skip processing link elements\r\n return;\r\n }\r\n traverseChildren(child, callback);\r\n });\r\n};\r\nexport const removeAttributes = (elements) => {\r\n const elementsArray = [...elements];\r\n elementsArray.forEach((element) => {\r\n // Check if the element is a link\r\n if (element.tagName.toLowerCase() === 'a') {\r\n // Skip processing link elements\r\n return;\r\n }\r\n // Otherwise, traverse children and remove attributes\r\n traverseChildren(element, removeAttributesOnElement);\r\n });\r\n};\r\nexport const wrapElements = (elements, config) => {\r\n const elementsArray = [...elements];\r\n elementsArray.forEach((element) => {\r\n const wrapper = document.createElement(config.tagName || 'div');\r\n config?.attributes?.forEach((attribute) => wrapper.setAttribute(attribute.name, attribute.value));\r\n element.parentNode?.insertBefore(wrapper, element);\r\n wrapper.appendChild(element);\r\n config.callback && config.callback(wrapper, config?.additional?.classLarge);\r\n });\r\n};\r\nexport const setElementClassByContainerWith = (element, classLarge, classSmall) => {\r\n const checkWidth = (element) => {\r\n const child = element.children?.[0];\r\n if (!child)\r\n return;\r\n const widthChild = child.getBoundingClientRect().width;\r\n const widthElement = element?.getBoundingClientRect().width || 0;\r\n if (widthElement < widthChild) {\r\n classLarge && element.classList.add(classLarge);\r\n classSmall && element.classList.remove(classSmall);\r\n }\r\n else {\r\n classSmall && element.classList.add(classSmall);\r\n classLarge && element.classList.remove(classLarge);\r\n }\r\n };\r\n checkWidth(element);\r\n const mql = window.matchMedia('(min-width: 1024px)');\r\n mql.addEventListener('change', () => checkWidth(element));\r\n};\r\n","import whenDomReady from 'when-dom-ready';\r\nimport { removeAttributes, wrapElements, setElementClassByContainerWith } from '../utils/element';\r\nconst setCellLabels = (tables) => {\r\n const tablesArray = [...tables];\r\n tablesArray.forEach((table) => {\r\n const ths = table.querySelectorAll('th');\r\n const trs = table.querySelectorAll('tr');\r\n const trsArray = [...trs];\r\n const thsArray = [...ths];\r\n trsArray.forEach((tr) => {\r\n const tds = tr.querySelectorAll('td');\r\n const tdsArray = [...tds];\r\n tdsArray.forEach((td, index) => {\r\n td.setAttribute('data-label', thsArray[index].innerText);\r\n const children = [...td.childNodes];\r\n const wrapper = document.createElement('div');\r\n td.appendChild(wrapper);\r\n children.forEach((child) => wrapper.appendChild(child));\r\n });\r\n });\r\n });\r\n};\r\nfunction initialise() {\r\n const tables = document.querySelectorAll('.fr-view table');\r\n removeAttributes(tables);\r\n wrapElements(tables, {\r\n tagName: 'div',\r\n attributes: [{\r\n name: 'class',\r\n value: 'table'\r\n }],\r\n callback: setElementClassByContainerWith,\r\n additional: {\r\n classLarge: 'table--large'\r\n }\r\n });\r\n setCellLabels(tables);\r\n}\r\nwhenDomReady().then(initialise);\r\n"],"sourceRoot":""}