+
{const t=typeof e=="function"?Zm(e):e,n=(r,i)=>ay(t,r,i);return Object.assign(n,t),n},cy=e=>e?tc(e):tc;var mu=cy;const fy=(e,t={})=>(n,r,i)=>{const{enabled:o,anonymousActionType:l,...s}=t;let u;try{u=(o!=null?o:({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0}&&"production")!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!u)return({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0}&&"production")!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(n,r,i);const a=u.connect(s);let c=!0;i.setState=(m,y,S)=>{const C=n(m,y);return c&&a.send(S===void 0?{type:l||"anonymous"}:typeof S=="string"?{type:S}:S,r()),C};const f=(...m)=>{const y=c;c=!1,n(...m),c=y},d=e(i.setState,r,i);if(a.init(d),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let m=!1;const y=i.dispatch;i.dispatch=(...S)=>{({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0}&&"production")!=="production"&&S[0].type==="__setState"&&!m&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),m=!0),y(...S)}}return a.subscribe(m=>{var y;switch(m.type){case"ACTION":if(typeof m.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return el(m.payload,S=>{if(S.type==="__setState"){f(S.state);return}!i.dispatchFromDevtools||typeof i.dispatch=="function"&&i.dispatch(S)});case"DISPATCH":switch(m.payload.type){case"RESET":return f(d),a.init(i.getState());case"COMMIT":return a.init(i.getState());case"ROLLBACK":return el(m.state,S=>{f(S),a.init(i.getState())});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return el(m.state,S=>{f(S)});case"IMPORT_STATE":{const{nextLiftedState:S}=m.payload,C=(y=S.computedStates.slice(-1)[0])==null?void 0:y.state;if(!C)return;f(C),a.send(null,S);return}case"PAUSE_RECORDING":return c=!c}return}}),d},dy=fy,el=(e,t)=>{let n;try{n=JSON.parse(e)}catch(r){console.error("[zustand devtools middleware] Could not parse the received json",r)}n!==void 0&&t(n)},Xi=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return Xi(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return Xi(r)(n)}}}},hy=(e,t)=>(n,r,i)=>{let o={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:C=>C,version:0,merge:(C,v)=>({...v,...C}),...t},l=!1;const s=new Set,u=new Set;let a;try{a=o.getStorage()}catch{}if(!a)return e((...C)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...C)},r,i);const c=Xi(o.serialize),f=()=>{const C=o.partialize({...r()});let v;const p=c({state:C,version:o.version}).then(h=>a.setItem(o.name,h)).catch(h=>{v=h});if(v)throw v;return p},d=i.setState;i.setState=(C,v)=>{d(C,v),f()};const m=e((...C)=>{n(...C),f()},r,i);let y;const S=()=>{var C;if(!a)return;l=!1,s.forEach(p=>p(r()));const v=((C=o.onRehydrateStorage)==null?void 0:C.call(o,r()))||void 0;return Xi(a.getItem.bind(a))(o.name).then(p=>{if(p)return o.deserialize(p)}).then(p=>{if(p)if(typeof p.version=="number"&&p.version!==o.version){if(o.migrate)return o.migrate(p.state,p.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return p.state}).then(p=>{var h;return y=o.merge(p,(h=r())!=null?h:m),n(y,!0),f()}).then(()=>{v==null||v(y,void 0),l=!0,u.forEach(p=>p(y))}).catch(p=>{v==null||v(void 0,p)})};return i.persist={setOptions:C=>{o={...o,...C},C.getStorage&&(a=C.getStorage())},clearStorage:()=>{a==null||a.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>S(),hasHydrated:()=>l,onHydrate:C=>(s.add(C),()=>{s.delete(C)}),onFinishHydration:C=>(u.add(C),()=>{u.delete(C)})},S(),y||m},py=hy;function Nr(){return Math.floor(Math.random()*1e4)}const D=mu(dy((e,t)=>({parallelCount:1,requestOptions:{prompt:"a photograph of an astronaut riding a horse",seed:Nr(),num_outputs:1,num_inference_steps:50,guidance_scale:7.5,width:512,height:512,prompt_strength:.8,turbo:!0,use_cpu:!1,use_full_precision:!0,save_to_disk_path:"null",use_face_correction:"GFPGANv1.3",use_upscale:"RealESRGAN_x4plus",show_only_filtered_image:!0},tags:[],uiOptions:{isUseRandomSeed:!0,isUseAutoSave:!1,isSoundEnabled:!1},allModifiers:[[[]]],isInpainting:!1,setParallelCount:n=>e(se(r=>{r.parallelCount=n})),setRequestOptions:(n,r)=>{e(se(i=>{i.requestOptions[n]=r}))},getValueForRequestKey:n=>t().requestOptions[n],setAllModifiers:n=>{e(se(r=>{r.allModifiers=n}))},toggleTag:n=>{e(se(r=>{const i=r.tags.indexOf(n);i>-1?r.tags.splice(i,1):r.tags.push(n)}))},hasTag:n=>t().tags.indexOf(n)>-1,selectedTags:()=>t().tags,builtRequest:()=>{const n=t(),r=n.requestOptions,i=n.tags,o=`${r.prompt} ${i.join(",")}`,l={...r,prompt:o};return n.uiOptions.isUseAutoSave||(l.save_to_disk_path=null),l.init_image===void 0&&(l.prompt_strength=void 0),l.use_upscale===""&&(l.use_upscale=null),l.use_upscale===null&&l.use_face_correction===null&&(l.show_only_filtered_image=!1),l},toggleUseFaceCorrection:()=>{e(se(n=>{const r=typeof n.getValueForRequestKey("use_face_correction")=="string"?null:"GFPGANv1.3";n.requestOptions.use_face_correction=r}))},isUsingFaceCorrection:()=>typeof t().getValueForRequestKey("use_face_correction")=="string",isUsingUpscaling:()=>t().getValueForRequestKey("use_upscale")!="",toggleUseRandomSeed:()=>{e(se(n=>{n.uiOptions.isUseRandomSeed=!n.uiOptions.isUseRandomSeed,n.requestOptions.seed=n.uiOptions.isUseRandomSeed?Nr():n.requestOptions.seed,localStorage.setItem("ui:isUseRandomSeed",n.uiOptions.isUseRandomSeed)}))},isRandomSeed:()=>t().uiOptions.isUseRandomSeed,toggleUseAutoSave:()=>{e(se(n=>{n.uiOptions.isUseAutoSave=!n.uiOptions.isUseAutoSave,localStorage.setItem("ui:isUseAutoSave",n.uiOptions.isUseAutoSave)}))},isUseAutoSave:()=>t().uiOptions.isUseAutoSave,toggleSoundEnabled:()=>{e(se(n=>{n.uiOptions.isSoundEnabled=!n.uiOptions.isSoundEnabled}))},isSoundEnabled:()=>t().uiOptions.isSoundEnabled,toggleInpainting:()=>{e(se(n=>{n.isInpainting=!n.isInpainting}))}})));var nc="_1jo75h1",rc="_1jo75h0",vy="_1jo75h2";const ic="Stable Diffusion is starting...",my="Stable Diffusion is ready to use!",oc="Stable Diffusion is not running!";function yy({className:e}){const[t,n]=R.exports.useState(ic),[r,i]=R.exports.useState(rc),{status:o,data:l}=Zt(["health"],Hm,{refetchInterval:Vm});return R.exports.useEffect(()=>{o==="loading"?(n(ic),i(rc)):o==="error"?(n(oc),i(nc)):o==="success"&&(l[0]==="OK"?(n(my),i(vy)):(n(oc),i(nc)))},[o,l]),w(tn,{children:w("p",{className:[r,e].join(" "),children:t})})}var gy="_1v2cc580";function Sy(){const{status:e,data:t}=Zt([ss],Yd),[n,r]=R.exports.useState("2.1.0"),[i,o]=R.exports.useState("");return R.exports.useEffect(()=>{if(e==="success"){const{update_branch:l}=t;r("v2.1"),o(l==="main"?"(stable)":"(beta)")}},[e,t,r,r]),O("div",{className:gy,children:[O("h1",{children:["Stable Diffusion UI ",n," ",i," "]}),w(yy,{className:"status-display"})]})}const je=mu(py((e,t)=>({isOpenAdvancedSettings:!1,isOpenAdvImprovementSettings:!1,isOpenAdvPropertySettings:!1,isOpenAdvWorkflowSettings:!1,isOpenAdvGPUSettings:!1,isOpenImageModifier:!1,imageMofidiersMap:{},toggleAdvancedSettings:()=>{e(se(n=>{n.isOpenAdvancedSettings=!n.isOpenAdvancedSettings}))},toggleAdvImprovementSettings:()=>{e(se(n=>{n.isOpenAdvImprovementSettings=!n.isOpenAdvImprovementSettings}))},toggleAdvPropertySettings:()=>{e(se(n=>{n.isOpenAdvPropertySettings=!n.isOpenAdvPropertySettings}))},toggleAdvWorkflowSettings:()=>{e(se(n=>{n.isOpenAdvWorkflowSettings=!n.isOpenAdvWorkflowSettings}))},toggleAdvGPUSettings:()=>{e(se(n=>{n.isOpenAdvGPUSettings=!n.isOpenAdvGPUSettings}))},toggleImageModifier:()=>{e(se(n=>{n.isOpenImageModifier=!n.isOpenImageModifier}))}}),{name:"createUI"}));var Kn="_11d5x3d1",wy="_11d5x3d0",So="_11d5x3d2";function _y(){const e=D(c=>c.isUsingFaceCorrection()),t=D(c=>c.isUsingUpscaling()),n=D(c=>c.getValueForRequestKey("use_upscale")),r=D(c=>c.getValueForRequestKey("show_only_filtered_image")),i=D(c=>c.toggleUseFaceCorrection),o=D(c=>c.setRequestOptions),l=je(c=>c.isOpenAdvImprovementSettings),s=je(c=>c.toggleAdvImprovementSettings),[u,a]=R.exports.useState(!1);return R.exports.useEffect(()=>{console.log("isUsingUpscaling",t),console.log("isUsingFaceCorrection",e),a(!(e||n))},[e,t,a]),O("div",{children:[w("button",{type:"button",className:So,onClick:s,children:w("h4",{children:"Improvement Settings"})}),l&&O(tn,{children:[w("div",{children:O("label",{children:[w("input",{type:"checkbox",checked:e,onChange:c=>i()}),"Fix incorrect faces and eyes (uses GFPGAN)"]})}),w("div",{children:O("label",{children:["Upscale the image to 4x resolution using",O("select",{id:"upscale_model",name:"upscale_model",value:n,onChange:c=>{o("use_upscale",c.target.value)},children:[w("option",{value:"",children:"No Uscaling"}),w("option",{value:"RealESRGAN_x4plus",children:"RealESRGAN_x4plus"}),w("option",{value:"RealESRGAN_x4plus_anime_6B",children:"RealESRGAN_x4plus_anime_6B"})]})]})}),w("div",{children:O("label",{children:[w("input",{disabled:u,type:"checkbox",checked:r,onChange:c=>o("show_only_filtered_image",c.target.checked)}),"Show only filtered image"]})})]})]})}const lc=[{value:128,label:"128 (*)"},{value:192,label:"192"},{value:256,label:"256 (*)"},{value:320,label:"320"},{value:384,label:"384"},{value:448,label:"448"},{value:512,label:"512 (*)"},{value:576,label:"576"},{value:640,label:"640"},{value:704,label:"704"},{value:768,label:"768 (*)"},{value:832,label:"832"},{value:896,label:"896"},{value:960,label:"960"},{value:1024,label:"1024 (*)"}];function ky(){const e=D(d=>d.setRequestOptions),t=D(d=>d.toggleUseRandomSeed),n=D(d=>d.isRandomSeed()),r=D(d=>d.getValueForRequestKey("seed")),i=D(d=>d.getValueForRequestKey("num_inference_steps")),o=D(d=>d.getValueForRequestKey("guidance_scale")),l=D(d=>d.getValueForRequestKey("init_image")),s=D(d=>d.getValueForRequestKey("prompt_strength")),u=D(d=>d.getValueForRequestKey("width")),a=D(d=>d.getValueForRequestKey("height")),c=je(d=>d.isOpenAdvPropertySettings),f=je(d=>d.toggleAdvPropertySettings);return O("div",{children:[w("button",{type:"button",className:So,onClick:f,children:w("h4",{children:"Property Settings"})}),c&&O(tn,{children:[O("div",{children:[O("label",{children:["Seed:",w("input",{size:10,value:r,onChange:d=>e("seed",d.target.value),disabled:n,placeholder:"random"})]}),O("label",{children:[w("input",{type:"checkbox",checked:n,onChange:d=>t()})," ","Random Image"]})]}),w("div",{children:O("label",{children:["Number of inference steps:"," ",w("input",{value:i,onChange:d=>{e("num_inference_steps",d.target.value)},size:4})]})}),O("div",{children:[O("label",{children:["Guidance Scale:",w("input",{value:o,onChange:d=>e("guidance_scale",d.target.value),type:"range",min:"0",max:"20",step:".1"})]}),w("span",{children:o})]}),l&&O("div",{children:[O("label",{children:["Prompt Strength:"," ",w("input",{value:s,onChange:d=>e("prompt_strength",d.target.value),type:"range",min:"0",max:"1",step:".05"})]}),w("span",{children:s})]}),w("div",{children:O("label",{children:["Width:",w("select",{value:u,onChange:d=>e("width",d.target.value),children:lc.map(d=>w("option",{value:d.value,children:d.label},"width-option_"+d.value))})]})}),w("div",{children:O("label",{children:["Height:",w("select",{value:a,onChange:d=>e("height",d.target.value),children:lc.map(d=>w("option",{value:d.value,children:d.label},"height-option_"+d.value))})]})})]})]})}function Cy(){const e=D(f=>f.getValueForRequestKey("num_outputs")),t=D(f=>f.parallelCount),n=D(f=>f.isUseAutoSave()),r=D(f=>f.getValueForRequestKey("save_to_disk_path")),i=D(f=>f.isSoundEnabled()),o=D(f=>f.setRequestOptions),l=D(f=>f.setParallelCount),s=D(f=>f.toggleUseAutoSave),u=D(f=>f.toggleSoundEnabled),a=je(f=>f.isOpenAdvWorkflowSettings),c=je(f=>f.toggleAdvWorkflowSettings);return O("div",{children:[w("button",{type:"button",className:So,onClick:c,children:w("h4",{children:"Workflow Settings"})}),a&&O(tn,{children:[w("div",{children:O("label",{children:["Number of images to make:"," ",w("input",{type:"number",value:e,onChange:f=>o("num_outputs",parseInt(f.target.value,10)),size:4})]})}),w("div",{children:O("label",{children:["Generate in parallel:",w("input",{type:"number",value:t,onChange:f=>l(parseInt(f.target.value,10)),size:4})]})}),O("div",{children:[O("label",{children:[w("input",{checked:n,onChange:f=>s(),type:"checkbox"}),"Automatically save to"," "]}),O("label",{children:[w("input",{value:r,onChange:f=>o("save_to_disk_path",f.target.value),size:40,disabled:!n}),w("span",{className:"visually-hidden",children:"Path on disk where images will be saved"})]})]}),w("div",{children:O("label",{children:[w("input",{checked:i,onChange:f=>u(),type:"checkbox"}),"Play sound on task completion"]})})]})]})}function Ey(){const e=D(l=>l.getValueForRequestKey("turbo")),t=D(l=>l.getValueForRequestKey("use_cpu")),n=D(l=>l.getValueForRequestKey("use_full_precision")),r=D(l=>l.setRequestOptions),i=je(l=>l.isOpenAdvGPUSettings),o=je(l=>l.toggleAdvGPUSettings);return O("div",{children:[w("button",{type:"button",className:So,onClick:o,children:w("h4",{children:"GPU Settings"})}),i&&O(tn,{children:[w("div",{children:O("label",{children:[w("input",{checked:e,onChange:l=>r("turbo",l.target.checked),type:"checkbox"}),"Turbo mode (generates images faster, but uses an additional 1 GB of GPU memory)"]})}),w("div",{children:O("label",{children:[w("input",{type:"checkbox",checked:t,onChange:l=>r("use_cpu",l.target.checked)}),"Use CPU instead of GPU (warning: this will be *very* slow)"]})}),w("div",{children:O("label",{children:[w("input",{checked:n,onChange:l=>r("use_full_precision",l.target.checked),type:"checkbox"}),"Use full precision (for GPU-only. warning: this will consume more VRAM)"]})})]})]})}function xy(){const[e,t]=R.exports.useState(!1),[n,r]=R.exports.useState("beta"),{status:i,data:o}=Zt([ss],Yd),l=lu(),{status:s,data:u}=Zt([Gm],()=>Ym(n),{enabled:e});return R.exports.useEffect(()=>{if(i==="success"){const{update_branch:a}=o;r(a==="main"?"beta":"main")}},[i,o]),R.exports.useEffect(()=>{s==="success"&&(u[0]=="OK"&&l.invalidateQueries([ss]),t(!1))},[s,u,t]),O("label",{children:[w("input",{disabled:!0,type:"checkbox",checked:n==="main",onChange:a=>{t(!0)}}),"Enable Beta Mode"]})}function Py(){return O("ul",{className:wy,children:[w("li",{className:Kn,children:w(_y,{})}),w("li",{className:Kn,children:w(ky,{})}),w("li",{className:Kn,children:w(Cy,{})}),w("li",{className:Kn,children:w(Ey,{})}),w("li",{className:Kn,children:w(xy,{})})]})}function Oy(){const e=je(n=>n.isOpenAdvancedSettings),t=je(n=>n.toggleAdvancedSettings);return O("div",{className:"panel-box",children:[w("button",{type:"button",onClick:t,className:"panel-box-toggle-btn",children:w("h3",{children:"Advanced Settings"})}),e&&w(Py,{})]})}function Zd({name:e}){const t=D(i=>i.hasTag(e))?"selected":"",n=D(i=>i.toggleTag),r=()=>{n(e)};return w("div",{className:"modifierTag "+t,onClick:r,children:w("p",{children:e})})}function Ry({tags:e}){return w("ul",{className:"modifier-list",children:e.map(t=>w("li",{children:w(Zd,{name:t})},t))})}function Ny({title:e,tags:t}){const[n,r]=R.exports.useState(!1);return O("div",{className:"modifier-grouping",children:[w("div",{className:"modifier-grouping-header",onClick:()=>{r(!n)},children:w("h5",{children:e})}),n&&w(Ry,{tags:t})]})}function Iy(){const e=D(i=>i.allModifiers);console.log("allModifiers",e);const t=je(i=>i.isOpenImageModifier),n=je(i=>i.toggleImageModifier);return O("div",{className:"panel-box",children:[w("button",{type:"button",onClick:()=>{n()},className:"panel-box-toggle-btn",children:w("h4",{children:"Image Modifiers (art styles, tags, ect)"})}),t&&e.map((i,o)=>w(Ny,{title:i[0],tags:i[1]},i[0]))]})}var My="fma0ug0";function Ty({imageData:e,brushSize:t,brushShape:n,brushColor:r,isErasing:i}){const o=R.exports.useRef(null),l=R.exports.useRef(null),[s,u]=R.exports.useState(!1),[a,c]=R.exports.useState(512),[f,d]=R.exports.useState(512);R.exports.useEffect(()=>{const p=new Image;p.onload=()=>{c(p.width),d(p.height)},p.src=e},[e]),R.exports.useEffect(()=>{if(o.current){const p=o.current.getContext("2d"),h=p.getImageData(0,0,a,f),g=h.data;for(let x=0;x0&&(g[x]=parseInt(r,16),g[x+1]=parseInt(r,16),g[x+2]=parseInt(r,16));p.putImageData(h,0,0)}},[r]);const m=p=>{u(!0)},y=p=>{u(!1);const h=o.current;h&&h.toDataURL()},S=(p,h,g,x,E)=>{const k=o.current;if(k){const _=k.getContext("2d");if(i){const M=g/2;_.clearRect(p-M,h-M,g,g)}else _.beginPath(),_.lineWidth=g,_.lineCap=x,_.strokeStyle=E,_.moveTo(p,h),_.lineTo(p,h),_.stroke()}},C=(p,h,g,x,E)=>{const k=l.current;if(k){const _=k.getContext("2d");if(_.beginPath(),_.clearRect(0,0,k.width,k.height),i){const M=g/2;_.lineWidth=2,_.lineCap="butt",_.strokeStyle=E,_.moveTo(p-M,h-M),_.lineTo(p+M,h-M),_.lineTo(p+M,h+M),_.lineTo(p-M,h+M),_.lineTo(p-M,h-M),_.stroke()}else _.lineWidth=g,_.lineCap=x,_.strokeStyle=E,_.moveTo(p,h),_.lineTo(p,h),_.stroke()}};return O("div",{className:My,children:[w("img",{src:e}),w("canvas",{ref:o,width:a,height:f}),w("canvas",{ref:l,width:a,height:f,onMouseDown:m,onMouseUp:y,onMouseMove:p=>{const{nativeEvent:{offsetX:h,offsetY:g}}=p;C(h,g,t,n,r),s&&S(h,g,t,n,r)}})]})}var sc="_2yyo4x2",Dy="_2yyo4x1",Fy="_2yyo4x0";function Ly(){const e=R.exports.useRef(null),[t,n]=R.exports.useState("20"),[r,i]=R.exports.useState("round"),[o,l]=R.exports.useState("#fff"),[s,u]=R.exports.useState(!1),a=D(S=>S.getValueForRequestKey("init_image"));return O("div",{className:Fy,children:[w(Ty,{imageData:a,brushSize:t,brushShape:r,brushColor:o,isErasing:s}),O("div",{className:Dy,children:[O("div",{className:sc,children:[w("button",{onClick:()=>{u(!1)},children:"Mask"}),w("button",{onClick:()=>{u(!0)},children:"Erase"}),w("button",{disabled:!0,onClick:()=>{console.log("fill mask!!",e)},children:"Fill"}),w("button",{disabled:!0,onClick:()=>{console.log("clear all")},children:"Clear"}),O("label",{children:["Brush Size",w("input",{type:"range",min:"1",max:"100",value:t,onChange:S=>{n(S.target.value)}})]})]}),O("div",{className:sc,children:[w("button",{onClick:()=>{i("round")},children:"Cirle Brush"}),w("button",{onClick:()=>{i("square")},children:"Square Brush"}),w("button",{onClick:()=>{l("#000")},children:"Dark Brush"}),w("button",{onClick:()=>{l("#fff")},children:"Light Brush"})]})]})]})}var Ay="cjcdm20",Uy="cjcdm21";var zy="_1how28i0",jy="_1how28i1";var $y="_1rn4m8a4",Qy="_1rn4m8a2",By="_1rn4m8a3",qy="_1rn4m8a0",Vy="_1rn4m8a1",Hy="_1rn4m8a5";function Ky(e){const t=R.exports.useRef(null),n=D(a=>a.getValueForRequestKey("init_image")),r=D(a=>a.isInpainting),i=D(a=>a.setRequestOptions),o=()=>{var a;(a=t.current)==null||a.click()},l=a=>{const c=a.target.files[0];if(c){const f=new FileReader;f.onload=d=>{d.target&&i("init_image",d.target.result)},f.readAsDataURL(c)}},s=D(a=>a.toggleInpainting);return O("div",{className:qy,children:[O("div",{children:[O("label",{className:Vy,children:[w("b",{children:"Initial Image:"})," (optional)"]}),w("input",{ref:t,className:Qy,name:"init_image",type:"file",onChange:l}),w("button",{className:By,onClick:o,children:"Select File"})]}),w("div",{className:$y,children:n&&O(tn,{children:[O("div",{children:[w("img",{src:n,width:"100",height:"100"}),w("button",{className:Hy,onClick:()=>{i("init_image",void 0),r&&s()},children:"X"})]}),O("label",{children:[w("input",{type:"checkbox",onChange:a=>{s()},checked:r}),"Use for Inpainting"]})]})})]})}function Wy(){const e=D(t=>t.selectedTags());return O("div",{className:"selected-tags",children:[w("p",{children:"Active Tags"}),w("ul",{children:e.map(t=>w("li",{children:w(Zd,{name:t})},t))})]})}const sr=mu((e,t)=>({images:new Array,completedImageIds:new Array,addNewImage:(n,r,i=!1)=>{e(se(o=>{let{seed:l}=r;i&&(l=Nr()),o.images.push({id:n,options:{...r,seed:l}})}))},hasQueuedImages:()=>t().images.length>0,firstInQueue:()=>t().images[0]||[],removeFirstInQueue:()=>{e(se(n=>{const r=n.images.shift();n.completedImageIds.push(r.id)}))}}));let ni;const Gy=new Uint8Array(16);function Yy(){if(!ni&&(ni=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ni))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ni(Gy)}const oe=[];for(let e=0;e<256;++e)oe.push((e+256).toString(16).slice(1));function Xy(e,t=0){return(oe[e[t+0]]+oe[e[t+1]]+oe[e[t+2]]+oe[e[t+3]]+"-"+oe[e[t+4]]+oe[e[t+5]]+"-"+oe[e[t+6]]+oe[e[t+7]]+"-"+oe[e[t+8]]+oe[e[t+9]]+"-"+oe[e[t+10]]+oe[e[t+11]]+oe[e[t+12]]+oe[e[t+13]]+oe[e[t+14]]+oe[e[t+15]]).toLowerCase()}const Jy=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),uc={randomUUID:Jy};function Zy(e,t,n){if(uc.randomUUID&&!t&&!e)return uc.randomUUID();e=e||{};const r=e.random||(e.rng||Yy)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n=n||0;for(let i=0;i<16;++i)t[n+i]=r[i];return t}return Xy(r)}var by="_1hnlbmt0";function eg(){const e=D(s=>s.parallelCount),t=D(s=>s.builtRequest),n=sr(s=>s.addNewImage),r=sr(s=>s.hasQueuedImages()),i=D(s=>s.isRandomSeed()),o=D(s=>s.setRequestOptions);return w("button",{className:by,onClick:()=>{const s=t();let u=[],{num_outputs:a}=s;if(e>a)u.push(a);else for(;a>=1;)a-=e,a<=0?u.push(e):u.push(Math.abs(a));u.forEach((c,f)=>{let d=s.seed;f!==0&&(d=Nr()),n(Zy(),{...s,num_outputs:c,seed:d})}),i&&o("seed",Nr())},disabled:r,children:"Make"})}function tg(){const e=D(r=>r.getValueForRequestKey("prompt")),t=D(r=>r.setRequestOptions);return O("div",{className:zy,children:[O("div",{className:jy,children:[w("p",{children:"Prompt "}),w("textarea",{value:e,onChange:r=>{t("prompt",r.target.value)}})]}),w(Ky,{}),w(Wy,{}),w(eg,{})]})}function ng(){const e=D(t=>t.isInpainting);return O(tn,{children:[O("div",{className:Ay,children:[w(tg,{}),w(Oy,{}),w(Iy,{})]}),e&&w("div",{className:Uy,children:w(Ly,{})})]})}const rg=`${Lt}/ding.mp3`,ig=yc.forwardRef((e,t)=>w("audio",{ref:t,style:{display:"none"},children:w("source",{src:rg,type:"audio/mp3"})}));var og="_1yvg52n0",lg="_1yvg52n1";function sg({imageData:e,metadata:t,className:n}){return w("div",{className:[og,n].join(" "),children:w("img",{className:lg,src:e,alt:t.prompt})})}function ug({image:e}){const{info:t,data:n}=e||{info:null,data:null},r=D(s=>s.setRequestOptions),i=()=>{const{prompt:s,seed:u,num_inference_steps:a,guidance_scale:c,use_face_correction:f,use_upscale:d,width:m,height:y}=t;let S=s.replace(/[^a-zA-Z0-9]/g,"_");S=S.substring(0,100);let C=`${S}_Seed-${u}_Steps-${a}_Guidance-${c}`;return f&&(C+=`_FaceCorrection-${f}`),d&&(C+=`_Upscale-${d}`),C+=`_${m}x${y}`,C+=".png",C},o=()=>{const s=document.createElement("a");s.download=i(),s.href=n,s.click()},l=()=>{r("init_image",n)};return O("div",{className:"current-display",children:[e&&O("div",{children:[O("p",{children:[" ",t.prompt]}),w(sg,{imageData:n,metadata:t}),O("div",{children:[w("button",{onClick:o,children:"Save"}),w("button",{onClick:l,children:"Use as Input"})]})]}),w("div",{})]})}var ag="fsj92y0",cg="fsj92y1";function fg({images:e,setCurrentDisplay:t}){const n=r=>{const i=e[r];t(i)};return w("div",{className:ag,children:e&&e.map((r,i)=>w("button",{className:cg,onClick:()=>{n(i)},children:w("img",{src:r.data,alt:r.info.prompt})},i))})}var dg="_688lcr1",hg="_688lcr0",pg="_688lcr2";function vg(){const e=R.exports.useRef(null),t=D(m=>m.isSoundEnabled()),{id:n,options:r}=sr(m=>m.firstInQueue()),i=sr(m=>m.removeFirstInQueue),[o,l]=R.exports.useState(null),{status:s,data:u}=Zt([ba,n],()=>Xm(r),{enabled:n!==void 0});R.exports.useEffect(()=>{var m;s==="success"&&u.status==="succeeded"&&(t&&((m=e.current)==null||m.play()),i())},[s,u,i,e,t]);const a=lu(),[c,f]=R.exports.useState([]),d=sr(m=>m.completedImageIds);return R.exports.useEffect(()=>{const m=d.map(y=>a.getQueryData([ba,y]));if(m.length>0){const y=m.map((S,C)=>{if(S!==void 0)return S.output.map(v=>({id:`${d[C]}-${v.seed}`,data:v.data,info:{...S.request,seed:v.seed}}))}).flat().reverse();f(y),l(y[0]||null)}else f([]),l(null)},[f,l,a,d]),O("div",{className:hg,children:[w(ig,{ref:e}),w("div",{className:dg,children:w(ug,{image:o})}),w("div",{className:pg,children:w(fg,{images:c,setCurrentDisplay:l})})]})}function mg(){return O("div",{id:"footer",className:"panel-box",children:[O("p",{children:["If you found this project useful and want to help keep it alive, please"," ",w("a",{href:"https://ko-fi.com/cmdr2_stablediffusion_ui",target:"_blank",children:w("img",{src:`${Lt}/kofi.png`,id:"coffeeButton"})})," ","to help cover the cost of development and maintenance! Thank you for your support!"]}),O("p",{children:["Please feel free to join the"," ",w("a",{href:"https://discord.com/invite/u9yhsFmEkB",target:"_blank",children:"discord community"})," ","or"," ",w("a",{href:"https://github.com/cmdr2/stable-diffusion-ui/issues",target:"_blank",children:"file an issue"})," ","if you have any problems or suggestions in using this interface."]}),O("div",{id:"footer-legal",children:[O("p",{children:[w("b",{children:"Disclaimer:"})," The authors of this project are not responsible for any content generated using this interface."]}),O("p",{children:["This license of this software forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, ",w("br",{}),"spread misinformation and target vulnerable groups. For the full list of restrictions please read"," ",w("a",{href:"https://github.com/cmdr2/stable-diffusion-ui/blob/main/LICENSE",target:"_blank",children:"the license"}),"."]}),w("p",{children:"By using this software, you consent to the terms and conditions of the license."})]})]})}function yg({className:e}){const t=D(s=>s.setRequestOptions),{status:n,data:r}=Zt(["SaveDir"],Wm),{status:i,data:o}=Zt(["modifications"],Km),l=D(s=>s.setAllModifiers);return R.exports.useEffect(()=>{n==="success"&&t("save_to_disk_path",r)},[t,n,r]),R.exports.useEffect(()=>{i==="success"?l(o):i==="error"&&l(Jm)},[t,i,o]),O("div",{className:[jm,e].join(" "),children:[w("header",{className:qm,children:w(Sy,{})}),w("nav",{className:$m,children:w(ng,{})}),w("main",{className:Qm,children:w(vg,{})}),w("footer",{className:Bm,children:w(mg,{})})]})}function gg({className:e}){return w("div",{children:w("h1",{children:"Settings"})})}var Sg="_4vfmtj1t";const wg=new Cm;function _g(){const e=Sg;return w(Em,{location:wg,routes:[{path:"/",element:w(yg,{className:e})},{path:"/settings",element:w(gg,{className:e})}]})}const kg=new Hv({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1,staleTime:1/0}}});um();tl.createRoot(document.getElementById("root")).render(w(yc.StrictMode,{children:O(Gv,{client:kg,children:[w(_g,{}),w(tm,{initialIsOpen:!0})]})}));
+ */var go=R.exports,bm=nu.exports;function ey(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var ty=typeof Object.is=="function"?Object.is:ey,ny=bm.useSyncExternalStore,ry=go.useRef,iy=go.useEffect,oy=go.useMemo,ly=go.useDebugValue;Jd.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var o=ry(null);if(o.current===null){var l={hasValue:!1,value:null};o.current=l}else l=o.current;o=oy(function(){function u(m){if(!a){if(a=!0,c=m,m=r(m),i!==void 0&&l.hasValue){var y=l.value;if(i(y,m))return f=y}return f=m}if(y=f,ty(c,m))return y;var S=r(m);return i!==void 0&&i(y,S)?y:(c=m,f=S)}var a=!1,c,f,d=n===void 0?null:n;return[function(){return u(t())},d===null?void 0:function(){return u(d())}]},[t,n,r,i]);var s=ny(e,o[0],o[1]);return iy(function(){l.hasValue=!0,l.value=s},[s]),ly(s),s};(function(e){e.exports=Jd})(Xd);const sy=ac(Xd.exports),{useSyncExternalStoreWithSelector:uy}=sy;function ay(e,t=e.getState,n){const r=uy(e.subscribe,e.getState,e.getServerState||e.getState,t,n);return R.exports.useDebugValue(r),r}const tc=e=>{const t=typeof e=="function"?Zm(e):e,n=(r,i)=>ay(t,r,i);return Object.assign(n,t),n},cy=e=>e?tc(e):tc;var mu=cy;const fy=(e,t={})=>(n,r,i)=>{const{enabled:o,anonymousActionType:l,...s}=t;let u;try{u=(o!=null?o:({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0}&&"production")!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!u)return({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0}&&"production")!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(n,r,i);const a=u.connect(s);let c=!0;i.setState=(m,y,S)=>{const C=n(m,y);return c&&a.send(S===void 0?{type:l||"anonymous"}:typeof S=="string"?{type:S}:S,r()),C};const f=(...m)=>{const y=c;c=!1,n(...m),c=y},d=e(i.setState,r,i);if(a.init(d),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let m=!1;const y=i.dispatch;i.dispatch=(...S)=>{({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0}&&"production")!=="production"&&S[0].type==="__setState"&&!m&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),m=!0),y(...S)}}return a.subscribe(m=>{var y;switch(m.type){case"ACTION":if(typeof m.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return el(m.payload,S=>{if(S.type==="__setState"){f(S.state);return}!i.dispatchFromDevtools||typeof i.dispatch=="function"&&i.dispatch(S)});case"DISPATCH":switch(m.payload.type){case"RESET":return f(d),a.init(i.getState());case"COMMIT":return a.init(i.getState());case"ROLLBACK":return el(m.state,S=>{f(S),a.init(i.getState())});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return el(m.state,S=>{f(S)});case"IMPORT_STATE":{const{nextLiftedState:S}=m.payload,C=(y=S.computedStates.slice(-1)[0])==null?void 0:y.state;if(!C)return;f(C),a.send(null,S);return}case"PAUSE_RECORDING":return c=!c}return}}),d},dy=fy,el=(e,t)=>{let n;try{n=JSON.parse(e)}catch(r){console.error("[zustand devtools middleware] Could not parse the received json",r)}n!==void 0&&t(n)},Xi=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return Xi(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return Xi(r)(n)}}}},hy=(e,t)=>(n,r,i)=>{let o={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:C=>C,version:0,merge:(C,v)=>({...v,...C}),...t},l=!1;const s=new Set,u=new Set;let a;try{a=o.getStorage()}catch{}if(!a)return e((...C)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...C)},r,i);const c=Xi(o.serialize),f=()=>{const C=o.partialize({...r()});let v;const p=c({state:C,version:o.version}).then(h=>a.setItem(o.name,h)).catch(h=>{v=h});if(v)throw v;return p},d=i.setState;i.setState=(C,v)=>{d(C,v),f()};const m=e((...C)=>{n(...C),f()},r,i);let y;const S=()=>{var C;if(!a)return;l=!1,s.forEach(p=>p(r()));const v=((C=o.onRehydrateStorage)==null?void 0:C.call(o,r()))||void 0;return Xi(a.getItem.bind(a))(o.name).then(p=>{if(p)return o.deserialize(p)}).then(p=>{if(p)if(typeof p.version=="number"&&p.version!==o.version){if(o.migrate)return o.migrate(p.state,p.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return p.state}).then(p=>{var h;return y=o.merge(p,(h=r())!=null?h:m),n(y,!0),f()}).then(()=>{v==null||v(y,void 0),l=!0,u.forEach(p=>p(y))}).catch(p=>{v==null||v(void 0,p)})};return i.persist={setOptions:C=>{o={...o,...C},C.getStorage&&(a=C.getStorage())},clearStorage:()=>{a==null||a.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>S(),hasHydrated:()=>l,onHydrate:C=>(s.add(C),()=>{s.delete(C)}),onFinishHydration:C=>(u.add(C),()=>{u.delete(C)})},S(),y||m},py=hy;function Nr(){return Math.floor(Math.random()*1e4)}const D=mu(dy((e,t)=>({parallelCount:1,requestOptions:{prompt:"a photograph of an astronaut riding a horse",seed:Nr(),num_outputs:1,num_inference_steps:50,guidance_scale:7.5,width:512,height:512,prompt_strength:.8,turbo:!0,use_cpu:!1,use_full_precision:!0,save_to_disk_path:"null",use_face_correction:"GFPGANv1.3",use_upscale:"RealESRGAN_x4plus",show_only_filtered_image:!0},tags:[],uiOptions:{isUseRandomSeed:!0,isUseAutoSave:!1,isSoundEnabled:!1},allModifiers:[[[]]],isInpainting:!1,setParallelCount:n=>e(se(r=>{r.parallelCount=n})),setRequestOptions:(n,r)=>{e(se(i=>{i.requestOptions[n]=r}))},getValueForRequestKey:n=>t().requestOptions[n],setAllModifiers:n=>{e(se(r=>{r.allModifiers=n}))},toggleTag:n=>{e(se(r=>{const i=r.tags.indexOf(n);i>-1?r.tags.splice(i,1):r.tags.push(n)}))},hasTag:n=>t().tags.indexOf(n)>-1,selectedTags:()=>t().tags,builtRequest:()=>{const n=t(),r=n.requestOptions,i=n.tags,o=`${r.prompt} ${i.join(",")}`,l={...r,prompt:o};return n.uiOptions.isUseAutoSave||(l.save_to_disk_path=null),l.init_image===void 0&&(l.prompt_strength=void 0),l.use_upscale===""&&(l.use_upscale=null),l.use_upscale===null&&l.use_face_correction===null&&(l.show_only_filtered_image=!1),l},toggleUseFaceCorrection:()=>{e(se(n=>{const r=typeof n.getValueForRequestKey("use_face_correction")=="string"?null:"GFPGANv1.3";n.requestOptions.use_face_correction=r}))},isUsingFaceCorrection:()=>typeof t().getValueForRequestKey("use_face_correction")=="string",isUsingUpscaling:()=>t().getValueForRequestKey("use_upscale")!="",toggleUseRandomSeed:()=>{e(se(n=>{n.uiOptions.isUseRandomSeed=!n.uiOptions.isUseRandomSeed,n.requestOptions.seed=n.uiOptions.isUseRandomSeed?Nr():n.requestOptions.seed,localStorage.setItem("ui:isUseRandomSeed",n.uiOptions.isUseRandomSeed)}))},isRandomSeed:()=>t().uiOptions.isUseRandomSeed,toggleUseAutoSave:()=>{e(se(n=>{n.uiOptions.isUseAutoSave=!n.uiOptions.isUseAutoSave,localStorage.setItem("ui:isUseAutoSave",n.uiOptions.isUseAutoSave)}))},isUseAutoSave:()=>t().uiOptions.isUseAutoSave,toggleSoundEnabled:()=>{e(se(n=>{n.uiOptions.isSoundEnabled=!n.uiOptions.isSoundEnabled}))},isSoundEnabled:()=>t().uiOptions.isSoundEnabled,toggleInpainting:()=>{e(se(n=>{n.isInpainting=!n.isInpainting}))}})));var nc="_1jo75h1",rc="_1jo75h0",vy="_1jo75h2";const ic="Stable Diffusion is starting...",my="Stable Diffusion is ready to use!",oc="Stable Diffusion is not running!";function yy({className:e}){const[t,n]=R.exports.useState(ic),[r,i]=R.exports.useState(rc),{status:o,data:l}=Zt(["health"],Hm,{refetchInterval:Vm});return R.exports.useEffect(()=>{o==="loading"?(n(ic),i(rc)):o==="error"?(n(oc),i(nc)):o==="success"&&(l[0]==="OK"?(n(my),i(vy)):(n(oc),i(nc)))},[o,l]),w(tn,{children:w("p",{className:[r,e].join(" "),children:t})})}var gy="_1v2cc580";function Sy(){const{status:e,data:t}=Zt([ss],Yd),[n,r]=R.exports.useState("2.1.0"),[i,o]=R.exports.useState("");return R.exports.useEffect(()=>{if(e==="success"){const{update_branch:l}=t;r("v2.1"),o(l==="main"?"(stable)":"(beta)")}},[e,t,r,r]),O("div",{className:gy,children:[O("h1",{children:["Stable Diffusion UI ",n," ",i," "]}),w(yy,{className:"status-display"})]})}const je=mu(py((e,t)=>({isOpenAdvancedSettings:!1,isOpenAdvImprovementSettings:!1,isOpenAdvPropertySettings:!1,isOpenAdvWorkflowSettings:!1,isOpenAdvGPUSettings:!1,isOpenImageModifier:!1,imageMofidiersMap:{},toggleAdvancedSettings:()=>{e(se(n=>{n.isOpenAdvancedSettings=!n.isOpenAdvancedSettings}))},toggleAdvImprovementSettings:()=>{e(se(n=>{n.isOpenAdvImprovementSettings=!n.isOpenAdvImprovementSettings}))},toggleAdvPropertySettings:()=>{e(se(n=>{n.isOpenAdvPropertySettings=!n.isOpenAdvPropertySettings}))},toggleAdvWorkflowSettings:()=>{e(se(n=>{n.isOpenAdvWorkflowSettings=!n.isOpenAdvWorkflowSettings}))},toggleAdvGPUSettings:()=>{e(se(n=>{n.isOpenAdvGPUSettings=!n.isOpenAdvGPUSettings}))},toggleImageModifier:()=>{e(se(n=>{n.isOpenImageModifier=!n.isOpenImageModifier}))}}),{name:"createUI"}));var Kn="_11d5x3d1",wy="_11d5x3d0",So="_11d5x3d2";function _y(){const e=D(c=>c.isUsingFaceCorrection()),t=D(c=>c.isUsingUpscaling()),n=D(c=>c.getValueForRequestKey("use_upscale")),r=D(c=>c.getValueForRequestKey("show_only_filtered_image")),i=D(c=>c.toggleUseFaceCorrection),o=D(c=>c.setRequestOptions),l=je(c=>c.isOpenAdvImprovementSettings),s=je(c=>c.toggleAdvImprovementSettings),[u,a]=R.exports.useState(!1);return R.exports.useEffect(()=>{console.log("isUsingUpscaling",t),console.log("isUsingFaceCorrection",e),a(!(e||n))},[e,t,a]),O("div",{children:[w("button",{type:"button",className:So,onClick:s,children:w("h4",{children:"Improvement Settings"})}),l&&O(tn,{children:[w("div",{children:O("label",{children:[w("input",{type:"checkbox",checked:e,onChange:c=>i()}),"Fix incorrect faces and eyes (uses GFPGAN)"]})}),w("div",{children:O("label",{children:["Upscale the image to 4x resolution using",O("select",{id:"upscale_model",name:"upscale_model",value:n,onChange:c=>{o("use_upscale",c.target.value)},children:[w("option",{value:"",children:"No Uscaling"}),w("option",{value:"RealESRGAN_x4plus",children:"RealESRGAN_x4plus"}),w("option",{value:"RealESRGAN_x4plus_anime_6B",children:"RealESRGAN_x4plus_anime_6B"})]})]})}),w("div",{children:O("label",{children:[w("input",{disabled:u,type:"checkbox",checked:r,onChange:c=>o("show_only_filtered_image",c.target.checked)}),"Show only filtered image"]})})]})]})}const lc=[{value:128,label:"128 (*)"},{value:192,label:"192"},{value:256,label:"256 (*)"},{value:320,label:"320"},{value:384,label:"384"},{value:448,label:"448"},{value:512,label:"512 (*)"},{value:576,label:"576"},{value:640,label:"640"},{value:704,label:"704"},{value:768,label:"768 (*)"},{value:832,label:"832"},{value:896,label:"896"},{value:960,label:"960"},{value:1024,label:"1024 (*)"}];function ky(){const e=D(d=>d.setRequestOptions),t=D(d=>d.toggleUseRandomSeed),n=D(d=>d.isRandomSeed()),r=D(d=>d.getValueForRequestKey("seed")),i=D(d=>d.getValueForRequestKey("num_inference_steps")),o=D(d=>d.getValueForRequestKey("guidance_scale")),l=D(d=>d.getValueForRequestKey("init_image")),s=D(d=>d.getValueForRequestKey("prompt_strength")),u=D(d=>d.getValueForRequestKey("width")),a=D(d=>d.getValueForRequestKey("height")),c=je(d=>d.isOpenAdvPropertySettings),f=je(d=>d.toggleAdvPropertySettings);return O("div",{children:[w("button",{type:"button",className:So,onClick:f,children:w("h4",{children:"Property Settings"})}),c&&O(tn,{children:[O("div",{children:[O("label",{children:["Seed:",w("input",{size:10,value:r,onChange:d=>e("seed",d.target.value),disabled:n,placeholder:"random"})]}),O("label",{children:[w("input",{type:"checkbox",checked:n,onChange:d=>t()})," ","Random Image"]})]}),w("div",{children:O("label",{children:["Number of inference steps:"," ",w("input",{value:i,onChange:d=>{e("num_inference_steps",d.target.value)},size:4})]})}),O("div",{children:[O("label",{children:["Guidance Scale:",w("input",{value:o,onChange:d=>e("guidance_scale",d.target.value),type:"range",min:"0",max:"20",step:".1"})]}),w("span",{children:o})]}),l&&O("div",{children:[O("label",{children:["Prompt Strength:"," ",w("input",{value:s,onChange:d=>e("prompt_strength",d.target.value),type:"range",min:"0",max:"1",step:".05"})]}),w("span",{children:s})]}),w("div",{children:O("label",{children:["Width:",w("select",{value:u,onChange:d=>e("width",d.target.value),children:lc.map(d=>w("option",{value:d.value,children:d.label},"width-option_"+d.value))})]})}),w("div",{children:O("label",{children:["Height:",w("select",{value:a,onChange:d=>e("height",d.target.value),children:lc.map(d=>w("option",{value:d.value,children:d.label},"height-option_"+d.value))})]})})]})]})}function Cy(){const e=D(f=>f.getValueForRequestKey("num_outputs")),t=D(f=>f.parallelCount),n=D(f=>f.isUseAutoSave()),r=D(f=>f.getValueForRequestKey("save_to_disk_path")),i=D(f=>f.isSoundEnabled()),o=D(f=>f.setRequestOptions),l=D(f=>f.setParallelCount),s=D(f=>f.toggleUseAutoSave),u=D(f=>f.toggleSoundEnabled),a=je(f=>f.isOpenAdvWorkflowSettings),c=je(f=>f.toggleAdvWorkflowSettings);return O("div",{children:[w("button",{type:"button",className:So,onClick:c,children:w("h4",{children:"Workflow Settings"})}),a&&O(tn,{children:[w("div",{children:O("label",{children:["Number of images to make:"," ",w("input",{type:"number",value:e,onChange:f=>o("num_outputs",parseInt(f.target.value,10)),size:4})]})}),w("div",{children:O("label",{children:["Generate in parallel:",w("input",{type:"number",value:t,onChange:f=>l(parseInt(f.target.value,10)),size:4})]})}),O("div",{children:[O("label",{children:[w("input",{checked:n,onChange:f=>s(),type:"checkbox"}),"Automatically save to"," "]}),O("label",{children:[w("input",{value:r,onChange:f=>o("save_to_disk_path",f.target.value),size:40,disabled:!n}),w("span",{className:"visually-hidden",children:"Path on disk where images will be saved"})]})]}),w("div",{children:O("label",{children:[w("input",{checked:i,onChange:f=>u(),type:"checkbox"}),"Play sound on task completion"]})})]})]})}function Ey(){const e=D(l=>l.getValueForRequestKey("turbo")),t=D(l=>l.getValueForRequestKey("use_cpu")),n=D(l=>l.getValueForRequestKey("use_full_precision")),r=D(l=>l.setRequestOptions),i=je(l=>l.isOpenAdvGPUSettings),o=je(l=>l.toggleAdvGPUSettings);return O("div",{children:[w("button",{type:"button",className:So,onClick:o,children:w("h4",{children:"GPU Settings"})}),i&&O(tn,{children:[w("div",{children:O("label",{children:[w("input",{checked:e,onChange:l=>r("turbo",l.target.checked),type:"checkbox"}),"Turbo mode (generates images faster, but uses an additional 1 GB of GPU memory)"]})}),w("div",{children:O("label",{children:[w("input",{type:"checkbox",checked:t,onChange:l=>r("use_cpu",l.target.checked)}),"Use CPU instead of GPU (warning: this will be *very* slow)"]})}),w("div",{children:O("label",{children:[w("input",{checked:n,onChange:l=>r("use_full_precision",l.target.checked),type:"checkbox"}),"Use full precision (for GPU-only. warning: this will consume more VRAM)"]})})]})]})}function xy(){const[e,t]=R.exports.useState(!1),[n,r]=R.exports.useState("beta"),{status:i,data:o}=Zt([ss],Yd),l=lu(),{status:s,data:u}=Zt([Gm],()=>Ym(n),{enabled:e});return R.exports.useEffect(()=>{if(i==="success"){const{update_branch:a}=o;r(a==="main"?"beta":"main")}},[i,o]),R.exports.useEffect(()=>{s==="success"&&(u[0]=="OK"&&l.invalidateQueries([ss]),t(!1))},[s,u,t]),O("label",{children:[w("input",{disabled:!0,type:"checkbox",checked:n==="main",onChange:a=>{t(!0)}}),"Enable Beta Mode"]})}function Py(){return O("ul",{className:wy,children:[w("li",{className:Kn,children:w(_y,{})}),w("li",{className:Kn,children:w(ky,{})}),w("li",{className:Kn,children:w(Cy,{})}),w("li",{className:Kn,children:w(Ey,{})}),w("li",{className:Kn,children:w(xy,{})})]})}function Oy(){const e=je(n=>n.isOpenAdvancedSettings),t=je(n=>n.toggleAdvancedSettings);return O("div",{className:"panel-box",children:[w("button",{type:"button",onClick:t,className:"panel-box-toggle-btn",children:w("h3",{children:"Advanced Settings"})}),e&&w(Py,{})]})}function Zd({name:e}){const t=D(i=>i.hasTag(e))?"selected":"",n=D(i=>i.toggleTag),r=()=>{n(e)};return w("div",{className:"modifierTag "+t,onClick:r,children:w("p",{children:e})})}function Ry({tags:e}){return w("ul",{className:"modifier-list",children:e.map(t=>w("li",{children:w(Zd,{name:t})},t))})}function Ny({title:e,tags:t}){const[n,r]=R.exports.useState(!1);return O("div",{className:"modifier-grouping",children:[w("div",{className:"modifier-grouping-header",onClick:()=>{r(!n)},children:w("h5",{children:e})}),n&&w(Ry,{tags:t})]})}function Iy(){const e=D(i=>i.allModifiers);console.log("allModifiers",e);const t=je(i=>i.isOpenImageModifier),n=je(i=>i.toggleImageModifier);return O("div",{className:"panel-box",children:[w("button",{type:"button",onClick:()=>{n()},className:"panel-box-toggle-btn",children:w("h4",{children:"Image Modifiers (art styles, tags, ect)"})}),t&&e.map((i,o)=>w(Ny,{title:i[0],tags:i[1]},i[0]))]})}var My="fma0ug0";function Ty({imageData:e,brushSize:t,brushShape:n,brushColor:r,isErasing:i}){const o=R.exports.useRef(null),l=R.exports.useRef(null),[s,u]=R.exports.useState(!1),[a,c]=R.exports.useState(512),[f,d]=R.exports.useState(512);R.exports.useEffect(()=>{const p=new Image;p.onload=()=>{c(p.width),d(p.height)},p.src=e},[e]),R.exports.useEffect(()=>{if(o.current){const p=o.current.getContext("2d"),h=p.getImageData(0,0,a,f),g=h.data;for(let x=0;x0&&(g[x]=parseInt(r,16),g[x+1]=parseInt(r,16),g[x+2]=parseInt(r,16));p.putImageData(h,0,0)}},[r]);const m=p=>{u(!0)},y=p=>{u(!1);const h=o.current;h&&h.toDataURL()},S=(p,h,g,x,E)=>{const k=o.current;if(k){const _=k.getContext("2d");if(i){const M=g/2;_.clearRect(p-M,h-M,g,g)}else _.beginPath(),_.lineWidth=g,_.lineCap=x,_.strokeStyle=E,_.moveTo(p,h),_.lineTo(p,h),_.stroke()}},C=(p,h,g,x,E)=>{const k=l.current;if(k){const _=k.getContext("2d");if(_.beginPath(),_.clearRect(0,0,k.width,k.height),i){const M=g/2;_.lineWidth=2,_.lineCap="butt",_.strokeStyle=E,_.moveTo(p-M,h-M),_.lineTo(p+M,h-M),_.lineTo(p+M,h+M),_.lineTo(p-M,h+M),_.lineTo(p-M,h-M),_.stroke()}else _.lineWidth=g,_.lineCap=x,_.strokeStyle=E,_.moveTo(p,h),_.lineTo(p,h),_.stroke()}};return O("div",{className:My,children:[w("img",{src:e}),w("canvas",{ref:o,width:a,height:f}),w("canvas",{ref:l,width:a,height:f,onMouseDown:m,onMouseUp:y,onMouseMove:p=>{const{nativeEvent:{offsetX:h,offsetY:g}}=p;C(h,g,t,n,r),s&&S(h,g,t,n,r)}})]})}var sc="_2yyo4x2",Dy="_2yyo4x1",Fy="_2yyo4x0";function Ly(){const e=R.exports.useRef(null),[t,n]=R.exports.useState("20"),[r,i]=R.exports.useState("round"),[o,l]=R.exports.useState("#fff"),[s,u]=R.exports.useState(!1),a=D(S=>S.getValueForRequestKey("init_image"));return O("div",{className:Fy,children:[w(Ty,{imageData:a,brushSize:t,brushShape:r,brushColor:o,isErasing:s}),O("div",{className:Dy,children:[O("div",{className:sc,children:[w("button",{onClick:()=>{u(!1)},children:"Mask"}),w("button",{onClick:()=>{u(!0)},children:"Erase"}),w("button",{disabled:!0,onClick:()=>{console.log("fill mask!!",e)},children:"Fill"}),w("button",{disabled:!0,onClick:()=>{console.log("clear all")},children:"Clear"}),O("label",{children:["Brush Size",w("input",{type:"range",min:"1",max:"100",value:t,onChange:S=>{n(S.target.value)}})]})]}),O("div",{className:sc,children:[w("button",{onClick:()=>{i("round")},children:"Cirle Brush"}),w("button",{onClick:()=>{i("square")},children:"Square Brush"}),w("button",{onClick:()=>{l("#000")},children:"Dark Brush"}),w("button",{onClick:()=>{l("#fff")},children:"Light Brush"})]})]})]})}var Ay="cjcdm20",Uy="cjcdm21";var zy="_1how28i0",jy="_1how28i1";var $y="_1rn4m8a4",Qy="_1rn4m8a2",By="_1rn4m8a3",qy="_1rn4m8a0",Vy="_1rn4m8a1",Hy="_1rn4m8a5";function Ky(e){const t=R.exports.useRef(null),n=D(a=>a.getValueForRequestKey("init_image")),r=D(a=>a.isInpainting),i=D(a=>a.setRequestOptions),o=()=>{var a;(a=t.current)==null||a.click()},l=a=>{const c=a.target.files[0];if(c){const f=new FileReader;f.onload=d=>{d.target&&i("init_image",d.target.result)},f.readAsDataURL(c)}},s=D(a=>a.toggleInpainting);return O("div",{className:qy,children:[O("div",{children:[O("label",{className:Vy,children:[w("b",{children:"Initial Image:"})," (optional)"]}),w("input",{ref:t,className:Qy,name:"init_image",type:"file",onChange:l}),w("button",{className:By,onClick:o,children:"Select File"})]}),w("div",{className:$y,children:n&&O(tn,{children:[O("div",{children:[w("img",{src:n,width:"100",height:"100"}),w("button",{className:Hy,onClick:()=>{i("init_image",void 0),r&&s()},children:"X"})]}),O("label",{children:[w("input",{type:"checkbox",onChange:a=>{s()},checked:r}),"Use for Inpainting"]})]})})]})}function Wy(){const e=D(t=>t.selectedTags());return O("div",{className:"selected-tags",children:[w("p",{children:"Active Tags"}),w("ul",{children:e.map(t=>w("li",{children:w(Zd,{name:t})},t))})]})}const sr=mu((e,t)=>({images:new Array,completedImageIds:new Array,addNewImage:(n,r,i=!1)=>{e(se(o=>{let{seed:l}=r;i&&(l=Nr()),o.images.push({id:n,options:{...r,seed:l}})}))},hasQueuedImages:()=>t().images.length>0,firstInQueue:()=>t().images[0]||[],removeFirstInQueue:()=>{e(se(n=>{const r=n.images.shift();n.completedImageIds.push(r.id)}))}}));let ni;const Gy=new Uint8Array(16);function Yy(){if(!ni&&(ni=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ni))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ni(Gy)}const oe=[];for(let e=0;e<256;++e)oe.push((e+256).toString(16).slice(1));function Xy(e,t=0){return(oe[e[t+0]]+oe[e[t+1]]+oe[e[t+2]]+oe[e[t+3]]+"-"+oe[e[t+4]]+oe[e[t+5]]+"-"+oe[e[t+6]]+oe[e[t+7]]+"-"+oe[e[t+8]]+oe[e[t+9]]+"-"+oe[e[t+10]]+oe[e[t+11]]+oe[e[t+12]]+oe[e[t+13]]+oe[e[t+14]]+oe[e[t+15]]).toLowerCase()}const Jy=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),uc={randomUUID:Jy};function Zy(e,t,n){if(uc.randomUUID&&!t&&!e)return uc.randomUUID();e=e||{};const r=e.random||(e.rng||Yy)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n=n||0;for(let i=0;i<16;++i)t[n+i]=r[i];return t}return Xy(r)}var by="_1hnlbmt0";function eg(){const e=D(s=>s.parallelCount),t=D(s=>s.builtRequest),n=sr(s=>s.addNewImage),r=sr(s=>s.hasQueuedImages()),i=D(s=>s.isRandomSeed()),o=D(s=>s.setRequestOptions);return w("button",{className:by,onClick:()=>{const s=t();let u=[],{num_outputs:a}=s;if(e>a)u.push(a);else for(;a>=1;)a-=e,a<=0?u.push(e):u.push(Math.abs(a));u.forEach((c,f)=>{let d=s.seed;f!==0&&(d=Nr()),n(Zy(),{...s,num_outputs:c,seed:d})}),i&&o("seed",Nr())},disabled:r,children:"Make"})}function tg(){const e=D(r=>r.getValueForRequestKey("prompt")),t=D(r=>r.setRequestOptions);return O("div",{className:zy,children:[O("div",{className:jy,children:[w("p",{children:"Prompt "}),w("textarea",{value:e,onChange:r=>{t("prompt",r.target.value)}})]}),w(Ky,{}),w(Wy,{}),w(eg,{})]})}function ng(){const e=D(t=>t.isInpainting);return O(tn,{children:[O("div",{className:Ay,children:[w(tg,{}),w(Oy,{}),w(Iy,{})]}),e&&w("div",{className:Uy,children:w(Ly,{})})]})}const rg=`${Lt}/ding.mp3`,ig=yc.forwardRef((e,t)=>w("audio",{ref:t,style:{display:"none"},children:w("source",{src:rg,type:"audio/mp3"})}));var og="_1yvg52n0",lg="_1yvg52n1";function sg({imageData:e,metadata:t,className:n}){return w("div",{className:[og,n].join(" "),children:w("img",{className:lg,src:e,alt:t.prompt})})}function ug({image:e}){const{info:t,data:n}=e||{info:null,data:null},r=D(s=>s.setRequestOptions),i=()=>{const{prompt:s,seed:u,num_inference_steps:a,guidance_scale:c,use_face_correction:f,use_upscale:d,width:m,height:y}=t;let S=s.replace(/[^a-zA-Z0-9]/g,"_");S=S.substring(0,100);let C=`${S}_Seed-${u}_Steps-${a}_Guidance-${c}`;return f&&(C+=`_FaceCorrection-${f}`),d&&(C+=`_Upscale-${d}`),C+=`_${m}x${y}`,C+=".png",C},o=()=>{const s=document.createElement("a");s.download=i(),s.href=n,s.click()},l=()=>{r("init_image",n)};return O("div",{className:"current-display",children:[e&&O("div",{children:[O("p",{children:[" ",t.prompt]}),w(sg,{imageData:n,metadata:t}),O("div",{children:[w("button",{onClick:o,children:"Save"}),w("button",{onClick:l,children:"Use as Input"})]})]}),w("div",{})]})}var ag="fsj92y0",cg="fsj92y1";function fg({images:e,setCurrentDisplay:t}){const n=r=>{const i=e[r];t(i)};return w("div",{className:ag,children:e&&e.map((r,i)=>r===void 0?(console.warn(`image ${i} is undefined`),null):w("button",{className:cg,onClick:()=>{n(i)},children:w("img",{src:r.data,alt:r.info.prompt})},i))})}var dg="_688lcr1",hg="_688lcr0",pg="_688lcr2";function vg(){const e=R.exports.useRef(null),t=D(m=>m.isSoundEnabled()),{id:n,options:r}=sr(m=>m.firstInQueue()),i=sr(m=>m.removeFirstInQueue),[o,l]=R.exports.useState(null),{status:s,data:u}=Zt([ba,n],()=>Xm(r),{enabled:n!==void 0});R.exports.useEffect(()=>{var m;s==="success"&&u.status==="succeeded"&&(t&&((m=e.current)==null||m.play()),i())},[s,u,i,e,t]);const a=lu(),[c,f]=R.exports.useState([]),d=sr(m=>m.completedImageIds);return R.exports.useEffect(()=>{const m=d.map(y=>a.getQueryData([ba,y]));if(m.length>0){const y=m.map((S,C)=>{if(S!==void 0)return S.output.map(v=>({id:`${d[C]}-${v.seed}`,data:v.data,info:{...S.request,seed:v.seed}}))}).flat().reverse().filter(S=>S!==void 0);f(y);debugger;l(y[0]||null)}else f([]),l(null)},[f,l,a,d]),O("div",{className:hg,children:[w(ig,{ref:e}),w("div",{className:dg,children:w(ug,{image:o})}),w("div",{className:pg,children:w(fg,{images:c,setCurrentDisplay:l})})]})}function mg(){return O("div",{id:"footer",className:"panel-box",children:[O("p",{children:["If you found this project useful and want to help keep it alive, please"," ",w("a",{href:"https://ko-fi.com/cmdr2_stablediffusion_ui",target:"_blank",children:w("img",{src:`${Lt}/kofi.png`,id:"coffeeButton"})})," ","to help cover the cost of development and maintenance! Thank you for your support!"]}),O("p",{children:["Please feel free to join the"," ",w("a",{href:"https://discord.com/invite/u9yhsFmEkB",target:"_blank",children:"discord community"})," ","or"," ",w("a",{href:"https://github.com/cmdr2/stable-diffusion-ui/issues",target:"_blank",children:"file an issue"})," ","if you have any problems or suggestions in using this interface."]}),O("div",{id:"footer-legal",children:[O("p",{children:[w("b",{children:"Disclaimer:"})," The authors of this project are not responsible for any content generated using this interface."]}),O("p",{children:["This license of this software forbids you from sharing any content that violates any laws, produce any harm to a person, disseminate any personal information that would be meant for harm, ",w("br",{}),"spread misinformation and target vulnerable groups. For the full list of restrictions please read"," ",w("a",{href:"https://github.com/cmdr2/stable-diffusion-ui/blob/main/LICENSE",target:"_blank",children:"the license"}),"."]}),w("p",{children:"By using this software, you consent to the terms and conditions of the license."})]})]})}function yg({className:e}){const t=D(s=>s.setRequestOptions),{status:n,data:r}=Zt(["SaveDir"],Wm),{status:i,data:o}=Zt(["modifications"],Km),l=D(s=>s.setAllModifiers);return R.exports.useEffect(()=>{n==="success"&&t("save_to_disk_path",r)},[t,n,r]),R.exports.useEffect(()=>{i==="success"?l(o):i==="error"&&l(Jm)},[t,i,o]),O("div",{className:[jm,e].join(" "),children:[w("header",{className:qm,children:w(Sy,{})}),w("nav",{className:$m,children:w(ng,{})}),w("main",{className:Qm,children:w(vg,{})}),w("footer",{className:Bm,children:w(mg,{})})]})}function gg({className:e}){return w("div",{children:w("h1",{children:"Settings"})})}var Sg="_4vfmtj1t";const wg=new Cm;function _g(){const e=Sg;return w(Em,{location:wg,routes:[{path:"/",element:w(yg,{className:e})},{path:"/settings",element:w(gg,{className:e})}]})}const kg=new Hv({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1,staleTime:1/0}}});um();tl.createRoot(document.getElementById("root")).render(w(yc.StrictMode,{children:O(Gv,{client:kg,children:[w(_g,{}),w(tm,{initialIsOpen:!0})]})}));