UNPKG

unsuspected-hangeul

Version:

함수형 난해한 언어 '평범한 한글'의 명세와 구현체입니다. 평범한 한글 문장으로 보이는 프로그램을 짜보세요!

3 lines (2 loc) 50.3 kB
function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function n(t){var n={exports:{}};return t(n,n.exports),n.exports}var e=n(function(t){var n={};function e(t){return t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.exports=n,n.eastAsianWidth=function(t){var n=t.charCodeAt(0),e=2==t.length?t.charCodeAt(1):0,r=n;return 55296<=n&&n<=56319&&56320<=e&&e<=57343&&(r=(n&=1023)<<10|(e&=1023),r+=65536),12288==r||65281<=r&&r<=65376||65504<=r&&r<=65510?"F":8361==r||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?"H":4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?"W":32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||172==r||175==r||10214<=r&&r<=10221||10629<=r&&r<=10630?"Na":161==r||164==r||167<=r&&r<=168||170==r||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||198==r||208==r||215<=r&&r<=216||222<=r&&r<=225||230==r||232<=r&&r<=234||236<=r&&r<=237||240==r||242<=r&&r<=243||247<=r&&r<=250||252==r||254==r||257==r||273==r||275==r||283==r||294<=r&&r<=295||299==r||305<=r&&r<=307||312==r||319<=r&&r<=322||324==r||328<=r&&r<=331||333==r||338<=r&&r<=339||358<=r&&r<=359||363==r||462==r||464==r||466==r||468==r||470==r||472==r||474==r||476==r||593==r||609==r||708==r||711==r||713<=r&&r<=715||717==r||720==r||728<=r&&r<=731||733==r||735==r||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||1025==r||1040<=r&&r<=1103||1105==r||8208==r||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||8240==r||8242<=r&&r<=8243||8245==r||8251==r||8254==r||8308==r||8319==r||8321<=r&&r<=8324||8364==r||8451==r||8453==r||8457==r||8467==r||8470==r||8481<=r&&r<=8482||8486==r||8491==r||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||8585==r||8592<=r&&r<=8601||8632<=r&&r<=8633||8658==r||8660==r||8679==r||8704==r||8706<=r&&r<=8707||8711<=r&&r<=8712||8715==r||8719==r||8721==r||8725==r||8730==r||8733<=r&&r<=8736||8739==r||8741==r||8743<=r&&r<=8748||8750==r||8756<=r&&r<=8759||8764<=r&&r<=8765||8776==r||8780==r||8786==r||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||8853==r||8857==r||8869==r||8895==r||8978==r||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||9675==r||9678<=r&&r<=9681||9698<=r&&r<=9701||9711==r||9733<=r&&r<=9734||9737==r||9742<=r&&r<=9743||9748<=r&&r<=9749||9756==r||9758==r||9792==r||9794==r||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||9839==r||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||9955==r||9960<=r&&r<=9983||10045==r||10071==r||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||65533==r||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?"A":"N"},n.characterLength=function(t){var n=this.eastAsianWidth(t);return"F"==n||"W"==n||"A"==n?2:1},n.length=function(t){for(var n=e(t),r=0,i=0;i<n.length;i++)r+=this.characterLength(n[i]);return r},n.slice=function(t,r,i){textLen=n.length(t),i=i||1,(r=r||0)<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var s="",o=0,a=e(t),c=0;c<a.length;c++){var u=a[c],h=n.length(u);if(o>=r-(2==h?1:0)){if(!(o+h<=i))break;s+=u}o+=h}return s}}),r=n(function(t,n){!function(n){var e=Math.cosh||function(t){return Math.abs(t)<1e-9?1-t:.5*(Math.exp(t)+Math.exp(-t))},r=Math.sinh||function(t){return Math.abs(t)<1e-9?t:.5*(Math.exp(t)-Math.exp(-t))},i=function(){throw SyntaxError("Invalid Param")};function s(t,n){var e=Math.abs(t),r=Math.abs(n);return 0===t?Math.log(r):0===n?Math.log(e):e<3e3&&r<3e3?.5*Math.log(t*t+n*n):(t/=2,n/=2,.5*Math.log(t*t+n*n)+Math.LN2)}function o(t,n){if(!(this instanceof o))return new o(t,n);var e=function(t,n){var e={re:0,im:0};if(null==t)e.re=e.im=0;else if(void 0!==n)e.re=t,e.im=n;else switch(typeof t){case"object":if("im"in t&&"re"in t)e.re=t.re,e.im=t.im;else if("abs"in t&&"arg"in t){if(!Number.isFinite(t.abs)&&Number.isFinite(t.arg))return o.INFINITY;e.re=t.abs*Math.cos(t.arg),e.im=t.abs*Math.sin(t.arg)}else if("r"in t&&"phi"in t){if(!Number.isFinite(t.r)&&Number.isFinite(t.phi))return o.INFINITY;e.re=t.r*Math.cos(t.phi),e.im=t.r*Math.sin(t.phi)}else 2===t.length?(e.re=t[0],e.im=t[1]):i();break;case"string":e.im=e.re=0;var r=t.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),s=1,a=0;null===r&&i();for(var c=0;c<r.length;c++){var u=r[c];" "===u||"\t"===u||"\n"===u||("+"===u?s++:"-"===u?a++:"i"===u||"I"===u?(s+a===0&&i()," "===r[c+1]||isNaN(r[c+1])?e.im+=parseFloat((a%2?"-":"")+"1"):(e.im+=parseFloat((a%2?"-":"")+r[c+1]),c++),s=a=0):((s+a===0||isNaN(u))&&i(),"i"===r[c+1]||"I"===r[c+1]?(e.im+=parseFloat((a%2?"-":"")+u),c++):e.re+=parseFloat((a%2?"-":"")+u),s=a=0))}s+a>0&&i();break;case"number":e.im=0,e.re=t;break;default:i()}return e}(t,n);this.re=e.re,this.im=e.im}o.prototype={re:0,im:0,sign:function(){var t=this.abs();return new o(this.re/t,this.im/t)},add:function(t,n){var e=new o(t,n);return this.isInfinite()&&e.isInfinite()?o.NAN:this.isInfinite()||e.isInfinite()?o.INFINITY:new o(this.re+e.re,this.im+e.im)},sub:function(t,n){var e=new o(t,n);return this.isInfinite()&&e.isInfinite()?o.NAN:this.isInfinite()||e.isInfinite()?o.INFINITY:new o(this.re-e.re,this.im-e.im)},mul:function(t,n){var e=new o(t,n);return this.isInfinite()&&e.isZero()||this.isZero()&&e.isInfinite()?o.NAN:this.isInfinite()||e.isInfinite()?o.INFINITY:0===e.im&&0===this.im?new o(this.re*e.re,0):new o(this.re*e.re-this.im*e.im,this.re*e.im+this.im*e.re)},div:function(t,n){var e=new o(t,n);if(this.isZero()&&e.isZero()||this.isInfinite()&&e.isInfinite())return o.NAN;if(this.isInfinite()||e.isZero())return o.INFINITY;if(this.isZero()||e.isInfinite())return o.ZERO;t=this.re,n=this.im;var r,i,s=e.re,a=e.im;return 0===a?new o(t/s,n/s):Math.abs(s)<Math.abs(a)?new o((t*(i=s/a)+n)/(r=s*i+a),(n*i-t)/r):new o((t+n*(i=a/s))/(r=a*i+s),(n-t*i)/r)},pow:function(t,n){var e=new o(t,n);if(t=this.re,n=this.im,e.isZero())return o.ONE;if(0===e.im){if(0===n&&t>0)return new o(Math.pow(t,e.re),0);if(0===t)switch((e.re%4+4)%4){case 0:return new o(Math.pow(n,e.re),0);case 1:return new o(0,Math.pow(n,e.re));case 2:return new o(-Math.pow(n,e.re),0);case 3:return new o(0,-Math.pow(n,e.re))}}if(0===t&&0===n&&e.re>0&&e.im>=0)return o.ZERO;var r=Math.atan2(n,t),i=s(t,n);return t=Math.exp(e.re*i-e.im*r),n=e.im*i+e.re*r,new o(t*Math.cos(n),t*Math.sin(n))},sqrt:function(){var t,n,e=this.re,r=this.im,i=this.abs();if(e>=0){if(0===r)return new o(Math.sqrt(e),0);t=.5*Math.sqrt(2*(i+e))}else t=Math.abs(r)/Math.sqrt(2*(i-e));return n=e<=0?.5*Math.sqrt(2*(i-e)):Math.abs(r)/Math.sqrt(2*(i+e)),new o(t,r<0?-n:n)},exp:function(){var t=Math.exp(this.re);return new o(t*Math.cos(this.im),t*Math.sin(this.im))},expm1:function(){var t=this.re,n=this.im;return new o(Math.expm1(t)*Math.cos(n)+function(t){var n=Math.PI/4;if(-n>t||t>n)return Math.cos(t)-1;var e=t*t;return e*(e*(e*(e*(e*(e*(e*(e/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-.5)}(n),Math.exp(t)*Math.sin(n))},log:function(){var t=this.re,n=this.im;return new o(s(t,n),Math.atan2(n,t))},abs:function(){return t=this.re,n=this.im,e=Math.abs(t),r=Math.abs(n),e<3e3&&r<3e3?Math.sqrt(e*e+r*r):(e<r?(e=r,r=t/n):r=n/t,e*Math.sqrt(1+r*r));var t,n,e,r},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){var t=this.re,n=this.im;return new o(Math.sin(t)*e(n),Math.cos(t)*r(n))},cos:function(){var t=this.re,n=this.im;return new o(Math.cos(t)*e(n),-Math.sin(t)*r(n))},tan:function(){var t=2*this.re,n=2*this.im,i=Math.cos(t)+e(n);return new o(Math.sin(t)/i,r(n)/i)},cot:function(){var t=2*this.re,n=2*this.im,i=Math.cos(t)-e(n);return new o(-Math.sin(t)/i,r(n)/i)},sec:function(){var t=this.re,n=this.im,i=.5*e(2*n)+.5*Math.cos(2*t);return new o(Math.cos(t)*e(n)/i,Math.sin(t)*r(n)/i)},csc:function(){var t=this.re,n=this.im,i=.5*e(2*n)-.5*Math.cos(2*t);return new o(Math.sin(t)*e(n)/i,-Math.cos(t)*r(n)/i)},asin:function(){var t=this.re,n=this.im,e=new o(n*n-t*t+1,-2*t*n).sqrt(),r=new o(e.re-n,e.im+t).log();return new o(r.im,-r.re)},acos:function(){var t=this.re,n=this.im,e=new o(n*n-t*t+1,-2*t*n).sqrt(),r=new o(e.re-n,e.im+t).log();return new o(Math.PI/2-r.im,r.re)},atan:function(){var t=this.re,n=this.im;if(0===t){if(1===n)return new o(0,Infinity);if(-1===n)return new o(0,-Infinity)}var e=t*t+(1-n)*(1-n),r=new o((1-n*n-t*t)/e,-2*t/e).log();return new o(-.5*r.im,.5*r.re)},acot:function(){var t=this.re,n=this.im;if(0===n)return new o(Math.atan2(1,t),0);var e=t*t+n*n;return 0!==e?new o(t/e,-n/e).atan():new o(0!==t?t/0:0,0!==n?-n/0:0).atan()},asec:function(){var t=this.re,n=this.im;if(0===t&&0===n)return new o(0,Infinity);var e=t*t+n*n;return 0!==e?new o(t/e,-n/e).acos():new o(0!==t?t/0:0,0!==n?-n/0:0).acos()},acsc:function(){var t=this.re,n=this.im;if(0===t&&0===n)return new o(Math.PI/2,Infinity);var e=t*t+n*n;return 0!==e?new o(t/e,-n/e).asin():new o(0!==t?t/0:0,0!==n?-n/0:0).asin()},sinh:function(){var t=this.re,n=this.im;return new o(r(t)*Math.cos(n),e(t)*Math.sin(n))},cosh:function(){var t=this.re,n=this.im;return new o(e(t)*Math.cos(n),r(t)*Math.sin(n))},tanh:function(){var t=2*this.re,n=2*this.im,i=e(t)+Math.cos(n);return new o(r(t)/i,Math.sin(n)/i)},coth:function(){var t=2*this.re,n=2*this.im,i=e(t)-Math.cos(n);return new o(r(t)/i,-Math.sin(n)/i)},csch:function(){var t=this.re,n=this.im,i=Math.cos(2*n)-e(2*t);return new o(-2*r(t)*Math.cos(n)/i,2*e(t)*Math.sin(n)/i)},sech:function(){var t=this.re,n=this.im,i=Math.cos(2*n)+e(2*t);return new o(2*e(t)*Math.cos(n)/i,-2*r(t)*Math.sin(n)/i)},asinh:function(){var t=this.im;this.im=-this.re,this.re=t;var n=this.asin();return this.re=-this.im,this.im=t,t=n.re,n.re=-n.im,n.im=t,n},acosh:function(){var t=this.acos();if(t.im<=0){var n=t.re;t.re=-t.im,t.im=n}else n=t.im,t.im=-t.re,t.re=n;return t},atanh:function(){var t=this.re,n=this.im,e=t>1&&0===n,r=1-t,i=1+t,a=r*r+n*n,c=0!==a?new o((i*r-n*n)/a,(n*r+i*n)/a):new o(-1!==t?t/0:0,0!==n?n/0:0),u=c.re;return c.re=s(c.re,c.im)/2,c.im=Math.atan2(c.im,u)/2,e&&(c.im=-c.im),c},acoth:function(){var t=this.re,n=this.im;if(0===t&&0===n)return new o(0,Math.PI/2);var e=t*t+n*n;return 0!==e?new o(t/e,-n/e).atanh():new o(0!==t?t/0:0,0!==n?-n/0:0).atanh()},acsch:function(){var t=this.re,n=this.im;if(0===n)return new o(0!==t?Math.log(t+Math.sqrt(t*t+1)):Infinity,0);var e=t*t+n*n;return 0!==e?new o(t/e,-n/e).asinh():new o(0!==t?t/0:0,0!==n?-n/0:0).asinh()},asech:function(){var t=this.re,n=this.im;if(this.isZero())return o.INFINITY;var e=t*t+n*n;return 0!==e?new o(t/e,-n/e).acosh():new o(0!==t?t/0:0,0!==n?-n/0:0).acosh()},inverse:function(){if(this.isZero())return o.INFINITY;if(this.isInfinite())return o.ZERO;var t=this.re,n=this.im,e=t*t+n*n;return new o(t/e,-n/e)},conjugate:function(){return new o(this.re,-this.im)},neg:function(){return new o(-this.re,-this.im)},ceil:function(t){return t=Math.pow(10,t||0),new o(Math.ceil(this.re*t)/t,Math.ceil(this.im*t)/t)},floor:function(t){return t=Math.pow(10,t||0),new o(Math.floor(this.re*t)/t,Math.floor(this.im*t)/t)},round:function(t){return t=Math.pow(10,t||0),new o(Math.round(this.re*t)/t,Math.round(this.im*t)/t)},equals:function(t,n){var e=new o(t,n);return Math.abs(e.re-this.re)<=o.EPSILON&&Math.abs(e.im-this.im)<=o.EPSILON},clone:function(){return new o(this.re,this.im)},toString:function(){var t=this.re,n=this.im,e="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(t)<o.EPSILON&&(t=0),Math.abs(n)<o.EPSILON&&(n=0),0===n?e+t:(0!==t?(e+=t,e+=" ",n<0?(n=-n,e+="-"):e+="+",e+=" "):n<0&&(n=-n,e+="-"),1!==n&&(e+=n),e+"i"))},toVector:function(){return[this.re,this.im]},valueOf:function(){return 0===this.im?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return 0===this.im&&0===this.re},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!(this.isNaN()||this.isFinite())}},o.ZERO=new o(0,0),o.ONE=new o(1,0),o.I=new o(0,1),o.PI=new o(Math.PI,0),o.E=new o(Math.E,0),o.INFINITY=new o(Infinity,Infinity),o.NAN=new o(NaN,NaN),o.EPSILON=1e-15,Object.defineProperty(o,"__esModule",{value:!0}),o.default=o,o.Complex=o,t.exports=o}()}),i=/*@__PURE__*/t(r);function s(t){const n="bigint"==typeof t?Number(t):t;return new i(n)}function o(t,n=10n){const e="0123456789abcdefghijklmnopqrstuvwxyz".slice(0,Number(n)),r=BigInt(n);let i,s=1n;if("string"==typeof t){"+"===t[0]?t=t.slice(1):"-"===t[0]&&(s=-1n,t=t.slice(1)),i=t.toLowerCase().split("").map(t=>e.indexOf(t));const r=i.indexOf(-1);if(-1!==r)throw Error(`다음 글자를 ${n}진법 숫자로 해석할 수 없습니다: '${t[r]}'`)}else i=t;let o=0n;for(let t=0;t<i.length;t++)o*=r,o+=BigInt(i[t]);return o*s}function a(t){return"bigint"!=typeof t&&(t instanceof i?a(t.re)||a(t.im):!(isFinite(t)||isNaN(t)))}function c(t){return"bigint"==typeof t||Number.isInteger(t)}function u(t,n){return n instanceof i?t.re===n.re&&t.im===n.im:0===t.im&&("bigint"==typeof n?h(n,t.re):n===t.re)}function h(t,n){return c(n)&&t===BigInt(n)}function f(t,n){return t instanceof i?u(t,n):n instanceof i?u(n,t):"bigint"==typeof t?h(t,n):"bigint"==typeof n?h(n,t):t===n}function l(t,n,e=1e-9,r=1e-16){if(e<0||r<0)throw RangeError("Tolerances must be non-negative.");if(f(t,n))return!0;if(a(t)||a(n))return!1;const o="bigint"==typeof t?Number(t):t,c="bigint"==typeof n?Number(n):n,u=m(function(t,n){return"bigint"==typeof t&&"bigint"==typeof n?t-n:t instanceof i||n instanceof i?s(t).sub(s(n)):Number(t)-Number(n)}(o,c));return u<=e*m(c)||u<=e*m(o)||u<=r}function m(t){return"bigint"==typeof t?t>=0n?t:-t:t instanceof i?t.abs():Math.abs(t)}function w(t,n){return"bigint"==typeof t&&"bigint"==typeof n?t+n:t instanceof i||n instanceof i?function(t,n){return new i(t.re+n.re,t.im+n.im)}(s(t),s(n)):Number(t)+Number(n)}function v(t,n){return"bigint"==typeof t&&"bigint"==typeof n?t*n:t instanceof i||n instanceof i?function(t,n){return new i(t.re*n.re-t.im*n.im,t.re*n.im+t.im*n.re)}(s(t),s(n)):Number(t)*Number(n)}Math.trunc=Math.trunc||function(t){return isNaN(t)?NaN:t>0?Math.floor(t):Math.ceil(t)};class p{constructor(t,n,e,r,i){this.filename=void 0,this.line_no=void 0,this.start_col=void 0,this.end_col=void 0,this.line=void 0,this.str=void 0,this.filename=t,this.line_no=n,this.start_col=e,this.end_col=r,this.line=i}toString(){return null==this.str&&(this.str=this.line+"\n"+" ".repeat(e.length(this.line.slice(0,this.start_col)))+"^".repeat(e.length(this.line.slice(this.start_col,this.end_col)))),this.str}}class d{constructor(t,n){this.metadata=void 0,this.value=void 0,this.metadata=t,this.value=n}}class g{constructor(t,n){this.metadata=void 0,this.rel=void 0,this.metadata=t,this.rel=n}}class y{constructor(t,n,e){this.metadata=void 0,this.relA=void 0,this.relF=void 0,this.metadata=t,this.relA=n,this.relF=e}}class b{constructor(t,n){this.metadata=void 0,this.body=void 0,this.metadata=t,this.body=n}}class N{constructor(t,n,e){this.metadata=void 0,this.fun=void 0,this.argv=void 0,this.metadata=t,this.fun=n,this.argv=e}}class M{constructor(t,n){this.funs=void 0,this.args=void 0,this.funs=t,this.args=n}}class I extends Error{constructor(t){let n="";for(const e of t.metadatas)n+=`${e.filename} ${e.line_no+1}번줄 `,n+=`${e.start_col+1}~${e.end_col+1}번째 글자:\n`,n+=e.toString()+"\n";super(n+"\n"+t.message),this.err=void 0,this.err=t}}class x{asKey(t){return this.format(t)}}function E(t){return isFinite(t)?t.toString():isNaN(t)?"nan":t>0?"inf":"-inf"}class $ extends x{constructor(t){super(),this.value=void 0,this.value=t}format(t){return this.value.toString()}}$.typeName="정수";class F extends x{constructor(t){super(),this.value=void 0,this.value=t}format(t){var n;return E(this.value)+(n=this.value,isFinite(n)&&l(n,Math.floor(n))?".0":"")}asKey(t){return E(this.value)}}F.typeName="실수";class A extends x{constructor(t){super(),this.value=void 0,this.value=t}format(t){const n=this.value.re,e=this.value.im,r=E(n)+(e<0?"":"+");return(0===n?"":r)+(1==e?"":-1==e?"-":E(e))+"i"}asKey(t){return this.value.im?this.format(t):E(this.value.re)}}A.typeName="복소수";class B extends x{constructor(t){super(),this.value=void 0,this.value=t}format(t){return this.value?"True":"False"}}B.typeName="논릿값";class j extends x{constructor(t){super(),this.value=void 0,this.value=t}format(t){return`[${this.value.map(n=>t.strict(n).format(t)).join(", ")}]`}asKey(t){return`[${this.value.map(n=>t.strict(n).asKey(t)).join(", ")}]`}}j.typeName="목록";class O extends x{constructor(t){super(),this.str=void 0,this.value=void 0,this.str=t,this.value=Array.from(t)}format(t){return"'"+this.str+"'"}}O.typeName="문자열";class _ extends x{constructor(t){super(),this.value=void 0,this.str=void 0,this.value=t}formatByte(t){return"\\x"+("0"+t.toString(16).toUpperCase()).slice(-2)}format(t){if(!this.str){const t=Array.from(new Uint8Array(this.value)).map(this.formatByte);this.str="b'"+t.join("")+"'"}return this.str}}_.typeName="바이트열";class U extends x{constructor(t){super(),this.value=void 0,this._keys=void 0,this._values=void 0,this.value=t}keys(){return this._keys||(this._keys=Object.keys(this.value).sort()),this._keys}values(){return this._values||(this._values=this.keys().map(t=>this.value[t])),this._values}format(t){const n=this.values().map(n=>t.strict(n).format(t));return"{"+this.keys().map((t,e)=>t+": "+n[e]).join(", ")+"}"}asKey(t){const n=this.values().map(n=>t.strict(n).asKey(t));return"{"+this.keys().map((t,e)=>t+": "+n[e]).join(", ")+"}"}}U.typeName="사전";class C extends x{constructor(t,n,e){super(),this.inst=void 0,this.argv=void 0,this.continuation=void 0,this.inst=t,this.argv=n,this.continuation=e}format(t){const n=this.argv.map(n=>t.strict(n).format(t)).join(", ");return`<드나듦 ${this.inst}: [${n}]>`}asKey(t){const n=this.argv.map(n=>t.strict(n).asKey(t)).join(", ");return`<드나듦 ${this.inst}: [${n}]>`}}C.typeName="드나듦";class P extends x{constructor(){super()}format(t){return"Nil"}}P.typeName="빈값";let S=0;class k extends x{constructor(t=""){super(),this.id=void 0,this.str=void 0,this.id=S++,this.str="<"+t+"함수>"}format(t){return this.str}asKey(t){return this.str.replace(">"," #"+this.id+">")}}k.typeName="함수";class L extends k{constructor(t,n){super(`깊이 ${n.args.length}에서 생성된 `),this.body=void 0,this.env=void 0,this.body=t,this.env=n}execute(t,n,e){const r=this.env.args.concat([e]),i=new M(this.env.funs,r);return new Z(this.body,i,null)}}class T extends k{constructor(t,n){super(),this.module=void 0,this.module=t,this.str="<기본 제공 모듈 "+n+">"}execute(t,n,e){return this.module(t,n,e)}}class K extends x{constructor(t,n,e){super(),this.metadatas=void 0,this.message=void 0,this.value=void 0,this.metadatas=t,this.message=n,this.value=e}format(t){return`<예외: [${this.value.map(n=>n.format(t)).join(", ")}]>`}asKey(t){return`<예외: [${this.value.map(n=>n.asKey(t)).join(", ")}]>`}}K.typeName="예외";class Z{constructor(t,n,e){this.expr=void 0,this.env=void 0,this.cache=void 0,this.expr=t,this.env=n,this.cache=e}}const q=[$,F],V=[...q,A],D=[j,O,_],Y=[k,B,U,A,K,...D];function R(){return R=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},R.apply(this,arguments)}const z="ㄱ|ㄱ|ㄴ|ㄷ|ㄷ|ㄹ|ㅁ|ㅂ|ㅂ|ㅅ|ㅅ| ㅇ|ㅈ|ㅈ|ㅈ|ㄱ|ㄷ|ㅂ| ㅎ|ㄴㄱ|ㄴ|ㄴㄷ|ㄴㅂ|ㄷㄱ|ㄹㄴ|ㄹ|ㄹ ㅎ|ㄹ|ㅁㅂ|ㅁ|ㅂㄱ|ㅂㄴ|ㅂㄷ|ㅂㅅ|ㅂㅅㄱ|ㅂㅅㄷ|ㅂㅅㅂ|ㅂㅅ|ㅂㅅㅈ|ㅂㅈ|ㅂㅈ|ㅂㄷ|ㅂㅂ|ㅂ|ㅂ|ㅅㄱ|ㅅㄴ|ㅅㄷ|ㅅㄹ|ㅅㅁ|ㅅㅂ|ㅅㅂㄱ|ㅅㅅ|ㅅ ㅇ|ㅅㅈ|ㅅㅈ|ㅅㄱ|ㅅㄷ|ㅅㅂ|ㅅ ㅎ|ㅅ|ㅅ|ㅅ|ㅅ|ㅅ| ㅇㄱ| ㅇㄷ| ㅇㅁ| ㅇㅂ| ㅇㅅ| ㅇㅅ| ㅇ| ㅇㅈ| ㅇㅈ| ㅇㄷ| ㅇㅂ| ㅇ|ㅈ ㅇ|ㅈ|ㅈ|ㅈ|ㅈ|ㅈㄱ|ㅈ ㅎ|ㅈ|ㅈ|ㅂㅂ|ㅂ| ㅎ| ㅎ|ㄱㄷ|ㄴㅅ|ㄴㅈ|ㄴ ㅎ|ㄷㄹ".split("|"),W="ㄱ|ㄱ|ㄱㅅ|ㄴ|ㄴㅈ|ㄴ ㅎ|ㄷ|ㄷ|ㄹ|ㄹㄱ|ㄹㅁ|ㄹㅂ|ㄹㅅ|ㄹㄷ|ㄹㅂ|ㄹ ㅎ|ㅁ|ㅂ|ㅂ|ㅂㅅ|ㅅ|ㅅ| ㅇ|ㅈ|ㅈ|ㅈ|ㄱ|ㄷ|ㅂ| ㅎ".split("|"),H="ㄴ|ㄴㄷ|ㄴㅅ|ㄴㅅ|ㄹㄱㅅ|ㄹㄷ|ㄹㅂㅅ|ㅁㅅ|ㅁ|ㅂㄱ|ㅂㄷ|ㅂㅅㄱ|ㅂㅅㄷ|ㅂㅈ|ㅂㄷ|ㅂ|ㅂ|ㅅㄱ|ㅅㄴ| ㅇ| ㅇ| ㅇㅅ| ㅇㅅ|ㅂ| ㅎ| ㅎ".split("|"),G="ㄷㅁ|ㄷㅂ|ㄷㅅ|ㄷㅈ|ㄹㄱ|ㄹㄱ|ㄹㄷ|ㄹㄷ|ㄹㅁ|ㄹㅂ|ㄹㅂ|ㄹㅂ|ㄹㅅ|ㄹㅈ|ㄹㄱ|ㅁㄱ|ㅁㄷ|ㅁㅅ|ㅂㅅㄷ|ㅂㄱ|ㅂ ㅎ|ㅅㅂ| ㅇㄹ| ㅇ ㅎ|ㅈ ㅎ|ㄷ|ㅂ ㅎ| ㅎㅅ| ㅎ".split("|");function J(t){if(1!==t.length)throw Error("[normalizeChar] Length of string should be 1, not "+t.length+": "+t);function n(n,e,r=1){let i=t.charCodeAt(0)-e.charCodeAt(0);return i=Math.floor(i/r),i>=0&&i<n.length?n[i]:""}return t>="ᄀ"&&t<="ᇿ"?n(z,"ᄀ"):t>="〮"&&t<="〯"?"":t>="ㄱ"&&t<="ㅤ"?n(W,"ㄱ"):t>="ㅥ"&&t<="ㆎ"?n(H,"ㅥ"):t>="ꥠ"&&t<="ꥼ"?n(G,"ꥠ"):t>="가"&&t<="힯"?n(z,"가",588):t>="ힰ"&&t<="ퟆ"||t>="ퟋ"&&t<="ퟻ"?"":t>="ᅠ"&&t<="ᄒ"?n(W,"ᄀ"):"ᅡᅢᅣᅤᅥᅦᅧᅨᅩᅪᅫᅬᅭᅮᅯᅰᅱᅲᅳᅴᅵ".indexOf(t)>=0?"":" "}function Q(t){return t.split("").map(J).join("").split(/( )/)}function X(t){const n=t.split("").map(function(t){return"ㄱㄴㄷㄹㅁㅂㅅㅈ".indexOf(t)});if(-1!==n.indexOf(-1))throw SyntaxError("Argument "+t+" has an unsupported character");let e=BigInt("0o"+n.reverse().join(""));return t.length%2==0&&(e=-e),e}function tt(t){const n=t<0;let e=(t=t>=0?t:-t).toString(8).split("").reverse().map(t=>"ㄱㄴㄷㄹㅁㅂㅅㅈ"[+t]).join("");return e.length%2==0!==n&&(e+="ㄱ"),e}function nt(t,n){const[e,r]=t;if(-1!==e.indexOf("ㅎ")){const t=e.slice(1);if(t){const e=Number(X(t));if(e<0)throw new ot(r,`함수 호출 시 ${e}개의 인수를 요구했습니다.`);const i=n.pop();if(null==i)throw new ot(r,"호출할 함수가 없습니다.");if(0===e)n.push(new N(r,i,[]));else{const t=n.splice(-e,e);if(t.length<e)throw new ot(r,`함수 호출 시 ${e}개의 인수를 요구했으나 표현식이 ${t.length}개밖에 없습니다.`);n.push(new N(r,i,t))}}else{const t=n.pop();if(null==t)throw new ot(r,"함수 몸통이 없습니다.");n.push(new b(r,t))}}else if(-1!==e.indexOf("ㅇ")){const t=e.slice(1);if(""!==t){const e=n.pop();if(null==e)throw new ot(r,"인수 참조 구문이 잘못되었습니다.");const i=Number(X(t));n.push(new y(r,e,i))}else{const t=n.pop();if(null==t)throw new ot(r,"함수 참조 구문이 잘못되었습니다.");if(!(t instanceof d))throw new ot(r,"함수 참조 시에는 정수 리터럴만 허용됩니다.");n.push(new g(r,Number(t.value)))}}else n.push(new d(r,X(e)))}function et(t,n){const e=function(t,n){const e=n.split("\n").flatMap((n,e)=>(n+"\n").split("").flatMap((r,i)=>Q(r).filter(t=>""!==t).map(r=>[r,new p(t,e,i,i+1,n)])));if(0===e.length)return[];let r=[e[0]];for(const[t,n]of e.slice(1)){const e=r.pop();if(null==e)throw Error("Internal::tokenize::EMPTY_STACK");const[o,a]=e;" "===o&&" "===t?r.push([o,a]):" "!==o&&" "!==t?r.push([o+t,(i=a,s=n,new p(i.filename,i.line_no,i.start_col,s.end_col,i.line))]):(r.push([o,a]),r.push([t,n]))}var i,s;return r.filter(([t,n])=>" "!==t)}(t,n),r=[];for(const t of e)nt(t,r);return r}class rt extends I{constructor(t,n,e){const r=[X("ㅂ"),...e].map(t=>new $(t));super(new K([t],n,r))}}class it extends rt{constructor(t,n){super(t,n,[X("ㅈㅈ")])}}class st extends rt{constructor(t,n){super(t,n,[X("ㅅㅅ")])}}class ot extends rt{constructor(t,n){super(t,n,[X("ㅁㅂ")])}}class at extends rt{constructor(t,n){super(t,n,[X("ㄱ")])}}class ct extends rt{constructor(t,n){super(t,n,[X("ㅈㅁ")])}}class ut extends rt{constructor(t,n){super(t,n,[X("ㄴㄴ")])}}class ht extends rt{constructor(t,n){super(t,n,[X("ㅁㅈ")])}}class ft extends rt{constructor(t,n){super(t,n,[X("ㅂ")])}}class lt extends rt{constructor(t,n){super(t,n,[X("ㅂㄱ")])}}function mt(t){return t instanceof Z&&t.expr instanceof d}function wt(t){return t.value}function vt(t){const n=t.map(t=>t.byteLength).reduce((t,n)=>t+n,0),e=new ArrayBuffer(n),r=new Uint8Array(e);return t.reduce(function(t,n){return r.set(new Uint8Array(n),t),t+n.byteLength},0),e}function pt(t,n){const e=n(t);if(e instanceof j)return new j(e.value.map(t=>pt(t,n)));if(e instanceof U){const t=e.value,r={};return Object.keys(t).forEach(function(e){r[e]=pt(t[e],n)}),new U(r)}return e instanceof K?new K(e.metadatas,e.message,e.value.map(t=>pt(t,n))):e}function dt(t){return 0===t.length||t.every(function(n){return n===t[0]})}function gt(t,n){return t.every(function(t){return n.some(function(n){return t instanceof n})})}function yt(t,n=", "){return t.join(n)}function bt(t,n,e){if(gt(n,e))return n;const r=e.map(t=>t.typeName),i=n.map(t=>t.constructor.typeName);throw new at(t,`인수를 ${yt(r)} 중에서 주어야 하는데 ${function(t,n,e){if(0===t.length)return t+"을";const r=t.charCodeAt(t.length-1);return r<44032||r>55203?t+"을":t+((r-44032)%28!=0?"을":"를")}(yt(i))} 주었습니다.`)}function Nt(t,n,e){const r=Array.isArray(e)?e:[e];if(-1===r.indexOf(n.length))throw new ct(t,`인수를 ${yt(r.map(t=>t.toString()),"개나 ")}개를 주어야 하는데 ${n.length}개의 인수를 주었습니다.`)}function Mt(t,n,e){if(!(n.length>=e))throw new ct(t,`인수를 ${e}개 이상 주어야 하는데${n.length}개 주었습니다.`)}function It(t,n,e){if(!(n.length<=e))throw new ct(t,`인수를 ${e}개 이하 주어야 하는데${n.length}개 주었습니다.`)}function xt(t,n,e,r){return void 0===r&&(r=[]),It(t,n,e),Mt(t,n,e-r.length),n.length<e&&(n=n.concat(r.slice(-(e-n.length)))),n}function Et(t){return"bigint"==typeof t?new $(t):t instanceof i?new A(t):new F(t)}var $t={ㄱ:function(t,n,e){if(Mt(n,e,1),gt(bt(n,[t.strict(e[0])],[B,...V]),V))return Et(bt(n,e.map(n=>t.strict(n)),V).map(t=>t.value).reduce(v));for(const r of e){const[e]=bt(n,[t.strict(r)],[B]);if(!e.value)return new B(!1)}return new B(!0)},ㄷ:function(t,n,e){Mt(n,e,1);const r=bt(n,[t.strict(e[0])],[B,U,...V,...D]);if(gt(r,[B])){for(const r of e){const[e]=bt(n,[t.strict(r)],[B]);if(e.value)return new B(!0)}return new B(!1)}if(gt(r,[O])){const r=bt(n,e.map(n=>t.strict(n)),[O]);return new O(r.map(t=>t.str).join(""))}if(gt(r,[_])){const r=bt(n,e.map(n=>t.strict(n)),[_]);return new _(vt(r.map(wt)))}if(gt(r,[j])){const r=bt(n,e.map(n=>t.strict(n)),[j]);return new j(r.map(wt).reduce((t,n)=>t.concat(n)))}if(gt(r,[U])){const r=bt(n,e.map(n=>t.strict(n)),[U]),i={};return r.map(wt).forEach(t=>Object.assign(i,t)),new U(i)}return Et(bt(n,e.map(n=>t.strict(n)),V).map(t=>t.value).reduce(w))},ㅅ:function(t,n,e){Nt(n,e,[2,3]);const r=bt(n,e.map(n=>t.strict(n)),V);if(3===r.length){const[t,e,i]=bt(n,r,[$]);try{return new $(function(t,n,e){if(0n===e)throw Error("0을 법으로 할 수 없습니다.");t%=e;let r=1n;for(n<0n&&(n=-n,t=function(t,n){const[e,r,i]=function(t,n){let[e,r,i,s]=[0n,1n,1n,0n];for(;0n!==t;){const o=n/t;[t,n]=[n%t,t],[i,s]=[s,i-o*s],[e,r]=[r,e-o*r]}return[n,e,i]}(t%n,n);if(1n===e)return(r+n)%n;throw Error(`법 ${n}에 대한 ${t}의 역원이 없습니다.`)}(t,e));n>0n;){if(0n===t)return 0n;n%2n===1n&&(r=r*t%e),n/=2n,t=t**2n%e}return r}(t.value,e.value,i.value))}catch(t){if(t instanceof Error)throw new st(n,t.message);throw t}}Nt(n,r,2);try{return Et(function(t,n){if("bigint"==typeof t&&"bigint"==typeof n&&n>=0)return t**n;const e="bigint"==typeof(r=n)||"number"==typeof r?r:l(r.im,0)?r.re:r;var r;if(!(e instanceof i)&&e<0&&f(t,0))throw Error("0의 역수를 구하려고 했습니다.");return t instanceof i||n instanceof i||t<0&&!c(n)?s(t).pow(s(n)):1===Number(t)?1:Math.pow(Number(t),Number(n))}(r[0].value,r[1].value))}catch(t){if(t instanceof Error)throw new ut(n,t.message);throw t}},ㄴㄴ:function(t,n,e){Nt(n,e,2);const r=bt(n,e.map(n=>t.strict(n)),q);try{return Et(function(t,n){if(0===Number(n))throw Error("0으로 나눌 수 없습니다.");return"bigint"==typeof t&&"bigint"==typeof n?t/n:Math.trunc(Number(t)/Number(n))}(r[0].value,r[1].value))}catch(t){if(t instanceof Error)throw new ut(n,"0의 역수를 구하려고 했습니다.");throw t}},ㄴㅁ:function(t,n,e){Nt(n,e,2);const r=bt(n,e.map(n=>t.strict(n)),q);try{return Et(function(t,n){if(0===Number(n))throw Error("0으로 나눌 수 없습니다.");return"bigint"==typeof t&&"bigint"==typeof n?t%n:Number(t)%Number(n)}(r[0].value,r[1].value))}catch(t){if(t instanceof Error)throw new ut(n,"0의 역수를 구하려고 했습니다.");throw t}}};function Ft(t,n){const e=xt(t,n,2,[new $(10n)]),[r]=bt(t,[e[0]],[O]),[i]=bt(t,[e[1]],[$]);return[r.str,Number(i.value)]}var At={ㅅㅈ:function(t,n,e){const r=e.length;if(r%2==1)throw new ct(n,`ㅅㅈ 함수에는 인수를 짝수 개로 주어야 하는데 ${r}개를 주었습니다.`);const i=e.filter((t,n)=>n%2==0),s=e.filter((t,n)=>n%2==1),o=i.map(n=>t.strict(n).asKey(t)),a={};for(let t=0;t<r/2;t++)a[o[t]]=s[t];return new U(a)},ㅁㄹ:function(t,n,e){return new j(e)},ㅁㅈ:function(t,n,e){if(Nt(n,e,[0,1]),0===e.length)return new O("");const[r]=bt(n,[t.strict(e[0])],[O,...V]);return r instanceof O?r:new O(r.format(t))},ㅈㅅ:function(t,n,e){Nt(n,e,[1,2]);const r=bt(n,e.map(n=>t.strict(n)),[O,...q]),i=[r[0]];if(gt(i,q)){if(Nt(n,r,1),i[0]instanceof $)return i[0];const t=Math.trunc(i[0].value);return new $(BigInt(t))}const[s,a]=Ft(n,r);try{return new $(o(s,a))}catch(t){if(t instanceof Error)throw new ct(n,t.message);throw t}},ㅅㅅ:function(t,n,e){Nt(n,e,[1,2]);const r=bt(n,e.map(n=>t.strict(n)),[O,...q]),i=[r[0]];if(gt(i,q))return Nt(n,r,1),new F(Number(i[0].value));const[s,a]=Ft(n,r);if(10===a){const t=Number(s);if(isNaN(t))throw new ct(n,`다음 문자열을 실수값으로 변환할 수 없습니다: '${s}'`);return new F(t)}const c=s.trim().split(".");let u=c.join("");"+"===u[0]&&(u=u.slice(1));try{const t=Number(o(u,a));return new F(t/a**(c.length>1?c[1].length:0))}catch(t){throw new ct(n,`다음 문자열을 실수값으로 변환할 수 없습니다: '${s}'`)}},ㅂㅅ:function(t,n,e){Nt(n,e,[1,2]);const r=bt(n,e.map(n=>t.strict(n)),[O,...V]);if(1===e.length){const t=r[0]instanceof O?r[0].str:r[0].value;try{return new A(s(t))}catch(e){if(e instanceof Error)throw new ct(n,`다음 문자열을 복소수값으로 변환할 수 없습니다: ${t}`);throw e}}const o=bt(n,r,V).map(t=>s(t.value));return new A(i({re:o[0].re-o[1].im,im:o[0].im+o[1].re}))},ㅂㄱ:function(t,n,e){return Nt(n,e,0),new P},ㄷㅂ:function(t,n,e){const r=e.map(n=>t.strict(n)),i=`사용자 예외: ${r.map(n=>n.format(t))}`;return new K([n],i,r)}},Bt={ㄷㅈ:function(t,n,e){Nt(n,e,1);const[r]=bt(n,e.map(n=>t.strict(n)),[K]);throw new I(r)},ㅅㄷ:function(t,n,e){Nt(n,e,2);try{return pt(e[0],n=>t.strict(n))}catch(r){if(r instanceof I)return t.procFunctional(n,e[1])(t,n,[r.err]);throw r}}};class jt extends k{constructor(t){super("연결된 "),this.funs=void 0,this.funs=t}execute(t,n,e){return this.funs.reduce((e,r)=>[r(t,n,e)],e)[0]}}class Ot extends k{constructor(t,n){super("모아 받는 "),this.context=void 0,this.fn=void 0,this.context=t,this.fn=n}execute(t,n,e){Nt(n,e,1);const r=this.context.strict(e[0]),[i]=bt(n,[r],[j,K]);return this.fn(t,n,i.value)}}class _t extends k{constructor(t){super("펼쳐 받는 "),this.fn=void 0,this.fn=t}execute(t,n,e){return this.fn(t,n,[new j(e)])}}function Ut(t,n){return e=>t.procFunctional(n,e,!0)}var Ct={ㄴㄱ:function(t,n,e){return new jt(e.map(Ut(t,n)))},ㅁㅂ:function(t,n,e){return Nt(n,e,1),new Ot(t,Ut(t,n)(e[0]))},ㅂㅂ:function(t,n,e){return Nt(n,e,1),new _t(Ut(t,n)(e[0]))}};const Pt={ㄹ:"r",ㅈㄹ:"w",ㅈㄱ:"a",ㄹㅈㄹ:"r+",ㅈㄹㄹ:"w+",ㅈㄱㄹ:"a+"};class St extends k{constructor(t){super("파일 접근 "),this.file=void 0,this.file=t}execute(t,n,e){Mt(n,e,1);const[r]=bt(n,e.slice(-1).map(n=>t.strict(n)),[$]),i=tt(r.value);if("ㄷ"===i)return this.close(t,n,e);if("ㄹ"===i)return this.read(t,n,e);if("ㅈㄹ"===i)return this.write(t,n,e);if("ㅈ"===i)return this.seekOrTell(t,n,e);if("ㄱ"===i)return this.truncate(t,n,e);throw new ct(n,`${i}은 파일 객체가 인식하지 못하는 명령입니다.`)}close(t,n,e){var r=this;return Nt(n,e,1),new C("FileV::close",[this],async function(t,e){try{return r.file.close(),new P}catch(t){throw new it(n,`파일 닫기에 실패하였습니다: ${t}`)}})}read(t,n,e){var r=this;Nt(n,e,2);const[i]=bt(n,[t.strict(e[0])],[$]);return new C("FileV::read",[this,i],async function(t,e){try{const t=await r.file.read(Number(i.value));return new _(t)}catch(t){throw new it(n,`파일 읽기에 실패하였습니다: ${t}`)}})}write(t,n,e){var r=this;Nt(n,e,2);const[i]=bt(n,[t.strict(e[0])],[_]);return new C("FileV::write",[this,i],async function(t,e){try{const t=r.file.write(i.value);return new $(BigInt(t))}catch(t){throw new it(n,`파일 쓰기에 실패하였습니다: ${t}`)}})}seekOrTell(t,n,e){var r=this;It(n,e,3);const i=e.map(n=>t.strict(n));if(1===e.length)return new C("FileV::seekOrTell",[this],async function(t,e){try{return new $(BigInt(r.file.tell()))}catch(t){throw new it(n,`파일의 어디를 읽고 있는지 알아내는 데 실패하였습니다: ${t}`)}});let s,o="SEEK_SET";if(2===e.length)[s]=bt(n,[i[0]],[$]);else{[s]=bt(n,[i[1]],[$]);let[t]=bt(n,[i[0]],[$]);switch(tt(t.value)){case"ㅅㅈㅂㄷ":o="SEEK_SET";break;case"ㅈㄱㅂㄷ":o="SEEK_CUR";break;default:throw new ct(n,`파일 객체의 ㅈ 명령에 주는 위치 인수로 ${t.value}은 적절하지 않습니다.`)}}return new C("FileV::seekOrTell",[this,...i.slice(0,-1)],async function(t,e){try{const t=r.file.seek(Number(s.value),o);return new $(BigInt(t))}catch(t){throw new it(n,`파일의 읽는 위치를 수정하는 데 실패하였습니다: ${t}`)}})}truncate(t,n,e){var r=this;It(n,e,2);const i=bt(n,e.map(n=>t.strict(n)),[$]),s=i.length>1?Number(i[0].value):void 0;return new C("FileV::truncate",[this,...i.slice(0,-1)],async function(t,e){try{const t=r.file.truncate(s);return new $(BigInt(t))}catch(t){throw new it(n,`파일 크기를 재조정하는 데 실패하였습니다: ${t}`)}})}}var kt={ㄹ:function(t,n,e){return Nt(n,e,0),new C("ㄹ",e,async function(t,n){const e=await n.input();return null==e?new P:new O(e)})},ㅈㄹ:function(t,n,e){Nt(n,e,1);const r=bt(n,e.map(n=>t.strict(n)),[O]);return new C("ㅈㄹ",r,async function(t,n){return n.print(r[0].str),new P})},ㄱㅅ:function(t,n,e){Nt(n,e,1);const r=pt(e[0],n=>t.strict(n));return new C("ㄱㅅ",[r],async function(t,n){return r})},ㄱㄹ:function(t,n,e){Nt(n,e,[2,3]);const[r]=bt(n,[t.strict(e[0])],[C]);return new C("ㄱㄹ",e,async function(i,s){let o;try{o=await i(r)}catch(r){if(r instanceof I){if(e.length<3)throw r;const i=t.procFunctional(n,e[2])(t,n,[r.err]),[s]=bt(n,[t.strict(i)],[C]);return s}throw r}const a=t.procFunctional(n,e[1])(t,n,[o]),[c]=bt(n,[t.strict(a)],[C]);return c})},ㄱㄴ:function(t,n,e){Nt(n,e,2);const[r]=bt(n,[t.strict(e[0])],[$,O]),i=r instanceof $?Number(r.value):r.str,[s]=bt(n,[t.strict(e[1])],[$]),o=tt(s.value);if(!(o in Pt))throw new ct(n,`${o}은 기본 제공 함수 ㄱㄴ이 이해하는 파일 열기 방식이 아닙니다.`);const a=Pt[o];return new C("ㄱㄴ",[r,s],async function(e,r){try{return new St(t.loadUtils.open(i,a))}catch(t){throw new it(n,`파일 열기에 실패하였습니다: ${t}`)}})}};function Lt(t,n){if(0===n.length)return!0;if(!dt(n.map(t=>t.length)))return!1;for(var e=n[0].length,r=0;r<e;r++)if(!Tt(t,n.map(t=>t[r])).value)return!1;return!0}function Tt(t,n){const e=n.map(n=>t.strict(n));return gt(e,[k])?new B(dt(e)):gt(e,[U])?new B(function(t,n){if(0===n.length)return!0;const e=n.map(t=>t.keys());return!!Lt(t,e.map(t=>t.map(t=>new O(t))))&&e[0].map(t=>n.map(n=>n.value[t])).map(n=>Tt(t,n)).every(wt)}(t,e)):gt(e,[C])?dt(e.map(t=>t.inst))?new B(Lt(t,e.map(t=>t.argv))):new B(!1):gt(e,V)?new B(0===(r=e.map(t=>t.value)).length||r.slice(1).every(t=>f(t,r[0]))):gt(e,[j,K])?new B(Lt(t,e.map(wt))):gt(e,[_])?new B(function(t){if(0===t.length)return!0;if(!dt(t.map(t=>t.byteLength)))return!1;const n=t[0].byteLength,e=t.map(t=>new Uint8Array(t));for(let t=0;t<n;t++)if(!dt(e.map(n=>n[t])))return!1;return!0}(e.map(wt))):gt(e,[O])?new B(dt(e.map(t=>t.str))):gt(e,[B])?new B(dt(e.map(wt))):gt(e,[P])?new B(!0):new B(!1);var r}var Kt={ㄴ:function(t,n,e){return Tt(t,e)},ㅁ:function(t,n,e){Nt(n,e,1);const r=bt(n,e.map(n=>t.strict(n)),[B]);return new B(!r[0].value)},ㅈ:function(t,n,e){Nt(n,e,2);const r=bt(n,e.map(n=>t.strict(n)),q);return new B(r[0].value<r[1].value)},ㅈㅈ:function(t,n,e){return Nt(n,e,0),new B(!0)},ㄱㅈ:function(t,n,e){return Nt(n,e,0),new B(!1)}};function Zt(t,n){return function(e,r,i){Nt(r,i,n);const s=bt(r,i.map(t=>e.strict(t)),[$]);return new $(t(...s.map(wt)))}}var qt={ㅂㄷ:{ㄱ:Zt((t,n)=>t&n,2),ㄷ:Zt((t,n)=>t|n,2),ㅁ:Zt(t=>~t,1),ㅂ:Zt((t,n)=>t^n,2),ㅈ:Zt((t,n)=>t<<n,2)}};const Vt=["utf","unsigned","signed","float"];class Dt extends k{constructor(t,n,e,r){super(),this.scheme=void 0,this.numBytes=void 0,this.bigEndian=void 0,this.endianness=void 0,this.codec=void 0;const[i,s]=bt(t,[n,e],[$]);if(this.scheme=Vt[Number(i.value)],this.numBytes=Number(s.value),this.endianness="",r){const[n]=bt(t,[r],[B]);this.bigEndian=n.value,this.endianness=this.bigEndian?"big":"little"}this.codec=this.getCodec(),this.str="<Codec(scheme="+this.scheme+", num_bytes="+this.numBytes+", big_endian="+this.bigEndian+")>"}execute(t,n,e){const r=e.map(n=>t.strict(n));try{return this.codec(t,n,r)}catch(t){if(t instanceof I)throw t;throw new ct(n,`요청된 변환을 수행하지 못했습니다. 변환기: ${this.str}, 인수: ${r}`)}}getCodec(){switch(this.scheme){case"utf":return this.unicodeCodec;case"signed":case"unsigned":return this.integerCodec;case"float":return this.floatingPointCodec}}unicodeCodec(t,n,e){Nt(n,e,1);const[r]=bt(n,e.map(n=>t.strict(n)),[O,_]);if(r instanceof O){if(1===this.numBytes){const t=new TextEncoder;return new _(t.encode(r.str).buffer)}let t;if(2===this.numBytes)t=r.str.split("").map(t=>t.charCodeAt(0));else{if(4!==this.numBytes)throw new ct(n,`UTF-${8*this.numBytes} 형식은 존재하지 않습니다.`);t=r.value.map(t=>t.codePointAt(0)).filter(t=>null!=t)}""===this.endianness&&t.unshift(65279);const e=new ArrayBuffer(t.length*this.numBytes);return function(t,n,e,r){const i={1:t.setUint8.bind(t),2:t.setUint16.bind(t),4:t.setUint32.bind(t)}[e];if(null==i)throw Error();for(let t=0;t<n.length;t++)i(t*e,n[t],!r)}(new DataView(e),t,this.numBytes,this.bigEndian),new _(e)}{var i;const t=r.value;if(1===this.numBytes){const n=new TextDecoder;return new O(n.decode(new Uint8Array(t)))}let n=new DataView(t),e=null!=(i=this.bigEndian)?i:function(){const t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!1),256===new Int16Array(t)[0]}();if(""===this.endianness){const r=(this.numBytes>2?n.getUint32:n.getUint16).bind(n),i=65279===r(0);(i||65279===r(0,!0))&&(e=i,n=new DataView(t,this.numBytes))}const s=function(t,n,e){const r={1:t.getUint8.bind(t),2:t.getUint16.bind(t),4:t.getUint32.bind(t)}[n];if(null==r)throw Error();var i=[];for(let s=0;s<t.byteLength;s+=n)i.push(r(s,!e));return i}(n,this.numBytes,e);return new O(String.fromCodePoint(...s))}}integerCodec(t,n,e){Nt(n,e,1);const r="signed"===this.scheme,[i]=bt(n,e.map(n=>t.strict(n)),[$,_]);if(i instanceof $){let t=i.value;const n=t<0;if(n&&!r)throw Error("음수는 부호 없는 정수 형식으로 변환할 수 없습니다.");if(!function(t,n,e){const r=2n<<8n*n;return e?-r/2n<=t&&t<r/2n:0n<=t&&t<r}(t,BigInt(this.numBytes),r))throw Error(`${this.numBytes}바이트로 표현할 수 없는 정수를 받았습니다.`);n&&(t=~t);const e=function(t,n=10n){if(t<0n)throw Error("Cannot convert a negative integer into array form.");const e=BigInt(n),r=[];for(;t>0n;)r.push(t%e),t/=e;return r.reverse()}(t,256n).map(Number),s=new ArrayBuffer(this.numBytes),o=new Uint8Array(s);return o.set(e,this.numBytes-e.length),n&&o.forEach((t,n)=>o[n]=~t),this.bigEndian||o.reverse(),new _(s)}{const t=i.value.slice(0),n=new Uint8Array(t);this.bigEndian||n.reverse();const e=r&&128&n[0];e&&n.forEach((t,e)=>n[e]=~t);let s=o(Array.from(n),256);return e&&(s=~s),new $(s)}}floatingPointCodec(t,n,e){throw EvalError("Not yet implemented")}}var Yt={ㅂ:function(t,n,e){Nt(n,e,[2,3]);const r=e.map(n=>t.strict(n));return new Dt(n,r[0],r[1],r.length>2?r[2]:void 0)}};function Rt(t){return n=>new t(n)}function zt(t,n,e,r){return function(i,s,o){Nt(s,o,n);const a=bt(s,o.map(t=>i.strict(t)),r).map(t=>t.value);return e(t(...a))}}function Wt(t){return function(n,e,r){Nt(e,r,1);const i=bt(e,[n.strict(r[0])],V);if(gt(i,q)){const n=Math[t](Number(i[0].value));if(!isNaN(n))return new F(n)}return new A(s(i[0].value)[t]())}}function Ht(t){return function(n,e,r){Nt(e,r,1);const[i]=bt(e,[n.strict(r[0])],q);if(i instanceof $)return i;const s=BigInt(t(i.value));return new $(s)}}const Gt=Wt("atan"),Jt=zt((t,n)=>Math.atan2(Number(t),Number(n)),2,Rt(F),q),Qt=[qt,Yt,{ㅅ:{ㅂ:Math.PI,ㅈ:Math.E,ㅁ:Infinity,ㄴ:NaN,ㄱ:zt((t,n)=>l(t,n),2,Rt(B),V),ㄴㄴ:zt(function(t){return"bigint"!=typeof t&&(t instanceof i?t.isNaN():isNaN(t))},1,Rt(B),V),ㅁㄴ:zt(a,1,Rt(B),V),ㅈㄷ:zt(m,1,Et,V),ㄹㄱ:Wt("log"),ㅅㄴ:Wt("sin"),ㄴㅅ:Wt("asin"),ㄱㅅ:Wt("cos"),ㅅㄱ:Wt("acos"),ㄷㄴ:Wt("tan"),ㄴㄷ:function(t,n,e){return 2===e.length?Jt(t,n,e):Gt(t,n,e)},ㅂㄹ:{ㄱ:Ht(Math.trunc),ㄴ:Ht(Math.floor),ㄷ:Ht(function(t){let n=Math.round(t);return t%1!=.5&&t%1!=-.5||n%2!=1&&n%2!=-1||n--,n}),ㄹ:Ht(Math.ceil),ㅁ:Ht(function(t){return t>0?Math.ceil(t):Math.floor(t)})}}}];var Xt={},tn=new U({});function nn(t,n){n=t.loadUtils.normalizePath(n);var e=Xt[n];if(e)return e;const r=et(n,t.loadUtils.load(n));if(1!==r.length)throw new ct(r[0].metadata,`모듈에는 표현식이 하나만 있어야 하는데 ${r.length}개가 있습니다.`);const i=new M([],[]);return e=new Z(r[0],i,null),Xt[n]=e,e}function en(t,n,e){const r=`정수 리터럴열 ${e.map(tt).join(" ")}에 맞는 모듈을 찾지 못했습니다.`;if(5n===e[0]){var i=tn;for(const t of e.slice(1)){if(!(i instanceof U))throw new ht(n,r);i=i.value[t.toString()]}return i}const s=rn(t,n,e,".");if(!s)throw new ht(n,r);return nn(t,s)}function rn(t,n,e,r){if(0===e.length)return t.loadUtils.isFile(r)?r:null;const i=e[0],s=e.slice(1),o=t.loadUtils.listdir(r).map(e=>{if(!function(t,n){t=Q(t).join(" ").trim();try{return X(t)===n}catch(t){return!1}}(e,i))return null;const o=t.loadUtils.joinPath(r,e);return rn(t,n,s,o)}).filter(t=>t);if(o.length>1)throw new ft(n,`${r}에 정수 리터럴열 ${e}에 맞는 모듈이 ${o.length}개 있어 모호합니다.`);return o.length?o[0]:null}function sn(t,n){return"function"==typeof t?new T(t,n.join(" ")):"number"==typeof t?new F(t):on(t,n)}function on(t,n){let e={};for(const r in t)e[X(r).toString()]=sn(t[r],n.concat([r]));return new U(e)}function*an(t,n,e,r){const i=n<0?n+t.length:n,s=e<0?e+t.length:e;if(r>0){const n=Math.max(0,i),e=Math.min(s,t.length);for(let i=n;i<e;i+=r)yield t[i]}else{const n=Math.min(i,t.length-1),e=Math.max(-1,s);for(let i=n;i>e;i+=r)yield t[i]}}Qt.forEach(function(t){const n=on(t,["ㅂ"]);Object.assign(tn.value,n.value)});const cn=R({},$t,At,Bt,Ct,kt,Kt,{ㅂ:function(t,n,e){if(Mt(n,e,1),e.every(mt))return en(t,n,e.map(t=>t.expr.value));Nt(n,e,1);const[r]=bt(n,[t.strict(e[0])],[O]);return nn(t,r.str)}},{ㅈㄷ:function(t,n,e){Nt(n,e,1);const[r]=bt(n,e.map(n=>t.strict(n)),[...D,K]);return new $(r instanceof _?BigInt(r.value.byteLength):BigInt(r.value.length))},ㅂㅈ:function(t,n,e){Nt(n,e,[2,3,4]);const r=e.map(n=>t.strict(n)),[i]=bt(n,[r[0]],D),s=bt(n,r.slice(1),[$]).map(t=>Number(t.value)),[o,a,c]=xt(n,s,3,[(u=i.value,"length"in u?u.length:u.byteLength),1]);var u;if(0===c)throw new ct(n,"0은 ㅂㅈ 함수의 네 번째 인수로 적합하지 않습니다.");if(i instanceof j){const t=an(i.value,o,a,c);return new j(Array.from(t))}if(i instanceof O){const t=an(i.value,o,a,c);return new O(Array.from(t).join(""))}const h=an(Array.from(new Uint8Array(i.value)),o,a,c);return new _(new Uint8Array(h).buffer)},ㅁㄷ:function(t,n,e){Nt(n,e,2);const[r]=bt(n,[t.strict(e[0])],[j]),i=t.procFunctional(n,e[1]);return new j(r.value.map(e=>i(t,n,[e])))},ㅅㅂ:function(t,n,e){Nt(n,e,2);const[r]=bt(n,[t.strict(e[0])],[j]),i=t.procFunctional(n,e[1]),s=r.value.map(e=>t.strict(i(t,n,[e]))),o=bt(n,s,[B]).map(wt);return new j(r.value.filter((t,n)=>o[n]))},ㅅㄹ:function(t,n,e){Nt(n,e,[2,3]);let r=null;3===e.length&&(r=e[1],e=[e[0],e[2]]);const i=t.strict(e[0])instanceof j;function s(t){return i?t.slice().reverse():t}e=s(e);const o=t.procFunctional(n,e[0]),[a]=bt(n,[t.strict(e[1])],[j]);let c=s(a.value);return null==r&&(r=c[0],c=c.slice(1)),c.reduce(function(e,r){const i=s([e,r]);return o(t,n,i)},r)}},{ㅂㄹ:function(t,n,e){Nt(n,e,[1,2]);const r=bt(n,e.map(n=>t.strict(n)),[O,_]);if(r[0]instanceof O){const t=bt(n,r,[O]),e=t[0].str.split(t.length>1?t[1].str:"");return new j(e.map(t=>new O(t)))}const i=bt(n,r,[_]),s=String.fromCharCode(...new Uint8Array(i[0].value)),o=i.length>1?String.fromCharCode(...new Uint8Array(i[1].value)):"",a=s.split(o).map(t=>new _(new Uint8Array(t.split("").map(t=>t.charCodeAt(0))).buffer));return new j(a)},ㄱㅁ:function(t,n,e){Nt(n,e,[1,2]);const[r]=bt(n,[t.strict(e[0])],[j]),i=bt(n,r.value.map(n=>t.strict(n)),[O,_]);if(i[0]instanceof O){const r=bt(n,i,[O]),s=e.length>1?t.strict(e[1]):new O(""),[o]=bt(n,[s],[O]);return new O(r.map(t=>t.str).join(o.str))}const s=bt(n,i,[_]),o=e.length>1?t.strict(e[1]):new _(new ArrayBuffer(0)),[a]=bt(n,[o],[_]);if(0===s.length)return new _(new ArrayBuffer(0));const c=[s[0].value];for(const t of s.slice(1))c.push(a.value),c.push(t.value);return new _(vt(c))}});class un{constructor(t){this.loadUtils=void 0,this.loadUtils=t}strict(t){if(t instanceof Z){if(t.cache){if(t.cache instanceof I)throw t.cache;return t.cache}try{return t.cache=this.strict(fn(this,t.expr,t.env)),t.cache}catch(n){throw n instanceof I&&(t.cache=n),n}}return t}procFunctional(t,n,e){if(mt(n))return function(t,n){const e=tt(n),r=cn[e];if(r)return r;throw new ht(t,`${e}이라는 이름의 기본 제공 함수를 찾지 못했습니다.`)}(t,Number(n.expr.value));const r=e?Y:[k],[i]=bt(t,[this.strict(n)],r);return i instanceof k?i.execute.bind(i):i instanceof B?function(t,n,e){return Nt(n,e,2),e[i.value?0:1]}:i instanceof U?function(t,n,e){Nt(n,e,1);const r=t.strict(e[0]).asKey(t),s=i.value[r];if(s)return s;throw new ht(n,`사전에 다음 표제가 없습니다: ${r}`)}:i instanceof A?function(t,n,e){Nt(n,e,1);const r=t.strict(e[0]),[s]=bt(n,[r],[$]);if(0n===s.value||1n===s.value)return new F(i.value.toVector()[Number(s.value)]);throw new ct(n,`복소수 객체의 ${s.value}번째 요소를 접근하려고 했습니다.`)}:function(t,n,e){Nt(n,e,1);const r=t.strict(e[0]),[s]=bt(n,[r],[$]),o=Number(s.value);try{return i instanceof _?new _(function(t,n){const e=n<0?n+t.byteLength:n;if(e<0||e>=t.byteLength)throw Error(`길이 ${t.byteLength}의 바이트열의 ${n}번째 요소를 요청했습니다.`);return t.slice(e,e+1)}(i.value,o)):i instanceof O?new O(hn(i.value,o)):hn(i.value,o)}catch(t){if(t instanceof Error)throw new lt(n,t.message);throw t}}}}function hn(t,n){const e=n<0?n+t.length:n;if(e<0||e>=t.length)throw Error(`길이 ${t.length}의 객체의 ${n}번째 요소를 요청했습니다.`);return t[e]}function fn(t,n,e){if(n instanceof d)return new $(n.value);if(n instanceof g){const t=hn(e.funs,-n.rel-1);if(null==t)throw new lt(n.metadata,"함수 참조의 범위를 벗어났습니다.");return t}if(n instanceof y){if(e.funs.length!==e.args.length)throw Error("Assertion Error: Environment has "+e.funs.length+" funs and "+e.args.length+" args.");const r=hn(e.args,-n.relF-1);if(null==r)throw new lt(n.metadata,"존재하지 않는 함수에 대한 인수 참조를 시도했습니다.");const i=t.strict(fn(t,n.relA,e)),[s]=bt(n.metadata,[i],[$]),o=s.value;if(o<0||o>r.length)throw new lt(n.metadata,`${o}번째 인수를 참조하는데 ${r.length}개의 인수만 받았습니다.`);return r[Number(o)]}if(n instanceof b){var r=e.funs.slice(),i=new M(r,e.args),s=new L(n.body,i);return i.funs.push(s),s}if(n instanceof N){var o=new Z(n.fun,e,null),a=n.argv.map(function(t){return new Z(t,e,null)});return t.procFunctional(n.metadata,o,!0)(t,n.metadata,a)}throw Error("Unexpected expression: "+n)}async function ln(t,n){const e=t=>ln(t,n);for(;t instanceof C;)t=await t.continuation(e,n);return t}async function mn(t,n,e,r){const i=t=>mn(t,n,e,r);if((t=n.strict(t))instanceof C){t=await ln(t,e);const n=await i(t);return r?"IO("+n+")":n}if(t instanceof j)return"["+(await Promise.all(t.value.map(i))).join(", ")+"]";if(t instanceof U){const n=t.value,e=t.keys();return"{"+(await Promise.all(e.map(async t=>t+": "+await i(n[t])))).join(", ")+"}"}return t instanceof K?"<예외: ["+(await Promise.all(t.value.map(i))).join(", ")+"]>":t.format(n)}async function wn(t,n,e,r,i=!0){const s=et(t,n),o=new un(r),a=new M([],[]),c=s.map(t=>fn(o,t,a));return Promise.all(c.map(t=>mn(t,o,e,i)))}async function vn(t,n,e,r,i){const s=new p("<main>",0,0,0,""),o=e.map(t=>new O(t)),a=et(t,n);if(0===a.length)return 0;if(a.length>1){const t=new K(a.map(t=>t.metadata),`모듈에는 표현식이 하나만 있어야 하는데 ${a.length}개가 있습니다.`,[]);throw new I(t)}const c=new un(i),u=new M([],[]);let h=c.strict(fn(c,a[0],u));if(h instanceof k){const t=c.procFunctional(s,h);h=c.strict(t(c,s,o))}h instanceof C&&(h=await ln(h,r));const[f]=bt(s,[h],[$,P]);return f instanceof P?0:Number(f.value)}export{wn as main,vn as run}; //# sourceMappingURL=main.js.map