From e39513680bbb68b2e8b7447dff91bc45d12ab71a Mon Sep 17 00:00:00 2001 From: ronaldzgithub <36839548+ronaldzgithub@users.noreply.github.com> Date: Sat, 16 Nov 2024 22:18:24 +0800 Subject: [PATCH] host showed --- appstore_panel/dist/bundle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appstore_panel/dist/bundle.js b/appstore_panel/dist/bundle.js index 22ea37f..1c243a3 100644 --- a/appstore_panel/dist/bundle.js +++ b/appstore_panel/dist/bundle.js @@ -1939,4 +1939,4 @@ __p+='`),et}),c+=`'; `,nt="obj";c=`var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; `+c+`return __p; `;var at;try{at=new Function(nt,"_",c)}catch(et){throw et.source=c,et}var lt=function(et){return at.call(this,et,_$1)};return lt.source="function("+nt+`){ -`+c+"}",lt}function result(e,o,s){o=toPath(o);var a=o.length;if(!a)return isFunction$1(s)?s.call(e):s;for(var $=0;$1)flatten$1(at,o-1,s,a),$=a.length;else for(var lt=0,et=at.length;lto?(a&&(clearTimeout(a),a=null),at=it,nt=e.apply($,c),a||($=c=null)):!a&&s.trailing!==!1&&(a=setTimeout(lt,st)),nt};return et.cancel=function(){clearTimeout(a),at=0,a=$=c=null},et}function debounce(e,o,s){var a,$,c,nt,at,lt=function(){var it=now()-$;o>it?a=setTimeout(lt,o-it):(a=null,s||(nt=e.apply(at,c)),a||(c=at=null))},et=restArguments(function(it){return at=this,c=it,$=now(),a||(a=setTimeout(lt,o),s&&(nt=e.apply(at,c))),nt});return et.cancel=function(){clearTimeout(a),a=c=at=null},et}function wrap(e,o){return partial(o,e)}function negate(e){return function(){return!e.apply(this,arguments)}}function compose(){var e=arguments,o=e.length-1;return function(){for(var s=o,a=e[o].apply(this,arguments);s--;)a=e[s].call(this,a);return a}}function after(e,o){return function(){if(--e<1)return o.apply(this,arguments)}}function before(e,o){var s;return function(){return--e>0&&(s=o.apply(this,arguments)),e<=1&&(o=null),s}}const once=partial(before,2);function findKey(e,o,s){o=cb(o,s);for(var a=keys(e),$,c=0,nt=a.length;c0?0:$-1;c>=0&&c<$;c+=e)if(s(o[c],c,o))return c;return-1}}const findIndex=createPredicateIndexFinder(1),findLastIndex=createPredicateIndexFinder(-1);function sortedIndex(e,o,s,a){s=cb(s,a,1);for(var $=s(o),c=0,nt=getLength(e);c0?nt=c>=0?c:Math.max(c+at,nt):at=c>=0?Math.min(c+1,at):c+at+1;else if(s&&c&&at)return c=s(a,$),a[c]===$?c:-1;if($!==$)return c=o(slice.call(a,nt,at),isNaN$1),c>=0?c+nt:-1;for(c=e>0?nt:at-1;c>=0&&c0?0:at-1;for(c||($=s[nt?nt[lt]:lt],lt+=e);lt>=0&<=3;return o(s,optimizeCb(a,c,4),$,nt)}}const reduce=createReduce(1),reduceRight=createReduce(-1);function filter(e,o,s){var a=[];return o=cb(o,s),each(e,function($,c,nt){o($,c,nt)&&a.push($)}),a}function reject(e,o,s){return filter(e,negate(cb(o)),s)}function every(e,o,s){o=cb(o,s);for(var a=!isArrayLike(e)&&keys(e),$=(a||e).length,c=0;c<$;c++){var nt=a?a[c]:c;if(!o(e[nt],nt,e))return!1}return!0}function some(e,o,s){o=cb(o,s);for(var a=!isArrayLike(e)&&keys(e),$=(a||e).length,c=0;c<$;c++){var nt=a?a[c]:c;if(o(e[nt],nt,e))return!0}return!1}function contains(e,o,s,a){return isArrayLike(e)||(e=values(e)),(typeof s!="number"||a)&&(s=0),indexOf(e,o,s)>=0}const invoke=restArguments(function(e,o,s){var a,$;return isFunction$1(o)?$=o:(o=toPath(o),a=o.slice(0,-1),o=o[o.length-1]),map(e,function(c){var nt=$;if(!nt){if(a&&a.length&&(c=deepGet(c,a)),c==null)return;nt=c[o]}return nt==null?nt:nt.apply(c,s)})});function pluck(e,o){return map(e,property(o))}function where(e,o){return filter(e,matcher(o))}function max(e,o,s){var a=-1/0,$=-1/0,c,nt;if(o==null||typeof o=="number"&&typeof e[0]!="object"&&e!=null){e=isArrayLike(e)?e:values(e);for(var at=0,lt=e.length;ata&&(a=c)}else o=cb(o,s),each(e,function(et,it,st){nt=o(et,it,st),(nt>$||nt===-1/0&&a===-1/0)&&(a=et,$=nt)});return a}function min(e,o,s){var a=1/0,$=1/0,c,nt;if(o==null||typeof o=="number"&&typeof e[0]!="object"&&e!=null){e=isArrayLike(e)?e:values(e);for(var at=0,lt=e.length;atat||nt===void 0)return 1;if(nt1&&(a=optimizeCb(a,o[1])),o=allKeys(e)):(a=keyInObj,o=flatten$1(o,!1,!1),e=Object(e));for(var $=0,c=o.length;$1&&(a=o[1])):(o=map(flatten$1(o,!1,!1),String),s=function($,c){return!contains(o,c)}),pick(e,s,a)});function initial(e,o,s){return slice.call(e,0,Math.max(0,e.length-(o==null||s?1:o)))}function first(e,o,s){return e==null||e.length<1?o==null||s?void 0:[]:o==null||s?e[0]:initial(e,e.length-o)}function rest(e,o,s){return slice.call(e,o==null||s?1:o)}function last(e,o,s){return e==null||e.length<1?o==null||s?void 0:[]:o==null||s?e[e.length-1]:rest(e,Math.max(0,e.length-o))}function compact(e){return filter(e,Boolean)}function flatten(e,o){return flatten$1(e,o,!1)}const difference=restArguments(function(e,o){return o=flatten$1(o,!0,!0),filter(e,function(s){return!contains(o,s)})}),without=restArguments(function(e,o){return difference(e,o)});function uniq(e,o,s,a){isBoolean(o)||(a=s,s=o,o=!1),s!=null&&(s=cb(s,a));for(var $=[],c=[],nt=0,at=getLength(e);nt"u"?it={autoBom:!1}:typeof it!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),it={autoBom:!it}),it.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(et.type)?new Blob(["\uFEFF",et],{type:et.type}):et}function a(et,it,st){var ct=new XMLHttpRequest;ct.open("GET",et),ct.responseType="blob",ct.onload=function(){lt(ct.response,it,st)},ct.onerror=function(){console.error("could not download file")},ct.send()}function $(et){var it=new XMLHttpRequest;it.open("HEAD",et,!1);try{it.send()}catch{}return 200<=it.status&&299>=it.status}function c(et){try{et.dispatchEvent(new MouseEvent("click"))}catch{var it=document.createEvent("MouseEvents");it.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),et.dispatchEvent(it)}}var nt=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof commonjsGlobal=="object"&&commonjsGlobal.global===commonjsGlobal?commonjsGlobal:void 0,at=nt.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),lt=nt.saveAs||(typeof window!="object"||window!==nt?function(){}:"download"in HTMLAnchorElement.prototype&&!at?function(et,it,st){var ct=nt.URL||nt.webkitURL,ft=document.createElement("a");it=it||et.name||"download",ft.download=it,ft.rel="noopener",typeof et=="string"?(ft.href=et,ft.origin===location.origin?c(ft):$(ft.href)?a(et,it,st):c(ft,ft.target="_blank")):(ft.href=ct.createObjectURL(et),setTimeout(function(){ct.revokeObjectURL(ft.href)},4e4),setTimeout(function(){c(ft)},0))}:"msSaveOrOpenBlob"in navigator?function(et,it,st){if(it=it||et.name||"download",typeof et!="string")navigator.msSaveOrOpenBlob(s(et,st),it);else if($(et))a(et,it,st);else{var ct=document.createElement("a");ct.href=et,ct.target="_blank",setTimeout(function(){c(ct)})}}:function(et,it,st,ct){if(ct=ct||open("","_blank"),ct&&(ct.document.title=ct.document.body.innerText="downloading..."),typeof et=="string")return a(et,it,st);var ft=et.type==="application/octet-stream",pt=/constructor/i.test(nt.HTMLElement)||nt.safari,gt=/CriOS\/[\d]+/.test(navigator.userAgent);if((gt||ft&&pt||at)&&typeof FileReader<"u"){var wt=new FileReader;wt.onloadend=function(){var $t=wt.result;$t=gt?$t:$t.replace(/^data:[^;]*;/,"data:attachment/file;"),ct?ct.location.href=$t:location=$t,ct=null},wt.readAsDataURL(et)}else{var vt=nt.URL||nt.webkitURL,_t=vt.createObjectURL(et);ct?ct.location=_t:location.href=_t,ct=null,setTimeout(function(){vt.revokeObjectURL(_t)},4e4)}});nt.saveAs=lt.saveAs=lt,e.exports=lt})})(FileSaver_min);var FileSaver_minExports=FileSaver_min.exports;const Segment=({param:e,index:o,handleInputChange:s,sourceImageID:a,template_id:$=null})=>{const[c,nt]=reactExports.useState([]),[at,lt]=reactExports.useState(null),[et,it]=reactExports.useState(null),[st,ct]=reactExports.useState(null),[ft,pt]=reactExports.useState(null),gt=useModel(),[wt,vt]=reactExports.useState(null),[_t,$t]=reactExports.useState(null),[Pt,Nt]=reactExports.useState({});reactExports.useState(null),reactExports.useState(null);const[Lt,Ft]=reactExports.useState(null),[Wt,vr]=reactExports.useState(null),[wr,_o]=reactExports.useState(null),[Jt,Kr]=reactExports.useState(null),[Ot,gr]=reactExports.useState(null),[$o,On]=reactExports.useState(null),en=reactExports.useRef(null),Lr=reactExports.useRef(null),[ko,Ir]=reactExports.useState("/api/resources/proxyurl/shangxiaobao.com:9001"),Dr=reactExports.useRef(null),Zr=reactExports.useRef(null);reactExports.useEffect(()=>{(()=>{const _n=document.createElement("script");_n.src=`${WEB_SITE}/assets/opencv.js`,_n.async=!0,_n.onload=()=>{console.log("OpenCV.js loaded")},document.body.appendChild(_n)})()},[]),reactExports.useEffect(()=>{},[]),reactExports.useEffect(()=>{console.log("new source iamge id",a);const So={};Dr.current=So,(!a||et)&&(Kr(generateUniqueFilename("_embeddings.npy")),gr(generateUniqueFilename("_mask.png")),it(null),ct(null),$t(null),nt([]),Nt({}),pt(null),lt(null),vt(null),vr(null)),a&&getLocalResourceURL(a,$).then(_n=>{if(Dr.current!=So){console.log("cancel executions.",a);return}if(_o(_n.url),vn(_n.url),(!e.value||!e.value[1]||!e.value[1].name||$o)&&Zo(new URL(_n.url),So),Dr.current!=So){console.log("cancel executions.",a);return}On(a)})},[a]),reactExports.useEffect(()=>{const So={};Zr.current=So,(async Do=>{if(!Lt&&!Wt&&e&&e.value&&Array.isArray(e.value)&&e.value.length>0&&e.value[1]){let Xo={url:null,file:null},Lo={url:null,file:null};if(Zr.current!==Do){console.log("quit1");return}if(e.value[0]&&e.value[0].name){if(Xo=await getLocalResourceURL(`${e.value[0].name}_${e.value[0].type}_${e.value[0].size}`,$),Zr.current!==Do){console.log("quit1");return}zo(Xo.url),Ft(Xo.file)}if(Zr.current!==Do){console.log("quit2");return}if(e.value[1]&&e.value[1].name){if(Lo=await getLocalResourceURL(`${e.value[1].name}_${e.value[1].type}_${e.value[1].size}`,$),Zr.current!==Do){console.log("quit1");return}vr(Lo.file),tn(Lo.file)}if(Zr.current!==Do){console.log("quit3");return}s(o,{target:{name:Xo.file&&Xo.file.name?Xo.file.name:"mask.file",files:[Xo?.file,Lo.file]}})}else console.log("legacy flow.")})(So)},[e]),reactExports.useEffect(()=>{const So=()=>{et&&et.width/et.height},_n=new ResizeObserver(Do=>{for(const Xo of Do)Xo.target===document.body&&So()});return So(),_n.observe(document.body),()=>{_n.unobserve(document.body)}},[et]);const tn=async So=>{if(So)try{const _n=await Yo(So),Do=await Js(_n,"float32");vt(Do)}catch(_n){alert("internal error"),console.error("Failed to load tensor:",_n)}},vn=async So=>{try{if(!So)return;const _n=new Image;_n.src=new URL(So).href,_n.onload=()=>{const{height:Do,width:Xo,samScale:Lo}=Fo(_n);$t({height:Do,width:Xo,samScale:Lo}),_n.width=Xo,_n.height=Do,it(_n)}}catch(_n){console.log(_n)}},zo=async So=>{try{if(!So){ct(null);return}const _n=new Image;_n.src=new URL(So).href,_n.onload=()=>{ct(_n)}}catch(_n){console.log(_n)}};function Yo(So){return new Promise((_n,Do)=>{const Xo=new FileReader;Xo.onload=Lo=>{_n(Lo.target.result)},Xo.onerror=Lo=>{Do(Lo)},Xo.readAsArrayBuffer(So)})}async function jo(So,_n){try{const Do=new Blob([So],{type:"application/octet-stream"}),Xo=Jt,Lo=new File([Do],Xo,{type:"application/octet-stream"});if(Dr.current!==_n){console.log("canceld:",Lo);return}if(vr(Lo),tn(Lo),Dr.current!==_n){console.log("canceld:",Lo);return}console.log("seding param change :",Lo),s(o,{target:{name:Ot,files:[null,Lo]}}),ct(null)}catch(Do){console.error("Error saving ArrayBuffer:",Do)}}const Ko=async So=>{const _n=await fetch(So).then(Lo=>Lo.blob()),Do=new File([_n],"mask.png",{type:"image/png"}),Xo=new FormData;return Xo.append("file",_n),Xo.append("name",Do.name),Xo.append("size",Do.size),Xo.append("type",Do.type),Xo},Zo=async(So,_n)=>{const Do=await Ko(So);let Xo=0;for(;Xo<3;){try{if(Dr.current!==_n)return;let Lo=await fetch(`${MARKETPLACE_SITE}${ko}/getembeddings_refined`,{method:"POST",body:Do});if(Lo.ok){const Jo=await Lo.arrayBuffer();jo(Jo,_n);break}else alert("网络阻塞,重试一下就好 ..."),console.error("Failed to get embeddings:",Lo.statusText)}catch(Lo){alert("网络阻塞,重试一下就好 ..."),console.error("Error loading image tensor:",Lo)}Xo+=1}},Fo=So=>{let Do=So.naturalWidth,Xo=So.naturalHeight;const Lo=1024/Math.max(Xo,Do);return{height:Xo,width:Do,samScale:Lo}},Js=async(So,_n)=>{const Xo=await new npyjs().load(So);return new yt(_n,Xo.data,Xo.shape)};reactExports.useEffect(()=>{if(c){const So=In();if(So){const _n=rn(So);_n.onload=()=>{const Do=document.createElement("canvas"),Xo=Do.getContext("2d");Do.width=So.width,Do.height=So.height,Xo.fillStyle="white",Xo.fillRect(0,0,Do.width,Do.height),Xo.drawImage(_n,0,0);try{if(window.cv&&window.cv.imread){const Lo=window.cv.imread(Do);if(Lo.empty())console.error("The source matrix is empty.");else{const Jo=new window.cv.Mat;window.cv.cvtColor(Lo,Jo,window.cv.COLOR_RGBA2GRAY,0);const Xs=new window.cv.Mat,na=new window.cv.Size(5,5);window.cv.GaussianBlur(Jo,Xs,na,0,0,window.cv.BORDER_DEFAULT);const ba=window.cv.Mat.ones(5,5,window.cv.CV_8U),ga=new window.cv.Mat;window.cv.morphologyEx(Xs,ga,window.cv.MORPH_CLOSE,ba);const eu=new window.cv.Mat;window.cv.threshold(ga,eu,127,255,window.cv.THRESH_BINARY),window.cv.imshow(Do,eu),Lo.delete(),Jo.delete(),Xs.delete(),ga.delete(),eu.delete(),ba.delete()}}else console.error("OpenCV.js is not loaded properly.")}catch(Lo){console.error("OPENCV ERROR:",Lo)}Do.toBlob(Lo=>{if(Lo){const Jo=Ot,Xs=new File([Lo],Jo,{type:"image/png"});Ft(Xs),s(o,{target:{name:Ot,files:[Xs,Wt]}})}},"image/png")},ct(_n)}else ct(null)}},[c]),reactExports.useEffect(()=>{if(!at){pt(null);return}if(gt===null||wt===null||_t===null)return;(async()=>{const _n=await ar({x:at.x,y:at.y}),Do=rn(_n);pt(Do)})()},[at]),reactExports.useEffect(()=>{if(!st)return;const So=new window.Image;So.src=st.src,So.onload=()=>{const _n=en.current;if(!_n)return;const Do=_n.getContext("2d");_n.width=So.width,_n.height=So.height,Do.drawImage(So,0,0);const Xo=Do.getImageData(0,0,_n.width,_n.height),Lo=Xo.data;for(let Jo=0;Jo{if(So.preventDefault(),!st)return;const _n=document.createElement("canvas");_n.width=st.width,_n.height=st.height;const Do=_n.getContext("2d");Do.drawImage(st,0,0);const Xo=Do.getImageData(0,0,st.width,st.height).data,Lo=document.createElement("canvas");Lo.width=st.width,Lo.height=st.height;const Jo=Lo.getContext("2d");Jo.drawImage(et,0,0,st.width,st.height);const Xs=Jo.getImageData(0,0,st.width,st.height).data;for(let na=0;na{const ba=URL.createObjectURL(na),ga=document.createElement("a");ga.download="extracted_areas.png",ga.href=ba,ga.click()},"image/png")},Dt=async So=>{if(gt===null||wt===null||_t===null)return;So.preventDefault();const _n=So.currentTarget.getBoundingClientRect(),Do=(So.clientX-_n.left)*(_t.width/_n.width),Xo=(So.clientY-_n.top)*(_t.height/_n.height);if(So.button===0){const Lo=[...c,Jr(Do,Xo)];let Jo=await ar({x:Do,y:Xo});Nt({...Pt,[`${Do},${Xo},1`]:Jo}),nt(Lo)}else if(So.button===2){const Lo=[...c,Jr(Do,Xo,-1)];let Jo=await ar({x:Do,y:Xo});Nt({...Pt,[`${Do},${Xo},-1`]:Jo}),nt(Lo)}},Eo=So=>{So.preventDefault()},Jr=(So,_n,Do=1)=>({x:So,y:_n,clickType:Do}),ar=async({x:So,y:_n})=>{try{if(gt===null||wt===null||_t===null)return;const Do=[Jr(So,_n)],Xo=modelData({clicks:Do,tensor:wt,modelScale:_t});if(Xo===void 0)return;const Jo=(await gt.run(Xo))[gt.outputNames[0]];return er(Jo.data,Jo.dims[2],Jo.dims[3])}catch(Do){console.log(Do)}return null};function er(So,_n,Do){const[Xo,Lo,Jo,Xs]=[0,114,189,255],na=new Uint8ClampedArray(4*_n*Do).fill(0);for(let ba=0;ba0&&(na[4*ba+0]=Xo,na[4*ba+1]=Lo,na[4*ba+2]=Jo,na[4*ba+3]=Xs);return new ImageData(na,Do,_n)}function _r(So){const _n=document.createElement("canvas");return _n.width=So.width,_n.height=So.height,_n.getContext("2d").putImageData(So,0,0),_n}const In=()=>{if(Object.keys(Pt).length===0)return null;if(gt===null||wt===null||_t===null)return;Pt[Object.keys(Pt)[0]];const So=et.width,_n=et.height,Do=document.createElement("canvas");Do.getContext("2d"),Do.width=So,Do.height=_n;const Xo=new Uint8ClampedArray(4*So*_n).fill(0);return Object.entries(Pt).forEach(([Jo,Xs])=>{const ba=_r(Xs).getContext("2d").getImageData(0,0,So,_n).data,ga=parseInt(Jo.split(",")[2]);if(ga===-1)for(let eu=0;eu0&&(Xo[eu+3]=0);else if(ga===1)for(let eu=0;eu0&&(Xo[eu+3]=255)}),new ImageData(Xo,So,_n)};function rn(So){const _n=_r(So),Do=new Image;return Do.src=_n.toDataURL(),Do}const Yr=So=>{if(So.preventDefault(),!st)return;const _n=document.createElement("canvas"),Do=_n.getContext("2d");if(_n.width=st.width,_n.height=st.height,Do.fillStyle="white",Do.fillRect(0,0,_n.width,_n.height),Do.drawImage(st,0,0),window.cv)try{const Xo=window.cv.imread(_n),Lo=new window.cv.Mat;window.cv.cvtColor(Xo,Lo,window.cv.COLOR_RGBA2GRAY,0);const Jo=new window.cv.Mat,Xs=new window.cv.Size(5,5);window.cv.GaussianBlur(Lo,Jo,Xs,0,0,window.cv.BORDER_DEFAULT);const na=window.cv.Mat.ones(5,5,window.cv.CV_8U),ba=new window.cv.Mat;window.cv.morphologyEx(Jo,ba,window.cv.MORPH_CLOSE,na);const ga=new window.cv.Mat;window.cv.threshold(ba,ga,127,255,window.cv.THRESH_BINARY),window.cv.imshow(_n,ga);const eu=_n.toDataURL("image/png");Xo.delete(),Lo.delete(),Jo.delete(),ba.delete(),ga.delete(),na.delete();const mu=Io(eu);let gu=generateUniqueFilename("mask.png");FileSaver_minExports.saveAs(mu,gu)}catch(Xo){console.error("OPENCV ERROR:",Xo),_n.toBlob(Lo=>{let Jo=generateUniqueFilename("mask.png");FileSaver_minExports.saveAs(Lo,Jo)},"image/png")}};function Io(So){const _n=atob(So.split(",")[1]),Do=new Array(_n.length);for(let Lo=0;Lo<_n.length;Lo++)Do[Lo]=_n.charCodeAt(Lo);const Xo=new Uint8Array(Do);return new Blob([Xo],{type:"image/png"})}const Bo=So=>{So.preventDefault(),ct(null),nt([]),Nt({}),pt(null),lt(null),Ft(null),s(o,{target:{name:Ot,files:[null,Wt]}})},Ao=_.throttle(So=>{if(gt===null||wt===null||_t===null)return;let _n=So.nativeEvent.target;const Do=_n.getBoundingClientRect();let Xo=So.clientX-Do.left,Lo=So.clientY-Do.top;const Jo=et?et.width/_n.offsetWidth:1;Xo*=Jo,Lo*=Jo;const Xs=Jr(Xo,Lo);Xs&<(Xs)},15),Qo=So=>{console.log("out"),lt(null),pt(null)};return reactExports.useState(null),reactExports.useState(500),jsxRuntimeExports.jsxs("div",{className:"my-file-drop-area",children:[(!wt||!gt||!_t)&&jsxRuntimeExports.jsx("div",{style:{fontSize:"14px",textAlign:"center",padding:"20px",zIndex:999,backgroundColor:"rgba(255, 255, 255, 0.9)"},children:et?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("img",{style:{width:"20px",height:"20px"},loading:"lazy",className:"mix_blend_mode",src:`${WEB_SITE}/images/loading.gif`,alt:"active-icon"}),window.innerWidth>1e3?"蒙版加载中,大概需要10-20秒,然后移动鼠标,稍作等待后,蓝色区域为备选区域(左键是加选,右键是减选),红色是已选区域(即:在结果中保留的部分)":"红色已选,点击选择"]}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:window.innerWidth>1e3?"这里是左边的原图的蒙版选择区域,红色选中的区域在结果图中不会变。 ":"蒙版"})}),wt&>&&_t&&at==null&&window.innerWidth>1e3&&jsxRuntimeExports.jsx("div",{style:{fontSize:"14px",textAlign:"center",padding:"20px",zIndex:999,backgroundColor:"rgba(255, 255, 255, 0.4)"},children:et?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:window.innerWidth>1e3?"挪动鼠标,蓝色为待选区域,红色为结果图中不变的区域,左键➕,右键➖":"点击选择蒙版"}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:window.innerWidth>1e3?"这里是左边的原图的蒙版选择区域,红色选中的区域在结果图中不会变。 ":"蒙版"})}),!1,st&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("button",{onClick:Yr,style:{position:"absolute",top:"20px",left:0,background:"#31BE4B",border:"none",borderRadius:"4px",color:"#FFFFFF",margin:window.innerWidth>1e3?"10px":"0px",fontSize:"10px",zIndex:999},children:"下载"}),jsxRuntimeExports.jsx("button",{onClick:Ks,style:{position:"absolute",top:"50px",left:0,background:"#2C5ECE",border:"none",borderRadius:"4px",color:"#ffffff",margin:window.innerWidth>1e3?"10px":"0px",fontSize:"10px",zIndex:999},children:"剪裁"}),jsxRuntimeExports.jsx("button",{onClick:Bo,style:{position:"absolute",top:"80px",left:0,background:"#E6E6E6",border:"none",borderRadius:"4px",color:"#787878",margin:window.innerWidth>1e3?"10px":"0px",fontSize:"10px",zIndex:999},children:"清空"})]}),et&&jsxRuntimeExports.jsx("img",{src:et.src,name:"sourceimage",style:{position:"absolute",height:"auto",width:"auto",maxWidth:"100%",maxHeight:"100%",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}}),st&&jsxRuntimeExports.jsx("canvas",{ref:en,style:{position:"absolute",height:"auto",width:"auto",maxWidth:"100%",maxHeight:"100%",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}}),ft&&jsxRuntimeExports.jsx("img",{src:ft.src,style:{position:"absolute",height:"auto",width:"auto",maxWidth:"100%",maxHeight:"100%",opacity:"0.5",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}}),et&&jsxRuntimeExports.jsx("img",{ref:Lr,src:et.src,name:"sourceimage",style:{position:"absolute",height:"auto",width:"auto",maxWidth:"100%",maxHeight:"100%",top:"50%",left:"50%",opacity:"0.2",zIndex:"990",transform:"translate(-50%, -50%)"},onMouseDown:Dt,onMouseMove:Ao,onMouseLeave:Qo,onContextMenu:Eo})]})};function ImageEditor({param:e,canvasWidth:o,canvasHeight:s,url:a,handleChanged:$}){const c=reactExports.useRef(null),[nt,at]=reactExports.useState({x:0,y:0,width:0,height:0,scale:1}),[lt,et]=reactExports.useState(!1),[it,st]=reactExports.useState({x:0,y:0,width:0,height:0}),[ct,ft]=reactExports.useState(!1),[pt,gt]=reactExports.useState(null),[wt,vt]=reactExports.useState(!1),[_t,$t]=reactExports.useState(null),[Pt,Nt]=reactExports.useState(1),Lt=reactExports.useRef(null),[Ft,Wt]=reactExports.useState(null),vr=Zr=>{if(Zr){const tn=e.accept.split(","),vn=Zr.name.split(".").pop().toLowerCase();if(tn==""||tn.includes(`.${vn}`)){const zo={target:{name:e.name,files:[Zr]}};$(zo)}else alert("文件类型暂不支持,请上传如下类型文件:"+e.accept)}},wr=Zr=>{Zr.preventDefault(),Zr.stopPropagation(),Zr.target.files[0]&&$(Zr)};reactExports.useEffect(()=>{const Zr=new Image;Zr.src=a,Zr.onload=()=>{const tn=o/1.5/Zr.width,vn=s/1.5/Zr.height,zo=Math.min(vn,tn),Yo={image:Zr,x:(c.current.width-Zr.width*zo)/2,y:(c.current.height-Zr.height*zo)/2,width:Zr.width*zo,height:Zr.height*zo,scale:zo};at(Yo),st({x:Yo.x,y:Yo.y,width:Yo.width,height:Yo.height}),Wt(Yo),Nt(zo),et(!0),$t(Zr)}},[o,s,a]);const _o=Zr=>{Zr.preventDefault(),Ft&&(at(Ft),st({x:Ft.x,y:Ft.y,width:Ft.width,height:Ft.height}))},Jt=(Zr,tn)=>{const zo=tn.height/15,Yo=tn.width/15;for(let jo=0;jo{const tn=o/_t.width,vn=s/_t.height,zo=_t.width*tn,Yo=_t.height*vn;Zr.font="16px Arial",Zr.fillStyle="black",Zr.textAlign="right",Zr.font="12px Arial",Zr.fillText(`最大宽度: ${Math.round(zo/Pt)}px, 最大高度: ${Math.round(Yo/Pt)}px`,c.current.width-10,c.current.height-10)};reactExports.useEffect(()=>{const Zr=c.current,tn=Zr.getContext("2d");Zr.width=o,Zr.height=s,Jt(tn,Zr)},[]);const Ot=Zr=>{Zr.preventDefault(),Zr.stopPropagation();const vn=.01*(1024/_t.width),zo=Zr.clientX-c.current.getBoundingClientRect().left,Yo=Zr.clientY-c.current.getBoundingClientRect().top,jo=Zr.deltaY>0?-vn:vn;at(Ko=>{const Zo=Math.max(.02,Math.min(8,Ko.scale+jo)),Fo=_t.width*Zo,Js=_t.height*Zo,Ks=zo-(zo-Ko.x)*(Zo/Ko.scale),Dt=Yo-(Yo-Ko.y)*(Zo/Ko.scale);return{...Ko,x:Ks,y:Dt,width:Fo,height:Js,scale:Zo}})},gr=Zr=>{Zr.preventDefault();const tn={x:Zr.clientX-c.current.getBoundingClientRect().left,y:Zr.clientY-c.current.getBoundingClientRect().top},vn=8;if(Math.abs(tn.x-it.x){if(Zr.preventDefault(),wt){const jo=Zr.clientX-c.current.getBoundingClientRect().left,Ko=Zr.clientY-c.current.getBoundingClientRect().top;at(Zo=>({...Zo,x:jo-pt.x,y:Ko-pt.y}));return}if(!ct)return;const tn=Zr.clientX-c.current.getBoundingClientRect().left,vn=Zr.clientY-c.current.getBoundingClientRect().top,zo=tn+pt.x,Yo=vn+pt.y;st(jo=>{switch(pt.corner){case"topLeft":return{...jo,x:zo,y:Yo,width:jo.width+(jo.x-zo),height:jo.height+(jo.y-Yo)};case"topRight":return{...jo,y:Yo,width:zo-jo.x,height:jo.height+(jo.y-Yo)};case"bottomLeft":return{...jo,x:zo,width:jo.width+(jo.x-zo),height:Yo-jo.y};case"bottomRight":return{...jo,width:zo-jo.x,height:Yo-jo.y};default:return jo}})},On=()=>{ft(!1),vt(!1)};reactExports.useEffect(()=>{if(lt&&nt){const Zr=c.current,tn=Zr.getContext("2d");tn.clearRect(0,0,Zr.width,Zr.height),Jt(tn,Zr),tn.drawImage(nt.image,nt.x,nt.y,nt.width,nt.height),en(tn),Kr(tn)}},[nt,lt,it]);const en=Zr=>{const tn=c.current;Zr.clearRect(0,0,tn.width,tn.height),Jt(Zr,tn),Zr.drawImage(_t,nt.x,nt.y,nt.width,nt.height),Zr.strokeStyle="grey",Zr.lineWidth=2,Zr.strokeRect(it.x,it.y,it.width,it.height);const vn=8;Zr.fillStyle="blue",Zr.fillRect(it.x-vn/2,it.y-vn/2,vn,vn),Zr.fillRect(it.x+it.width-vn/2,it.y-vn/2,vn,vn),Zr.fillRect(it.x-vn/2,it.y+it.height-vn/2,vn,vn),Zr.fillRect(it.x+it.width-vn/2,it.y+it.height-vn/2,vn,vn)};function Lr(Zr,tn){const vn=document.createElement("canvas"),zo=vn.getContext("2d");return vn.width=Zr.width/tn,vn.height=Zr.height/tn,zo.drawImage(Zr,0,0,vn.width,vn.height),vn}const ko=Zr=>{Zr.preventDefault();const tn=document.createElement("canvas"),vn=tn.getContext("2d");tn.width=Math.round(it.width/Pt),tn.height=Math.round(it.height/Pt);const zo=Ft.width/nt.width,Yo=Lr(Ft.image,zo),jo=Yo.width,Ko=Yo.height,Zo=(nt.x-it.x)/Pt,Fo=(nt.y-it.y)/Pt;vn.drawImage(Yo,0,0,jo,Ko,Zo,Fo,jo,Ko),tn.toBlob(Js=>{const Ks=URL.createObjectURL(Js),Dt=document.createElement("a");Dt.href=Ks,Dt.download="saved-image.png",document.body.appendChild(Dt),Dt.click(),document.body.removeChild(Dt),URL.revokeObjectURL(Ks)},"image/png")},Ir=Zr=>{Zr.preventDefault();const tn=document.createElement("canvas"),vn=tn.getContext("2d");tn.width=Math.round(it.width/Pt),tn.height=Math.round(it.height/Pt);const zo=Ft.width/nt.width,Yo=Lr(Ft.image,zo),jo=Yo.width,Ko=Yo.height,Zo=(nt.x-it.x)/Pt,Fo=(nt.y-it.y)/Pt;vn.drawImage(Yo,0,0,jo,Ko,Zo,Fo,jo,Ko),tn.toBlob(Js=>{URL.createObjectURL(Js),document.createElement("a");const Ks=Dr("edited_.png"),Dt=new File([Js],Ks,{type:"image/png"});vr(Dt)},"image/png")};function Dr(Zr){const tn=new Date,vn=tn.getFullYear()+("0"+(tn.getMonth()+1)).slice(-2)+("0"+tn.getDate()).slice(-2)+"_"+("0"+tn.getHours()).slice(-2)+("0"+tn.getMinutes()).slice(-2)+("0"+tn.getSeconds()).slice(-2),zo=v4().replace(/-/g,""),Yo=`${vn}_${zo}_`,jo=Zr.split("/").pop();return`${Yo}${jo}`}return jsxRuntimeExports.jsxs("div",{style:{position:"relative",width:"canvasWidthpx",height:"canvasHeightpx",border:"1px solid black"},children:[jsxRuntimeExports.jsx("canvas",{ref:c,onWheel:Ot,onMouseDown:gr,onMouseMove:$o,onMouseUp:On}),jsxRuntimeExports.jsxs("div",{style:{position:"absolute",top:"5px",left:"0px",fontSize:"10px",color:"#787878"},children:[jsxRuntimeExports.jsx("span",{style:{display:"inline-block",padding:"0 10px"},children:"拖动四个角改变结果图大小,滚轮缩放原始图像,拖动图像改变位置,"}),jsxRuntimeExports.jsxs("div",{style:{fontSize:"10px",padding:"0 10px"},children:["宽: ",Math.round(it.width/Pt),"px, 高: ",Math.round(it.height/Pt),"px; 原图在新图中坐标:( ",Math.round((nt.x-it.x)/Pt),", ",Math.round((nt.y-it.y)/Pt)," )"]}),jsxRuntimeExports.jsx("input",{type:"file",ref:Lt,style:{display:"none"},onChange:Zr=>{wr(Zr)}})]}),jsxRuntimeExports.jsx("div",{className:"newfileInput",children:jsxRuntimeExports.jsx("button",{onClick:Zr=>{Zr.preventDefault(),Lt.current.click()},children:"新建上传"})}),jsxRuntimeExports.jsxs("div",{className:"newfileInputCon",children:[jsxRuntimeExports.jsx("button",{onClick:Zr=>_o(Zr),style:{color:"#2C5ECE"},children:"复原"}),jsxRuntimeExports.jsx("button",{onClick:Zr=>ko(Zr),style:{color:"#31BE4B"},children:"下载"}),jsxRuntimeExports.jsx("button",{onClick:Zr=>Ir(Zr),style:{color:"#787878"},children:"确认"})]})]})}function EditableImage({index:e,param:o,handleInputChange:s,previewUrl:a}){const[$,c]=reactExports.useState(!1),nt=reactExports.useRef(null),at=ft=>{ft.preventDefault(),c(!0)},lt=ft=>{ft.preventDefault(),c(!1)},et=ft=>{ft.preventDefault()},it=ft=>{ft.preventDefault(),c(!1);const pt=ft.dataTransfer.files[0];if(pt){const gt=o.accept.split(","),wt=pt.name.split(".").pop().toLowerCase();if(gt==""||gt.includes(`.${wt}`)){const vt={target:{name:o.name,files:[pt]}};s(e,vt)}else alert("文件类型暂不支持,请上传如下类型文件:"+o.accept)}},st=ft=>async pt=>{await s(ft,pt)},ct=ft=>{ft.preventDefault(),ft.target.files[0]&&s(e,ft)};return jsxRuntimeExports.jsxs("div",{className:`my-file-drop-area ${$?"dragging":""}`,onDragEnter:at,onDragLeave:lt,onDragOver:et,onDrop:it,onClick:()=>{a||nt.current.click()},style:{position:"relative",minHeight:window.innerWidth>1e3?"500px":"320px",maxWidth:"100%",maxHeight:"100%"},children:[jsxRuntimeExports.jsx("input",{type:"file",ref:nt,style:{display:"none"},name:o.name,accept:o.accept,onChange:ft=>ct(ft)}),a?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ImageEditor,{param:o,canvasHeight:window.innerWidth>1e3?480:300,canvasWidth:window.innerWidth>1e3?320:200,url:a,handleChanged:st(e)}),jsxRuntimeExports.jsx("button",{type:"button",className:"cancel",onClick:ft=>{ft.stopPropagation(),nt.current.value="",s(e,null)},style:{position:"absolute",top:"10px",right:"10px",padding:"2px",fontSize:"10px",borderRadius:"5%",backgroundColor:"#ccc",border:"none",cursor:"pointer"},children:"X"})]}):jsxRuntimeExports.jsx("p",{style:{textAlign:"center",margin:0,fontSize:"13px"},children:"+"})]})}const DynamicParameterRender=({params:e,setParamFunc:o,template_id:s=null,is_author:a=!1})=>{const $=api$1.get("userType"),[c,nt]=reactExports.useState([]),[at,lt]=reactExports.useState({}),et=reactExports.useRef(null);reactExports.useState(!0);let it=new AbortController;reactExports.useEffect(()=>{it=new AbortController;const _t=it.signal;return pt(e,_t).then($t=>{if(_t.aborted)throw new Error("Fetch aborted");JSON.stringify(e)!==JSON.stringify($t)&&o&&o($t)}).catch($t=>{console.error("Failed to update parameters:",$t)}),()=>{it.abort()}},[e]);const st=async(_t,$t)=>{const Pt={};et.current=Pt;const Nt=e.findIndex(Wt=>Wt.maskSourceUrl===e[_t].name);let Lt=null;Nt>=0&&(Lt=null);const Ft=await Promise.all(e.map(async(Wt,vr)=>{try{if(_t===vr||vr==Nt)if(Wt.type==="file"||Wt.type==="combo_image_selection"||Wt.type==="image_editer"){if($t===void 0||$t==null){const{value:wr,..._o}=Wt;Wt=_o}else if($t.target.files[0])try{let wr=$t.target.files[0];const _o=URL.createObjectURL(wr);if(wr.type.startsWith("image/")){const Jt=await loadImage(_o),{height:Kr,width:Ot,samScale:gr}=handleImageScale(Jt);wr=await resizeImage(Jt,Ot,Kr,wr),saveFile(wr.file,`${wr.name}_${wr.type}_${wr.size}`)}else wr={file:wr,name:wr.name,size:wr.size,type:wr.type},saveFile(wr.file,`${wr.name}_${wr.type}_${wr.size}`);URL.revokeObjectURL(_o),Wt={...Wt,value:wr}}catch(wr){throw console.error("Error processing image:",wr),URL.revokeObjectURL(objectURL),wr}return Wt}else if(Wt.type==="mask")if(vr==Nt&&($t=Lt),$t)if($t.target.files.length>0){let wr=[];for(let _o=0;_o<$t.target.files.length;_o++){const Jt=$t.target.files[_o];if(Jt){const Kr={file:Jt,name:Jt.name,size:Jt.size,type:Jt.type},Ot=`${Kr.name}_${Kr.type}_${Kr.size}`;await saveFile(Kr.file,Ot),wr.push(Kr)}else Jt==""?wr.push(Wt.value?.[_o]):wr.push(null)}return Wt={...Wt,value:wr},Wt}else return Wt;else return Wt={...Wt,value:[null,null]},Wt;else if(Wt.type==="workflow"){if(vr==Nt)if($t)try{$t=await ct($t.target.files[0])}catch(wr){console.error("workflow is error:",wr),$t=[]}else $t=[];return Wt={...Wt,value:$t},Wt}else return Wt={...Wt,value:$t},Wt;return Wt}catch(wr){console.error("Error handling input change:",wr)}}));et.current!=Pt&&console.log("canceld input change: params are ",Ft),o&&o(Ft)},ct=async _t=>{try{if(!_t)return[];let $t=await transformNodesFromFile(_t);return console.log("Returned transformed nodes:",$t),$t}catch($t){throw console.error("Error:",$t),alert($t),$t}},ft=async(_t,$t,Pt)=>{if(Pt.aborted)throw new Error("Fetch aborted");if((_t.type==="file"||_t.type==="combo_image_selection"||_t.type==="image_editer")&&_t.value){let Nt=`${_t.value.name}_${_t.value.type}_${_t.value.size}`,Lt=_t.value.name?(await getLocalResourceURL(`${_t.value.name}_${_t.value.type}_${_t.value.size}`,s)).url:null;if(Nt!=`${_t.value.name}_${_t.value.type}_${_t.value.size}`)throw console.error("changed "+Nt),new Error("Fetch aborted already changed. ");if(Pt.aborted)throw new Error("Fetch aborted");if(Lt){const Ft=e.findIndex(Wt=>Wt.maskSourceUrl===_t.name);nt(Wt=>{const vr=[...Wt];return vr[$t]=Lt,Ft>=0&&(vr[Ft]=`${_t.value.name}_${_t.value.type}_${_t.value.size}`),vr})}}else(_t.type==="file"||_t.type==="combo_image_selection"||_t.type==="mask"||_t.type==="image_editer")&&!_t.value&&nt(Nt=>{const Lt=[...Nt];Lt[$t]=null;const Ft=e.findIndex(Wt=>Wt.maskSourceUrl===_t.name);return Ft>=0&&(Lt[Ft]=null),Lt});return _t},pt=async(_t,$t)=>{const Pt=_t.map(async(Nt,Lt)=>{if($t.aborted)throw new Error("Fetch aborted");if((Nt.type==="selection"||Nt.type==="image_selection")&&!Nt.value)try{const Ft=JSON.parse(Nt.options||Nt.default);if(Array.isArray(Ft))return{...Nt,value:Ft[0].value}}catch{const Wt=(Nt.options||Nt.default||"").split(",")[0].trim();return{...Nt,value:Wt}}else{if(Nt.type==="text"&&(Nt.value===void 0||Nt.value==null))return{...Nt,value:Nt.default};if(Nt.type==="file"||Nt.type==="combo_image_selection"||Nt.type==="mask"||Nt.type==="image_editer")return await ft(Nt,Lt,$t)}return Nt});if($t.aborted)throw new Error("Fetch aborted");return Promise.all(Pt)},gt=_t=>async $t=>{await st(_t,$t)},wt=(_t,$t)=>{const Pt={...at,[_t]:$t};lt(Pt);const Nt=e.map((Lt,Ft)=>_t===Ft&&(Lt.type==="image_selection"||Lt.type==="combo_image_selection")?{...Lt,value:$t}:Lt);o&&o(Nt)},vt=()=>{const _t=e.map((Lt,Ft)=>{switch(Lt.type){case"text":return jsxRuntimeExports.jsxs("div",{style:{height:($=="user"||$=="guest")&&Lt.visibleToUser==0?"0px":"fit-content"},children:[jsxRuntimeExports.jsx("div",{className:styles.form_label_con,children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,style:{fontSize:"12px"},children:[Lt.name,": "]})}),jsxRuntimeExports.jsx("textarea",{rows:1,className:"parameter_input_medium",style:{display:"block",marginLeft:"20px"},type:"text",name:Lt.name,placeholder:"请输入文字,地方不够,请拖动右下角",defaultValue:Lt.value||Lt.default||Lt.accept||"",onBlur:Wt=>st(Ft,Wt.target.value),onInput:Wt=>{Wt.target.style.height="auto",Wt.target.style.height=Wt.target.scrollHeight+"px"},onFocus:Wt=>{Wt.target.style.height="auto",Wt.target.style.height=Wt.target.scrollHeight+"px"}})]},Ft+JSON.stringify(Lt));case"selection":return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{className:styles.form_label_con,style:{marginTop:"20px"},children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,children:[Lt.name,": "]})]}),jsxRuntimeExports.jsx("select",{name:Lt.name,className:"dropdown_container_search",value:Lt.value,onChange:Wt=>st(Ft,Wt.target.value),children:(()=>{try{const Wt=JSON.parse(Lt.options||Lt.default);if(console.log(1),Array.isArray(Wt))return Wt.map((vr,wr)=>jsxRuntimeExports.jsx("option",{value:vr.value,children:vr.option},wr))}catch{return(Lt.options||Lt.default||"").split(",").map((vr,wr)=>jsxRuntimeExports.jsx("option",{value:vr.trim(),children:vr.trim()},wr))}})()})]},Ft+JSON.stringify(Lt));case"image_selection":return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:styles.item_title_area,style:{padding:"5px 10px"},children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,children:[Lt.name,": "]})}),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:(()=>{try{const Wt=JSON.parse(Lt.options||Lt.default||"{}");if(Array.isArray(Wt))return jsxRuntimeExports.jsx(ImageList,{optionsObject:Wt,param:Lt,handleImageSelect:wt,paramIndex:Ft})}catch{return(Lt.options||Lt.default||"").split(",").map((vr,wr)=>jsxRuntimeExports.jsx("div",{className:styles.image_option,children:jsxRuntimeExports.jsx("img",{src:vr.trim(),alt:`Option ${wr+1}`,onClick:()=>wt(Ft,vr.trim()),className:Lt.value===vr.trim()?styles.image_selected:""},wr)},wr))}})()})]},Ft+JSON.stringify(Lt));case"combo_image_selection":return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{className:styles.form_label_con,style:{marginTop:"20px"},children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,children:[Lt.name,": "]})]}),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(ComboImageList,{optionsObject:Lt.options||Lt.default||"[]",param:Lt,paramIndex:Ft,handleImageSelect:wt,handleInputChange:st,uploadPreviewUrl:c[Ft]},Ft)})]},Ft+JSON.stringify(Lt));case"file":return jsxRuntimeExports.jsxs("div",{style:{minHeight:window.innerWidth>1e3?Lt.name=="图标"||Lt.accept.includes("json")?"100px":"550px":Lt.name=="图标"||Lt.accept&&Lt.accept.includes("json")?"30px":"350px",height:$!="admin"&&Lt.visibleToUser==0&&!a?"0px":"fit-content"},children:[($=="admin"||Lt.visibleToUser!==0||a)&&Lt.name!="图标"&&jsxRuntimeExports.jsx("div",{className:styles.item_title_area,style:{padding:"20px"},children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,children:[Lt.name,": "]})}),jsxRuntimeExports.jsx("div",{style:{height:window.innerWidth>1e3?$!="admin"&&Lt.visibleToUser==0&&!a?"0px":Lt.name=="图标"||Lt.accept&&Lt.accept.includes("json")?"60px":"500px":$!="admin"&&Lt.visibleToUser==0&&!a?"0px":Lt.name=="图标"||Lt.accept.includes("json")?"60px":"300px"},children:o&&jsxRuntimeExports.jsx(FileUpload,{index:Ft,param:Lt,handleInputChange:st,previewUrl:c[Ft],visible:$=="admin"||Lt.visibleToUser!=0||a,verbose:!0},Ft)})]},Ft+JSON.stringify(Lt));case"image_editer":return jsxRuntimeExports.jsxs("div",{style:{minHeight:window.innerWidth>1e3?"550px":"350px",height:"fit-content",width:"100%",minWidth:"fit-content"},id:"dddd",children:[jsxRuntimeExports.jsx("div",{className:styles.item_title_area,style:{padding:"10px 10px 0 10px"},children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,children:[Lt.name,": "]})}),o&&jsxRuntimeExports.jsx(EditableImage,{index:Ft,param:Lt,handleInputChange:st,previewUrl:c[Ft]},Ft)]},Ft+JSON.stringify(Lt));case"mask":return jsxRuntimeExports.jsxs("div",{style:{minHeight:window.innerWidth>1e3?"550px":"350px",height:"fit-content"},children:[jsxRuntimeExports.jsx("div",{className:styles.item_title_area,style:{padding:"10px 10px 0 10px"},children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,children:[Lt.name,": "]})}),jsxRuntimeExports.jsx("div",{style:{height:window.innerWidth>1e3?"500px":"300px"},children:o&&jsxRuntimeExports.jsx(Segment,{param:Lt,index:Ft,handleInputChange:st,sourceImageID:c[Ft],template_id:s},Ft)})]},Ft);case"workflow":return jsxRuntimeExports.jsxs("div",{style:{height:"fit-content"},children:[jsxRuntimeExports.jsxs("div",{className:styles.form_label_con,style:{},children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,children:[Lt.name,": "]})]}),jsxRuntimeExports.jsx("div",{style:{height:"fit-content"},children:o&&jsxRuntimeExports.jsx(DynamicParameterRender,{params:Lt.value,index:Ft,setParamFunc:gt(Ft),template_id:s},Ft+JSON.stringify(Lt)+"workflow")})]},Ft+JSON.stringify(Lt));default:return null}}),$t=[];let Pt=0,Nt=["image_selection","combo_image_selection","workflow"];for(;Pt<_t.length;)Nt.includes(e[Pt].type)?($t.push(jsxRuntimeExports.jsx("div",{style:{marginBottom:"25px",height:"fit-content"},className:"rightItenBottom",children:_t[Pt]},Pt)),Pt++):($=="user"||$=="guest")&&e[Pt].visibleToUser==0||e[Pt].type==="file"&&Pt+1<_t.length&&_t[Pt+1]&&!["file","mask"].includes(e[Pt+1].type)?($t.push(jsxRuntimeExports.jsxs("div",{className:"leftItemTop",children:[jsxRuntimeExports.jsxs("div",{className:styles.form_label_con,children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsxs("label",{className:styles.form_label,children:["参数",jsxRuntimeExports.jsx("span",{style:{fontSize:"9px"},children:" (选填)"})]})]}),jsxRuntimeExports.jsx("div",{className:styles.compileCon,style:{display:"flex",marginBottom:"5px",height:$!="admin"&&e[Pt].visibleToUser==0&&!a?"0px":"fit-content"},children:jsxRuntimeExports.jsx("div",{style:{width:"90%",height:$!="admin"&&e[Pt].visibleToUser==0&&!a?"0px":"fit-content"},children:_t[Pt]})},Pt)]})),Pt++):($t.push(jsxRuntimeExports.jsxs("div",{id:"asasad",className:styles.compileCon,style:{width:"90%",marginBottom:"5px",height:"fit-content",marginTop:e[Pt].name==="图标"?"30px":"0",boxShadow:e[Pt].name==="图标"?"none":"0px 2px 4px 0px rgba(0,0,0,0.16)",border:e[Pt].name==="图标"?"1px solid #afafbc":"none",borderRadius:e[Pt].name==="图标"?"10px":"0 0 10px 10px",marginLeft:e[Pt].name==="图标"?"10px":"0"},children:[jsxRuntimeExports.jsx("div",{style:{height:"fit-content"},children:_t[Pt]}),jsxRuntimeExports.jsx("div",{style:{height:"fit-content"},children:Pt+1<_t.length&&_t[Pt+1]})]},Pt)),Pt+=2);return $t};return jsxRuntimeExports.jsx("form",{id:"dynamicForm",style:{width:"100%"},children:vt()})};function ImageDisplayCombo({file:e,watermark:o=!1}){const[s,a]=reactExports.useState(""),[$,c]=reactExports.useState(!1),[nt,at]=reactExports.useState(!0);reactExports.useEffect(()=>(fileDisplayAble(e)?fetchAndSetImage(e).then(it=>a(it)).catch(console.error):at(!1),()=>s&&URL.revokeObjectURL(s)),[e.id,e.type,e.name]);const lt=it=>{it.preventDefault(),c(!0),document.body.style.cursor="zoom-out"},et=()=>{c(!1),document.body.style.cursor="pointer"};return jsxRuntimeExports.jsxs("div",{style:{maxWidth:"100%",height:"auto"},children:[s?jsxRuntimeExports.jsx(MediaDisplay,{url:s,type:e.type,muted:!0,controls:!0,autoplay:!0,watermark:o,onMediaClick:lt}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:nt?jsxRuntimeExports.jsx("div",{children:"加载中..."}):jsxRuntimeExports.jsx("div",{children:"点击下载..."})}),jsxRuntimeExports.jsx(Popup,{visible:$,position:"bottom",style:{zIndex:1e6},bodyStyle:{width:"100%",height:"100%"},destroyOnClose:!0,closeOnMaskClick:!0,showCloseButton:!0,children:jsxRuntimeExports.jsx(ImageModal,{closeModal:et,imageUrl:s,filetype:e.type})})]})}function Files({files:e,downloadFile:o,returnResourceIcon:s,shareContent:a=null}){const $=api$1.get("userType");return jsxRuntimeExports.jsxs("div",{className:"gridContainer_resouce_new",children:[" ",e&&e.filter(c=>!c.name.endsWith(".npy")&&!c.name.endsWith(".json")).map(c=>jsxRuntimeExports.jsxs("div",{children:[" ",jsxRuntimeExports.jsxs("div",{className:styles.history_box,children:[" ",jsxRuntimeExports.jsx(ImageDisplayCombo,{file:c,watermark:$=="guest"}),jsxRuntimeExports.jsx("div",{style:{display:"flex",cursor:"pointer"},children:jsxRuntimeExports.jsxs("div",{className:styles.picListBot,children:[jsxRuntimeExports.jsx("div",{style:{fontSize:"10px",color:"#787878"},className:styles.single_line_block,onClick:()=>o(c.id,c.name),children:c.name}),jsxRuntimeExports.jsxs("div",{style:{fontSize:"9px",textAlign:"right"},onClick:()=>o(c.id,c.name),className:styles.downBth,children:[c.type.split("/")[1],c.size!==""?` • ${formatBytes(c.size)}`:"",jsxRuntimeExports.jsxs("span",{children:["点击下载",$=="user"||$=="guest"?"(含水印)":""]})]}),($=="user"||$=="guest")&&jsxRuntimeExports.jsxs("div",{style:{fontSize:"9px",textAlign:"right"},onClick:()=>o(c.id,c.name),className:styles.downBth,children:[c.type.split("/")[1],c.size!==""?` • ${formatBytes(c.size)}`:"",jsxRuntimeExports.jsx("span",{children:"注册去水印下载"})]}),a&&jsxRuntimeExports.jsx("div",{style:{fontSize:"9px",padding:"5px"},children:jsxRuntimeExports.jsx("button",{onClick:()=>a(c.id),style:{background:"#4591ee",width:"100%",border:"none",color:"#fff",borderRadius:"8px",padding:"7px 25px",fontSize:"12px"},children:"发布"})})]})})]})]},c.id))]})}function ResourceList({files:e,channel:o,runs:s,runid:a,selectedRunStatus:$,share:c=!0}){const[nt,at]=reactExports.useState(null),lt=reactExports.useMemo(()=>s.map(st=>{const ct=e.filter(ft=>ft.agent_execution_id===st.id);return ct.length!==0&&{run:st,files:ct}}).filter(Boolean),[e,s]),et=(st,ct)=>{const ft=e.filter(pt=>pt.agent_execution_id===st);ft.length!==0&&downloadAllFiles(ft,ct)},it=e.some(st=>st.agent_execution_id!==null);return jsxRuntimeExports.jsxs("div",{id:"resource-list",children:[o==="output"&&(!it||e.length<=0?jsxRuntimeExports.jsx("div",{className:"horizontal_space_between flex_wrap",children:$!=="ERROR_PAUSED"&&$!=="COMPLETED"&&$!=="TERMINATED"&&$!=="ITERATION_LIMIT_EXCEEDED"?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("span",{className:"feed_title mt_8",children:"尚未执行完毕.或者没有输出文件."})}),jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("img",{style:{width:"34px",height:"34px"},loading:"lazy",className:"mix_blend_mode",src:`${WEB_SITE}/images/loading.gif`,alt:"active-icon",tyle:{float:"left"}})})]}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("span",{className:"feed_title mt_8",children:"已经结束!"})})})}):jsxRuntimeExports.jsx("div",{id:"division_by_runs",className:"horizontal_space_between flex_wrap",children:lt.map((st,ct)=>jsxRuntimeExports.jsx("div",{style:{width:"100%"},children:st.run.id===a&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"horizontal_container justify_space_between cursor_pointer padding_8_6",onClick:()=>at(st.run.id===a?null:st.run.id),children:[jsxRuntimeExports.jsx("div",{className:"horizontal_container",children:jsxRuntimeExports.jsx("img",{src:a===st.run.id?`${WEB_SITE}/images/arrow_downward_dropdown.svg`:`${WEB_SITE}/images/arrow_forward.svg`,alt:"arrow",style:{width:"14px",height:"14px"}})}),jsxRuntimeExports.jsx("img",{src:`${WEB_SITE}/images/download.svg`,alt:"download_icon",style:{width:"20px",height:"21px"},onClick:()=>et(st.run.id,st.run.name)})]}),jsxRuntimeExports.jsx(Files,{files:st.files,downloadFile,returnResourceIcon,shareContent:c?shareContent:null})]})},lt.length-ct-1))})),o==="input"&&e&&jsxRuntimeExports.jsx(Files,{files:e,downloadFile,returnResourceIcon})]})}function ResourceManager({agentId:e,runs:o,runid:s,selectedRunStatus:a,share:$=!0}){const[c,nt]=reactExports.useState([]),[at,lt]=reactExports.useState([]);reactExports.useState("input"),reactExports.useState(!1),reactExports.useRef(null),reactExports.useEffect(()=>{const it=window.setInterval(function(){a!=="ERROR_PAUSED"&&a!=="COMPLETED"&&a!=="TERMINATED"&&a!=="ITERATION_LIMIT_EXCEEDED"&&et()},5e3);return()=>clearInterval(it)},[s,a]),reactExports.useEffect(()=>{et()},[e]);function et(){getResources(e).then(it=>{const st=it.data,ct=st.filter(pt=>pt.channel==="INPUT"),ft=st.filter(pt=>pt.channel==="OUTPUT");lt(ct),nt(ft)}).catch(it=>{console.error("Error fetching resources:",it)})}return jsxRuntimeExports.jsxs("div",{className:"sectionCon",children:[jsxRuntimeExports.jsxs("div",{className:"section-area",children:[jsxRuntimeExports.jsx("div",{className:"detail_top mb_10",children:jsxRuntimeExports.jsxs("div",{className:"documentTitle",children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("span",{children:"运行结果"})]})}),jsxRuntimeExports.jsx("div",{className:"w_100 mr_10 mb_20",children:jsxRuntimeExports.jsx(ResourceList,{files:c,channel:"output",runs:o,runid:s,selectedRunStatus:a,share:$})})]}),jsxRuntimeExports.jsxs("div",{className:"section-area",children:[jsxRuntimeExports.jsx("div",{className:"detail_top mb_10 width=100%",children:jsxRuntimeExports.jsxs("div",{className:"documentTitle",children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("span",{children:"原始文件"})]})}),jsxRuntimeExports.jsx("div",{className:"w_100 mr_10 mb_20",children:jsxRuntimeExports.jsx(ResourceList,{files:at,channel:"input",runs:o,selectedRunStatus:a})})]}),jsxRuntimeExports.jsx(k$1,{})]})}function AgentExecutionChecker({executionId:e,targetStatus:o,runAction:s,intervalTime:a}){reactExports.useEffect(()=>{const $=window.setInterval(async()=>{try{const c=await getExecution(e);o.includes(c.data.status)&&(s(c.data.status),clearInterval($))}catch(c){console.error("Error fetching execution:",c)}},a);return()=>clearInterval($)},[e,o,s,a])}const WorkerAdmin=({sj_display:e,onUpdateDialog:o,onCloseWorkerAdmin:s,isvisible:a})=>{const[$,c]=reactExports.useState(!1);reactExports.useState("1");const[nt,at]=reactExports.useState(localStorage.getItem("keyHuaxiaobao")=="null"?null:localStorage.getItem("keyHuaxiaobao")),[lt,et]=reactExports.useState(localStorage.getItem("accessTokenHuaxiaobao")=="null"?null:localStorage.getItem("accessTokenHuaxiaobao")),[it,st]=reactExports.useState(null),[ct,ft]=reactExports.useState(null),[pt,gt]=reactExports.useState(null),[wt,vt]=reactExports.useState(null),[_t,$t]=reactExports.useState(null),[Pt,Nt]=reactExports.useState(null),[Lt,Ft]=reactExports.useState(null),[Wt,vr]=reactExports.useState(["百变真我学习趣味爱情节日短视频电商音乐电商跳舞其他","百变真我","学习","趣味","爱情","节日","短视频","电商","音乐","跳舞","其他"]),[wr,_o]=reactExports.useState(!1),[Jt,Kr]=reactExports.useState(!1),Ot=reactExports.useRef(null);reactExports.useRef(null),reactExports.useRef(null),reactExports.useRef(null);const[gr,$o]=reactExports.useState(!1),[On,en]=reactExports.useState(0),[Lr,ko]=reactExports.useState(localStorage.getItem("usernameHuaxiaobao")=="null"?null:localStorage.getItem("usernameHuaxiaobao")),[Ir,Dr]=reactExports.useState(localStorage.getItem("usernameHuaxiaobao")=="null"?null:localStorage.getItem("usernameHuaxiaobao")+"的一件精品"),[Zr,tn]=reactExports.useState("我想为你作一件事.."),[vn,zo]=reactExports.useState("百变真我"),[Yo,jo]=reactExports.useState([{name:"图标",type:"file",accept:".png,.jpg,.jpeg,.webp,.gif"}]);reactExports.useEffect(()=>{(async()=>{try{const In=await getFileObject("newlogo1.png_image/png_70522");if(In){jo([{name:"图标",type:"file",value:{file:In,name:In.name,type:In.type,size:In.size},accept:".png,.jpg,.jpeg,.webp,.gif"}]);return}else{const rn=await fetch(`${WEB_SITE}/logo/newlogo1.png`);if(!rn.ok)throw new Error("Failed to fetch logo");const Yr=await rn.blob(),Io=new File([Yr],"newlogo1.png",{type:"image/png"});saveFile(Io,`${Io.name}_${Io.type}_${Io.size}`),jo([{name:"图标",type:"file",value:{file:Io,name:Io.name,type:Io.type,size:Io.size},accept:".png,.jpg,.jpeg,.webp,.gif"}])}}catch(In){console.error("Error fetching logo:",In)}})()},[]);const Ko=_r=>{Nt(_r),_r=="COMPLETED"?(document.getElementById("trial").disabled=!1,document.getElementById("trial").innerText="运行完毕,再来一遍",document.getElementById("publish")&&(document.getElementById("publish").disabled=!1,document.getElementById("publish").innerText="运行完毕,可以定价上架啦!")):alert("出现错误:",_r)},Zo=async _r=>{create_order_debug({id:1001,price:0,pre_price:0,amount:1,description:_r}).then(rn=>{rn.data.result.startsWith("SUCCESS"),console.log(rn.data.result)}).catch(rn=>{console.error("Error adding user:",rn)})};reactExports.useEffect(()=>{c(a)},[a]);const Fo=_r=>{ft(_r)},Js=_r=>{jo(_r)},Ks=()=>{if(!it)return alert("请在工作流内部添加参数标记节点,可以看帮助或者咨询客服微信v:aizhaoshulin了解"),!1;if(Ir?.replace(/\s/g,"")==="")return alert("任务名称不能为空"),!1;if(Zr?.replace(/\s/g,"")==="")return alert("任务描述不能为空"),!1;if(!Yo[0].value)return alert("请添加logo"),!1;for(let _r of Yo)if(_r.type==="file"&&_r.value===void 0)return alert(_r.name+":图标(logo)中必须输入合适文件"),!1;return!0};reactExports.useEffect(()=>{const _r=async rn=>{const Yr=await window.comfyui_app.graphToPrompt();console.log("MoneySetting initialized with response:",Yr);let Io=JSON.stringify(Yr.output,null,2);if(Object.values(Yr.output).some(Bo=>Bo.class_type==="ComfyUIAppstoreHost"))alert("请删除您的ComfyUIWebHost节点");else{console.log("No ComfyUIWebHost item found in the output.");const Bo=Math.max(...Object.keys(Yr.output).map(So=>parseInt(So)));Yr.output[Bo+1]={inputs:{"ComfyUI 主机地址":rn+".shangxiaobao.com:7000"},class_type:"ComfyUIAppstoreHost",_meta:{title:"ComfyUI Appstore Host (ComfyUI_Appstore)"}},Io=JSON.stringify(Yr.output,null,2);const Ao=new Blob([Io],{type:"application/json"}),Qo=new File([Ao],"workflow_api.json",{type:"application/octet-stream"});console.log("MoneySetting initialized with response:",Yr);try{const So=await transformNodesFromFile(Ao);ft(So),st(Qo)}catch(So){console.error("workflow not ready:",So)}}};(async()=>{const Yr=await fetch("/manager/asset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(!Yr.ok)throw new Error(`HTTP error! status: ${Yr.status}`);const Io=await Yr.json(),Bo=Io.message,Ao=Io.data;Bo=="success"&&(gt(Ao),_r(Ao))})()},[]);const Dt=async _r=>{if(!Ks())return;_r.preventDefault();const In=[{name:"工作流文件的名称",type:"file",value:{file:it,name:it.name,type:it.type,size:it.size},visibleToUser:0},{maskSourceUrl:"工作流文件的名称",name:"工作的配置",type:"workflow",value:ct,visibleToUser:1}],rn={token:nt,name:Ir,description:Zr,category:vn,host:pt,parameter:In,logo:Yo||[]};try{const Yr=await fetch(`${API_BASE_URL}agents/create_workflow_agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(rn)});if(!Yr.ok)throw new Error(`HTTP error! status: ${Yr.status}`);const Io=await Yr.json();console.log("Form submitted successfully");const Bo=Io.id,Ao=Io.name,Qo=Io.execution_id;vt(Bo),uploadParameterFiles(In,Bo),uploadLogos(Yo,Bo,!1),updateExecution(Qo,{status:"RUNNING"}).then(So=>{document.getElementById("trial").disabled=!0,document.getElementById("trial").innerText="正在运行",document.getElementById("publish")&&(document.getElementById("publish").disabled=!0,document.getElementById("publish").innerText="等运行完毕后,即可上架"),$t(Qo),Nt(null)}).catch(So=>{alert("失败"),console.error("Error updating execution:",So)}),console.log("Server response:",Io)}catch(Yr){console.error("Error submitting form:",Yr)}},Eo=_r=>{setLocalStorageValue("agent_category",Wt[_r],zo),_o(!1)};reactExports.useEffect(()=>{function _r(In){Ot.current&&!Ot.current.contains(In.target)&&_o(!1)}return document.addEventListener("mousedown",_r),()=>{document.removeEventListener("mousedown",_r)}},[]);const Jr=(_r,In)=>{publishToMarketplace(_r,parseFloat(In)).then(rn=>{Ft(rn.data.id),$o(!1)}).catch(rn=>{console.error("Error publishing to marketplace:",rn)})},ar=()=>{$o(!1)},er=_r=>{en(_r.target.value)};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[gr&&jsxRuntimeExports.jsx("div",{className:"modal",style:{height:"100%",zIndex:1999999999999},children:jsxRuntimeExports.jsxs("div",{className:"modal-content",style:{width:"75%"},onClick:_r=>_r.preventDefault(),children:[jsxRuntimeExports.jsx("div",{className:styles.detail_name,children:"准备好了吗?发布到市场!"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("label",{className:styles.form_label,children:"价格"}),jsxRuntimeExports.jsx("input",{className:"input_medium",type:"text",value:On,onChange:er})]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",justifyContent:"flex-end"},children:[jsxRuntimeExports.jsx("button",{className:"secondary_button",style:{marginRight:"10px"},onClick:ar,children:"取消"}),jsxRuntimeExports.jsxs("button",{className:styles.run_button,style:{paddingLeft:"15px",paddingRight:"25px"},onClick:()=>Jr(_t,On),children:[jsxRuntimeExports.jsx("img",{style:{width:"14px",height:"14px"},src:`${WEB_SITE}/images/run_icon.svg`,alt:"run-icon"})," 发布"]})]})]})}),jsxRuntimeExports.jsxs(Popup,{visible:$,position:"right",bodyStyle:{direction:"ltl",paddingTop:"10px",zIndex:1999999999998,width:"50vw",height:"100vh",backgroundColor:"white",position:"fixed",right:"0px",top:"0px",overflow:"auto",padding:"10px 10px"},destroyOnClose:!1,children:[Jt&&jsxRuntimeExports.jsx("div",{className:"modal",children:jsxRuntimeExports.jsxs("div",{className:"modal-content",style:{width:"75%"},onClick:_r=>_r.preventDefault(),children:[jsxRuntimeExports.jsx("div",{className:styles.detail_name,children:"在工作流中需要用户输入的节点后面挂一个 ComfyUI Appstore Param 节点,选择丰富的类型,即可变成用户的丰富界面!"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("label",{className:styles.form_label,children:"加VX群了解"}),jsxRuntimeExports.jsx("img",{style:{width:"90%",cursor:"pointer"},src:"https://huaxiaobao.net/logo/dev_wechat.png"}),jsxRuntimeExports.jsx("br",{}),jsxRuntimeExports.jsx("label",{className:styles.form_label,children:"或者直接查看文档和帮助视频"}),jsxRuntimeExports.jsx("img",{src:`${WEB_SITE}/help/help.png`,onClick:()=>window.open("https://huaxiaobao.net/?category=help","_blank"),style:{width:"20px",height:"20px",cursor:"pointer"}})]}),jsxRuntimeExports.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:jsxRuntimeExports.jsx("button",{className:styles.run_button,style:{paddingLeft:"15px",paddingRight:"25px"},onClick:()=>Kr(!1),children:"  OK"})})]})}),jsxRuntimeExports.jsx("div",{style:{padding:"10px"},children:jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{style:{paddingBottom:"20px"},children:[jsxRuntimeExports.jsx("span",{style:{display:"none"}}),jsxRuntimeExports.jsxs("div",{className:"documentTitle",children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("span",{children:"画小宝,ComfyUI作者变现的平台"}),jsxRuntimeExports.jsx("img",{src:`${WEB_SITE}/help/help2.png`,onClick:()=>window.open("https://huaxiaobao.net/?category=help","_blank"),style:{marginTop:"5px",width:"20px",height:"20px",cursor:"pointer",borderRadius:"50%"},onMouseOver:_r=>{_r.currentTarget.src=`${WEB_SITE}/logo/dev_qq.png`,_r.currentTarget.style.width="200px",_r.currentTarget.style.borderRadius="10px",_r.currentTarget.style.height="auto"},onMouseOut:_r=>{_r.currentTarget.src=`${WEB_SITE}/help/help2.png`,_r.currentTarget.style.width="20px",_r.currentTarget.style.borderRadius="50%",_r.currentTarget.style.height="auto"}})]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[jsxRuntimeExports.jsxs("span",{children:[" ","画小宝 huaxiaobao.net 逛逛,马上入驻开店,开启工作流,开始赚钱"]}),jsxRuntimeExports.jsx("span",{style:{cursor:"pointer",fontStyle:"italic"},onClick:()=>window.open("https://huaxiaobao.net/?category=Help_Page","_blank"),children:"享受万元流量奖励"})]})]}),jsxRuntimeExports.jsxs("div",{className:"documentTitle",children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("span",{children:"第一步,游客登录,或者注册用户"})]}),!Lr&&jsxRuntimeExports.jsxs("div",{id:"huaxiaobao_guest",style:{border:"dotted",borderWidth:"thin"},children:[jsxRuntimeExports.jsxs("span",{style:{display:"block"},children:["选项一:游客就可以玩,马上点击即获得价值10元”墨宝“奖励,优点:方便,缺点,只能这台机器玩"," "]}),jsxRuntimeExports.jsx("button",{id:"loginGuestButton",className:"secondary_button",onClick:async()=>{var _r="Guest_"+Math.random().toString(36).substr(2,9);document.getElementById("loginGuestButton").textContent="登录中";const rn=await(await fetch(`${API_BASE_URL}register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:_r,smsCode:"Gues",password:_r})})).json();rn.key?(console.log("Login successful, key:",rn.key),document.querySelector("button").style.display="none",document.getElementById("huaxiaobao_login").style.display="none",document.getElementById("huaxiaobao_guest").style.display="none",document.getElementById("huaxiaobao_token").style.display="block",document.getElementById("huaxiaobao_token").textContent=` 游客已登录,请记录画小宝账号信息:用户名:${_r} 密码:${_r}`,setLocalStorageValue("accessTokenHuaxiaobao",rn.token,et),setLocalStorageValue("usernameHuaxiaobao",_r,ko),setLocalStorageValue("keyHuaxiaobao",rn.key,at),Dr(_r+"的一个精品"),Zo(pt)):console.error("Login failed")},children:"一键登录"})]}),jsxRuntimeExports.jsx("span",{id:"huaxiaobao_token",style:{display:Lr?"block":"none"},children:Lr&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("br",{}),Lr,' + "已经登录"',jsxRuntimeExports.jsx("button",{style:{marginRight:"7px"},className:"secondary_button",onClick:()=>{setLocalStorageValue("usernameHuaxiaobao",null,ko)},children:"登出"})]})}),!Lr&&jsxRuntimeExports.jsxs("div",{id:"huaxiaobao_login",style:{border:"dotted",borderWidth:"thin"},children:[jsxRuntimeExports.jsxs("span",{style:{display:"block"},children:["选项二:画小宝登录,或者注册, 马上获得价值50元“墨宝奖励”"," "]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"row",height:"100%"},children:[jsxRuntimeExports.jsx("label",{children:"手机号:"}),jsxRuntimeExports.jsx("input",{style:{width:"150px",fontSize:"13px"},className:"input_medium",type:"text",id:"username",placeholder:"输入手机号"}),jsxRuntimeExports.jsx("label",{children:"密码:"}),jsxRuntimeExports.jsx("input",{style:{width:"150px",fontSize:"13px"},className:"input_medium",type:"password",id:"password",placeholder:"输入密码"})]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"row",height:"100%"},children:[jsxRuntimeExports.jsx("button",{id:"loginButton",className:"secondary_button",onClick:async()=>{const In=await(await fetch(`${API_BASE_URL}login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:document.getElementById("username").value,password:document.getElementById("password").value})})).json();In.key?(console.log("Login successful"),document.querySelectorAll("label").forEach(rn=>rn.style.display="none"),document.getElementById("huaxiaobao_login").style.display="none",document.getElementById("huaxiaobao_guest").style.display="none",document.getElementById("huaxiaobao_token").style.display="block",document.getElementById("huaxiaobao_token").textContent=" 正式用户登录",setLocalStorageValue("accessTokenHuaxiaobao",In.token,et),setLocalStorageValue("usernameHuaxiaobao",document.getElementById("username").value,ko),setLocalStorageValue("keyHuaxiaobao",In.key,at),Dr(document.getElementById("username").value+"的一个精品"),Zo(pt)):(alert("用户名密码不正确,请重试"),console.error("Login failed"))},children:"登录"}),jsxRuntimeExports.jsx("button",{className:"secondary_button",onClick:()=>window.open("https://huaxiaobao.net/?register","_blank"),children:"注册"})]})]})]})}),Lr&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{style:{padding:"10px"},children:[jsxRuntimeExports.jsxs("div",{className:"documentTitle",children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("span",{children:"第二步,修改工作流,标记参数并测试"})]}),jsxRuntimeExports.jsxs("div",{style:{marginTop:"10px",width:"100%",textAlign:"left",fontSize:"12px",height:"100%",background:"#324d61"},className:styles.compileCon,children:[jsxRuntimeExports.jsxs("div",{className:styles.form_label_con,children:[it?jsxRuntimeExports.jsx("span",{style:{cursor:"pointer"},children:"下面是显示给用户的区域:这里是跟着工作流中的appstore节点设定变化的。"}):jsxRuntimeExports.jsx("span",{style:{cursor:"pointer"},children:"请在工作流内部添加参数标记节点Appstore Param节点,可以看帮助或者咨询客服微信v:aizhaoshulin了解"}),jsxRuntimeExports.jsx("img",{src:`${WEB_SITE}/help/help.png`,onClick:()=>window.open("https://huaxiaobao.net/?category=Help_Page","_blank"),style:{width:"20px",height:"20px",cursor:"pointer"}})]}),jsxRuntimeExports.jsx("div",{style:{margin:"5px"},children:ct&&jsxRuntimeExports.jsx(DynamicParameterRender,{params:ct,setParamFunc:Fo})})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%"},children:[jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"row",height:"100%"},children:[jsxRuntimeExports.jsxs("div",{style:{marginTop:"10px",width:"100%",textAlign:"left",fontSize:"12px",height:"100%"},className:styles.compileCon,children:[jsxRuntimeExports.jsx("div",{className:styles.form_label_con,children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,style:{fontSize:"12px"},children:["名称:"," "]})}),jsxRuntimeExports.jsx("input",{className:"input_medium",type:"text",value:Ir,onChange:_r=>Dr(_r.target.value),style:{fontSize:"13px"},placeholder:"简洁的名称,例子,马良的画笔"})]}),jsxRuntimeExports.jsxs("div",{style:{marginTop:"10px",width:"100%",textAlign:"left",fontSize:"12px",height:"100%"},className:styles.compileCon,children:[jsxRuntimeExports.jsx("div",{className:styles.form_label_con,children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,style:{fontSize:"12px"},children:["分类"," "]})}),jsxRuntimeExports.jsxs("div",{className:"dropdown_container_search",style:{width:"90%"},children:[jsxRuntimeExports.jsxs("div",{className:"custom_select_container",onClick:()=>_o(!wr),children:[vn,jsxRuntimeExports.jsx("img",{style:{width:"20px",height:"21px"},src:wr?WEB_SITE+"/images/dropdown_up.svg":WEB_SITE+"/images/dropdown_down.svg",alt:"expand-icon"})]}),jsxRuntimeExports.jsx("div",{children:wr&&jsxRuntimeExports.jsx("div",{className:"custom_select_options",ref:Ot,style:{width:"100%"},children:jsxRuntimeExports.jsx("div",{className:"model_options",children:Wt.slice(1).map((_r,In)=>jsxRuntimeExports.jsx("div",{className:"custom_select_option",onClick:()=>Eo(In+1),style:{maxWidth:"100%"},children:_r},In+1))})})})]})]})]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"row",height:"100%"},children:[jsxRuntimeExports.jsxs("div",{style:{marginTop:"10px",width:"100%",textAlign:"left",fontSize:"12px",height:"100%"},className:styles.compileCon,children:[jsxRuntimeExports.jsx("div",{className:styles.form_label_con,children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,style:{fontSize:"12px"},children:["简介:"," "]})}),jsxRuntimeExports.jsx("textarea",{value:Zr,className:"textarea_medium",rows:8,style:{fontSize:"13px"},onChange:_r=>tn(_r.target.value),placeholder:"来两句介绍,功能和亮点!更有助于吸引用户"})]}),jsxRuntimeExports.jsxs("div",{style:{marginTop:"10px",width:"100%",textAlign:"left",fontSize:"12px",height:"100%"},className:styles.compileCon,children:[jsxRuntimeExports.jsx("div",{className:styles.form_label_con,children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,style:{fontSize:"12px"},children:["Logo"," "]})}),jsxRuntimeExports.jsx(DynamicParameterRender,{params:Yo,setParamFunc:Js,is_author:!0})]})]})]}),jsxRuntimeExports.jsx("div",{style:{display:"flex",flexDirection:"row",height:"100%"},children:jsxRuntimeExports.jsx("button",{id:"trial",className:"button_auth",style:{width:"100%"},onClick:_r=>Dt(_r),children:"试运行"})})]})]}),_t&&jsxRuntimeExports.jsx(ResourceManager,{agentId:wt,runs:[{id:_t}],runid:_t,share:!1})]}),Lr&&_t&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(AgentExecutionChecker,{executionId:_t,targetStatus:["ERROR_PAUSED","COMPLETED","TERMINATED","ITERATION_LIMIT_EXCEEDED"],runAction:Ko,intervalTime:5e3}),jsxRuntimeExports.jsxs("div",{style:{padding:"10px"},children:[jsxRuntimeExports.jsxs("div",{className:"documentTitle",children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("span",{children:"第三步,准备上架和赚钱"})]}),jsxRuntimeExports.jsx("button",{id:"publish",disabled:Pt!="COMPLETED",style:{marginRight:"7px",width:"100%"},className:"button_auth",onClick:()=>{$o(!0)},children:"运行完毕后, 上架售卖!"}),jsxRuntimeExports.jsx("br",{}),jsxRuntimeExports.jsx("br",{}),jsxRuntimeExports.jsx("br",{}),Lt&&jsxRuntimeExports.jsx("button",{style:{marginRight:"7px",width:"100%"},className:"button_auth",onClick:()=>window.open(MARKETPLACE_SITE+"/?category=Create_Agent&targetid="+Lt,"_blank"),children:"已经发布! 查看市场!"})]})]})]})]})},App=()=>{const[e,o]=reactExports.useState({right:10,top:120}),[s,a]=reactExports.useState(!1),$=reactExports.useRef(!1),c=reactExports.useRef({x:0,y:0}),nt=(it,st)=>{let ct=0;return(...ft)=>{const pt=new Date().getTime();pt-ct{it.button===0&&(it.stopPropagation(),$.current=!0,c.current={x:it.clientX,y:it.clientY})},lt=nt(it=>{$.current&&o(st=>{const ct=st.right-(it.clientX-c.current.x),ft=st.top+(it.clientY-c.current.y);return c.current={x:it.clientX,y:it.clientY},{right:ct,top:ft}})},30),et=()=>{$.current&&($.current=!1,console.log("Mouse Up: Stop Dragging"))};return reactExports.useEffect(()=>(document.addEventListener("mousemove",lt),document.addEventListener("mouseup",et),()=>{document.removeEventListener("mousemove",lt),document.removeEventListener("mouseup",et)}),[]),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(WorkerAdmin,{isvisible:s},s),jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"row",position:"fixed",zIndex:0x71afd498cffff,backgroundColor:"transparent",right:`${e.right}px`,top:`${e.top}px`,height:"60px",cursor:"pointer"},onMouseDown:at,children:[jsxRuntimeExports.jsx("div",{style:{borderRadius:"10px",height:"30px"},children:jsxRuntimeExports.jsx("img",{style:{marginTop:"3px",borderRadius:"10px",height:"100%",pointerEvents:"none"},src:`${WEB_SITE}/logo/simplelogo.png`})}),jsxRuntimeExports.jsx("div",{className:"secondary_button",style:{opacity:"0.4"},onClick:()=>{s?window.confirm("关闭后当前结果将不再保存,确认吗?")&&a(!s):a(!s)},children:s?"收起":"Appstore"}),jsxRuntimeExports.jsx("div",{style:{borderRadius:"50%",height:"30px"},children:jsxRuntimeExports.jsx("img",{src:`${WEB_SITE}/help/help2.png`,onClick:()=>window.open("https://huaxiaobao.net/?category=help","_blank"),style:{marginTop:"5px",width:"20px",height:"20px",cursor:"pointer",borderRadius:"50%"},onMouseOver:it=>{it.currentTarget.src=`${WEB_SITE}/logo/dev_qq.png`,it.currentTarget.style.width="200px",it.currentTarget.style.borderRadius="10px",it.currentTarget.style.height="auto"},onMouseOut:it=>{it.currentTarget.src=`${WEB_SITE}/help/help2.png`,it.currentTarget.style.width="20px",it.currentTarget.style.borderRadius="50%",it.currentTarget.style.height="auto"}})})]})]})},root=client.createRoot(document.getElementById("admin-app-appstore"));root.render(jsxRuntimeExports.jsx(GlobalProvider,{children:jsxRuntimeExports.jsx(App,{})})); +`+c+"}",lt}function result(e,o,s){o=toPath(o);var a=o.length;if(!a)return isFunction$1(s)?s.call(e):s;for(var $=0;$1)flatten$1(at,o-1,s,a),$=a.length;else for(var lt=0,et=at.length;lto?(a&&(clearTimeout(a),a=null),at=it,nt=e.apply($,c),a||($=c=null)):!a&&s.trailing!==!1&&(a=setTimeout(lt,st)),nt};return et.cancel=function(){clearTimeout(a),at=0,a=$=c=null},et}function debounce(e,o,s){var a,$,c,nt,at,lt=function(){var it=now()-$;o>it?a=setTimeout(lt,o-it):(a=null,s||(nt=e.apply(at,c)),a||(c=at=null))},et=restArguments(function(it){return at=this,c=it,$=now(),a||(a=setTimeout(lt,o),s&&(nt=e.apply(at,c))),nt});return et.cancel=function(){clearTimeout(a),a=c=at=null},et}function wrap(e,o){return partial(o,e)}function negate(e){return function(){return!e.apply(this,arguments)}}function compose(){var e=arguments,o=e.length-1;return function(){for(var s=o,a=e[o].apply(this,arguments);s--;)a=e[s].call(this,a);return a}}function after(e,o){return function(){if(--e<1)return o.apply(this,arguments)}}function before(e,o){var s;return function(){return--e>0&&(s=o.apply(this,arguments)),e<=1&&(o=null),s}}const once=partial(before,2);function findKey(e,o,s){o=cb(o,s);for(var a=keys(e),$,c=0,nt=a.length;c0?0:$-1;c>=0&&c<$;c+=e)if(s(o[c],c,o))return c;return-1}}const findIndex=createPredicateIndexFinder(1),findLastIndex=createPredicateIndexFinder(-1);function sortedIndex(e,o,s,a){s=cb(s,a,1);for(var $=s(o),c=0,nt=getLength(e);c0?nt=c>=0?c:Math.max(c+at,nt):at=c>=0?Math.min(c+1,at):c+at+1;else if(s&&c&&at)return c=s(a,$),a[c]===$?c:-1;if($!==$)return c=o(slice.call(a,nt,at),isNaN$1),c>=0?c+nt:-1;for(c=e>0?nt:at-1;c>=0&&c0?0:at-1;for(c||($=s[nt?nt[lt]:lt],lt+=e);lt>=0&<=3;return o(s,optimizeCb(a,c,4),$,nt)}}const reduce=createReduce(1),reduceRight=createReduce(-1);function filter(e,o,s){var a=[];return o=cb(o,s),each(e,function($,c,nt){o($,c,nt)&&a.push($)}),a}function reject(e,o,s){return filter(e,negate(cb(o)),s)}function every(e,o,s){o=cb(o,s);for(var a=!isArrayLike(e)&&keys(e),$=(a||e).length,c=0;c<$;c++){var nt=a?a[c]:c;if(!o(e[nt],nt,e))return!1}return!0}function some(e,o,s){o=cb(o,s);for(var a=!isArrayLike(e)&&keys(e),$=(a||e).length,c=0;c<$;c++){var nt=a?a[c]:c;if(o(e[nt],nt,e))return!0}return!1}function contains(e,o,s,a){return isArrayLike(e)||(e=values(e)),(typeof s!="number"||a)&&(s=0),indexOf(e,o,s)>=0}const invoke=restArguments(function(e,o,s){var a,$;return isFunction$1(o)?$=o:(o=toPath(o),a=o.slice(0,-1),o=o[o.length-1]),map(e,function(c){var nt=$;if(!nt){if(a&&a.length&&(c=deepGet(c,a)),c==null)return;nt=c[o]}return nt==null?nt:nt.apply(c,s)})});function pluck(e,o){return map(e,property(o))}function where(e,o){return filter(e,matcher(o))}function max(e,o,s){var a=-1/0,$=-1/0,c,nt;if(o==null||typeof o=="number"&&typeof e[0]!="object"&&e!=null){e=isArrayLike(e)?e:values(e);for(var at=0,lt=e.length;ata&&(a=c)}else o=cb(o,s),each(e,function(et,it,st){nt=o(et,it,st),(nt>$||nt===-1/0&&a===-1/0)&&(a=et,$=nt)});return a}function min(e,o,s){var a=1/0,$=1/0,c,nt;if(o==null||typeof o=="number"&&typeof e[0]!="object"&&e!=null){e=isArrayLike(e)?e:values(e);for(var at=0,lt=e.length;atat||nt===void 0)return 1;if(nt1&&(a=optimizeCb(a,o[1])),o=allKeys(e)):(a=keyInObj,o=flatten$1(o,!1,!1),e=Object(e));for(var $=0,c=o.length;$1&&(a=o[1])):(o=map(flatten$1(o,!1,!1),String),s=function($,c){return!contains(o,c)}),pick(e,s,a)});function initial(e,o,s){return slice.call(e,0,Math.max(0,e.length-(o==null||s?1:o)))}function first(e,o,s){return e==null||e.length<1?o==null||s?void 0:[]:o==null||s?e[0]:initial(e,e.length-o)}function rest(e,o,s){return slice.call(e,o==null||s?1:o)}function last(e,o,s){return e==null||e.length<1?o==null||s?void 0:[]:o==null||s?e[e.length-1]:rest(e,Math.max(0,e.length-o))}function compact(e){return filter(e,Boolean)}function flatten(e,o){return flatten$1(e,o,!1)}const difference=restArguments(function(e,o){return o=flatten$1(o,!0,!0),filter(e,function(s){return!contains(o,s)})}),without=restArguments(function(e,o){return difference(e,o)});function uniq(e,o,s,a){isBoolean(o)||(a=s,s=o,o=!1),s!=null&&(s=cb(s,a));for(var $=[],c=[],nt=0,at=getLength(e);nt"u"?it={autoBom:!1}:typeof it!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),it={autoBom:!it}),it.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(et.type)?new Blob(["\uFEFF",et],{type:et.type}):et}function a(et,it,st){var ct=new XMLHttpRequest;ct.open("GET",et),ct.responseType="blob",ct.onload=function(){lt(ct.response,it,st)},ct.onerror=function(){console.error("could not download file")},ct.send()}function $(et){var it=new XMLHttpRequest;it.open("HEAD",et,!1);try{it.send()}catch{}return 200<=it.status&&299>=it.status}function c(et){try{et.dispatchEvent(new MouseEvent("click"))}catch{var it=document.createEvent("MouseEvents");it.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),et.dispatchEvent(it)}}var nt=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof commonjsGlobal=="object"&&commonjsGlobal.global===commonjsGlobal?commonjsGlobal:void 0,at=nt.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),lt=nt.saveAs||(typeof window!="object"||window!==nt?function(){}:"download"in HTMLAnchorElement.prototype&&!at?function(et,it,st){var ct=nt.URL||nt.webkitURL,ft=document.createElement("a");it=it||et.name||"download",ft.download=it,ft.rel="noopener",typeof et=="string"?(ft.href=et,ft.origin===location.origin?c(ft):$(ft.href)?a(et,it,st):c(ft,ft.target="_blank")):(ft.href=ct.createObjectURL(et),setTimeout(function(){ct.revokeObjectURL(ft.href)},4e4),setTimeout(function(){c(ft)},0))}:"msSaveOrOpenBlob"in navigator?function(et,it,st){if(it=it||et.name||"download",typeof et!="string")navigator.msSaveOrOpenBlob(s(et,st),it);else if($(et))a(et,it,st);else{var ct=document.createElement("a");ct.href=et,ct.target="_blank",setTimeout(function(){c(ct)})}}:function(et,it,st,ct){if(ct=ct||open("","_blank"),ct&&(ct.document.title=ct.document.body.innerText="downloading..."),typeof et=="string")return a(et,it,st);var ft=et.type==="application/octet-stream",pt=/constructor/i.test(nt.HTMLElement)||nt.safari,gt=/CriOS\/[\d]+/.test(navigator.userAgent);if((gt||ft&&pt||at)&&typeof FileReader<"u"){var wt=new FileReader;wt.onloadend=function(){var $t=wt.result;$t=gt?$t:$t.replace(/^data:[^;]*;/,"data:attachment/file;"),ct?ct.location.href=$t:location=$t,ct=null},wt.readAsDataURL(et)}else{var vt=nt.URL||nt.webkitURL,_t=vt.createObjectURL(et);ct?ct.location=_t:location.href=_t,ct=null,setTimeout(function(){vt.revokeObjectURL(_t)},4e4)}});nt.saveAs=lt.saveAs=lt,e.exports=lt})})(FileSaver_min);var FileSaver_minExports=FileSaver_min.exports;const Segment=({param:e,index:o,handleInputChange:s,sourceImageID:a,template_id:$=null})=>{const[c,nt]=reactExports.useState([]),[at,lt]=reactExports.useState(null),[et,it]=reactExports.useState(null),[st,ct]=reactExports.useState(null),[ft,pt]=reactExports.useState(null),gt=useModel(),[wt,vt]=reactExports.useState(null),[_t,$t]=reactExports.useState(null),[Pt,Nt]=reactExports.useState({});reactExports.useState(null),reactExports.useState(null);const[Lt,Ft]=reactExports.useState(null),[Wt,vr]=reactExports.useState(null),[wr,_o]=reactExports.useState(null),[Jt,Kr]=reactExports.useState(null),[Ot,gr]=reactExports.useState(null),[$o,On]=reactExports.useState(null),en=reactExports.useRef(null),Lr=reactExports.useRef(null),[ko,Ir]=reactExports.useState("/api/resources/proxyurl/shangxiaobao.com:9001"),Dr=reactExports.useRef(null),Zr=reactExports.useRef(null);reactExports.useEffect(()=>{(()=>{const _n=document.createElement("script");_n.src=`${WEB_SITE}/assets/opencv.js`,_n.async=!0,_n.onload=()=>{console.log("OpenCV.js loaded")},document.body.appendChild(_n)})()},[]),reactExports.useEffect(()=>{},[]),reactExports.useEffect(()=>{console.log("new source iamge id",a);const So={};Dr.current=So,(!a||et)&&(Kr(generateUniqueFilename("_embeddings.npy")),gr(generateUniqueFilename("_mask.png")),it(null),ct(null),$t(null),nt([]),Nt({}),pt(null),lt(null),vt(null),vr(null)),a&&getLocalResourceURL(a,$).then(_n=>{if(Dr.current!=So){console.log("cancel executions.",a);return}if(_o(_n.url),vn(_n.url),(!e.value||!e.value[1]||!e.value[1].name||$o)&&Zo(new URL(_n.url),So),Dr.current!=So){console.log("cancel executions.",a);return}On(a)})},[a]),reactExports.useEffect(()=>{const So={};Zr.current=So,(async Do=>{if(!Lt&&!Wt&&e&&e.value&&Array.isArray(e.value)&&e.value.length>0&&e.value[1]){let Xo={url:null,file:null},Lo={url:null,file:null};if(Zr.current!==Do){console.log("quit1");return}if(e.value[0]&&e.value[0].name){if(Xo=await getLocalResourceURL(`${e.value[0].name}_${e.value[0].type}_${e.value[0].size}`,$),Zr.current!==Do){console.log("quit1");return}zo(Xo.url),Ft(Xo.file)}if(Zr.current!==Do){console.log("quit2");return}if(e.value[1]&&e.value[1].name){if(Lo=await getLocalResourceURL(`${e.value[1].name}_${e.value[1].type}_${e.value[1].size}`,$),Zr.current!==Do){console.log("quit1");return}vr(Lo.file),tn(Lo.file)}if(Zr.current!==Do){console.log("quit3");return}s(o,{target:{name:Xo.file&&Xo.file.name?Xo.file.name:"mask.file",files:[Xo?.file,Lo.file]}})}else console.log("legacy flow.")})(So)},[e]),reactExports.useEffect(()=>{const So=()=>{et&&et.width/et.height},_n=new ResizeObserver(Do=>{for(const Xo of Do)Xo.target===document.body&&So()});return So(),_n.observe(document.body),()=>{_n.unobserve(document.body)}},[et]);const tn=async So=>{if(So)try{const _n=await Yo(So),Do=await Js(_n,"float32");vt(Do)}catch(_n){alert("internal error"),console.error("Failed to load tensor:",_n)}},vn=async So=>{try{if(!So)return;const _n=new Image;_n.src=new URL(So).href,_n.onload=()=>{const{height:Do,width:Xo,samScale:Lo}=Fo(_n);$t({height:Do,width:Xo,samScale:Lo}),_n.width=Xo,_n.height=Do,it(_n)}}catch(_n){console.log(_n)}},zo=async So=>{try{if(!So){ct(null);return}const _n=new Image;_n.src=new URL(So).href,_n.onload=()=>{ct(_n)}}catch(_n){console.log(_n)}};function Yo(So){return new Promise((_n,Do)=>{const Xo=new FileReader;Xo.onload=Lo=>{_n(Lo.target.result)},Xo.onerror=Lo=>{Do(Lo)},Xo.readAsArrayBuffer(So)})}async function jo(So,_n){try{const Do=new Blob([So],{type:"application/octet-stream"}),Xo=Jt,Lo=new File([Do],Xo,{type:"application/octet-stream"});if(Dr.current!==_n){console.log("canceld:",Lo);return}if(vr(Lo),tn(Lo),Dr.current!==_n){console.log("canceld:",Lo);return}console.log("seding param change :",Lo),s(o,{target:{name:Ot,files:[null,Lo]}}),ct(null)}catch(Do){console.error("Error saving ArrayBuffer:",Do)}}const Ko=async So=>{const _n=await fetch(So).then(Lo=>Lo.blob()),Do=new File([_n],"mask.png",{type:"image/png"}),Xo=new FormData;return Xo.append("file",_n),Xo.append("name",Do.name),Xo.append("size",Do.size),Xo.append("type",Do.type),Xo},Zo=async(So,_n)=>{const Do=await Ko(So);let Xo=0;for(;Xo<3;){try{if(Dr.current!==_n)return;let Lo=await fetch(`${MARKETPLACE_SITE}${ko}/getembeddings_refined`,{method:"POST",body:Do});if(Lo.ok){const Jo=await Lo.arrayBuffer();jo(Jo,_n);break}else alert("网络阻塞,重试一下就好 ..."),console.error("Failed to get embeddings:",Lo.statusText)}catch(Lo){alert("网络阻塞,重试一下就好 ..."),console.error("Error loading image tensor:",Lo)}Xo+=1}},Fo=So=>{let Do=So.naturalWidth,Xo=So.naturalHeight;const Lo=1024/Math.max(Xo,Do);return{height:Xo,width:Do,samScale:Lo}},Js=async(So,_n)=>{const Xo=await new npyjs().load(So);return new yt(_n,Xo.data,Xo.shape)};reactExports.useEffect(()=>{if(c){const So=In();if(So){const _n=rn(So);_n.onload=()=>{const Do=document.createElement("canvas"),Xo=Do.getContext("2d");Do.width=So.width,Do.height=So.height,Xo.fillStyle="white",Xo.fillRect(0,0,Do.width,Do.height),Xo.drawImage(_n,0,0);try{if(window.cv&&window.cv.imread){const Lo=window.cv.imread(Do);if(Lo.empty())console.error("The source matrix is empty.");else{const Jo=new window.cv.Mat;window.cv.cvtColor(Lo,Jo,window.cv.COLOR_RGBA2GRAY,0);const Xs=new window.cv.Mat,na=new window.cv.Size(5,5);window.cv.GaussianBlur(Jo,Xs,na,0,0,window.cv.BORDER_DEFAULT);const ba=window.cv.Mat.ones(5,5,window.cv.CV_8U),ga=new window.cv.Mat;window.cv.morphologyEx(Xs,ga,window.cv.MORPH_CLOSE,ba);const eu=new window.cv.Mat;window.cv.threshold(ga,eu,127,255,window.cv.THRESH_BINARY),window.cv.imshow(Do,eu),Lo.delete(),Jo.delete(),Xs.delete(),ga.delete(),eu.delete(),ba.delete()}}else console.error("OpenCV.js is not loaded properly.")}catch(Lo){console.error("OPENCV ERROR:",Lo)}Do.toBlob(Lo=>{if(Lo){const Jo=Ot,Xs=new File([Lo],Jo,{type:"image/png"});Ft(Xs),s(o,{target:{name:Ot,files:[Xs,Wt]}})}},"image/png")},ct(_n)}else ct(null)}},[c]),reactExports.useEffect(()=>{if(!at){pt(null);return}if(gt===null||wt===null||_t===null)return;(async()=>{const _n=await ar({x:at.x,y:at.y}),Do=rn(_n);pt(Do)})()},[at]),reactExports.useEffect(()=>{if(!st)return;const So=new window.Image;So.src=st.src,So.onload=()=>{const _n=en.current;if(!_n)return;const Do=_n.getContext("2d");_n.width=So.width,_n.height=So.height,Do.drawImage(So,0,0);const Xo=Do.getImageData(0,0,_n.width,_n.height),Lo=Xo.data;for(let Jo=0;Jo{if(So.preventDefault(),!st)return;const _n=document.createElement("canvas");_n.width=st.width,_n.height=st.height;const Do=_n.getContext("2d");Do.drawImage(st,0,0);const Xo=Do.getImageData(0,0,st.width,st.height).data,Lo=document.createElement("canvas");Lo.width=st.width,Lo.height=st.height;const Jo=Lo.getContext("2d");Jo.drawImage(et,0,0,st.width,st.height);const Xs=Jo.getImageData(0,0,st.width,st.height).data;for(let na=0;na{const ba=URL.createObjectURL(na),ga=document.createElement("a");ga.download="extracted_areas.png",ga.href=ba,ga.click()},"image/png")},Dt=async So=>{if(gt===null||wt===null||_t===null)return;So.preventDefault();const _n=So.currentTarget.getBoundingClientRect(),Do=(So.clientX-_n.left)*(_t.width/_n.width),Xo=(So.clientY-_n.top)*(_t.height/_n.height);if(So.button===0){const Lo=[...c,Jr(Do,Xo)];let Jo=await ar({x:Do,y:Xo});Nt({...Pt,[`${Do},${Xo},1`]:Jo}),nt(Lo)}else if(So.button===2){const Lo=[...c,Jr(Do,Xo,-1)];let Jo=await ar({x:Do,y:Xo});Nt({...Pt,[`${Do},${Xo},-1`]:Jo}),nt(Lo)}},Eo=So=>{So.preventDefault()},Jr=(So,_n,Do=1)=>({x:So,y:_n,clickType:Do}),ar=async({x:So,y:_n})=>{try{if(gt===null||wt===null||_t===null)return;const Do=[Jr(So,_n)],Xo=modelData({clicks:Do,tensor:wt,modelScale:_t});if(Xo===void 0)return;const Jo=(await gt.run(Xo))[gt.outputNames[0]];return er(Jo.data,Jo.dims[2],Jo.dims[3])}catch(Do){console.log(Do)}return null};function er(So,_n,Do){const[Xo,Lo,Jo,Xs]=[0,114,189,255],na=new Uint8ClampedArray(4*_n*Do).fill(0);for(let ba=0;ba0&&(na[4*ba+0]=Xo,na[4*ba+1]=Lo,na[4*ba+2]=Jo,na[4*ba+3]=Xs);return new ImageData(na,Do,_n)}function _r(So){const _n=document.createElement("canvas");return _n.width=So.width,_n.height=So.height,_n.getContext("2d").putImageData(So,0,0),_n}const In=()=>{if(Object.keys(Pt).length===0)return null;if(gt===null||wt===null||_t===null)return;Pt[Object.keys(Pt)[0]];const So=et.width,_n=et.height,Do=document.createElement("canvas");Do.getContext("2d"),Do.width=So,Do.height=_n;const Xo=new Uint8ClampedArray(4*So*_n).fill(0);return Object.entries(Pt).forEach(([Jo,Xs])=>{const ba=_r(Xs).getContext("2d").getImageData(0,0,So,_n).data,ga=parseInt(Jo.split(",")[2]);if(ga===-1)for(let eu=0;eu0&&(Xo[eu+3]=0);else if(ga===1)for(let eu=0;eu0&&(Xo[eu+3]=255)}),new ImageData(Xo,So,_n)};function rn(So){const _n=_r(So),Do=new Image;return Do.src=_n.toDataURL(),Do}const Yr=So=>{if(So.preventDefault(),!st)return;const _n=document.createElement("canvas"),Do=_n.getContext("2d");if(_n.width=st.width,_n.height=st.height,Do.fillStyle="white",Do.fillRect(0,0,_n.width,_n.height),Do.drawImage(st,0,0),window.cv)try{const Xo=window.cv.imread(_n),Lo=new window.cv.Mat;window.cv.cvtColor(Xo,Lo,window.cv.COLOR_RGBA2GRAY,0);const Jo=new window.cv.Mat,Xs=new window.cv.Size(5,5);window.cv.GaussianBlur(Lo,Jo,Xs,0,0,window.cv.BORDER_DEFAULT);const na=window.cv.Mat.ones(5,5,window.cv.CV_8U),ba=new window.cv.Mat;window.cv.morphologyEx(Jo,ba,window.cv.MORPH_CLOSE,na);const ga=new window.cv.Mat;window.cv.threshold(ba,ga,127,255,window.cv.THRESH_BINARY),window.cv.imshow(_n,ga);const eu=_n.toDataURL("image/png");Xo.delete(),Lo.delete(),Jo.delete(),ba.delete(),ga.delete(),na.delete();const mu=Io(eu);let gu=generateUniqueFilename("mask.png");FileSaver_minExports.saveAs(mu,gu)}catch(Xo){console.error("OPENCV ERROR:",Xo),_n.toBlob(Lo=>{let Jo=generateUniqueFilename("mask.png");FileSaver_minExports.saveAs(Lo,Jo)},"image/png")}};function Io(So){const _n=atob(So.split(",")[1]),Do=new Array(_n.length);for(let Lo=0;Lo<_n.length;Lo++)Do[Lo]=_n.charCodeAt(Lo);const Xo=new Uint8Array(Do);return new Blob([Xo],{type:"image/png"})}const Bo=So=>{So.preventDefault(),ct(null),nt([]),Nt({}),pt(null),lt(null),Ft(null),s(o,{target:{name:Ot,files:[null,Wt]}})},Ao=_.throttle(So=>{if(gt===null||wt===null||_t===null)return;let _n=So.nativeEvent.target;const Do=_n.getBoundingClientRect();let Xo=So.clientX-Do.left,Lo=So.clientY-Do.top;const Jo=et?et.width/_n.offsetWidth:1;Xo*=Jo,Lo*=Jo;const Xs=Jr(Xo,Lo);Xs&<(Xs)},15),Qo=So=>{console.log("out"),lt(null),pt(null)};return reactExports.useState(null),reactExports.useState(500),jsxRuntimeExports.jsxs("div",{className:"my-file-drop-area",children:[(!wt||!gt||!_t)&&jsxRuntimeExports.jsx("div",{style:{fontSize:"14px",textAlign:"center",padding:"20px",zIndex:999,backgroundColor:"rgba(255, 255, 255, 0.9)"},children:et?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("img",{style:{width:"20px",height:"20px"},loading:"lazy",className:"mix_blend_mode",src:`${WEB_SITE}/images/loading.gif`,alt:"active-icon"}),window.innerWidth>1e3?"蒙版加载中,大概需要10-20秒,然后移动鼠标,稍作等待后,蓝色区域为备选区域(左键是加选,右键是减选),红色是已选区域(即:在结果中保留的部分)":"红色已选,点击选择"]}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:window.innerWidth>1e3?"这里是左边的原图的蒙版选择区域,红色选中的区域在结果图中不会变。 ":"蒙版"})}),wt&>&&_t&&at==null&&window.innerWidth>1e3&&jsxRuntimeExports.jsx("div",{style:{fontSize:"14px",textAlign:"center",padding:"20px",zIndex:999,backgroundColor:"rgba(255, 255, 255, 0.4)"},children:et?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:window.innerWidth>1e3?"挪动鼠标,蓝色为待选区域,红色为结果图中不变的区域,左键➕,右键➖":"点击选择蒙版"}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:window.innerWidth>1e3?"这里是左边的原图的蒙版选择区域,红色选中的区域在结果图中不会变。 ":"蒙版"})}),!1,st&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("button",{onClick:Yr,style:{position:"absolute",top:"20px",left:0,background:"#31BE4B",border:"none",borderRadius:"4px",color:"#FFFFFF",margin:window.innerWidth>1e3?"10px":"0px",fontSize:"10px",zIndex:999},children:"下载"}),jsxRuntimeExports.jsx("button",{onClick:Ks,style:{position:"absolute",top:"50px",left:0,background:"#2C5ECE",border:"none",borderRadius:"4px",color:"#ffffff",margin:window.innerWidth>1e3?"10px":"0px",fontSize:"10px",zIndex:999},children:"剪裁"}),jsxRuntimeExports.jsx("button",{onClick:Bo,style:{position:"absolute",top:"80px",left:0,background:"#E6E6E6",border:"none",borderRadius:"4px",color:"#787878",margin:window.innerWidth>1e3?"10px":"0px",fontSize:"10px",zIndex:999},children:"清空"})]}),et&&jsxRuntimeExports.jsx("img",{src:et.src,name:"sourceimage",style:{position:"absolute",height:"auto",width:"auto",maxWidth:"100%",maxHeight:"100%",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}}),st&&jsxRuntimeExports.jsx("canvas",{ref:en,style:{position:"absolute",height:"auto",width:"auto",maxWidth:"100%",maxHeight:"100%",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}}),ft&&jsxRuntimeExports.jsx("img",{src:ft.src,style:{position:"absolute",height:"auto",width:"auto",maxWidth:"100%",maxHeight:"100%",opacity:"0.5",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}}),et&&jsxRuntimeExports.jsx("img",{ref:Lr,src:et.src,name:"sourceimage",style:{position:"absolute",height:"auto",width:"auto",maxWidth:"100%",maxHeight:"100%",top:"50%",left:"50%",opacity:"0.2",zIndex:"990",transform:"translate(-50%, -50%)"},onMouseDown:Dt,onMouseMove:Ao,onMouseLeave:Qo,onContextMenu:Eo})]})};function ImageEditor({param:e,canvasWidth:o,canvasHeight:s,url:a,handleChanged:$}){const c=reactExports.useRef(null),[nt,at]=reactExports.useState({x:0,y:0,width:0,height:0,scale:1}),[lt,et]=reactExports.useState(!1),[it,st]=reactExports.useState({x:0,y:0,width:0,height:0}),[ct,ft]=reactExports.useState(!1),[pt,gt]=reactExports.useState(null),[wt,vt]=reactExports.useState(!1),[_t,$t]=reactExports.useState(null),[Pt,Nt]=reactExports.useState(1),Lt=reactExports.useRef(null),[Ft,Wt]=reactExports.useState(null),vr=Zr=>{if(Zr){const tn=e.accept.split(","),vn=Zr.name.split(".").pop().toLowerCase();if(tn==""||tn.includes(`.${vn}`)){const zo={target:{name:e.name,files:[Zr]}};$(zo)}else alert("文件类型暂不支持,请上传如下类型文件:"+e.accept)}},wr=Zr=>{Zr.preventDefault(),Zr.stopPropagation(),Zr.target.files[0]&&$(Zr)};reactExports.useEffect(()=>{const Zr=new Image;Zr.src=a,Zr.onload=()=>{const tn=o/1.5/Zr.width,vn=s/1.5/Zr.height,zo=Math.min(vn,tn),Yo={image:Zr,x:(c.current.width-Zr.width*zo)/2,y:(c.current.height-Zr.height*zo)/2,width:Zr.width*zo,height:Zr.height*zo,scale:zo};at(Yo),st({x:Yo.x,y:Yo.y,width:Yo.width,height:Yo.height}),Wt(Yo),Nt(zo),et(!0),$t(Zr)}},[o,s,a]);const _o=Zr=>{Zr.preventDefault(),Ft&&(at(Ft),st({x:Ft.x,y:Ft.y,width:Ft.width,height:Ft.height}))},Jt=(Zr,tn)=>{const zo=tn.height/15,Yo=tn.width/15;for(let jo=0;jo{const tn=o/_t.width,vn=s/_t.height,zo=_t.width*tn,Yo=_t.height*vn;Zr.font="16px Arial",Zr.fillStyle="black",Zr.textAlign="right",Zr.font="12px Arial",Zr.fillText(`最大宽度: ${Math.round(zo/Pt)}px, 最大高度: ${Math.round(Yo/Pt)}px`,c.current.width-10,c.current.height-10)};reactExports.useEffect(()=>{const Zr=c.current,tn=Zr.getContext("2d");Zr.width=o,Zr.height=s,Jt(tn,Zr)},[]);const Ot=Zr=>{Zr.preventDefault(),Zr.stopPropagation();const vn=.01*(1024/_t.width),zo=Zr.clientX-c.current.getBoundingClientRect().left,Yo=Zr.clientY-c.current.getBoundingClientRect().top,jo=Zr.deltaY>0?-vn:vn;at(Ko=>{const Zo=Math.max(.02,Math.min(8,Ko.scale+jo)),Fo=_t.width*Zo,Js=_t.height*Zo,Ks=zo-(zo-Ko.x)*(Zo/Ko.scale),Dt=Yo-(Yo-Ko.y)*(Zo/Ko.scale);return{...Ko,x:Ks,y:Dt,width:Fo,height:Js,scale:Zo}})},gr=Zr=>{Zr.preventDefault();const tn={x:Zr.clientX-c.current.getBoundingClientRect().left,y:Zr.clientY-c.current.getBoundingClientRect().top},vn=8;if(Math.abs(tn.x-it.x){if(Zr.preventDefault(),wt){const jo=Zr.clientX-c.current.getBoundingClientRect().left,Ko=Zr.clientY-c.current.getBoundingClientRect().top;at(Zo=>({...Zo,x:jo-pt.x,y:Ko-pt.y}));return}if(!ct)return;const tn=Zr.clientX-c.current.getBoundingClientRect().left,vn=Zr.clientY-c.current.getBoundingClientRect().top,zo=tn+pt.x,Yo=vn+pt.y;st(jo=>{switch(pt.corner){case"topLeft":return{...jo,x:zo,y:Yo,width:jo.width+(jo.x-zo),height:jo.height+(jo.y-Yo)};case"topRight":return{...jo,y:Yo,width:zo-jo.x,height:jo.height+(jo.y-Yo)};case"bottomLeft":return{...jo,x:zo,width:jo.width+(jo.x-zo),height:Yo-jo.y};case"bottomRight":return{...jo,width:zo-jo.x,height:Yo-jo.y};default:return jo}})},On=()=>{ft(!1),vt(!1)};reactExports.useEffect(()=>{if(lt&&nt){const Zr=c.current,tn=Zr.getContext("2d");tn.clearRect(0,0,Zr.width,Zr.height),Jt(tn,Zr),tn.drawImage(nt.image,nt.x,nt.y,nt.width,nt.height),en(tn),Kr(tn)}},[nt,lt,it]);const en=Zr=>{const tn=c.current;Zr.clearRect(0,0,tn.width,tn.height),Jt(Zr,tn),Zr.drawImage(_t,nt.x,nt.y,nt.width,nt.height),Zr.strokeStyle="grey",Zr.lineWidth=2,Zr.strokeRect(it.x,it.y,it.width,it.height);const vn=8;Zr.fillStyle="blue",Zr.fillRect(it.x-vn/2,it.y-vn/2,vn,vn),Zr.fillRect(it.x+it.width-vn/2,it.y-vn/2,vn,vn),Zr.fillRect(it.x-vn/2,it.y+it.height-vn/2,vn,vn),Zr.fillRect(it.x+it.width-vn/2,it.y+it.height-vn/2,vn,vn)};function Lr(Zr,tn){const vn=document.createElement("canvas"),zo=vn.getContext("2d");return vn.width=Zr.width/tn,vn.height=Zr.height/tn,zo.drawImage(Zr,0,0,vn.width,vn.height),vn}const ko=Zr=>{Zr.preventDefault();const tn=document.createElement("canvas"),vn=tn.getContext("2d");tn.width=Math.round(it.width/Pt),tn.height=Math.round(it.height/Pt);const zo=Ft.width/nt.width,Yo=Lr(Ft.image,zo),jo=Yo.width,Ko=Yo.height,Zo=(nt.x-it.x)/Pt,Fo=(nt.y-it.y)/Pt;vn.drawImage(Yo,0,0,jo,Ko,Zo,Fo,jo,Ko),tn.toBlob(Js=>{const Ks=URL.createObjectURL(Js),Dt=document.createElement("a");Dt.href=Ks,Dt.download="saved-image.png",document.body.appendChild(Dt),Dt.click(),document.body.removeChild(Dt),URL.revokeObjectURL(Ks)},"image/png")},Ir=Zr=>{Zr.preventDefault();const tn=document.createElement("canvas"),vn=tn.getContext("2d");tn.width=Math.round(it.width/Pt),tn.height=Math.round(it.height/Pt);const zo=Ft.width/nt.width,Yo=Lr(Ft.image,zo),jo=Yo.width,Ko=Yo.height,Zo=(nt.x-it.x)/Pt,Fo=(nt.y-it.y)/Pt;vn.drawImage(Yo,0,0,jo,Ko,Zo,Fo,jo,Ko),tn.toBlob(Js=>{URL.createObjectURL(Js),document.createElement("a");const Ks=Dr("edited_.png"),Dt=new File([Js],Ks,{type:"image/png"});vr(Dt)},"image/png")};function Dr(Zr){const tn=new Date,vn=tn.getFullYear()+("0"+(tn.getMonth()+1)).slice(-2)+("0"+tn.getDate()).slice(-2)+"_"+("0"+tn.getHours()).slice(-2)+("0"+tn.getMinutes()).slice(-2)+("0"+tn.getSeconds()).slice(-2),zo=v4().replace(/-/g,""),Yo=`${vn}_${zo}_`,jo=Zr.split("/").pop();return`${Yo}${jo}`}return jsxRuntimeExports.jsxs("div",{style:{position:"relative",width:"canvasWidthpx",height:"canvasHeightpx",border:"1px solid black"},children:[jsxRuntimeExports.jsx("canvas",{ref:c,onWheel:Ot,onMouseDown:gr,onMouseMove:$o,onMouseUp:On}),jsxRuntimeExports.jsxs("div",{style:{position:"absolute",top:"5px",left:"0px",fontSize:"10px",color:"#787878"},children:[jsxRuntimeExports.jsx("span",{style:{display:"inline-block",padding:"0 10px"},children:"拖动四个角改变结果图大小,滚轮缩放原始图像,拖动图像改变位置,"}),jsxRuntimeExports.jsxs("div",{style:{fontSize:"10px",padding:"0 10px"},children:["宽: ",Math.round(it.width/Pt),"px, 高: ",Math.round(it.height/Pt),"px; 原图在新图中坐标:( ",Math.round((nt.x-it.x)/Pt),", ",Math.round((nt.y-it.y)/Pt)," )"]}),jsxRuntimeExports.jsx("input",{type:"file",ref:Lt,style:{display:"none"},onChange:Zr=>{wr(Zr)}})]}),jsxRuntimeExports.jsx("div",{className:"newfileInput",children:jsxRuntimeExports.jsx("button",{onClick:Zr=>{Zr.preventDefault(),Lt.current.click()},children:"新建上传"})}),jsxRuntimeExports.jsxs("div",{className:"newfileInputCon",children:[jsxRuntimeExports.jsx("button",{onClick:Zr=>_o(Zr),style:{color:"#2C5ECE"},children:"复原"}),jsxRuntimeExports.jsx("button",{onClick:Zr=>ko(Zr),style:{color:"#31BE4B"},children:"下载"}),jsxRuntimeExports.jsx("button",{onClick:Zr=>Ir(Zr),style:{color:"#787878"},children:"确认"})]})]})}function EditableImage({index:e,param:o,handleInputChange:s,previewUrl:a}){const[$,c]=reactExports.useState(!1),nt=reactExports.useRef(null),at=ft=>{ft.preventDefault(),c(!0)},lt=ft=>{ft.preventDefault(),c(!1)},et=ft=>{ft.preventDefault()},it=ft=>{ft.preventDefault(),c(!1);const pt=ft.dataTransfer.files[0];if(pt){const gt=o.accept.split(","),wt=pt.name.split(".").pop().toLowerCase();if(gt==""||gt.includes(`.${wt}`)){const vt={target:{name:o.name,files:[pt]}};s(e,vt)}else alert("文件类型暂不支持,请上传如下类型文件:"+o.accept)}},st=ft=>async pt=>{await s(ft,pt)},ct=ft=>{ft.preventDefault(),ft.target.files[0]&&s(e,ft)};return jsxRuntimeExports.jsxs("div",{className:`my-file-drop-area ${$?"dragging":""}`,onDragEnter:at,onDragLeave:lt,onDragOver:et,onDrop:it,onClick:()=>{a||nt.current.click()},style:{position:"relative",minHeight:window.innerWidth>1e3?"500px":"320px",maxWidth:"100%",maxHeight:"100%"},children:[jsxRuntimeExports.jsx("input",{type:"file",ref:nt,style:{display:"none"},name:o.name,accept:o.accept,onChange:ft=>ct(ft)}),a?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ImageEditor,{param:o,canvasHeight:window.innerWidth>1e3?480:300,canvasWidth:window.innerWidth>1e3?320:200,url:a,handleChanged:st(e)}),jsxRuntimeExports.jsx("button",{type:"button",className:"cancel",onClick:ft=>{ft.stopPropagation(),nt.current.value="",s(e,null)},style:{position:"absolute",top:"10px",right:"10px",padding:"2px",fontSize:"10px",borderRadius:"5%",backgroundColor:"#ccc",border:"none",cursor:"pointer"},children:"X"})]}):jsxRuntimeExports.jsx("p",{style:{textAlign:"center",margin:0,fontSize:"13px"},children:"+"})]})}const DynamicParameterRender=({params:e,setParamFunc:o,template_id:s=null,is_author:a=!1})=>{const $=api$1.get("userType"),[c,nt]=reactExports.useState([]),[at,lt]=reactExports.useState({}),et=reactExports.useRef(null);reactExports.useState(!0);let it=new AbortController;reactExports.useEffect(()=>{it=new AbortController;const _t=it.signal;return pt(e,_t).then($t=>{if(_t.aborted)throw new Error("Fetch aborted");JSON.stringify(e)!==JSON.stringify($t)&&o&&o($t)}).catch($t=>{console.error("Failed to update parameters:",$t)}),()=>{it.abort()}},[e]);const st=async(_t,$t)=>{const Pt={};et.current=Pt;const Nt=e.findIndex(Wt=>Wt.maskSourceUrl===e[_t].name);let Lt=null;Nt>=0&&(Lt=null);const Ft=await Promise.all(e.map(async(Wt,vr)=>{try{if(_t===vr||vr==Nt)if(Wt.type==="file"||Wt.type==="combo_image_selection"||Wt.type==="image_editer"){if($t===void 0||$t==null){const{value:wr,..._o}=Wt;Wt=_o}else if($t.target.files[0])try{let wr=$t.target.files[0];const _o=URL.createObjectURL(wr);if(wr.type.startsWith("image/")){const Jt=await loadImage(_o),{height:Kr,width:Ot,samScale:gr}=handleImageScale(Jt);wr=await resizeImage(Jt,Ot,Kr,wr),saveFile(wr.file,`${wr.name}_${wr.type}_${wr.size}`)}else wr={file:wr,name:wr.name,size:wr.size,type:wr.type},saveFile(wr.file,`${wr.name}_${wr.type}_${wr.size}`);URL.revokeObjectURL(_o),Wt={...Wt,value:wr}}catch(wr){throw console.error("Error processing image:",wr),URL.revokeObjectURL(objectURL),wr}return Wt}else if(Wt.type==="mask")if(vr==Nt&&($t=Lt),$t)if($t.target.files.length>0){let wr=[];for(let _o=0;_o<$t.target.files.length;_o++){const Jt=$t.target.files[_o];if(Jt){const Kr={file:Jt,name:Jt.name,size:Jt.size,type:Jt.type},Ot=`${Kr.name}_${Kr.type}_${Kr.size}`;await saveFile(Kr.file,Ot),wr.push(Kr)}else Jt==""?wr.push(Wt.value?.[_o]):wr.push(null)}return Wt={...Wt,value:wr},Wt}else return Wt;else return Wt={...Wt,value:[null,null]},Wt;else if(Wt.type==="workflow"){if(vr==Nt)if($t)try{$t=await ct($t.target.files[0])}catch(wr){console.error("workflow is error:",wr),$t=[]}else $t=[];return Wt={...Wt,value:$t},Wt}else return Wt={...Wt,value:$t},Wt;return Wt}catch(wr){console.error("Error handling input change:",wr)}}));et.current!=Pt&&console.log("canceld input change: params are ",Ft),o&&o(Ft)},ct=async _t=>{try{if(!_t)return[];let $t=await transformNodesFromFile(_t);return console.log("Returned transformed nodes:",$t),$t}catch($t){throw console.error("Error:",$t),alert($t),$t}},ft=async(_t,$t,Pt)=>{if(Pt.aborted)throw new Error("Fetch aborted");if((_t.type==="file"||_t.type==="combo_image_selection"||_t.type==="image_editer")&&_t.value){let Nt=`${_t.value.name}_${_t.value.type}_${_t.value.size}`,Lt=_t.value.name?(await getLocalResourceURL(`${_t.value.name}_${_t.value.type}_${_t.value.size}`,s)).url:null;if(Nt!=`${_t.value.name}_${_t.value.type}_${_t.value.size}`)throw console.error("changed "+Nt),new Error("Fetch aborted already changed. ");if(Pt.aborted)throw new Error("Fetch aborted");if(Lt){const Ft=e.findIndex(Wt=>Wt.maskSourceUrl===_t.name);nt(Wt=>{const vr=[...Wt];return vr[$t]=Lt,Ft>=0&&(vr[Ft]=`${_t.value.name}_${_t.value.type}_${_t.value.size}`),vr})}}else(_t.type==="file"||_t.type==="combo_image_selection"||_t.type==="mask"||_t.type==="image_editer")&&!_t.value&&nt(Nt=>{const Lt=[...Nt];Lt[$t]=null;const Ft=e.findIndex(Wt=>Wt.maskSourceUrl===_t.name);return Ft>=0&&(Lt[Ft]=null),Lt});return _t},pt=async(_t,$t)=>{const Pt=_t.map(async(Nt,Lt)=>{if($t.aborted)throw new Error("Fetch aborted");if((Nt.type==="selection"||Nt.type==="image_selection")&&!Nt.value)try{const Ft=JSON.parse(Nt.options||Nt.default);if(Array.isArray(Ft))return{...Nt,value:Ft[0].value}}catch{const Wt=(Nt.options||Nt.default||"").split(",")[0].trim();return{...Nt,value:Wt}}else{if(Nt.type==="text"&&(Nt.value===void 0||Nt.value==null))return{...Nt,value:Nt.default};if(Nt.type==="file"||Nt.type==="combo_image_selection"||Nt.type==="mask"||Nt.type==="image_editer")return await ft(Nt,Lt,$t)}return Nt});if($t.aborted)throw new Error("Fetch aborted");return Promise.all(Pt)},gt=_t=>async $t=>{await st(_t,$t)},wt=(_t,$t)=>{const Pt={...at,[_t]:$t};lt(Pt);const Nt=e.map((Lt,Ft)=>_t===Ft&&(Lt.type==="image_selection"||Lt.type==="combo_image_selection")?{...Lt,value:$t}:Lt);o&&o(Nt)},vt=()=>{const _t=e.map((Lt,Ft)=>{switch(Lt.type){case"text":return jsxRuntimeExports.jsxs("div",{style:{height:($=="user"||$=="guest")&&Lt.visibleToUser==0?"0px":"fit-content"},children:[jsxRuntimeExports.jsx("div",{className:styles.form_label_con,children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,style:{fontSize:"12px"},children:[Lt.name,": "]})}),jsxRuntimeExports.jsx("textarea",{rows:1,className:"parameter_input_medium",style:{display:"block",marginLeft:"20px"},type:"text",name:Lt.name,placeholder:"请输入文字,地方不够,请拖动右下角",defaultValue:Lt.value||Lt.default||Lt.accept||"",onBlur:Wt=>st(Ft,Wt.target.value),onInput:Wt=>{Wt.target.style.height="auto",Wt.target.style.height=Wt.target.scrollHeight+"px"},onFocus:Wt=>{Wt.target.style.height="auto",Wt.target.style.height=Wt.target.scrollHeight+"px"}})]},Ft+JSON.stringify(Lt));case"selection":return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{className:styles.form_label_con,style:{marginTop:"20px"},children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,children:[Lt.name,": "]})]}),jsxRuntimeExports.jsx("select",{name:Lt.name,className:"dropdown_container_search",value:Lt.value,onChange:Wt=>st(Ft,Wt.target.value),children:(()=>{try{const Wt=JSON.parse(Lt.options||Lt.default);if(console.log(1),Array.isArray(Wt))return Wt.map((vr,wr)=>jsxRuntimeExports.jsx("option",{value:vr.value,children:vr.option},wr))}catch{return(Lt.options||Lt.default||"").split(",").map((vr,wr)=>jsxRuntimeExports.jsx("option",{value:vr.trim(),children:vr.trim()},wr))}})()})]},Ft+JSON.stringify(Lt));case"image_selection":return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:styles.item_title_area,style:{padding:"5px 10px"},children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,children:[Lt.name,": "]})}),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:(()=>{try{const Wt=JSON.parse(Lt.options||Lt.default||"{}");if(Array.isArray(Wt))return jsxRuntimeExports.jsx(ImageList,{optionsObject:Wt,param:Lt,handleImageSelect:wt,paramIndex:Ft})}catch{return(Lt.options||Lt.default||"").split(",").map((vr,wr)=>jsxRuntimeExports.jsx("div",{className:styles.image_option,children:jsxRuntimeExports.jsx("img",{src:vr.trim(),alt:`Option ${wr+1}`,onClick:()=>wt(Ft,vr.trim()),className:Lt.value===vr.trim()?styles.image_selected:""},wr)},wr))}})()})]},Ft+JSON.stringify(Lt));case"combo_image_selection":return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{className:styles.form_label_con,style:{marginTop:"20px"},children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,children:[Lt.name,": "]})]}),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(ComboImageList,{optionsObject:Lt.options||Lt.default||"[]",param:Lt,paramIndex:Ft,handleImageSelect:wt,handleInputChange:st,uploadPreviewUrl:c[Ft]},Ft)})]},Ft+JSON.stringify(Lt));case"file":return jsxRuntimeExports.jsxs("div",{style:{minHeight:window.innerWidth>1e3?Lt.name=="图标"||Lt.accept.includes("json")?"100px":"550px":Lt.name=="图标"||Lt.accept&&Lt.accept.includes("json")?"30px":"350px",height:$!="admin"&&Lt.visibleToUser==0&&!a?"0px":"fit-content"},children:[($=="admin"||Lt.visibleToUser!==0||a)&&Lt.name!="图标"&&jsxRuntimeExports.jsx("div",{className:styles.item_title_area,style:{padding:"20px"},children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,children:[Lt.name,": "]})}),jsxRuntimeExports.jsx("div",{style:{height:window.innerWidth>1e3?$!="admin"&&Lt.visibleToUser==0&&!a?"0px":Lt.name=="图标"||Lt.accept&&Lt.accept.includes("json")?"60px":"500px":$!="admin"&&Lt.visibleToUser==0&&!a?"0px":Lt.name=="图标"||Lt.accept.includes("json")?"60px":"300px"},children:o&&jsxRuntimeExports.jsx(FileUpload,{index:Ft,param:Lt,handleInputChange:st,previewUrl:c[Ft],visible:$=="admin"||Lt.visibleToUser!=0||a,verbose:!0},Ft)})]},Ft+JSON.stringify(Lt));case"image_editer":return jsxRuntimeExports.jsxs("div",{style:{minHeight:window.innerWidth>1e3?"550px":"350px",height:"fit-content",width:"100%",minWidth:"fit-content"},id:"dddd",children:[jsxRuntimeExports.jsx("div",{className:styles.item_title_area,style:{padding:"10px 10px 0 10px"},children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,children:[Lt.name,": "]})}),o&&jsxRuntimeExports.jsx(EditableImage,{index:Ft,param:Lt,handleInputChange:st,previewUrl:c[Ft]},Ft)]},Ft+JSON.stringify(Lt));case"mask":return jsxRuntimeExports.jsxs("div",{style:{minHeight:window.innerWidth>1e3?"550px":"350px",height:"fit-content"},children:[jsxRuntimeExports.jsx("div",{className:styles.item_title_area,style:{padding:"10px 10px 0 10px"},children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,children:[Lt.name,": "]})}),jsxRuntimeExports.jsx("div",{style:{height:window.innerWidth>1e3?"500px":"300px"},children:o&&jsxRuntimeExports.jsx(Segment,{param:Lt,index:Ft,handleInputChange:st,sourceImageID:c[Ft],template_id:s},Ft)})]},Ft);case"workflow":return jsxRuntimeExports.jsxs("div",{style:{height:"fit-content"},children:[jsxRuntimeExports.jsxs("div",{className:styles.form_label_con,style:{},children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,htmlFor:Lt.name,children:[Lt.name,": "]})]}),jsxRuntimeExports.jsx("div",{style:{height:"fit-content"},children:o&&jsxRuntimeExports.jsx(DynamicParameterRender,{params:Lt.value,index:Ft,setParamFunc:gt(Ft),template_id:s},Ft+JSON.stringify(Lt)+"workflow")})]},Ft+JSON.stringify(Lt));default:return null}}),$t=[];let Pt=0,Nt=["image_selection","combo_image_selection","workflow"];for(;Pt<_t.length;)Nt.includes(e[Pt].type)?($t.push(jsxRuntimeExports.jsx("div",{style:{marginBottom:"25px",height:"fit-content"},className:"rightItenBottom",children:_t[Pt]},Pt)),Pt++):($=="user"||$=="guest")&&e[Pt].visibleToUser==0||e[Pt].type==="file"&&Pt+1<_t.length&&_t[Pt+1]&&!["file","mask"].includes(e[Pt+1].type)?($t.push(jsxRuntimeExports.jsxs("div",{className:"leftItemTop",children:[jsxRuntimeExports.jsxs("div",{className:styles.form_label_con,children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsxs("label",{className:styles.form_label,children:["参数",jsxRuntimeExports.jsx("span",{style:{fontSize:"9px"},children:" (选填)"})]})]}),jsxRuntimeExports.jsx("div",{className:styles.compileCon,style:{display:"flex",marginBottom:"5px",height:$!="admin"&&e[Pt].visibleToUser==0&&!a?"0px":"fit-content"},children:jsxRuntimeExports.jsx("div",{style:{width:"90%",height:$!="admin"&&e[Pt].visibleToUser==0&&!a?"0px":"fit-content"},children:_t[Pt]})},Pt)]})),Pt++):($t.push(jsxRuntimeExports.jsxs("div",{id:"asasad",className:styles.compileCon,style:{width:"90%",marginBottom:"5px",height:"fit-content",marginTop:e[Pt].name==="图标"?"30px":"0",boxShadow:e[Pt].name==="图标"?"none":"0px 2px 4px 0px rgba(0,0,0,0.16)",border:e[Pt].name==="图标"?"1px solid #afafbc":"none",borderRadius:e[Pt].name==="图标"?"10px":"0 0 10px 10px",marginLeft:e[Pt].name==="图标"?"10px":"0"},children:[jsxRuntimeExports.jsx("div",{style:{height:"fit-content"},children:_t[Pt]}),jsxRuntimeExports.jsx("div",{style:{height:"fit-content"},children:Pt+1<_t.length&&_t[Pt+1]})]},Pt)),Pt+=2);return $t};return jsxRuntimeExports.jsx("form",{id:"dynamicForm",style:{width:"100%"},children:vt()})};function ImageDisplayCombo({file:e,watermark:o=!1}){const[s,a]=reactExports.useState(""),[$,c]=reactExports.useState(!1),[nt,at]=reactExports.useState(!0);reactExports.useEffect(()=>(fileDisplayAble(e)?fetchAndSetImage(e).then(it=>a(it)).catch(console.error):at(!1),()=>s&&URL.revokeObjectURL(s)),[e.id,e.type,e.name]);const lt=it=>{it.preventDefault(),c(!0),document.body.style.cursor="zoom-out"},et=()=>{c(!1),document.body.style.cursor="pointer"};return jsxRuntimeExports.jsxs("div",{style:{maxWidth:"100%",height:"auto"},children:[s?jsxRuntimeExports.jsx(MediaDisplay,{url:s,type:e.type,muted:!0,controls:!0,autoplay:!0,watermark:o,onMediaClick:lt}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:nt?jsxRuntimeExports.jsx("div",{children:"加载中..."}):jsxRuntimeExports.jsx("div",{children:"点击下载..."})}),jsxRuntimeExports.jsx(Popup,{visible:$,position:"bottom",style:{zIndex:1e6},bodyStyle:{width:"100%",height:"100%"},destroyOnClose:!0,closeOnMaskClick:!0,showCloseButton:!0,children:jsxRuntimeExports.jsx(ImageModal,{closeModal:et,imageUrl:s,filetype:e.type})})]})}function Files({files:e,downloadFile:o,returnResourceIcon:s,shareContent:a=null}){const $=api$1.get("userType");return jsxRuntimeExports.jsxs("div",{className:"gridContainer_resouce_new",children:[" ",e&&e.filter(c=>!c.name.endsWith(".npy")&&!c.name.endsWith(".json")).map(c=>jsxRuntimeExports.jsxs("div",{children:[" ",jsxRuntimeExports.jsxs("div",{className:styles.history_box,children:[" ",jsxRuntimeExports.jsx(ImageDisplayCombo,{file:c,watermark:$=="guest"}),jsxRuntimeExports.jsx("div",{style:{display:"flex",cursor:"pointer"},children:jsxRuntimeExports.jsxs("div",{className:styles.picListBot,children:[jsxRuntimeExports.jsx("div",{style:{fontSize:"10px",color:"#787878"},className:styles.single_line_block,onClick:()=>o(c.id,c.name),children:c.name}),jsxRuntimeExports.jsxs("div",{style:{fontSize:"9px",textAlign:"right"},onClick:()=>o(c.id,c.name),className:styles.downBth,children:[c.type.split("/")[1],c.size!==""?` • ${formatBytes(c.size)}`:"",jsxRuntimeExports.jsxs("span",{children:["点击下载",$=="user"||$=="guest"?"(含水印)":""]})]}),($=="user"||$=="guest")&&jsxRuntimeExports.jsxs("div",{style:{fontSize:"9px",textAlign:"right"},onClick:()=>o(c.id,c.name),className:styles.downBth,children:[c.type.split("/")[1],c.size!==""?` • ${formatBytes(c.size)}`:"",jsxRuntimeExports.jsx("span",{children:"注册去水印下载"})]}),a&&jsxRuntimeExports.jsx("div",{style:{fontSize:"9px",padding:"5px"},children:jsxRuntimeExports.jsx("button",{onClick:()=>a(c.id),style:{background:"#4591ee",width:"100%",border:"none",color:"#fff",borderRadius:"8px",padding:"7px 25px",fontSize:"12px"},children:"发布"})})]})})]})]},c.id))]})}function ResourceList({files:e,channel:o,runs:s,runid:a,selectedRunStatus:$,share:c=!0}){const[nt,at]=reactExports.useState(null),lt=reactExports.useMemo(()=>s.map(st=>{const ct=e.filter(ft=>ft.agent_execution_id===st.id);return ct.length!==0&&{run:st,files:ct}}).filter(Boolean),[e,s]),et=(st,ct)=>{const ft=e.filter(pt=>pt.agent_execution_id===st);ft.length!==0&&downloadAllFiles(ft,ct)},it=e.some(st=>st.agent_execution_id!==null);return jsxRuntimeExports.jsxs("div",{id:"resource-list",children:[o==="output"&&(!it||e.length<=0?jsxRuntimeExports.jsx("div",{className:"horizontal_space_between flex_wrap",children:$!=="ERROR_PAUSED"&&$!=="COMPLETED"&&$!=="TERMINATED"&&$!=="ITERATION_LIMIT_EXCEEDED"?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("span",{className:"feed_title mt_8",children:"尚未执行完毕.或者没有输出文件."})}),jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("img",{style:{width:"34px",height:"34px"},loading:"lazy",className:"mix_blend_mode",src:`${WEB_SITE}/images/loading.gif`,alt:"active-icon",tyle:{float:"left"}})})]}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("span",{className:"feed_title mt_8",children:"已经结束!"})})})}):jsxRuntimeExports.jsx("div",{id:"division_by_runs",className:"horizontal_space_between flex_wrap",children:lt.map((st,ct)=>jsxRuntimeExports.jsx("div",{style:{width:"100%"},children:st.run.id===a&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"horizontal_container justify_space_between cursor_pointer padding_8_6",onClick:()=>at(st.run.id===a?null:st.run.id),children:[jsxRuntimeExports.jsx("div",{className:"horizontal_container",children:jsxRuntimeExports.jsx("img",{src:a===st.run.id?`${WEB_SITE}/images/arrow_downward_dropdown.svg`:`${WEB_SITE}/images/arrow_forward.svg`,alt:"arrow",style:{width:"14px",height:"14px"}})}),jsxRuntimeExports.jsx("img",{src:`${WEB_SITE}/images/download.svg`,alt:"download_icon",style:{width:"20px",height:"21px"},onClick:()=>et(st.run.id,st.run.name)})]}),jsxRuntimeExports.jsx(Files,{files:st.files,downloadFile,returnResourceIcon,shareContent:c?shareContent:null})]})},lt.length-ct-1))})),o==="input"&&e&&jsxRuntimeExports.jsx(Files,{files:e,downloadFile,returnResourceIcon})]})}function ResourceManager({agentId:e,runs:o,runid:s,selectedRunStatus:a,share:$=!0}){const[c,nt]=reactExports.useState([]),[at,lt]=reactExports.useState([]);reactExports.useState("input"),reactExports.useState(!1),reactExports.useRef(null),reactExports.useEffect(()=>{const it=window.setInterval(function(){a!=="ERROR_PAUSED"&&a!=="COMPLETED"&&a!=="TERMINATED"&&a!=="ITERATION_LIMIT_EXCEEDED"&&et()},5e3);return()=>clearInterval(it)},[s,a]),reactExports.useEffect(()=>{et()},[e]);function et(){getResources(e).then(it=>{const st=it.data,ct=st.filter(pt=>pt.channel==="INPUT"),ft=st.filter(pt=>pt.channel==="OUTPUT");lt(ct),nt(ft)}).catch(it=>{console.error("Error fetching resources:",it)})}return jsxRuntimeExports.jsxs("div",{className:"sectionCon",children:[jsxRuntimeExports.jsxs("div",{className:"section-area",children:[jsxRuntimeExports.jsx("div",{className:"detail_top mb_10",children:jsxRuntimeExports.jsxs("div",{className:"documentTitle",children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("span",{children:"运行结果"})]})}),jsxRuntimeExports.jsx("div",{className:"w_100 mr_10 mb_20",children:jsxRuntimeExports.jsx(ResourceList,{files:c,channel:"output",runs:o,runid:s,selectedRunStatus:a,share:$})})]}),jsxRuntimeExports.jsxs("div",{className:"section-area",children:[jsxRuntimeExports.jsx("div",{className:"detail_top mb_10 width=100%",children:jsxRuntimeExports.jsxs("div",{className:"documentTitle",children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("span",{children:"原始文件"})]})}),jsxRuntimeExports.jsx("div",{className:"w_100 mr_10 mb_20",children:jsxRuntimeExports.jsx(ResourceList,{files:at,channel:"input",runs:o,selectedRunStatus:a})})]}),jsxRuntimeExports.jsx(k$1,{})]})}function AgentExecutionChecker({executionId:e,targetStatus:o,runAction:s,intervalTime:a}){reactExports.useEffect(()=>{const $=window.setInterval(async()=>{try{const c=await getExecution(e);o.includes(c.data.status)&&(s(c.data.status),clearInterval($))}catch(c){console.error("Error fetching execution:",c)}},a);return()=>clearInterval($)},[e,o,s,a])}const WorkerAdmin=({sj_display:e,onUpdateDialog:o,onCloseWorkerAdmin:s,isvisible:a})=>{const[$,c]=reactExports.useState(!1);reactExports.useState("1");const[nt,at]=reactExports.useState(localStorage.getItem("keyHuaxiaobao")=="null"?null:localStorage.getItem("keyHuaxiaobao")),[lt,et]=reactExports.useState(localStorage.getItem("accessTokenHuaxiaobao")=="null"?null:localStorage.getItem("accessTokenHuaxiaobao")),[it,st]=reactExports.useState(null),[ct,ft]=reactExports.useState(null),[pt,gt]=reactExports.useState(null),[wt,vt]=reactExports.useState(null),[_t,$t]=reactExports.useState(null),[Pt,Nt]=reactExports.useState(null),[Lt,Ft]=reactExports.useState(null),[Wt,vr]=reactExports.useState(["百变真我学习趣味爱情节日短视频电商音乐电商跳舞其他","百变真我","学习","趣味","爱情","节日","短视频","电商","音乐","跳舞","其他"]),[wr,_o]=reactExports.useState(!1),[Jt,Kr]=reactExports.useState(!1),Ot=reactExports.useRef(null);reactExports.useRef(null),reactExports.useRef(null),reactExports.useRef(null);const[gr,$o]=reactExports.useState(!1),[On,en]=reactExports.useState(0),[Lr,ko]=reactExports.useState(localStorage.getItem("usernameHuaxiaobao")=="null"?null:localStorage.getItem("usernameHuaxiaobao")),[Ir,Dr]=reactExports.useState(localStorage.getItem("usernameHuaxiaobao")=="null"?null:localStorage.getItem("usernameHuaxiaobao")+"的一件精品"),[Zr,tn]=reactExports.useState("我想为你作一件事.."),[vn,zo]=reactExports.useState("百变真我"),[Yo,jo]=reactExports.useState([{name:"图标",type:"file",accept:".png,.jpg,.jpeg,.webp,.gif"}]);reactExports.useEffect(()=>{(async()=>{try{const In=await getFileObject("newlogo1.png_image/png_70522");if(In){jo([{name:"图标",type:"file",value:{file:In,name:In.name,type:In.type,size:In.size},accept:".png,.jpg,.jpeg,.webp,.gif"}]);return}else{const rn=await fetch(`${WEB_SITE}/logo/newlogo1.png`);if(!rn.ok)throw new Error("Failed to fetch logo");const Yr=await rn.blob(),Io=new File([Yr],"newlogo1.png",{type:"image/png"});saveFile(Io,`${Io.name}_${Io.type}_${Io.size}`),jo([{name:"图标",type:"file",value:{file:Io,name:Io.name,type:Io.type,size:Io.size},accept:".png,.jpg,.jpeg,.webp,.gif"}])}}catch(In){console.error("Error fetching logo:",In)}})()},[]);const Ko=_r=>{Nt(_r),_r=="COMPLETED"?(document.getElementById("trial").disabled=!1,document.getElementById("trial").innerText="运行完毕,再来一遍",document.getElementById("publish")&&(document.getElementById("publish").disabled=!1,document.getElementById("publish").innerText="运行完毕,可以定价上架啦!")):alert("出现错误:",_r)},Zo=async _r=>{create_order_debug({id:1001,price:0,pre_price:0,amount:1,description:_r}).then(rn=>{rn.data.result.startsWith("SUCCESS"),console.log(rn.data.result)}).catch(rn=>{console.error("Error adding user:",rn)})};reactExports.useEffect(()=>{c(a)},[a]);const Fo=_r=>{ft(_r)},Js=_r=>{jo(_r)},Ks=()=>{if(!it)return alert("请在工作流内部添加参数标记节点,可以看帮助或者咨询客服微信v:aizhaoshulin了解"),!1;if(Ir?.replace(/\s/g,"")==="")return alert("任务名称不能为空"),!1;if(Zr?.replace(/\s/g,"")==="")return alert("任务描述不能为空"),!1;if(!Yo[0].value)return alert("请添加logo"),!1;for(let _r of Yo)if(_r.type==="file"&&_r.value===void 0)return alert(_r.name+":图标(logo)中必须输入合适文件"),!1;return!0};reactExports.useEffect(()=>{const _r=async rn=>{const Yr=await window.comfyui_app.graphToPrompt();console.log("MoneySetting initialized with response:",Yr);let Io=JSON.stringify(Yr.output,null,2);if(Object.values(Yr.output).some(Bo=>Bo.class_type==="ComfyUIAppstoreHost"))alert("请删除您的ComfyUIWebHost节点");else{console.log("No ComfyUIWebHost item found in the output.");const Bo=Math.max(...Object.keys(Yr.output).map(So=>parseInt(So)));Yr.output[Bo+1]={inputs:{"ComfyUI 主机地址":rn+".shangxiaobao.com:7000"},class_type:"ComfyUIAppstoreHost",_meta:{title:"ComfyUI Appstore Host (ComfyUI_Appstore)"}},Io=JSON.stringify(Yr.output,null,2);const Ao=new Blob([Io],{type:"application/json"}),Qo=new File([Ao],"workflow_api.json",{type:"application/octet-stream"});console.log("MoneySetting initialized with response:",Yr);try{const So=await transformNodesFromFile(Ao);ft(So),st(Qo)}catch(So){console.error("workflow not ready:",So)}}};(async()=>{const Yr=await fetch("/manager/asset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(!Yr.ok)throw new Error(`HTTP error! status: ${Yr.status}`);const Io=await Yr.json(),Bo=Io.message,Ao=Io.data;Bo=="success"&&(gt(Ao),_r(Ao))})()},[]);const Dt=async _r=>{if(!Ks())return;_r.preventDefault();const In=[{name:"工作流文件的名称",type:"file",value:{file:it,name:it.name,type:it.type,size:it.size},visibleToUser:0},{maskSourceUrl:"工作流文件的名称",name:"工作的配置",type:"workflow",value:ct,visibleToUser:1}],rn={token:nt,name:Ir,description:Zr,category:vn,host:pt,parameter:In,logo:Yo||[]};try{const Yr=await fetch(`${API_BASE_URL}agents/create_workflow_agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(rn)});if(!Yr.ok)throw new Error(`HTTP error! status: ${Yr.status}`);const Io=await Yr.json();console.log("Form submitted successfully");const Bo=Io.id,Ao=Io.name,Qo=Io.execution_id;vt(Bo),uploadParameterFiles(In,Bo),uploadLogos(Yo,Bo,!1),updateExecution(Qo,{status:"RUNNING"}).then(So=>{document.getElementById("trial").disabled=!0,document.getElementById("trial").innerText="正在运行",document.getElementById("publish")&&(document.getElementById("publish").disabled=!0,document.getElementById("publish").innerText="等运行完毕后,即可上架"),$t(Qo),Nt(null)}).catch(So=>{alert("失败"),console.error("Error updating execution:",So)}),console.log("Server response:",Io)}catch(Yr){console.error("Error submitting form:",Yr)}},Eo=_r=>{setLocalStorageValue("agent_category",Wt[_r],zo),_o(!1)};reactExports.useEffect(()=>{function _r(In){Ot.current&&!Ot.current.contains(In.target)&&_o(!1)}return document.addEventListener("mousedown",_r),()=>{document.removeEventListener("mousedown",_r)}},[]);const Jr=(_r,In)=>{publishToMarketplace(_r,parseFloat(In)).then(rn=>{Ft(rn.data.id),$o(!1)}).catch(rn=>{console.error("Error publishing to marketplace:",rn)})},ar=()=>{$o(!1)},er=_r=>{en(_r.target.value)};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[gr&&jsxRuntimeExports.jsx("div",{className:"modal",style:{height:"100%",zIndex:1999999999999},children:jsxRuntimeExports.jsxs("div",{className:"modal-content",style:{width:"75%"},onClick:_r=>_r.preventDefault(),children:[jsxRuntimeExports.jsx("div",{className:styles.detail_name,children:"准备好了吗?发布到市场!"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("label",{className:styles.form_label,children:"价格"}),jsxRuntimeExports.jsx("input",{className:"input_medium",type:"text",value:On,onChange:er})]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",justifyContent:"flex-end"},children:[jsxRuntimeExports.jsx("button",{className:"secondary_button",style:{marginRight:"10px"},onClick:ar,children:"取消"}),jsxRuntimeExports.jsxs("button",{className:styles.run_button,style:{paddingLeft:"15px",paddingRight:"25px"},onClick:()=>Jr(_t,On),children:[jsxRuntimeExports.jsx("img",{style:{width:"14px",height:"14px"},src:`${WEB_SITE}/images/run_icon.svg`,alt:"run-icon"})," 发布"]})]})]})}),jsxRuntimeExports.jsxs(Popup,{visible:$,position:"right",bodyStyle:{direction:"ltl",paddingTop:"10px",zIndex:1999999999998,width:"50vw",height:"100vh",backgroundColor:"white",position:"fixed",right:"0px",top:"0px",overflow:"auto",padding:"10px 10px"},destroyOnClose:!1,children:[Jt&&jsxRuntimeExports.jsx("div",{className:"modal",children:jsxRuntimeExports.jsxs("div",{className:"modal-content",style:{width:"75%"},onClick:_r=>_r.preventDefault(),children:[jsxRuntimeExports.jsx("div",{className:styles.detail_name,children:"在工作流中需要用户输入的节点后面挂一个 ComfyUI Appstore Param 节点,选择丰富的类型,即可变成用户的丰富界面!"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("label",{className:styles.form_label,children:"加VX群了解"}),jsxRuntimeExports.jsx("img",{style:{width:"90%",cursor:"pointer"},src:"https://huaxiaobao.net/logo/dev_wechat.png"}),jsxRuntimeExports.jsx("br",{}),jsxRuntimeExports.jsx("label",{className:styles.form_label,children:"或者直接查看文档和帮助视频"}),jsxRuntimeExports.jsx("img",{src:`${WEB_SITE}/help/help.png`,onClick:()=>window.open("https://huaxiaobao.net/?category=help","_blank"),style:{width:"20px",height:"20px",cursor:"pointer"}})]}),jsxRuntimeExports.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:jsxRuntimeExports.jsx("button",{className:styles.run_button,style:{paddingLeft:"15px",paddingRight:"25px"},onClick:()=>Kr(!1),children:"  OK"})})]})}),jsxRuntimeExports.jsx("div",{style:{padding:"10px"},children:jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{style:{paddingBottom:"20px"},children:[jsxRuntimeExports.jsx("span",{style:{display:"none"}}),jsxRuntimeExports.jsxs("div",{className:"documentTitle",children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("span",{children:"画小宝,ComfyUI作者变现的平台"}),jsxRuntimeExports.jsx("img",{src:`${WEB_SITE}/help/help2.png`,onClick:()=>window.open("https://huaxiaobao.net/?category=help","_blank"),style:{marginTop:"5px",width:"20px",height:"20px",cursor:"pointer",borderRadius:"50%"},onMouseOver:_r=>{_r.currentTarget.src=`${WEB_SITE}/logo/dev_qq.png`,_r.currentTarget.style.width="200px",_r.currentTarget.style.borderRadius="10px",_r.currentTarget.style.height="auto"},onMouseOut:_r=>{_r.currentTarget.src=`${WEB_SITE}/help/help2.png`,_r.currentTarget.style.width="20px",_r.currentTarget.style.borderRadius="50%",_r.currentTarget.style.height="auto"}})]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[jsxRuntimeExports.jsxs("span",{children:[" ","画小宝 huaxiaobao.net 逛逛,马上入驻开店,开启工作流,开始赚钱"]}),jsxRuntimeExports.jsx("span",{style:{cursor:"pointer",fontStyle:"italic"},onClick:()=>window.open("https://huaxiaobao.net/?category=Help_Page","_blank"),children:"享受万元流量奖励"})]})]}),jsxRuntimeExports.jsxs("div",{className:"documentTitle",children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("span",{children:"第一步,游客登录,或者注册用户"})]}),!Lr&&jsxRuntimeExports.jsxs("div",{id:"huaxiaobao_guest",style:{border:"dotted",borderWidth:"thin"},children:[jsxRuntimeExports.jsxs("span",{style:{display:"block"},children:["选项一:游客就可以玩,马上点击即获得价值10元”墨宝“奖励,优点:方便,缺点,只能这台机器玩"," "]}),jsxRuntimeExports.jsx("button",{id:"loginGuestButton",className:"secondary_button",onClick:async()=>{var _r="Guest_"+Math.random().toString(36).substr(2,9);document.getElementById("loginGuestButton").textContent="登录中";const rn=await(await fetch(`${API_BASE_URL}register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:_r,smsCode:"Gues",password:_r})})).json();rn.key?(console.log("Login successful, key:",rn.key),document.querySelector("button").style.display="none",document.getElementById("huaxiaobao_login").style.display="none",document.getElementById("huaxiaobao_guest").style.display="none",document.getElementById("huaxiaobao_token").style.display="block",document.getElementById("huaxiaobao_token").textContent=` 游客已登录,请记录画小宝账号信息:用户名:${_r} 密码:${_r}`,setLocalStorageValue("accessTokenHuaxiaobao",rn.token,et),setLocalStorageValue("usernameHuaxiaobao",_r,ko),setLocalStorageValue("keyHuaxiaobao",rn.key,at),Dr(_r+"的一个精品"),Zo(pt)):console.error("Login failed")},children:"一键登录"})]}),jsxRuntimeExports.jsx("span",{id:"huaxiaobao_token",style:{display:Lr?"block":"none"},children:Lr&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("br",{}),Lr,' + "已经登录"',jsxRuntimeExports.jsx("button",{style:{marginRight:"7px"},className:"secondary_button",onClick:()=>{setLocalStorageValue("usernameHuaxiaobao",null,ko)},children:"登出"})]})}),!Lr&&jsxRuntimeExports.jsxs("div",{id:"huaxiaobao_login",style:{border:"dotted",borderWidth:"thin"},children:[jsxRuntimeExports.jsxs("span",{style:{display:"block"},children:["选项二:画小宝登录,或者注册, 马上获得价值50元“墨宝奖励”"," "]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"row",height:"100%"},children:[jsxRuntimeExports.jsx("label",{children:"手机号:"}),jsxRuntimeExports.jsx("input",{style:{width:"150px",fontSize:"13px"},className:"input_medium",type:"text",id:"username",placeholder:"输入手机号"}),jsxRuntimeExports.jsx("label",{children:"密码:"}),jsxRuntimeExports.jsx("input",{style:{width:"150px",fontSize:"13px"},className:"input_medium",type:"password",id:"password",placeholder:"输入密码"})]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"row",height:"100%"},children:[jsxRuntimeExports.jsx("button",{id:"loginButton",className:"secondary_button",onClick:async()=>{const In=await(await fetch(`${API_BASE_URL}login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:document.getElementById("username").value,password:document.getElementById("password").value})})).json();In.key?(console.log("Login successful"),document.querySelectorAll("label").forEach(rn=>rn.style.display="none"),document.getElementById("huaxiaobao_login").style.display="none",document.getElementById("huaxiaobao_guest").style.display="none",document.getElementById("huaxiaobao_token").style.display="block",document.getElementById("huaxiaobao_token").textContent=" 正式用户登录",setLocalStorageValue("accessTokenHuaxiaobao",In.token,et),setLocalStorageValue("usernameHuaxiaobao",document.getElementById("username").value,ko),setLocalStorageValue("keyHuaxiaobao",In.key,at),Dr(document.getElementById("username").value+"的一个精品"),Zo(pt)):(alert("用户名密码不正确,请重试"),console.error("Login failed"))},children:"登录"}),jsxRuntimeExports.jsx("button",{className:"secondary_button",onClick:()=>window.open("https://huaxiaobao.net/?register","_blank"),children:"注册"})]})]})]})}),Lr&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{style:{padding:"10px"},children:[jsxRuntimeExports.jsxs("div",{className:"documentTitle",children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("span",{children:"第二步,修改工作流,标记参数并测试"})]}),jsxRuntimeExports.jsxs("div",{style:{marginTop:"10px",width:"100%",textAlign:"left",fontSize:"12px",height:"100%",background:"#324d61"},className:styles.compileCon,children:[jsxRuntimeExports.jsxs("div",{className:styles.form_label_con,children:[it?jsxRuntimeExports.jsx("span",{style:{cursor:"pointer"},children:"下面是显示给用户的区域:这里是跟着工作流中的appstore节点设定变化的。"}):jsxRuntimeExports.jsx("span",{style:{cursor:"pointer"},children:"请在工作流内部添加参数标记节点Appstore Param节点,可以看帮助或者咨询客服微信v:aizhaoshulin了解"}),jsxRuntimeExports.jsx("img",{src:`${WEB_SITE}/help/help.png`,onClick:()=>window.open("https://huaxiaobao.net/?category=Help_Page","_blank"),style:{width:"20px",height:"20px",cursor:"pointer"}})]}),jsxRuntimeExports.jsx("div",{style:{margin:"5px"},children:ct&&jsxRuntimeExports.jsx(DynamicParameterRender,{params:ct,setParamFunc:Fo})})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%"},children:[jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"row",height:"100%"},children:[jsxRuntimeExports.jsxs("div",{style:{marginTop:"10px",width:"100%",textAlign:"left",fontSize:"12px",height:"100%"},className:styles.compileCon,children:[jsxRuntimeExports.jsx("div",{className:styles.form_label_con,children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,style:{fontSize:"12px"},children:["名称:"," "]})}),jsxRuntimeExports.jsx("input",{className:"input_medium",type:"text",value:Ir,onChange:_r=>Dr(_r.target.value),style:{fontSize:"13px"},placeholder:"简洁的名称,例子,马良的画笔"})]}),jsxRuntimeExports.jsxs("div",{style:{marginTop:"10px",width:"100%",textAlign:"left",fontSize:"12px",height:"100%"},className:styles.compileCon,children:[jsxRuntimeExports.jsx("div",{className:styles.form_label_con,children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,style:{fontSize:"12px"},children:["分类"," "]})}),jsxRuntimeExports.jsxs("div",{className:"dropdown_container_search",style:{width:"90%"},children:[jsxRuntimeExports.jsxs("div",{className:"custom_select_container",onClick:()=>_o(!wr),children:[vn,jsxRuntimeExports.jsx("img",{style:{width:"20px",height:"21px"},src:wr?WEB_SITE+"/images/dropdown_up.svg":WEB_SITE+"/images/dropdown_down.svg",alt:"expand-icon"})]}),jsxRuntimeExports.jsx("div",{children:wr&&jsxRuntimeExports.jsx("div",{className:"custom_select_options",ref:Ot,style:{width:"100%"},children:jsxRuntimeExports.jsx("div",{className:"model_options",children:Wt.slice(1).map((_r,In)=>jsxRuntimeExports.jsx("div",{className:"custom_select_option",onClick:()=>Eo(In+1),style:{maxWidth:"100%"},children:_r},In+1))})})})]})]})]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"row",height:"100%"},children:[jsxRuntimeExports.jsxs("div",{style:{marginTop:"10px",width:"100%",textAlign:"left",fontSize:"12px",height:"100%"},className:styles.compileCon,children:[jsxRuntimeExports.jsx("div",{className:styles.form_label_con,children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,style:{fontSize:"12px"},children:["简介:"," "]})}),jsxRuntimeExports.jsx("textarea",{value:Zr,className:"textarea_medium",rows:8,style:{fontSize:"13px"},onChange:_r=>tn(_r.target.value),placeholder:"来两句介绍,功能和亮点!更有助于吸引用户"})]}),jsxRuntimeExports.jsxs("div",{style:{marginTop:"10px",width:"100%",textAlign:"left",fontSize:"12px",height:"100%"},className:styles.compileCon,children:[jsxRuntimeExports.jsx("div",{className:styles.form_label_con,children:jsxRuntimeExports.jsxs("label",{className:styles.form_label_text,style:{fontSize:"12px"},children:["Logo"," "]})}),jsxRuntimeExports.jsx(DynamicParameterRender,{params:Yo,setParamFunc:Js,is_author:!0})]})]})]}),jsxRuntimeExports.jsx("div",{style:{display:"flex",flexDirection:"row",height:"100%"},children:jsxRuntimeExports.jsx("button",{id:"trial",className:"button_auth",style:{width:"100%"},onClick:_r=>Dt(_r),children:"试运行"})})]})]}),_t&&jsxRuntimeExports.jsx(ResourceManager,{agentId:wt,runs:[{id:_t}],runid:_t,share:!1})]}),Lr&&_t&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(AgentExecutionChecker,{executionId:_t,targetStatus:["ERROR_PAUSED","COMPLETED","TERMINATED","ITERATION_LIMIT_EXCEEDED"],runAction:Ko,intervalTime:5e3}),jsxRuntimeExports.jsxs("div",{style:{padding:"10px"},children:[jsxRuntimeExports.jsxs("div",{className:"documentTitle",children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("span",{children:"第三步,准备上架和赚钱"})]}),jsxRuntimeExports.jsx("button",{id:"publish",disabled:Pt!="COMPLETED",style:{marginRight:"7px",width:"100%"},className:"button_auth",onClick:()=>{$o(!0)},children:"运行完毕后, 上架售卖!"}),jsxRuntimeExports.jsx("br",{}),jsxRuntimeExports.jsx("br",{}),jsxRuntimeExports.jsx("br",{}),Lt&&jsxRuntimeExports.jsx("button",{style:{marginRight:"7px",width:"100%"},className:"button_auth",onClick:()=>window.open(MARKETPLACE_SITE+"/?category=Create_Agent&targetid="+Lt,"_blank"),children:"已经发布! 查看市场!"}),jsxRuntimeExports.jsx("br",{})]})]}),jsxRuntimeExports.jsx("span",{style:{textAlign:"right"},children:pt})]})]})},App=()=>{const[e,o]=reactExports.useState({right:10,top:120}),[s,a]=reactExports.useState(!1),$=reactExports.useRef(!1),c=reactExports.useRef({x:0,y:0}),nt=(it,st)=>{let ct=0;return(...ft)=>{const pt=new Date().getTime();pt-ct{it.button===0&&(it.stopPropagation(),$.current=!0,c.current={x:it.clientX,y:it.clientY})},lt=nt(it=>{$.current&&o(st=>{const ct=st.right-(it.clientX-c.current.x),ft=st.top+(it.clientY-c.current.y);return c.current={x:it.clientX,y:it.clientY},{right:ct,top:ft}})},30),et=()=>{$.current&&($.current=!1,console.log("Mouse Up: Stop Dragging"))};return reactExports.useEffect(()=>(document.addEventListener("mousemove",lt),document.addEventListener("mouseup",et),()=>{document.removeEventListener("mousemove",lt),document.removeEventListener("mouseup",et)}),[]),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(WorkerAdmin,{isvisible:s},s),jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"row",position:"fixed",zIndex:0x71afd498cffff,backgroundColor:"transparent",right:`${e.right}px`,top:`${e.top}px`,height:"60px",cursor:"pointer"},onMouseDown:at,children:[jsxRuntimeExports.jsx("div",{style:{borderRadius:"10px",height:"30px"},children:jsxRuntimeExports.jsx("img",{style:{marginTop:"3px",borderRadius:"10px",height:"100%",pointerEvents:"none"},src:`${WEB_SITE}/logo/simplelogo.png`})}),jsxRuntimeExports.jsx("div",{className:"secondary_button",style:{opacity:"0.4"},onClick:()=>{s?window.confirm("关闭后当前结果将不再保存,确认吗?")&&a(!s):a(!s)},children:s?"收起":"Appstore"}),jsxRuntimeExports.jsx("div",{style:{borderRadius:"50%",height:"30px"},children:jsxRuntimeExports.jsx("img",{src:`${WEB_SITE}/help/help2.png`,onClick:()=>window.open("https://huaxiaobao.net/?category=help","_blank"),style:{marginTop:"5px",width:"20px",height:"20px",cursor:"pointer",borderRadius:"50%"},onMouseOver:it=>{it.currentTarget.src=`${WEB_SITE}/logo/dev_qq.png`,it.currentTarget.style.width="200px",it.currentTarget.style.borderRadius="10px",it.currentTarget.style.height="auto"},onMouseOut:it=>{it.currentTarget.src=`${WEB_SITE}/help/help2.png`,it.currentTarget.style.width="20px",it.currentTarget.style.borderRadius="50%",it.currentTarget.style.height="auto"}})})]})]})},root=client.createRoot(document.getElementById("admin-app-appstore"));root.render(jsxRuntimeExports.jsx(GlobalProvider,{children:jsxRuntimeExports.jsx(App,{})}));