var n=Symbol("@ts-pattern/matcher"),t="@ts-pattern/anonymous-select-key",e=function(n){return Boolean(n&&"object"==typeof n)},r=function(t){return t&&!!t[n]},u=function t(u,i,c){if(e(u)){if(r(u)){var o=u[n]().match(i),a=o.matched,f=o.selections;return a&&f&&Object.keys(f).forEach(function(n){return c(n,f[n])}),a}if(!e(i))return !1;if(Array.isArray(u))return !!Array.isArray(i)&&u.length===i.length&&u.every(function(n,e){return t(n,i[e],c)});if(u instanceof Map)return i instanceof Map&&Array.from(u.keys()).every(function(n){return t(u.get(n),i.get(n),c)});if(u instanceof Set){if(!(i instanceof Set))return !1;if(0===u.size)return 0===i.size;if(1===u.size){var s=Array.from(u.values())[0];return r(s)?Array.from(i.values()).every(function(n){return t(s,n,c)}):i.has(s)}return Array.from(u.values()).every(function(n){return i.has(n)})}return Object.keys(u).every(function(e){var o,a=u[e];return (e in i||r(o=a)&&"optional"===o[n]().matcherType)&&t(a,i[e],c)})}return Object.is(i,u)};function h(t){var e;return (e={})[n]=function(){return {match:function(n){return {matched:Boolean(t(n))}}}},e}h(function(n){return !0});h(function(n){return "string"==typeof n});h(function(n){return "number"==typeof n});h(function(n){return "boolean"==typeof n});h(function(n){return "bigint"==typeof n});h(function(n){return "symbol"==typeof n});h(function(n){return null==n});function K(n){return new O(n,[])}var O=/*#__PURE__*/function(){function n(n,t){this.value=void 0,this.cases=void 0,this.value=n,this.cases=t;}var e=n.prototype;return e.with=function(){var e=[].slice.call(arguments),r=e[e.length-1],i=[e[0]],c=[];return 3===e.length&&"function"==typeof e[1]?(i.push(e[0]),c.push(e[1])):e.length>2&&i.push.apply(i,e.slice(1,e.length-1)),new n(this.value,this.cases.concat([{match:function(n){var e={},r=Boolean(i.some(function(t){return u(t,n,function(n,t){e[n]=t;})})&&c.every(function(t){return t(n)}));return {matched:r,value:r&&Object.keys(e).length?t in e?e[t]:e:n}},handler:r}]))},e.when=function(t,e){return new n(this.value,this.cases.concat([{match:function(n){return {matched:Boolean(t(n)),value:n}},handler:e}]))},e.otherwise=function(t){return new n(this.value,this.cases.concat([{match:function(n){return {matched:!0,value:n}},handler:t}])).run()},e.exhaustive=function(){return this.run()},e.run=function(){for(var n=this.value,t=void 0,e=0;e<this.cases.length;e++){var r=this.cases[e],u=r.match(this.value);if(u.matched){n=u.value,t=r.handler;break}}if(!t){var i;try{i=JSON.stringify(this.value);}catch(n){i=this.value;}throw new Error("Pattern matching error: no pattern matches value "+i)}return t(n,this.value)},n}();

export { K };
//# sourceMappingURL=index.module-d24badee.js.map
