import{isEmpty}from"../../base/helpers.mjs";import{FormView}from"../base.mjs";import{NumberInputView,CheckboxInputView,SelectInputView,MaskTypeInputView}from"../input.mjs";let defaultWidth=512,defaultHeight=512,defaultChunkingSize=64;if(!(isEmpty(window.enfugue)||isEmpty(window.enfugue.config)||isEmpty(window.enfugue.config.model)||isEmpty(window.enfugue.config.model.invocation))){let e=window.enfugue.config.model.invocation;isEmpty(e.width)||(defaultWidth=e.width),isEmpty(e.height)||(defaultHeight=e.height),isEmpty(e.chunkingSize)||(defaultChunkingSize=e.chunkingSize)}class CanvasFormView extends FormView{static className="canvas-form-view";static collapseFieldSets=!0;static autoSubmit=!0;static fieldSets={Dimensions:{width:{label:"Width",class:NumberInputView,config:{min:64,max:16384,value:defaultWidth,step:8,tooltip:"The width of the canvas in pixels."}},height:{label:"Height",class:NumberInputView,config:{min:64,max:16384,value:defaultHeight,step:8,tooltip:"The height of the canvas in pixels."}},useChunking:{label:"Use Chunking",class:CheckboxInputView,config:{tooltip:"When enabled, the engine will only ever process a square in the size of the configured model size at once. After each square, the frame will be moved by the configured amount of pixels along either the horizontal or vertical axis, and then the image is re-diffused. When this is disabled, the entire canvas will be diffused at once. This can have varying results, but a guaranteed result is increased VRAM use.",value:!1}},chunkingSize:{label:"Chunking Size",class:SelectInputView,config:{options:["8","16","32","64","128","256","512"],value:`${defaultChunkingSize}`,tooltip:"The number of pixels to move the frame when doing chunked diffusion. A low number can produce more detailed results, but can be noisy, and takes longer to process. A high number is faster to process, but can have poor results especially along frame boundaries. The recommended value is set by default."}},chunkingMaskType:{label:"Chunking Mask",class:MaskTypeInputView}}};async submit(){await super.submit(),this.values.useChunking?this.removeClass("no-chunking"):this.addClass("no-chunking")}}export{CanvasFormView};
