{"version":3,"sources":["description.js"],"names":["Object","defineProperty","exports","value","getJoiner","primitives_1","require","descriptionTokenizer","spacing","join","spec","description","source","default","compactJoiner","preserveJoiner","lines","map","tokens","trim","filter","lineNo","num","i","type","getDescription","delimiter","start","postDelimiter","slice","length","Markers","lastLine","undefined","end","endsWith","reduce"],"mappings":"AAAA;;AACAA,MAAM,CAACC,cAAP,CAAsBC,OAAtB,EAA+B,YAA/B,EAA6C;AAAEC,EAAAA,KAAK,EAAE;AAAT,CAA7C;AACAD,OAAO,CAACE,SAAR,GAAoB,KAAK,CAAzB;;AACA,MAAMC,YAAY,GAAGC,OAAH,wBAAlB;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,oBAAT,CAA8BC,OAAO,GAAG,SAAxC,EAAmD;AAC/C,QAAMC,IAAI,GAAGL,SAAS,CAACI,OAAD,CAAtB;AACA,SAAQE,IAAD,IAAU;AACbA,IAAAA,IAAI,CAACC,WAAL,GAAmBF,IAAI,CAACC,IAAI,CAACE,MAAN,CAAvB;AACA,WAAOF,IAAP;AACH,GAHD;AAIH;;AACDR,OAAO,CAACW,OAAR,GAAkBN,oBAAlB;;AACA,SAASH,SAAT,CAAmBI,OAAnB,EAA4B;AACxB,MAAIA,OAAO,KAAK,SAAhB,EACI,OAAOM,aAAP;AACJ,MAAIN,OAAO,KAAK,UAAhB,EACI,OAAOO,cAAP;AACJ,SAAOP,OAAP;AACH;;AACDN,OAAO,CAACE,SAAR,GAAoBA,SAApB;;AACA,SAASU,aAAT,CAAuBE,KAAvB,EAA8B;AAC1B,SAAOA,KAAK,CACPC,GADE,CACE,CAAC;AAAEC,IAAAA,MAAM,EAAE;AAAEP,MAAAA;AAAF;AAAV,GAAD,KAAiCA,WAAW,CAACQ,IAAZ,EADnC,EAEFC,MAFE,CAEMT,WAAD,IAAiBA,WAAW,KAAK,EAFtC,EAGFF,IAHE,CAGG,GAHH,CAAP;AAIH;;AACD,MAAMY,MAAM,GAAG,CAACC,GAAD,EAAM;AAAEJ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,IAA1B,CAA+B,IAA/B,CAAP;AACH","sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getJoiner = void 0;\nconst primitives_1 = require(\"../../primitives\");\n/**\n * Makes no changes to `spec.lines[].tokens` but joins them into `spec.description`\n * following given spacing srtategy\n * @param {Spacing} spacing tells how to handle the whitespace\n */\nfunction descriptionTokenizer(spacing = 'compact') {\n const join = getJoiner(spacing);\n return (spec) => {\n spec.description = join(spec.source);\n return spec;\n };\n}\nexports.default = descriptionTokenizer;\nfunction getJoiner(spacing) {\n if (spacing === 'compact')\n return compactJoiner;\n if (spacing === 'preserve')\n return preserveJoiner;\n return spacing;\n}\nexports.getJoiner = getJoiner;\nfunction compactJoiner(lines) {\n return lines\n .map(({ tokens: { description } }) => description.trim())\n .filter((description) => description !== '')\n .join(' ');\n}\nconst lineNo = (num, { tokens }, i) => tokens.type === '' ? num : i;\nconst getDescription = ({ tokens }) => (tokens.delimiter === '' ? tokens.start : tokens.postDelimiter.slice(1)) +\n tokens.description;\nfunction preserveJoiner(lines) {\n if (lines.length === 0)\n return '';\n // skip the opening line with no description\n if (lines[0].tokens.description === '' &&\n lines[0].tokens.delimiter === primitives_1.Markers.start)\n lines = lines.slice(1);\n // skip the closing line with no description\n const lastLine = lines[lines.length - 1];\n if (lastLine !== undefined &&\n lastLine.tokens.description === '' &&\n lastLine.tokens.end.endsWith(primitives_1.Markers.end))\n lines = lines.slice(0, -1);\n // description starts at the last line of type definition\n lines = lines.slice(lines.reduce(lineNo, 0));\n return lines.map(getDescription).join('\\n');\n}\n"],"file":"description.cjs"}