diff --git a/dist/the-field-2.0.0.js b/dist/the-field-2.0.1.js similarity index 99% rename from dist/the-field-2.0.0.js rename to dist/the-field-2.0.1.js index bf38d0f..19591ec 100644 --- a/dist/the-field-2.0.0.js +++ b/dist/the-field-2.0.1.js @@ -2099,4 +2099,4 @@ exports.cutWedges = cutWedges; /******/ return __webpack_require__("./src/index.ts"); /******/ })() ; -//# sourceMappingURL=the-field-2.0.0.js.map \ No newline at end of file +//# sourceMappingURL=the-field-2.0.1.js.map \ No newline at end of file diff --git a/dist/the-field-2.0.0.js.map b/dist/the-field-2.0.1.js.map similarity index 99% rename from dist/the-field-2.0.0.js.map rename to dist/the-field-2.0.1.js.map index 72eb444..9923e48 100644 --- a/dist/the-field-2.0.0.js.map +++ b/dist/the-field-2.0.1.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://TheField/./node_modules/tiled-geometry/lib/compass/axis.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-direction-flags.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-direction.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-orientation.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-turn.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/direction.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/flip.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/index.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/turn.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/cardinal-path.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/index.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/mask-rectangle.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/mask.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/offset.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/raster-mask.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/rectangle.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/size.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/transform-rectangle.js","webpack://TheField/./node_modules/tiled-geometry/lib/index.js","webpack://TheField/./src/compute.ts","webpack://TheField/./src/constants.ts","webpack://TheField/./src/field-of-view-impl.ts","webpack://TheField/./src/field-of-view-map.ts","webpack://TheField/./src/index.ts","webpack://TheField/./src/wedge.ts","webpack://TheField/webpack/bootstrap","webpack://TheField/webpack/startup"],"names":[],"mappings":";;;;;;;;;;;AAAa;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,2BAA2B,GAAG,8BAA8B,GAAG,iCAAiC,GAAG,sBAAsB,GAAG,oBAAoB,GAAG,YAAY,GAAG,YAAY;AAC9K;AACA;AACA;AACA;AACA,CAAC,0BAA0B,YAAY,KAAK;AAC5C,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA,8BAA8B;AAC9B;AACA;AACA;AACA;AACA,2BAA2B;;;;;;;;;;;ACrCd;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,mDAAmD,GAAG,qDAAqD,GAAG,kDAAkD,GAAG,kDAAkD,GAAG,sCAAsC,GAAG,8BAA8B;AAC/R;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,8DAA8D,8BAA8B,KAAK;AAClG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA,kDAAkD;AAClD;AACA;AACA;AACA,kDAAkD;AAClD;AACA;AACA;AACA,qDAAqD;AACrD;AACA;AACA;AACA;AACA,mDAAmD;;;;;;;;;;;AC7CtC;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,wCAAwC,GAAG,gDAAgD,GAAG,sCAAsC,GAAG,sCAAsC,GAAG,iCAAiC,GAAG,iCAAiC,GAAG,2BAA2B,GAAG,yBAAyB;AAC/S;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,oDAAoD,yBAAyB,KAAK;AACnF,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA,gDAAgD;AAChD;AACA;AACA;AACA;AACA,wCAAwC;;;;;;;;;;;AC/C3B;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,0CAA0C,GAAG,uDAAuD,GAAG,kCAAkC,GAAG,+BAA+B,GAAG,mCAAmC,GAAG,6BAA6B,GAAG,2BAA2B;AAC/Q,eAAe,mBAAO,CAAC,iEAAQ;AAC/B,eAAe,mBAAO,CAAC,iEAAQ;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,wDAAwD,2BAA2B,KAAK;AACzF,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA,uDAAuD;AACvD;AACA;AACA;AACA;AACA,0CAA0C;;;;;;;;;;;ACtE7B;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,mCAAmC,GAAG,4BAA4B,GAAG,0CAA0C,GAAG,2BAA2B,GAAG,6BAA6B,GAAG,4BAA4B,GAAG,sBAAsB,GAAG,oBAAoB;AAC5P;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,0CAA0C,oBAAoB,KAAK;AACpE,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA,0CAA0C;AAC1C;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA;AACA,mCAAmC;;;;;;;;;;;AC/CtB;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,gCAAgC,GAAG,wBAAwB,GAAG,sCAAsC,GAAG,yBAAyB,GAAG,2BAA2B,GAAG,yBAAyB,GAAG,kBAAkB,GAAG,iBAAiB;AACnO;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,oCAAoC,iBAAiB,KAAK;AAC3D,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;AACA;AACA,gCAAgC;;;;;;;;;;;AC3DnB;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,mCAAmC,GAAG,uBAAuB,GAAG,oBAAoB,GAAG,oBAAoB,GAAG,aAAa,GAAG,YAAY;AAC1I;AACA;AACA;AACA;AACA,CAAC,0BAA0B,YAAY,KAAK;AAC5C,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA;AACA;AACA,mCAAmC;;;;;;;;;;;AChCtB;AACb;AACA;AACA,kCAAkC,oCAAoC,aAAa,EAAE,EAAE;AACvF,CAAC;AACD;AACA;AACA,C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A;AACA;AACA,kBAAkB,uBAAuB;AACzC,iBAAiB,uFAAuF;AACxG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe;AACf;AACA;AACA;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qDAAqD,QAAQ;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB;AACA,4BAA4B,YAAY;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,oBAAoB;;;;;;;;;;;AClIP;AACb;AACA;AACA,kCAAkC,oCAAoC,aAAa,EAAE,EAAE;AACvF,CAAC;AACD;AACA;AACA,CAAC;AACD;AACA;AACA;AACA,8CAA6C,CAAC,cAAc,EAAC;AAC7D,aAAa,mBAAO,CAAC,kEAAU;AAC/B,aAAa,mBAAO,CAAC,8DAAQ;AAC7B,aAAa,mBAAO,CAAC,wEAAa;AAClC,aAAa,mBAAO,CAAC,8DAAQ;AAC7B,aAAa,mBAAO,CAAC,kFAAkB;AACvC,aAAa,mBAAO,CAAC,4EAAe;AACpC,aAAa,mBAAO,CAAC,gFAAiB;AACtC,aAAa,mBAAO,CAAC,4FAAuB;;;;;;;;;;;ACnB/B;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,qBAAqB;AACrB,oBAAoB,mBAAO,CAAC,wEAAa;AACzC,eAAe,mBAAO,CAAC,8DAAQ;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,qBAAqB,GAAG,mBAAmB,IAAI,WAAW;AAC5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,QAAQ;AAC3B,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA,qBAAqB;;;;;;;;;;;ACrFR;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,YAAY;AACZ,eAAe,mBAAO,CAAC,8DAAQ;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,iBAAiB;AACxC,2BAA2B,gBAAgB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,OAAO;AAC3B;AACA,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,cAAc;AAClC;AACA,uBAAuB;AACvB;AACA;AACA;AACA;AACA,YAAY;;;;;;;;;;;ACjGC;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,cAAc;AACd,kBAAkB,mBAAO,CAAC,sEAAY;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,OAAO,GAAG,OAAO;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,cAAc;AAChD,sCAAsC,cAAc;AACpD;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;;;;;;;;;;;ACpGD;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,kBAAkB;AAClB,oBAAoB,mBAAO,CAAC,wEAAa;AACzC;AACA;AACA;AACA;AACA,sDAAsD,aAAa,cAAc,OAAO;AACxF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,uBAAuB,iBAAiB;AACxC;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,iBAAiB,GAAG,kBAAkB,KAAK,MAAM;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;;;;;;;;;;;ACzFL;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,iBAAiB;AACjB,eAAe,mBAAO,CAAC,8DAAQ;AAC/B,iBAAiB,mBAAO,CAAC,kEAAU;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,WAAW,GAAG,YAAY,GAAG,WAAW,GAAG,YAAY;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B,iCAAiC,aAAa;AAC9C,oCAAoC,YAAY;AAChD,uBAAuB;AACvB;AACA;AACA;AACA;AACA,oBAAoB,OAAO;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;;;;;;;;;;;ACxJJ;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,YAAY;AACZ,kBAAkB,mBAAO,CAAC,sEAAY;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,MAAM,GAAG,OAAO;AACzD;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,WAAW,GAAG,YAAY;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,MAAM,GAAG,OAAO;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,iBAAiB;AACxC,2BAA2B,gBAAgB;AAC3C,uBAAuB;AACvB;AACA;AACA;AACA;AACA,oBAAoB,OAAO;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;;;;;;;;;;;ACrFC;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,0BAA0B;AAC1B,oBAAoB,mBAAO,CAAC,wEAAa;AACzC,kBAAkB,mBAAO,CAAC,sEAAY;AACtC,iBAAiB,mBAAO,CAAC,kEAAU;AACnC,eAAe,mBAAO,CAAC,8DAAQ;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,WAAW;AAC9B,qBAAqB,mCAAmC,GAAG,6CAA6C,GAAG,gBAAgB;AAC3H,qBAAqB,iBAAiB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;;;;;;;;;;;ACzPb;AACb;AACA;AACA,kCAAkC,oCAAoC,aAAa,EAAE,EAAE;AACvF,CAAC;AACD;AACA;AACA,CAAC;AACD;AACA;AACA;AACA,8CAA6C,CAAC,cAAc,EAAC;AAC7D,aAAa,mBAAO,CAAC,qEAAW;AAChC,aAAa,mBAAO,CAAC,+DAAQ;;;;;;;;;;;ACbhB;AACb;AACA;AACA,kCAAkC,oCAAoC,aAAa,EAAE,EAAE;AACvF,CAAC;AACD;AACA;AACA,CAAC;AACD;AACA,yCAAyC,6BAA6B;AACtE,CAAC;AACD;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA6C,CAAC,cAAc,EAAC;AAC7D,0BAA0B;AAC1B,0BAA0B,mBAAO,CAAC,kEAAgB;AAClD,+BAA+B,mBAAO,CAAC,uCAAa;AACpD,6BAA6B,mBAAO,CAAC,yDAAsB;AAC3D,gBAAgB,mBAAO,CAAC,+BAAS;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA,WAAW,uBAAuB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4EAA4E,mCAAmC;AAC/G;AACA;AACA;AACA,uHAAuH,8CAA8C;AACrK;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;ACpGa;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,mBAAmB,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,kBAAkB;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB,kBAAkB;AAClB,mBAAmB;;;;;;;;;;;ACvBN;AACb;AACA;AACA,kCAAkC,oCAAoC,aAAa,EAAE,EAAE;AACvF,CAAC;AACD;AACA;AACA,CAAC;AACD;AACA,yCAAyC,6BAA6B;AACtE,CAAC;AACD;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA6C,CAAC,cAAc,EAAC;AAC7D,uBAAuB;AACvB,0BAA0B,mBAAO,CAAC,kEAAgB;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;;;;;;;;;;;AC1DV;AACb;AACA;AACA,kCAAkC,oCAAoC,aAAa,EAAE,EAAE;AACvF,CAAC;AACD;AACA;AACA,CAAC;AACD;AACA,yCAAyC,6BAA6B;AACtE,CAAC;AACD;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA6C,CAAC,cAAc,EAAC;AAC7D,sBAAsB;AACtB,0BAA0B,mBAAO,CAAC,kEAAgB;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;;;;;;;;;;;ACvET;AACb;AACA;AACA;AACA;AACA;AACA;AACA,8CAA6C,CAAC,cAAc,EAAC;AAC7D,0BAA0B,GAAG,sBAAsB;AACnD,0BAA0B,mBAAO,CAAC,uDAAqB;AACvD,kDAAiD,CAAC,qCAAqC,2CAA2C,EAAE,EAAE,EAAC;AACvI,gBAAgB,mBAAO,CAAC,mCAAW;AACnC,sDAAqD,CAAC,qCAAqC,qCAAqC,EAAE,EAAE,EAAC;;;;;;;;;;;ACZxH;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,iBAAiB,GAAG,gBAAgB,GAAG,kBAAkB;AACzD;AACA;AACA,cAAc,eAAe,GAAG,gBAAgB;AAChD;AACA;AACA;AACA,aAAa,EAAE,sCAAsC;AACrD;AACA;AACA;AACA,eAAe,qCAAqC;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,yCAAyC;AACtD;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,qBAAqB,GAAG,yBAAyB;AACzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,oBAAoB;AAC5C;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;;;;;;;UCnFjB;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;UCrBA;UACA;UACA;UACA","file":"the-field-2.0.0.js","sourcesContent":["\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.axisAddCardinalTurn = exports.axisFromNorthSouthTurn = exports.axisFromCardinalDirection = exports.axisOrthogonal = exports.axisToString = exports.AXES = exports.Axis = void 0;\r\nvar Axis;\r\n(function (Axis) {\r\n Axis[Axis[\"NORTH_SOUTH\"] = 0] = \"NORTH_SOUTH\";\r\n Axis[Axis[\"WEST_EAST\"] = 1] = \"WEST_EAST\";\r\n})(Axis = exports.Axis || (exports.Axis = {}));\r\nexports.AXES = [\r\n Axis.NORTH_SOUTH,\r\n Axis.WEST_EAST,\r\n];\r\nconst AXES_STR = [\r\n 'N-S',\r\n 'W-E',\r\n];\r\nfunction axisToString(axis) {\r\n return AXES_STR[axis];\r\n}\r\nexports.axisToString = axisToString;\r\nfunction axisOrthogonal(axis) {\r\n return (axis ^ 1);\r\n}\r\nexports.axisOrthogonal = axisOrthogonal;\r\n// conversion\r\nfunction axisFromCardinalDirection(dir) {\r\n return (dir & 1);\r\n}\r\nexports.axisFromCardinalDirection = axisFromCardinalDirection;\r\nfunction axisFromNorthSouthTurn(turn) {\r\n return (turn & 1);\r\n}\r\nexports.axisFromNorthSouthTurn = axisFromNorthSouthTurn;\r\n// math\r\nfunction axisAddCardinalTurn(axis, turn) {\r\n return ((axis + turn) & 1);\r\n}\r\nexports.axisAddCardinalTurn = axisAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalDirectionFlagsFromCardinalDirection = exports.cardinalDirectionFlagsRemoveCardinalDirection = exports.cardinalDirectionFlagsSetCardinalDirection = exports.cardinalDirectionFlagsHasCardinalDirection = exports.cardinalDirectionFlagsToString = exports.CardinalDirectionFlags = void 0;\r\nvar CardinalDirectionFlags;\r\n(function (CardinalDirectionFlags) {\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"NONE\"] = 0] = \"NONE\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"NORTH\"] = 1] = \"NORTH\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"EAST\"] = 2] = \"EAST\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"SOUTH\"] = 4] = \"SOUTH\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"WEST\"] = 8] = \"WEST\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"ALL\"] = 15] = \"ALL\";\r\n})(CardinalDirectionFlags = exports.CardinalDirectionFlags || (exports.CardinalDirectionFlags = {}));\r\nfunction cardinalDirectionFlagsToString(flags) {\r\n let ret = '[';\r\n if ((flags & CardinalDirectionFlags.NORTH) !== 0) {\r\n ret += 'N';\r\n }\r\n if ((flags & CardinalDirectionFlags.EAST) !== 0) {\r\n ret += 'E';\r\n }\r\n if ((flags & CardinalDirectionFlags.SOUTH) !== 0) {\r\n ret += 'S';\r\n }\r\n if ((flags & CardinalDirectionFlags.WEST) !== 0) {\r\n ret += 'W';\r\n }\r\n return ret + ']';\r\n}\r\nexports.cardinalDirectionFlagsToString = cardinalDirectionFlagsToString;\r\nfunction cardinalDirectionFlagsHasCardinalDirection(flags, dir) {\r\n return (flags & cardinalDirectionFlagsFromCardinalDirection(dir)) !== 0;\r\n}\r\nexports.cardinalDirectionFlagsHasCardinalDirection = cardinalDirectionFlagsHasCardinalDirection;\r\nfunction cardinalDirectionFlagsSetCardinalDirection(flags, dir) {\r\n return (flags | cardinalDirectionFlagsFromCardinalDirection(dir));\r\n}\r\nexports.cardinalDirectionFlagsSetCardinalDirection = cardinalDirectionFlagsSetCardinalDirection;\r\nfunction cardinalDirectionFlagsRemoveCardinalDirection(flags, dir) {\r\n return (flags & ~cardinalDirectionFlagsFromCardinalDirection(dir));\r\n}\r\nexports.cardinalDirectionFlagsRemoveCardinalDirection = cardinalDirectionFlagsRemoveCardinalDirection;\r\n// conversion\r\nfunction cardinalDirectionFlagsFromCardinalDirection(dir) {\r\n return (1 << dir);\r\n}\r\nexports.cardinalDirectionFlagsFromCardinalDirection = cardinalDirectionFlagsFromCardinalDirection;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalDirectionAddCardinalTurn = exports.cardinalDirectionFromCardinalOrientation = exports.cardinalDirectionFromNorthTurn = exports.cardinalDirectionFromDirection = exports.cardinalDirectionOpposite = exports.cardinalDirectionToString = exports.CARDINAL_DIRECTIONS = exports.CardinalDirection = void 0;\r\nvar CardinalDirection;\r\n(function (CardinalDirection) {\r\n CardinalDirection[CardinalDirection[\"NORTH\"] = 0] = \"NORTH\";\r\n CardinalDirection[CardinalDirection[\"EAST\"] = 1] = \"EAST\";\r\n CardinalDirection[CardinalDirection[\"SOUTH\"] = 2] = \"SOUTH\";\r\n CardinalDirection[CardinalDirection[\"WEST\"] = 3] = \"WEST\";\r\n})(CardinalDirection = exports.CardinalDirection || (exports.CardinalDirection = {}));\r\nexports.CARDINAL_DIRECTIONS = [\r\n CardinalDirection.NORTH,\r\n CardinalDirection.EAST,\r\n CardinalDirection.SOUTH,\r\n CardinalDirection.WEST,\r\n];\r\nconst CARDINAL_DIRECTIONS_STR = [\r\n 'N',\r\n 'E',\r\n 'S',\r\n 'W',\r\n];\r\nfunction cardinalDirectionToString(dir) {\r\n return CARDINAL_DIRECTIONS_STR[dir];\r\n}\r\nexports.cardinalDirectionToString = cardinalDirectionToString;\r\nfunction cardinalDirectionOpposite(dir) {\r\n return ((dir + 2) & 3);\r\n}\r\nexports.cardinalDirectionOpposite = cardinalDirectionOpposite;\r\n// conversion\r\nfunction cardinalDirectionFromDirection(dir) {\r\n return (dir >> 1);\r\n}\r\nexports.cardinalDirectionFromDirection = cardinalDirectionFromDirection;\r\nfunction cardinalDirectionFromNorthTurn(turn) {\r\n return turn;\r\n}\r\nexports.cardinalDirectionFromNorthTurn = cardinalDirectionFromNorthTurn;\r\nfunction cardinalDirectionFromCardinalOrientation(orientation) {\r\n return (orientation >>> 1);\r\n}\r\nexports.cardinalDirectionFromCardinalOrientation = cardinalDirectionFromCardinalOrientation;\r\n// math\r\nfunction cardinalDirectionAddCardinalTurn(dir, turn) {\r\n return ((dir + turn) & 3);\r\n}\r\nexports.cardinalDirectionAddCardinalTurn = cardinalDirectionAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalOrientationAddCardinalTurn = exports.cardinalOrientationFromFlipAndCardinalDirection = exports.cardinalOrientationReverse = exports.cardinalOrientationFlip = exports.cardinalOrientationToString = exports.CARDINAL_ORIENTATIONS = exports.CardinalOrientation = void 0;\r\nconst axis_1 = require(\"./axis\");\r\nconst flip_1 = require(\"./flip\");\r\nvar CardinalOrientation;\r\n(function (CardinalOrientation) {\r\n CardinalOrientation[CardinalOrientation[\"HEADS_NORTH\"] = 0] = \"HEADS_NORTH\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_NORTH\"] = 1] = \"TAILS_NORTH\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_EAST\"] = 2] = \"HEADS_EAST\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_EAST\"] = 3] = \"TAILS_EAST\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_SOUTH\"] = 4] = \"HEADS_SOUTH\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_SOUTH\"] = 5] = \"TAILS_SOUTH\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_WEST\"] = 6] = \"HEADS_WEST\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_WEST\"] = 7] = \"TAILS_WEST\";\r\n})(CardinalOrientation = exports.CardinalOrientation || (exports.CardinalOrientation = {}));\r\nexports.CARDINAL_ORIENTATIONS = [\r\n CardinalOrientation.HEADS_NORTH,\r\n CardinalOrientation.TAILS_NORTH,\r\n CardinalOrientation.HEADS_EAST,\r\n CardinalOrientation.TAILS_EAST,\r\n CardinalOrientation.HEADS_SOUTH,\r\n CardinalOrientation.TAILS_SOUTH,\r\n CardinalOrientation.HEADS_WEST,\r\n CardinalOrientation.TAILS_WEST,\r\n];\r\nconst CARDINAL_ORIENTATIONS_STR = [\r\n 'HN',\r\n 'TN',\r\n 'HE',\r\n 'TE',\r\n 'HS',\r\n 'TS',\r\n 'HW',\r\n 'TW',\r\n];\r\nfunction cardinalOrientationToString(orientation) {\r\n return CARDINAL_ORIENTATIONS_STR[orientation];\r\n}\r\nexports.cardinalOrientationToString = cardinalOrientationToString;\r\nfunction cardinalOrientationFlip(orientation, axis) {\r\n if (axis === axis_1.Axis.NORTH_SOUTH) {\r\n return ((9 - orientation) & 7);\r\n }\r\n else {\r\n return ((13 - orientation) & 7);\r\n }\r\n}\r\nexports.cardinalOrientationFlip = cardinalOrientationFlip;\r\nfunction cardinalOrientationReverse(orientation) {\r\n if (orientation === CardinalOrientation.HEADS_EAST) {\r\n return CardinalOrientation.HEADS_WEST;\r\n }\r\n else if (orientation === CardinalOrientation.HEADS_WEST) {\r\n return CardinalOrientation.HEADS_EAST;\r\n }\r\n else {\r\n return orientation;\r\n }\r\n}\r\nexports.cardinalOrientationReverse = cardinalOrientationReverse;\r\n// conversion\r\nfunction cardinalOrientationFromFlipAndCardinalDirection(flip, dir) {\r\n return (dir * 2 + (flip !== flip_1.Flip.HEADS ? 1 : 0));\r\n}\r\nexports.cardinalOrientationFromFlipAndCardinalDirection = cardinalOrientationFromFlipAndCardinalDirection;\r\n// math\r\nfunction cardinalOrientationAddCardinalTurn(orientation, turn) {\r\n return ((orientation + turn * 2) & 7);\r\n}\r\nexports.cardinalOrientationAddCardinalTurn = cardinalOrientationAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalTurnAddCardinalTurn = exports.cardinalTurnFromTurn = exports.cardinalTurnFromCardinalDirections = exports.cardinalTurnReverse = exports.cardinalTurnToDegrees = exports.cardinalTurnToString = exports.CARDINAL_TURNS = exports.CardinalTurn = void 0;\r\nvar CardinalTurn;\r\n(function (CardinalTurn) {\r\n CardinalTurn[CardinalTurn[\"NONE\"] = 0] = \"NONE\";\r\n CardinalTurn[CardinalTurn[\"RIGHT\"] = 1] = \"RIGHT\";\r\n CardinalTurn[CardinalTurn[\"AROUND\"] = 2] = \"AROUND\";\r\n CardinalTurn[CardinalTurn[\"LEFT\"] = 3] = \"LEFT\";\r\n})(CardinalTurn = exports.CardinalTurn || (exports.CardinalTurn = {}));\r\nexports.CARDINAL_TURNS = [\r\n CardinalTurn.NONE,\r\n CardinalTurn.RIGHT,\r\n CardinalTurn.AROUND,\r\n CardinalTurn.LEFT,\r\n];\r\nconst CARDINAL_TURNS_STR = [\r\n 'T0',\r\n 'T+90',\r\n 'T180',\r\n 'T-90',\r\n];\r\nfunction cardinalTurnToString(dir) {\r\n return CARDINAL_TURNS_STR[dir];\r\n}\r\nexports.cardinalTurnToString = cardinalTurnToString;\r\nfunction cardinalTurnToDegrees(turn) {\r\n return turn * 90;\r\n}\r\nexports.cardinalTurnToDegrees = cardinalTurnToDegrees;\r\nfunction cardinalTurnReverse(dir) {\r\n return ((4 - dir) & 3);\r\n}\r\nexports.cardinalTurnReverse = cardinalTurnReverse;\r\n// conversion\r\nfunction cardinalTurnFromCardinalDirections(from, to) {\r\n return ((to - from) & 3);\r\n}\r\nexports.cardinalTurnFromCardinalDirections = cardinalTurnFromCardinalDirections;\r\nfunction cardinalTurnFromTurn(turn) {\r\n return (turn >> 1);\r\n}\r\nexports.cardinalTurnFromTurn = cardinalTurnFromTurn;\r\n// math\r\nfunction cardinalTurnAddCardinalTurn(turn1, turn2) {\r\n return ((turn1 + turn2) & 3);\r\n}\r\nexports.cardinalTurnAddCardinalTurn = cardinalTurnAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.directionAddCardinalTurn = exports.directionAddTurn = exports.directionFromCardinalDirection = exports.directionOpposite = exports.directionIsCardinal = exports.directionToString = exports.DIRECTIONS = exports.Direction = void 0;\r\nvar Direction;\r\n(function (Direction) {\r\n Direction[Direction[\"NORTH\"] = 0] = \"NORTH\";\r\n Direction[Direction[\"NORTHEAST\"] = 1] = \"NORTHEAST\";\r\n Direction[Direction[\"EAST\"] = 2] = \"EAST\";\r\n Direction[Direction[\"SOUTHEAST\"] = 3] = \"SOUTHEAST\";\r\n Direction[Direction[\"SOUTH\"] = 4] = \"SOUTH\";\r\n Direction[Direction[\"SOUTHWEST\"] = 5] = \"SOUTHWEST\";\r\n Direction[Direction[\"WEST\"] = 6] = \"WEST\";\r\n Direction[Direction[\"NORTHWEST\"] = 7] = \"NORTHWEST\";\r\n})(Direction = exports.Direction || (exports.Direction = {}));\r\nexports.DIRECTIONS = [\r\n Direction.NORTH,\r\n Direction.NORTHEAST,\r\n Direction.EAST,\r\n Direction.SOUTHEAST,\r\n Direction.SOUTH,\r\n Direction.SOUTHWEST,\r\n Direction.WEST,\r\n Direction.NORTHWEST,\r\n];\r\nconst DIRECTIONS_STR = [\r\n 'N',\r\n 'NE',\r\n 'E',\r\n 'SE',\r\n 'S',\r\n 'SW',\r\n 'W',\r\n 'NW',\r\n];\r\nfunction directionToString(dir) {\r\n return DIRECTIONS_STR[dir];\r\n}\r\nexports.directionToString = directionToString;\r\nfunction directionIsCardinal(dir) {\r\n return (dir & 1) === 0;\r\n}\r\nexports.directionIsCardinal = directionIsCardinal;\r\nfunction directionOpposite(dir) {\r\n return ((dir + 4) & 7);\r\n}\r\nexports.directionOpposite = directionOpposite;\r\n// conversion\r\nfunction directionFromCardinalDirection(dir) {\r\n return (dir << 1);\r\n}\r\nexports.directionFromCardinalDirection = directionFromCardinalDirection;\r\n// math\r\nfunction directionAddTurn(dir, turn) {\r\n return ((dir + turn) & 7);\r\n}\r\nexports.directionAddTurn = directionAddTurn;\r\nfunction directionAddCardinalTurn(dir, turn) {\r\n return ((dir + turn * 2) & 7);\r\n}\r\nexports.directionAddCardinalTurn = directionAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.flipFromCardinalOrientation = exports.flipFromBoolean = exports.flipOpposite = exports.flipToString = exports.FLIPS = exports.Flip = void 0;\r\nvar Flip;\r\n(function (Flip) {\r\n Flip[Flip[\"HEADS\"] = 0] = \"HEADS\";\r\n Flip[Flip[\"TAILS\"] = 1] = \"TAILS\";\r\n})(Flip = exports.Flip || (exports.Flip = {}));\r\nexports.FLIPS = [\r\n Flip.HEADS,\r\n Flip.TAILS,\r\n];\r\nconst FLIPS_STR = [\r\n 'H',\r\n 'T',\r\n];\r\nfunction flipToString(flip) {\r\n return FLIPS_STR[flip];\r\n}\r\nexports.flipToString = flipToString;\r\nfunction flipOpposite(flip) {\r\n return (flip ^ 1);\r\n}\r\nexports.flipOpposite = flipOpposite;\r\n// conversion\r\nfunction flipFromBoolean(tails) {\r\n return tails ? Flip.TAILS : Flip.HEADS;\r\n}\r\nexports.flipFromBoolean = flipFromBoolean;\r\nfunction flipFromCardinalOrientation(orientation) {\r\n return (orientation & 1);\r\n}\r\nexports.flipFromCardinalOrientation = flipFromCardinalOrientation;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./direction\"), exports);\r\n__exportStar(require(\"./turn\"), exports);\r\n__exportStar(require(\"./cardinal-direction\"), exports);\r\n__exportStar(require(\"./cardinal-turn\"), exports);\r\n__exportStar(require(\"./cardinal-direction-flags\"), exports);\r\n__exportStar(require(\"./flip\"), exports);\r\n__exportStar(require(\"./cardinal-orientation\"), exports);\r\n__exportStar(require(\"./axis\"), exports);\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.turnAddTurn = exports.turnFromDirections = exports.turnFromCardinalTurn = exports.turnFromCardinalDirections = exports.turnReverse = exports.turnIsCardinal = exports.turnToDegrees = exports.turnToString = exports.TURNS = exports.Turn = void 0;\r\nvar Turn;\r\n(function (Turn) {\r\n Turn[Turn[\"NONE\"] = 0] = \"NONE\";\r\n Turn[Turn[\"R_45\"] = 1] = \"R_45\";\r\n Turn[Turn[\"R_90\"] = 2] = \"R_90\";\r\n Turn[Turn[\"R_135\"] = 3] = \"R_135\";\r\n Turn[Turn[\"T_180\"] = 4] = \"T_180\";\r\n Turn[Turn[\"L_135\"] = 5] = \"L_135\";\r\n Turn[Turn[\"L_90\"] = 6] = \"L_90\";\r\n Turn[Turn[\"L_45\"] = 7] = \"L_45\";\r\n})(Turn = exports.Turn || (exports.Turn = {}));\r\nexports.TURNS = [\r\n Turn.NONE,\r\n Turn.R_45,\r\n Turn.R_90,\r\n Turn.R_135,\r\n Turn.T_180,\r\n Turn.L_135,\r\n Turn.L_90,\r\n Turn.L_45,\r\n];\r\nconst TURNS_STR = [\r\n 'T0',\r\n 'T+45',\r\n 'T+90',\r\n 'T+135',\r\n 'T180',\r\n 'T-135',\r\n 'T-90',\r\n 'T-45',\r\n];\r\nfunction turnToString(turn) {\r\n return TURNS_STR[turn];\r\n}\r\nexports.turnToString = turnToString;\r\nfunction turnToDegrees(turn) {\r\n return turn * 45;\r\n}\r\nexports.turnToDegrees = turnToDegrees;\r\nfunction turnIsCardinal(turn) {\r\n return (turn & 1) === 0;\r\n}\r\nexports.turnIsCardinal = turnIsCardinal;\r\nfunction turnReverse(turn) {\r\n return ((8 - turn) & 7);\r\n}\r\nexports.turnReverse = turnReverse;\r\n// conversion\r\nfunction turnFromCardinalDirections(from, to) {\r\n return (((to - from) * 2) & 7);\r\n}\r\nexports.turnFromCardinalDirections = turnFromCardinalDirections;\r\nfunction turnFromCardinalTurn(turn) {\r\n return (turn << 1);\r\n}\r\nexports.turnFromCardinalTurn = turnFromCardinalTurn;\r\nfunction turnFromDirections(from, to) {\r\n return ((to - from) & 7);\r\n}\r\nexports.turnFromDirections = turnFromDirections;\r\n// math\r\nfunction turnAddTurn(turn1, turn2) {\r\n return ((turn1 + turn2) & 7);\r\n}\r\nexports.turnAddTurn = turnAddTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.CardinalPath = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nconst offset_1 = require(\"./offset\");\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst raster_mask_1 = require(\"./raster-mask\");\r\nconst LOCAL_OFF = new offset_1.Offset();\r\nfunction sortedInsert(array, value) {\r\n array.push(value);\r\n let i = array.length - 1;\r\n while (i > 0 && value < array[i - 1]) {\r\n array[i] = array[i - 1];\r\n i--;\r\n }\r\n array[i] = value;\r\n}\r\nclass CardinalPath {\r\n constructor(start, segments) {\r\n this._start = new offset_1.Offset();\r\n this._start.copyFrom(start);\r\n this._segments = segments;\r\n }\r\n // accessors\r\n toString() {\r\n return `${this._start.toString()}:`\r\n + `${this._segments.map((segment) => compass_1.cardinalDirectionToString(segment)).join('')}`;\r\n }\r\n equals(other) {\r\n return this._start.equals(other._start)\r\n && this._segments.length === other._segments.length\r\n && this._segments.every((v, i) => v === other._segments[i]);\r\n }\r\n get length() {\r\n return this._segments.length;\r\n }\r\n // utilities\r\n getIsClosed() {\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n }\r\n return this._start.equals(LOCAL_OFF);\r\n }\r\n *offsets() {\r\n let { x, y } = this._start;\r\n yield { x, y };\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.setFromCardinalDirection(segment);\r\n x += LOCAL_OFF.x;\r\n y += LOCAL_OFF.y;\r\n yield { x, y };\r\n }\r\n }\r\n getBounds() {\r\n let northY = this._start.y;\r\n let southY = northY;\r\n let westX = this._start.x;\r\n let eastX = westX;\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n switch (segment) {\r\n case compass_1.CardinalDirection.NORTH:\r\n northY = Math.min(northY, LOCAL_OFF.y);\r\n break;\r\n case compass_1.CardinalDirection.EAST:\r\n eastX = Math.max(eastX, LOCAL_OFF.x);\r\n break;\r\n case compass_1.CardinalDirection.SOUTH:\r\n southY = Math.max(southY, LOCAL_OFF.y);\r\n break;\r\n case compass_1.CardinalDirection.WEST:\r\n westX = Math.min(westX, LOCAL_OFF.x);\r\n break;\r\n // istanbul ignore next\r\n default:\r\n throw new Error(`bad direction ${segment} in cardinal path`);\r\n }\r\n }\r\n return new rectangle_1.Rectangle(westX, northY, eastX - westX + 1, southY - northY + 1);\r\n }\r\n getArea() {\r\n let total = 0;\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n switch (segment) {\r\n case compass_1.CardinalDirection.NORTH:\r\n total -= LOCAL_OFF.x;\r\n break;\r\n case compass_1.CardinalDirection.SOUTH:\r\n total += LOCAL_OFF.x;\r\n break;\r\n }\r\n }\r\n return Math.abs(total);\r\n }\r\n rasterize(bounds) {\r\n const lines = new Array();\r\n if (typeof bounds === 'undefined') {\r\n bounds = this.getBounds();\r\n }\r\n // assert(this.getIsClosed())\r\n LOCAL_OFF.copyFrom(this._start);\r\n const { northY } = bounds;\r\n const southY = northY + bounds.height - 1;\r\n for (let y = northY; y < southY; y++) {\r\n lines.push([]);\r\n }\r\n LOCAL_OFF.copyFrom(this._start);\r\n // assert(LOCAL_OFF.y >= northY && LOCAL_OFF.y <= southY)\r\n for (const segment of this._segments) {\r\n if (segment === compass_1.CardinalDirection.SOUTH) {\r\n sortedInsert(lines[LOCAL_OFF.y - northY], LOCAL_OFF.x);\r\n }\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n // assert(LOCAL_OFF.y >= northY && LOCAL_OFF.y <= southY)\r\n if (segment === compass_1.CardinalDirection.NORTH) {\r\n sortedInsert(lines[LOCAL_OFF.y - northY], LOCAL_OFF.x);\r\n }\r\n }\r\n return new raster_mask_1.RasterMask({\r\n westX: bounds.westX,\r\n northY: bounds.northY,\r\n width: bounds.width - 1,\r\n height: bounds.height - 1,\r\n }, lines);\r\n }\r\n}\r\nexports.CardinalPath = CardinalPath;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./offset\"), exports);\r\n__exportStar(require(\"./size\"), exports);\r\n__exportStar(require(\"./rectangle\"), exports);\r\n__exportStar(require(\"./mask\"), exports);\r\n__exportStar(require(\"./mask-rectangle\"), exports);\r\n__exportStar(require(\"./raster-mask\"), exports);\r\n__exportStar(require(\"./cardinal-path\"), exports);\r\n__exportStar(require(\"./transform-rectangle\"), exports);\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.MaskRectangle = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst mask_1 = require(\"./mask\");\r\nclass MaskRectangle {\r\n constructor(rect, initialValue = false, outsideValue = false) {\r\n this._rect = new rectangle_1.Rectangle();\r\n if (typeof rect !== 'undefined') {\r\n this._rect.copyFrom(rect);\r\n }\r\n this._mask = new mask_1.Mask(rect, initialValue);\r\n this._outsideValue = outsideValue;\r\n }\r\n // accessors\r\n toString() {\r\n return `${this._rect.northWest}/${this._outsideValue}\\n${this._mask}`;\r\n }\r\n equals(other) {\r\n return this._rect.equals(other._rect)\r\n && this._mask.equals(other._mask)\r\n && this._outsideValue === other._outsideValue;\r\n }\r\n get westX() {\r\n return this._rect.westX;\r\n }\r\n get northY() {\r\n return this._rect.northY;\r\n }\r\n get width() {\r\n return this._rect.width;\r\n }\r\n get height() {\r\n return this._rect.height;\r\n }\r\n get(x, y) {\r\n if (!this._rect.contains(x, y)) {\r\n return this._outsideValue;\r\n }\r\n return this._mask.get(x - this.westX, y - this.northY);\r\n }\r\n getAtIndex(index) {\r\n return this._mask.getAtIndex(index);\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._rect.copyFrom(other._rect);\r\n this._mask.copyFrom(other._mask);\r\n this._outsideValue = other._outsideValue;\r\n return this;\r\n }\r\n set(x, y, value) {\r\n this._mask.set(x - this.westX, y - this.northY, value);\r\n return this;\r\n }\r\n setAtOffset(off, value) {\r\n return this.set(off.x, off.y, value);\r\n }\r\n setAtIndex(index, value) {\r\n this._mask.setAtIndex(index, value);\r\n return this;\r\n }\r\n // utilities\r\n index(x, y) {\r\n return this._mask.index(x - this.westX, y - this.northY);\r\n }\r\n *locations() {\r\n for (const loc of this._mask.locations()) {\r\n const x = loc.x + this.westX;\r\n const y = loc.y + this.northY;\r\n const { value } = loc;\r\n yield { x, y, value };\r\n }\r\n }\r\n *offsetsWithTrue() {\r\n for (const off of this._mask.offsetsWithTrue()) {\r\n const x = off.x + this.westX;\r\n const y = off.y + this.northY;\r\n yield { x, y };\r\n }\r\n }\r\n}\r\nexports.MaskRectangle = MaskRectangle;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Mask = void 0;\r\nconst size_1 = require(\"./size\");\r\nclass Mask {\r\n constructor(size, initialValue = false) {\r\n this._size = new size_1.Size();\r\n if (typeof size !== 'undefined') {\r\n this._size.copyFrom(size);\r\n }\r\n this._bits = new Array(Math.ceil(this._size.area / 32)).fill(initialValue ? 0xffffffff : 0);\r\n }\r\n // accessors\r\n toString() {\r\n let ret = '';\r\n for (let y = 0; y < this.height; y++) {\r\n for (let x = 0; x < this.width; x++) {\r\n ret += this.get(x, y) ? '☑' : '☐';\r\n }\r\n ret += '\\n';\r\n }\r\n return ret;\r\n }\r\n equals(other) {\r\n return this._size.equals(other._size)\r\n && this._bits.length === other._bits.length\r\n && this._bits.every((v, i) => v === other._bits[i]);\r\n }\r\n get width() {\r\n return this._size.width;\r\n }\r\n get height() {\r\n return this._size.height;\r\n }\r\n get(x, y) {\r\n return this.getAtIndex(this.index(x, y));\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n getAtIndex(index) {\r\n // assert(index >= 0 && index < this._size.area)\r\n const arrayIndex = index >>> 5;\r\n const bitMask = 1 << (index & 31);\r\n return (this._bits[arrayIndex] & bitMask) !== 0;\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._size.copyFrom(other._size);\r\n this._bits = other._bits.slice();\r\n return this;\r\n }\r\n set(x, y, value) {\r\n return this.setAtIndex(this.index(x, y), value);\r\n }\r\n setAtOffset(off, value) {\r\n return this.set(off.x, off.y, value);\r\n }\r\n setAtIndex(index, value) {\r\n // assert(index >= 0 && index < this._size.area)\r\n const arrayIndex = index >>> 5;\r\n const bitMask = 1 << (index & 31);\r\n if (value) {\r\n this._bits[arrayIndex] |= bitMask;\r\n }\r\n else {\r\n this._bits[arrayIndex] &= ~bitMask;\r\n }\r\n return this;\r\n }\r\n // utilities\r\n index(x, y) {\r\n return this._size.index(x, y);\r\n }\r\n *locations() {\r\n let arrayIndex = 0;\r\n let bitMask = 1;\r\n for (const { x, y } of this._size.offsets()) {\r\n const value = (this._bits[arrayIndex] & bitMask) !== 0;\r\n yield { x, y, value };\r\n if (bitMask === (1 << 31)) {\r\n bitMask = 1;\r\n arrayIndex++;\r\n }\r\n else {\r\n bitMask <<= 1;\r\n }\r\n }\r\n }\r\n *offsetsWithTrue() {\r\n for (const { x, y, value } of this.locations()) {\r\n if (value) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n}\r\nexports.Mask = Mask;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Offset = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nconst X_FROM_DIRECTION = [0, 1, 1, 1, 0, -1, -1, -1];\r\nconst Y_FROM_DIRECTION = [-1, -1, 0, 1, 1, 1, 0, -1];\r\nconst X_FROM_CARDINAL_DIRECTION = [0, 1, 0, -1];\r\nconst Y_FROM_CARDINAL_DIRECTION = [-1, 0, 1, 0];\r\nclass Offset {\r\n constructor(x, y) {\r\n if (typeof x === 'undefined') {\r\n x = 0;\r\n }\r\n if (typeof y === 'undefined') {\r\n y = 0;\r\n }\r\n this.x = x;\r\n this.y = y;\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.x},${this.y})`;\r\n }\r\n equals(other) {\r\n return this.x === other.x && this.y === other.y;\r\n }\r\n // mutators\r\n set(x, y) {\r\n this.x = x;\r\n this.y = y;\r\n return this;\r\n }\r\n copyFrom(other) {\r\n return this.set(other.x, other.y);\r\n }\r\n setFromDirection(dir) {\r\n return this.set(X_FROM_DIRECTION[dir], Y_FROM_DIRECTION[dir]);\r\n }\r\n setFromCardinalDirection(dir) {\r\n return this.set(X_FROM_CARDINAL_DIRECTION[dir], Y_FROM_CARDINAL_DIRECTION[dir]);\r\n }\r\n add(x, y) {\r\n this.x += x;\r\n this.y += y;\r\n return this;\r\n }\r\n addSize(size) {\r\n return this.add(size.width, size.height);\r\n }\r\n addOffset(off) {\r\n return this.add(off.x, off.y);\r\n }\r\n addDirection(dir) {\r\n return this.add(X_FROM_DIRECTION[dir], Y_FROM_DIRECTION[dir]);\r\n }\r\n addCardinalDirection(dir) {\r\n return this.add(X_FROM_CARDINAL_DIRECTION[dir], Y_FROM_CARDINAL_DIRECTION[dir]);\r\n }\r\n subtractOffset(off) {\r\n return this.add(-off.x, -off.y);\r\n }\r\n multiply(factor) {\r\n this.x *= factor;\r\n this.y *= factor;\r\n return this;\r\n }\r\n rotate(turn, anchor) {\r\n if (anchor) {\r\n return this.subtractOffset(anchor).rotate(turn).addOffset(anchor);\r\n }\r\n else {\r\n const dir = compass_1.cardinalDirectionFromNorthTurn(turn);\r\n const { x, y } = this;\r\n const dirx = X_FROM_CARDINAL_DIRECTION[dir];\r\n const diry = Y_FROM_CARDINAL_DIRECTION[dir];\r\n const nx = -y * dirx - x * diry;\r\n const ny = x * dirx - y * diry;\r\n return this.set(nx, ny);\r\n }\r\n }\r\n // utilities\r\n // chebyshev: can move in any direction (diagonals are ok)\r\n distanceChebyshev(other) {\r\n return Math.max(Math.abs(this.x - other.x), Math.abs(this.y - other.y));\r\n }\r\n // manhattan: can move only in cardinal directions (no diagonals)\r\n distanceManhattan(other) {\r\n return Math.abs(this.x - other.x) + Math.abs(this.y - other.y);\r\n }\r\n // chebyshev: can move in any direction (diagonals are ok)\r\n *nearbyChebyshevOffsets(cursor, radius) {\r\n if (radius >= 0) {\r\n for (let dy = -radius; dy <= radius; dy++) {\r\n for (let dx = -radius; dx <= radius; dx++) {\r\n yield cursor.set(this.x + dx, this.y + dy);\r\n }\r\n }\r\n }\r\n }\r\n}\r\nexports.Offset = Offset;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.RasterMask = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nclass RasterMask {\r\n constructor(bounds, lines) {\r\n this._rect = new rectangle_1.Rectangle();\r\n if (lines.length !== bounds.height) {\r\n throw new Error(`bad lines array length ${lines.length} for bounds ${bounds}`);\r\n }\r\n this._rect.copyFrom(bounds);\r\n this._lines = lines;\r\n }\r\n // accessors\r\n toString() {\r\n let shape = '';\r\n const { eastX } = this._rect;\r\n for (let y = 0; y < this.height; y++) {\r\n const line = this._lines[y];\r\n let x = this.westX;\r\n for (let i = 0; i < line.length; i += 2) {\r\n const start = line[i];\r\n const end = line[i + 1];\r\n while (x < start) {\r\n shape += '∙';\r\n x++;\r\n }\r\n while (x < end) {\r\n shape += '█';\r\n x++;\r\n }\r\n }\r\n while (x <= eastX) {\r\n shape += '∙';\r\n x++;\r\n }\r\n shape += '\\n';\r\n }\r\n return `(${this._rect.westX},${this._rect.northY})\\n${shape}`;\r\n }\r\n equals(other) {\r\n return this._rect.equals(other._rect)\r\n && this._lines.length === other._lines.length\r\n && this._lines.every((v, i) => (v.length === other._lines[i].length\r\n && v.every((w, j) => w === other._lines[i][j])));\r\n }\r\n get northY() {\r\n return this._rect.northY;\r\n }\r\n get southY() {\r\n return this._rect.southY;\r\n }\r\n get westX() {\r\n return this._rect.westX;\r\n }\r\n get width() {\r\n return this._rect.width;\r\n }\r\n get height() {\r\n return this._rect.height;\r\n }\r\n get(x, y) {\r\n if (y < this.northY || y > this._rect.southY) {\r\n return false;\r\n }\r\n const line = this._lines[y - this.northY];\r\n for (let i = 0; i < line.length; i += 2) {\r\n if (x >= line[i] && x < line[i + 1]) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n // utilities\r\n *bandsAt(y) {\r\n if (y >= this.northY && y <= this._rect.southY) {\r\n const line = this._lines[y - this.northY];\r\n for (let i = 0; i < line.length; i += 2) {\r\n yield {\r\n westX: line[i],\r\n eastX: line[i + 1] - 1,\r\n };\r\n }\r\n }\r\n }\r\n}\r\nexports.RasterMask = RasterMask;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Rectangle = void 0;\r\nconst size_1 = require(\"./size\");\r\nconst offset_1 = require(\"./offset\");\r\nconst ROTATE_CORNER_X = [0, 0, 1, 1];\r\nconst ROTATE_CORNER_Y = [0, 1, 1, 0];\r\nclass Rectangle {\r\n constructor(westX, northY, width, height) {\r\n if (typeof westX === 'undefined') {\r\n westX = 0;\r\n }\r\n if (typeof northY === 'undefined') {\r\n northY = 0;\r\n }\r\n if (typeof width === 'undefined') {\r\n width = 0;\r\n }\r\n if (typeof height === 'undefined') {\r\n height = 0;\r\n }\r\n this.northWest = new offset_1.Offset(westX, northY);\r\n this.size = new size_1.Size(width, height);\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.westX},${this.northY} ${this.width}x${this.height})`;\r\n }\r\n equals(other) {\r\n return this.westX === other.westX && this.northY === other.northY && this.size.equals(other);\r\n }\r\n get northY() {\r\n return this.northWest.y;\r\n }\r\n get southY() {\r\n return this.northWest.y + this.size.height - 1;\r\n }\r\n get westX() {\r\n return this.northWest.x;\r\n }\r\n get eastX() {\r\n return this.northWest.x + this.size.width - 1;\r\n }\r\n get width() {\r\n return this.size.width;\r\n }\r\n get height() {\r\n return this.size.height;\r\n }\r\n get empty() {\r\n return this.size.empty;\r\n }\r\n get area() {\r\n return this.size.area;\r\n }\r\n // mutators\r\n set(westX, northY, width, height) {\r\n this.northWest.set(westX, northY);\r\n this.size.set(width, height);\r\n return this;\r\n }\r\n setFromCorners(off1, off2) {\r\n const westX = Math.min(off1.x, off2.x);\r\n const eastX = Math.max(off1.x, off2.x);\r\n const northY = Math.min(off1.y, off2.y);\r\n const southY = Math.max(off1.y, off2.y);\r\n return this.set(westX, northY, eastX - westX + 1, southY - northY + 1);\r\n }\r\n copyFrom(other) {\r\n return this.set(other.westX, other.northY, other.width, other.height);\r\n }\r\n addOffset(off) {\r\n this.northWest.addOffset(off);\r\n return this;\r\n }\r\n scale(factor) {\r\n this.northWest.multiply(factor);\r\n this.size.multiply(factor);\r\n return this;\r\n }\r\n rotate(turn, anchor) {\r\n const cx = ROTATE_CORNER_X[turn];\r\n const cy = ROTATE_CORNER_Y[turn];\r\n this.northWest.add(cx * (this.width - 1), cy * (this.height - 1)).rotate(turn, anchor);\r\n this.size.rotate(turn);\r\n return this;\r\n }\r\n extendToInclude(off) {\r\n const dx = off.x - this.westX;\r\n if (dx < 0) {\r\n this.size.width -= dx;\r\n this.northWest.x = off.x;\r\n }\r\n else if (dx >= this.size.width) {\r\n this.size.width = dx + 1;\r\n }\r\n const dy = off.y - this.northWest.y;\r\n if (dy < 0) {\r\n this.size.height -= dy;\r\n this.northWest.y = off.y;\r\n }\r\n else if (dy >= this.size.height) {\r\n this.size.height = dy + 1;\r\n }\r\n return this;\r\n }\r\n // utilities\r\n contains(x, y) {\r\n return this.size.contains(x - this.westX, y - this.northY);\r\n }\r\n index(x, y) {\r\n return this.size.index(x - this.westX, y - this.northY);\r\n }\r\n containsOffset(off) {\r\n return this.contains(off.x, off.y);\r\n }\r\n containsRectangle(other) {\r\n if (other.width === 0 && other.height === 0) {\r\n return false;\r\n }\r\n const x = other.westX - this.westX;\r\n const y = other.northY - this.northY;\r\n if (!this.size.contains(x, y)) {\r\n return false;\r\n }\r\n return this.size.contains(x + other.width - 1, y + other.height - 1);\r\n }\r\n overlapsRectangle(other) {\r\n return this.northY <= other.northY + other.height - 1\r\n && this.southY >= other.northY\r\n && this.westX <= other.westX + other.width - 1\r\n && this.eastX >= other.westX\r\n && !this.empty\r\n && other.width !== 0 && other.height !== 0;\r\n }\r\n *offsets() {\r\n const { eastX, southY } = this;\r\n for (let y = this.northY; y <= southY; y++) {\r\n for (let x = this.westX; x <= eastX; x++) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n anyOf(predicate) {\r\n for (const { x, y } of this.offsets()) {\r\n if (predicate(x, y)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\nexports.Rectangle = Rectangle;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Size = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nclass Size {\r\n constructor(width, height) {\r\n if (typeof width === 'undefined') {\r\n width = 0;\r\n }\r\n if (typeof height === 'undefined') {\r\n height = 0;\r\n }\r\n if (width < 0 || height < 0) {\r\n throw new Error(`bad size (${width}x${height})`);\r\n }\r\n this.width = width;\r\n this.height = height;\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.width}x${this.height})`;\r\n }\r\n equals(other) {\r\n return this.width === other.width && this.height === other.height;\r\n }\r\n get empty() {\r\n return this.width === 0 || this.height === 0;\r\n }\r\n get area() {\r\n return this.width * this.height;\r\n }\r\n // mutators\r\n set(width, height) {\r\n if (width < 0 || height < 0) {\r\n throw new Error(`bad size (${width}x${height})`);\r\n }\r\n this.width = width;\r\n this.height = height;\r\n return this;\r\n }\r\n copyFrom(other) {\r\n return this.set(other.width, other.height);\r\n }\r\n add(width, height) {\r\n this.width += width;\r\n this.height += height;\r\n return this;\r\n }\r\n multiply(factor) {\r\n this.width *= factor;\r\n this.height *= factor;\r\n return this;\r\n }\r\n rotate(turn) {\r\n if (compass_1.axisFromNorthSouthTurn(turn) === compass_1.Axis.WEST_EAST) {\r\n this.set(this.height, this.width);\r\n }\r\n return this;\r\n }\r\n // utilities\r\n contains(x, y) {\r\n return x >= 0 && y >= 0 && x < this.width && y < this.height;\r\n }\r\n containsOffset(off) {\r\n return this.contains(off.x, off.y);\r\n }\r\n index(x, y) {\r\n return y * this.width + x;\r\n }\r\n *offsets() {\r\n for (let y = 0; y < this.height; y++) {\r\n for (let x = 0; x < this.width; x++) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n anyOf(predicate) {\r\n for (const { x, y } of this.offsets()) {\r\n if (predicate(x, y)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\nexports.Size = Size;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.TransformRectangle = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst compass_1 = require(\"../compass\");\r\nconst offset_1 = require(\"./offset\");\r\nconst size_1 = require(\"./size\");\r\nconst LOCAL_OFF = new offset_1.Offset();\r\nconst LOCAL_OFF2 = new offset_1.Offset();\r\nconst LOCAL_SIZE = new size_1.Size();\r\nclass TransformRectangle {\r\n constructor(width, height) {\r\n this._size = new size_1.Size();\r\n this._flip = compass_1.Flip.HEADS;\r\n this._rotate = compass_1.CardinalTurn.NONE;\r\n this._translate = new offset_1.Offset();\r\n this._matrix = [1, 0, 0, 0, 1, 0];\r\n this._targetRect = new rectangle_1.Rectangle();\r\n if (typeof width === 'undefined') {\r\n // nothing\r\n }\r\n else if (typeof width === 'number') {\r\n this._size.set(width, height);\r\n }\r\n else {\r\n this._size.copyFrom(width);\r\n }\r\n this._update();\r\n }\r\n // accessors\r\n toString() {\r\n return `[${this._size}`\r\n + ` -> ${compass_1.flipToString(this._flip)} ${compass_1.cardinalTurnToString(this._rotate)} ${this._translate}`\r\n + ` -> ${this._targetRect}]`;\r\n }\r\n equals(other) {\r\n return this._size.equals(other._size)\r\n && this._flip === other._flip\r\n && this._rotate === other._rotate\r\n && this._translate.equals(other._translate);\r\n }\r\n get flip() {\r\n return this._flip;\r\n }\r\n get rotate() {\r\n return this._rotate;\r\n }\r\n get northY() {\r\n return this._translate.y;\r\n }\r\n get southY() {\r\n return this._translate.y + this._targetRect.height - 1;\r\n }\r\n get westX() {\r\n return this._translate.x;\r\n }\r\n get eastX() {\r\n return this._translate.x + this._targetRect.width - 1;\r\n }\r\n get width() {\r\n return this._targetRect.width;\r\n }\r\n get height() {\r\n return this._targetRect.height;\r\n }\r\n // internal\r\n // 0\r\n // 0 -1\r\n // +90\r\n // 1 0\r\n // 180\r\n // 0 1\r\n // -90\r\n // -1 0\r\n //\r\n // heads:\r\n // 0\r\n // 1 0 x\r\n // 0 1 y\r\n // +90\r\n // 0 -1 x + h - 1\r\n // 1 0 y\r\n // 180\r\n // -1 0 x + w - 1\r\n // 0 -1 y + h - 1\r\n // -90\r\n // 0 1 x\r\n // -1 0 y + w - 1\r\n //\r\n // tails:\r\n // 0\r\n // -1 0 x + w - 1\r\n // 0 1 y\r\n // +90\r\n // 0 -1 x + h - 1\r\n // -1 0 y + w - 1\r\n // 180\r\n // 1 0 x\r\n // 0 -1 y + h - 1\r\n // -90\r\n // 0 1 x\r\n // 1 0 y\r\n _update() {\r\n LOCAL_OFF.setFromCardinalDirection(compass_1.cardinalDirectionFromNorthTurn(this._rotate));\r\n const flipSign = this._flip === compass_1.Flip.TAILS ? -1 : 1;\r\n this._matrix[0] = -LOCAL_OFF.y * flipSign;\r\n this._matrix[1] = -LOCAL_OFF.x;\r\n this._matrix[2] = this._translate.x;\r\n this._matrix[3] = LOCAL_OFF.x * flipSign;\r\n this._matrix[4] = -LOCAL_OFF.y;\r\n this._matrix[5] = this._translate.y;\r\n switch (this._rotate) {\r\n case compass_1.CardinalTurn.NONE:\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n this._matrix[2] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.RIGHT:\r\n this._matrix[2] += this._size.height - 1;\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n this._matrix[5] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.AROUND:\r\n this._matrix[5] += this._size.height - 1;\r\n if (this._flip === compass_1.Flip.HEADS) {\r\n this._matrix[2] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.LEFT:\r\n if (this._flip === compass_1.Flip.HEADS) {\r\n this._matrix[5] += this._size.width - 1;\r\n }\r\n break;\r\n }\r\n LOCAL_SIZE.copyFrom(this._size).rotate(this._rotate);\r\n this._targetRect.set(this._translate.x, this._translate.y, LOCAL_SIZE.width, LOCAL_SIZE.height);\r\n return this;\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._size.copyFrom(other._size);\r\n this._flip = other._flip;\r\n this._rotate = other._rotate;\r\n this._translate.copyFrom(other._translate);\r\n other._matrix.forEach((v, i) => this._matrix[i] = v);\r\n this._targetRect.copyFrom(other._targetRect);\r\n return this;\r\n }\r\n reset() {\r\n this._flip = compass_1.Flip.HEADS;\r\n this._rotate = compass_1.CardinalTurn.NONE;\r\n this._translate.set(0, 0);\r\n return this._update();\r\n }\r\n invert() {\r\n const nrotate = compass_1.cardinalTurnFromCardinalDirections(compass_1.CardinalDirection.NORTH, compass_1.cardinalDirectionFromCardinalOrientation(compass_1.cardinalOrientationReverse(compass_1.cardinalOrientationFromFlipAndCardinalDirection(this._flip, compass_1.cardinalDirectionFromNorthTurn(this._rotate)))));\r\n this._rotate = nrotate;\r\n this._size.rotate(nrotate);\r\n this._translate.multiply(-1);\r\n return this._update();\r\n }\r\n setTransform(flip, rotate, translate) {\r\n this._flip = flip;\r\n this._rotate = rotate;\r\n this._translate.copyFrom(translate);\r\n return this._update();\r\n }\r\n setFlip(flip) {\r\n this._flip = flip;\r\n return this._update();\r\n }\r\n setRotate(rotate) {\r\n this._rotate = rotate;\r\n return this._update();\r\n }\r\n setTranslate(x, y) {\r\n this._translate.set(x, y);\r\n return this._update();\r\n }\r\n setTranslateOffset(translate) {\r\n this._translate.copyFrom(translate);\r\n return this._update();\r\n }\r\n // utility\r\n applyToCardinalOrientation(orientation) {\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n orientation = compass_1.cardinalOrientationFlip(orientation, compass_1.Axis.NORTH_SOUTH);\r\n }\r\n return compass_1.cardinalOrientationAddCardinalTurn(orientation, this._rotate);\r\n }\r\n unapplyFromCardinalOrientation(orientation) {\r\n orientation = compass_1.cardinalOrientationAddCardinalTurn(orientation, compass_1.cardinalTurnReverse(this._rotate));\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n orientation = compass_1.cardinalOrientationFlip(orientation, compass_1.Axis.NORTH_SOUTH);\r\n }\r\n return orientation;\r\n }\r\n applyToCardinalDirection(orientation) {\r\n return compass_1.cardinalDirectionFromCardinalOrientation(this.applyToCardinalOrientation(compass_1.cardinalOrientationFromFlipAndCardinalDirection(compass_1.Flip.HEADS, orientation)));\r\n }\r\n unapplyFromCardinalDirection(orientation) {\r\n return compass_1.cardinalDirectionFromCardinalOrientation(this.unapplyFromCardinalOrientation(compass_1.cardinalOrientationFromFlipAndCardinalDirection(compass_1.Flip.HEADS, orientation)));\r\n }\r\n applyTo(offOut, x, y) {\r\n const nx = x * this._matrix[0] + y * this._matrix[1] + this._matrix[2];\r\n const ny = x * this._matrix[3] + y * this._matrix[4] + this._matrix[5];\r\n return offOut.set(nx, ny);\r\n }\r\n unapplyFrom(offOut, x, y) {\r\n const tx = x - this._matrix[2];\r\n const ty = y - this._matrix[5];\r\n const nx = tx * this._matrix[0] + ty * this._matrix[3];\r\n const ny = tx * this._matrix[1] + ty * this._matrix[4];\r\n return offOut.set(nx, ny);\r\n }\r\n applyToOffset(offOut, off) {\r\n if (typeof off === 'undefined') {\r\n off = offOut;\r\n }\r\n return this.applyTo(offOut, off.x, off.y);\r\n }\r\n unapplyFromOffset(offOut, off) {\r\n if (typeof off === 'undefined') {\r\n off = offOut;\r\n }\r\n return this.unapplyFrom(offOut, off.x, off.y);\r\n }\r\n applyToRectangle(rectOut, rect) {\r\n if (typeof rect !== 'undefined') {\r\n rectOut.copyFrom(rect);\r\n }\r\n LOCAL_OFF.set(rectOut.westX, rectOut.northY);\r\n LOCAL_OFF2.set(rectOut.eastX, rectOut.southY);\r\n this.applyToOffset(LOCAL_OFF);\r\n this.applyToOffset(LOCAL_OFF2);\r\n return rectOut.setFromCorners(LOCAL_OFF, LOCAL_OFF2);\r\n }\r\n unapplyFromRectangle(rectOut, rect) {\r\n if (typeof rect !== 'undefined') {\r\n rectOut.copyFrom(rect);\r\n }\r\n LOCAL_OFF.set(rectOut.westX, rectOut.northY);\r\n LOCAL_OFF2.set(rectOut.eastX, rectOut.southY);\r\n this.unapplyFromOffset(LOCAL_OFF);\r\n this.unapplyFromOffset(LOCAL_OFF2);\r\n return rectOut.setFromCorners(LOCAL_OFF, LOCAL_OFF2);\r\n }\r\n}\r\nexports.TransformRectangle = TransformRectangle;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./compass\"), exports);\r\n__exportStar(require(\"./grid\"), exports);\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n});\r\nvar __importStar = (this && this.__importStar) || function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.computeFieldOfView = void 0;\r\nconst geom = __importStar(require(\"tiled-geometry\"));\r\nconst constants = __importStar(require(\"./constants\"));\r\nconst field_of_view_impl_1 = require(\"./field-of-view-impl\");\r\nconst wedge_1 = require(\"./wedge\");\r\n/* eslint-disable indent */\r\n/**\r\n * Compute the field of view for a camera at the given tile.\r\n * chebyshevRadius is the vision radius. It uses chebyshev distance\r\n * (https://en.wikipedia.org/wiki/Chebyshev_distance), which just means\r\n * that the limit of vision in a large empty field will be square.\r\n *\r\n * This returns a FieldOfView, which indicates which tiles are visible.\r\n * fieldOfView.get(x, y) will return true for visible tiles.\r\n */\r\nfunction computeFieldOfView(map, x, y, chebyshevRadius) {\r\n const origin = new geom.Offset(x, y);\r\n const field = new field_of_view_impl_1.FieldOfViewImpl(origin, chebyshevRadius);\r\n // the field is divided into quadrants\r\n quadrant(map, field, origin, chebyshevRadius, -1, -1);\r\n quadrant(map, field, origin, chebyshevRadius, 1, -1);\r\n quadrant(map, field, origin, chebyshevRadius, -1, 1);\r\n quadrant(map, field, origin, chebyshevRadius, 1, 1);\r\n return field;\r\n}\r\nexports.computeFieldOfView = computeFieldOfView;\r\nfunction quadrant(map, field, origin, chebyshevRadius, xSign, ySign) {\r\n const { x: startX, y: startY } = origin;\r\n const endDX = (Math.min(Math.max(startX + xSign * (chebyshevRadius + 1), -1), map.width) - startX) * xSign;\r\n const endDY = (Math.min(Math.max(startY + ySign * (chebyshevRadius + 1), -1), map.height) - startY) * ySign;\r\n if (endDX < 0 || endDY < 0) {\r\n // the origin is outside of the map\r\n return;\r\n }\r\n const startMapIndex = map.index(origin.x, origin.y);\r\n const startMaskIndex = field.visible.index(origin.x, origin.y);\r\n // Initial wedge is from slope zero to slope infinity (i.e. the whole quadrant)\r\n let wedges = wedge_1.initWedges();\r\n for (let dy = 0, yMapIndex = startMapIndex, yMaskIndex = startMaskIndex; dy !== endDY && wedges.length > 0; dy++, yMapIndex += ySign * map.width, yMaskIndex += ySign * field.visible.width) {\r\n const divYpos = 1 / (dy + 0.5);\r\n const divYneg = dy === 0 ? Number.POSITIVE_INFINITY : 1 / (dy - 0.5);\r\n let wedgeIndex = 0;\r\n for (let dx = 0, mapIndex = yMapIndex, maskIndex = yMaskIndex, slopeY = -0.5 * divYpos, slopeX = 0.5 * divYneg; dx !== endDX && wedgeIndex !== wedges.length; dx++, mapIndex += xSign, maskIndex += xSign,\r\n slopeY += divYpos, slopeX += divYneg) {\r\n // the slopes of the four corners of this tile\r\n // these are named as follows:\r\n // slopeY is the slope closest to the Y axis\r\n // slopeX is the slope closest to the X axis\r\n // this is always true:\r\n // slopeY < slopeX\r\n //\r\n // O = origin, C = current\r\n // +---+---+---+\r\n // | O | | |\r\n // +---+---+---X\r\n // | | | C |\r\n // +---+---Y---+\r\n // advance the wedge index until this tile is not after the current wedge\r\n while (slopeY > wedges[wedgeIndex].high) {\r\n wedgeIndex++;\r\n if (wedgeIndex >= wedges.length) {\r\n break;\r\n }\r\n }\r\n if (wedgeIndex >= wedges.length) {\r\n break;\r\n }\r\n // if the current wedge is after this tile, move on\r\n if (slopeX < wedges[wedgeIndex].low) {\r\n continue;\r\n }\r\n // we can see this tile\r\n field.visible.setAtIndex(maskIndex, true);\r\n const body = (dx !== 0 || dy !== 0) && map.getBodyAtIndex(mapIndex);\r\n if (body) {\r\n wedges = wedge_1.cutWedges(wedges, slopeY + constants.BODY_INSET, slopeX - constants.BODY_INSET);\r\n }\r\n }\r\n }\r\n}\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.WEDGE_COUNT = exports.WEDGE_HIGH = exports.WEDGE_LOW = exports.BODY_INSET = void 0;\r\n/**\r\n * A smallish number, to adjust some wedges.\r\n */\r\nconst EPSILON = 0.00001;\r\n/**\r\n * Bodies in this algorithm do not entirely fill their tiles. This is\r\n * implemented by adjusting the angles of the shadows the bodies cast,\r\n * making the wedge very slightly narrower. BODY_INSET represents the\r\n * amount of reduction on either side of the wedge.\r\n */\r\nexports.BODY_INSET = EPSILON;\r\n/**\r\n * In the shadowcasting algorithm, each shadow is represented by a \"wedge\",\r\n * running from a \"low\" angle to a \"high\" angle. The wedges are all stored in\r\n * a simple number array, with two numbers for each wedge. These constants\r\n * (WEDGE_LOW and WEDGE_HIGH) help to identify which number is which.\r\n * WEDGE_COUNT is just how many numbers per wedge.\r\n */\r\nexports.WEDGE_LOW = 0;\r\nexports.WEDGE_HIGH = 1;\r\nexports.WEDGE_COUNT = 2;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n});\r\nvar __importStar = (this && this.__importStar) || function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.FieldOfViewImpl = void 0;\r\nconst geom = __importStar(require(\"tiled-geometry\"));\r\n/**\r\n * The FieldOfViewImpl class is the concrete implementation of the FieldOfView interface.\r\n */\r\nclass FieldOfViewImpl {\r\n constructor(origin, chebyshevRadius) {\r\n this.origin = origin;\r\n this.chebyshevRadius = chebyshevRadius;\r\n const boundRect = new geom.Rectangle(origin.x - chebyshevRadius, origin.y - chebyshevRadius, chebyshevRadius * 2 + 1, chebyshevRadius * 2 + 1);\r\n this.visible = new geom.MaskRectangle(boundRect);\r\n // the origin is always visible\r\n this.visible.setAtOffset(origin, true);\r\n }\r\n getVisible(x, y) {\r\n return this.visible.get(x, y);\r\n }\r\n toString() {\r\n let ret = '';\r\n for (const location of this.visible.locations()) {\r\n const { x, y } = location;\r\n if (this.origin.equals(location)) {\r\n ret += '@';\r\n }\r\n else if (this.getVisible(x, y)) {\r\n ret += '-';\r\n }\r\n else {\r\n ret += '.';\r\n }\r\n if (x === this.visible.westX + this.visible.width - 1) {\r\n ret += '\\n';\r\n }\r\n }\r\n return ret;\r\n }\r\n}\r\nexports.FieldOfViewImpl = FieldOfViewImpl;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n});\r\nvar __importStar = (this && this.__importStar) || function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.FieldOfViewMap = void 0;\r\nconst geom = __importStar(require(\"tiled-geometry\"));\r\n/**\r\n * For each number in the _tileFlags array, we store (1 << FLAGS_POW2) cells,\r\n * as bits where a true indicates the presence of a body.\r\n */\r\nconst FLAGS_POW2 = 5;\r\n/**\r\n * The FieldOfViewMap class describes the map over which the field of view will be\r\n * computed. It starts empty.\r\n */\r\nclass FieldOfViewMap {\r\n constructor(width, height) {\r\n this._size = new geom.Size();\r\n this._size.set(width, height);\r\n this._tileFlags = new Array((this._size.area >> FLAGS_POW2) + 1).fill(0);\r\n }\r\n get width() {\r\n return this._size.width;\r\n }\r\n get height() {\r\n return this._size.height;\r\n }\r\n // bodies\r\n addBody(x, y) {\r\n if (this._size.contains(x, y)) {\r\n const index = this.index(x, y);\r\n this._tileFlags[index >> FLAGS_POW2] |= 1 << (index & ((1 << FLAGS_POW2) - 1));\r\n }\r\n return this;\r\n }\r\n removeBody(x, y) {\r\n if (this._size.contains(x, y)) {\r\n const index = this.index(x, y);\r\n this._tileFlags[index >> FLAGS_POW2] &= ~(1 << (index & ((1 << FLAGS_POW2) - 1)));\r\n }\r\n return this;\r\n }\r\n getBody(x, y) {\r\n const index = this.index(x, y);\r\n return this.getBodyAtIndex(index);\r\n }\r\n // internal\r\n index(x, y) {\r\n return this._size.index(x, y);\r\n }\r\n getBodyAtIndex(index) {\r\n return (this._tileFlags[index >> FLAGS_POW2] & (1 << (index & ((1 << FLAGS_POW2) - 1)))) !== 0;\r\n }\r\n}\r\nexports.FieldOfViewMap = FieldOfViewMap;\r\n","\"use strict\";\r\n/*\r\n * TheField\r\n * github.com/sbj42/the-field\r\n * James Clark\r\n * Licensed under the MIT license.\r\n */\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.computeFieldOfView = exports.FieldOfViewMap = void 0;\r\nvar field_of_view_map_1 = require(\"./field-of-view-map\");\r\nObject.defineProperty(exports, \"FieldOfViewMap\", { enumerable: true, get: function () { return field_of_view_map_1.FieldOfViewMap; } });\r\nvar compute_1 = require(\"./compute\");\r\nObject.defineProperty(exports, \"computeFieldOfView\", { enumerable: true, get: function () { return compute_1.computeFieldOfView; } });\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cutWedges = exports.cutWedge = exports.initWedges = void 0;\r\n// istanbul ignore next\r\nfunction rangeToString(low, high) {\r\n return `${low.toFixed(7)}-${high.toFixed(7)}`;\r\n}\r\n// istanbul ignore next\r\nfunction wedgeToString(wedge) {\r\n return `{${rangeToString(wedge.low, wedge.high)}}`;\r\n}\r\n// istanbul ignore next\r\nfunction wedgesToString(wedges) {\r\n return `[${wedges.map(wedgeToString).join(', ')}]`;\r\n}\r\n// istanbul ignore next\r\nfunction debugLog(msg) {\r\n // eslint-disable-next-line no-console\r\n console.info(msg);\r\n}\r\nfunction initWedges() {\r\n return [{ low: 0, high: Number.POSITIVE_INFINITY }];\r\n}\r\nexports.initWedges = initWedges;\r\nconst DEBUG_CUTWEDGE = false;\r\n/**\r\n * This function cuts a range of angles out of a wedge.\r\n */\r\nfunction cutWedge(wedge, low, high) {\r\n // istanbul ignore next\r\n if (DEBUG_CUTWEDGE) {\r\n debugLog(`cut ${wedgeToString(wedge)} ${rangeToString(low, high)}`);\r\n }\r\n let ret;\r\n if (low <= wedge.low) {\r\n if (high >= wedge.high) {\r\n // wedge is entirely occluded, remove it\r\n ret = [];\r\n }\r\n else if (high >= wedge.low) {\r\n // low part of wedge is occluded, trim it\r\n wedge.low = high;\r\n ret = [wedge];\r\n }\r\n else {\r\n // cut doesn't reach the wedge\r\n ret = [wedge];\r\n }\r\n }\r\n else if (high >= wedge.high) {\r\n if (low <= wedge.high) {\r\n // high part of wedge is occluded, trim it\r\n wedge.high = low;\r\n ret = [wedge];\r\n }\r\n else {\r\n // cut doesn't reach the wedge\r\n ret = [wedge];\r\n }\r\n }\r\n else {\r\n // middle part of wedge is occluded, split it\r\n const nextWedge = {\r\n low: high,\r\n high: wedge.high,\r\n };\r\n wedge.high = low;\r\n ret = [wedge, nextWedge];\r\n }\r\n // istanbul ignore next\r\n if (DEBUG_CUTWEDGE) {\r\n debugLog(`--> ${wedgesToString(ret)}`);\r\n }\r\n return ret;\r\n}\r\nexports.cutWedge = cutWedge;\r\nfunction cutWedges(wedges, low, high) {\r\n const ret = new Array();\r\n for (const wedge of wedges) {\r\n ret.push(...cutWedge(wedge, low, high));\r\n }\r\n return ret;\r\n}\r\nexports.cutWedges = cutWedges;\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// module exports must be returned from runtime so entry inlining is disabled\n// startup\n// Load entry module and return exports\nreturn __webpack_require__(\"./src/index.ts\");\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://TheField/./node_modules/tiled-geometry/lib/compass/axis.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-direction-flags.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-direction.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-orientation.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-turn.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/direction.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/flip.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/index.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/turn.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/cardinal-path.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/index.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/mask-rectangle.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/mask.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/offset.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/raster-mask.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/rectangle.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/size.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/transform-rectangle.js","webpack://TheField/./node_modules/tiled-geometry/lib/index.js","webpack://TheField/./src/compute.ts","webpack://TheField/./src/constants.ts","webpack://TheField/./src/field-of-view-impl.ts","webpack://TheField/./src/field-of-view-map.ts","webpack://TheField/./src/index.ts","webpack://TheField/./src/wedge.ts","webpack://TheField/webpack/bootstrap","webpack://TheField/webpack/startup"],"names":[],"mappings":";;;;;;;;;;;AAAa;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,2BAA2B,GAAG,8BAA8B,GAAG,iCAAiC,GAAG,sBAAsB,GAAG,oBAAoB,GAAG,YAAY,GAAG,YAAY;AAC9K;AACA;AACA;AACA;AACA,CAAC,0BAA0B,YAAY,KAAK;AAC5C,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA,8BAA8B;AAC9B;AACA;AACA;AACA;AACA,2BAA2B;;;;;;;;;;;ACrCd;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,mDAAmD,GAAG,qDAAqD,GAAG,kDAAkD,GAAG,kDAAkD,GAAG,sCAAsC,GAAG,8BAA8B;AAC/R;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,8DAA8D,8BAA8B,KAAK;AAClG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA,kDAAkD;AAClD;AACA;AACA;AACA,kDAAkD;AAClD;AACA;AACA;AACA,qDAAqD;AACrD;AACA;AACA;AACA;AACA,mDAAmD;;;;;;;;;;;AC7CtC;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,wCAAwC,GAAG,gDAAgD,GAAG,sCAAsC,GAAG,sCAAsC,GAAG,iCAAiC,GAAG,iCAAiC,GAAG,2BAA2B,GAAG,yBAAyB;AAC/S;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,oDAAoD,yBAAyB,KAAK;AACnF,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA,gDAAgD;AAChD;AACA;AACA;AACA;AACA,wCAAwC;;;;;;;;;;;AC/C3B;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,0CAA0C,GAAG,uDAAuD,GAAG,kCAAkC,GAAG,+BAA+B,GAAG,mCAAmC,GAAG,6BAA6B,GAAG,2BAA2B;AAC/Q,eAAe,mBAAO,CAAC,iEAAQ;AAC/B,eAAe,mBAAO,CAAC,iEAAQ;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,wDAAwD,2BAA2B,KAAK;AACzF,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA,uDAAuD;AACvD;AACA;AACA;AACA;AACA,0CAA0C;;;;;;;;;;;ACtE7B;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,mCAAmC,GAAG,4BAA4B,GAAG,0CAA0C,GAAG,2BAA2B,GAAG,6BAA6B,GAAG,4BAA4B,GAAG,sBAAsB,GAAG,oBAAoB;AAC5P;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,0CAA0C,oBAAoB,KAAK;AACpE,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA,0CAA0C;AAC1C;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA;AACA,mCAAmC;;;;;;;;;;;AC/CtB;AACb,8CA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mBAAO,CAAC,iGAAwB;AAC7C,aAAa,mBAAO,CAAC,iEAAQ;;;;;;;;;;;ACnBhB;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,mBAAmB,GAAG,0BAA0B,GAAG,4BAA4B,GAAG,kCAAkC,GAAG,mBAAmB,GAAG,sBAAsB,GAAG,qBAAqB,GAAG,oBAAoB,GAAG,aAAa,GAAG,YAAY;AACjP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,0BAA0B,YAAY,KAAK;AAC5C,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA,mBAAmB;;;;;;;;;;;ACnEN;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,oBAAoB;AACpB,kBAAkB,mBAAO,CAAC,sEAAY;AACtC,iBAAiB,mBAAO,CAAC,kEAAU;AACnC,oBAAoB,mBAAO,CAAC,wEAAa;AACzC,sBAAsB,mBAAO,CAAC,4EAAe;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,uBAAuB;AACzC,iBAAiB,uFAAuF;AACxG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,OAAO;AACpB,eAAe;AACf;AACA;AACA;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qDAAqD,QAAQ;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS;AACxB;AACA,4BAA4B,YAAY;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,oBAAoB;;;;;;;;;;;AClIP;AACb;AACA;AACA,kCAAkC,oCAAoC,aAAa,EAAE,EAAE;AACvF,CAAC;AACD;AACA;AACA,CAAC;AACD;AACA;AACA;AACA,8CAA6C,CAAC,cAAc,EAAC;AAC7D,aAAa,mBAAO,CAAC,kEAAU;AAC/B,aAAa,mBAAO,CAAC,8DAAQ;AAC7B,aAAa,mBAAO,CAAC,wEAAa;AAClC,aAAa,mBAAO,CAAC,8DAAQ;AAC7B,aAAa,mBAAO,CAAC,kFAAkB;AACvC,aAAa,mBAAO,CAAC,4EAAe;AACpC,aAAa,mBAAO,CAAC,gFAAiB;AACtC,aAAa,mBAAO,CAAC,4FAAuB;;;;;;;;;;;ACnB/B;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,qBAAqB;AACrB,oBAAoB,mBAAO,CAAC,wEAAa;AACzC,eAAe,mBAAO,CAAC,8DAAQ;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,qBAAqB,GAAG,mBAAmB,IAAI,WAAW;AAC5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,QAAQ;AAC3B,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA,qBAAqB;;;;;;;;;;;ACrFR;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,YAAY;AACZ,eAAe,mBAAO,CAAC,8DAAQ;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,iBAAiB;AACxC,2BAA2B,gBAAgB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,OAAO;AAC3B;AACA,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,cAAc;AAClC;AACA,uBAAuB;AACvB;AACA;AACA;AACA;AACA,YAAY;;;;;;;;;;;ACjGC;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,cAAc;AACd,kBAAkB,mBAAO,CAAC,sEAAY;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,OAAO,GAAG,OAAO;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,cAAc;AAChD,sCAAsC,cAAc;AACpD;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;;;;;;;;;;;ACpGD;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,kBAAkB;AAClB,oBAAoB,mBAAO,CAAC,wEAAa;AACzC;AACA;AACA;AACA;AACA,sDAAsD,aAAa,cAAc,OAAO;AACxF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,uBAAuB,iBAAiB;AACxC;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,iBAAiB,GAAG,kBAAkB,KAAK,MAAM;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,iBAAiB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;;;;;;;;;;;ACzFL;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,iBAAiB;AACjB,eAAe,mBAAO,CAAC,8DAAQ;AAC/B,iBAAiB,mBAAO,CAAC,kEAAU;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,WAAW,GAAG,YAAY,GAAG,WAAW,GAAG,YAAY;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B,iCAAiC,aAAa;AAC9C,oCAAoC,YAAY;AAChD,uBAAuB;AACvB;AACA;AACA;AACA;AACA,oBAAoB,OAAO;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;;;;;;;;;;;ACxJJ;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,YAAY;AACZ,kBAAkB,mBAAO,CAAC,sEAAY;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,MAAM,GAAG,OAAO;AACzD;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,WAAW,GAAG,YAAY;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,MAAM,GAAG,OAAO;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,iBAAiB;AACxC,2BAA2B,gBAAgB;AAC3C,uBAAuB;AACvB;AACA;AACA;AACA;AACA,oBAAoB,OAAO;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;;;;;;;;;;;ACrFC;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,0BAA0B;AAC1B,oBAAoB,mBAAO,CAAC,wEAAa;AACzC,kBAAkB,mBAAO,CAAC,sEAAY;AACtC,iBAAiB,mBAAO,CAAC,kEAAU;AACnC,eAAe,mBAAO,CAAC,8DAAQ;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,WAAW;AAC9B,qBAAqB,mCAAmC,GAAG,6CAA6C,GAAG,gBAAgB;AAC3H,qBAAqB,iBAAiB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;;;;;;;;;;;ACzPb;AACb;AACA;AACA,kCAAkC,oCAAoC,aAAa,EAAE,EAAE;AACvF,CAAC;AACD;AACA;AACA,CAAC;AACD;AACA;AACA;AACA,8CAA6C,CAAC,cAAc,EAAC;AAC7D,aAAa,mBAAO,CAAC,qEAAW;AAChC,aAAa,mBAAO,CAAC,+DAAQ;;;;;;;;;;;ACbhB;AACb;AACA;AACA,kCAAkC,oCAAoC,aAAa,EAAE,EAAE;AACvF,CAAC;AACD;AACA;AACA,CAAC;AACD;AACA,yCAAyC,6BAA6B;AACtE,CAAC;AACD;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA6C,CAAC,cAAc,EAAC;AAC7D,0BAA0B;AAC1B,0BAA0B,mBAAO,CAAC,kEAAgB;AAClD,+BAA+B,mBAAO,CAAC,uCAAa;AACpD,6BAA6B,mBAAO,CAAC,yDAAsB;AAC3D,gBAAgB,mBAAO,CAAC,+BAAS;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA,WAAW,uBAAuB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4EAA4E,mCAAmC;AAC/G;AACA;AACA;AACA,uHAAuH,8CAA8C;AACrK;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;ACpGa;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,mBAAmB,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,kBAAkB;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB,kBAAkB;AAClB,mBAAmB;;;;;;;;;;;ACvBN;AACb;AACA;AACA,kCAAkC,oCAAoC,aAAa,EAAE,EAAE;AACvF,CAAC;AACD;AACA;AACA,CAAC;AACD;AACA,yCAAyC,6BAA6B;AACtE,CAAC;AACD;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA6C,CAAC,cAAc,EAAC;AAC7D,uBAAuB;AACvB,0BAA0B,mBAAO,CAAC,kEAAgB;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;;;;;;;;;;;AC1DV;AACb;AACA;AACA,kCAAkC,oCAAoC,aAAa,EAAE,EAAE;AACvF,CAAC;AACD;AACA;AACA,CAAC;AACD;AACA,yCAAyC,6BAA6B;AACtE,CAAC;AACD;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA6C,CAAC,cAAc,EAAC;AAC7D,sBAAsB;AACtB,0BAA0B,mBAAO,CAAC,kEAAgB;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;;;;;;;;;;;ACvET;AACb;AACA;AACA;AACA;AACA;AACA;AACA,8CAA6C,CAAC,cAAc,EAAC;AAC7D,0BAA0B,GAAG,sBAAsB;AACnD,0BAA0B,mBAAO,CAAC,uDAAqB;AACvD,kDAAiD,CAAC,qCAAqC,2CAA2C,EAAE,EAAE,EAAC;AACvI,gBAAgB,mBAAO,CAAC,mCAAW;AACnC,sDAAqD,CAAC,qCAAqC,qCAAqC,EAAE,EAAE,EAAC;;;;;;;;;;;ACZxH;AACb,8CAA6C,CAAC,cAAc,EAAC;AAC7D,iBAAiB,GAAG,gBAAgB,GAAG,kBAAkB;AACzD;AACA;AACA,cAAc,eAAe,GAAG,gBAAgB;AAChD;AACA;AACA;AACA,aAAa,EAAE,sCAAsC;AACrD;AACA;AACA;AACA,eAAe,qCAAqC;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,yCAAyC;AACtD;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,qBAAqB,GAAG,yBAAyB;AACzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,oBAAoB;AAC5C;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;;;;;;;UCnFjB;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;UCrBA;UACA;UACA;UACA","file":"the-field-2.0.1.js","sourcesContent":["\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.axisAddCardinalTurn = exports.axisFromNorthSouthTurn = exports.axisFromCardinalDirection = exports.axisOrthogonal = exports.axisToString = exports.AXES = exports.Axis = void 0;\r\nvar Axis;\r\n(function (Axis) {\r\n Axis[Axis[\"NORTH_SOUTH\"] = 0] = \"NORTH_SOUTH\";\r\n Axis[Axis[\"WEST_EAST\"] = 1] = \"WEST_EAST\";\r\n})(Axis = exports.Axis || (exports.Axis = {}));\r\nexports.AXES = [\r\n Axis.NORTH_SOUTH,\r\n Axis.WEST_EAST,\r\n];\r\nconst AXES_STR = [\r\n 'N-S',\r\n 'W-E',\r\n];\r\nfunction axisToString(axis) {\r\n return AXES_STR[axis];\r\n}\r\nexports.axisToString = axisToString;\r\nfunction axisOrthogonal(axis) {\r\n return (axis ^ 1);\r\n}\r\nexports.axisOrthogonal = axisOrthogonal;\r\n// conversion\r\nfunction axisFromCardinalDirection(dir) {\r\n return (dir & 1);\r\n}\r\nexports.axisFromCardinalDirection = axisFromCardinalDirection;\r\nfunction axisFromNorthSouthTurn(turn) {\r\n return (turn & 1);\r\n}\r\nexports.axisFromNorthSouthTurn = axisFromNorthSouthTurn;\r\n// math\r\nfunction axisAddCardinalTurn(axis, turn) {\r\n return ((axis + turn) & 1);\r\n}\r\nexports.axisAddCardinalTurn = axisAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalDirectionFlagsFromCardinalDirection = exports.cardinalDirectionFlagsRemoveCardinalDirection = exports.cardinalDirectionFlagsSetCardinalDirection = exports.cardinalDirectionFlagsHasCardinalDirection = exports.cardinalDirectionFlagsToString = exports.CardinalDirectionFlags = void 0;\r\nvar CardinalDirectionFlags;\r\n(function (CardinalDirectionFlags) {\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"NONE\"] = 0] = \"NONE\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"NORTH\"] = 1] = \"NORTH\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"EAST\"] = 2] = \"EAST\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"SOUTH\"] = 4] = \"SOUTH\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"WEST\"] = 8] = \"WEST\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"ALL\"] = 15] = \"ALL\";\r\n})(CardinalDirectionFlags = exports.CardinalDirectionFlags || (exports.CardinalDirectionFlags = {}));\r\nfunction cardinalDirectionFlagsToString(flags) {\r\n let ret = '[';\r\n if ((flags & CardinalDirectionFlags.NORTH) !== 0) {\r\n ret += 'N';\r\n }\r\n if ((flags & CardinalDirectionFlags.EAST) !== 0) {\r\n ret += 'E';\r\n }\r\n if ((flags & CardinalDirectionFlags.SOUTH) !== 0) {\r\n ret += 'S';\r\n }\r\n if ((flags & CardinalDirectionFlags.WEST) !== 0) {\r\n ret += 'W';\r\n }\r\n return ret + ']';\r\n}\r\nexports.cardinalDirectionFlagsToString = cardinalDirectionFlagsToString;\r\nfunction cardinalDirectionFlagsHasCardinalDirection(flags, dir) {\r\n return (flags & cardinalDirectionFlagsFromCardinalDirection(dir)) !== 0;\r\n}\r\nexports.cardinalDirectionFlagsHasCardinalDirection = cardinalDirectionFlagsHasCardinalDirection;\r\nfunction cardinalDirectionFlagsSetCardinalDirection(flags, dir) {\r\n return (flags | cardinalDirectionFlagsFromCardinalDirection(dir));\r\n}\r\nexports.cardinalDirectionFlagsSetCardinalDirection = cardinalDirectionFlagsSetCardinalDirection;\r\nfunction cardinalDirectionFlagsRemoveCardinalDirection(flags, dir) {\r\n return (flags & ~cardinalDirectionFlagsFromCardinalDirection(dir));\r\n}\r\nexports.cardinalDirectionFlagsRemoveCardinalDirection = cardinalDirectionFlagsRemoveCardinalDirection;\r\n// conversion\r\nfunction cardinalDirectionFlagsFromCardinalDirection(dir) {\r\n return (1 << dir);\r\n}\r\nexports.cardinalDirectionFlagsFromCardinalDirection = cardinalDirectionFlagsFromCardinalDirection;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalDirectionAddCardinalTurn = exports.cardinalDirectionFromCardinalOrientation = exports.cardinalDirectionFromNorthTurn = exports.cardinalDirectionFromDirection = exports.cardinalDirectionOpposite = exports.cardinalDirectionToString = exports.CARDINAL_DIRECTIONS = exports.CardinalDirection = void 0;\r\nvar CardinalDirection;\r\n(function (CardinalDirection) {\r\n CardinalDirection[CardinalDirection[\"NORTH\"] = 0] = \"NORTH\";\r\n CardinalDirection[CardinalDirection[\"EAST\"] = 1] = \"EAST\";\r\n CardinalDirection[CardinalDirection[\"SOUTH\"] = 2] = \"SOUTH\";\r\n CardinalDirection[CardinalDirection[\"WEST\"] = 3] = \"WEST\";\r\n})(CardinalDirection = exports.CardinalDirection || (exports.CardinalDirection = {}));\r\nexports.CARDINAL_DIRECTIONS = [\r\n CardinalDirection.NORTH,\r\n CardinalDirection.EAST,\r\n CardinalDirection.SOUTH,\r\n CardinalDirection.WEST,\r\n];\r\nconst CARDINAL_DIRECTIONS_STR = [\r\n 'N',\r\n 'E',\r\n 'S',\r\n 'W',\r\n];\r\nfunction cardinalDirectionToString(dir) {\r\n return CARDINAL_DIRECTIONS_STR[dir];\r\n}\r\nexports.cardinalDirectionToString = cardinalDirectionToString;\r\nfunction cardinalDirectionOpposite(dir) {\r\n return ((dir + 2) & 3);\r\n}\r\nexports.cardinalDirectionOpposite = cardinalDirectionOpposite;\r\n// conversion\r\nfunction cardinalDirectionFromDirection(dir) {\r\n return (dir >> 1);\r\n}\r\nexports.cardinalDirectionFromDirection = cardinalDirectionFromDirection;\r\nfunction cardinalDirectionFromNorthTurn(turn) {\r\n return turn;\r\n}\r\nexports.cardinalDirectionFromNorthTurn = cardinalDirectionFromNorthTurn;\r\nfunction cardinalDirectionFromCardinalOrientation(orientation) {\r\n return (orientation >>> 1);\r\n}\r\nexports.cardinalDirectionFromCardinalOrientation = cardinalDirectionFromCardinalOrientation;\r\n// math\r\nfunction cardinalDirectionAddCardinalTurn(dir, turn) {\r\n return ((dir + turn) & 3);\r\n}\r\nexports.cardinalDirectionAddCardinalTurn = cardinalDirectionAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalOrientationAddCardinalTurn = exports.cardinalOrientationFromFlipAndCardinalDirection = exports.cardinalOrientationReverse = exports.cardinalOrientationFlip = exports.cardinalOrientationToString = exports.CARDINAL_ORIENTATIONS = exports.CardinalOrientation = void 0;\r\nconst axis_1 = require(\"./axis\");\r\nconst flip_1 = require(\"./flip\");\r\nvar CardinalOrientation;\r\n(function (CardinalOrientation) {\r\n CardinalOrientation[CardinalOrientation[\"HEADS_NORTH\"] = 0] = \"HEADS_NORTH\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_NORTH\"] = 1] = \"TAILS_NORTH\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_EAST\"] = 2] = \"HEADS_EAST\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_EAST\"] = 3] = \"TAILS_EAST\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_SOUTH\"] = 4] = \"HEADS_SOUTH\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_SOUTH\"] = 5] = \"TAILS_SOUTH\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_WEST\"] = 6] = \"HEADS_WEST\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_WEST\"] = 7] = \"TAILS_WEST\";\r\n})(CardinalOrientation = exports.CardinalOrientation || (exports.CardinalOrientation = {}));\r\nexports.CARDINAL_ORIENTATIONS = [\r\n CardinalOrientation.HEADS_NORTH,\r\n CardinalOrientation.TAILS_NORTH,\r\n CardinalOrientation.HEADS_EAST,\r\n CardinalOrientation.TAILS_EAST,\r\n CardinalOrientation.HEADS_SOUTH,\r\n CardinalOrientation.TAILS_SOUTH,\r\n CardinalOrientation.HEADS_WEST,\r\n CardinalOrientation.TAILS_WEST,\r\n];\r\nconst CARDINAL_ORIENTATIONS_STR = [\r\n 'HN',\r\n 'TN',\r\n 'HE',\r\n 'TE',\r\n 'HS',\r\n 'TS',\r\n 'HW',\r\n 'TW',\r\n];\r\nfunction cardinalOrientationToString(orientation) {\r\n return CARDINAL_ORIENTATIONS_STR[orientation];\r\n}\r\nexports.cardinalOrientationToString = cardinalOrientationToString;\r\nfunction cardinalOrientationFlip(orientation, axis) {\r\n if (axis === axis_1.Axis.NORTH_SOUTH) {\r\n return ((9 - orientation) & 7);\r\n }\r\n else {\r\n return ((13 - orientation) & 7);\r\n }\r\n}\r\nexports.cardinalOrientationFlip = cardinalOrientationFlip;\r\nfunction cardinalOrientationReverse(orientation) {\r\n if (orientation === CardinalOrientation.HEADS_EAST) {\r\n return CardinalOrientation.HEADS_WEST;\r\n }\r\n else if (orientation === CardinalOrientation.HEADS_WEST) {\r\n return CardinalOrientation.HEADS_EAST;\r\n }\r\n else {\r\n return orientation;\r\n }\r\n}\r\nexports.cardinalOrientationReverse = cardinalOrientationReverse;\r\n// conversion\r\nfunction cardinalOrientationFromFlipAndCardinalDirection(flip, dir) {\r\n return (dir * 2 + (flip !== flip_1.Flip.HEADS ? 1 : 0));\r\n}\r\nexports.cardinalOrientationFromFlipAndCardinalDirection = cardinalOrientationFromFlipAndCardinalDirection;\r\n// math\r\nfunction cardinalOrientationAddCardinalTurn(orientation, turn) {\r\n return ((orientation + turn * 2) & 7);\r\n}\r\nexports.cardinalOrientationAddCardinalTurn = cardinalOrientationAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalTurnAddCardinalTurn = exports.cardinalTurnFromTurn = exports.cardinalTurnFromCardinalDirections = exports.cardinalTurnReverse = exports.cardinalTurnToDegrees = exports.cardinalTurnToString = exports.CARDINAL_TURNS = exports.CardinalTurn = void 0;\r\nvar CardinalTurn;\r\n(function (CardinalTurn) {\r\n CardinalTurn[CardinalTurn[\"NONE\"] = 0] = \"NONE\";\r\n CardinalTurn[CardinalTurn[\"RIGHT\"] = 1] = \"RIGHT\";\r\n CardinalTurn[CardinalTurn[\"AROUND\"] = 2] = \"AROUND\";\r\n CardinalTurn[CardinalTurn[\"LEFT\"] = 3] = \"LEFT\";\r\n})(CardinalTurn = exports.CardinalTurn || (exports.CardinalTurn = {}));\r\nexports.CARDINAL_TURNS = [\r\n CardinalTurn.NONE,\r\n CardinalTurn.RIGHT,\r\n CardinalTurn.AROUND,\r\n CardinalTurn.LEFT,\r\n];\r\nconst CARDINAL_TURNS_STR = [\r\n 'T0',\r\n 'T+90',\r\n 'T180',\r\n 'T-90',\r\n];\r\nfunction cardinalTurnToString(dir) {\r\n return CARDINAL_TURNS_STR[dir];\r\n}\r\nexports.cardinalTurnToString = cardinalTurnToString;\r\nfunction cardinalTurnToDegrees(turn) {\r\n return turn * 90;\r\n}\r\nexports.cardinalTurnToDegrees = cardinalTurnToDegrees;\r\nfunction cardinalTurnReverse(dir) {\r\n return ((4 - dir) & 3);\r\n}\r\nexports.cardinalTurnReverse = cardinalTurnReverse;\r\n// conversion\r\nfunction cardinalTurnFromCardinalDirections(from, to) {\r\n return ((to - from) & 3);\r\n}\r\nexports.cardinalTurnFromCardinalDirections = cardinalTurnFromCardinalDirections;\r\nfunction cardinalTurnFromTurn(turn) {\r\n return (turn >> 1);\r\n}\r\nexports.cardinalTurnFromTurn = cardinalTurnFromTurn;\r\n// math\r\nfunction cardinalTurnAddCardinalTurn(turn1, turn2) {\r\n return ((turn1 + turn2) & 3);\r\n}\r\nexports.cardinalTurnAddCardinalTurn = cardinalTurnAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.directionAddCardinalTurn = exports.directionAddTurn = exports.directionFromCardinalDirection = exports.directionOpposite = exports.directionIsCardinal = exports.directionToString = exports.DIRECTIONS = exports.Direction = void 0;\r\nvar Direction;\r\n(function (Direction) {\r\n Direction[Direction[\"NORTH\"] = 0] = \"NORTH\";\r\n Direction[Direction[\"NORTHEAST\"] = 1] = \"NORTHEAST\";\r\n Direction[Direction[\"EAST\"] = 2] = \"EAST\";\r\n Direction[Direction[\"SOUTHEAST\"] = 3] = \"SOUTHEAST\";\r\n Direction[Direction[\"SOUTH\"] = 4] = \"SOUTH\";\r\n Direction[Direction[\"SOUTHWEST\"] = 5] = \"SOUTHWEST\";\r\n Direction[Direction[\"WEST\"] = 6] = \"WEST\";\r\n Direction[Direction[\"NORTHWEST\"] = 7] = \"NORTHWEST\";\r\n})(Direction = exports.Direction || (exports.Direction = {}));\r\nexports.DIRECTIONS = [\r\n Direction.NORTH,\r\n Direction.NORTHEAST,\r\n Direction.EAST,\r\n Direction.SOUTHEAST,\r\n Direction.SOUTH,\r\n Direction.SOUTHWEST,\r\n Direction.WEST,\r\n Direction.NORTHWEST,\r\n];\r\nconst DIRECTIONS_STR = [\r\n 'N',\r\n 'NE',\r\n 'E',\r\n 'SE',\r\n 'S',\r\n 'SW',\r\n 'W',\r\n 'NW',\r\n];\r\nfunction directionToString(dir) {\r\n return DIRECTIONS_STR[dir];\r\n}\r\nexports.directionToString = directionToString;\r\nfunction directionIsCardinal(dir) {\r\n return (dir & 1) === 0;\r\n}\r\nexports.directionIsCardinal = directionIsCardinal;\r\nfunction directionOpposite(dir) {\r\n return ((dir + 4) & 7);\r\n}\r\nexports.directionOpposite = directionOpposite;\r\n// conversion\r\nfunction directionFromCardinalDirection(dir) {\r\n return (dir << 1);\r\n}\r\nexports.directionFromCardinalDirection = directionFromCardinalDirection;\r\n// math\r\nfunction directionAddTurn(dir, turn) {\r\n return ((dir + turn) & 7);\r\n}\r\nexports.directionAddTurn = directionAddTurn;\r\nfunction directionAddCardinalTurn(dir, turn) {\r\n return ((dir + turn * 2) & 7);\r\n}\r\nexports.directionAddCardinalTurn = directionAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.flipFromCardinalOrientation = exports.flipFromBoolean = exports.flipOpposite = exports.flipToString = exports.FLIPS = exports.Flip = void 0;\r\nvar Flip;\r\n(function (Flip) {\r\n Flip[Flip[\"HEADS\"] = 0] = \"HEADS\";\r\n Flip[Flip[\"TAILS\"] = 1] = \"TAILS\";\r\n})(Flip = exports.Flip || (exports.Flip = {}));\r\nexports.FLIPS = [\r\n Flip.HEADS,\r\n Flip.TAILS,\r\n];\r\nconst FLIPS_STR = [\r\n 'H',\r\n 'T',\r\n];\r\nfunction flipToString(flip) {\r\n return FLIPS_STR[flip];\r\n}\r\nexports.flipToString = flipToString;\r\nfunction flipOpposite(flip) {\r\n return (flip ^ 1);\r\n}\r\nexports.flipOpposite = flipOpposite;\r\n// conversion\r\nfunction flipFromBoolean(tails) {\r\n return tails ? Flip.TAILS : Flip.HEADS;\r\n}\r\nexports.flipFromBoolean = flipFromBoolean;\r\nfunction flipFromCardinalOrientation(orientation) {\r\n return (orientation & 1);\r\n}\r\nexports.flipFromCardinalOrientation = flipFromCardinalOrientation;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./direction\"), exports);\r\n__exportStar(require(\"./turn\"), exports);\r\n__exportStar(require(\"./cardinal-direction\"), exports);\r\n__exportStar(require(\"./cardinal-turn\"), exports);\r\n__exportStar(require(\"./cardinal-direction-flags\"), exports);\r\n__exportStar(require(\"./flip\"), exports);\r\n__exportStar(require(\"./cardinal-orientation\"), exports);\r\n__exportStar(require(\"./axis\"), exports);\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.turnAddTurn = exports.turnFromDirections = exports.turnFromCardinalTurn = exports.turnFromCardinalDirections = exports.turnReverse = exports.turnIsCardinal = exports.turnToDegrees = exports.turnToString = exports.TURNS = exports.Turn = void 0;\r\nvar Turn;\r\n(function (Turn) {\r\n Turn[Turn[\"NONE\"] = 0] = \"NONE\";\r\n Turn[Turn[\"R_45\"] = 1] = \"R_45\";\r\n Turn[Turn[\"R_90\"] = 2] = \"R_90\";\r\n Turn[Turn[\"R_135\"] = 3] = \"R_135\";\r\n Turn[Turn[\"T_180\"] = 4] = \"T_180\";\r\n Turn[Turn[\"L_135\"] = 5] = \"L_135\";\r\n Turn[Turn[\"L_90\"] = 6] = \"L_90\";\r\n Turn[Turn[\"L_45\"] = 7] = \"L_45\";\r\n})(Turn = exports.Turn || (exports.Turn = {}));\r\nexports.TURNS = [\r\n Turn.NONE,\r\n Turn.R_45,\r\n Turn.R_90,\r\n Turn.R_135,\r\n Turn.T_180,\r\n Turn.L_135,\r\n Turn.L_90,\r\n Turn.L_45,\r\n];\r\nconst TURNS_STR = [\r\n 'T0',\r\n 'T+45',\r\n 'T+90',\r\n 'T+135',\r\n 'T180',\r\n 'T-135',\r\n 'T-90',\r\n 'T-45',\r\n];\r\nfunction turnToString(turn) {\r\n return TURNS_STR[turn];\r\n}\r\nexports.turnToString = turnToString;\r\nfunction turnToDegrees(turn) {\r\n return turn * 45;\r\n}\r\nexports.turnToDegrees = turnToDegrees;\r\nfunction turnIsCardinal(turn) {\r\n return (turn & 1) === 0;\r\n}\r\nexports.turnIsCardinal = turnIsCardinal;\r\nfunction turnReverse(turn) {\r\n return ((8 - turn) & 7);\r\n}\r\nexports.turnReverse = turnReverse;\r\n// conversion\r\nfunction turnFromCardinalDirections(from, to) {\r\n return (((to - from) * 2) & 7);\r\n}\r\nexports.turnFromCardinalDirections = turnFromCardinalDirections;\r\nfunction turnFromCardinalTurn(turn) {\r\n return (turn << 1);\r\n}\r\nexports.turnFromCardinalTurn = turnFromCardinalTurn;\r\nfunction turnFromDirections(from, to) {\r\n return ((to - from) & 7);\r\n}\r\nexports.turnFromDirections = turnFromDirections;\r\n// math\r\nfunction turnAddTurn(turn1, turn2) {\r\n return ((turn1 + turn2) & 7);\r\n}\r\nexports.turnAddTurn = turnAddTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.CardinalPath = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nconst offset_1 = require(\"./offset\");\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst raster_mask_1 = require(\"./raster-mask\");\r\nconst LOCAL_OFF = new offset_1.Offset();\r\nfunction sortedInsert(array, value) {\r\n array.push(value);\r\n let i = array.length - 1;\r\n while (i > 0 && value < array[i - 1]) {\r\n array[i] = array[i - 1];\r\n i--;\r\n }\r\n array[i] = value;\r\n}\r\nclass CardinalPath {\r\n constructor(start, segments) {\r\n this._start = new offset_1.Offset();\r\n this._start.copyFrom(start);\r\n this._segments = segments;\r\n }\r\n // accessors\r\n toString() {\r\n return `${this._start.toString()}:`\r\n + `${this._segments.map((segment) => compass_1.cardinalDirectionToString(segment)).join('')}`;\r\n }\r\n equals(other) {\r\n return this._start.equals(other._start)\r\n && this._segments.length === other._segments.length\r\n && this._segments.every((v, i) => v === other._segments[i]);\r\n }\r\n get length() {\r\n return this._segments.length;\r\n }\r\n // utilities\r\n getIsClosed() {\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n }\r\n return this._start.equals(LOCAL_OFF);\r\n }\r\n *offsets() {\r\n let { x, y } = this._start;\r\n yield { x, y };\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.setFromCardinalDirection(segment);\r\n x += LOCAL_OFF.x;\r\n y += LOCAL_OFF.y;\r\n yield { x, y };\r\n }\r\n }\r\n getBounds() {\r\n let northY = this._start.y;\r\n let southY = northY;\r\n let westX = this._start.x;\r\n let eastX = westX;\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n switch (segment) {\r\n case compass_1.CardinalDirection.NORTH:\r\n northY = Math.min(northY, LOCAL_OFF.y);\r\n break;\r\n case compass_1.CardinalDirection.EAST:\r\n eastX = Math.max(eastX, LOCAL_OFF.x);\r\n break;\r\n case compass_1.CardinalDirection.SOUTH:\r\n southY = Math.max(southY, LOCAL_OFF.y);\r\n break;\r\n case compass_1.CardinalDirection.WEST:\r\n westX = Math.min(westX, LOCAL_OFF.x);\r\n break;\r\n // istanbul ignore next\r\n default:\r\n throw new Error(`bad direction ${segment} in cardinal path`);\r\n }\r\n }\r\n return new rectangle_1.Rectangle(westX, northY, eastX - westX + 1, southY - northY + 1);\r\n }\r\n getArea() {\r\n let total = 0;\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n switch (segment) {\r\n case compass_1.CardinalDirection.NORTH:\r\n total -= LOCAL_OFF.x;\r\n break;\r\n case compass_1.CardinalDirection.SOUTH:\r\n total += LOCAL_OFF.x;\r\n break;\r\n }\r\n }\r\n return Math.abs(total);\r\n }\r\n rasterize(bounds) {\r\n const lines = new Array();\r\n if (typeof bounds === 'undefined') {\r\n bounds = this.getBounds();\r\n }\r\n // assert(this.getIsClosed())\r\n LOCAL_OFF.copyFrom(this._start);\r\n const { northY } = bounds;\r\n const southY = northY + bounds.height - 1;\r\n for (let y = northY; y < southY; y++) {\r\n lines.push([]);\r\n }\r\n LOCAL_OFF.copyFrom(this._start);\r\n // assert(LOCAL_OFF.y >= northY && LOCAL_OFF.y <= southY)\r\n for (const segment of this._segments) {\r\n if (segment === compass_1.CardinalDirection.SOUTH) {\r\n sortedInsert(lines[LOCAL_OFF.y - northY], LOCAL_OFF.x);\r\n }\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n // assert(LOCAL_OFF.y >= northY && LOCAL_OFF.y <= southY)\r\n if (segment === compass_1.CardinalDirection.NORTH) {\r\n sortedInsert(lines[LOCAL_OFF.y - northY], LOCAL_OFF.x);\r\n }\r\n }\r\n return new raster_mask_1.RasterMask({\r\n westX: bounds.westX,\r\n northY: bounds.northY,\r\n width: bounds.width - 1,\r\n height: bounds.height - 1,\r\n }, lines);\r\n }\r\n}\r\nexports.CardinalPath = CardinalPath;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./offset\"), exports);\r\n__exportStar(require(\"./size\"), exports);\r\n__exportStar(require(\"./rectangle\"), exports);\r\n__exportStar(require(\"./mask\"), exports);\r\n__exportStar(require(\"./mask-rectangle\"), exports);\r\n__exportStar(require(\"./raster-mask\"), exports);\r\n__exportStar(require(\"./cardinal-path\"), exports);\r\n__exportStar(require(\"./transform-rectangle\"), exports);\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.MaskRectangle = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst mask_1 = require(\"./mask\");\r\nclass MaskRectangle {\r\n constructor(rect, initialValue = false, outsideValue = false) {\r\n this._rect = new rectangle_1.Rectangle();\r\n if (typeof rect !== 'undefined') {\r\n this._rect.copyFrom(rect);\r\n }\r\n this._mask = new mask_1.Mask(rect, initialValue);\r\n this._outsideValue = outsideValue;\r\n }\r\n // accessors\r\n toString() {\r\n return `${this._rect.northWest}/${this._outsideValue}\\n${this._mask}`;\r\n }\r\n equals(other) {\r\n return this._rect.equals(other._rect)\r\n && this._mask.equals(other._mask)\r\n && this._outsideValue === other._outsideValue;\r\n }\r\n get westX() {\r\n return this._rect.westX;\r\n }\r\n get northY() {\r\n return this._rect.northY;\r\n }\r\n get width() {\r\n return this._rect.width;\r\n }\r\n get height() {\r\n return this._rect.height;\r\n }\r\n get(x, y) {\r\n if (!this._rect.contains(x, y)) {\r\n return this._outsideValue;\r\n }\r\n return this._mask.get(x - this.westX, y - this.northY);\r\n }\r\n getAtIndex(index) {\r\n return this._mask.getAtIndex(index);\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._rect.copyFrom(other._rect);\r\n this._mask.copyFrom(other._mask);\r\n this._outsideValue = other._outsideValue;\r\n return this;\r\n }\r\n set(x, y, value) {\r\n this._mask.set(x - this.westX, y - this.northY, value);\r\n return this;\r\n }\r\n setAtOffset(off, value) {\r\n return this.set(off.x, off.y, value);\r\n }\r\n setAtIndex(index, value) {\r\n this._mask.setAtIndex(index, value);\r\n return this;\r\n }\r\n // utilities\r\n index(x, y) {\r\n return this._mask.index(x - this.westX, y - this.northY);\r\n }\r\n *locations() {\r\n for (const loc of this._mask.locations()) {\r\n const x = loc.x + this.westX;\r\n const y = loc.y + this.northY;\r\n const { value } = loc;\r\n yield { x, y, value };\r\n }\r\n }\r\n *offsetsWithTrue() {\r\n for (const off of this._mask.offsetsWithTrue()) {\r\n const x = off.x + this.westX;\r\n const y = off.y + this.northY;\r\n yield { x, y };\r\n }\r\n }\r\n}\r\nexports.MaskRectangle = MaskRectangle;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Mask = void 0;\r\nconst size_1 = require(\"./size\");\r\nclass Mask {\r\n constructor(size, initialValue = false) {\r\n this._size = new size_1.Size();\r\n if (typeof size !== 'undefined') {\r\n this._size.copyFrom(size);\r\n }\r\n this._bits = new Array(Math.ceil(this._size.area / 32)).fill(initialValue ? 0xffffffff : 0);\r\n }\r\n // accessors\r\n toString() {\r\n let ret = '';\r\n for (let y = 0; y < this.height; y++) {\r\n for (let x = 0; x < this.width; x++) {\r\n ret += this.get(x, y) ? '☑' : '☐';\r\n }\r\n ret += '\\n';\r\n }\r\n return ret;\r\n }\r\n equals(other) {\r\n return this._size.equals(other._size)\r\n && this._bits.length === other._bits.length\r\n && this._bits.every((v, i) => v === other._bits[i]);\r\n }\r\n get width() {\r\n return this._size.width;\r\n }\r\n get height() {\r\n return this._size.height;\r\n }\r\n get(x, y) {\r\n return this.getAtIndex(this.index(x, y));\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n getAtIndex(index) {\r\n // assert(index >= 0 && index < this._size.area)\r\n const arrayIndex = index >>> 5;\r\n const bitMask = 1 << (index & 31);\r\n return (this._bits[arrayIndex] & bitMask) !== 0;\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._size.copyFrom(other._size);\r\n this._bits = other._bits.slice();\r\n return this;\r\n }\r\n set(x, y, value) {\r\n return this.setAtIndex(this.index(x, y), value);\r\n }\r\n setAtOffset(off, value) {\r\n return this.set(off.x, off.y, value);\r\n }\r\n setAtIndex(index, value) {\r\n // assert(index >= 0 && index < this._size.area)\r\n const arrayIndex = index >>> 5;\r\n const bitMask = 1 << (index & 31);\r\n if (value) {\r\n this._bits[arrayIndex] |= bitMask;\r\n }\r\n else {\r\n this._bits[arrayIndex] &= ~bitMask;\r\n }\r\n return this;\r\n }\r\n // utilities\r\n index(x, y) {\r\n return this._size.index(x, y);\r\n }\r\n *locations() {\r\n let arrayIndex = 0;\r\n let bitMask = 1;\r\n for (const { x, y } of this._size.offsets()) {\r\n const value = (this._bits[arrayIndex] & bitMask) !== 0;\r\n yield { x, y, value };\r\n if (bitMask === (1 << 31)) {\r\n bitMask = 1;\r\n arrayIndex++;\r\n }\r\n else {\r\n bitMask <<= 1;\r\n }\r\n }\r\n }\r\n *offsetsWithTrue() {\r\n for (const { x, y, value } of this.locations()) {\r\n if (value) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n}\r\nexports.Mask = Mask;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Offset = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nconst X_FROM_DIRECTION = [0, 1, 1, 1, 0, -1, -1, -1];\r\nconst Y_FROM_DIRECTION = [-1, -1, 0, 1, 1, 1, 0, -1];\r\nconst X_FROM_CARDINAL_DIRECTION = [0, 1, 0, -1];\r\nconst Y_FROM_CARDINAL_DIRECTION = [-1, 0, 1, 0];\r\nclass Offset {\r\n constructor(x, y) {\r\n if (typeof x === 'undefined') {\r\n x = 0;\r\n }\r\n if (typeof y === 'undefined') {\r\n y = 0;\r\n }\r\n this.x = x;\r\n this.y = y;\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.x},${this.y})`;\r\n }\r\n equals(other) {\r\n return this.x === other.x && this.y === other.y;\r\n }\r\n // mutators\r\n set(x, y) {\r\n this.x = x;\r\n this.y = y;\r\n return this;\r\n }\r\n copyFrom(other) {\r\n return this.set(other.x, other.y);\r\n }\r\n setFromDirection(dir) {\r\n return this.set(X_FROM_DIRECTION[dir], Y_FROM_DIRECTION[dir]);\r\n }\r\n setFromCardinalDirection(dir) {\r\n return this.set(X_FROM_CARDINAL_DIRECTION[dir], Y_FROM_CARDINAL_DIRECTION[dir]);\r\n }\r\n add(x, y) {\r\n this.x += x;\r\n this.y += y;\r\n return this;\r\n }\r\n addSize(size) {\r\n return this.add(size.width, size.height);\r\n }\r\n addOffset(off) {\r\n return this.add(off.x, off.y);\r\n }\r\n addDirection(dir) {\r\n return this.add(X_FROM_DIRECTION[dir], Y_FROM_DIRECTION[dir]);\r\n }\r\n addCardinalDirection(dir) {\r\n return this.add(X_FROM_CARDINAL_DIRECTION[dir], Y_FROM_CARDINAL_DIRECTION[dir]);\r\n }\r\n subtractOffset(off) {\r\n return this.add(-off.x, -off.y);\r\n }\r\n multiply(factor) {\r\n this.x *= factor;\r\n this.y *= factor;\r\n return this;\r\n }\r\n rotate(turn, anchor) {\r\n if (anchor) {\r\n return this.subtractOffset(anchor).rotate(turn).addOffset(anchor);\r\n }\r\n else {\r\n const dir = compass_1.cardinalDirectionFromNorthTurn(turn);\r\n const { x, y } = this;\r\n const dirx = X_FROM_CARDINAL_DIRECTION[dir];\r\n const diry = Y_FROM_CARDINAL_DIRECTION[dir];\r\n const nx = -y * dirx - x * diry;\r\n const ny = x * dirx - y * diry;\r\n return this.set(nx, ny);\r\n }\r\n }\r\n // utilities\r\n // chebyshev: can move in any direction (diagonals are ok)\r\n distanceChebyshev(other) {\r\n return Math.max(Math.abs(this.x - other.x), Math.abs(this.y - other.y));\r\n }\r\n // manhattan: can move only in cardinal directions (no diagonals)\r\n distanceManhattan(other) {\r\n return Math.abs(this.x - other.x) + Math.abs(this.y - other.y);\r\n }\r\n // chebyshev: can move in any direction (diagonals are ok)\r\n *nearbyChebyshevOffsets(cursor, radius) {\r\n if (radius >= 0) {\r\n for (let dy = -radius; dy <= radius; dy++) {\r\n for (let dx = -radius; dx <= radius; dx++) {\r\n yield cursor.set(this.x + dx, this.y + dy);\r\n }\r\n }\r\n }\r\n }\r\n}\r\nexports.Offset = Offset;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.RasterMask = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nclass RasterMask {\r\n constructor(bounds, lines) {\r\n this._rect = new rectangle_1.Rectangle();\r\n if (lines.length !== bounds.height) {\r\n throw new Error(`bad lines array length ${lines.length} for bounds ${bounds}`);\r\n }\r\n this._rect.copyFrom(bounds);\r\n this._lines = lines;\r\n }\r\n // accessors\r\n toString() {\r\n let shape = '';\r\n const { eastX } = this._rect;\r\n for (let y = 0; y < this.height; y++) {\r\n const line = this._lines[y];\r\n let x = this.westX;\r\n for (let i = 0; i < line.length; i += 2) {\r\n const start = line[i];\r\n const end = line[i + 1];\r\n while (x < start) {\r\n shape += '∙';\r\n x++;\r\n }\r\n while (x < end) {\r\n shape += '█';\r\n x++;\r\n }\r\n }\r\n while (x <= eastX) {\r\n shape += '∙';\r\n x++;\r\n }\r\n shape += '\\n';\r\n }\r\n return `(${this._rect.westX},${this._rect.northY})\\n${shape}`;\r\n }\r\n equals(other) {\r\n return this._rect.equals(other._rect)\r\n && this._lines.length === other._lines.length\r\n && this._lines.every((v, i) => (v.length === other._lines[i].length\r\n && v.every((w, j) => w === other._lines[i][j])));\r\n }\r\n get northY() {\r\n return this._rect.northY;\r\n }\r\n get southY() {\r\n return this._rect.southY;\r\n }\r\n get westX() {\r\n return this._rect.westX;\r\n }\r\n get width() {\r\n return this._rect.width;\r\n }\r\n get height() {\r\n return this._rect.height;\r\n }\r\n get(x, y) {\r\n if (y < this.northY || y > this._rect.southY) {\r\n return false;\r\n }\r\n const line = this._lines[y - this.northY];\r\n for (let i = 0; i < line.length; i += 2) {\r\n if (x >= line[i] && x < line[i + 1]) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n // utilities\r\n *bandsAt(y) {\r\n if (y >= this.northY && y <= this._rect.southY) {\r\n const line = this._lines[y - this.northY];\r\n for (let i = 0; i < line.length; i += 2) {\r\n yield {\r\n westX: line[i],\r\n eastX: line[i + 1] - 1,\r\n };\r\n }\r\n }\r\n }\r\n}\r\nexports.RasterMask = RasterMask;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Rectangle = void 0;\r\nconst size_1 = require(\"./size\");\r\nconst offset_1 = require(\"./offset\");\r\nconst ROTATE_CORNER_X = [0, 0, 1, 1];\r\nconst ROTATE_CORNER_Y = [0, 1, 1, 0];\r\nclass Rectangle {\r\n constructor(westX, northY, width, height) {\r\n if (typeof westX === 'undefined') {\r\n westX = 0;\r\n }\r\n if (typeof northY === 'undefined') {\r\n northY = 0;\r\n }\r\n if (typeof width === 'undefined') {\r\n width = 0;\r\n }\r\n if (typeof height === 'undefined') {\r\n height = 0;\r\n }\r\n this.northWest = new offset_1.Offset(westX, northY);\r\n this.size = new size_1.Size(width, height);\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.westX},${this.northY} ${this.width}x${this.height})`;\r\n }\r\n equals(other) {\r\n return this.westX === other.westX && this.northY === other.northY && this.size.equals(other);\r\n }\r\n get northY() {\r\n return this.northWest.y;\r\n }\r\n get southY() {\r\n return this.northWest.y + this.size.height - 1;\r\n }\r\n get westX() {\r\n return this.northWest.x;\r\n }\r\n get eastX() {\r\n return this.northWest.x + this.size.width - 1;\r\n }\r\n get width() {\r\n return this.size.width;\r\n }\r\n get height() {\r\n return this.size.height;\r\n }\r\n get empty() {\r\n return this.size.empty;\r\n }\r\n get area() {\r\n return this.size.area;\r\n }\r\n // mutators\r\n set(westX, northY, width, height) {\r\n this.northWest.set(westX, northY);\r\n this.size.set(width, height);\r\n return this;\r\n }\r\n setFromCorners(off1, off2) {\r\n const westX = Math.min(off1.x, off2.x);\r\n const eastX = Math.max(off1.x, off2.x);\r\n const northY = Math.min(off1.y, off2.y);\r\n const southY = Math.max(off1.y, off2.y);\r\n return this.set(westX, northY, eastX - westX + 1, southY - northY + 1);\r\n }\r\n copyFrom(other) {\r\n return this.set(other.westX, other.northY, other.width, other.height);\r\n }\r\n addOffset(off) {\r\n this.northWest.addOffset(off);\r\n return this;\r\n }\r\n scale(factor) {\r\n this.northWest.multiply(factor);\r\n this.size.multiply(factor);\r\n return this;\r\n }\r\n rotate(turn, anchor) {\r\n const cx = ROTATE_CORNER_X[turn];\r\n const cy = ROTATE_CORNER_Y[turn];\r\n this.northWest.add(cx * (this.width - 1), cy * (this.height - 1)).rotate(turn, anchor);\r\n this.size.rotate(turn);\r\n return this;\r\n }\r\n extendToInclude(off) {\r\n const dx = off.x - this.westX;\r\n if (dx < 0) {\r\n this.size.width -= dx;\r\n this.northWest.x = off.x;\r\n }\r\n else if (dx >= this.size.width) {\r\n this.size.width = dx + 1;\r\n }\r\n const dy = off.y - this.northWest.y;\r\n if (dy < 0) {\r\n this.size.height -= dy;\r\n this.northWest.y = off.y;\r\n }\r\n else if (dy >= this.size.height) {\r\n this.size.height = dy + 1;\r\n }\r\n return this;\r\n }\r\n // utilities\r\n contains(x, y) {\r\n return this.size.contains(x - this.westX, y - this.northY);\r\n }\r\n index(x, y) {\r\n return this.size.index(x - this.westX, y - this.northY);\r\n }\r\n containsOffset(off) {\r\n return this.contains(off.x, off.y);\r\n }\r\n containsRectangle(other) {\r\n if (other.width === 0 && other.height === 0) {\r\n return false;\r\n }\r\n const x = other.westX - this.westX;\r\n const y = other.northY - this.northY;\r\n if (!this.size.contains(x, y)) {\r\n return false;\r\n }\r\n return this.size.contains(x + other.width - 1, y + other.height - 1);\r\n }\r\n overlapsRectangle(other) {\r\n return this.northY <= other.northY + other.height - 1\r\n && this.southY >= other.northY\r\n && this.westX <= other.westX + other.width - 1\r\n && this.eastX >= other.westX\r\n && !this.empty\r\n && other.width !== 0 && other.height !== 0;\r\n }\r\n *offsets() {\r\n const { eastX, southY } = this;\r\n for (let y = this.northY; y <= southY; y++) {\r\n for (let x = this.westX; x <= eastX; x++) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n anyOf(predicate) {\r\n for (const { x, y } of this.offsets()) {\r\n if (predicate(x, y)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\nexports.Rectangle = Rectangle;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Size = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nclass Size {\r\n constructor(width, height) {\r\n if (typeof width === 'undefined') {\r\n width = 0;\r\n }\r\n if (typeof height === 'undefined') {\r\n height = 0;\r\n }\r\n if (width < 0 || height < 0) {\r\n throw new Error(`bad size (${width}x${height})`);\r\n }\r\n this.width = width;\r\n this.height = height;\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.width}x${this.height})`;\r\n }\r\n equals(other) {\r\n return this.width === other.width && this.height === other.height;\r\n }\r\n get empty() {\r\n return this.width === 0 || this.height === 0;\r\n }\r\n get area() {\r\n return this.width * this.height;\r\n }\r\n // mutators\r\n set(width, height) {\r\n if (width < 0 || height < 0) {\r\n throw new Error(`bad size (${width}x${height})`);\r\n }\r\n this.width = width;\r\n this.height = height;\r\n return this;\r\n }\r\n copyFrom(other) {\r\n return this.set(other.width, other.height);\r\n }\r\n add(width, height) {\r\n this.width += width;\r\n this.height += height;\r\n return this;\r\n }\r\n multiply(factor) {\r\n this.width *= factor;\r\n this.height *= factor;\r\n return this;\r\n }\r\n rotate(turn) {\r\n if (compass_1.axisFromNorthSouthTurn(turn) === compass_1.Axis.WEST_EAST) {\r\n this.set(this.height, this.width);\r\n }\r\n return this;\r\n }\r\n // utilities\r\n contains(x, y) {\r\n return x >= 0 && y >= 0 && x < this.width && y < this.height;\r\n }\r\n containsOffset(off) {\r\n return this.contains(off.x, off.y);\r\n }\r\n index(x, y) {\r\n return y * this.width + x;\r\n }\r\n *offsets() {\r\n for (let y = 0; y < this.height; y++) {\r\n for (let x = 0; x < this.width; x++) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n anyOf(predicate) {\r\n for (const { x, y } of this.offsets()) {\r\n if (predicate(x, y)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\nexports.Size = Size;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.TransformRectangle = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst compass_1 = require(\"../compass\");\r\nconst offset_1 = require(\"./offset\");\r\nconst size_1 = require(\"./size\");\r\nconst LOCAL_OFF = new offset_1.Offset();\r\nconst LOCAL_OFF2 = new offset_1.Offset();\r\nconst LOCAL_SIZE = new size_1.Size();\r\nclass TransformRectangle {\r\n constructor(width, height) {\r\n this._size = new size_1.Size();\r\n this._flip = compass_1.Flip.HEADS;\r\n this._rotate = compass_1.CardinalTurn.NONE;\r\n this._translate = new offset_1.Offset();\r\n this._matrix = [1, 0, 0, 0, 1, 0];\r\n this._targetRect = new rectangle_1.Rectangle();\r\n if (typeof width === 'undefined') {\r\n // nothing\r\n }\r\n else if (typeof width === 'number') {\r\n this._size.set(width, height);\r\n }\r\n else {\r\n this._size.copyFrom(width);\r\n }\r\n this._update();\r\n }\r\n // accessors\r\n toString() {\r\n return `[${this._size}`\r\n + ` -> ${compass_1.flipToString(this._flip)} ${compass_1.cardinalTurnToString(this._rotate)} ${this._translate}`\r\n + ` -> ${this._targetRect}]`;\r\n }\r\n equals(other) {\r\n return this._size.equals(other._size)\r\n && this._flip === other._flip\r\n && this._rotate === other._rotate\r\n && this._translate.equals(other._translate);\r\n }\r\n get flip() {\r\n return this._flip;\r\n }\r\n get rotate() {\r\n return this._rotate;\r\n }\r\n get northY() {\r\n return this._translate.y;\r\n }\r\n get southY() {\r\n return this._translate.y + this._targetRect.height - 1;\r\n }\r\n get westX() {\r\n return this._translate.x;\r\n }\r\n get eastX() {\r\n return this._translate.x + this._targetRect.width - 1;\r\n }\r\n get width() {\r\n return this._targetRect.width;\r\n }\r\n get height() {\r\n return this._targetRect.height;\r\n }\r\n // internal\r\n // 0\r\n // 0 -1\r\n // +90\r\n // 1 0\r\n // 180\r\n // 0 1\r\n // -90\r\n // -1 0\r\n //\r\n // heads:\r\n // 0\r\n // 1 0 x\r\n // 0 1 y\r\n // +90\r\n // 0 -1 x + h - 1\r\n // 1 0 y\r\n // 180\r\n // -1 0 x + w - 1\r\n // 0 -1 y + h - 1\r\n // -90\r\n // 0 1 x\r\n // -1 0 y + w - 1\r\n //\r\n // tails:\r\n // 0\r\n // -1 0 x + w - 1\r\n // 0 1 y\r\n // +90\r\n // 0 -1 x + h - 1\r\n // -1 0 y + w - 1\r\n // 180\r\n // 1 0 x\r\n // 0 -1 y + h - 1\r\n // -90\r\n // 0 1 x\r\n // 1 0 y\r\n _update() {\r\n LOCAL_OFF.setFromCardinalDirection(compass_1.cardinalDirectionFromNorthTurn(this._rotate));\r\n const flipSign = this._flip === compass_1.Flip.TAILS ? -1 : 1;\r\n this._matrix[0] = -LOCAL_OFF.y * flipSign;\r\n this._matrix[1] = -LOCAL_OFF.x;\r\n this._matrix[2] = this._translate.x;\r\n this._matrix[3] = LOCAL_OFF.x * flipSign;\r\n this._matrix[4] = -LOCAL_OFF.y;\r\n this._matrix[5] = this._translate.y;\r\n switch (this._rotate) {\r\n case compass_1.CardinalTurn.NONE:\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n this._matrix[2] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.RIGHT:\r\n this._matrix[2] += this._size.height - 1;\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n this._matrix[5] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.AROUND:\r\n this._matrix[5] += this._size.height - 1;\r\n if (this._flip === compass_1.Flip.HEADS) {\r\n this._matrix[2] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.LEFT:\r\n if (this._flip === compass_1.Flip.HEADS) {\r\n this._matrix[5] += this._size.width - 1;\r\n }\r\n break;\r\n }\r\n LOCAL_SIZE.copyFrom(this._size).rotate(this._rotate);\r\n this._targetRect.set(this._translate.x, this._translate.y, LOCAL_SIZE.width, LOCAL_SIZE.height);\r\n return this;\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._size.copyFrom(other._size);\r\n this._flip = other._flip;\r\n this._rotate = other._rotate;\r\n this._translate.copyFrom(other._translate);\r\n other._matrix.forEach((v, i) => this._matrix[i] = v);\r\n this._targetRect.copyFrom(other._targetRect);\r\n return this;\r\n }\r\n reset() {\r\n this._flip = compass_1.Flip.HEADS;\r\n this._rotate = compass_1.CardinalTurn.NONE;\r\n this._translate.set(0, 0);\r\n return this._update();\r\n }\r\n invert() {\r\n const nrotate = compass_1.cardinalTurnFromCardinalDirections(compass_1.CardinalDirection.NORTH, compass_1.cardinalDirectionFromCardinalOrientation(compass_1.cardinalOrientationReverse(compass_1.cardinalOrientationFromFlipAndCardinalDirection(this._flip, compass_1.cardinalDirectionFromNorthTurn(this._rotate)))));\r\n this._rotate = nrotate;\r\n this._size.rotate(nrotate);\r\n this._translate.multiply(-1);\r\n return this._update();\r\n }\r\n setTransform(flip, rotate, translate) {\r\n this._flip = flip;\r\n this._rotate = rotate;\r\n this._translate.copyFrom(translate);\r\n return this._update();\r\n }\r\n setFlip(flip) {\r\n this._flip = flip;\r\n return this._update();\r\n }\r\n setRotate(rotate) {\r\n this._rotate = rotate;\r\n return this._update();\r\n }\r\n setTranslate(x, y) {\r\n this._translate.set(x, y);\r\n return this._update();\r\n }\r\n setTranslateOffset(translate) {\r\n this._translate.copyFrom(translate);\r\n return this._update();\r\n }\r\n // utility\r\n applyToCardinalOrientation(orientation) {\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n orientation = compass_1.cardinalOrientationFlip(orientation, compass_1.Axis.NORTH_SOUTH);\r\n }\r\n return compass_1.cardinalOrientationAddCardinalTurn(orientation, this._rotate);\r\n }\r\n unapplyFromCardinalOrientation(orientation) {\r\n orientation = compass_1.cardinalOrientationAddCardinalTurn(orientation, compass_1.cardinalTurnReverse(this._rotate));\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n orientation = compass_1.cardinalOrientationFlip(orientation, compass_1.Axis.NORTH_SOUTH);\r\n }\r\n return orientation;\r\n }\r\n applyToCardinalDirection(orientation) {\r\n return compass_1.cardinalDirectionFromCardinalOrientation(this.applyToCardinalOrientation(compass_1.cardinalOrientationFromFlipAndCardinalDirection(compass_1.Flip.HEADS, orientation)));\r\n }\r\n unapplyFromCardinalDirection(orientation) {\r\n return compass_1.cardinalDirectionFromCardinalOrientation(this.unapplyFromCardinalOrientation(compass_1.cardinalOrientationFromFlipAndCardinalDirection(compass_1.Flip.HEADS, orientation)));\r\n }\r\n applyTo(offOut, x, y) {\r\n const nx = x * this._matrix[0] + y * this._matrix[1] + this._matrix[2];\r\n const ny = x * this._matrix[3] + y * this._matrix[4] + this._matrix[5];\r\n return offOut.set(nx, ny);\r\n }\r\n unapplyFrom(offOut, x, y) {\r\n const tx = x - this._matrix[2];\r\n const ty = y - this._matrix[5];\r\n const nx = tx * this._matrix[0] + ty * this._matrix[3];\r\n const ny = tx * this._matrix[1] + ty * this._matrix[4];\r\n return offOut.set(nx, ny);\r\n }\r\n applyToOffset(offOut, off) {\r\n if (typeof off === 'undefined') {\r\n off = offOut;\r\n }\r\n return this.applyTo(offOut, off.x, off.y);\r\n }\r\n unapplyFromOffset(offOut, off) {\r\n if (typeof off === 'undefined') {\r\n off = offOut;\r\n }\r\n return this.unapplyFrom(offOut, off.x, off.y);\r\n }\r\n applyToRectangle(rectOut, rect) {\r\n if (typeof rect !== 'undefined') {\r\n rectOut.copyFrom(rect);\r\n }\r\n LOCAL_OFF.set(rectOut.westX, rectOut.northY);\r\n LOCAL_OFF2.set(rectOut.eastX, rectOut.southY);\r\n this.applyToOffset(LOCAL_OFF);\r\n this.applyToOffset(LOCAL_OFF2);\r\n return rectOut.setFromCorners(LOCAL_OFF, LOCAL_OFF2);\r\n }\r\n unapplyFromRectangle(rectOut, rect) {\r\n if (typeof rect !== 'undefined') {\r\n rectOut.copyFrom(rect);\r\n }\r\n LOCAL_OFF.set(rectOut.westX, rectOut.northY);\r\n LOCAL_OFF2.set(rectOut.eastX, rectOut.southY);\r\n this.unapplyFromOffset(LOCAL_OFF);\r\n this.unapplyFromOffset(LOCAL_OFF2);\r\n return rectOut.setFromCorners(LOCAL_OFF, LOCAL_OFF2);\r\n }\r\n}\r\nexports.TransformRectangle = TransformRectangle;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./compass\"), exports);\r\n__exportStar(require(\"./grid\"), exports);\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n});\r\nvar __importStar = (this && this.__importStar) || function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.computeFieldOfView = void 0;\r\nconst geom = __importStar(require(\"tiled-geometry\"));\r\nconst constants = __importStar(require(\"./constants\"));\r\nconst field_of_view_impl_1 = require(\"./field-of-view-impl\");\r\nconst wedge_1 = require(\"./wedge\");\r\n/* eslint-disable indent */\r\n/**\r\n * Compute the field of view for a camera at the given tile.\r\n * chebyshevRadius is the vision radius. It uses chebyshev distance\r\n * (https://en.wikipedia.org/wiki/Chebyshev_distance), which just means\r\n * that the limit of vision in a large empty field will be square.\r\n *\r\n * This returns a FieldOfView, which indicates which tiles are visible.\r\n * fieldOfView.get(x, y) will return true for visible tiles.\r\n */\r\nfunction computeFieldOfView(map, x, y, chebyshevRadius) {\r\n const origin = new geom.Offset(x, y);\r\n const field = new field_of_view_impl_1.FieldOfViewImpl(origin, chebyshevRadius);\r\n // the field is divided into quadrants\r\n quadrant(map, field, origin, chebyshevRadius, -1, -1);\r\n quadrant(map, field, origin, chebyshevRadius, 1, -1);\r\n quadrant(map, field, origin, chebyshevRadius, -1, 1);\r\n quadrant(map, field, origin, chebyshevRadius, 1, 1);\r\n return field;\r\n}\r\nexports.computeFieldOfView = computeFieldOfView;\r\nfunction quadrant(map, field, origin, chebyshevRadius, xSign, ySign) {\r\n const { x: startX, y: startY } = origin;\r\n const endDX = (Math.min(Math.max(startX + xSign * (chebyshevRadius + 1), -1), map.width) - startX) * xSign;\r\n const endDY = (Math.min(Math.max(startY + ySign * (chebyshevRadius + 1), -1), map.height) - startY) * ySign;\r\n if (endDX < 0 || endDY < 0) {\r\n // the origin is outside of the map\r\n return;\r\n }\r\n const startMapIndex = map.index(origin.x, origin.y);\r\n const startMaskIndex = field.visible.index(origin.x, origin.y);\r\n // Initial wedge is from slope zero to slope infinity (i.e. the whole quadrant)\r\n let wedges = wedge_1.initWedges();\r\n for (let dy = 0, yMapIndex = startMapIndex, yMaskIndex = startMaskIndex; dy !== endDY && wedges.length > 0; dy++, yMapIndex += ySign * map.width, yMaskIndex += ySign * field.visible.width) {\r\n const divYpos = 1 / (dy + 0.5);\r\n const divYneg = dy === 0 ? Number.POSITIVE_INFINITY : 1 / (dy - 0.5);\r\n let wedgeIndex = 0;\r\n for (let dx = 0, mapIndex = yMapIndex, maskIndex = yMaskIndex, slopeY = -0.5 * divYpos, slopeX = 0.5 * divYneg; dx !== endDX && wedgeIndex !== wedges.length; dx++, mapIndex += xSign, maskIndex += xSign,\r\n slopeY += divYpos, slopeX += divYneg) {\r\n // the slopes of the four corners of this tile\r\n // these are named as follows:\r\n // slopeY is the slope closest to the Y axis\r\n // slopeX is the slope closest to the X axis\r\n // this is always true:\r\n // slopeY < slopeX\r\n //\r\n // O = origin, C = current\r\n // +---+---+---+\r\n // | O | | |\r\n // +---+---+---X\r\n // | | | C |\r\n // +---+---Y---+\r\n // advance the wedge index until this tile is not after the current wedge\r\n while (slopeY > wedges[wedgeIndex].high) {\r\n wedgeIndex++;\r\n if (wedgeIndex >= wedges.length) {\r\n break;\r\n }\r\n }\r\n if (wedgeIndex >= wedges.length) {\r\n break;\r\n }\r\n // if the current wedge is after this tile, move on\r\n if (slopeX < wedges[wedgeIndex].low) {\r\n continue;\r\n }\r\n // we can see this tile\r\n field.visible.setAtIndex(maskIndex, true);\r\n const body = (dx !== 0 || dy !== 0) && map.getBodyAtIndex(mapIndex);\r\n if (body) {\r\n wedges = wedge_1.cutWedges(wedges, slopeY + constants.BODY_INSET, slopeX - constants.BODY_INSET);\r\n }\r\n }\r\n }\r\n}\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.WEDGE_COUNT = exports.WEDGE_HIGH = exports.WEDGE_LOW = exports.BODY_INSET = void 0;\r\n/**\r\n * A smallish number, to adjust some wedges.\r\n */\r\nconst EPSILON = 0.00001;\r\n/**\r\n * Bodies in this algorithm do not entirely fill their tiles. This is\r\n * implemented by adjusting the angles of the shadows the bodies cast,\r\n * making the wedge very slightly narrower. BODY_INSET represents the\r\n * amount of reduction on either side of the wedge.\r\n */\r\nexports.BODY_INSET = EPSILON;\r\n/**\r\n * In the shadowcasting algorithm, each shadow is represented by a \"wedge\",\r\n * running from a \"low\" angle to a \"high\" angle. The wedges are all stored in\r\n * a simple number array, with two numbers for each wedge. These constants\r\n * (WEDGE_LOW and WEDGE_HIGH) help to identify which number is which.\r\n * WEDGE_COUNT is just how many numbers per wedge.\r\n */\r\nexports.WEDGE_LOW = 0;\r\nexports.WEDGE_HIGH = 1;\r\nexports.WEDGE_COUNT = 2;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n});\r\nvar __importStar = (this && this.__importStar) || function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.FieldOfViewImpl = void 0;\r\nconst geom = __importStar(require(\"tiled-geometry\"));\r\n/**\r\n * The FieldOfViewImpl class is the concrete implementation of the FieldOfView interface.\r\n */\r\nclass FieldOfViewImpl {\r\n constructor(origin, chebyshevRadius) {\r\n this.origin = origin;\r\n this.chebyshevRadius = chebyshevRadius;\r\n const boundRect = new geom.Rectangle(origin.x - chebyshevRadius, origin.y - chebyshevRadius, chebyshevRadius * 2 + 1, chebyshevRadius * 2 + 1);\r\n this.visible = new geom.MaskRectangle(boundRect);\r\n // the origin is always visible\r\n this.visible.setAtOffset(origin, true);\r\n }\r\n getVisible(x, y) {\r\n return this.visible.get(x, y);\r\n }\r\n toString() {\r\n let ret = '';\r\n for (const location of this.visible.locations()) {\r\n const { x, y } = location;\r\n if (this.origin.equals(location)) {\r\n ret += '@';\r\n }\r\n else if (this.getVisible(x, y)) {\r\n ret += '-';\r\n }\r\n else {\r\n ret += '.';\r\n }\r\n if (x === this.visible.westX + this.visible.width - 1) {\r\n ret += '\\n';\r\n }\r\n }\r\n return ret;\r\n }\r\n}\r\nexports.FieldOfViewImpl = FieldOfViewImpl;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n});\r\nvar __importStar = (this && this.__importStar) || function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.FieldOfViewMap = void 0;\r\nconst geom = __importStar(require(\"tiled-geometry\"));\r\n/**\r\n * For each number in the _tileFlags array, we store (1 << FLAGS_POW2) cells,\r\n * as bits where a true indicates the presence of a body.\r\n */\r\nconst FLAGS_POW2 = 5;\r\n/**\r\n * The FieldOfViewMap class describes the map over which the field of view will be\r\n * computed. It starts empty.\r\n */\r\nclass FieldOfViewMap {\r\n constructor(width, height) {\r\n this._size = new geom.Size();\r\n this._size.set(width, height);\r\n this._tileFlags = new Array((this._size.area >> FLAGS_POW2) + 1).fill(0);\r\n }\r\n get width() {\r\n return this._size.width;\r\n }\r\n get height() {\r\n return this._size.height;\r\n }\r\n // bodies\r\n addBody(x, y) {\r\n if (this._size.contains(x, y)) {\r\n const index = this.index(x, y);\r\n this._tileFlags[index >> FLAGS_POW2] |= 1 << (index & ((1 << FLAGS_POW2) - 1));\r\n }\r\n return this;\r\n }\r\n removeBody(x, y) {\r\n if (this._size.contains(x, y)) {\r\n const index = this.index(x, y);\r\n this._tileFlags[index >> FLAGS_POW2] &= ~(1 << (index & ((1 << FLAGS_POW2) - 1)));\r\n }\r\n return this;\r\n }\r\n getBody(x, y) {\r\n const index = this.index(x, y);\r\n return this.getBodyAtIndex(index);\r\n }\r\n // internal\r\n index(x, y) {\r\n return this._size.index(x, y);\r\n }\r\n getBodyAtIndex(index) {\r\n return (this._tileFlags[index >> FLAGS_POW2] & (1 << (index & ((1 << FLAGS_POW2) - 1)))) !== 0;\r\n }\r\n}\r\nexports.FieldOfViewMap = FieldOfViewMap;\r\n","\"use strict\";\r\n/*\r\n * TheField\r\n * github.com/sbj42/the-field\r\n * James Clark\r\n * Licensed under the MIT license.\r\n */\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.computeFieldOfView = exports.FieldOfViewMap = void 0;\r\nvar field_of_view_map_1 = require(\"./field-of-view-map\");\r\nObject.defineProperty(exports, \"FieldOfViewMap\", { enumerable: true, get: function () { return field_of_view_map_1.FieldOfViewMap; } });\r\nvar compute_1 = require(\"./compute\");\r\nObject.defineProperty(exports, \"computeFieldOfView\", { enumerable: true, get: function () { return compute_1.computeFieldOfView; } });\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cutWedges = exports.cutWedge = exports.initWedges = void 0;\r\n// istanbul ignore next\r\nfunction rangeToString(low, high) {\r\n return `${low.toFixed(7)}-${high.toFixed(7)}`;\r\n}\r\n// istanbul ignore next\r\nfunction wedgeToString(wedge) {\r\n return `{${rangeToString(wedge.low, wedge.high)}}`;\r\n}\r\n// istanbul ignore next\r\nfunction wedgesToString(wedges) {\r\n return `[${wedges.map(wedgeToString).join(', ')}]`;\r\n}\r\n// istanbul ignore next\r\nfunction debugLog(msg) {\r\n // eslint-disable-next-line no-console\r\n console.info(msg);\r\n}\r\nfunction initWedges() {\r\n return [{ low: 0, high: Number.POSITIVE_INFINITY }];\r\n}\r\nexports.initWedges = initWedges;\r\nconst DEBUG_CUTWEDGE = false;\r\n/**\r\n * This function cuts a range of angles out of a wedge.\r\n */\r\nfunction cutWedge(wedge, low, high) {\r\n // istanbul ignore next\r\n if (DEBUG_CUTWEDGE) {\r\n debugLog(`cut ${wedgeToString(wedge)} ${rangeToString(low, high)}`);\r\n }\r\n let ret;\r\n if (low <= wedge.low) {\r\n if (high >= wedge.high) {\r\n // wedge is entirely occluded, remove it\r\n ret = [];\r\n }\r\n else if (high >= wedge.low) {\r\n // low part of wedge is occluded, trim it\r\n wedge.low = high;\r\n ret = [wedge];\r\n }\r\n else {\r\n // cut doesn't reach the wedge\r\n ret = [wedge];\r\n }\r\n }\r\n else if (high >= wedge.high) {\r\n if (low <= wedge.high) {\r\n // high part of wedge is occluded, trim it\r\n wedge.high = low;\r\n ret = [wedge];\r\n }\r\n else {\r\n // cut doesn't reach the wedge\r\n ret = [wedge];\r\n }\r\n }\r\n else {\r\n // middle part of wedge is occluded, split it\r\n const nextWedge = {\r\n low: high,\r\n high: wedge.high,\r\n };\r\n wedge.high = low;\r\n ret = [wedge, nextWedge];\r\n }\r\n // istanbul ignore next\r\n if (DEBUG_CUTWEDGE) {\r\n debugLog(`--> ${wedgesToString(ret)}`);\r\n }\r\n return ret;\r\n}\r\nexports.cutWedge = cutWedge;\r\nfunction cutWedges(wedges, low, high) {\r\n const ret = new Array();\r\n for (const wedge of wedges) {\r\n ret.push(...cutWedge(wedge, low, high));\r\n }\r\n return ret;\r\n}\r\nexports.cutWedges = cutWedges;\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// module exports must be returned from runtime so entry inlining is disabled\n// startup\n// Load entry module and return exports\nreturn __webpack_require__(\"./src/index.ts\");\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/the-field-2.0.0.min.js b/dist/the-field-2.0.1.min.js similarity index 99% rename from dist/the-field-2.0.0.min.js rename to dist/the-field-2.0.1.min.js index 975f7f0..e4f1ffc 100644 --- a/dist/the-field-2.0.0.min.js +++ b/dist/the-field-2.0.1.min.js @@ -1,2 +1,2 @@ var TheField;TheField=(()=>{"use strict";var t={677:(t,i)=>{var e;Object.defineProperty(i,"__esModule",{value:!0}),i.axisAddCardinalTurn=i.axisFromNorthSouthTurn=i.axisFromCardinalDirection=i.axisOrthogonal=i.axisToString=i.AXES=i.Axis=void 0,function(t){t[t.NORTH_SOUTH=0]="NORTH_SOUTH",t[t.WEST_EAST=1]="WEST_EAST"}(e=i.Axis||(i.Axis={})),i.AXES=[e.NORTH_SOUTH,e.WEST_EAST];const r=["N-S","W-E"];i.axisToString=function(t){return r[t]},i.axisOrthogonal=function(t){return 1^t},i.axisFromCardinalDirection=function(t){return 1&t},i.axisFromNorthSouthTurn=function(t){return 1&t},i.axisAddCardinalTurn=function(t,i){return t+i&1}},340:(t,i)=>{var e;function r(t){return 1<{var e;Object.defineProperty(i,"__esModule",{value:!0}),i.cardinalDirectionAddCardinalTurn=i.cardinalDirectionFromCardinalOrientation=i.cardinalDirectionFromNorthTurn=i.cardinalDirectionFromDirection=i.cardinalDirectionOpposite=i.cardinalDirectionToString=i.CARDINAL_DIRECTIONS=i.CardinalDirection=void 0,function(t){t[t.NORTH=0]="NORTH",t[t.EAST=1]="EAST",t[t.SOUTH=2]="SOUTH",t[t.WEST=3]="WEST"}(e=i.CardinalDirection||(i.CardinalDirection={})),i.CARDINAL_DIRECTIONS=[e.NORTH,e.EAST,e.SOUTH,e.WEST];const r=["N","E","S","W"];i.cardinalDirectionToString=function(t){return r[t]},i.cardinalDirectionOpposite=function(t){return t+2&3},i.cardinalDirectionFromDirection=function(t){return t>>1},i.cardinalDirectionFromNorthTurn=function(t){return t},i.cardinalDirectionFromCardinalOrientation=function(t){return t>>>1},i.cardinalDirectionAddCardinalTurn=function(t,i){return t+i&3}},852:(t,i,e)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.cardinalOrientationAddCardinalTurn=i.cardinalOrientationFromFlipAndCardinalDirection=i.cardinalOrientationReverse=i.cardinalOrientationFlip=i.cardinalOrientationToString=i.CARDINAL_ORIENTATIONS=i.CardinalOrientation=void 0;const r=e(677),n=e(254);var s;!function(t){t[t.HEADS_NORTH=0]="HEADS_NORTH",t[t.TAILS_NORTH=1]="TAILS_NORTH",t[t.HEADS_EAST=2]="HEADS_EAST",t[t.TAILS_EAST=3]="TAILS_EAST",t[t.HEADS_SOUTH=4]="HEADS_SOUTH",t[t.TAILS_SOUTH=5]="TAILS_SOUTH",t[t.HEADS_WEST=6]="HEADS_WEST",t[t.TAILS_WEST=7]="TAILS_WEST"}(s=i.CardinalOrientation||(i.CardinalOrientation={})),i.CARDINAL_ORIENTATIONS=[s.HEADS_NORTH,s.TAILS_NORTH,s.HEADS_EAST,s.TAILS_EAST,s.HEADS_SOUTH,s.TAILS_SOUTH,s.HEADS_WEST,s.TAILS_WEST];const a=["HN","TN","HE","TE","HS","TS","HW","TW"];i.cardinalOrientationToString=function(t){return a[t]},i.cardinalOrientationFlip=function(t,i){return i===r.Axis.NORTH_SOUTH?9-t&7:13-t&7},i.cardinalOrientationReverse=function(t){return t===s.HEADS_EAST?s.HEADS_WEST:t===s.HEADS_WEST?s.HEADS_EAST:t},i.cardinalOrientationFromFlipAndCardinalDirection=function(t,i){return 2*i+(t!==n.Flip.HEADS?1:0)},i.cardinalOrientationAddCardinalTurn=function(t,i){return t+2*i&7}},974:(t,i)=>{var e;Object.defineProperty(i,"__esModule",{value:!0}),i.cardinalTurnAddCardinalTurn=i.cardinalTurnFromTurn=i.cardinalTurnFromCardinalDirections=i.cardinalTurnReverse=i.cardinalTurnToDegrees=i.cardinalTurnToString=i.CARDINAL_TURNS=i.CardinalTurn=void 0,function(t){t[t.NONE=0]="NONE",t[t.RIGHT=1]="RIGHT",t[t.AROUND=2]="AROUND",t[t.LEFT=3]="LEFT"}(e=i.CardinalTurn||(i.CardinalTurn={})),i.CARDINAL_TURNS=[e.NONE,e.RIGHT,e.AROUND,e.LEFT];const r=["T0","T+90","T180","T-90"];i.cardinalTurnToString=function(t){return r[t]},i.cardinalTurnToDegrees=function(t){return 90*t},i.cardinalTurnReverse=function(t){return 4-t&3},i.cardinalTurnFromCardinalDirections=function(t,i){return i-t&3},i.cardinalTurnFromTurn=function(t){return t>>1},i.cardinalTurnAddCardinalTurn=function(t,i){return t+i&3}},588:(t,i)=>{var e;Object.defineProperty(i,"__esModule",{value:!0}),i.directionAddCardinalTurn=i.directionAddTurn=i.directionFromCardinalDirection=i.directionOpposite=i.directionIsCardinal=i.directionToString=i.DIRECTIONS=i.Direction=void 0,function(t){t[t.NORTH=0]="NORTH",t[t.NORTHEAST=1]="NORTHEAST",t[t.EAST=2]="EAST",t[t.SOUTHEAST=3]="SOUTHEAST",t[t.SOUTH=4]="SOUTH",t[t.SOUTHWEST=5]="SOUTHWEST",t[t.WEST=6]="WEST",t[t.NORTHWEST=7]="NORTHWEST"}(e=i.Direction||(i.Direction={})),i.DIRECTIONS=[e.NORTH,e.NORTHEAST,e.EAST,e.SOUTHEAST,e.SOUTH,e.SOUTHWEST,e.WEST,e.NORTHWEST];const r=["N","NE","E","SE","S","SW","W","NW"];i.directionToString=function(t){return r[t]},i.directionIsCardinal=function(t){return 0==(1&t)},i.directionOpposite=function(t){return t+4&7},i.directionFromCardinalDirection=function(t){return t<<1},i.directionAddTurn=function(t,i){return t+i&7},i.directionAddCardinalTurn=function(t,i){return t+2*i&7}},254:(t,i)=>{var e;Object.defineProperty(i,"__esModule",{value:!0}),i.flipFromCardinalOrientation=i.flipFromBoolean=i.flipOpposite=i.flipToString=i.FLIPS=i.Flip=void 0,function(t){t[t.HEADS=0]="HEADS",t[t.TAILS=1]="TAILS"}(e=i.Flip||(i.Flip={})),i.FLIPS=[e.HEADS,e.TAILS];const r=["H","T"];i.flipToString=function(t){return r[t]},i.flipOpposite=function(t){return 1^t},i.flipFromBoolean=function(t){return t?e.TAILS:e.HEADS},i.flipFromCardinalOrientation=function(t){return 1&t}},778:function(t,i,e){var r=this&&this.__createBinding||(Object.create?function(t,i,e,r){void 0===r&&(r=e),Object.defineProperty(t,r,{enumerable:!0,get:function(){return i[e]}})}:function(t,i,e,r){void 0===r&&(r=e),t[r]=i[e]}),n=this&&this.__exportStar||function(t,i){for(var e in t)"default"===e||Object.prototype.hasOwnProperty.call(i,e)||r(i,t,e)};Object.defineProperty(i,"__esModule",{value:!0}),n(e(588),i),n(e(854),i),n(e(343),i),n(e(974),i),n(e(340),i),n(e(254),i),n(e(852),i),n(e(677),i)},854:(t,i)=>{var e;Object.defineProperty(i,"__esModule",{value:!0}),i.turnAddTurn=i.turnFromDirections=i.turnFromCardinalTurn=i.turnFromCardinalDirections=i.turnReverse=i.turnIsCardinal=i.turnToDegrees=i.turnToString=i.TURNS=i.Turn=void 0,function(t){t[t.NONE=0]="NONE",t[t.R_45=1]="R_45",t[t.R_90=2]="R_90",t[t.R_135=3]="R_135",t[t.T_180=4]="T_180",t[t.L_135=5]="L_135",t[t.L_90=6]="L_90",t[t.L_45=7]="L_45"}(e=i.Turn||(i.Turn={})),i.TURNS=[e.NONE,e.R_45,e.R_90,e.R_135,e.T_180,e.L_135,e.L_90,e.L_45];const r=["T0","T+45","T+90","T+135","T180","T-135","T-90","T-45"];i.turnToString=function(t){return r[t]},i.turnToDegrees=function(t){return 45*t},i.turnIsCardinal=function(t){return 0==(1&t)},i.turnReverse=function(t){return 8-t&7},i.turnFromCardinalDirections=function(t,i){return 2*(i-t)&7},i.turnFromCardinalTurn=function(t){return t<<1},i.turnFromDirections=function(t,i){return i-t&7},i.turnAddTurn=function(t,i){return t+i&7}},913:(t,i,e)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CardinalPath=void 0;const r=e(778),n=e(894),s=e(84),a=e(37),o=new n.Offset;function h(t,i){t.push(i);let e=t.length-1;for(;e>0&&ir.cardinalDirectionToString(t))).join("")}`}equals(t){return this._start.equals(t._start)&&this._segments.length===t._segments.length&&this._segments.every(((i,e)=>i===t._segments[e]))}get length(){return this._segments.length}getIsClosed(){o.copyFrom(this._start);for(const t of this._segments)o.addCardinalDirection(t);return this._start.equals(o)}*offsets(){let{x:t,y:i}=this._start;yield{x:t,y:i};for(const e of this._segments)o.setFromCardinalDirection(e),t+=o.x,i+=o.y,yield{x:t,y:i}}getBounds(){let t=this._start.y,i=t,e=this._start.x,n=e;o.copyFrom(this._start);for(const s of this._segments)switch(o.addCardinalDirection(s),s){case r.CardinalDirection.NORTH:t=Math.min(t,o.y);break;case r.CardinalDirection.EAST:n=Math.max(n,o.x);break;case r.CardinalDirection.SOUTH:i=Math.max(i,o.y);break;case r.CardinalDirection.WEST:e=Math.min(e,o.x);break;default:throw new Error(`bad direction ${s} in cardinal path`)}return new s.Rectangle(e,t,n-e+1,i-t+1)}getArea(){let t=0;o.copyFrom(this._start);for(const i of this._segments)switch(o.addCardinalDirection(i),i){case r.CardinalDirection.NORTH:t-=o.x;break;case r.CardinalDirection.SOUTH:t+=o.x}return Math.abs(t)}rasterize(t){const i=new Array;void 0===t&&(t=this.getBounds()),o.copyFrom(this._start);const{northY:e}=t,n=e+t.height-1;for(let t=e;t{Object.defineProperty(i,"__esModule",{value:!0}),i.MaskRectangle=void 0;const r=e(84),n=e(475);i.MaskRectangle=class{constructor(t,i=!1,e=!1){this._rect=new r.Rectangle,void 0!==t&&this._rect.copyFrom(t),this._mask=new n.Mask(t,i),this._outsideValue=e}toString(){return`${this._rect.northWest}/${this._outsideValue}\n${this._mask}`}equals(t){return this._rect.equals(t._rect)&&this._mask.equals(t._mask)&&this._outsideValue===t._outsideValue}get westX(){return this._rect.westX}get northY(){return this._rect.northY}get width(){return this._rect.width}get height(){return this._rect.height}get(t,i){return this._rect.contains(t,i)?this._mask.get(t-this.westX,i-this.northY):this._outsideValue}getAtIndex(t){return this._mask.getAtIndex(t)}getAtOffset(t){return this.get(t.x,t.y)}copyFrom(t){return this._rect.copyFrom(t._rect),this._mask.copyFrom(t._mask),this._outsideValue=t._outsideValue,this}set(t,i,e){return this._mask.set(t-this.westX,i-this.northY,e),this}setAtOffset(t,i){return this.set(t.x,t.y,i)}setAtIndex(t,i){return this._mask.setAtIndex(t,i),this}index(t,i){return this._mask.index(t-this.westX,i-this.northY)}*locations(){for(const t of this._mask.locations()){const i=t.x+this.westX,e=t.y+this.northY,{value:r}=t;yield{x:i,y:e,value:r}}}*offsetsWithTrue(){for(const t of this._mask.offsetsWithTrue()){const i=t.x+this.westX,e=t.y+this.northY;yield{x:i,y:e}}}}},475:(t,i,e)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Mask=void 0;const r=e(925);i.Mask=class{constructor(t,i=!1){this._size=new r.Size,void 0!==t&&this._size.copyFrom(t),this._bits=new Array(Math.ceil(this._size.area/32)).fill(i?4294967295:0)}toString(){let t="";for(let i=0;ii===t._bits[e]))}get width(){return this._size.width}get height(){return this._size.height}get(t,i){return this.getAtIndex(this.index(t,i))}getAtOffset(t){return this.get(t.x,t.y)}getAtIndex(t){const i=t>>>5,e=1<<(31&t);return 0!=(this._bits[i]&e)}copyFrom(t){return this._size.copyFrom(t._size),this._bits=t._bits.slice(),this}set(t,i,e){return this.setAtIndex(this.index(t,i),e)}setAtOffset(t,i){return this.set(t.x,t.y,i)}setAtIndex(t,i){const e=t>>>5,r=1<<(31&t);return i?this._bits[e]|=r:this._bits[e]&=~r,this}index(t,i){return this._size.index(t,i)}*locations(){let t=0,i=1;for(const{x:e,y:r}of this._size.offsets()){const n=0!=(this._bits[t]&i);yield{x:e,y:r,value:n},i===1<<31?(i=1,t++):i<<=1}}*offsetsWithTrue(){for(const{x:t,y:i,value:e}of this.locations())e&&(yield{x:t,y:i})}}},894:(t,i,e)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Offset=void 0;const r=e(778),n=[0,1,1,1,0,-1,-1,-1],s=[-1,-1,0,1,1,1,0,-1],a=[0,1,0,-1],o=[-1,0,1,0];i.Offset=class{constructor(t,i){void 0===t&&(t=0),void 0===i&&(i=0),this.x=t,this.y=i}toString(){return`(${this.x},${this.y})`}equals(t){return this.x===t.x&&this.y===t.y}set(t,i){return this.x=t,this.y=i,this}copyFrom(t){return this.set(t.x,t.y)}setFromDirection(t){return this.set(n[t],s[t])}setFromCardinalDirection(t){return this.set(a[t],o[t])}add(t,i){return this.x+=t,this.y+=i,this}addSize(t){return this.add(t.width,t.height)}addOffset(t){return this.add(t.x,t.y)}addDirection(t){return this.add(n[t],s[t])}addCardinalDirection(t){return this.add(a[t],o[t])}subtractOffset(t){return this.add(-t.x,-t.y)}multiply(t){return this.x*=t,this.y*=t,this}rotate(t,i){if(i)return this.subtractOffset(i).rotate(t).addOffset(i);{const i=r.cardinalDirectionFromNorthTurn(t),{x:e,y:n}=this,s=a[i],h=o[i],u=-n*s-e*h,l=e*s-n*h;return this.set(u,l)}}distanceChebyshev(t){return Math.max(Math.abs(this.x-t.x),Math.abs(this.y-t.y))}distanceManhattan(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}*nearbyChebyshevOffsets(t,i){if(i>=0)for(let e=-i;e<=i;e++)for(let r=-i;r<=i;r++)yield t.set(this.x+r,this.y+e)}}},37:(t,i,e)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RasterMask=void 0;const r=e(84);i.RasterMask=class{constructor(t,i){if(this._rect=new r.Rectangle,i.length!==t.height)throw new Error(`bad lines array length ${i.length} for bounds ${t}`);this._rect.copyFrom(t),this._lines=i}toString(){let t="";const{eastX:i}=this._rect;for(let e=0;ei.length===t._lines[e].length&&i.every(((i,r)=>i===t._lines[e][r]))))}get northY(){return this._rect.northY}get southY(){return this._rect.southY}get westX(){return this._rect.westX}get width(){return this._rect.width}get height(){return this._rect.height}get(t,i){if(ithis._rect.southY)return!1;const e=this._lines[i-this.northY];for(let i=0;i=e[i]&&t=this.northY&&t<=this._rect.southY){const i=this._lines[t-this.northY];for(let t=0;t{Object.defineProperty(i,"__esModule",{value:!0}),i.Rectangle=void 0;const r=e(925),n=e(894),s=[0,0,1,1],a=[0,1,1,0];i.Rectangle=class{constructor(t,i,e,s){void 0===t&&(t=0),void 0===i&&(i=0),void 0===e&&(e=0),void 0===s&&(s=0),this.northWest=new n.Offset(t,i),this.size=new r.Size(e,s)}toString(){return`(${this.westX},${this.northY} ${this.width}x${this.height})`}equals(t){return this.westX===t.westX&&this.northY===t.northY&&this.size.equals(t)}get northY(){return this.northWest.y}get southY(){return this.northWest.y+this.size.height-1}get westX(){return this.northWest.x}get eastX(){return this.northWest.x+this.size.width-1}get width(){return this.size.width}get height(){return this.size.height}get empty(){return this.size.empty}get area(){return this.size.area}set(t,i,e,r){return this.northWest.set(t,i),this.size.set(e,r),this}setFromCorners(t,i){const e=Math.min(t.x,i.x),r=Math.max(t.x,i.x),n=Math.min(t.y,i.y),s=Math.max(t.y,i.y);return this.set(e,n,r-e+1,s-n+1)}copyFrom(t){return this.set(t.westX,t.northY,t.width,t.height)}addOffset(t){return this.northWest.addOffset(t),this}scale(t){return this.northWest.multiply(t),this.size.multiply(t),this}rotate(t,i){const e=s[t],r=a[t];return this.northWest.add(e*(this.width-1),r*(this.height-1)).rotate(t,i),this.size.rotate(t),this}extendToInclude(t){const i=t.x-this.westX;i<0?(this.size.width-=i,this.northWest.x=t.x):i>=this.size.width&&(this.size.width=i+1);const e=t.y-this.northWest.y;return e<0?(this.size.height-=e,this.northWest.y=t.y):e>=this.size.height&&(this.size.height=e+1),this}contains(t,i){return this.size.contains(t-this.westX,i-this.northY)}index(t,i){return this.size.index(t-this.westX,i-this.northY)}containsOffset(t){return this.contains(t.x,t.y)}containsRectangle(t){if(0===t.width&&0===t.height)return!1;const i=t.westX-this.westX,e=t.northY-this.northY;return!!this.size.contains(i,e)&&this.size.contains(i+t.width-1,e+t.height-1)}overlapsRectangle(t){return this.northY<=t.northY+t.height-1&&this.southY>=t.northY&&this.westX<=t.westX+t.width-1&&this.eastX>=t.westX&&!this.empty&&0!==t.width&&0!==t.height}*offsets(){const{eastX:t,southY:i}=this;for(let e=this.northY;e<=i;e++)for(let i=this.westX;i<=t;i++)yield{x:i,y:e}}anyOf(t){for(const{x:i,y:e}of this.offsets())if(t(i,e))return!0;return!1}}},925:(t,i,e)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Size=void 0;const r=e(778);i.Size=class{constructor(t,i){if(void 0===t&&(t=0),void 0===i&&(i=0),t<0||i<0)throw new Error(`bad size (${t}x${i})`);this.width=t,this.height=i}toString(){return`(${this.width}x${this.height})`}equals(t){return this.width===t.width&&this.height===t.height}get empty(){return 0===this.width||0===this.height}get area(){return this.width*this.height}set(t,i){if(t<0||i<0)throw new Error(`bad size (${t}x${i})`);return this.width=t,this.height=i,this}copyFrom(t){return this.set(t.width,t.height)}add(t,i){return this.width+=t,this.height+=i,this}multiply(t){return this.width*=t,this.height*=t,this}rotate(t){return r.axisFromNorthSouthTurn(t)===r.Axis.WEST_EAST&&this.set(this.height,this.width),this}contains(t,i){return t>=0&&i>=0&&t{Object.defineProperty(i,"__esModule",{value:!0}),i.TransformRectangle=void 0;const r=e(84),n=e(778),s=e(894),a=e(925),o=new s.Offset,h=new s.Offset,u=new a.Size;i.TransformRectangle=class{constructor(t,i){this._size=new a.Size,this._flip=n.Flip.HEADS,this._rotate=n.CardinalTurn.NONE,this._translate=new s.Offset,this._matrix=[1,0,0,0,1,0],this._targetRect=new r.Rectangle,void 0===t||("number"==typeof t?this._size.set(t,i):this._size.copyFrom(t)),this._update()}toString(){return`[${this._size} -> ${n.flipToString(this._flip)} ${n.cardinalTurnToString(this._rotate)} ${this._translate} -> ${this._targetRect}]`}equals(t){return this._size.equals(t._size)&&this._flip===t._flip&&this._rotate===t._rotate&&this._translate.equals(t._translate)}get flip(){return this._flip}get rotate(){return this._rotate}get northY(){return this._translate.y}get southY(){return this._translate.y+this._targetRect.height-1}get westX(){return this._translate.x}get eastX(){return this._translate.x+this._targetRect.width-1}get width(){return this._targetRect.width}get height(){return this._targetRect.height}_update(){o.setFromCardinalDirection(n.cardinalDirectionFromNorthTurn(this._rotate));const t=this._flip===n.Flip.TAILS?-1:1;switch(this._matrix[0]=-o.y*t,this._matrix[1]=-o.x,this._matrix[2]=this._translate.x,this._matrix[3]=o.x*t,this._matrix[4]=-o.y,this._matrix[5]=this._translate.y,this._rotate){case n.CardinalTurn.NONE:this._flip===n.Flip.TAILS&&(this._matrix[2]+=this._size.width-1);break;case n.CardinalTurn.RIGHT:this._matrix[2]+=this._size.height-1,this._flip===n.Flip.TAILS&&(this._matrix[5]+=this._size.width-1);break;case n.CardinalTurn.AROUND:this._matrix[5]+=this._size.height-1,this._flip===n.Flip.HEADS&&(this._matrix[2]+=this._size.width-1);break;case n.CardinalTurn.LEFT:this._flip===n.Flip.HEADS&&(this._matrix[5]+=this._size.width-1)}return u.copyFrom(this._size).rotate(this._rotate),this._targetRect.set(this._translate.x,this._translate.y,u.width,u.height),this}copyFrom(t){return this._size.copyFrom(t._size),this._flip=t._flip,this._rotate=t._rotate,this._translate.copyFrom(t._translate),t._matrix.forEach(((t,i)=>this._matrix[i]=t)),this._targetRect.copyFrom(t._targetRect),this}reset(){return this._flip=n.Flip.HEADS,this._rotate=n.CardinalTurn.NONE,this._translate.set(0,0),this._update()}invert(){const t=n.cardinalTurnFromCardinalDirections(n.CardinalDirection.NORTH,n.cardinalDirectionFromCardinalOrientation(n.cardinalOrientationReverse(n.cardinalOrientationFromFlipAndCardinalDirection(this._flip,n.cardinalDirectionFromNorthTurn(this._rotate)))));return this._rotate=t,this._size.rotate(t),this._translate.multiply(-1),this._update()}setTransform(t,i,e){return this._flip=t,this._rotate=i,this._translate.copyFrom(e),this._update()}setFlip(t){return this._flip=t,this._update()}setRotate(t){return this._rotate=t,this._update()}setTranslate(t,i){return this._translate.set(t,i),this._update()}setTranslateOffset(t){return this._translate.copyFrom(t),this._update()}applyToCardinalOrientation(t){return this._flip===n.Flip.TAILS&&(t=n.cardinalOrientationFlip(t,n.Axis.NORTH_SOUTH)),n.cardinalOrientationAddCardinalTurn(t,this._rotate)}unapplyFromCardinalOrientation(t){return t=n.cardinalOrientationAddCardinalTurn(t,n.cardinalTurnReverse(this._rotate)),this._flip===n.Flip.TAILS&&(t=n.cardinalOrientationFlip(t,n.Axis.NORTH_SOUTH)),t}applyToCardinalDirection(t){return n.cardinalDirectionFromCardinalOrientation(this.applyToCardinalOrientation(n.cardinalOrientationFromFlipAndCardinalDirection(n.Flip.HEADS,t)))}unapplyFromCardinalDirection(t){return n.cardinalDirectionFromCardinalOrientation(this.unapplyFromCardinalOrientation(n.cardinalOrientationFromFlipAndCardinalDirection(n.Flip.HEADS,t)))}applyTo(t,i,e){const r=i*this._matrix[0]+e*this._matrix[1]+this._matrix[2],n=i*this._matrix[3]+e*this._matrix[4]+this._matrix[5];return t.set(r,n)}unapplyFrom(t,i,e){const r=i-this._matrix[2],n=e-this._matrix[5],s=r*this._matrix[0]+n*this._matrix[3],a=r*this._matrix[1]+n*this._matrix[4];return t.set(s,a)}applyToOffset(t,i){return void 0===i&&(i=t),this.applyTo(t,i.x,i.y)}unapplyFromOffset(t,i){return void 0===i&&(i=t),this.unapplyFrom(t,i.x,i.y)}applyToRectangle(t,i){return void 0!==i&&t.copyFrom(i),o.set(t.westX,t.northY),h.set(t.eastX,t.southY),this.applyToOffset(o),this.applyToOffset(h),t.setFromCorners(o,h)}unapplyFromRectangle(t,i){return void 0!==i&&t.copyFrom(i),o.set(t.westX,t.northY),h.set(t.eastX,t.southY),this.unapplyFromOffset(o),this.unapplyFromOffset(h),t.setFromCorners(o,h)}}},841:function(t,i,e){var r=this&&this.__createBinding||(Object.create?function(t,i,e,r){void 0===r&&(r=e),Object.defineProperty(t,r,{enumerable:!0,get:function(){return i[e]}})}:function(t,i,e,r){void 0===r&&(r=e),t[r]=i[e]}),n=this&&this.__exportStar||function(t,i){for(var e in t)"default"===e||Object.prototype.hasOwnProperty.call(i,e)||r(i,t,e)};Object.defineProperty(i,"__esModule",{value:!0}),n(e(778),i),n(e(551),i)},695:function(t,i,e){var r=this&&this.__createBinding||(Object.create?function(t,i,e,r){void 0===r&&(r=e),Object.defineProperty(t,r,{enumerable:!0,get:function(){return i[e]}})}:function(t,i,e,r){void 0===r&&(r=e),t[r]=i[e]}),n=this&&this.__setModuleDefault||(Object.create?function(t,i){Object.defineProperty(t,"default",{enumerable:!0,value:i})}:function(t,i){t.default=i}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var e in t)"default"!==e&&Object.prototype.hasOwnProperty.call(t,e)&&r(i,t,e);return n(i,t),i};Object.defineProperty(i,"__esModule",{value:!0}),i.computeFieldOfView=void 0;const a=s(e(841)),o=s(e(601)),h=e(550),u=e(720);function l(t,i,e,r,n,s){const{x:a,y:h}=e,l=(Math.min(Math.max(a+n*(r+1),-1),t.width)-a)*n,c=(Math.min(Math.max(h+s*(r+1),-1),t.height)-h)*s;if(l<0||c<0)return;const d=t.index(e.x,e.y),_=i.visible.index(e.x,e.y);let f=u.initWedges();for(let e=0,r=d,a=_;e!==c&&f.length>0;e++,r+=s*t.width,a+=s*i.visible.width){const s=1/(e+.5),h=0===e?Number.POSITIVE_INFINITY:1/(e-.5);let c=0;for(let d=0,_=r,T=a,g=-.5*s,O=.5*h;d!==l&&c!==f.length;d++,_+=n,T+=n,g+=s,O+=h){for(;g>f[c].high&&(c++,!(c>=f.length)););if(c>=f.length)break;O{Object.defineProperty(i,"__esModule",{value:!0}),i.WEDGE_COUNT=i.WEDGE_HIGH=i.WEDGE_LOW=i.BODY_INSET=void 0,i.BODY_INSET=1e-5,i.WEDGE_LOW=0,i.WEDGE_HIGH=1,i.WEDGE_COUNT=2},550:function(t,i,e){var r=this&&this.__createBinding||(Object.create?function(t,i,e,r){void 0===r&&(r=e),Object.defineProperty(t,r,{enumerable:!0,get:function(){return i[e]}})}:function(t,i,e,r){void 0===r&&(r=e),t[r]=i[e]}),n=this&&this.__setModuleDefault||(Object.create?function(t,i){Object.defineProperty(t,"default",{enumerable:!0,value:i})}:function(t,i){t.default=i}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var e in t)"default"!==e&&Object.prototype.hasOwnProperty.call(t,e)&&r(i,t,e);return n(i,t),i};Object.defineProperty(i,"__esModule",{value:!0}),i.FieldOfViewImpl=void 0;const a=s(e(841));i.FieldOfViewImpl=class{constructor(t,i){this.origin=t,this.chebyshevRadius=i;const e=new a.Rectangle(t.x-i,t.y-i,2*i+1,2*i+1);this.visible=new a.MaskRectangle(e),this.visible.setAtOffset(t,!0)}getVisible(t,i){return this.visible.get(t,i)}toString(){let t="";for(const i of this.visible.locations()){const{x:e,y:r}=i;this.origin.equals(i)?t+="@":this.getVisible(e,r)?t+="-":t+=".",e===this.visible.westX+this.visible.width-1&&(t+="\n")}return t}}},60:function(t,i,e){var r=this&&this.__createBinding||(Object.create?function(t,i,e,r){void 0===r&&(r=e),Object.defineProperty(t,r,{enumerable:!0,get:function(){return i[e]}})}:function(t,i,e,r){void 0===r&&(r=e),t[r]=i[e]}),n=this&&this.__setModuleDefault||(Object.create?function(t,i){Object.defineProperty(t,"default",{enumerable:!0,value:i})}:function(t,i){t.default=i}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var e in t)"default"!==e&&Object.prototype.hasOwnProperty.call(t,e)&&r(i,t,e);return n(i,t),i};Object.defineProperty(i,"__esModule",{value:!0}),i.FieldOfViewMap=void 0;const a=s(e(841));i.FieldOfViewMap=class{constructor(t,i){this._size=new a.Size,this._size.set(t,i),this._tileFlags=new Array(1+(this._size.area>>5)).fill(0)}get width(){return this._size.width}get height(){return this._size.height}addBody(t,i){if(this._size.contains(t,i)){const e=this.index(t,i);this._tileFlags[e>>5]|=1<<(31&e)}return this}removeBody(t,i){if(this._size.contains(t,i)){const e=this.index(t,i);this._tileFlags[e>>5]&=~(1<<(31&e))}return this}getBody(t,i){const e=this.index(t,i);return this.getBodyAtIndex(e)}index(t,i){return this._size.index(t,i)}getBodyAtIndex(t){return 0!=(this._tileFlags[t>>5]&1<<(31&t))}}},607:(t,i,e)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.computeFieldOfView=i.FieldOfViewMap=void 0;var r=e(60);Object.defineProperty(i,"FieldOfViewMap",{enumerable:!0,get:function(){return r.FieldOfViewMap}});var n=e(695);Object.defineProperty(i,"computeFieldOfView",{enumerable:!0,get:function(){return n.computeFieldOfView}})},720:(t,i)=>{function e(t,i,e){let r;if(i<=t.low)e>=t.high?r=[]:e>=t.low?(t.low=e,r=[t]):r=[t];else if(e>=t.high)i<=t.high?(t.high=i,r=[t]):r=[t];else{const n={low:e,high:t.high};t.high=i,r=[t,n]}return r}Object.defineProperty(i,"__esModule",{value:!0}),i.cutWedges=i.cutWedge=i.initWedges=void 0,i.initWedges=function(){return[{low:0,high:Number.POSITIVE_INFINITY}]},i.cutWedge=e,i.cutWedges=function(t,i,r){const n=new Array;for(const s of t)n.push(...e(s,i,r));return n}}},i={};return function e(r){if(i[r])return i[r].exports;var n=i[r]={exports:{}};return t[r].call(n.exports,n,n.exports,e),n.exports}(607)})(); -//# sourceMappingURL=the-field-2.0.0.min.js.map \ No newline at end of file +//# sourceMappingURL=the-field-2.0.1.min.js.map \ No newline at end of file diff --git a/dist/the-field-2.0.0.min.js.map b/dist/the-field-2.0.1.min.js.map similarity index 99% rename from dist/the-field-2.0.0.min.js.map rename to dist/the-field-2.0.1.min.js.map index c5f8893..edc636d 100644 --- a/dist/the-field-2.0.0.min.js.map +++ b/dist/the-field-2.0.1.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://TheField/./node_modules/tiled-geometry/lib/compass/axis.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-direction-flags.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-direction.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-orientation.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-turn.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/direction.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/flip.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/index.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/turn.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/cardinal-path.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/index.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/mask-rectangle.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/mask.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/offset.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/raster-mask.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/rectangle.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/size.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/transform-rectangle.js","webpack://TheField/./node_modules/tiled-geometry/lib/index.js","webpack://TheField/./src/compute.ts","webpack://TheField/./src/constants.ts","webpack://TheField/./src/field-of-view-impl.ts","webpack://TheField/./src/field-of-view-map.ts","webpack://TheField/./src/index.ts","webpack://TheField/./src/wedge.ts","webpack://TheField/webpack/bootstrap","webpack://TheField/webpack/startup"],"names":["Axis","Object","defineProperty","exports","value","axisAddCardinalTurn","axisFromNorthSouthTurn","axisFromCardinalDirection","axisOrthogonal","axisToString","AXES","NORTH_SOUTH","WEST_EAST","AXES_STR","axis","dir","turn","CardinalDirectionFlags","cardinalDirectionFlagsFromCardinalDirection","cardinalDirectionFlagsRemoveCardinalDirection","cardinalDirectionFlagsSetCardinalDirection","cardinalDirectionFlagsHasCardinalDirection","cardinalDirectionFlagsToString","flags","ret","NORTH","EAST","SOUTH","WEST","CardinalDirection","cardinalDirectionAddCardinalTurn","cardinalDirectionFromCardinalOrientation","cardinalDirectionFromNorthTurn","cardinalDirectionFromDirection","cardinalDirectionOpposite","cardinalDirectionToString","CARDINAL_DIRECTIONS","CARDINAL_DIRECTIONS_STR","orientation","cardinalOrientationAddCardinalTurn","cardinalOrientationFromFlipAndCardinalDirection","cardinalOrientationReverse","cardinalOrientationFlip","cardinalOrientationToString","CARDINAL_ORIENTATIONS","CardinalOrientation","axis_1","flip_1","HEADS_NORTH","TAILS_NORTH","HEADS_EAST","TAILS_EAST","HEADS_SOUTH","TAILS_SOUTH","HEADS_WEST","TAILS_WEST","CARDINAL_ORIENTATIONS_STR","flip","Flip","HEADS","CardinalTurn","cardinalTurnAddCardinalTurn","cardinalTurnFromTurn","cardinalTurnFromCardinalDirections","cardinalTurnReverse","cardinalTurnToDegrees","cardinalTurnToString","CARDINAL_TURNS","NONE","RIGHT","AROUND","LEFT","CARDINAL_TURNS_STR","from","to","turn1","turn2","Direction","directionAddCardinalTurn","directionAddTurn","directionFromCardinalDirection","directionOpposite","directionIsCardinal","directionToString","DIRECTIONS","NORTHEAST","SOUTHEAST","SOUTHWEST","NORTHWEST","DIRECTIONS_STR","flipFromCardinalOrientation","flipFromBoolean","flipOpposite","flipToString","FLIPS","TAILS","FLIPS_STR","tails","__createBinding","this","create","o","m","k","k2","undefined","enumerable","get","__exportStar","p","prototype","hasOwnProperty","call","Turn","turnAddTurn","turnFromDirections","turnFromCardinalTurn","turnFromCardinalDirections","turnReverse","turnIsCardinal","turnToDegrees","turnToString","TURNS","R_45","R_90","R_135","T_180","L_135","L_90","L_45","TURNS_STR","CardinalPath","compass_1","offset_1","rectangle_1","raster_mask_1","LOCAL_OFF","Offset","sortedInsert","array","push","i","length","start","segments","_start","copyFrom","_segments","toString","map","segment","join","other","equals","every","v","addCardinalDirection","x","y","setFromCardinalDirection","northY","southY","westX","eastX","Math","min","max","Error","Rectangle","total","abs","bounds","lines","Array","getBounds","height","RasterMask","width","MaskRectangle","mask_1","rect","initialValue","outsideValue","_rect","_mask","Mask","_outsideValue","northWest","contains","index","getAtIndex","off","set","setAtIndex","loc","locations","offsetsWithTrue","size_1","size","_size","Size","_bits","ceil","area","fill","arrayIndex","bitMask","slice","offsets","X_FROM_DIRECTION","Y_FROM_DIRECTION","X_FROM_CARDINAL_DIRECTION","Y_FROM_CARDINAL_DIRECTION","add","factor","anchor","subtractOffset","rotate","addOffset","dirx","diry","nx","ny","cursor","radius","dy","dx","_lines","shape","line","end","w","j","ROTATE_CORNER_X","ROTATE_CORNER_Y","empty","off1","off2","multiply","cx","cy","predicate","TransformRectangle","LOCAL_OFF2","LOCAL_SIZE","_flip","_rotate","_translate","_matrix","_targetRect","_update","flipSign","forEach","nrotate","translate","applyToCardinalOrientation","unapplyFromCardinalOrientation","offOut","tx","ty","applyTo","unapplyFrom","rectOut","applyToOffset","setFromCorners","unapplyFromOffset","__setModuleDefault","__importStar","mod","__esModule","result","computeFieldOfView","geom","constants","field_of_view_impl_1","wedge_1","quadrant","field","origin","chebyshevRadius","xSign","ySign","startX","startY","endDX","endDY","startMapIndex","startMaskIndex","visible","wedges","initWedges","yMapIndex","yMaskIndex","divYpos","divYneg","Number","POSITIVE_INFINITY","wedgeIndex","mapIndex","maskIndex","slopeY","slopeX","high","low","getBodyAtIndex","cutWedges","BODY_INSET","FieldOfViewImpl","WEDGE_COUNT","WEDGE_HIGH","WEDGE_LOW","boundRect","setAtOffset","location","getVisible","FieldOfViewMap","_tileFlags","field_of_view_map_1","compute_1","cutWedge","wedge","nextWedge","__webpack_module_cache__","__webpack_require__","moduleId","module","__webpack_modules__"],"mappings":"4DAGA,IAAIA,EAFJC,OAAOC,eAAeC,EAAS,aAAc,CAAEC,OAAO,IACtDD,EAAQE,oBAAsBF,EAAQG,uBAAyBH,EAAQI,0BAA4BJ,EAAQK,eAAiBL,EAAQM,aAAeN,EAAQO,KAAOP,EAAQH,UAAO,EAEjL,SAAWA,GACPA,EAAKA,EAAkB,YAAI,GAAK,cAChCA,EAAKA,EAAgB,UAAI,GAAK,YAFlC,CAGGA,EAAOG,EAAQH,OAASG,EAAQH,KAAO,KAC1CG,EAAQO,KAAO,CACXV,EAAKW,YACLX,EAAKY,WAET,MAAMC,EAAW,CACb,MACA,OAKJV,EAAQM,aAHR,SAAsBK,GAClB,OAAOD,EA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GAAQkB,EAAMjB,KAEnBiB,EAAMjB,IAAMD,EACZtR,EAAM,CAACwS,IAIPxS,EAAM,CAACwS,QAGV,GAAIlB,GAAQkB,EAAMlB,KACfC,GAAOiB,EAAMlB,MAEbkB,EAAMlB,KAAOC,EACbvR,EAAM,CAACwS,IAIPxS,EAAM,CAACwS,OAGV,CAED,MAAMC,EAAY,CACdlB,IAAKD,EACLA,KAAMkB,EAAMlB,MAEhBkB,EAAMlB,KAAOC,EACbvR,EAAM,CAACwS,EAAOC,GAMlB,OAAOzS,EAxEXvB,OAAOC,eAAeC,EAAS,aAAc,CAAEC,OAAO,IACtDD,EAAQ8S,UAAY9S,EAAQ4T,SAAW5T,EAAQ+R,gBAAa,EAqB5D/R,EAAQ+R,WAHR,WACI,MAAO,CAAC,CAAEa,IAAK,EAAGD,KAAMP,OAAOC,qBAsDnCrS,EAAQ4T,SAAWA,EAQnB5T,EAAQ8S,UAPR,SAAmBhB,EAAQc,EAAKD,GAC5B,MAAMtR,EAAM,IAAIqJ,MAChB,IAAK,MAAMmJ,KAAS/B,EAChBzQ,EAAIoH,QAAQmL,EAASC,EAAOjB,EAAKD,IAErC,OAAOtR,KChFP0S,EAA2B,GCE/B,ODCA,SAASC,EAAoBC,GAE5B,GAAGF,EAAyBE,GAC3B,OAAOF,EAAyBE,GAAUjU,QAG3C,IAAIkU,EAASH,EAAyBE,GAAY,CAGjDjU,QAAS,IAOV,OAHAmU,EAAoBF,GAAUpN,KAAKqN,EAAOlU,QAASkU,EAAQA,EAAOlU,QAASgU,GAGpEE,EAAOlU,QCjBRgU,CAAoB,M","file":"the-field-2.0.0.min.js","sourcesContent":["\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.axisAddCardinalTurn = exports.axisFromNorthSouthTurn = exports.axisFromCardinalDirection = exports.axisOrthogonal = exports.axisToString = exports.AXES = exports.Axis = void 0;\r\nvar Axis;\r\n(function (Axis) {\r\n Axis[Axis[\"NORTH_SOUTH\"] = 0] = \"NORTH_SOUTH\";\r\n Axis[Axis[\"WEST_EAST\"] = 1] = \"WEST_EAST\";\r\n})(Axis = exports.Axis || (exports.Axis = {}));\r\nexports.AXES = [\r\n Axis.NORTH_SOUTH,\r\n Axis.WEST_EAST,\r\n];\r\nconst AXES_STR = [\r\n 'N-S',\r\n 'W-E',\r\n];\r\nfunction axisToString(axis) {\r\n return AXES_STR[axis];\r\n}\r\nexports.axisToString = axisToString;\r\nfunction axisOrthogonal(axis) {\r\n return (axis ^ 1);\r\n}\r\nexports.axisOrthogonal = axisOrthogonal;\r\n// conversion\r\nfunction axisFromCardinalDirection(dir) {\r\n return (dir & 1);\r\n}\r\nexports.axisFromCardinalDirection = axisFromCardinalDirection;\r\nfunction axisFromNorthSouthTurn(turn) {\r\n return (turn & 1);\r\n}\r\nexports.axisFromNorthSouthTurn = axisFromNorthSouthTurn;\r\n// math\r\nfunction axisAddCardinalTurn(axis, turn) {\r\n return ((axis + turn) & 1);\r\n}\r\nexports.axisAddCardinalTurn = axisAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalDirectionFlagsFromCardinalDirection = exports.cardinalDirectionFlagsRemoveCardinalDirection = exports.cardinalDirectionFlagsSetCardinalDirection = exports.cardinalDirectionFlagsHasCardinalDirection = exports.cardinalDirectionFlagsToString = exports.CardinalDirectionFlags = void 0;\r\nvar CardinalDirectionFlags;\r\n(function (CardinalDirectionFlags) {\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"NONE\"] = 0] = \"NONE\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"NORTH\"] = 1] = \"NORTH\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"EAST\"] = 2] = \"EAST\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"SOUTH\"] = 4] = \"SOUTH\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"WEST\"] = 8] = \"WEST\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"ALL\"] = 15] = \"ALL\";\r\n})(CardinalDirectionFlags = exports.CardinalDirectionFlags || (exports.CardinalDirectionFlags = {}));\r\nfunction cardinalDirectionFlagsToString(flags) {\r\n let ret = '[';\r\n if ((flags & CardinalDirectionFlags.NORTH) !== 0) {\r\n ret += 'N';\r\n }\r\n if ((flags & CardinalDirectionFlags.EAST) !== 0) {\r\n ret += 'E';\r\n }\r\n if ((flags & CardinalDirectionFlags.SOUTH) !== 0) {\r\n ret += 'S';\r\n }\r\n if ((flags & CardinalDirectionFlags.WEST) !== 0) {\r\n ret += 'W';\r\n }\r\n return ret + ']';\r\n}\r\nexports.cardinalDirectionFlagsToString = cardinalDirectionFlagsToString;\r\nfunction cardinalDirectionFlagsHasCardinalDirection(flags, dir) {\r\n return (flags & cardinalDirectionFlagsFromCardinalDirection(dir)) !== 0;\r\n}\r\nexports.cardinalDirectionFlagsHasCardinalDirection = cardinalDirectionFlagsHasCardinalDirection;\r\nfunction cardinalDirectionFlagsSetCardinalDirection(flags, dir) {\r\n return (flags | cardinalDirectionFlagsFromCardinalDirection(dir));\r\n}\r\nexports.cardinalDirectionFlagsSetCardinalDirection = cardinalDirectionFlagsSetCardinalDirection;\r\nfunction cardinalDirectionFlagsRemoveCardinalDirection(flags, dir) {\r\n return (flags & ~cardinalDirectionFlagsFromCardinalDirection(dir));\r\n}\r\nexports.cardinalDirectionFlagsRemoveCardinalDirection = cardinalDirectionFlagsRemoveCardinalDirection;\r\n// conversion\r\nfunction cardinalDirectionFlagsFromCardinalDirection(dir) {\r\n return (1 << dir);\r\n}\r\nexports.cardinalDirectionFlagsFromCardinalDirection = cardinalDirectionFlagsFromCardinalDirection;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalDirectionAddCardinalTurn = exports.cardinalDirectionFromCardinalOrientation = exports.cardinalDirectionFromNorthTurn = exports.cardinalDirectionFromDirection = exports.cardinalDirectionOpposite = exports.cardinalDirectionToString = exports.CARDINAL_DIRECTIONS = exports.CardinalDirection = void 0;\r\nvar CardinalDirection;\r\n(function (CardinalDirection) {\r\n CardinalDirection[CardinalDirection[\"NORTH\"] = 0] = \"NORTH\";\r\n CardinalDirection[CardinalDirection[\"EAST\"] = 1] = \"EAST\";\r\n CardinalDirection[CardinalDirection[\"SOUTH\"] = 2] = \"SOUTH\";\r\n CardinalDirection[CardinalDirection[\"WEST\"] = 3] = \"WEST\";\r\n})(CardinalDirection = exports.CardinalDirection || (exports.CardinalDirection = {}));\r\nexports.CARDINAL_DIRECTIONS = [\r\n CardinalDirection.NORTH,\r\n CardinalDirection.EAST,\r\n CardinalDirection.SOUTH,\r\n CardinalDirection.WEST,\r\n];\r\nconst CARDINAL_DIRECTIONS_STR = [\r\n 'N',\r\n 'E',\r\n 'S',\r\n 'W',\r\n];\r\nfunction cardinalDirectionToString(dir) {\r\n return CARDINAL_DIRECTIONS_STR[dir];\r\n}\r\nexports.cardinalDirectionToString = cardinalDirectionToString;\r\nfunction cardinalDirectionOpposite(dir) {\r\n return ((dir + 2) & 3);\r\n}\r\nexports.cardinalDirectionOpposite = cardinalDirectionOpposite;\r\n// conversion\r\nfunction cardinalDirectionFromDirection(dir) {\r\n return (dir >> 1);\r\n}\r\nexports.cardinalDirectionFromDirection = cardinalDirectionFromDirection;\r\nfunction cardinalDirectionFromNorthTurn(turn) {\r\n return turn;\r\n}\r\nexports.cardinalDirectionFromNorthTurn = cardinalDirectionFromNorthTurn;\r\nfunction cardinalDirectionFromCardinalOrientation(orientation) {\r\n return (orientation >>> 1);\r\n}\r\nexports.cardinalDirectionFromCardinalOrientation = cardinalDirectionFromCardinalOrientation;\r\n// math\r\nfunction cardinalDirectionAddCardinalTurn(dir, turn) {\r\n return ((dir + turn) & 3);\r\n}\r\nexports.cardinalDirectionAddCardinalTurn = cardinalDirectionAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalOrientationAddCardinalTurn = exports.cardinalOrientationFromFlipAndCardinalDirection = exports.cardinalOrientationReverse = exports.cardinalOrientationFlip = exports.cardinalOrientationToString = exports.CARDINAL_ORIENTATIONS = exports.CardinalOrientation = void 0;\r\nconst axis_1 = require(\"./axis\");\r\nconst flip_1 = require(\"./flip\");\r\nvar CardinalOrientation;\r\n(function (CardinalOrientation) {\r\n CardinalOrientation[CardinalOrientation[\"HEADS_NORTH\"] = 0] = \"HEADS_NORTH\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_NORTH\"] = 1] = \"TAILS_NORTH\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_EAST\"] = 2] = \"HEADS_EAST\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_EAST\"] = 3] = \"TAILS_EAST\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_SOUTH\"] = 4] = \"HEADS_SOUTH\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_SOUTH\"] = 5] = \"TAILS_SOUTH\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_WEST\"] = 6] = \"HEADS_WEST\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_WEST\"] = 7] = \"TAILS_WEST\";\r\n})(CardinalOrientation = exports.CardinalOrientation || (exports.CardinalOrientation = {}));\r\nexports.CARDINAL_ORIENTATIONS = [\r\n CardinalOrientation.HEADS_NORTH,\r\n CardinalOrientation.TAILS_NORTH,\r\n CardinalOrientation.HEADS_EAST,\r\n CardinalOrientation.TAILS_EAST,\r\n CardinalOrientation.HEADS_SOUTH,\r\n CardinalOrientation.TAILS_SOUTH,\r\n CardinalOrientation.HEADS_WEST,\r\n CardinalOrientation.TAILS_WEST,\r\n];\r\nconst CARDINAL_ORIENTATIONS_STR = [\r\n 'HN',\r\n 'TN',\r\n 'HE',\r\n 'TE',\r\n 'HS',\r\n 'TS',\r\n 'HW',\r\n 'TW',\r\n];\r\nfunction cardinalOrientationToString(orientation) {\r\n return CARDINAL_ORIENTATIONS_STR[orientation];\r\n}\r\nexports.cardinalOrientationToString = cardinalOrientationToString;\r\nfunction cardinalOrientationFlip(orientation, axis) {\r\n if (axis === axis_1.Axis.NORTH_SOUTH) {\r\n return ((9 - orientation) & 7);\r\n }\r\n else {\r\n return ((13 - orientation) & 7);\r\n }\r\n}\r\nexports.cardinalOrientationFlip = cardinalOrientationFlip;\r\nfunction cardinalOrientationReverse(orientation) {\r\n if (orientation === CardinalOrientation.HEADS_EAST) {\r\n return CardinalOrientation.HEADS_WEST;\r\n }\r\n else if (orientation === CardinalOrientation.HEADS_WEST) {\r\n return CardinalOrientation.HEADS_EAST;\r\n }\r\n else {\r\n return orientation;\r\n }\r\n}\r\nexports.cardinalOrientationReverse = cardinalOrientationReverse;\r\n// conversion\r\nfunction cardinalOrientationFromFlipAndCardinalDirection(flip, dir) {\r\n return (dir * 2 + (flip !== flip_1.Flip.HEADS ? 1 : 0));\r\n}\r\nexports.cardinalOrientationFromFlipAndCardinalDirection = cardinalOrientationFromFlipAndCardinalDirection;\r\n// math\r\nfunction cardinalOrientationAddCardinalTurn(orientation, turn) {\r\n return ((orientation + turn * 2) & 7);\r\n}\r\nexports.cardinalOrientationAddCardinalTurn = cardinalOrientationAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalTurnAddCardinalTurn = exports.cardinalTurnFromTurn = exports.cardinalTurnFromCardinalDirections = exports.cardinalTurnReverse = exports.cardinalTurnToDegrees = exports.cardinalTurnToString = exports.CARDINAL_TURNS = exports.CardinalTurn = void 0;\r\nvar CardinalTurn;\r\n(function (CardinalTurn) {\r\n CardinalTurn[CardinalTurn[\"NONE\"] = 0] = \"NONE\";\r\n CardinalTurn[CardinalTurn[\"RIGHT\"] = 1] = \"RIGHT\";\r\n CardinalTurn[CardinalTurn[\"AROUND\"] = 2] = \"AROUND\";\r\n CardinalTurn[CardinalTurn[\"LEFT\"] = 3] = \"LEFT\";\r\n})(CardinalTurn = exports.CardinalTurn || (exports.CardinalTurn = {}));\r\nexports.CARDINAL_TURNS = [\r\n CardinalTurn.NONE,\r\n CardinalTurn.RIGHT,\r\n CardinalTurn.AROUND,\r\n CardinalTurn.LEFT,\r\n];\r\nconst CARDINAL_TURNS_STR = [\r\n 'T0',\r\n 'T+90',\r\n 'T180',\r\n 'T-90',\r\n];\r\nfunction cardinalTurnToString(dir) {\r\n return CARDINAL_TURNS_STR[dir];\r\n}\r\nexports.cardinalTurnToString = cardinalTurnToString;\r\nfunction cardinalTurnToDegrees(turn) {\r\n return turn * 90;\r\n}\r\nexports.cardinalTurnToDegrees = cardinalTurnToDegrees;\r\nfunction cardinalTurnReverse(dir) {\r\n return ((4 - dir) & 3);\r\n}\r\nexports.cardinalTurnReverse = cardinalTurnReverse;\r\n// conversion\r\nfunction cardinalTurnFromCardinalDirections(from, to) {\r\n return ((to - from) & 3);\r\n}\r\nexports.cardinalTurnFromCardinalDirections = cardinalTurnFromCardinalDirections;\r\nfunction cardinalTurnFromTurn(turn) {\r\n return (turn >> 1);\r\n}\r\nexports.cardinalTurnFromTurn = cardinalTurnFromTurn;\r\n// math\r\nfunction cardinalTurnAddCardinalTurn(turn1, turn2) {\r\n return ((turn1 + turn2) & 3);\r\n}\r\nexports.cardinalTurnAddCardinalTurn = cardinalTurnAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.directionAddCardinalTurn = exports.directionAddTurn = exports.directionFromCardinalDirection = exports.directionOpposite = exports.directionIsCardinal = exports.directionToString = exports.DIRECTIONS = exports.Direction = void 0;\r\nvar Direction;\r\n(function (Direction) {\r\n Direction[Direction[\"NORTH\"] = 0] = \"NORTH\";\r\n Direction[Direction[\"NORTHEAST\"] = 1] = \"NORTHEAST\";\r\n Direction[Direction[\"EAST\"] = 2] = \"EAST\";\r\n Direction[Direction[\"SOUTHEAST\"] = 3] = \"SOUTHEAST\";\r\n Direction[Direction[\"SOUTH\"] = 4] = \"SOUTH\";\r\n Direction[Direction[\"SOUTHWEST\"] = 5] = \"SOUTHWEST\";\r\n Direction[Direction[\"WEST\"] = 6] = \"WEST\";\r\n Direction[Direction[\"NORTHWEST\"] = 7] = \"NORTHWEST\";\r\n})(Direction = exports.Direction || (exports.Direction = {}));\r\nexports.DIRECTIONS = [\r\n Direction.NORTH,\r\n Direction.NORTHEAST,\r\n Direction.EAST,\r\n Direction.SOUTHEAST,\r\n Direction.SOUTH,\r\n Direction.SOUTHWEST,\r\n Direction.WEST,\r\n Direction.NORTHWEST,\r\n];\r\nconst DIRECTIONS_STR = [\r\n 'N',\r\n 'NE',\r\n 'E',\r\n 'SE',\r\n 'S',\r\n 'SW',\r\n 'W',\r\n 'NW',\r\n];\r\nfunction directionToString(dir) {\r\n return DIRECTIONS_STR[dir];\r\n}\r\nexports.directionToString = directionToString;\r\nfunction directionIsCardinal(dir) {\r\n return (dir & 1) === 0;\r\n}\r\nexports.directionIsCardinal = directionIsCardinal;\r\nfunction directionOpposite(dir) {\r\n return ((dir + 4) & 7);\r\n}\r\nexports.directionOpposite = directionOpposite;\r\n// conversion\r\nfunction directionFromCardinalDirection(dir) {\r\n return (dir << 1);\r\n}\r\nexports.directionFromCardinalDirection = directionFromCardinalDirection;\r\n// math\r\nfunction directionAddTurn(dir, turn) {\r\n return ((dir + turn) & 7);\r\n}\r\nexports.directionAddTurn = directionAddTurn;\r\nfunction directionAddCardinalTurn(dir, turn) {\r\n return ((dir + turn * 2) & 7);\r\n}\r\nexports.directionAddCardinalTurn = directionAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.flipFromCardinalOrientation = exports.flipFromBoolean = exports.flipOpposite = exports.flipToString = exports.FLIPS = exports.Flip = void 0;\r\nvar Flip;\r\n(function (Flip) {\r\n Flip[Flip[\"HEADS\"] = 0] = \"HEADS\";\r\n Flip[Flip[\"TAILS\"] = 1] = \"TAILS\";\r\n})(Flip = exports.Flip || (exports.Flip = {}));\r\nexports.FLIPS = [\r\n Flip.HEADS,\r\n Flip.TAILS,\r\n];\r\nconst FLIPS_STR = [\r\n 'H',\r\n 'T',\r\n];\r\nfunction flipToString(flip) {\r\n return FLIPS_STR[flip];\r\n}\r\nexports.flipToString = flipToString;\r\nfunction flipOpposite(flip) {\r\n return (flip ^ 1);\r\n}\r\nexports.flipOpposite = flipOpposite;\r\n// conversion\r\nfunction flipFromBoolean(tails) {\r\n return tails ? Flip.TAILS : Flip.HEADS;\r\n}\r\nexports.flipFromBoolean = flipFromBoolean;\r\nfunction flipFromCardinalOrientation(orientation) {\r\n return (orientation & 1);\r\n}\r\nexports.flipFromCardinalOrientation = flipFromCardinalOrientation;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./direction\"), exports);\r\n__exportStar(require(\"./turn\"), exports);\r\n__exportStar(require(\"./cardinal-direction\"), exports);\r\n__exportStar(require(\"./cardinal-turn\"), exports);\r\n__exportStar(require(\"./cardinal-direction-flags\"), exports);\r\n__exportStar(require(\"./flip\"), exports);\r\n__exportStar(require(\"./cardinal-orientation\"), exports);\r\n__exportStar(require(\"./axis\"), exports);\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.turnAddTurn = exports.turnFromDirections = exports.turnFromCardinalTurn = exports.turnFromCardinalDirections = exports.turnReverse = exports.turnIsCardinal = exports.turnToDegrees = exports.turnToString = exports.TURNS = exports.Turn = void 0;\r\nvar Turn;\r\n(function (Turn) {\r\n Turn[Turn[\"NONE\"] = 0] = \"NONE\";\r\n Turn[Turn[\"R_45\"] = 1] = \"R_45\";\r\n Turn[Turn[\"R_90\"] = 2] = \"R_90\";\r\n Turn[Turn[\"R_135\"] = 3] = \"R_135\";\r\n Turn[Turn[\"T_180\"] = 4] = \"T_180\";\r\n Turn[Turn[\"L_135\"] = 5] = \"L_135\";\r\n Turn[Turn[\"L_90\"] = 6] = \"L_90\";\r\n Turn[Turn[\"L_45\"] = 7] = \"L_45\";\r\n})(Turn = exports.Turn || (exports.Turn = {}));\r\nexports.TURNS = [\r\n Turn.NONE,\r\n Turn.R_45,\r\n Turn.R_90,\r\n Turn.R_135,\r\n Turn.T_180,\r\n Turn.L_135,\r\n Turn.L_90,\r\n Turn.L_45,\r\n];\r\nconst TURNS_STR = [\r\n 'T0',\r\n 'T+45',\r\n 'T+90',\r\n 'T+135',\r\n 'T180',\r\n 'T-135',\r\n 'T-90',\r\n 'T-45',\r\n];\r\nfunction turnToString(turn) {\r\n return TURNS_STR[turn];\r\n}\r\nexports.turnToString = turnToString;\r\nfunction turnToDegrees(turn) {\r\n return turn * 45;\r\n}\r\nexports.turnToDegrees = turnToDegrees;\r\nfunction turnIsCardinal(turn) {\r\n return (turn & 1) === 0;\r\n}\r\nexports.turnIsCardinal = turnIsCardinal;\r\nfunction turnReverse(turn) {\r\n return ((8 - turn) & 7);\r\n}\r\nexports.turnReverse = turnReverse;\r\n// conversion\r\nfunction turnFromCardinalDirections(from, to) {\r\n return (((to - from) * 2) & 7);\r\n}\r\nexports.turnFromCardinalDirections = turnFromCardinalDirections;\r\nfunction turnFromCardinalTurn(turn) {\r\n return (turn << 1);\r\n}\r\nexports.turnFromCardinalTurn = turnFromCardinalTurn;\r\nfunction turnFromDirections(from, to) {\r\n return ((to - from) & 7);\r\n}\r\nexports.turnFromDirections = turnFromDirections;\r\n// math\r\nfunction turnAddTurn(turn1, turn2) {\r\n return ((turn1 + turn2) & 7);\r\n}\r\nexports.turnAddTurn = turnAddTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.CardinalPath = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nconst offset_1 = require(\"./offset\");\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst raster_mask_1 = require(\"./raster-mask\");\r\nconst LOCAL_OFF = new offset_1.Offset();\r\nfunction sortedInsert(array, value) {\r\n array.push(value);\r\n let i = array.length - 1;\r\n while (i > 0 && value < array[i - 1]) {\r\n array[i] = array[i - 1];\r\n i--;\r\n }\r\n array[i] = value;\r\n}\r\nclass CardinalPath {\r\n constructor(start, segments) {\r\n this._start = new offset_1.Offset();\r\n this._start.copyFrom(start);\r\n this._segments = segments;\r\n }\r\n // accessors\r\n toString() {\r\n return `${this._start.toString()}:`\r\n + `${this._segments.map((segment) => compass_1.cardinalDirectionToString(segment)).join('')}`;\r\n }\r\n equals(other) {\r\n return this._start.equals(other._start)\r\n && this._segments.length === other._segments.length\r\n && this._segments.every((v, i) => v === other._segments[i]);\r\n }\r\n get length() {\r\n return this._segments.length;\r\n }\r\n // utilities\r\n getIsClosed() {\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n }\r\n return this._start.equals(LOCAL_OFF);\r\n }\r\n *offsets() {\r\n let { x, y } = this._start;\r\n yield { x, y };\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.setFromCardinalDirection(segment);\r\n x += LOCAL_OFF.x;\r\n y += LOCAL_OFF.y;\r\n yield { x, y };\r\n }\r\n }\r\n getBounds() {\r\n let northY = this._start.y;\r\n let southY = northY;\r\n let westX = this._start.x;\r\n let eastX = westX;\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n switch (segment) {\r\n case compass_1.CardinalDirection.NORTH:\r\n northY = Math.min(northY, LOCAL_OFF.y);\r\n break;\r\n case compass_1.CardinalDirection.EAST:\r\n eastX = Math.max(eastX, LOCAL_OFF.x);\r\n break;\r\n case compass_1.CardinalDirection.SOUTH:\r\n southY = Math.max(southY, LOCAL_OFF.y);\r\n break;\r\n case compass_1.CardinalDirection.WEST:\r\n westX = Math.min(westX, LOCAL_OFF.x);\r\n break;\r\n // istanbul ignore next\r\n default:\r\n throw new Error(`bad direction ${segment} in cardinal path`);\r\n }\r\n }\r\n return new rectangle_1.Rectangle(westX, northY, eastX - westX + 1, southY - northY + 1);\r\n }\r\n getArea() {\r\n let total = 0;\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n switch (segment) {\r\n case compass_1.CardinalDirection.NORTH:\r\n total -= LOCAL_OFF.x;\r\n break;\r\n case compass_1.CardinalDirection.SOUTH:\r\n total += LOCAL_OFF.x;\r\n break;\r\n }\r\n }\r\n return Math.abs(total);\r\n }\r\n rasterize(bounds) {\r\n const lines = new Array();\r\n if (typeof bounds === 'undefined') {\r\n bounds = this.getBounds();\r\n }\r\n // assert(this.getIsClosed())\r\n LOCAL_OFF.copyFrom(this._start);\r\n const { northY } = bounds;\r\n const southY = northY + bounds.height - 1;\r\n for (let y = northY; y < southY; y++) {\r\n lines.push([]);\r\n }\r\n LOCAL_OFF.copyFrom(this._start);\r\n // assert(LOCAL_OFF.y >= northY && LOCAL_OFF.y <= southY)\r\n for (const segment of this._segments) {\r\n if (segment === compass_1.CardinalDirection.SOUTH) {\r\n sortedInsert(lines[LOCAL_OFF.y - northY], LOCAL_OFF.x);\r\n }\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n // assert(LOCAL_OFF.y >= northY && LOCAL_OFF.y <= southY)\r\n if (segment === compass_1.CardinalDirection.NORTH) {\r\n sortedInsert(lines[LOCAL_OFF.y - northY], LOCAL_OFF.x);\r\n }\r\n }\r\n return new raster_mask_1.RasterMask({\r\n westX: bounds.westX,\r\n northY: bounds.northY,\r\n width: bounds.width - 1,\r\n height: bounds.height - 1,\r\n }, lines);\r\n }\r\n}\r\nexports.CardinalPath = CardinalPath;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./offset\"), exports);\r\n__exportStar(require(\"./size\"), exports);\r\n__exportStar(require(\"./rectangle\"), exports);\r\n__exportStar(require(\"./mask\"), exports);\r\n__exportStar(require(\"./mask-rectangle\"), exports);\r\n__exportStar(require(\"./raster-mask\"), exports);\r\n__exportStar(require(\"./cardinal-path\"), exports);\r\n__exportStar(require(\"./transform-rectangle\"), exports);\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.MaskRectangle = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst mask_1 = require(\"./mask\");\r\nclass MaskRectangle {\r\n constructor(rect, initialValue = false, outsideValue = false) {\r\n this._rect = new rectangle_1.Rectangle();\r\n if (typeof rect !== 'undefined') {\r\n this._rect.copyFrom(rect);\r\n }\r\n this._mask = new mask_1.Mask(rect, initialValue);\r\n this._outsideValue = outsideValue;\r\n }\r\n // accessors\r\n toString() {\r\n return `${this._rect.northWest}/${this._outsideValue}\\n${this._mask}`;\r\n }\r\n equals(other) {\r\n return this._rect.equals(other._rect)\r\n && this._mask.equals(other._mask)\r\n && this._outsideValue === other._outsideValue;\r\n }\r\n get westX() {\r\n return this._rect.westX;\r\n }\r\n get northY() {\r\n return this._rect.northY;\r\n }\r\n get width() {\r\n return this._rect.width;\r\n }\r\n get height() {\r\n return this._rect.height;\r\n }\r\n get(x, y) {\r\n if (!this._rect.contains(x, y)) {\r\n return this._outsideValue;\r\n }\r\n return this._mask.get(x - this.westX, y - this.northY);\r\n }\r\n getAtIndex(index) {\r\n return this._mask.getAtIndex(index);\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._rect.copyFrom(other._rect);\r\n this._mask.copyFrom(other._mask);\r\n this._outsideValue = other._outsideValue;\r\n return this;\r\n }\r\n set(x, y, value) {\r\n this._mask.set(x - this.westX, y - this.northY, value);\r\n return this;\r\n }\r\n setAtOffset(off, value) {\r\n return this.set(off.x, off.y, value);\r\n }\r\n setAtIndex(index, value) {\r\n this._mask.setAtIndex(index, value);\r\n return this;\r\n }\r\n // utilities\r\n index(x, y) {\r\n return this._mask.index(x - this.westX, y - this.northY);\r\n }\r\n *locations() {\r\n for (const loc of this._mask.locations()) {\r\n const x = loc.x + this.westX;\r\n const y = loc.y + this.northY;\r\n const { value } = loc;\r\n yield { x, y, value };\r\n }\r\n }\r\n *offsetsWithTrue() {\r\n for (const off of this._mask.offsetsWithTrue()) {\r\n const x = off.x + this.westX;\r\n const y = off.y + this.northY;\r\n yield { x, y };\r\n }\r\n }\r\n}\r\nexports.MaskRectangle = MaskRectangle;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Mask = void 0;\r\nconst size_1 = require(\"./size\");\r\nclass Mask {\r\n constructor(size, initialValue = false) {\r\n this._size = new size_1.Size();\r\n if (typeof size !== 'undefined') {\r\n this._size.copyFrom(size);\r\n }\r\n this._bits = new Array(Math.ceil(this._size.area / 32)).fill(initialValue ? 0xffffffff : 0);\r\n }\r\n // accessors\r\n toString() {\r\n let ret = '';\r\n for (let y = 0; y < this.height; y++) {\r\n for (let x = 0; x < this.width; x++) {\r\n ret += this.get(x, y) ? '☑' : '☐';\r\n }\r\n ret += '\\n';\r\n }\r\n return ret;\r\n }\r\n equals(other) {\r\n return this._size.equals(other._size)\r\n && this._bits.length === other._bits.length\r\n && this._bits.every((v, i) => v === other._bits[i]);\r\n }\r\n get width() {\r\n return this._size.width;\r\n }\r\n get height() {\r\n return this._size.height;\r\n }\r\n get(x, y) {\r\n return this.getAtIndex(this.index(x, y));\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n getAtIndex(index) {\r\n // assert(index >= 0 && index < this._size.area)\r\n const arrayIndex = index >>> 5;\r\n const bitMask = 1 << (index & 31);\r\n return (this._bits[arrayIndex] & bitMask) !== 0;\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._size.copyFrom(other._size);\r\n this._bits = other._bits.slice();\r\n return this;\r\n }\r\n set(x, y, value) {\r\n return this.setAtIndex(this.index(x, y), value);\r\n }\r\n setAtOffset(off, value) {\r\n return this.set(off.x, off.y, value);\r\n }\r\n setAtIndex(index, value) {\r\n // assert(index >= 0 && index < this._size.area)\r\n const arrayIndex = index >>> 5;\r\n const bitMask = 1 << (index & 31);\r\n if (value) {\r\n this._bits[arrayIndex] |= bitMask;\r\n }\r\n else {\r\n this._bits[arrayIndex] &= ~bitMask;\r\n }\r\n return this;\r\n }\r\n // utilities\r\n index(x, y) {\r\n return this._size.index(x, y);\r\n }\r\n *locations() {\r\n let arrayIndex = 0;\r\n let bitMask = 1;\r\n for (const { x, y } of this._size.offsets()) {\r\n const value = (this._bits[arrayIndex] & bitMask) !== 0;\r\n yield { x, y, value };\r\n if (bitMask === (1 << 31)) {\r\n bitMask = 1;\r\n arrayIndex++;\r\n }\r\n else {\r\n bitMask <<= 1;\r\n }\r\n }\r\n }\r\n *offsetsWithTrue() {\r\n for (const { x, y, value } of this.locations()) {\r\n if (value) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n}\r\nexports.Mask = Mask;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Offset = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nconst X_FROM_DIRECTION = [0, 1, 1, 1, 0, -1, -1, -1];\r\nconst Y_FROM_DIRECTION = [-1, -1, 0, 1, 1, 1, 0, -1];\r\nconst X_FROM_CARDINAL_DIRECTION = [0, 1, 0, -1];\r\nconst Y_FROM_CARDINAL_DIRECTION = [-1, 0, 1, 0];\r\nclass Offset {\r\n constructor(x, y) {\r\n if (typeof x === 'undefined') {\r\n x = 0;\r\n }\r\n if (typeof y === 'undefined') {\r\n y = 0;\r\n }\r\n this.x = x;\r\n this.y = y;\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.x},${this.y})`;\r\n }\r\n equals(other) {\r\n return this.x === other.x && this.y === other.y;\r\n }\r\n // mutators\r\n set(x, y) {\r\n this.x = x;\r\n this.y = y;\r\n return this;\r\n }\r\n copyFrom(other) {\r\n return this.set(other.x, other.y);\r\n }\r\n setFromDirection(dir) {\r\n return this.set(X_FROM_DIRECTION[dir], Y_FROM_DIRECTION[dir]);\r\n }\r\n setFromCardinalDirection(dir) {\r\n return this.set(X_FROM_CARDINAL_DIRECTION[dir], Y_FROM_CARDINAL_DIRECTION[dir]);\r\n }\r\n add(x, y) {\r\n this.x += x;\r\n this.y += y;\r\n return this;\r\n }\r\n addSize(size) {\r\n return this.add(size.width, size.height);\r\n }\r\n addOffset(off) {\r\n return this.add(off.x, off.y);\r\n }\r\n addDirection(dir) {\r\n return this.add(X_FROM_DIRECTION[dir], Y_FROM_DIRECTION[dir]);\r\n }\r\n addCardinalDirection(dir) {\r\n return this.add(X_FROM_CARDINAL_DIRECTION[dir], Y_FROM_CARDINAL_DIRECTION[dir]);\r\n }\r\n subtractOffset(off) {\r\n return this.add(-off.x, -off.y);\r\n }\r\n multiply(factor) {\r\n this.x *= factor;\r\n this.y *= factor;\r\n return this;\r\n }\r\n rotate(turn, anchor) {\r\n if (anchor) {\r\n return this.subtractOffset(anchor).rotate(turn).addOffset(anchor);\r\n }\r\n else {\r\n const dir = compass_1.cardinalDirectionFromNorthTurn(turn);\r\n const { x, y } = this;\r\n const dirx = X_FROM_CARDINAL_DIRECTION[dir];\r\n const diry = Y_FROM_CARDINAL_DIRECTION[dir];\r\n const nx = -y * dirx - x * diry;\r\n const ny = x * dirx - y * diry;\r\n return this.set(nx, ny);\r\n }\r\n }\r\n // utilities\r\n // chebyshev: can move in any direction (diagonals are ok)\r\n distanceChebyshev(other) {\r\n return Math.max(Math.abs(this.x - other.x), Math.abs(this.y - other.y));\r\n }\r\n // manhattan: can move only in cardinal directions (no diagonals)\r\n distanceManhattan(other) {\r\n return Math.abs(this.x - other.x) + Math.abs(this.y - other.y);\r\n }\r\n // chebyshev: can move in any direction (diagonals are ok)\r\n *nearbyChebyshevOffsets(cursor, radius) {\r\n if (radius >= 0) {\r\n for (let dy = -radius; dy <= radius; dy++) {\r\n for (let dx = -radius; dx <= radius; dx++) {\r\n yield cursor.set(this.x + dx, this.y + dy);\r\n }\r\n }\r\n }\r\n }\r\n}\r\nexports.Offset = Offset;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.RasterMask = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nclass RasterMask {\r\n constructor(bounds, lines) {\r\n this._rect = new rectangle_1.Rectangle();\r\n if (lines.length !== bounds.height) {\r\n throw new Error(`bad lines array length ${lines.length} for bounds ${bounds}`);\r\n }\r\n this._rect.copyFrom(bounds);\r\n this._lines = lines;\r\n }\r\n // accessors\r\n toString() {\r\n let shape = '';\r\n const { eastX } = this._rect;\r\n for (let y = 0; y < this.height; y++) {\r\n const line = this._lines[y];\r\n let x = this.westX;\r\n for (let i = 0; i < line.length; i += 2) {\r\n const start = line[i];\r\n const end = line[i + 1];\r\n while (x < start) {\r\n shape += '∙';\r\n x++;\r\n }\r\n while (x < end) {\r\n shape += '█';\r\n x++;\r\n }\r\n }\r\n while (x <= eastX) {\r\n shape += '∙';\r\n x++;\r\n }\r\n shape += '\\n';\r\n }\r\n return `(${this._rect.westX},${this._rect.northY})\\n${shape}`;\r\n }\r\n equals(other) {\r\n return this._rect.equals(other._rect)\r\n && this._lines.length === other._lines.length\r\n && this._lines.every((v, i) => (v.length === other._lines[i].length\r\n && v.every((w, j) => w === other._lines[i][j])));\r\n }\r\n get northY() {\r\n return this._rect.northY;\r\n }\r\n get southY() {\r\n return this._rect.southY;\r\n }\r\n get westX() {\r\n return this._rect.westX;\r\n }\r\n get width() {\r\n return this._rect.width;\r\n }\r\n get height() {\r\n return this._rect.height;\r\n }\r\n get(x, y) {\r\n if (y < this.northY || y > this._rect.southY) {\r\n return false;\r\n }\r\n const line = this._lines[y - this.northY];\r\n for (let i = 0; i < line.length; i += 2) {\r\n if (x >= line[i] && x < line[i + 1]) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n // utilities\r\n *bandsAt(y) {\r\n if (y >= this.northY && y <= this._rect.southY) {\r\n const line = this._lines[y - this.northY];\r\n for (let i = 0; i < line.length; i += 2) {\r\n yield {\r\n westX: line[i],\r\n eastX: line[i + 1] - 1,\r\n };\r\n }\r\n }\r\n }\r\n}\r\nexports.RasterMask = RasterMask;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Rectangle = void 0;\r\nconst size_1 = require(\"./size\");\r\nconst offset_1 = require(\"./offset\");\r\nconst ROTATE_CORNER_X = [0, 0, 1, 1];\r\nconst ROTATE_CORNER_Y = [0, 1, 1, 0];\r\nclass Rectangle {\r\n constructor(westX, northY, width, height) {\r\n if (typeof westX === 'undefined') {\r\n westX = 0;\r\n }\r\n if (typeof northY === 'undefined') {\r\n northY = 0;\r\n }\r\n if (typeof width === 'undefined') {\r\n width = 0;\r\n }\r\n if (typeof height === 'undefined') {\r\n height = 0;\r\n }\r\n this.northWest = new offset_1.Offset(westX, northY);\r\n this.size = new size_1.Size(width, height);\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.westX},${this.northY} ${this.width}x${this.height})`;\r\n }\r\n equals(other) {\r\n return this.westX === other.westX && this.northY === other.northY && this.size.equals(other);\r\n }\r\n get northY() {\r\n return this.northWest.y;\r\n }\r\n get southY() {\r\n return this.northWest.y + this.size.height - 1;\r\n }\r\n get westX() {\r\n return this.northWest.x;\r\n }\r\n get eastX() {\r\n return this.northWest.x + this.size.width - 1;\r\n }\r\n get width() {\r\n return this.size.width;\r\n }\r\n get height() {\r\n return this.size.height;\r\n }\r\n get empty() {\r\n return this.size.empty;\r\n }\r\n get area() {\r\n return this.size.area;\r\n }\r\n // mutators\r\n set(westX, northY, width, height) {\r\n this.northWest.set(westX, northY);\r\n this.size.set(width, height);\r\n return this;\r\n }\r\n setFromCorners(off1, off2) {\r\n const westX = Math.min(off1.x, off2.x);\r\n const eastX = Math.max(off1.x, off2.x);\r\n const northY = Math.min(off1.y, off2.y);\r\n const southY = Math.max(off1.y, off2.y);\r\n return this.set(westX, northY, eastX - westX + 1, southY - northY + 1);\r\n }\r\n copyFrom(other) {\r\n return this.set(other.westX, other.northY, other.width, other.height);\r\n }\r\n addOffset(off) {\r\n this.northWest.addOffset(off);\r\n return this;\r\n }\r\n scale(factor) {\r\n this.northWest.multiply(factor);\r\n this.size.multiply(factor);\r\n return this;\r\n }\r\n rotate(turn, anchor) {\r\n const cx = ROTATE_CORNER_X[turn];\r\n const cy = ROTATE_CORNER_Y[turn];\r\n this.northWest.add(cx * (this.width - 1), cy * (this.height - 1)).rotate(turn, anchor);\r\n this.size.rotate(turn);\r\n return this;\r\n }\r\n extendToInclude(off) {\r\n const dx = off.x - this.westX;\r\n if (dx < 0) {\r\n this.size.width -= dx;\r\n this.northWest.x = off.x;\r\n }\r\n else if (dx >= this.size.width) {\r\n this.size.width = dx + 1;\r\n }\r\n const dy = off.y - this.northWest.y;\r\n if (dy < 0) {\r\n this.size.height -= dy;\r\n this.northWest.y = off.y;\r\n }\r\n else if (dy >= this.size.height) {\r\n this.size.height = dy + 1;\r\n }\r\n return this;\r\n }\r\n // utilities\r\n contains(x, y) {\r\n return this.size.contains(x - this.westX, y - this.northY);\r\n }\r\n index(x, y) {\r\n return this.size.index(x - this.westX, y - this.northY);\r\n }\r\n containsOffset(off) {\r\n return this.contains(off.x, off.y);\r\n }\r\n containsRectangle(other) {\r\n if (other.width === 0 && other.height === 0) {\r\n return false;\r\n }\r\n const x = other.westX - this.westX;\r\n const y = other.northY - this.northY;\r\n if (!this.size.contains(x, y)) {\r\n return false;\r\n }\r\n return this.size.contains(x + other.width - 1, y + other.height - 1);\r\n }\r\n overlapsRectangle(other) {\r\n return this.northY <= other.northY + other.height - 1\r\n && this.southY >= other.northY\r\n && this.westX <= other.westX + other.width - 1\r\n && this.eastX >= other.westX\r\n && !this.empty\r\n && other.width !== 0 && other.height !== 0;\r\n }\r\n *offsets() {\r\n const { eastX, southY } = this;\r\n for (let y = this.northY; y <= southY; y++) {\r\n for (let x = this.westX; x <= eastX; x++) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n anyOf(predicate) {\r\n for (const { x, y } of this.offsets()) {\r\n if (predicate(x, y)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\nexports.Rectangle = Rectangle;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Size = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nclass Size {\r\n constructor(width, height) {\r\n if (typeof width === 'undefined') {\r\n width = 0;\r\n }\r\n if (typeof height === 'undefined') {\r\n height = 0;\r\n }\r\n if (width < 0 || height < 0) {\r\n throw new Error(`bad size (${width}x${height})`);\r\n }\r\n this.width = width;\r\n this.height = height;\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.width}x${this.height})`;\r\n }\r\n equals(other) {\r\n return this.width === other.width && this.height === other.height;\r\n }\r\n get empty() {\r\n return this.width === 0 || this.height === 0;\r\n }\r\n get area() {\r\n return this.width * this.height;\r\n }\r\n // mutators\r\n set(width, height) {\r\n if (width < 0 || height < 0) {\r\n throw new Error(`bad size (${width}x${height})`);\r\n }\r\n this.width = width;\r\n this.height = height;\r\n return this;\r\n }\r\n copyFrom(other) {\r\n return this.set(other.width, other.height);\r\n }\r\n add(width, height) {\r\n this.width += width;\r\n this.height += height;\r\n return this;\r\n }\r\n multiply(factor) {\r\n this.width *= factor;\r\n this.height *= factor;\r\n return this;\r\n }\r\n rotate(turn) {\r\n if (compass_1.axisFromNorthSouthTurn(turn) === compass_1.Axis.WEST_EAST) {\r\n this.set(this.height, this.width);\r\n }\r\n return this;\r\n }\r\n // utilities\r\n contains(x, y) {\r\n return x >= 0 && y >= 0 && x < this.width && y < this.height;\r\n }\r\n containsOffset(off) {\r\n return this.contains(off.x, off.y);\r\n }\r\n index(x, y) {\r\n return y * this.width + x;\r\n }\r\n *offsets() {\r\n for (let y = 0; y < this.height; y++) {\r\n for (let x = 0; x < this.width; x++) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n anyOf(predicate) {\r\n for (const { x, y } of this.offsets()) {\r\n if (predicate(x, y)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\nexports.Size = Size;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.TransformRectangle = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst compass_1 = require(\"../compass\");\r\nconst offset_1 = require(\"./offset\");\r\nconst size_1 = require(\"./size\");\r\nconst LOCAL_OFF = new offset_1.Offset();\r\nconst LOCAL_OFF2 = new offset_1.Offset();\r\nconst LOCAL_SIZE = new size_1.Size();\r\nclass TransformRectangle {\r\n constructor(width, height) {\r\n this._size = new size_1.Size();\r\n this._flip = compass_1.Flip.HEADS;\r\n this._rotate = compass_1.CardinalTurn.NONE;\r\n this._translate = new offset_1.Offset();\r\n this._matrix = [1, 0, 0, 0, 1, 0];\r\n this._targetRect = new rectangle_1.Rectangle();\r\n if (typeof width === 'undefined') {\r\n // nothing\r\n }\r\n else if (typeof width === 'number') {\r\n this._size.set(width, height);\r\n }\r\n else {\r\n this._size.copyFrom(width);\r\n }\r\n this._update();\r\n }\r\n // accessors\r\n toString() {\r\n return `[${this._size}`\r\n + ` -> ${compass_1.flipToString(this._flip)} ${compass_1.cardinalTurnToString(this._rotate)} ${this._translate}`\r\n + ` -> ${this._targetRect}]`;\r\n }\r\n equals(other) {\r\n return this._size.equals(other._size)\r\n && this._flip === other._flip\r\n && this._rotate === other._rotate\r\n && this._translate.equals(other._translate);\r\n }\r\n get flip() {\r\n return this._flip;\r\n }\r\n get rotate() {\r\n return this._rotate;\r\n }\r\n get northY() {\r\n return this._translate.y;\r\n }\r\n get southY() {\r\n return this._translate.y + this._targetRect.height - 1;\r\n }\r\n get westX() {\r\n return this._translate.x;\r\n }\r\n get eastX() {\r\n return this._translate.x + this._targetRect.width - 1;\r\n }\r\n get width() {\r\n return this._targetRect.width;\r\n }\r\n get height() {\r\n return this._targetRect.height;\r\n }\r\n // internal\r\n // 0\r\n // 0 -1\r\n // +90\r\n // 1 0\r\n // 180\r\n // 0 1\r\n // -90\r\n // -1 0\r\n //\r\n // heads:\r\n // 0\r\n // 1 0 x\r\n // 0 1 y\r\n // +90\r\n // 0 -1 x + h - 1\r\n // 1 0 y\r\n // 180\r\n // -1 0 x + w - 1\r\n // 0 -1 y + h - 1\r\n // -90\r\n // 0 1 x\r\n // -1 0 y + w - 1\r\n //\r\n // tails:\r\n // 0\r\n // -1 0 x + w - 1\r\n // 0 1 y\r\n // +90\r\n // 0 -1 x + h - 1\r\n // -1 0 y + w - 1\r\n // 180\r\n // 1 0 x\r\n // 0 -1 y + h - 1\r\n // -90\r\n // 0 1 x\r\n // 1 0 y\r\n _update() {\r\n LOCAL_OFF.setFromCardinalDirection(compass_1.cardinalDirectionFromNorthTurn(this._rotate));\r\n const flipSign = this._flip === compass_1.Flip.TAILS ? -1 : 1;\r\n this._matrix[0] = -LOCAL_OFF.y * flipSign;\r\n this._matrix[1] = -LOCAL_OFF.x;\r\n this._matrix[2] = this._translate.x;\r\n this._matrix[3] = LOCAL_OFF.x * flipSign;\r\n this._matrix[4] = -LOCAL_OFF.y;\r\n this._matrix[5] = this._translate.y;\r\n switch (this._rotate) {\r\n case compass_1.CardinalTurn.NONE:\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n this._matrix[2] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.RIGHT:\r\n this._matrix[2] += this._size.height - 1;\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n this._matrix[5] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.AROUND:\r\n this._matrix[5] += this._size.height - 1;\r\n if (this._flip === compass_1.Flip.HEADS) {\r\n this._matrix[2] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.LEFT:\r\n if (this._flip === compass_1.Flip.HEADS) {\r\n this._matrix[5] += this._size.width - 1;\r\n }\r\n break;\r\n }\r\n LOCAL_SIZE.copyFrom(this._size).rotate(this._rotate);\r\n this._targetRect.set(this._translate.x, this._translate.y, LOCAL_SIZE.width, LOCAL_SIZE.height);\r\n return this;\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._size.copyFrom(other._size);\r\n this._flip = other._flip;\r\n this._rotate = other._rotate;\r\n this._translate.copyFrom(other._translate);\r\n other._matrix.forEach((v, i) => this._matrix[i] = v);\r\n this._targetRect.copyFrom(other._targetRect);\r\n return this;\r\n }\r\n reset() {\r\n this._flip = compass_1.Flip.HEADS;\r\n this._rotate = compass_1.CardinalTurn.NONE;\r\n this._translate.set(0, 0);\r\n return this._update();\r\n }\r\n invert() {\r\n const nrotate = compass_1.cardinalTurnFromCardinalDirections(compass_1.CardinalDirection.NORTH, compass_1.cardinalDirectionFromCardinalOrientation(compass_1.cardinalOrientationReverse(compass_1.cardinalOrientationFromFlipAndCardinalDirection(this._flip, compass_1.cardinalDirectionFromNorthTurn(this._rotate)))));\r\n this._rotate = nrotate;\r\n this._size.rotate(nrotate);\r\n this._translate.multiply(-1);\r\n return this._update();\r\n }\r\n setTransform(flip, rotate, translate) {\r\n this._flip = flip;\r\n this._rotate = rotate;\r\n this._translate.copyFrom(translate);\r\n return this._update();\r\n }\r\n setFlip(flip) {\r\n this._flip = flip;\r\n return this._update();\r\n }\r\n setRotate(rotate) {\r\n this._rotate = rotate;\r\n return this._update();\r\n }\r\n setTranslate(x, y) {\r\n this._translate.set(x, y);\r\n return this._update();\r\n }\r\n setTranslateOffset(translate) {\r\n this._translate.copyFrom(translate);\r\n return this._update();\r\n }\r\n // utility\r\n applyToCardinalOrientation(orientation) {\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n orientation = compass_1.cardinalOrientationFlip(orientation, compass_1.Axis.NORTH_SOUTH);\r\n }\r\n return compass_1.cardinalOrientationAddCardinalTurn(orientation, this._rotate);\r\n }\r\n unapplyFromCardinalOrientation(orientation) {\r\n orientation = compass_1.cardinalOrientationAddCardinalTurn(orientation, compass_1.cardinalTurnReverse(this._rotate));\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n orientation = compass_1.cardinalOrientationFlip(orientation, compass_1.Axis.NORTH_SOUTH);\r\n }\r\n return orientation;\r\n }\r\n applyToCardinalDirection(orientation) {\r\n return compass_1.cardinalDirectionFromCardinalOrientation(this.applyToCardinalOrientation(compass_1.cardinalOrientationFromFlipAndCardinalDirection(compass_1.Flip.HEADS, orientation)));\r\n }\r\n unapplyFromCardinalDirection(orientation) {\r\n return compass_1.cardinalDirectionFromCardinalOrientation(this.unapplyFromCardinalOrientation(compass_1.cardinalOrientationFromFlipAndCardinalDirection(compass_1.Flip.HEADS, orientation)));\r\n }\r\n applyTo(offOut, x, y) {\r\n const nx = x * this._matrix[0] + y * this._matrix[1] + this._matrix[2];\r\n const ny = x * this._matrix[3] + y * this._matrix[4] + this._matrix[5];\r\n return offOut.set(nx, ny);\r\n }\r\n unapplyFrom(offOut, x, y) {\r\n const tx = x - this._matrix[2];\r\n const ty = y - this._matrix[5];\r\n const nx = tx * this._matrix[0] + ty * this._matrix[3];\r\n const ny = tx * this._matrix[1] + ty * this._matrix[4];\r\n return offOut.set(nx, ny);\r\n }\r\n applyToOffset(offOut, off) {\r\n if (typeof off === 'undefined') {\r\n off = offOut;\r\n }\r\n return this.applyTo(offOut, off.x, off.y);\r\n }\r\n unapplyFromOffset(offOut, off) {\r\n if (typeof off === 'undefined') {\r\n off = offOut;\r\n }\r\n return this.unapplyFrom(offOut, off.x, off.y);\r\n }\r\n applyToRectangle(rectOut, rect) {\r\n if (typeof rect !== 'undefined') {\r\n rectOut.copyFrom(rect);\r\n }\r\n LOCAL_OFF.set(rectOut.westX, rectOut.northY);\r\n LOCAL_OFF2.set(rectOut.eastX, rectOut.southY);\r\n this.applyToOffset(LOCAL_OFF);\r\n this.applyToOffset(LOCAL_OFF2);\r\n return rectOut.setFromCorners(LOCAL_OFF, LOCAL_OFF2);\r\n }\r\n unapplyFromRectangle(rectOut, rect) {\r\n if (typeof rect !== 'undefined') {\r\n rectOut.copyFrom(rect);\r\n }\r\n LOCAL_OFF.set(rectOut.westX, rectOut.northY);\r\n LOCAL_OFF2.set(rectOut.eastX, rectOut.southY);\r\n this.unapplyFromOffset(LOCAL_OFF);\r\n this.unapplyFromOffset(LOCAL_OFF2);\r\n return rectOut.setFromCorners(LOCAL_OFF, LOCAL_OFF2);\r\n }\r\n}\r\nexports.TransformRectangle = TransformRectangle;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./compass\"), exports);\r\n__exportStar(require(\"./grid\"), exports);\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n});\r\nvar __importStar = (this && this.__importStar) || function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.computeFieldOfView = void 0;\r\nconst geom = __importStar(require(\"tiled-geometry\"));\r\nconst constants = __importStar(require(\"./constants\"));\r\nconst field_of_view_impl_1 = require(\"./field-of-view-impl\");\r\nconst wedge_1 = require(\"./wedge\");\r\n/* eslint-disable indent */\r\n/**\r\n * Compute the field of view for a camera at the given tile.\r\n * chebyshevRadius is the vision radius. It uses chebyshev distance\r\n * (https://en.wikipedia.org/wiki/Chebyshev_distance), which just means\r\n * that the limit of vision in a large empty field will be square.\r\n *\r\n * This returns a FieldOfView, which indicates which tiles are visible.\r\n * fieldOfView.get(x, y) will return true for visible tiles.\r\n */\r\nfunction computeFieldOfView(map, x, y, chebyshevRadius) {\r\n const origin = new geom.Offset(x, y);\r\n const field = new field_of_view_impl_1.FieldOfViewImpl(origin, chebyshevRadius);\r\n // the field is divided into quadrants\r\n quadrant(map, field, origin, chebyshevRadius, -1, -1);\r\n quadrant(map, field, origin, chebyshevRadius, 1, -1);\r\n quadrant(map, field, origin, chebyshevRadius, -1, 1);\r\n quadrant(map, field, origin, chebyshevRadius, 1, 1);\r\n return field;\r\n}\r\nexports.computeFieldOfView = computeFieldOfView;\r\nfunction quadrant(map, field, origin, chebyshevRadius, xSign, ySign) {\r\n const { x: startX, y: startY } = origin;\r\n const endDX = (Math.min(Math.max(startX + xSign * (chebyshevRadius + 1), -1), map.width) - startX) * xSign;\r\n const endDY = (Math.min(Math.max(startY + ySign * (chebyshevRadius + 1), -1), map.height) - startY) * ySign;\r\n if (endDX < 0 || endDY < 0) {\r\n // the origin is outside of the map\r\n return;\r\n }\r\n const startMapIndex = map.index(origin.x, origin.y);\r\n const startMaskIndex = field.visible.index(origin.x, origin.y);\r\n // Initial wedge is from slope zero to slope infinity (i.e. the whole quadrant)\r\n let wedges = wedge_1.initWedges();\r\n for (let dy = 0, yMapIndex = startMapIndex, yMaskIndex = startMaskIndex; dy !== endDY && wedges.length > 0; dy++, yMapIndex += ySign * map.width, yMaskIndex += ySign * field.visible.width) {\r\n const divYpos = 1 / (dy + 0.5);\r\n const divYneg = dy === 0 ? Number.POSITIVE_INFINITY : 1 / (dy - 0.5);\r\n let wedgeIndex = 0;\r\n for (let dx = 0, mapIndex = yMapIndex, maskIndex = yMaskIndex, slopeY = -0.5 * divYpos, slopeX = 0.5 * divYneg; dx !== endDX && wedgeIndex !== wedges.length; dx++, mapIndex += xSign, maskIndex += xSign,\r\n slopeY += divYpos, slopeX += divYneg) {\r\n // the slopes of the four corners of this tile\r\n // these are named as follows:\r\n // slopeY is the slope closest to the Y axis\r\n // slopeX is the slope closest to the X axis\r\n // this is always true:\r\n // slopeY < slopeX\r\n //\r\n // O = origin, C = current\r\n // +---+---+---+\r\n // | O | | |\r\n // +---+---+---X\r\n // | | | C |\r\n // +---+---Y---+\r\n // advance the wedge index until this tile is not after the current wedge\r\n while (slopeY > wedges[wedgeIndex].high) {\r\n wedgeIndex++;\r\n if (wedgeIndex >= wedges.length) {\r\n break;\r\n }\r\n }\r\n if (wedgeIndex >= wedges.length) {\r\n break;\r\n }\r\n // if the current wedge is after this tile, move on\r\n if (slopeX < wedges[wedgeIndex].low) {\r\n continue;\r\n }\r\n // we can see this tile\r\n field.visible.setAtIndex(maskIndex, true);\r\n const body = (dx !== 0 || dy !== 0) && map.getBodyAtIndex(mapIndex);\r\n if (body) {\r\n wedges = wedge_1.cutWedges(wedges, slopeY + constants.BODY_INSET, slopeX - constants.BODY_INSET);\r\n }\r\n }\r\n }\r\n}\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.WEDGE_COUNT = exports.WEDGE_HIGH = exports.WEDGE_LOW = exports.BODY_INSET = void 0;\r\n/**\r\n * A smallish number, to adjust some wedges.\r\n */\r\nconst EPSILON = 0.00001;\r\n/**\r\n * Bodies in this algorithm do not entirely fill their tiles. This is\r\n * implemented by adjusting the angles of the shadows the bodies cast,\r\n * making the wedge very slightly narrower. BODY_INSET represents the\r\n * amount of reduction on either side of the wedge.\r\n */\r\nexports.BODY_INSET = EPSILON;\r\n/**\r\n * In the shadowcasting algorithm, each shadow is represented by a \"wedge\",\r\n * running from a \"low\" angle to a \"high\" angle. The wedges are all stored in\r\n * a simple number array, with two numbers for each wedge. These constants\r\n * (WEDGE_LOW and WEDGE_HIGH) help to identify which number is which.\r\n * WEDGE_COUNT is just how many numbers per wedge.\r\n */\r\nexports.WEDGE_LOW = 0;\r\nexports.WEDGE_HIGH = 1;\r\nexports.WEDGE_COUNT = 2;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n});\r\nvar __importStar = (this && this.__importStar) || function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.FieldOfViewImpl = void 0;\r\nconst geom = __importStar(require(\"tiled-geometry\"));\r\n/**\r\n * The FieldOfViewImpl class is the concrete implementation of the FieldOfView interface.\r\n */\r\nclass FieldOfViewImpl {\r\n constructor(origin, chebyshevRadius) {\r\n this.origin = origin;\r\n this.chebyshevRadius = chebyshevRadius;\r\n const boundRect = new geom.Rectangle(origin.x - chebyshevRadius, origin.y - chebyshevRadius, chebyshevRadius * 2 + 1, chebyshevRadius * 2 + 1);\r\n this.visible = new geom.MaskRectangle(boundRect);\r\n // the origin is always visible\r\n this.visible.setAtOffset(origin, true);\r\n }\r\n getVisible(x, y) {\r\n return this.visible.get(x, y);\r\n }\r\n toString() {\r\n let ret = '';\r\n for (const location of this.visible.locations()) {\r\n const { x, y } = location;\r\n if (this.origin.equals(location)) {\r\n ret += '@';\r\n }\r\n else if (this.getVisible(x, y)) {\r\n ret += '-';\r\n }\r\n else {\r\n ret += '.';\r\n }\r\n if (x === this.visible.westX + this.visible.width - 1) {\r\n ret += '\\n';\r\n }\r\n }\r\n return ret;\r\n }\r\n}\r\nexports.FieldOfViewImpl = FieldOfViewImpl;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n});\r\nvar __importStar = (this && this.__importStar) || function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.FieldOfViewMap = void 0;\r\nconst geom = __importStar(require(\"tiled-geometry\"));\r\n/**\r\n * For each number in the _tileFlags array, we store (1 << FLAGS_POW2) cells,\r\n * as bits where a true indicates the presence of a body.\r\n */\r\nconst FLAGS_POW2 = 5;\r\n/**\r\n * The FieldOfViewMap class describes the map over which the field of view will be\r\n * computed. It starts empty.\r\n */\r\nclass FieldOfViewMap {\r\n constructor(width, height) {\r\n this._size = new geom.Size();\r\n this._size.set(width, height);\r\n this._tileFlags = new Array((this._size.area >> FLAGS_POW2) + 1).fill(0);\r\n }\r\n get width() {\r\n return this._size.width;\r\n }\r\n get height() {\r\n return this._size.height;\r\n }\r\n // bodies\r\n addBody(x, y) {\r\n if (this._size.contains(x, y)) {\r\n const index = this.index(x, y);\r\n this._tileFlags[index >> FLAGS_POW2] |= 1 << (index & ((1 << FLAGS_POW2) - 1));\r\n }\r\n return this;\r\n }\r\n removeBody(x, y) {\r\n if (this._size.contains(x, y)) {\r\n const index = this.index(x, y);\r\n this._tileFlags[index >> FLAGS_POW2] &= ~(1 << (index & ((1 << FLAGS_POW2) - 1)));\r\n }\r\n return this;\r\n }\r\n getBody(x, y) {\r\n const index = this.index(x, y);\r\n return this.getBodyAtIndex(index);\r\n }\r\n // internal\r\n index(x, y) {\r\n return this._size.index(x, y);\r\n }\r\n getBodyAtIndex(index) {\r\n return (this._tileFlags[index >> FLAGS_POW2] & (1 << (index & ((1 << FLAGS_POW2) - 1)))) !== 0;\r\n }\r\n}\r\nexports.FieldOfViewMap = FieldOfViewMap;\r\n","\"use strict\";\r\n/*\r\n * TheField\r\n * github.com/sbj42/the-field\r\n * James Clark\r\n * Licensed under the MIT license.\r\n */\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.computeFieldOfView = exports.FieldOfViewMap = void 0;\r\nvar field_of_view_map_1 = require(\"./field-of-view-map\");\r\nObject.defineProperty(exports, \"FieldOfViewMap\", { enumerable: true, get: function () { return field_of_view_map_1.FieldOfViewMap; } });\r\nvar compute_1 = require(\"./compute\");\r\nObject.defineProperty(exports, \"computeFieldOfView\", { enumerable: true, get: function () { return compute_1.computeFieldOfView; } });\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cutWedges = exports.cutWedge = exports.initWedges = void 0;\r\n// istanbul ignore next\r\nfunction rangeToString(low, high) {\r\n return `${low.toFixed(7)}-${high.toFixed(7)}`;\r\n}\r\n// istanbul ignore next\r\nfunction wedgeToString(wedge) {\r\n return `{${rangeToString(wedge.low, wedge.high)}}`;\r\n}\r\n// istanbul ignore next\r\nfunction wedgesToString(wedges) {\r\n return `[${wedges.map(wedgeToString).join(', ')}]`;\r\n}\r\n// istanbul ignore next\r\nfunction debugLog(msg) {\r\n // eslint-disable-next-line no-console\r\n console.info(msg);\r\n}\r\nfunction initWedges() {\r\n return [{ low: 0, high: Number.POSITIVE_INFINITY }];\r\n}\r\nexports.initWedges = initWedges;\r\nconst DEBUG_CUTWEDGE = false;\r\n/**\r\n * This function cuts a range of angles out of a wedge.\r\n */\r\nfunction cutWedge(wedge, low, high) {\r\n // istanbul ignore next\r\n if (DEBUG_CUTWEDGE) {\r\n debugLog(`cut ${wedgeToString(wedge)} ${rangeToString(low, high)}`);\r\n }\r\n let ret;\r\n if (low <= wedge.low) {\r\n if (high >= wedge.high) {\r\n // wedge is entirely occluded, remove it\r\n ret = [];\r\n }\r\n else if (high >= wedge.low) {\r\n // low part of wedge is occluded, trim it\r\n wedge.low = high;\r\n ret = [wedge];\r\n }\r\n else {\r\n // cut doesn't reach the wedge\r\n ret = [wedge];\r\n }\r\n }\r\n else if (high >= wedge.high) {\r\n if (low <= wedge.high) {\r\n // high part of wedge is occluded, trim it\r\n wedge.high = low;\r\n ret = [wedge];\r\n }\r\n else {\r\n // cut doesn't reach the wedge\r\n ret = [wedge];\r\n }\r\n }\r\n else {\r\n // middle part of wedge is occluded, split it\r\n const nextWedge = {\r\n low: high,\r\n high: wedge.high,\r\n };\r\n wedge.high = low;\r\n ret = [wedge, nextWedge];\r\n }\r\n // istanbul ignore next\r\n if (DEBUG_CUTWEDGE) {\r\n debugLog(`--> ${wedgesToString(ret)}`);\r\n }\r\n return ret;\r\n}\r\nexports.cutWedge = cutWedge;\r\nfunction cutWedges(wedges, low, high) {\r\n const ret = new Array();\r\n for (const wedge of wedges) {\r\n ret.push(...cutWedge(wedge, low, high));\r\n }\r\n return ret;\r\n}\r\nexports.cutWedges = cutWedges;\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// module exports must be returned from runtime so entry inlining is disabled\n// startup\n// Load entry module and return exports\nreturn __webpack_require__(607);\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://TheField/./node_modules/tiled-geometry/lib/compass/axis.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-direction-flags.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-direction.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-orientation.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/cardinal-turn.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/direction.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/flip.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/index.js","webpack://TheField/./node_modules/tiled-geometry/lib/compass/turn.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/cardinal-path.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/index.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/mask-rectangle.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/mask.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/offset.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/raster-mask.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/rectangle.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/size.js","webpack://TheField/./node_modules/tiled-geometry/lib/grid/transform-rectangle.js","webpack://TheField/./node_modules/tiled-geometry/lib/index.js","webpack://TheField/./src/compute.ts","webpack://TheField/./src/constants.ts","webpack://TheField/./src/field-of-view-impl.ts","webpack://TheField/./src/field-of-view-map.ts","webpack://TheField/./src/index.ts","webpack://TheField/./src/wedge.ts","webpack://TheField/webpack/bootstrap","webpack://TheField/webpack/startup"],"names":["Axis","Object","defineProperty","exports","value","axisAddCardinalTurn","axisFromNorthSouthTurn","axisFromCardinalDirection","axisOrthogonal","axisToString","AXES","NORTH_SOUTH","WEST_EAST","AXES_STR","axis","dir","turn","CardinalDirectionFlags","cardinalDirectionFlagsFromCardinalDirection","cardinalDirectionFlagsRemoveCardinalDirection","cardinalDirectionFlagsSetCardinalDirection","cardinalDirectionFlagsHasCardinalDirection","cardinalDirectionFlagsToString","flags","ret","NORTH","EAST","SOUTH","WEST","CardinalDirection","cardinalDirectionAddCardinalTurn","cardinalDirectionFromCardinalOrientation","cardinalDirectionFromNorthTurn","cardinalDirectionFromDirection","cardinalDirectionOpposite","cardinalDirectionToString","CARDINAL_DIRECTIONS","CARDINAL_DIRECTIONS_STR","orientation","cardinalOrientationAddCardinalTurn","cardinalOrientationFromFlipAndCardinalDirection","cardinalOrientationReverse","cardinalOrientationFlip","cardinalOrientationToString","CARDINAL_ORIENTATIONS","CardinalOrientation","axis_1","flip_1","HEADS_NORTH","TAILS_NORTH","HEADS_EAST","TAILS_EAST","HEADS_SOUTH","TAILS_SOUTH","HEADS_WEST","TAILS_WEST","CARDINAL_ORIENTATIONS_STR","flip","Flip","HEADS","CardinalTurn","cardinalTurnAddCardinalTurn","cardinalTurnFromTurn","cardinalTurnFromCardinalDirections","cardinalTurnReverse","cardinalTurnToDegrees","cardinalTurnToString","CARDINAL_TURNS","NONE","RIGHT","AROUND","LEFT","CARDINAL_TURNS_STR","from","to","turn1","turn2","Direction","directionAddCardinalTurn","directionAddTurn","directionFromCardinalDirection","directionOpposite","directionIsCardinal","directionToString","DIRECTIONS","NORTHEAST","SOUTHEAST","SOUTHWEST","NORTHWEST","DIRECTIONS_STR","flipFromCardinalOrientation","flipFromBoolean","flipOpposite","flipToString","FLIPS","TAILS","FLIPS_STR","tails","__createBinding","this","create","o","m","k","k2","undefined","enumerable","get","__exportStar","p","prototype","hasOwnProperty","call","Turn","turnAddTurn","turnFromDirections","turnFromCardinalTurn","turnFromCardinalDirections","turnReverse","turnIsCardinal","turnToDegrees","turnToString","TURNS","R_45","R_90","R_135","T_180","L_135","L_90","L_45","TURNS_STR","CardinalPath","compass_1","offset_1","rectangle_1","raster_mask_1","LOCAL_OFF","Offset","sortedInsert","array","push","i","length","start","segments","_start","copyFrom","_segments","toString","map","segment","join","other","equals","every","v","addCardinalDirection","x","y","setFromCardinalDirection","northY","southY","westX","eastX","Math","min","max","Error","Rectangle","total","abs","bounds","lines","Array","getBounds","height","RasterMask","width","MaskRectangle","mask_1","rect","initialValue","outsideValue","_rect","_mask","Mask","_outsideValue","northWest","contains","index","getAtIndex","off","set","setAtIndex","loc","locations","offsetsWithTrue","size_1","size","_size","Size","_bits","ceil","area","fill","arrayIndex","bitMask","slice","offsets","X_FROM_DIRECTION","Y_FROM_DIRECTION","X_FROM_CARDINAL_DIRECTION","Y_FROM_CARDINAL_DIRECTION","add","factor","anchor","subtractOffset","rotate","addOffset","dirx","diry","nx","ny","cursor","radius","dy","dx","_lines","shape","line","end","w","j","ROTATE_CORNER_X","ROTATE_CORNER_Y","empty","off1","off2","multiply","cx","cy","predicate","TransformRectangle","LOCAL_OFF2","LOCAL_SIZE","_flip","_rotate","_translate","_matrix","_targetRect","_update","flipSign","forEach","nrotate","translate","applyToCardinalOrientation","unapplyFromCardinalOrientation","offOut","tx","ty","applyTo","unapplyFrom","rectOut","applyToOffset","setFromCorners","unapplyFromOffset","__setModuleDefault","__importStar","mod","__esModule","result","computeFieldOfView","geom","constants","field_of_view_impl_1","wedge_1","quadrant","field","origin","chebyshevRadius","xSign","ySign","startX","startY","endDX","endDY","startMapIndex","startMaskIndex","visible","wedges","initWedges","yMapIndex","yMaskIndex","divYpos","divYneg","Number","POSITIVE_INFINITY","wedgeIndex","mapIndex","maskIndex","slopeY","slopeX","high","low","getBodyAtIndex","cutWedges","BODY_INSET","FieldOfViewImpl","WEDGE_COUNT","WEDGE_HIGH","WEDGE_LOW","boundRect","setAtOffset","location","getVisible","FieldOfViewMap","_tileFlags","field_of_view_map_1","compute_1","cutWedge","wedge","nextWedge","__webpack_module_cache__","__webpack_require__","moduleId","module","__webpack_modules__"],"mappings":"4DAGA,IAAIA,EAFJC,OAAOC,eAAeC,EAAS,aAAc,CAAEC,OAAO,IACtDD,EAAQE,oBAAsBF,EAAQG,uBAAyBH,EAAQI,0BAA4BJ,EAAQK,eAAiBL,EAAQM,aAAeN,EAAQO,KAAOP,EAAQH,UAAO,EAEjL,SAAWA,GACPA,EAAKA,EAAkB,YAAI,GAAK,cAChCA,EAAKA,EAAgB,UAAI,GAAK,YAFlC,CAGGA,EAAOG,EAAQH,OAASG,EAAQH,KAAO,KAC1CG,EAAQO,KAAO,CACXV,EAAKW,YACLX,EAAKY,WAET,MAAMC,EAAW,CACb,MACA,OAKJV,EAAQM,aAHR,SAAsBK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R,EAAM,GAEDsR,GAAQkB,EAAMjB,KAEnBiB,EAAMjB,IAAMD,EACZtR,EAAM,CAACwS,IAIPxS,EAAM,CAACwS,QAGV,GAAIlB,GAAQkB,EAAMlB,KACfC,GAAOiB,EAAMlB,MAEbkB,EAAMlB,KAAOC,EACbvR,EAAM,CAACwS,IAIPxS,EAAM,CAACwS,OAGV,CAED,MAAMC,EAAY,CACdlB,IAAKD,EACLA,KAAMkB,EAAMlB,MAEhBkB,EAAMlB,KAAOC,EACbvR,EAAM,CAACwS,EAAOC,GAMlB,OAAOzS,EAxEXvB,OAAOC,eAAeC,EAAS,aAAc,CAAEC,OAAO,IACtDD,EAAQ8S,UAAY9S,EAAQ4T,SAAW5T,EAAQ+R,gBAAa,EAqB5D/R,EAAQ+R,WAHR,WACI,MAAO,CAAC,CAAEa,IAAK,EAAGD,KAAMP,OAAOC,qBAsDnCrS,EAAQ4T,SAAWA,EAQnB5T,EAAQ8S,UAPR,SAAmBhB,EAAQc,EAAKD,GAC5B,MAAMtR,EAAM,IAAIqJ,MAChB,IAAK,MAAMmJ,KAAS/B,EAChBzQ,EAAIoH,QAAQmL,EAASC,EAAOjB,EAAKD,IAErC,OAAOtR,KChFP0S,EAA2B,GCE/B,ODCA,SAASC,EAAoBC,GAE5B,GAAGF,EAAyBE,GAC3B,OAAOF,EAAyBE,GAAUjU,QAG3C,IAAIkU,EAASH,EAAyBE,GAAY,CAGjDjU,QAAS,IAOV,OAHAmU,EAAoBF,GAAUpN,KAAKqN,EAAOlU,QAASkU,EAAQA,EAAOlU,QAASgU,GAGpEE,EAAOlU,QCjBRgU,CAAoB,M","file":"the-field-2.0.1.min.js","sourcesContent":["\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.axisAddCardinalTurn = exports.axisFromNorthSouthTurn = exports.axisFromCardinalDirection = exports.axisOrthogonal = exports.axisToString = exports.AXES = exports.Axis = void 0;\r\nvar Axis;\r\n(function (Axis) {\r\n Axis[Axis[\"NORTH_SOUTH\"] = 0] = \"NORTH_SOUTH\";\r\n Axis[Axis[\"WEST_EAST\"] = 1] = \"WEST_EAST\";\r\n})(Axis = exports.Axis || (exports.Axis = {}));\r\nexports.AXES = [\r\n Axis.NORTH_SOUTH,\r\n Axis.WEST_EAST,\r\n];\r\nconst AXES_STR = [\r\n 'N-S',\r\n 'W-E',\r\n];\r\nfunction axisToString(axis) {\r\n return AXES_STR[axis];\r\n}\r\nexports.axisToString = axisToString;\r\nfunction axisOrthogonal(axis) {\r\n return (axis ^ 1);\r\n}\r\nexports.axisOrthogonal = axisOrthogonal;\r\n// conversion\r\nfunction axisFromCardinalDirection(dir) {\r\n return (dir & 1);\r\n}\r\nexports.axisFromCardinalDirection = axisFromCardinalDirection;\r\nfunction axisFromNorthSouthTurn(turn) {\r\n return (turn & 1);\r\n}\r\nexports.axisFromNorthSouthTurn = axisFromNorthSouthTurn;\r\n// math\r\nfunction axisAddCardinalTurn(axis, turn) {\r\n return ((axis + turn) & 1);\r\n}\r\nexports.axisAddCardinalTurn = axisAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalDirectionFlagsFromCardinalDirection = exports.cardinalDirectionFlagsRemoveCardinalDirection = exports.cardinalDirectionFlagsSetCardinalDirection = exports.cardinalDirectionFlagsHasCardinalDirection = exports.cardinalDirectionFlagsToString = exports.CardinalDirectionFlags = void 0;\r\nvar CardinalDirectionFlags;\r\n(function (CardinalDirectionFlags) {\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"NONE\"] = 0] = \"NONE\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"NORTH\"] = 1] = \"NORTH\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"EAST\"] = 2] = \"EAST\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"SOUTH\"] = 4] = \"SOUTH\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"WEST\"] = 8] = \"WEST\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"ALL\"] = 15] = \"ALL\";\r\n})(CardinalDirectionFlags = exports.CardinalDirectionFlags || (exports.CardinalDirectionFlags = {}));\r\nfunction cardinalDirectionFlagsToString(flags) {\r\n let ret = '[';\r\n if ((flags & CardinalDirectionFlags.NORTH) !== 0) {\r\n ret += 'N';\r\n }\r\n if ((flags & CardinalDirectionFlags.EAST) !== 0) {\r\n ret += 'E';\r\n }\r\n if ((flags & CardinalDirectionFlags.SOUTH) !== 0) {\r\n ret += 'S';\r\n }\r\n if ((flags & CardinalDirectionFlags.WEST) !== 0) {\r\n ret += 'W';\r\n }\r\n return ret + ']';\r\n}\r\nexports.cardinalDirectionFlagsToString = cardinalDirectionFlagsToString;\r\nfunction cardinalDirectionFlagsHasCardinalDirection(flags, dir) {\r\n return (flags & cardinalDirectionFlagsFromCardinalDirection(dir)) !== 0;\r\n}\r\nexports.cardinalDirectionFlagsHasCardinalDirection = cardinalDirectionFlagsHasCardinalDirection;\r\nfunction cardinalDirectionFlagsSetCardinalDirection(flags, dir) {\r\n return (flags | cardinalDirectionFlagsFromCardinalDirection(dir));\r\n}\r\nexports.cardinalDirectionFlagsSetCardinalDirection = cardinalDirectionFlagsSetCardinalDirection;\r\nfunction cardinalDirectionFlagsRemoveCardinalDirection(flags, dir) {\r\n return (flags & ~cardinalDirectionFlagsFromCardinalDirection(dir));\r\n}\r\nexports.cardinalDirectionFlagsRemoveCardinalDirection = cardinalDirectionFlagsRemoveCardinalDirection;\r\n// conversion\r\nfunction cardinalDirectionFlagsFromCardinalDirection(dir) {\r\n return (1 << dir);\r\n}\r\nexports.cardinalDirectionFlagsFromCardinalDirection = cardinalDirectionFlagsFromCardinalDirection;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalDirectionAddCardinalTurn = exports.cardinalDirectionFromCardinalOrientation = exports.cardinalDirectionFromNorthTurn = exports.cardinalDirectionFromDirection = exports.cardinalDirectionOpposite = exports.cardinalDirectionToString = exports.CARDINAL_DIRECTIONS = exports.CardinalDirection = void 0;\r\nvar CardinalDirection;\r\n(function (CardinalDirection) {\r\n CardinalDirection[CardinalDirection[\"NORTH\"] = 0] = \"NORTH\";\r\n CardinalDirection[CardinalDirection[\"EAST\"] = 1] = \"EAST\";\r\n CardinalDirection[CardinalDirection[\"SOUTH\"] = 2] = \"SOUTH\";\r\n CardinalDirection[CardinalDirection[\"WEST\"] = 3] = \"WEST\";\r\n})(CardinalDirection = exports.CardinalDirection || (exports.CardinalDirection = {}));\r\nexports.CARDINAL_DIRECTIONS = [\r\n CardinalDirection.NORTH,\r\n CardinalDirection.EAST,\r\n CardinalDirection.SOUTH,\r\n CardinalDirection.WEST,\r\n];\r\nconst CARDINAL_DIRECTIONS_STR = [\r\n 'N',\r\n 'E',\r\n 'S',\r\n 'W',\r\n];\r\nfunction cardinalDirectionToString(dir) {\r\n return CARDINAL_DIRECTIONS_STR[dir];\r\n}\r\nexports.cardinalDirectionToString = cardinalDirectionToString;\r\nfunction cardinalDirectionOpposite(dir) {\r\n return ((dir + 2) & 3);\r\n}\r\nexports.cardinalDirectionOpposite = cardinalDirectionOpposite;\r\n// conversion\r\nfunction cardinalDirectionFromDirection(dir) {\r\n return (dir >> 1);\r\n}\r\nexports.cardinalDirectionFromDirection = cardinalDirectionFromDirection;\r\nfunction cardinalDirectionFromNorthTurn(turn) {\r\n return turn;\r\n}\r\nexports.cardinalDirectionFromNorthTurn = cardinalDirectionFromNorthTurn;\r\nfunction cardinalDirectionFromCardinalOrientation(orientation) {\r\n return (orientation >>> 1);\r\n}\r\nexports.cardinalDirectionFromCardinalOrientation = cardinalDirectionFromCardinalOrientation;\r\n// math\r\nfunction cardinalDirectionAddCardinalTurn(dir, turn) {\r\n return ((dir + turn) & 3);\r\n}\r\nexports.cardinalDirectionAddCardinalTurn = cardinalDirectionAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalOrientationAddCardinalTurn = exports.cardinalOrientationFromFlipAndCardinalDirection = exports.cardinalOrientationReverse = exports.cardinalOrientationFlip = exports.cardinalOrientationToString = exports.CARDINAL_ORIENTATIONS = exports.CardinalOrientation = void 0;\r\nconst axis_1 = require(\"./axis\");\r\nconst flip_1 = require(\"./flip\");\r\nvar CardinalOrientation;\r\n(function (CardinalOrientation) {\r\n CardinalOrientation[CardinalOrientation[\"HEADS_NORTH\"] = 0] = \"HEADS_NORTH\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_NORTH\"] = 1] = \"TAILS_NORTH\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_EAST\"] = 2] = \"HEADS_EAST\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_EAST\"] = 3] = \"TAILS_EAST\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_SOUTH\"] = 4] = \"HEADS_SOUTH\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_SOUTH\"] = 5] = \"TAILS_SOUTH\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_WEST\"] = 6] = \"HEADS_WEST\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_WEST\"] = 7] = \"TAILS_WEST\";\r\n})(CardinalOrientation = exports.CardinalOrientation || (exports.CardinalOrientation = {}));\r\nexports.CARDINAL_ORIENTATIONS = [\r\n CardinalOrientation.HEADS_NORTH,\r\n CardinalOrientation.TAILS_NORTH,\r\n CardinalOrientation.HEADS_EAST,\r\n CardinalOrientation.TAILS_EAST,\r\n CardinalOrientation.HEADS_SOUTH,\r\n CardinalOrientation.TAILS_SOUTH,\r\n CardinalOrientation.HEADS_WEST,\r\n CardinalOrientation.TAILS_WEST,\r\n];\r\nconst CARDINAL_ORIENTATIONS_STR = [\r\n 'HN',\r\n 'TN',\r\n 'HE',\r\n 'TE',\r\n 'HS',\r\n 'TS',\r\n 'HW',\r\n 'TW',\r\n];\r\nfunction cardinalOrientationToString(orientation) {\r\n return CARDINAL_ORIENTATIONS_STR[orientation];\r\n}\r\nexports.cardinalOrientationToString = cardinalOrientationToString;\r\nfunction cardinalOrientationFlip(orientation, axis) {\r\n if (axis === axis_1.Axis.NORTH_SOUTH) {\r\n return ((9 - orientation) & 7);\r\n }\r\n else {\r\n return ((13 - orientation) & 7);\r\n }\r\n}\r\nexports.cardinalOrientationFlip = cardinalOrientationFlip;\r\nfunction cardinalOrientationReverse(orientation) {\r\n if (orientation === CardinalOrientation.HEADS_EAST) {\r\n return CardinalOrientation.HEADS_WEST;\r\n }\r\n else if (orientation === CardinalOrientation.HEADS_WEST) {\r\n return CardinalOrientation.HEADS_EAST;\r\n }\r\n else {\r\n return orientation;\r\n }\r\n}\r\nexports.cardinalOrientationReverse = cardinalOrientationReverse;\r\n// conversion\r\nfunction cardinalOrientationFromFlipAndCardinalDirection(flip, dir) {\r\n return (dir * 2 + (flip !== flip_1.Flip.HEADS ? 1 : 0));\r\n}\r\nexports.cardinalOrientationFromFlipAndCardinalDirection = cardinalOrientationFromFlipAndCardinalDirection;\r\n// math\r\nfunction cardinalOrientationAddCardinalTurn(orientation, turn) {\r\n return ((orientation + turn * 2) & 7);\r\n}\r\nexports.cardinalOrientationAddCardinalTurn = cardinalOrientationAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalTurnAddCardinalTurn = exports.cardinalTurnFromTurn = exports.cardinalTurnFromCardinalDirections = exports.cardinalTurnReverse = exports.cardinalTurnToDegrees = exports.cardinalTurnToString = exports.CARDINAL_TURNS = exports.CardinalTurn = void 0;\r\nvar CardinalTurn;\r\n(function (CardinalTurn) {\r\n CardinalTurn[CardinalTurn[\"NONE\"] = 0] = \"NONE\";\r\n CardinalTurn[CardinalTurn[\"RIGHT\"] = 1] = \"RIGHT\";\r\n CardinalTurn[CardinalTurn[\"AROUND\"] = 2] = \"AROUND\";\r\n CardinalTurn[CardinalTurn[\"LEFT\"] = 3] = \"LEFT\";\r\n})(CardinalTurn = exports.CardinalTurn || (exports.CardinalTurn = {}));\r\nexports.CARDINAL_TURNS = [\r\n CardinalTurn.NONE,\r\n CardinalTurn.RIGHT,\r\n CardinalTurn.AROUND,\r\n CardinalTurn.LEFT,\r\n];\r\nconst CARDINAL_TURNS_STR = [\r\n 'T0',\r\n 'T+90',\r\n 'T180',\r\n 'T-90',\r\n];\r\nfunction cardinalTurnToString(dir) {\r\n return CARDINAL_TURNS_STR[dir];\r\n}\r\nexports.cardinalTurnToString = cardinalTurnToString;\r\nfunction cardinalTurnToDegrees(turn) {\r\n return turn * 90;\r\n}\r\nexports.cardinalTurnToDegrees = cardinalTurnToDegrees;\r\nfunction cardinalTurnReverse(dir) {\r\n return ((4 - dir) & 3);\r\n}\r\nexports.cardinalTurnReverse = cardinalTurnReverse;\r\n// conversion\r\nfunction cardinalTurnFromCardinalDirections(from, to) {\r\n return ((to - from) & 3);\r\n}\r\nexports.cardinalTurnFromCardinalDirections = cardinalTurnFromCardinalDirections;\r\nfunction cardinalTurnFromTurn(turn) {\r\n return (turn >> 1);\r\n}\r\nexports.cardinalTurnFromTurn = cardinalTurnFromTurn;\r\n// math\r\nfunction cardinalTurnAddCardinalTurn(turn1, turn2) {\r\n return ((turn1 + turn2) & 3);\r\n}\r\nexports.cardinalTurnAddCardinalTurn = cardinalTurnAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.directionAddCardinalTurn = exports.directionAddTurn = exports.directionFromCardinalDirection = exports.directionOpposite = exports.directionIsCardinal = exports.directionToString = exports.DIRECTIONS = exports.Direction = void 0;\r\nvar Direction;\r\n(function (Direction) {\r\n Direction[Direction[\"NORTH\"] = 0] = \"NORTH\";\r\n Direction[Direction[\"NORTHEAST\"] = 1] = \"NORTHEAST\";\r\n Direction[Direction[\"EAST\"] = 2] = \"EAST\";\r\n Direction[Direction[\"SOUTHEAST\"] = 3] = \"SOUTHEAST\";\r\n Direction[Direction[\"SOUTH\"] = 4] = \"SOUTH\";\r\n Direction[Direction[\"SOUTHWEST\"] = 5] = \"SOUTHWEST\";\r\n Direction[Direction[\"WEST\"] = 6] = \"WEST\";\r\n Direction[Direction[\"NORTHWEST\"] = 7] = \"NORTHWEST\";\r\n})(Direction = exports.Direction || (exports.Direction = {}));\r\nexports.DIRECTIONS = [\r\n Direction.NORTH,\r\n Direction.NORTHEAST,\r\n Direction.EAST,\r\n Direction.SOUTHEAST,\r\n Direction.SOUTH,\r\n Direction.SOUTHWEST,\r\n Direction.WEST,\r\n Direction.NORTHWEST,\r\n];\r\nconst DIRECTIONS_STR = [\r\n 'N',\r\n 'NE',\r\n 'E',\r\n 'SE',\r\n 'S',\r\n 'SW',\r\n 'W',\r\n 'NW',\r\n];\r\nfunction directionToString(dir) {\r\n return DIRECTIONS_STR[dir];\r\n}\r\nexports.directionToString = directionToString;\r\nfunction directionIsCardinal(dir) {\r\n return (dir & 1) === 0;\r\n}\r\nexports.directionIsCardinal = directionIsCardinal;\r\nfunction directionOpposite(dir) {\r\n return ((dir + 4) & 7);\r\n}\r\nexports.directionOpposite = directionOpposite;\r\n// conversion\r\nfunction directionFromCardinalDirection(dir) {\r\n return (dir << 1);\r\n}\r\nexports.directionFromCardinalDirection = directionFromCardinalDirection;\r\n// math\r\nfunction directionAddTurn(dir, turn) {\r\n return ((dir + turn) & 7);\r\n}\r\nexports.directionAddTurn = directionAddTurn;\r\nfunction directionAddCardinalTurn(dir, turn) {\r\n return ((dir + turn * 2) & 7);\r\n}\r\nexports.directionAddCardinalTurn = directionAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.flipFromCardinalOrientation = exports.flipFromBoolean = exports.flipOpposite = exports.flipToString = exports.FLIPS = exports.Flip = void 0;\r\nvar Flip;\r\n(function (Flip) {\r\n Flip[Flip[\"HEADS\"] = 0] = \"HEADS\";\r\n Flip[Flip[\"TAILS\"] = 1] = \"TAILS\";\r\n})(Flip = exports.Flip || (exports.Flip = {}));\r\nexports.FLIPS = [\r\n Flip.HEADS,\r\n Flip.TAILS,\r\n];\r\nconst FLIPS_STR = [\r\n 'H',\r\n 'T',\r\n];\r\nfunction flipToString(flip) {\r\n return FLIPS_STR[flip];\r\n}\r\nexports.flipToString = flipToString;\r\nfunction flipOpposite(flip) {\r\n return (flip ^ 1);\r\n}\r\nexports.flipOpposite = flipOpposite;\r\n// conversion\r\nfunction flipFromBoolean(tails) {\r\n return tails ? Flip.TAILS : Flip.HEADS;\r\n}\r\nexports.flipFromBoolean = flipFromBoolean;\r\nfunction flipFromCardinalOrientation(orientation) {\r\n return (orientation & 1);\r\n}\r\nexports.flipFromCardinalOrientation = flipFromCardinalOrientation;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./direction\"), exports);\r\n__exportStar(require(\"./turn\"), exports);\r\n__exportStar(require(\"./cardinal-direction\"), exports);\r\n__exportStar(require(\"./cardinal-turn\"), exports);\r\n__exportStar(require(\"./cardinal-direction-flags\"), exports);\r\n__exportStar(require(\"./flip\"), exports);\r\n__exportStar(require(\"./cardinal-orientation\"), exports);\r\n__exportStar(require(\"./axis\"), exports);\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.turnAddTurn = exports.turnFromDirections = exports.turnFromCardinalTurn = exports.turnFromCardinalDirections = exports.turnReverse = exports.turnIsCardinal = exports.turnToDegrees = exports.turnToString = exports.TURNS = exports.Turn = void 0;\r\nvar Turn;\r\n(function (Turn) {\r\n Turn[Turn[\"NONE\"] = 0] = \"NONE\";\r\n Turn[Turn[\"R_45\"] = 1] = \"R_45\";\r\n Turn[Turn[\"R_90\"] = 2] = \"R_90\";\r\n Turn[Turn[\"R_135\"] = 3] = \"R_135\";\r\n Turn[Turn[\"T_180\"] = 4] = \"T_180\";\r\n Turn[Turn[\"L_135\"] = 5] = \"L_135\";\r\n Turn[Turn[\"L_90\"] = 6] = \"L_90\";\r\n Turn[Turn[\"L_45\"] = 7] = \"L_45\";\r\n})(Turn = exports.Turn || (exports.Turn = {}));\r\nexports.TURNS = [\r\n Turn.NONE,\r\n Turn.R_45,\r\n Turn.R_90,\r\n Turn.R_135,\r\n Turn.T_180,\r\n Turn.L_135,\r\n Turn.L_90,\r\n Turn.L_45,\r\n];\r\nconst TURNS_STR = [\r\n 'T0',\r\n 'T+45',\r\n 'T+90',\r\n 'T+135',\r\n 'T180',\r\n 'T-135',\r\n 'T-90',\r\n 'T-45',\r\n];\r\nfunction turnToString(turn) {\r\n return TURNS_STR[turn];\r\n}\r\nexports.turnToString = turnToString;\r\nfunction turnToDegrees(turn) {\r\n return turn * 45;\r\n}\r\nexports.turnToDegrees = turnToDegrees;\r\nfunction turnIsCardinal(turn) {\r\n return (turn & 1) === 0;\r\n}\r\nexports.turnIsCardinal = turnIsCardinal;\r\nfunction turnReverse(turn) {\r\n return ((8 - turn) & 7);\r\n}\r\nexports.turnReverse = turnReverse;\r\n// conversion\r\nfunction turnFromCardinalDirections(from, to) {\r\n return (((to - from) * 2) & 7);\r\n}\r\nexports.turnFromCardinalDirections = turnFromCardinalDirections;\r\nfunction turnFromCardinalTurn(turn) {\r\n return (turn << 1);\r\n}\r\nexports.turnFromCardinalTurn = turnFromCardinalTurn;\r\nfunction turnFromDirections(from, to) {\r\n return ((to - from) & 7);\r\n}\r\nexports.turnFromDirections = turnFromDirections;\r\n// math\r\nfunction turnAddTurn(turn1, turn2) {\r\n return ((turn1 + turn2) & 7);\r\n}\r\nexports.turnAddTurn = turnAddTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.CardinalPath = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nconst offset_1 = require(\"./offset\");\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst raster_mask_1 = require(\"./raster-mask\");\r\nconst LOCAL_OFF = new offset_1.Offset();\r\nfunction sortedInsert(array, value) {\r\n array.push(value);\r\n let i = array.length - 1;\r\n while (i > 0 && value < array[i - 1]) {\r\n array[i] = array[i - 1];\r\n i--;\r\n }\r\n array[i] = value;\r\n}\r\nclass CardinalPath {\r\n constructor(start, segments) {\r\n this._start = new offset_1.Offset();\r\n this._start.copyFrom(start);\r\n this._segments = segments;\r\n }\r\n // accessors\r\n toString() {\r\n return `${this._start.toString()}:`\r\n + `${this._segments.map((segment) => compass_1.cardinalDirectionToString(segment)).join('')}`;\r\n }\r\n equals(other) {\r\n return this._start.equals(other._start)\r\n && this._segments.length === other._segments.length\r\n && this._segments.every((v, i) => v === other._segments[i]);\r\n }\r\n get length() {\r\n return this._segments.length;\r\n }\r\n // utilities\r\n getIsClosed() {\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n }\r\n return this._start.equals(LOCAL_OFF);\r\n }\r\n *offsets() {\r\n let { x, y } = this._start;\r\n yield { x, y };\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.setFromCardinalDirection(segment);\r\n x += LOCAL_OFF.x;\r\n y += LOCAL_OFF.y;\r\n yield { x, y };\r\n }\r\n }\r\n getBounds() {\r\n let northY = this._start.y;\r\n let southY = northY;\r\n let westX = this._start.x;\r\n let eastX = westX;\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n switch (segment) {\r\n case compass_1.CardinalDirection.NORTH:\r\n northY = Math.min(northY, LOCAL_OFF.y);\r\n break;\r\n case compass_1.CardinalDirection.EAST:\r\n eastX = Math.max(eastX, LOCAL_OFF.x);\r\n break;\r\n case compass_1.CardinalDirection.SOUTH:\r\n southY = Math.max(southY, LOCAL_OFF.y);\r\n break;\r\n case compass_1.CardinalDirection.WEST:\r\n westX = Math.min(westX, LOCAL_OFF.x);\r\n break;\r\n // istanbul ignore next\r\n default:\r\n throw new Error(`bad direction ${segment} in cardinal path`);\r\n }\r\n }\r\n return new rectangle_1.Rectangle(westX, northY, eastX - westX + 1, southY - northY + 1);\r\n }\r\n getArea() {\r\n let total = 0;\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n switch (segment) {\r\n case compass_1.CardinalDirection.NORTH:\r\n total -= LOCAL_OFF.x;\r\n break;\r\n case compass_1.CardinalDirection.SOUTH:\r\n total += LOCAL_OFF.x;\r\n break;\r\n }\r\n }\r\n return Math.abs(total);\r\n }\r\n rasterize(bounds) {\r\n const lines = new Array();\r\n if (typeof bounds === 'undefined') {\r\n bounds = this.getBounds();\r\n }\r\n // assert(this.getIsClosed())\r\n LOCAL_OFF.copyFrom(this._start);\r\n const { northY } = bounds;\r\n const southY = northY + bounds.height - 1;\r\n for (let y = northY; y < southY; y++) {\r\n lines.push([]);\r\n }\r\n LOCAL_OFF.copyFrom(this._start);\r\n // assert(LOCAL_OFF.y >= northY && LOCAL_OFF.y <= southY)\r\n for (const segment of this._segments) {\r\n if (segment === compass_1.CardinalDirection.SOUTH) {\r\n sortedInsert(lines[LOCAL_OFF.y - northY], LOCAL_OFF.x);\r\n }\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n // assert(LOCAL_OFF.y >= northY && LOCAL_OFF.y <= southY)\r\n if (segment === compass_1.CardinalDirection.NORTH) {\r\n sortedInsert(lines[LOCAL_OFF.y - northY], LOCAL_OFF.x);\r\n }\r\n }\r\n return new raster_mask_1.RasterMask({\r\n westX: bounds.westX,\r\n northY: bounds.northY,\r\n width: bounds.width - 1,\r\n height: bounds.height - 1,\r\n }, lines);\r\n }\r\n}\r\nexports.CardinalPath = CardinalPath;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./offset\"), exports);\r\n__exportStar(require(\"./size\"), exports);\r\n__exportStar(require(\"./rectangle\"), exports);\r\n__exportStar(require(\"./mask\"), exports);\r\n__exportStar(require(\"./mask-rectangle\"), exports);\r\n__exportStar(require(\"./raster-mask\"), exports);\r\n__exportStar(require(\"./cardinal-path\"), exports);\r\n__exportStar(require(\"./transform-rectangle\"), exports);\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.MaskRectangle = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst mask_1 = require(\"./mask\");\r\nclass MaskRectangle {\r\n constructor(rect, initialValue = false, outsideValue = false) {\r\n this._rect = new rectangle_1.Rectangle();\r\n if (typeof rect !== 'undefined') {\r\n this._rect.copyFrom(rect);\r\n }\r\n this._mask = new mask_1.Mask(rect, initialValue);\r\n this._outsideValue = outsideValue;\r\n }\r\n // accessors\r\n toString() {\r\n return `${this._rect.northWest}/${this._outsideValue}\\n${this._mask}`;\r\n }\r\n equals(other) {\r\n return this._rect.equals(other._rect)\r\n && this._mask.equals(other._mask)\r\n && this._outsideValue === other._outsideValue;\r\n }\r\n get westX() {\r\n return this._rect.westX;\r\n }\r\n get northY() {\r\n return this._rect.northY;\r\n }\r\n get width() {\r\n return this._rect.width;\r\n }\r\n get height() {\r\n return this._rect.height;\r\n }\r\n get(x, y) {\r\n if (!this._rect.contains(x, y)) {\r\n return this._outsideValue;\r\n }\r\n return this._mask.get(x - this.westX, y - this.northY);\r\n }\r\n getAtIndex(index) {\r\n return this._mask.getAtIndex(index);\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._rect.copyFrom(other._rect);\r\n this._mask.copyFrom(other._mask);\r\n this._outsideValue = other._outsideValue;\r\n return this;\r\n }\r\n set(x, y, value) {\r\n this._mask.set(x - this.westX, y - this.northY, value);\r\n return this;\r\n }\r\n setAtOffset(off, value) {\r\n return this.set(off.x, off.y, value);\r\n }\r\n setAtIndex(index, value) {\r\n this._mask.setAtIndex(index, value);\r\n return this;\r\n }\r\n // utilities\r\n index(x, y) {\r\n return this._mask.index(x - this.westX, y - this.northY);\r\n }\r\n *locations() {\r\n for (const loc of this._mask.locations()) {\r\n const x = loc.x + this.westX;\r\n const y = loc.y + this.northY;\r\n const { value } = loc;\r\n yield { x, y, value };\r\n }\r\n }\r\n *offsetsWithTrue() {\r\n for (const off of this._mask.offsetsWithTrue()) {\r\n const x = off.x + this.westX;\r\n const y = off.y + this.northY;\r\n yield { x, y };\r\n }\r\n }\r\n}\r\nexports.MaskRectangle = MaskRectangle;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Mask = void 0;\r\nconst size_1 = require(\"./size\");\r\nclass Mask {\r\n constructor(size, initialValue = false) {\r\n this._size = new size_1.Size();\r\n if (typeof size !== 'undefined') {\r\n this._size.copyFrom(size);\r\n }\r\n this._bits = new Array(Math.ceil(this._size.area / 32)).fill(initialValue ? 0xffffffff : 0);\r\n }\r\n // accessors\r\n toString() {\r\n let ret = '';\r\n for (let y = 0; y < this.height; y++) {\r\n for (let x = 0; x < this.width; x++) {\r\n ret += this.get(x, y) ? '☑' : '☐';\r\n }\r\n ret += '\\n';\r\n }\r\n return ret;\r\n }\r\n equals(other) {\r\n return this._size.equals(other._size)\r\n && this._bits.length === other._bits.length\r\n && this._bits.every((v, i) => v === other._bits[i]);\r\n }\r\n get width() {\r\n return this._size.width;\r\n }\r\n get height() {\r\n return this._size.height;\r\n }\r\n get(x, y) {\r\n return this.getAtIndex(this.index(x, y));\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n getAtIndex(index) {\r\n // assert(index >= 0 && index < this._size.area)\r\n const arrayIndex = index >>> 5;\r\n const bitMask = 1 << (index & 31);\r\n return (this._bits[arrayIndex] & bitMask) !== 0;\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._size.copyFrom(other._size);\r\n this._bits = other._bits.slice();\r\n return this;\r\n }\r\n set(x, y, value) {\r\n return this.setAtIndex(this.index(x, y), value);\r\n }\r\n setAtOffset(off, value) {\r\n return this.set(off.x, off.y, value);\r\n }\r\n setAtIndex(index, value) {\r\n // assert(index >= 0 && index < this._size.area)\r\n const arrayIndex = index >>> 5;\r\n const bitMask = 1 << (index & 31);\r\n if (value) {\r\n this._bits[arrayIndex] |= bitMask;\r\n }\r\n else {\r\n this._bits[arrayIndex] &= ~bitMask;\r\n }\r\n return this;\r\n }\r\n // utilities\r\n index(x, y) {\r\n return this._size.index(x, y);\r\n }\r\n *locations() {\r\n let arrayIndex = 0;\r\n let bitMask = 1;\r\n for (const { x, y } of this._size.offsets()) {\r\n const value = (this._bits[arrayIndex] & bitMask) !== 0;\r\n yield { x, y, value };\r\n if (bitMask === (1 << 31)) {\r\n bitMask = 1;\r\n arrayIndex++;\r\n }\r\n else {\r\n bitMask <<= 1;\r\n }\r\n }\r\n }\r\n *offsetsWithTrue() {\r\n for (const { x, y, value } of this.locations()) {\r\n if (value) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n}\r\nexports.Mask = Mask;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Offset = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nconst X_FROM_DIRECTION = [0, 1, 1, 1, 0, -1, -1, -1];\r\nconst Y_FROM_DIRECTION = [-1, -1, 0, 1, 1, 1, 0, -1];\r\nconst X_FROM_CARDINAL_DIRECTION = [0, 1, 0, -1];\r\nconst Y_FROM_CARDINAL_DIRECTION = [-1, 0, 1, 0];\r\nclass Offset {\r\n constructor(x, y) {\r\n if (typeof x === 'undefined') {\r\n x = 0;\r\n }\r\n if (typeof y === 'undefined') {\r\n y = 0;\r\n }\r\n this.x = x;\r\n this.y = y;\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.x},${this.y})`;\r\n }\r\n equals(other) {\r\n return this.x === other.x && this.y === other.y;\r\n }\r\n // mutators\r\n set(x, y) {\r\n this.x = x;\r\n this.y = y;\r\n return this;\r\n }\r\n copyFrom(other) {\r\n return this.set(other.x, other.y);\r\n }\r\n setFromDirection(dir) {\r\n return this.set(X_FROM_DIRECTION[dir], Y_FROM_DIRECTION[dir]);\r\n }\r\n setFromCardinalDirection(dir) {\r\n return this.set(X_FROM_CARDINAL_DIRECTION[dir], Y_FROM_CARDINAL_DIRECTION[dir]);\r\n }\r\n add(x, y) {\r\n this.x += x;\r\n this.y += y;\r\n return this;\r\n }\r\n addSize(size) {\r\n return this.add(size.width, size.height);\r\n }\r\n addOffset(off) {\r\n return this.add(off.x, off.y);\r\n }\r\n addDirection(dir) {\r\n return this.add(X_FROM_DIRECTION[dir], Y_FROM_DIRECTION[dir]);\r\n }\r\n addCardinalDirection(dir) {\r\n return this.add(X_FROM_CARDINAL_DIRECTION[dir], Y_FROM_CARDINAL_DIRECTION[dir]);\r\n }\r\n subtractOffset(off) {\r\n return this.add(-off.x, -off.y);\r\n }\r\n multiply(factor) {\r\n this.x *= factor;\r\n this.y *= factor;\r\n return this;\r\n }\r\n rotate(turn, anchor) {\r\n if (anchor) {\r\n return this.subtractOffset(anchor).rotate(turn).addOffset(anchor);\r\n }\r\n else {\r\n const dir = compass_1.cardinalDirectionFromNorthTurn(turn);\r\n const { x, y } = this;\r\n const dirx = X_FROM_CARDINAL_DIRECTION[dir];\r\n const diry = Y_FROM_CARDINAL_DIRECTION[dir];\r\n const nx = -y * dirx - x * diry;\r\n const ny = x * dirx - y * diry;\r\n return this.set(nx, ny);\r\n }\r\n }\r\n // utilities\r\n // chebyshev: can move in any direction (diagonals are ok)\r\n distanceChebyshev(other) {\r\n return Math.max(Math.abs(this.x - other.x), Math.abs(this.y - other.y));\r\n }\r\n // manhattan: can move only in cardinal directions (no diagonals)\r\n distanceManhattan(other) {\r\n return Math.abs(this.x - other.x) + Math.abs(this.y - other.y);\r\n }\r\n // chebyshev: can move in any direction (diagonals are ok)\r\n *nearbyChebyshevOffsets(cursor, radius) {\r\n if (radius >= 0) {\r\n for (let dy = -radius; dy <= radius; dy++) {\r\n for (let dx = -radius; dx <= radius; dx++) {\r\n yield cursor.set(this.x + dx, this.y + dy);\r\n }\r\n }\r\n }\r\n }\r\n}\r\nexports.Offset = Offset;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.RasterMask = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nclass RasterMask {\r\n constructor(bounds, lines) {\r\n this._rect = new rectangle_1.Rectangle();\r\n if (lines.length !== bounds.height) {\r\n throw new Error(`bad lines array length ${lines.length} for bounds ${bounds}`);\r\n }\r\n this._rect.copyFrom(bounds);\r\n this._lines = lines;\r\n }\r\n // accessors\r\n toString() {\r\n let shape = '';\r\n const { eastX } = this._rect;\r\n for (let y = 0; y < this.height; y++) {\r\n const line = this._lines[y];\r\n let x = this.westX;\r\n for (let i = 0; i < line.length; i += 2) {\r\n const start = line[i];\r\n const end = line[i + 1];\r\n while (x < start) {\r\n shape += '∙';\r\n x++;\r\n }\r\n while (x < end) {\r\n shape += '█';\r\n x++;\r\n }\r\n }\r\n while (x <= eastX) {\r\n shape += '∙';\r\n x++;\r\n }\r\n shape += '\\n';\r\n }\r\n return `(${this._rect.westX},${this._rect.northY})\\n${shape}`;\r\n }\r\n equals(other) {\r\n return this._rect.equals(other._rect)\r\n && this._lines.length === other._lines.length\r\n && this._lines.every((v, i) => (v.length === other._lines[i].length\r\n && v.every((w, j) => w === other._lines[i][j])));\r\n }\r\n get northY() {\r\n return this._rect.northY;\r\n }\r\n get southY() {\r\n return this._rect.southY;\r\n }\r\n get westX() {\r\n return this._rect.westX;\r\n }\r\n get width() {\r\n return this._rect.width;\r\n }\r\n get height() {\r\n return this._rect.height;\r\n }\r\n get(x, y) {\r\n if (y < this.northY || y > this._rect.southY) {\r\n return false;\r\n }\r\n const line = this._lines[y - this.northY];\r\n for (let i = 0; i < line.length; i += 2) {\r\n if (x >= line[i] && x < line[i + 1]) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n // utilities\r\n *bandsAt(y) {\r\n if (y >= this.northY && y <= this._rect.southY) {\r\n const line = this._lines[y - this.northY];\r\n for (let i = 0; i < line.length; i += 2) {\r\n yield {\r\n westX: line[i],\r\n eastX: line[i + 1] - 1,\r\n };\r\n }\r\n }\r\n }\r\n}\r\nexports.RasterMask = RasterMask;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Rectangle = void 0;\r\nconst size_1 = require(\"./size\");\r\nconst offset_1 = require(\"./offset\");\r\nconst ROTATE_CORNER_X = [0, 0, 1, 1];\r\nconst ROTATE_CORNER_Y = [0, 1, 1, 0];\r\nclass Rectangle {\r\n constructor(westX, northY, width, height) {\r\n if (typeof westX === 'undefined') {\r\n westX = 0;\r\n }\r\n if (typeof northY === 'undefined') {\r\n northY = 0;\r\n }\r\n if (typeof width === 'undefined') {\r\n width = 0;\r\n }\r\n if (typeof height === 'undefined') {\r\n height = 0;\r\n }\r\n this.northWest = new offset_1.Offset(westX, northY);\r\n this.size = new size_1.Size(width, height);\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.westX},${this.northY} ${this.width}x${this.height})`;\r\n }\r\n equals(other) {\r\n return this.westX === other.westX && this.northY === other.northY && this.size.equals(other);\r\n }\r\n get northY() {\r\n return this.northWest.y;\r\n }\r\n get southY() {\r\n return this.northWest.y + this.size.height - 1;\r\n }\r\n get westX() {\r\n return this.northWest.x;\r\n }\r\n get eastX() {\r\n return this.northWest.x + this.size.width - 1;\r\n }\r\n get width() {\r\n return this.size.width;\r\n }\r\n get height() {\r\n return this.size.height;\r\n }\r\n get empty() {\r\n return this.size.empty;\r\n }\r\n get area() {\r\n return this.size.area;\r\n }\r\n // mutators\r\n set(westX, northY, width, height) {\r\n this.northWest.set(westX, northY);\r\n this.size.set(width, height);\r\n return this;\r\n }\r\n setFromCorners(off1, off2) {\r\n const westX = Math.min(off1.x, off2.x);\r\n const eastX = Math.max(off1.x, off2.x);\r\n const northY = Math.min(off1.y, off2.y);\r\n const southY = Math.max(off1.y, off2.y);\r\n return this.set(westX, northY, eastX - westX + 1, southY - northY + 1);\r\n }\r\n copyFrom(other) {\r\n return this.set(other.westX, other.northY, other.width, other.height);\r\n }\r\n addOffset(off) {\r\n this.northWest.addOffset(off);\r\n return this;\r\n }\r\n scale(factor) {\r\n this.northWest.multiply(factor);\r\n this.size.multiply(factor);\r\n return this;\r\n }\r\n rotate(turn, anchor) {\r\n const cx = ROTATE_CORNER_X[turn];\r\n const cy = ROTATE_CORNER_Y[turn];\r\n this.northWest.add(cx * (this.width - 1), cy * (this.height - 1)).rotate(turn, anchor);\r\n this.size.rotate(turn);\r\n return this;\r\n }\r\n extendToInclude(off) {\r\n const dx = off.x - this.westX;\r\n if (dx < 0) {\r\n this.size.width -= dx;\r\n this.northWest.x = off.x;\r\n }\r\n else if (dx >= this.size.width) {\r\n this.size.width = dx + 1;\r\n }\r\n const dy = off.y - this.northWest.y;\r\n if (dy < 0) {\r\n this.size.height -= dy;\r\n this.northWest.y = off.y;\r\n }\r\n else if (dy >= this.size.height) {\r\n this.size.height = dy + 1;\r\n }\r\n return this;\r\n }\r\n // utilities\r\n contains(x, y) {\r\n return this.size.contains(x - this.westX, y - this.northY);\r\n }\r\n index(x, y) {\r\n return this.size.index(x - this.westX, y - this.northY);\r\n }\r\n containsOffset(off) {\r\n return this.contains(off.x, off.y);\r\n }\r\n containsRectangle(other) {\r\n if (other.width === 0 && other.height === 0) {\r\n return false;\r\n }\r\n const x = other.westX - this.westX;\r\n const y = other.northY - this.northY;\r\n if (!this.size.contains(x, y)) {\r\n return false;\r\n }\r\n return this.size.contains(x + other.width - 1, y + other.height - 1);\r\n }\r\n overlapsRectangle(other) {\r\n return this.northY <= other.northY + other.height - 1\r\n && this.southY >= other.northY\r\n && this.westX <= other.westX + other.width - 1\r\n && this.eastX >= other.westX\r\n && !this.empty\r\n && other.width !== 0 && other.height !== 0;\r\n }\r\n *offsets() {\r\n const { eastX, southY } = this;\r\n for (let y = this.northY; y <= southY; y++) {\r\n for (let x = this.westX; x <= eastX; x++) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n anyOf(predicate) {\r\n for (const { x, y } of this.offsets()) {\r\n if (predicate(x, y)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\nexports.Rectangle = Rectangle;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Size = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nclass Size {\r\n constructor(width, height) {\r\n if (typeof width === 'undefined') {\r\n width = 0;\r\n }\r\n if (typeof height === 'undefined') {\r\n height = 0;\r\n }\r\n if (width < 0 || height < 0) {\r\n throw new Error(`bad size (${width}x${height})`);\r\n }\r\n this.width = width;\r\n this.height = height;\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.width}x${this.height})`;\r\n }\r\n equals(other) {\r\n return this.width === other.width && this.height === other.height;\r\n }\r\n get empty() {\r\n return this.width === 0 || this.height === 0;\r\n }\r\n get area() {\r\n return this.width * this.height;\r\n }\r\n // mutators\r\n set(width, height) {\r\n if (width < 0 || height < 0) {\r\n throw new Error(`bad size (${width}x${height})`);\r\n }\r\n this.width = width;\r\n this.height = height;\r\n return this;\r\n }\r\n copyFrom(other) {\r\n return this.set(other.width, other.height);\r\n }\r\n add(width, height) {\r\n this.width += width;\r\n this.height += height;\r\n return this;\r\n }\r\n multiply(factor) {\r\n this.width *= factor;\r\n this.height *= factor;\r\n return this;\r\n }\r\n rotate(turn) {\r\n if (compass_1.axisFromNorthSouthTurn(turn) === compass_1.Axis.WEST_EAST) {\r\n this.set(this.height, this.width);\r\n }\r\n return this;\r\n }\r\n // utilities\r\n contains(x, y) {\r\n return x >= 0 && y >= 0 && x < this.width && y < this.height;\r\n }\r\n containsOffset(off) {\r\n return this.contains(off.x, off.y);\r\n }\r\n index(x, y) {\r\n return y * this.width + x;\r\n }\r\n *offsets() {\r\n for (let y = 0; y < this.height; y++) {\r\n for (let x = 0; x < this.width; x++) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n anyOf(predicate) {\r\n for (const { x, y } of this.offsets()) {\r\n if (predicate(x, y)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\nexports.Size = Size;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.TransformRectangle = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst compass_1 = require(\"../compass\");\r\nconst offset_1 = require(\"./offset\");\r\nconst size_1 = require(\"./size\");\r\nconst LOCAL_OFF = new offset_1.Offset();\r\nconst LOCAL_OFF2 = new offset_1.Offset();\r\nconst LOCAL_SIZE = new size_1.Size();\r\nclass TransformRectangle {\r\n constructor(width, height) {\r\n this._size = new size_1.Size();\r\n this._flip = compass_1.Flip.HEADS;\r\n this._rotate = compass_1.CardinalTurn.NONE;\r\n this._translate = new offset_1.Offset();\r\n this._matrix = [1, 0, 0, 0, 1, 0];\r\n this._targetRect = new rectangle_1.Rectangle();\r\n if (typeof width === 'undefined') {\r\n // nothing\r\n }\r\n else if (typeof width === 'number') {\r\n this._size.set(width, height);\r\n }\r\n else {\r\n this._size.copyFrom(width);\r\n }\r\n this._update();\r\n }\r\n // accessors\r\n toString() {\r\n return `[${this._size}`\r\n + ` -> ${compass_1.flipToString(this._flip)} ${compass_1.cardinalTurnToString(this._rotate)} ${this._translate}`\r\n + ` -> ${this._targetRect}]`;\r\n }\r\n equals(other) {\r\n return this._size.equals(other._size)\r\n && this._flip === other._flip\r\n && this._rotate === other._rotate\r\n && this._translate.equals(other._translate);\r\n }\r\n get flip() {\r\n return this._flip;\r\n }\r\n get rotate() {\r\n return this._rotate;\r\n }\r\n get northY() {\r\n return this._translate.y;\r\n }\r\n get southY() {\r\n return this._translate.y + this._targetRect.height - 1;\r\n }\r\n get westX() {\r\n return this._translate.x;\r\n }\r\n get eastX() {\r\n return this._translate.x + this._targetRect.width - 1;\r\n }\r\n get width() {\r\n return this._targetRect.width;\r\n }\r\n get height() {\r\n return this._targetRect.height;\r\n }\r\n // internal\r\n // 0\r\n // 0 -1\r\n // +90\r\n // 1 0\r\n // 180\r\n // 0 1\r\n // -90\r\n // -1 0\r\n //\r\n // heads:\r\n // 0\r\n // 1 0 x\r\n // 0 1 y\r\n // +90\r\n // 0 -1 x + h - 1\r\n // 1 0 y\r\n // 180\r\n // -1 0 x + w - 1\r\n // 0 -1 y + h - 1\r\n // -90\r\n // 0 1 x\r\n // -1 0 y + w - 1\r\n //\r\n // tails:\r\n // 0\r\n // -1 0 x + w - 1\r\n // 0 1 y\r\n // +90\r\n // 0 -1 x + h - 1\r\n // -1 0 y + w - 1\r\n // 180\r\n // 1 0 x\r\n // 0 -1 y + h - 1\r\n // -90\r\n // 0 1 x\r\n // 1 0 y\r\n _update() {\r\n LOCAL_OFF.setFromCardinalDirection(compass_1.cardinalDirectionFromNorthTurn(this._rotate));\r\n const flipSign = this._flip === compass_1.Flip.TAILS ? -1 : 1;\r\n this._matrix[0] = -LOCAL_OFF.y * flipSign;\r\n this._matrix[1] = -LOCAL_OFF.x;\r\n this._matrix[2] = this._translate.x;\r\n this._matrix[3] = LOCAL_OFF.x * flipSign;\r\n this._matrix[4] = -LOCAL_OFF.y;\r\n this._matrix[5] = this._translate.y;\r\n switch (this._rotate) {\r\n case compass_1.CardinalTurn.NONE:\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n this._matrix[2] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.RIGHT:\r\n this._matrix[2] += this._size.height - 1;\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n this._matrix[5] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.AROUND:\r\n this._matrix[5] += this._size.height - 1;\r\n if (this._flip === compass_1.Flip.HEADS) {\r\n this._matrix[2] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.LEFT:\r\n if (this._flip === compass_1.Flip.HEADS) {\r\n this._matrix[5] += this._size.width - 1;\r\n }\r\n break;\r\n }\r\n LOCAL_SIZE.copyFrom(this._size).rotate(this._rotate);\r\n this._targetRect.set(this._translate.x, this._translate.y, LOCAL_SIZE.width, LOCAL_SIZE.height);\r\n return this;\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._size.copyFrom(other._size);\r\n this._flip = other._flip;\r\n this._rotate = other._rotate;\r\n this._translate.copyFrom(other._translate);\r\n other._matrix.forEach((v, i) => this._matrix[i] = v);\r\n this._targetRect.copyFrom(other._targetRect);\r\n return this;\r\n }\r\n reset() {\r\n this._flip = compass_1.Flip.HEADS;\r\n this._rotate = compass_1.CardinalTurn.NONE;\r\n this._translate.set(0, 0);\r\n return this._update();\r\n }\r\n invert() {\r\n const nrotate = compass_1.cardinalTurnFromCardinalDirections(compass_1.CardinalDirection.NORTH, compass_1.cardinalDirectionFromCardinalOrientation(compass_1.cardinalOrientationReverse(compass_1.cardinalOrientationFromFlipAndCardinalDirection(this._flip, compass_1.cardinalDirectionFromNorthTurn(this._rotate)))));\r\n this._rotate = nrotate;\r\n this._size.rotate(nrotate);\r\n this._translate.multiply(-1);\r\n return this._update();\r\n }\r\n setTransform(flip, rotate, translate) {\r\n this._flip = flip;\r\n this._rotate = rotate;\r\n this._translate.copyFrom(translate);\r\n return this._update();\r\n }\r\n setFlip(flip) {\r\n this._flip = flip;\r\n return this._update();\r\n }\r\n setRotate(rotate) {\r\n this._rotate = rotate;\r\n return this._update();\r\n }\r\n setTranslate(x, y) {\r\n this._translate.set(x, y);\r\n return this._update();\r\n }\r\n setTranslateOffset(translate) {\r\n this._translate.copyFrom(translate);\r\n return this._update();\r\n }\r\n // utility\r\n applyToCardinalOrientation(orientation) {\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n orientation = compass_1.cardinalOrientationFlip(orientation, compass_1.Axis.NORTH_SOUTH);\r\n }\r\n return compass_1.cardinalOrientationAddCardinalTurn(orientation, this._rotate);\r\n }\r\n unapplyFromCardinalOrientation(orientation) {\r\n orientation = compass_1.cardinalOrientationAddCardinalTurn(orientation, compass_1.cardinalTurnReverse(this._rotate));\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n orientation = compass_1.cardinalOrientationFlip(orientation, compass_1.Axis.NORTH_SOUTH);\r\n }\r\n return orientation;\r\n }\r\n applyToCardinalDirection(orientation) {\r\n return compass_1.cardinalDirectionFromCardinalOrientation(this.applyToCardinalOrientation(compass_1.cardinalOrientationFromFlipAndCardinalDirection(compass_1.Flip.HEADS, orientation)));\r\n }\r\n unapplyFromCardinalDirection(orientation) {\r\n return compass_1.cardinalDirectionFromCardinalOrientation(this.unapplyFromCardinalOrientation(compass_1.cardinalOrientationFromFlipAndCardinalDirection(compass_1.Flip.HEADS, orientation)));\r\n }\r\n applyTo(offOut, x, y) {\r\n const nx = x * this._matrix[0] + y * this._matrix[1] + this._matrix[2];\r\n const ny = x * this._matrix[3] + y * this._matrix[4] + this._matrix[5];\r\n return offOut.set(nx, ny);\r\n }\r\n unapplyFrom(offOut, x, y) {\r\n const tx = x - this._matrix[2];\r\n const ty = y - this._matrix[5];\r\n const nx = tx * this._matrix[0] + ty * this._matrix[3];\r\n const ny = tx * this._matrix[1] + ty * this._matrix[4];\r\n return offOut.set(nx, ny);\r\n }\r\n applyToOffset(offOut, off) {\r\n if (typeof off === 'undefined') {\r\n off = offOut;\r\n }\r\n return this.applyTo(offOut, off.x, off.y);\r\n }\r\n unapplyFromOffset(offOut, off) {\r\n if (typeof off === 'undefined') {\r\n off = offOut;\r\n }\r\n return this.unapplyFrom(offOut, off.x, off.y);\r\n }\r\n applyToRectangle(rectOut, rect) {\r\n if (typeof rect !== 'undefined') {\r\n rectOut.copyFrom(rect);\r\n }\r\n LOCAL_OFF.set(rectOut.westX, rectOut.northY);\r\n LOCAL_OFF2.set(rectOut.eastX, rectOut.southY);\r\n this.applyToOffset(LOCAL_OFF);\r\n this.applyToOffset(LOCAL_OFF2);\r\n return rectOut.setFromCorners(LOCAL_OFF, LOCAL_OFF2);\r\n }\r\n unapplyFromRectangle(rectOut, rect) {\r\n if (typeof rect !== 'undefined') {\r\n rectOut.copyFrom(rect);\r\n }\r\n LOCAL_OFF.set(rectOut.westX, rectOut.northY);\r\n LOCAL_OFF2.set(rectOut.eastX, rectOut.southY);\r\n this.unapplyFromOffset(LOCAL_OFF);\r\n this.unapplyFromOffset(LOCAL_OFF2);\r\n return rectOut.setFromCorners(LOCAL_OFF, LOCAL_OFF2);\r\n }\r\n}\r\nexports.TransformRectangle = TransformRectangle;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./compass\"), exports);\r\n__exportStar(require(\"./grid\"), exports);\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n});\r\nvar __importStar = (this && this.__importStar) || function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.computeFieldOfView = void 0;\r\nconst geom = __importStar(require(\"tiled-geometry\"));\r\nconst constants = __importStar(require(\"./constants\"));\r\nconst field_of_view_impl_1 = require(\"./field-of-view-impl\");\r\nconst wedge_1 = require(\"./wedge\");\r\n/* eslint-disable indent */\r\n/**\r\n * Compute the field of view for a camera at the given tile.\r\n * chebyshevRadius is the vision radius. It uses chebyshev distance\r\n * (https://en.wikipedia.org/wiki/Chebyshev_distance), which just means\r\n * that the limit of vision in a large empty field will be square.\r\n *\r\n * This returns a FieldOfView, which indicates which tiles are visible.\r\n * fieldOfView.get(x, y) will return true for visible tiles.\r\n */\r\nfunction computeFieldOfView(map, x, y, chebyshevRadius) {\r\n const origin = new geom.Offset(x, y);\r\n const field = new field_of_view_impl_1.FieldOfViewImpl(origin, chebyshevRadius);\r\n // the field is divided into quadrants\r\n quadrant(map, field, origin, chebyshevRadius, -1, -1);\r\n quadrant(map, field, origin, chebyshevRadius, 1, -1);\r\n quadrant(map, field, origin, chebyshevRadius, -1, 1);\r\n quadrant(map, field, origin, chebyshevRadius, 1, 1);\r\n return field;\r\n}\r\nexports.computeFieldOfView = computeFieldOfView;\r\nfunction quadrant(map, field, origin, chebyshevRadius, xSign, ySign) {\r\n const { x: startX, y: startY } = origin;\r\n const endDX = (Math.min(Math.max(startX + xSign * (chebyshevRadius + 1), -1), map.width) - startX) * xSign;\r\n const endDY = (Math.min(Math.max(startY + ySign * (chebyshevRadius + 1), -1), map.height) - startY) * ySign;\r\n if (endDX < 0 || endDY < 0) {\r\n // the origin is outside of the map\r\n return;\r\n }\r\n const startMapIndex = map.index(origin.x, origin.y);\r\n const startMaskIndex = field.visible.index(origin.x, origin.y);\r\n // Initial wedge is from slope zero to slope infinity (i.e. the whole quadrant)\r\n let wedges = wedge_1.initWedges();\r\n for (let dy = 0, yMapIndex = startMapIndex, yMaskIndex = startMaskIndex; dy !== endDY && wedges.length > 0; dy++, yMapIndex += ySign * map.width, yMaskIndex += ySign * field.visible.width) {\r\n const divYpos = 1 / (dy + 0.5);\r\n const divYneg = dy === 0 ? Number.POSITIVE_INFINITY : 1 / (dy - 0.5);\r\n let wedgeIndex = 0;\r\n for (let dx = 0, mapIndex = yMapIndex, maskIndex = yMaskIndex, slopeY = -0.5 * divYpos, slopeX = 0.5 * divYneg; dx !== endDX && wedgeIndex !== wedges.length; dx++, mapIndex += xSign, maskIndex += xSign,\r\n slopeY += divYpos, slopeX += divYneg) {\r\n // the slopes of the four corners of this tile\r\n // these are named as follows:\r\n // slopeY is the slope closest to the Y axis\r\n // slopeX is the slope closest to the X axis\r\n // this is always true:\r\n // slopeY < slopeX\r\n //\r\n // O = origin, C = current\r\n // +---+---+---+\r\n // | O | | |\r\n // +---+---+---X\r\n // | | | C |\r\n // +---+---Y---+\r\n // advance the wedge index until this tile is not after the current wedge\r\n while (slopeY > wedges[wedgeIndex].high) {\r\n wedgeIndex++;\r\n if (wedgeIndex >= wedges.length) {\r\n break;\r\n }\r\n }\r\n if (wedgeIndex >= wedges.length) {\r\n break;\r\n }\r\n // if the current wedge is after this tile, move on\r\n if (slopeX < wedges[wedgeIndex].low) {\r\n continue;\r\n }\r\n // we can see this tile\r\n field.visible.setAtIndex(maskIndex, true);\r\n const body = (dx !== 0 || dy !== 0) && map.getBodyAtIndex(mapIndex);\r\n if (body) {\r\n wedges = wedge_1.cutWedges(wedges, slopeY + constants.BODY_INSET, slopeX - constants.BODY_INSET);\r\n }\r\n }\r\n }\r\n}\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.WEDGE_COUNT = exports.WEDGE_HIGH = exports.WEDGE_LOW = exports.BODY_INSET = void 0;\r\n/**\r\n * A smallish number, to adjust some wedges.\r\n */\r\nconst EPSILON = 0.00001;\r\n/**\r\n * Bodies in this algorithm do not entirely fill their tiles. This is\r\n * implemented by adjusting the angles of the shadows the bodies cast,\r\n * making the wedge very slightly narrower. BODY_INSET represents the\r\n * amount of reduction on either side of the wedge.\r\n */\r\nexports.BODY_INSET = EPSILON;\r\n/**\r\n * In the shadowcasting algorithm, each shadow is represented by a \"wedge\",\r\n * running from a \"low\" angle to a \"high\" angle. The wedges are all stored in\r\n * a simple number array, with two numbers for each wedge. These constants\r\n * (WEDGE_LOW and WEDGE_HIGH) help to identify which number is which.\r\n * WEDGE_COUNT is just how many numbers per wedge.\r\n */\r\nexports.WEDGE_LOW = 0;\r\nexports.WEDGE_HIGH = 1;\r\nexports.WEDGE_COUNT = 2;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n});\r\nvar __importStar = (this && this.__importStar) || function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.FieldOfViewImpl = void 0;\r\nconst geom = __importStar(require(\"tiled-geometry\"));\r\n/**\r\n * The FieldOfViewImpl class is the concrete implementation of the FieldOfView interface.\r\n */\r\nclass FieldOfViewImpl {\r\n constructor(origin, chebyshevRadius) {\r\n this.origin = origin;\r\n this.chebyshevRadius = chebyshevRadius;\r\n const boundRect = new geom.Rectangle(origin.x - chebyshevRadius, origin.y - chebyshevRadius, chebyshevRadius * 2 + 1, chebyshevRadius * 2 + 1);\r\n this.visible = new geom.MaskRectangle(boundRect);\r\n // the origin is always visible\r\n this.visible.setAtOffset(origin, true);\r\n }\r\n getVisible(x, y) {\r\n return this.visible.get(x, y);\r\n }\r\n toString() {\r\n let ret = '';\r\n for (const location of this.visible.locations()) {\r\n const { x, y } = location;\r\n if (this.origin.equals(location)) {\r\n ret += '@';\r\n }\r\n else if (this.getVisible(x, y)) {\r\n ret += '-';\r\n }\r\n else {\r\n ret += '.';\r\n }\r\n if (x === this.visible.westX + this.visible.width - 1) {\r\n ret += '\\n';\r\n }\r\n }\r\n return ret;\r\n }\r\n}\r\nexports.FieldOfViewImpl = FieldOfViewImpl;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n});\r\nvar __importStar = (this && this.__importStar) || function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.FieldOfViewMap = void 0;\r\nconst geom = __importStar(require(\"tiled-geometry\"));\r\n/**\r\n * For each number in the _tileFlags array, we store (1 << FLAGS_POW2) cells,\r\n * as bits where a true indicates the presence of a body.\r\n */\r\nconst FLAGS_POW2 = 5;\r\n/**\r\n * The FieldOfViewMap class describes the map over which the field of view will be\r\n * computed. It starts empty.\r\n */\r\nclass FieldOfViewMap {\r\n constructor(width, height) {\r\n this._size = new geom.Size();\r\n this._size.set(width, height);\r\n this._tileFlags = new Array((this._size.area >> FLAGS_POW2) + 1).fill(0);\r\n }\r\n get width() {\r\n return this._size.width;\r\n }\r\n get height() {\r\n return this._size.height;\r\n }\r\n // bodies\r\n addBody(x, y) {\r\n if (this._size.contains(x, y)) {\r\n const index = this.index(x, y);\r\n this._tileFlags[index >> FLAGS_POW2] |= 1 << (index & ((1 << FLAGS_POW2) - 1));\r\n }\r\n return this;\r\n }\r\n removeBody(x, y) {\r\n if (this._size.contains(x, y)) {\r\n const index = this.index(x, y);\r\n this._tileFlags[index >> FLAGS_POW2] &= ~(1 << (index & ((1 << FLAGS_POW2) - 1)));\r\n }\r\n return this;\r\n }\r\n getBody(x, y) {\r\n const index = this.index(x, y);\r\n return this.getBodyAtIndex(index);\r\n }\r\n // internal\r\n index(x, y) {\r\n return this._size.index(x, y);\r\n }\r\n getBodyAtIndex(index) {\r\n return (this._tileFlags[index >> FLAGS_POW2] & (1 << (index & ((1 << FLAGS_POW2) - 1)))) !== 0;\r\n }\r\n}\r\nexports.FieldOfViewMap = FieldOfViewMap;\r\n","\"use strict\";\r\n/*\r\n * TheField\r\n * github.com/sbj42/the-field\r\n * James Clark\r\n * Licensed under the MIT license.\r\n */\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.computeFieldOfView = exports.FieldOfViewMap = void 0;\r\nvar field_of_view_map_1 = require(\"./field-of-view-map\");\r\nObject.defineProperty(exports, \"FieldOfViewMap\", { enumerable: true, get: function () { return field_of_view_map_1.FieldOfViewMap; } });\r\nvar compute_1 = require(\"./compute\");\r\nObject.defineProperty(exports, \"computeFieldOfView\", { enumerable: true, get: function () { return compute_1.computeFieldOfView; } });\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cutWedges = exports.cutWedge = exports.initWedges = void 0;\r\n// istanbul ignore next\r\nfunction rangeToString(low, high) {\r\n return `${low.toFixed(7)}-${high.toFixed(7)}`;\r\n}\r\n// istanbul ignore next\r\nfunction wedgeToString(wedge) {\r\n return `{${rangeToString(wedge.low, wedge.high)}}`;\r\n}\r\n// istanbul ignore next\r\nfunction wedgesToString(wedges) {\r\n return `[${wedges.map(wedgeToString).join(', ')}]`;\r\n}\r\n// istanbul ignore next\r\nfunction debugLog(msg) {\r\n // eslint-disable-next-line no-console\r\n console.info(msg);\r\n}\r\nfunction initWedges() {\r\n return [{ low: 0, high: Number.POSITIVE_INFINITY }];\r\n}\r\nexports.initWedges = initWedges;\r\nconst DEBUG_CUTWEDGE = false;\r\n/**\r\n * This function cuts a range of angles out of a wedge.\r\n */\r\nfunction cutWedge(wedge, low, high) {\r\n // istanbul ignore next\r\n if (DEBUG_CUTWEDGE) {\r\n debugLog(`cut ${wedgeToString(wedge)} ${rangeToString(low, high)}`);\r\n }\r\n let ret;\r\n if (low <= wedge.low) {\r\n if (high >= wedge.high) {\r\n // wedge is entirely occluded, remove it\r\n ret = [];\r\n }\r\n else if (high >= wedge.low) {\r\n // low part of wedge is occluded, trim it\r\n wedge.low = high;\r\n ret = [wedge];\r\n }\r\n else {\r\n // cut doesn't reach the wedge\r\n ret = [wedge];\r\n }\r\n }\r\n else if (high >= wedge.high) {\r\n if (low <= wedge.high) {\r\n // high part of wedge is occluded, trim it\r\n wedge.high = low;\r\n ret = [wedge];\r\n }\r\n else {\r\n // cut doesn't reach the wedge\r\n ret = [wedge];\r\n }\r\n }\r\n else {\r\n // middle part of wedge is occluded, split it\r\n const nextWedge = {\r\n low: high,\r\n high: wedge.high,\r\n };\r\n wedge.high = low;\r\n ret = [wedge, nextWedge];\r\n }\r\n // istanbul ignore next\r\n if (DEBUG_CUTWEDGE) {\r\n debugLog(`--> ${wedgesToString(ret)}`);\r\n }\r\n return ret;\r\n}\r\nexports.cutWedge = cutWedge;\r\nfunction cutWedges(wedges, low, high) {\r\n const ret = new Array();\r\n for (const wedge of wedges) {\r\n ret.push(...cutWedge(wedge, low, high));\r\n }\r\n return ret;\r\n}\r\nexports.cutWedges = cutWedges;\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// module exports must be returned from runtime so entry inlining is disabled\n// startup\n// Load entry module and return exports\nreturn __webpack_require__(607);\n"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 6402c17..3e578cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "the-field", - "version": "2.0.0", + "version": "2.0.1", "description": "Basic shadow-casting field-of-view algorithm", "keywords": [ "fov", @@ -10,8 +10,8 @@ ], "author": "James Clark ", "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "lib/index.js", + "types": "lib/index.d.ts", "repository": "https://github.com/sbj42/the-field.git", "files": [ "lib"