{"version":3,"sources":["../source/close braces.js"],"names":["close_braces","retained_template","template","placeholder","empty_placeholder","cut_before","length","opening_braces","closing_braces","dangling_braces","replace"],"mappings":";;;;;;;AAAA;;AAEe,SAASA,YAAT,CAAsBC,iBAAtB,EAAyCC,QAAzC,EACf;AAAA,MADkEC,WAClE,uEADgF,GAChF;AAAA,MADqFC,iBACrF,uEADyG,GACzG;AACC,MAAIC,UAAU,GAAGJ,iBAAiB,CAACK,MAAnC;AAEA,MAAMC,cAAc,GAAG,+BAAiB,GAAjB,EAAsBN,iBAAtB,CAAvB;AACA,MAAMO,cAAc,GAAG,+BAAiB,GAAjB,EAAsBP,iBAAtB,CAAvB;AAEA,MAAIQ,eAAe,GAAGF,cAAc,GAAGC,cAAvC;;AAEA,SAAOC,eAAe,GAAG,CAAlB,IAAuBJ,UAAU,GAAGH,QAAQ,CAACI,MAApD,EACA;AACCL,IAAAA,iBAAiB,IAAIC,QAAQ,CAACG,UAAD,CAAR,CAAqBK,OAArB,CAA6BP,WAA7B,EAA0CC,iBAA1C,CAArB;;AAEA,QAAIF,QAAQ,CAACG,UAAD,CAAR,KAAyB,GAA7B,EACA;AACCI,MAAAA,eAAe;AACf;;AAEDJ,IAAAA,UAAU;AACV;;AAED,SAAOJ,iBAAP;AACA","sourcesContent":["import { count_occurences } from './helpers'\r\n\r\nexport default function close_braces(retained_template, template, placeholder = 'x', empty_placeholder = ' ')\r\n{\r\n\tlet cut_before = retained_template.length\r\n\r\n\tconst opening_braces = count_occurences('(', retained_template)\r\n\tconst closing_braces = count_occurences(')', retained_template)\r\n\r\n\tlet dangling_braces = opening_braces - closing_braces\r\n\r\n\twhile (dangling_braces > 0 && cut_before < template.length)\r\n\t{\r\n\t\tretained_template += template[cut_before].replace(placeholder, empty_placeholder)\r\n\r\n\t\tif (template[cut_before] === ')')\r\n\t\t{\r\n\t\t\tdangling_braces--\r\n\t\t}\r\n\r\n\t\tcut_before++\r\n\t}\r\n\r\n\treturn retained_template\r\n}\r\n"],"file":"close braces.js"}