!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).xmlTemplateLiteral={})}(this,(function(e){"use strict";var t,n,r,a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},a(e,t)};function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function i(e,t){var n,r,a,u,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return u={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function o(o){return function(c){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,o[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,r=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,u=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=u.next()).done;)i.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=u.return)&&n.call(u)}finally{if(a)throw a.error}}return i}function l(e,t,n){if(n||2===arguments.length)for(var r,a=0,u=t.length;a0&&(r.push({kind:e.AstKind.Composite,type:e.AttributeType.Text,value:a}),a=""),r.push({kind:e.AstKind.Composite,type:e.AttributeType.Data,value:n.current.value})):a+=n.current.value,p(n,!1);return v('"',n),r.length>0?(r.push({kind:e.AstKind.Composite,type:e.AttributeType.Text,value:a}),{kind:e.AstKind.Attribute,type:e.AttributeType.Composite,key:t,value:r}):{kind:e.AstKind.Attribute,type:e.AttributeType.Text,key:t,value:a}}(n,t))},h=function(t){v("<",t),p(t);var n=function(e){f("kind","Text",e);var t=e.current.value;return p(e),t}(t),r=function(e){for(var t=[];"Text"===e.current.kind;)t.push(y(e)),p(e);return t}(t);if("/>"===t.current.value)return v("/>",t),{kind:e.AstKind.Child,type:e.ChildType.Node,tag:n,attributes:r,children:[]};v(">",t),p(t,!1);var a=b(t);return v("",t),{kind:e.AstKind.Child,type:e.ChildType.Node,tag:n,attributes:r,children:a}},x=function(t){if("Data"===t.current.kind){var n=t.current.value;return p(t,!1),{kind:e.AstKind.Child,type:e.ChildType.Data,value:n}}if("Syntax"===t.current.kind&&"<"===t.current.value){var r=h(t);return p(t,!1),r}return function(t){for(var n="";"Text"===t.current.kind||"Whitespace"===t.current.kind||"Syntax"===t.current.kind&&""!==n.value?[3,5]:[4,{kind:"Syntax",value:"/>"}];case 4:return a.sent(),n=void 0,[3,1];case 5:return r?[4,r]:[3,7];case 6:a.sent(),a.label=7;case 7:return[3,1];case 8:return n?[4,n]:[3,10];case 9:a.sent(),a.label=10;case 10:return[2]}}))}function w(e){var t,n,r,a,u,c,l;return i(this,(function(i){switch(i.label){case 0:t="",i.label=1;case 1:i.trys.push([1,9,10,11]),n=o(e),r=n.next(),i.label=2;case 2:return r.done?[3,8]:"Text"===(a=r.value).kind?[3,6]:t?[4,{kind:"Text",value:t}]:[3,4];case 3:i.sent(),t="",i.label=4;case 4:return[4,a];case 5:return i.sent(),[3,7];case 6:t+=a.value,i.label=7;case 7:return r=n.next(),[3,2];case 8:return[3,11];case 9:return u=i.sent(),c={error:u},[3,11];case 10:try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(c)throw c.error}return[7];case 11:return t?[4,{kind:"Text",value:t}]:[3,13];case 12:i.sent(),i.label=13;case 13:return[2]}}))}function m(e){var t,n,r,a,u,c;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,24,25,26]),t=o(e),n=t.next(),i.label=1;case 1:if(n.done)return[3,23];switch(r=n.value,r){case"<":return[3,2];case">":return[3,4];case"/":return[3,6];case"=":return[3,8];case'"':return[3,10];case"\n":return[3,12];case"\r":return[3,14];case"\t":return[3,16];case" ":return[3,18]}return[3,20];case 2:return[4,{kind:"Syntax",value:"<"}];case 3:return i.sent(),[3,22];case 4:return[4,{kind:"Syntax",value:">"}];case 5:return i.sent(),[3,22];case 6:return[4,{kind:"Syntax",value:"/"}];case 7:return i.sent(),[3,22];case 8:return[4,{kind:"Syntax",value:"="}];case 9:return i.sent(),[3,22];case 10:return[4,{kind:"Syntax",value:'"'}];case 11:return i.sent(),[3,22];case 12:return[4,{kind:"Whitespace",value:"\n"}];case 13:return i.sent(),[3,22];case 14:return[4,{kind:"Whitespace",value:"\r"}];case 15:return i.sent(),[3,22];case 16:return[4,{kind:"Whitespace",value:"\t"}];case 17:return i.sent(),[3,22];case 18:return[4,{kind:"Whitespace",value:" "}];case 19:return i.sent(),[3,22];case 20:return[4,{kind:"Text",value:r}];case 21:return i.sent(),[3,22];case 22:return n=t.next(),[3,1];case 23:return[3,26];case 24:return a=i.sent(),u={error:a},[3,26];case 25:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(u)throw u.error}return[7];case 26:return[2]}}))}function A(e){var t,n,r,a,u,c;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,8,9,10]),t=o(e),n=t.next(),i.label=1;case 1:return n.done?[3,7]:"Static"!==(r=n.value).type?[3,3]:[5,o(T(w(m(r.value))))];case 2:return i.sent(),[3,6];case 3:return"Dynamic"!==r.type?[3,5]:[4,{kind:"Data",value:r.value}];case 4:return i.sent(),[3,6];case 5:throw new Error("Unknown segment: ".concat(r));case 6:return n=t.next(),[3,1];case 7:return[3,10];case 8:return a=i.sent(),u={error:a},[3,10];case 9:try{n&&!n.done&&(c=t.return)&&c.call(t)}finally{if(u)throw u.error}return[7];case 10:return[2]}}))}var g=function(e){var t=e.static.length,n=e.dynamic.length;if(t-n!=1)throw new RangeError('Invalid segment lengths: Expected "static.length - dynamic.length" to equal 1 but got '.concat(t-n));return new Array(t+n).fill(0).map((function(t,n){return n%2==0?{type:"Static",value:e.static[Math.floor(n/2)]}:{type:"Dynamic",value:e.dynamic[Math.floor(n/2)]}})).filter((function(e){return Boolean(e.value)}))};e.parseXml=function(e){return k(A(g({dynamic:[],static:[e]})))},e.xml=function(e){for(var t=[],n=1;n