(q,K,_)
| 1496 | */var Ui_=U6("node:util"),BI1=U6("node:stream"),Qi_=KU();Rr6();var di_=Ui_.debuglog("sharp"),ci_=(q)=>{BO6.queue.emit("change",q)},BO6=function(q,K){if(arguments.length===1&&!Qi_.defined(q))throw Error("Invalid input");if(!(this instanceof BO6))return new BO6(q,K);return BI1.Duplex.call(this),this.options={topOffsetPre:-1,leftOffsetPre:-1,widthPre:-1,heightPre:-1,topOffsetPost:-1,leftOffsetPost:-1,widthPost:-1,heightPost:-1,width:-1,height:-1,canvas:"crop",position:0,resizeBackground:[0,0,0,255],angle:0,rotationAngle:0,rotationBackground:[0,0,0,255],rotateBefore:!1,orientBefore:!1,flip:!1,flop:!1,extendTop:0,extendBottom:0,extendLeft:0,extendRight:0,extendBackground:[0,0,0,255],extendWith:"background",withoutEnlargement:!1,withoutReduction:!1,affineMatrix:[],affineBackground:[0,0,0,255],affineIdx:0,affineIdy:0,affineOdx:0,affineOdy:0,affineInterpolator:this.constructor.interpolators.bilinear,kernel:"lanczos3",fastShrinkOnLoad:!0,tint:[-1,0,0,0],flatten:!1,flattenBackground:[0,0,0],unflatten:!1,negate:!1,negateAlpha:!0,medianSize:0,blurSigma:0,precision:"integer",minAmpl:0.2,sharpenSigma:0,sharpenM1:1,sharpenM2:2,sharpenX1:2,sharpenY2:10,sharpenY3:20,threshold:0,thresholdGrayscale:!0,trimBackground:[],trimThreshold:-1,trimLineArt:!1,dilateWidth:0,erodeWidth:0,gamma:0,gammaOut:0,greyscale:!1,normalise:!1,normaliseLower:1,normaliseUpper:99,claheWidth:0,claheHeight:0,claheMaxSlope:3,brightness:1,saturation:1,hue:0,lightness:0,booleanBufferIn:null,booleanFileIn:"",joinChannelIn:[],extractChannel:-1,removeAlpha:!1,ensureAlpha:-1,colourspace:"srgb",colourspacePipeline:"last",composite:[],fileOut:"",formatOut:"input",streamOut:!1,keepMetadata:0,withMetadataOrientation:-1,withMetadataDensity:0,withIccProfile:"",withExif:{},withExifMerge:!0,withXmp:"",resolveWithObject:!1,loop:-1,delay:[],jpegQuality:80,jpegProgressive:!1,jpegChromaSubsampling:"4:2:0",jpegTrellisQuantisation:!1,jpegOvershootDeringing:!1,jpegOptimiseScans:!1,jpegOptimiseCoding:!0,jpegQuantisationTable:0,pngProgressive:!1,pngCompressionLevel:6,pngAdaptiveFiltering:!1,pngPalette:!1,pngQuality:100,pngEffort:7,pngBitdepth:8,pngDither:1,jp2Quality:80,jp2TileHeight:512,jp2TileWidth:512,jp2Lossless:!1,jp2ChromaSubsampling:"4:4:4",webpQuality:80,webpAlphaQuality:100,webpLossless:!1,webpNearLossless:!1,webpSmartSubsample:!1,webpSmartDeblock:!1,webpPreset:"default",webpEffort:4,webpMinSize:!1,webpMixed:!1,gifBitdepth:8,gifEffort:7,gifDither:1,gifInterFrameMaxError:0,gifInterPaletteMaxError:3,gifKeepDuplicateFrames:!1,gifReuse:!0,gifProgressive:!1,tiffQuality:80,tiffCompression:"jpeg",tiffBigtiff:!1,tiffPredictor:"horizontal",tiffPyramid:!1,tiffMiniswhite:!1,tiffBitdepth:8,tiffTile:!1,tiffTileHeight:256,tiffTileWidth:256,tiffXres:1,tiffYres:1,tiffResolutionUnit:"inch",heifQuality:50,heifLossless:!1,heifCompression:"av1",heifEffort:4,heifChromaSubsampling:"4:4:4",heifBitdepth:8,jxlDistance:1,jxlDecodingTier:0,jxlEffort:7,jxlLossless:!1,rawDepth:"uchar",tileSize:256,tileOverlap:0,tileContainer:"fs",tileLayout:"dz",tileFormat:"last",tileDepth:"last",tileAngle:0,tileSkipBlanks:-1,tileBackground:[255,255,255,255],tileCentre:!1,tileId:"https://example.com/iiif",tileBasename:"",timeoutSeconds:0,linearA:[],linearB:[],pdfBackground:[255,255,255,255],debuglog:(_)=>{this.emit("warning",_),di_(_)},queueListener:ci_},this.options.input=this._createInputDescriptor(q,K,{allowStream:!0}),this};Object.setPrototypeOf(BO6.prototype,BI1.Duplex.prototype);Object.setPrototypeOf(BO6,BI1.Duplex);function li_(){let q=this.constructor.call(),{debuglog:K,queueListener:_,...z}=this.options;if(q.options=structuredClone(z),q.options.debuglog=K,q.options.queueListener=_,this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),q.options.input.buffer=this.options.input.buffer,q.emit("finish")});return q}Object.assign(BO6.prototype,{clone:li_});KX4.exports=BO6});var $X4=m((k6O,YX4)=>{/*! |
| 1497 | Copyright 2013 Lovell Fuller and others. |
| 1498 | SPDX-License-Identifier: Apache-2.0 |
| 1499 | */var z1=KU(),t76=Rr6(),ni_={left:"low",top:"low",low:"low",center:"centre",centre:"centre",right:"high",bottom:"high",high:"high"},ii_=["failOn","limitInputPixels","unlimited","animated","autoOrient","density","ignoreIcc","page","pages","sequentialRead","jp2","openSlide","pdf","raw","svg","tiff","failOnError","openSlideLevel","pdfBackground","tiffSubifd"];function zX4(q){let K=ii_.filter((_)=>z1.defined(q[_])).map((_)=>[_,q[_]]);return K.length?Object.fromEntries(K):void 0}function ri_(q,K,_){let z={autoOrient:!1,failOn:"warning",limitInputPixels:268402689,ignoreIcc:!1,unlimited:!1,sequentialRead:!0};if(z1.string(q))z.file=q;else if(z1.buffer(q)){if(q.length===0)throw Error("Input Buffer is empty");z.buffer=q}else if(z1.arrayBuffer(q)){if(q.byteLength===0)throw Error("Input bit Array is empty");z.buffer=Buffer.from(q,0,q.byteLength)}else if(z1.typedArray(q)){if(q.length===0)throw Error("Input Bit Array is empty");z.buffer=Buffer.from(q.buffer,q.byteOffset,q.byteLength)}else if(z1.plainObject(q)&&!z1.defined(K)){if(K=q,zX4(K))z.buffer=[]}else if(!z1.defined(q)&&!z1.defined(K)&&z1.object(_)&&_.allowStream)z.buffer=[];else if(Array.isArray(q))if(q.length>1)if(!this.options.joining)this.options.joining=!0,this.options.join=q.map((Y)=>this._createInputDescriptor(Y));else throw Error("Recursive join is unsupported");else throw Error("Expected at least two images to join");else throw Error(`Unsupported input '${q}' of type ${typeof q}${z1.defined(K)?` when also providing options of type ${typeof K}`:""}`);if(z1.object(K)){if(z1.defined(K.failOnError))if(z1.bool(K.failOnError))z.failOn=K.failOnError?"warning":"none";else throw z1.invalidParameterError("failOnError","boolean",K.failOnError);if(z1.defined(K.failOn))if(z1.string(K.failOn)&&z1.inArray(K.failOn,["none","truncated","error","warning"]))z.failOn=K.failOn;else throw z1.invalidParameterError("failOn","one of: none, truncated, error, warning",K.failOn);if(z1.defined(K.autoOrient))if(z1.bool(K.autoOrient))z.autoOrient=K.autoOrient;else throw z1.invalidParameterError("autoOrient","boolean",K.autoOrient);if(z1.defined(K.density))if(z1.inRange(K.density,1,1e5))z.density=K.density;else throw z1.invalidParameterError("density","number between 1 and 100000",K.density);if(z1.defined(K.ignoreIcc))if(z1.bool(K.ignoreIcc))z.ignoreIcc=K.ignoreIcc;else throw z1.invalidParameterError("ignoreIcc","boolean",K.ignoreIcc);if(z1.defined(K.limitInputPixels))if(z1.bool(K.limitInputPixels))z.limitInputPixels=K.limitInputPixels?268402689:0;else if(z1.integer(K.limitInputPixels)&&z1.inRange(K.limitInputPixels,0,Number.MAX_SAFE_INTEGER))z.limitInputPixels=K.limitInputPixels;else throw z1.invalidParameterError("limitInputPixels","positive integer",K.limitInputPixels);if(z1.defined(K.unlimited))if(z1.bool(K.unlimited))z.unlimited=K.unlimited;else throw z1.invalidParameterError("unlimited","boolean",K.unlimited);if(z1.defined(K.sequentialRead))if(z1.bool(K.sequentialRead))z.sequentialRead=K.sequentialRead;else throw z1.invalidParameterError("sequentialRead","boolean",K.sequentialRead);if(z1.defined(K.raw)){if(z1.object(K.raw)&&z1.integer(K.raw.width)&&K.raw.width>0&&z1.integer(K.raw.height)&&K.raw.height>0&&z1.integer(K.raw.channels)&&z1.inRange(K.raw.channels,1,4))switch(z.rawWidth=K.raw.width,z.rawHeight=K.raw.height,z.rawChannels=K.raw.channels,q.constructor){case Uint8Array:case Uint8ClampedArray:z.rawDepth="uchar";break;case Int8Array:z.rawDepth="char";break;case Uint16Array:z.rawDepth="ushort";break;case Int16Array:z.rawDepth="short";break;case Uint32Array:z.rawDepth="uint";break;case Int32Array:z.rawDepth="int";break;case Float32Array:z.rawDepth="float";break;case Float64Array:z.rawDepth="double";break;default:z.rawDepth="uchar";break}else throw Error("Expected width, height and channels for raw pixel input");if(z.rawPremultiplied=!1,z1.defined(K.raw.premultiplied))if(z1.bool(K.raw.premultiplied))z.rawPremultiplied=K.raw.premultiplied;else throw z1.invalidParameterError("raw.premultiplied","boolean",K.raw.premultiplied);if(z.rawPageHeight=0,z1.defined(K.raw.pageHeight))if(z1.integer(K.raw.pageHeight)&&K.raw.pageHeight>0&&K.raw.pageHeight<=K.raw.height){if(K.raw.height%K.raw.pageHeight!==0)throw Error(`Expected raw.height ${K.raw.height} to be a multiple of raw.pageHeight ${K.raw.pageHeight}`);z.rawPageHeight=K.raw.pageHeight}else throw z1.invalidParameterError("raw.pageHeight","positive integer",K.raw.pageHeight)}if(z1.defined(K.animated))if(z1.bool(K.animated))z.pages=K.animated?-1:1;else throw z1.invalidParameterError("animated","boolean",K.animated);if(z1.defined(K.pages))if(z1.integer(K.pages)&&z1.inRange(K.pages,-1,1e5))z.pages=K.pages;else throw z1.invalidParameterError("pages","integer between -1 and 100000",K.pages);if(z1.defined(K.page))if(z1.integer(K.page)&&z1.inRange(K.page,0,1e5))z.page=K.page;else throw z1.invalidParameterError("page","integer between 0 and 100000",K.page);if(z1.object(K.openSlide)&&z1.defined(K.openSlide.level))if(z1.integer(K.openSlide.level)&&z1.inRange(K.openSlide.level,0,256))z.openSlideLevel=K.openSlide.level;else throw z1.invalidParameterError("openSlide.level","integer between 0 and 256",K.openSlide.level);else if(z1.defined(K.level))if(z1.integer(K.level)&&z1.inRange(K.level,0,256))z.openSlideLevel=K.level;else throw z1.invalidParameterError("level","integer between 0 and 256",K.level);if(z1.object(K.tiff)&&z1.defined(K.tiff.subifd))if(z1.integer(K.tiff.subifd)&&z1.inRange(K.tiff.subifd,-1,1e5))z.tiffSubifd=K.tiff.subifd;else throw z1.invalidParameterError("tiff.subifd","integer between -1 and 100000",K.tiff.subifd);else if(z1.defined(K.subifd))if(z1.integer(K.subifd)&&z1.inRange(K.subifd,-1,1e5))z.tiffSubifd=K.subifd;else throw z1.invalidParameterError("subifd","integer between -1 and 100000",K.subifd);if(z1.object(K.svg)){if(z1.defined(K.svg.stylesheet))if(z1.string(K.svg.stylesheet))z.svgStylesheet=K.svg.stylesheet;else throw z1.invalidParameterError("svg.stylesheet","string",K.svg.stylesheet);if(z1.defined(K.svg.highBitdepth))if(z1.bool(K.svg.highBitdepth))z.svgHighBitdepth=K.svg.highBitdepth;else throw z1.invalidParameterError("svg.highBitdepth","boolean",K.svg.highBitdepth)}if(z1.object(K.pdf)&&z1.defined(K.pdf.background))z.pdfBackground=this._getBackgroundColourOption(K.pdf.background);else if(z1.defined(K.pdfBackground))z.pdfBackground=this._getBackgroundColourOption(K.pdfBackground);if(z1.object(K.jp2)&&z1.defined(K.jp2.oneshot))if(z1.bool(K.jp2.oneshot))z.jp2Oneshot=K.jp2.oneshot;else throw z1.invalidParameterError("jp2.oneshot","boolean",K.jp2.oneshot);if(z1.defined(K.create))if(z1.object(K.create)&&z1.integer(K.create.width)&&K.create.width>0&&z1.integer(K.create.height)&&K.create.height>0&&z1.integer(K.create.channels)){if(z.createWidth=K.create.width,z.createHeight=K.create.height,z.createChannels=K.create.channels,z.createPageHeight=0,z1.defined(K.create.pageHeight))if(z1.integer(K.create.pageHeight)&&K.create.pageHeight>0&&K.create.pageHeight<=K.create.height){if(K.create.height%K.create.pageHeight!==0)throw Error(`Expected create.height ${K.create.height} to be a multiple of create.pageHeight ${K.create.pageHeight}`);z.createPageHeight=K.create.pageHeight}else throw z1.invalidParameterError("create.pageHeight","positive integer",K.create.pageHeight);if(z1.defined(K.create.noise)){if(!z1.object(K.create.noise))throw Error("Expected noise to be an object");if(K.create.noise.type!=="gaussian")throw Error("Only gaussian noise is supported at the moment");if(z.createNoiseType=K.create.noise.type,!z1.inRange(K.create.channels,1,4))throw z1.invalidParameterError("create.channels","number between 1 and 4",K.create.channels);if(z.createNoiseMean=128,z1.defined(K.create.noise.mean))if(z1.number(K.create.noise.mean)&&z1.inRange(K.create.noise.mean,0,1e4))z.createNoiseMean=K.create.noise.mean;else throw z1.invalidParameterError("create.noise.mean","number between 0 and 10000",K.create.noise.mean);if(z.createNoiseSigma=30,z1.defined(K.create.noise.sigma))if(z1.number(K.create.noise.sigma)&&z1.inRange(K.create.noise.sigma,0,1e4))z.createNoiseSigma=K.create.noise.sigma;else throw z1.invalidParameterError("create.noise.sigma","number between 0 and 10000",K.create.noise.sigma)}else if(z1.defined(K.create.background)){if(!z1.inRange(K.create.channels,3,4))throw z1.invalidParameterError("create.channels","number between 3 and 4",K.create.channels);z.createBackground=this._getBackgroundColourOption(K.create.background)}else throw Error("Expected valid noise or background to create a new input image");delete z.buffer}else throw Error("Expected valid width, height and channels to create a new input image");if(z1.defined(K.text))if(z1.object(K.text)&&z1.string(K.text.text)){if(z.textValue=K.text.text,z1.defined(K.text.height)&&z1.defined(K.text.dpi))throw Error("Expected only one of dpi or height");if(z1.defined(K.text.font))if(z1.string(K.text.font))z.textFont=K.text.font;else throw z1.invalidParameterError("text.font","string",K.text.font);if(z1.defined(K.text.fontfile))if(z1.string(K.text.fontfile))z.textFontfile=K.text.fontfile;else throw z1.invalidParameterError("text.fontfile","string",K.text.fontfile);if(z1.defined(K.text.width))if(z1.integer(K.text.width)&&K.text.width>0)z.textWidth=K.text.width;else throw z1.invalidParameterError("text.width","positive integer",K.text.width);if(z1.defined(K.text.height))if(z1.integer(K.text.height)&&K.text.height>0)z.textHeight=K.text.height;else throw z1.invalidParameterError("text.height","positive integer",K.text.height);if(z1.defined(K.text.align))if(z1.string(K.text.align)&&z1.string(this.constructor.align[K.text.align]))z.textAlign=this.constructor.align[K.text.align];else throw z1.invalidParameterError("text.align","valid alignment",K.text.align);if(z1.defined(K.text.justify))if(z1.bool(K.text.justify))z.textJustify=K.text.justify;else throw z1.invalidParameterError("text.justify","boolean",K.text.justify);if(z1.defined(K.text.dpi))if(z1.integer(K.text.dpi)&&z1.inRange(K.text.dpi,1,1e6))z.textDpi=K.text.dpi;else throw z1.invalidParameterError("text.dpi","integer between 1 and 1000000",K.text.dpi);if(z1.defined(K.text.rgba))if(z1.bool(K.text.rgba))z.textRgba=K.text.rgba;else throw z1.invalidParameterError("text.rgba","bool",K.text.rgba);if(z1.defined(K.text.spacing))if(z1.integer(K.text.spacing)&&z1.inRange(K.text.spacing,-1e6,1e6))z.textSpacing=K.text.spacing;else throw z1.invalidParameterError("text.spacing","integer between -1000000 and 1000000",K.text.spacing);if(z1.defined(K.text.wrap))if(z1.string(K.text.wrap)&&z1.inArray(K.text.wrap,["word","char","word-char","none"]))z.textWrap=K.text.wrap;else throw z1.invalidParameterError("text.wrap","one of: word, char, word-char, none",K.text.wrap);delete z.buffer}else throw Error("Expected a valid string to create an image with text.");if(z1.defined(K.join))if(z1.defined(this.options.join)){if(z1.defined(K.join.animated))if(z1.bool(K.join.animated))z.joinAnimated=K.join.animated;else throw z1.invalidParameterError("join.animated","boolean",K.join.animated);if(z1.defined(K.join.across))if(z1.integer(K.join.across)&&z1.inRange(K.join.across,1,1e6))z.joinAcross=K.join.across;else throw z1.invalidParameterError("join.across","integer between 1 and 100000",K.join.across);if(z1.defined(K.join.shim))if(z1.integer(K.join.shim)&&z1.inRange(K.join.shim,0,1e6))z.joinShim=K.join.shim;else throw z1.invalidParameterError("join.shim","integer between 0 and 100000",K.join.shim);if(z1.defined(K.join.background))z.joinBackground=this._getBackgroundColourOption(K.join.background);if(z1.defined(K.join.halign))if(z1.string(K.join.halign)&&z1.string(this.constructor.align[K.join.halign]))z.joinHalign=this.constructor.align[K.join.halign];else throw z1.invalidParameterError("join.halign","valid alignment",K.join.halign);if(z1.defined(K.join.valign))if(z1.string(K.join.valign)&&z1.string(this.constructor.align[K.join.valign]))z.joinValign=this.constructor.align[K.join.valign];else throw z1.invalidParameterError("join.valign","valid alignment",K.join.valign)}else throw Error("Expected input to be an array of images to join")}else if(z1.defined(K))throw Error(`Invalid input options ${K}`);return z}function oi_(q,K,_){if(Array.isArray(this.options.input.buffer))if(z1.buffer(q)){if(this.options.input.buffer.length===0)this.on("finish",()=>{this.streamInFinished=!0});this.options.input.buffer.push(q),_()}else _(Error("Non-Buffer data on Writable Stream"));else _(Error("Unexpected data on Writable Stream"))}function ai_(){if(this._isStreamInput())this.options.input.buffer=Buffer.concat(this.options.input.buffer)}function si_(){return Array.isArray(this.options.input.buffer)}function ti_(q){let K=Error();if(z1.fn(q)){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),t76.metadata(this.options,(_,z)=>{if(_)q(z1.nativeError(_,K));else q(null,z)})});else t76.metadata(this.options,(_,z)=>{if(_)q(z1.nativeError(_,K));else q(null,z)});return this}else if(this._isStreamInput())return new Promise((_,z)=>{let Y=()=>{this._flattenBufferIn(),t76.metadata(this.options,($,A)=>{if($)z(z1.nativeError($,K));else _(A)})};if(this.writableFinished)Y();else this.once("finish",Y)});else return new Promise((_,z)=>{t76.metadata(this.options,(Y,$)=>{if(Y)z(z1.nativeError(Y,K));else _($)})})}function ei_(q){let K=Error();if(z1.fn(q)){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),t76.stats(this.options,(_,z)=>{if(_)q(z1.nativeError(_,K));else q(null,z)})});else t76.stats(this.options,(_,z)=>{if(_)q(z1.nativeError(_,K));else q(null,z)});return this}else if(this._isStreamInput())return new Promise((_,z)=>{this.on("finish",function(){this._flattenBufferIn(),t76.stats(this.options,(Y,$)=>{if(Y)z(z1.nativeError(Y,K));else _($)})})});else return new Promise((_,z)=>{t76.stats(this.options,(Y,$)=>{if(Y)z(z1.nativeError(Y,K));else _($)})})}YX4.exports=(q)=>{Object.assign(q.prototype,{_inputOptionsFromObject:zX4,_createInputDescriptor:ri_,_write:oi_,_flattenBufferIn:ai_,_isStreamInput:si_,metadata:ti_,stats:ei_}),q.align=ni_}});var JX4=m((V6O,HX4)=>{/*! |
| 1500 | Copyright 2013 Lovell Fuller and others. |
| 1501 | SPDX-License-Identifier: Apache-2.0 |
nothing calls this directly
no test coverage detected