clickgo 5.9.1 → 5.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/demo.cga +0 -0
- package/dist/control/waterfall.cgc +0 -0
- package/dist/index.js +1 -1
- package/doc/clickgo-rag.md +70 -0
- package/package.json +1 -1
package/dist/app/demo.cga
CHANGED
|
Binary file
|
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var clickgo=Object.freeze({__proto__:null,get AbstractBoot(){return AbstractBoot},get control(){return control},get core(){return core},get dom(){return dom},get form(){return form},get fs(){return fs},get getCdn(){return getCdn},get getDevice(){return getDevice},get getDirname(){return getDirname},get getPlatform(){return getPlatform},get getVersion(){return getVersion},get global(){return global},get hasFrame(){return hasFrame},get isNative(){return isNative},get launcher(){return launcher},get modules(){return modules},get native(){return native$1},get storage(){return storage},get task(){return task},get theme(){return theme},get tool(){return tool},get zip(){return zip}});let compressorjs=null;function runIife(t){return new Function(t+"\nreturn emodule;")()}async function compressor(t,e={}){if(!compressorjs)try{const t=window.clickgo.config?.cdn??"https://cdn.jsdelivr.net";if(await loadScript(t+"/npm/compressorjs@1.2.1/dist/compressor.min.js"),!window.Compressor)throw Error("Compressor load failed.");compressorjs=window.Compressor}catch{return!1}return new Promise(n=>{compressorjs?new compressorjs(t,{quality:e.quality,maxWidth:e.maxWidth,maxHeight:e.maxHeight,success:e=>{!(t instanceof File)||e instanceof File?n(e):n(new File([e],t.name,{lastModified:t.lastModified,type:t.type}))},error:()=>{n(!1)}}):n(!1)})}function getClassPrototype(t,e=[],n=0){if(0===n)return getClassPrototype(Object.getPrototypeOf(t),e,n+1);const o={method:{},access:{}},r=Object.getOwnPropertyNames(t);if(r.includes("toString"))return o;for(const n of r){if("constructor"===n)continue;if(e.includes(n))continue;const r=Object.getOwnPropertyDescriptor(t,n);r&&(e.push(n),r.value?o.method[n]=r.value:(r.get??r.set)&&(o.access[n]||(o.access[n]={get:r.get??(()=>{}),set:r.set??(()=>{})})))}const s=getClassPrototype(Object.getPrototypeOf(t),e,n+1);return Object.assign(o.method,s.method),Object.assign(o.access,s.access),o}function blob2ArrayBuffer(t){return new Promise(function(e){const n=new FileReader;n.addEventListener("load",function(){e(n.result)}),n.readAsArrayBuffer(t)})}function sizeFormat(t,e=" "){const n=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];let o=0;for(;o<n.length-1&&t>=1024;)t/=1024,o++;return(Math.round(100*t)/100).toString()+e+n[o]}function weightFormat(t,e=" "){let n=0;for(;n<3&&t>=1e3;++n)t/=1e3;return(Math.round(100*t)/100).toString()+e+["mg","g","kg"][n]}function clone(t){if(Array.isArray(t)){const e=[];for(let n=0;n<t.length;++n)if(t[n]instanceof Date)e[n]=new Date(t[n].getTime());else if(t[n]instanceof FormData){const o=new FormData;for(const e of t[n])o.append(e[0],e[1]);e[n]=o}else null===t[n]?e[n]=null:"object"==typeof t[n]?e[n]=clone(t[n]):e[n]=t[n];return e}const e={};for(const n in t)if(t[n]instanceof Date)e[n]=new Date(t[n].getTime());else if(t[n]instanceof FormData){const o=new FormData;for(const e of t[n])o.append(e[0],e[1]);e[n]=o}else null===t[n]?e[n]=null:"object"==typeof t[n]?e[n]=clone(t[n]):e[n]=t[n];return e}function sleep$1(t=0){return new Promise(function(e){t>3e4?e(!1):window.setTimeout(function(){e(!0)},t)})}function nextFrame(){return new Promise(function(t){requestAnimationFrame(()=>{t()})})}async function sleepFrame(t){t>10&&(t=10);for(let e=0;e<t;++e)await nextFrame()}function purify(t){const e=[];let n=-1;return(t=(t=">"+t+"<").replace(/<!--([\s\S]*?)-->/g,"").replace(/<script[\s\S]+?<\/script>/g,function(t){return e.push(t),"[SCRIPT]"}).replace(/>([\s\S]*?)</g,function(t,e){return">"+e.replace(/\t|\r\n| {2}/g,"").replace(/\n|\r/g,"")+"<"}).replace(/\[SCRIPT\]/g,function(){return++n,e[n]})).slice(1,-1)}function match(t,e){for(const n of e)if(n.test(t))return!0;return!1}async function styleUrl2DataUrl(t,e,n){const o=/url\(["']{0,1}(.+?)["']{0,1}\)/gi;let r=null;for(;r=o.exec(e);){let o=urlResolve(t,r[1]);o.startsWith("/package/")&&(o=o.slice(8)),n[o]&&("string"!=typeof n[o]&&(e=e.replace(r[0],`url('${await blob2DataUrl(n[o])}')`)))}return e}function layoutAddTagClassAndReTagName(t,e){const n=[];t=(t=t.replace(/(\S+)=(".+?"|'.+?')/g,function(t,e){return"class"===e?t:(n.push(t),'"CG-PLACEHOLDER"')})).replace(/<(\/{0,1})([\w-]+)([\s\S]*?>)/g,function(t,n,o,r){return["template","slot","teleport"].includes(o)?t:"/"===n?"block"===o?"</div"+r:e?"</cg-"+o+r:t:(r=r.toLowerCase().includes(" class")?r.replace(/ class=(["']{0,1})/i," class=$1tag-"+o+" "):` class="tag-${o}"`+r,"block"===o?"<div"+r:e?"<cg-"+o+r:"<"+o+r)});let o=-1;return t.replace(/"CG-PLACEHOLDER"/g,function(){return n[++o]})}function layoutInsertAttr(t,e,n={}){return t.replace(/<([\w-]+)[\s\S]*?>/g,function(t,o){if(n.ignore)for(const e of n.ignore)if(e.test(o))return t;if(n.include){let e=!1;for(const t of n.include)if(t.test(o)){e=!0;break}if(!e)return t}return t.replace(/<[\w-]+/,function(t){return t+" "+e})})}function layoutClassPrependObject(t){return`{${(t=t.slice(1,-1).trim()).replace(/([ a-zA-Z0-9'"`[\]\-_]+)(\s*:)/g,(t,e,n)=>{if((e=e.trim()).startsWith("["))e=`[classPrepend(${e.slice(1,-1)})]`;else{let t="";e.startsWith("'")||e.startsWith('"')||e.startsWith("`")?(t=e[0],e=e.slice(1,-1)):t="'",e=`[classPrepend(${t}${e}${t})]`}return`${e}${n}`})}}`}function layoutClassPrepend(t,e){return t.replace(/ class=["'](.*?)["']/gi,function(t,n){const o=(n=n.trim()).split(/\s+/),r=[];for(const t of o)if(t)for(const n of e)t.startsWith("fa-")?r.push(`${t}`):r.push(`${n}${t}`);return` class="${r.join(" ")}"`}).replace(/ :class=(["']).*?["']((\s+[a-zA-Z0-9-_:@]+(=|\s*>))|(\s*)>)/gi,function(t,e){return t.replace(new RegExp(`:class=${e}([^${e}]+?)${e}`,"gi"),function(t,e){if((e=e.trim()).startsWith("[")){const t=parseArrayString(e);for(let e=0;e<t.length;++e)t[e]=t[e].trim(),t[e].startsWith("{")?t[e]=layoutClassPrependObject(t[e]):t[e]=`classPrepend(${t[e]})`;e=`[${t.join(",")}]`}else e=e.startsWith("{")?layoutClassPrependObject(e):`classPrepend(${e})`;return`:class="${e}"`})}).replace(/ id=(["'])/gi,` id=$1${e[0]}`)}function eventsAttrWrap(t){const e=new RegExp(`@(${["click","dblclick","pointerdown","pointerenter","pointerleave","pointerup","mousedown","mouseenter","mouseleave","mouseup","touchstart","touchmove","touchend","keydown","keypress","keyup","contextmenu"].join("|")})="(.+?)"`,"g");return t.replace(e,function(t,e,n){return/^[\w]+$/.test(n)?`@${e}="allowEvent($event) && ${n}($event)"`:`@${e}=";if(allowEvent($event)){${n}}"`})}function teleportGlue(t,e){return t.replace(/<teleport([\s\S]+?)to="(.+?)"([\s\S]+?<[\w-]+)/g,(t,n,o,r)=>"system"!==o?t:"<teleport"+n+"to=\"#cg-pop-list > [data-form-id='"+e+"']\""+r+" data-cg-pop data-cg-pop-none")}function stylePrepend(t,e=""){""===e&&(e="cg-scope"+Math.round(1e15*Math.random()).toString()+"_"),t=t.replace(/([\s\S]+?){([\s\S]+?)}/g,function(t,n,o){return n=n.replace(/(^|[ >,}\r\n])([a-zA-Z-_][a-zA-Z0-9-_]*)/g,function(t,e,n){return"global"===n?"[CGTMP-GLOBAL]":e+".tag-"+n}),n=(n=n.replace(/keyframes \.tag-([a-zA-Z0-9-_]+)/g,function(t,e){return"keyframes "+e})).replace(/([.#])([a-zA-Z0-9-_]+)/g,function(t,n,o){return n+e+o})+"{"+o+"}"});const n=[];t=t.replace(/(@font-face[\s\S]+?font-family\s*:\s*["']{0,1})(.+?)(["']{0,1}\s*[;\r\n }])/gi,function(t,o,r,s){return n.push(r),o+e+r+s});for(const o of n){const n=new RegExp(`(font.+?[: "'])(${o})`,"gi");t=t.replace(n,function(t,n,o){return n+e+o})}const o=[];t=t.replace(/([-@]keyframes *["']{0,1})([\w-]+)(["']{0,1}\s*?\{)/gi,function(t,n,r,s){return o.includes(r)||o.push(r),n+e+r+s});for(const n of o){let o=new RegExp(`(animation[ :\\r\\n]+)(${n})([ ;}\\r\\n])`,"gi");t=t.replace(o,function(t,n,o,r){return n+e+o+r}),o=new RegExp(`(animation-name[ :\\r\\n]+)(${n})([ ;}\\r\\n])`,"gi"),t=t.replace(o,function(t,n,o,r){return n+e+o+r})}return{prep:e,style:t}}function getMimeByPath(t){const e=t.lastIndexOf("."),n=(-1===e?t:t.slice(e+1)).toLowerCase();return{mime:{eot:"application/vnd.ms-fontobject",woff:"font/woff",ttf:"font/ttf",svg:"image/svg+xml",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",png:"image/png"}[n]??"application/octet-stream",ext:n}}function rand(t,e,n=0){if(n<0&&(n=0),0===n)return Math.floor(Math.random()*(e-t+1))+t;const o=Math.pow(10,n);return Math.round((Math.random()*(e-t)+t)*o)/o}const RANDOM_N="0123456789",RANDOM_U="ABCDEFGHIJKLMNOPQRSTUVWXYZ",RANDOM_L="abcdefghijklmnopqrstuvwxyz",RANDOM_UN=RANDOM_U+RANDOM_N,RANDOM_LN=RANDOM_L+RANDOM_N,RANDOM_LU=RANDOM_L+RANDOM_U,RANDOM_LUN=RANDOM_L+RANDOM_U+RANDOM_N,RANDOM_V="ACEFGHJKLMNPRSTWXY34567",RANDOM_LUNS=RANDOM_LUN+"()`~!@#$%^&*-+=_|{}[]:;'<>,.?/]\"";function random(t=8,e=RANDOM_LN,n=""){let o=n.length;if(o>0)for(let t=0;t<o;++t)e=e.replace(n[t],"");if(o=e.length,0===o)return"";let r="";for(let n=0;n<t;++n)r+=e[rand(0,o-1)];return r}function getBoolean(t){const e=typeof t;return"boolean"===e?t:"string"===e?"false"!==t:!!t}function getNumber(t){return"number"==typeof t?t:parseFloat(t)}function getArray(t){if("string"!=typeof t)return t;let e=[];if((t=t.trim()).startsWith("["))try{e=JSON.parse(t)}catch{return[]}else e=(t=t.replace(/ /g,"")).split(",");return e}function escapeHTML(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function unescapeHTML(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}function formatColor(t){const e=/[0-9.%, ]+/.exec(t);if(!e)return[];return e[0].split(",").map(t=>parseFloat(t))}function rgb2hex(t,e,n,o=1){if(void 0===e||void 0===n){if("string"!=typeof t)return"";const r=formatColor(t);t=Math.round(r[0]),e=Math.round(r[1]),n=Math.round(r[2]),o=r[3]??1}else"string"==typeof t&&(t=Math.round(parseFloat(t))),"string"==typeof e&&(e=Math.round(parseFloat(e))),"string"==typeof n&&(n=Math.round(parseFloat(n))),"string"==typeof o&&(o=parseFloat(o));return((t<<16)+(e<<8)+n).toString(16).padStart(6,"0")+(1===o?"":Math.round(255*o).toString(16).padStart(2,"0"))}function hex2rgb(t){const e={r:0,g:0,b:0,a:1,rgb:"rgb"};let n=!1,o=t.slice(t.startsWith("#")?1:0);3===o.length?o=[...o].map(t=>t+t).join(""):8===o.length&&(n=!0);const r=parseInt(o,16);return e.r=r>>>(n?24:16),e.g=(r&(n?16711680:65280))>>>(n?16:8),e.b=(r&(n?65280:255))>>>(n?8:0),n&&(e.a=Math.round((255&r)/255*100)/1e3),e.rgb=`${n?"a":""}(${e.r},${e.g},${e.b}${n?","+e.a:""})`,e}function rgb2hsl(t,e,n,o=1,r=!1){const s={h:0,s:0,l:0,a:1,hsl:"hsl"};if(void 0===e||void 0===n){if("string"!=typeof t)return s;const r=formatColor(t);t=r[0],e=r[1],n=r[2],o=r[3]??1}else"string"==typeof t&&(t=parseFloat(t)),"string"==typeof e&&(e=parseFloat(e)),"string"==typeof n&&(n=parseFloat(n)),"string"==typeof o&&(o=parseFloat(o));t/=255,e/=255,n/=255;const i=Math.min(t,e,n),a=Math.max(t,e,n),c=a-i;let l=0,d=0,f=0;return l=0==c?0:a==t?(e-n)/c%6:a==e?(n-t)/c+2:(t-e)/c+4,l=Math.round(60*l),l<0&&(l+=360),f=(a+i)/2,d=0==c?0:c/(1-Math.abs(2*f-1)),d*=100,f*=100,s.h=l,s.s=d,s.l=f,s.a=o,r||(s.h=Math.round(s.h),s.s=Math.round(s.s),s.l=Math.round(s.l)),s.hsl+=(1===s.a?"":"a")+`(${s.h},${s.s}%,${s.l}%${1===s.a?"":","+s.a})`,s}function hsl2rgb(t,e,n,o=1,r=!1){const s={r:0,g:0,b:0,a:1,rgb:"rgb"};if(void 0===e||void 0===n){if("string"!=typeof t)return s;const r=formatColor(t);t=r[0],e=r[1],n=r[2],o=r[3]??1}else"string"==typeof t&&(t=parseFloat(t)),"string"==typeof e&&(e=parseFloat(e)),"string"==typeof n&&(n=parseFloat(n)),"string"==typeof o&&(o=parseFloat(o));n/=100;const i=e=>(e+t/30)%12,a=(e/=100)*Math.min(n,1-n),c=t=>n-a*Math.max(-1,Math.min(i(t)-3,Math.min(9-i(t),1)));return s.r=255*c(0),s.g=255*c(8),s.b=255*c(4),s.a=o,r||(s.r=Math.round(s.r),s.g=Math.round(s.g),s.b=Math.round(s.b)),s.rgb+=(1===s.a?"":"a")+`(${s.r},${s.g},${s.b}${1===s.a?"":","+s.a})`,s}function request(t,e){return new Promise(function(n){const o=new XMLHttpRequest;if(!1===e.credentials&&(o.withCredentials=!1),o.upload.onloadstart=function(t){const n=e.uploadStart?.(t.total);n&&n instanceof Promise&&n.catch(()=>{})},o.upload.onprogress=function(t){const n=e.uploadProgress?.(t.loaded,t.total);n&&n instanceof Promise&&n.catch(()=>{})},o.upload.onloadend=function(){const t=e.uploadEnd?.();t&&t instanceof Promise&&t.catch(()=>{})},o.onloadstart=function(t){const n=e.start?.(t.total);n&&n instanceof Promise&&n.catch(()=>{})},o.onprogress=function(t){const n=e.progress?.(t.loaded,t.total);n&&n instanceof Promise&&n.catch(()=>{})},o.onloadend=function(){const t=e.end?.();t&&t instanceof Promise&&t.catch(()=>{})},o.onload=function(){let t=this.response;if(this.getResponseHeader("content-type")?.includes("json"))try{t=JSON.parse(t)}catch{t=this.response}const o=e.load?.(t);o&&o instanceof Promise&&o.catch(()=>{}),n(t)},o.onerror=function(){const t=e.error?.();t&&t instanceof Promise&&t.catch(()=>{}),n(null)},e.responseType&&(o.responseType=e.responseType),e.timeout&&(o.timeout=e.timeout),e.headers&&!Array.isArray(e.headers))for(const t in e.headers)o.setRequestHeader(t,e.headers[t]);o.open(e.method??"GET",t,!0),o.send(e.body)})}async function fetch$1(t,e){try{const n=await window.fetch(t,e);if(200===n.status||304===n.status){const t=n.headers.get("content-type")?.toLowerCase()??"";return["text/","javascript","json","css","xml","html"].some(e=>t.includes(e))?await n.text():await n.blob()}return null}catch{return null}}const retryTimes=[300,1e3,2e3];async function get$4(t,e,n={}){e??={},e.method="GET";const o=n.retry??3;for(let n=0;n<=o;++n){const r=await fetch$1(t,e);if(null!==r)return r;if(n===o)return null;await sleep$1(retryTimes[n])}return null}async function post(t,e,n){n??={},n.method="POST",n.headers??={},e instanceof FormData||(n.headers instanceof Headers?n.headers.set("content-type","application/json"):n.headers["content-type"]="application/json"),n.body=e instanceof FormData?e:JSON.stringify(e);return await fetch$1(t,n)}async function getResponseJson(t,e){const n=await get$4(t,e);if(!n)return null;if("string"!=typeof n)return null;try{return JSON.parse(n)}catch{return null}}function postResponseEventStream(t,e,n={}){const o=new AbortController;return setTimeout(()=>{(async()=>{try{const r=(await window.fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:o.signal})).body;if(!r)return void await(n.onTimeout?.());await(n.onStart?.());const s=r.getReader(),i=new TextDecoder("utf8");let a="";for(;;)try{const{value:t,done:e}=await s.read();if(e)break;if(a+=i.decode(t,{stream:!0}),!a.includes("\n\n"))continue;const o=a.split("\n\n");a=o.pop()??"";for(const t of o){const e=JSON.parse(t.slice(5).trim());e.init?await(n.onInit?.(e.init)):await(n.onData?.("string"==typeof e?e:e.choices?.[0]?.delta?.content??""))}}catch{break}await(n.onEnd?.())}catch{return void await(n.onTimeout?.())}})().catch(()=>{})},0),o}async function postResponseJson(t,e,n){const o=await post(t,e,n);if(!o)return null;if("string"!=typeof o)return null;try{return JSON.parse(o)}catch{return null}}function parseUrl(t){const e={protocol:null,auth:null,user:null,pass:null,host:null,hostname:null,port:null,pathname:"/",path:null,query:null,hash:null},n=t.indexOf("#");n>-1&&(e.hash=t.slice(n+1),t=t.slice(0,n));const o=t.indexOf("?");o>-1&&(e.query=t.slice(o+1),t=t.slice(0,o));const r=t.indexOf(":");if(r>-1){e.protocol=t.slice(0,r+1).toLowerCase(),(t=t.slice(r+1)).startsWith("//")&&(t=t.slice(2));let n=t.indexOf("/");-1===n&&(n=t.indexOf("\\")),n>-1&&(e.pathname=t.slice(n),t=t.slice(0,n));const o=t.indexOf("@");if(o>-1){const n=t.slice(0,o),r=n.indexOf(":");r>-1?(e.user=n.slice(0,r),e.pass=n.slice(r+1),e.auth=e.user+":"+e.pass):(e.user=n,e.auth=n),t=t.slice(o+1)}if(t){const n=t.indexOf(":");n>-1?(e.hostname=t.slice(0,n).toLowerCase(),e.port=t.slice(n+1),e.host=e.hostname+(e.port?":"+e.port:"")):(e.hostname=t.toLowerCase(),e.host=e.hostname)}}else e.pathname=t;return e.path=e.pathname+(e.query?"?"+e.query:""),e}function urlResolve(t,e){if(t=t.replace(/\\/g,"/"),""===(e=e.replace(/\\/g,"/")))return urlAtom(t);const n=parseUrl(t);if(e.startsWith("//"))return urlAtom(n.protocol?n.protocol+e:e);n.protocol&&(t=n.protocol+t.slice(n.protocol.length));const o=parseUrl(e);if(o.protocol)return urlAtom(o.protocol+e.slice(o.protocol.length));if(e.startsWith("#")||e.startsWith("?")){const n=t.indexOf(e[0]);return urlAtom(-1!==n?t.slice(0,n)+e:t+e)}let r=(n.auth?n.auth+"@":"")+(n.host??"");if(e.startsWith("/"))r+=e;else{r+=n.pathname.replace(/\/[^/]*$/g,"")+"/"+e}return n.protocol&&"file:"!==n.protocol&&!n.host?urlAtom(n.protocol+r):urlAtom((n.protocol?n.protocol+"//":"")+r)}function urlAtom(t){for(;t.includes("/./");)t=t.replace(/\/\.\//g,"/");for(;/\/(?!\.\.)[^/]+\/\.\.\//.test(t);)t=t.replace(/\/(?!\.\.)[^/]+\/\.\.\//g,"/");return t=t.replace(/\.\.\//g,"")}function blob2Text(t){return new Promise(function(e){const n=new FileReader;n.addEventListener("load",function(t){t.target?e(t.target.result):e("")}),n.readAsText(t)})}function blob2DataUrl(t){return new Promise(function(e){const n=new FileReader;n.addEventListener("load",function(t){t.target?e(t.target.result):e("")}),n.readAsDataURL(t)})}function execCommand(t){["copy","cut"].includes(t)&&document.execCommand(t)}function compar(t,e){const n={remove:{},add:{},length:{remove:0,add:0}};for(let o=0;o<t.length;++o){const r=t[o];e.includes(r)||(n.remove[r]=o,++n.length.remove)}for(let o=0;o<e.length;++o){const r=e[o];t.includes(r)||(n.add[r]=o,++n.length.add)}return n}function formatSecond(t){const e=Math.floor(t/3600);t-=3600*e;const n=Math.floor(t/60),o=Math.floor(t-60*n);return(e?e.toString().padStart(2,"0")+":":"")+n.toString().padStart(2,"0")+":"+o.toString().padStart(2,"0")}function formatTime(t,e){const n={date:"",time:"",zone:""};"number"==typeof t&&(t=new Date(t));const o=e??-t.getTimezoneOffset()/60;return t.setTime(t.getTime()+60*o*6e4),n.date=t.getUTCFullYear().toString()+"-"+(t.getUTCMonth()+1).toString().padStart(2,"0")+"-"+t.getUTCDate().toString().padStart(2,"0"),n.time=t.getUTCHours().toString().padStart(2,"0")+":"+t.getUTCMinutes().toString().padStart(2,"0")+":"+t.getUTCSeconds().toString().padStart(2,"0"),n.zone="UTC"+(o>=0?"+":"")+o.toString(),n}function isMs(t){return t>1e12}function queryStringify(t,e=!0){return e?Object.entries(t).map(([t,e])=>Array.isArray(e)?e.map(e=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&"):`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&"):Object.entries(t).map(([t,e])=>Array.isArray(e)?e.map(e=>`${t}=${e}}`).join("&"):`${t}=${e}`).join("&")}function queryParse(t){const e={},n={};for(const o of t.split("&")){if(!o.length)continue;const t=o.indexOf("="),r=decodeURIComponent(-1===t?o:o.slice(0,t)),s=-1===t?"":decodeURIComponent(o.slice(t+1));n[r]?e[r].push(s):void 0===e[r]?e[r]=s:(e[r]=[e[r],s],n[r]=!0)}return e}function isEscaped(t,e){let n=0;for(let o=e-1;o>=0&&"\\"===t[o];o--)n++;return n%2!=0}function parseArrayString(t){const e=t.trim().slice(1,-1),n=[];let o="",r=0,s=!1,i="";for(let t=0;t<e.length;t++){const a=e[t];if('"'!==a&&"'"!==a||s?a===i&&s&&!isEscaped(e,t)&&(s=!1,i=""):(s=!0,i=a),!s)if("{"===a||"["===a||"("===a)r++;else if("}"===a||"]"===a||")"===a)r--;else if(","===a&&0===r){o.trim()&&n.push(o.trim()),o="";continue}o+=a}return o.trim()&&n.push(o.trim()),n}function isEscapeChar(t,e){let n=t[e-1],o=0;for(;"\\"===n;)n=t[e-++o-1];return o%2!=0}var ESTATE;function stateMachine(t,e,n){let o=ESTATE.NORMAL;t=t.replace(/\r\n/g,"\n").replace(/\r/g,"\n");const r={s:0,m:0,l:0};let s="",i="",a={state:ESTATE.NORMAL,word:"",nonnull:""};for(let c=e;c<t.length;++c){const e=t[c];switch(o){case ESTATE.COMMENT:if("*"===s){if("*"===e&&"/"===t[c+1]){if(i+=e+t[++c],c>=0&&!n({state:o,start:c-i.length+1,end:c,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const l=i.trim();l&&(a.nonnull=l),o=ESTATE.NORMAL,i="",s=""}else i+=e;break}if("\n"===e){if(--c,!n({state:o,start:c-i.length+1,end:c,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.NORMAL,i="",s=""}else i+=e;break;case ESTATE.REG:switch(e){case"[":isEscapeChar(t,c)||(s="["),i+=e;break;case"]":isEscapeChar(t,c)||"["!==s||(s="/"),i+=e;break;case"/":isEscapeChar(t,c)||"/"!==s||(s="e"),i+=e;break;default:{if("e"!==s){i+=e;break}if(/\w/.test(e)){i+=e;break}if(--c,!n({state:o,start:c-i.length+1,end:c,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.NORMAL,i="",s=""}}break;case ESTATE.STRING:if(i+=e,e===s&&!isEscapeChar(t,c)){if(!n({state:o,start:c-i.length+1,end:c,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.NORMAL,i="",s=""}break;case ESTATE.WORD:if(!/[$\w]/.test(e)){if(--c,!n({state:o,start:c-i.length+1,end:c,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.NORMAL,i="",s="";break}i+=e;break;default:switch(e){case'"':case"'":case"`":{if(c-1>=0&&!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.STRING,i=e,s=e;break}case"/":{if("/"===t[c+1]){if(c-1>=0&&!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const l=i.trim();l&&(a.nonnull=l),o=ESTATE.COMMENT,i=e+t[++c],s=e;break}if("*"===t[c+1]){if(c-1>=0&&!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const l=i.trim();l&&(a.nonnull=l),o=ESTATE.COMMENT,i=e+t[++c],s=t[c];break}let l="";for(let d=c-1;d>=0;--d)if(l){if(!/[$\w]/.test(t[d]))break;l=t[d]+l}else{if(/\s/.test(t[d]))continue;if(")"===t[d]||"]"===t[d])break;if(!/[$\w]/.test(t[d])){if(c-1>=0&&!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.REG,i=e,s=e;break}l=t[d]}if(l&&"return"===l){if(c-1>=0&&!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.REG,i=e,s=e}o!==ESTATE.REG&&(i+=e);break}case"(":if(i.includes("(")||i.includes(")")){if(!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.word=i;const t=i.trim();t&&(a.nonnull=t),i="",s=""}i+=e,++r.s;break;case")":if(i.includes("(")||i.includes(")")){if(!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.word=i;const t=i.trim();t&&(a.nonnull=t),i="",s=""}i+=e,--r.s;break;case"[":if(i.includes("[")||i.includes("]")){if(!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.word=i;const t=i.trim();t&&(a.nonnull=t),i="",s=""}i+=e,++r.m;break;case"]":if(i.includes("[")||i.includes("]")){if(!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.word=i;const t=i.trim();t&&(a.nonnull=t),i="",s=""}i+=e,--r.m;break;case"{":if(i.includes("{")||i.includes("}")){if(!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.word=i;const t=i.trim();t&&(a.nonnull=t),i="",s=""}i+=e,++r.l;break;case"}":if(i.includes("{")||i.includes("}")){if(!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.word=i;const t=i.trim();t&&(a.nonnull=t),i="",s=""}i+=e,--r.l;break;default:if(/[$\w]/.test(e)){if(c-1>=0&&!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.WORD,i=e,s=e;break}i+=e}}}if(i){const e=t.length-1;n({state:o,start:e-i.length+1,end:e,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r})}}let headElement;function getHeadElement(){if(!headElement){const t=document.querySelectorAll("head");headElement=t[t.length-1]}return headElement}async function loadScript(t){return new Promise(e=>{const n=document.createElement("script");n.addEventListener("load",function(){e(!0)}),n.addEventListener("error",function(){e(!1)}),n.src=t,getHeadElement().appendChild(n)})}async function loadScripts(t,e={}){await Promise.all(t.map(async t=>{const n=await loadScript(t);e.loaded?.(t,n?1:0)}))}async function loadLink(t,e="after"){return new Promise(n=>{const o=getHeadElement(),r=document.createElement("link");r.addEventListener("load",function(){n(!0)}),r.addEventListener("error",function(){n(!1)}),r.href=t,r.rel="stylesheet","before"===e?o.insertBefore(r,o.firstChild):o.appendChild(r)})}async function loadLinks(t,e={}){await Promise.all(t.map(async t=>{const n=await loadLink(t);e.loaded?.(t,n?1:0)}))}function loadStyle(t){const e=document.createElement("style");e.innerHTML=t,getHeadElement().appendChild(e)}function isFalsy(t){return null==t||""===t||!1===t||0===t}function isTruthy(t){return!isFalsy(t)}function logicalOr(t,e){return isFalsy(t)?e:t}!function(t){t[t.NORMAL=0]="NORMAL",t[t.WORD=1]="WORD",t[t.STRING=2]="STRING",t[t.REG=3]="REG",t[t.COMMENT=4]="COMMENT"}(ESTATE||(ESTATE={}));const lang={codes:["sc","tc","ja","ko","th","vi","ar","id","en","es","de","fr","pt","ru","it","tr"],names:["简体中文","繁體中文","日本語","한국어","ไทย","Tiếng việt","العربية","Bahasa Indonesia","English","Español","Deutsch","Français","Português","Русский","Italiano","Türkçe"],map:{cn:"sc",zh:"tc",ja:"ja",ko:"ko",th:"th",vi:"vi",ar:"ar",id:"id",en:"en",es:"es",de:"de",fr:"fr",pt:"pt",ru:"ru",it:"it",tr:"tr"},getCodeByAccept:t=>{if(t??=navigator.language,"*"===t)return"sc";const e=t.toLowerCase();for(const t in lang.map)if(e.includes(t))return lang.map[t];return"en"}};var tool=Object.freeze({__proto__:null,get ESTATE(){return ESTATE},RANDOM_L:RANDOM_L,RANDOM_LN:RANDOM_LN,RANDOM_LU:RANDOM_LU,RANDOM_LUN:RANDOM_LUN,RANDOM_LUNS:RANDOM_LUNS,RANDOM_N:RANDOM_N,RANDOM_U:RANDOM_U,RANDOM_UN:RANDOM_UN,RANDOM_V:RANDOM_V,blob2ArrayBuffer:blob2ArrayBuffer,blob2DataUrl:blob2DataUrl,blob2Text:blob2Text,clone:clone,compar:compar,compressor:compressor,escapeHTML:escapeHTML,eventsAttrWrap:eventsAttrWrap,execCommand:execCommand,fetch:fetch$1,formatColor:formatColor,formatSecond:formatSecond,formatTime:formatTime,get:get$4,getArray:getArray,getBoolean:getBoolean,getClassPrototype:getClassPrototype,getMimeByPath:getMimeByPath,getNumber:getNumber,getResponseJson:getResponseJson,hex2rgb:hex2rgb,hsl2rgb:hsl2rgb,isEscapeChar:isEscapeChar,isEscaped:isEscaped,isFalsy:isFalsy,isMs:isMs,isTruthy:isTruthy,lang:lang,layoutAddTagClassAndReTagName:layoutAddTagClassAndReTagName,layoutClassPrepend:layoutClassPrepend,layoutInsertAttr:layoutInsertAttr,loadLink:loadLink,loadLinks:loadLinks,loadScript:loadScript,loadScripts:loadScripts,loadStyle:loadStyle,logicalOr:logicalOr,match:match,nextFrame:nextFrame,parseArrayString:parseArrayString,parseUrl:parseUrl,post:post,postResponseEventStream:postResponseEventStream,postResponseJson:postResponseJson,purify:purify,queryParse:queryParse,queryStringify:queryStringify,rand:rand,random:random,request:request,rgb2hex:rgb2hex,rgb2hsl:rgb2hsl,runIife:runIife,sizeFormat:sizeFormat,sleep:sleep$1,sleepFrame:sleepFrame,stateMachine:stateMachine,stylePrepend:stylePrepend,styleUrl2DataUrl:styleUrl2DataUrl,teleportGlue:teleportGlue,unescapeHTML:unescapeHTML,urlAtom:urlAtom,urlResolve:urlResolve,weightFormat:weightFormat});let sysId$9="";function initSysId$8(t){sysId$9||(sysId$9=t)}const token=random(32,RANDOM_LUNS),methods={};function on(t,e,n,o=!1,r){"string"!=typeof t&&(t=t.taskId),getOrigin(t)&&(methods[t]||(methods[t]={}),methods[t][e+"-"+(r?r.toString():"")]={once:o,handler:n})}function once(t,e,n,o){on(t,e,n,!0,o)}function off(t,e,n){if("string"!=typeof t&&(t=t.taskId),!methods[t])return;const o=e+"-"+(n?n.toString():"");methods[t][o]&&delete methods[t][o]}function clear$2(t,e){if("string"!=typeof t&&(t=t.taskId),methods[t])if(e)for(const n in methods[t])n.endsWith("-"+e.toString())&&delete methods[t][n];else delete methods[t]}function getListenerList(t){void 0!==t&&"string"!=typeof t&&(t=t.taskId);const e={};for(const n in methods)if(!t||n===t){e[n]={};for(const t in methods[n]){const o=t.lastIndexOf("-"),r=t.slice(0,o),s=t.slice(o+1);e[n][s]||(e[n][s]={}),e[n][s][r]?++e[n][s][r]:e[n][s][r]=1}}return e}async function invoke(t,...e){return isNative()?window.clickgoNative.invoke(t,...e):null}async function invokeSys(t,e,...n){if(t===sysId$9)return invoke(e,token,...n)}async function quit(t){return!!(await checkPermission(t,"root"))[0]&&(await invoke("cg-quit",token),!0)}async function size(t,e,n){return!!(await checkPermission(t,"native.form"))[0]&&(await invoke("cg-set-size",token,e,n),!0)}async function max$1(t){return!!(await checkPermission(t,"native.form"))[0]&&(await invoke("cg-set-state",token,"max"),!0)}async function min$1(t){return!!(await checkPermission(t,"native.form"))[0]&&(await invoke("cg-set-state",token,"min"),!0)}async function unmaximize(t){return!!(await checkPermission(t,"native.form"))[0]&&(await invoke("cg-set-state",token,"unmaximize"),!0)}async function restore(t){return!!(await checkPermission(t,"native.form"))[0]&&(await invoke("cg-set-state",token,"restore"),!0)}async function activate(t){return!!(await checkPermission(t,"native.form"))[0]&&(await invoke("cg-activate",token),!0)}async function close$1(t){return!!(await checkPermission(t,"root"))[0]&&(await invoke("cg-close",token),!0)}async function maximizable(t,e){return!!(await checkPermission(t,"native.form"))[0]&&(await invoke("cg-maximizable",token,e),!0)}function open$1(t={}){return invoke("cg-form-open",token,t)}function save(t={}){return invoke("cg-form-save",token,t)}function dialog$1(t={}){return invoke("cg-form-dialog",token,t)}async function ping(t){return invoke("cg-ping",t)}async function isMax(){return invoke("cg-is-max")}window.clickgoNativeWeb={invoke:function(t,...e){for(const n in methods)for(const o in methods[n])o.startsWith(t+"-")&&(methods[n][o].handler(...e),methods[n][o].once&&(delete methods[n][o],Object.keys(methods[n]).length||delete methods[n]))}};let inited$4=!1;function init$5(){inited$4||(inited$4=!0,invoke("cg-init",token))}var native$1=Object.freeze({__proto__:null,activate:activate,clear:clear$2,close:close$1,dialog:dialog$1,getListenerList:getListenerList,init:init$5,initSysId:initSysId$8,invoke:invoke,invokeSys:invokeSys,isMax:isMax,max:max$1,maximizable:maximizable,min:min$1,off:off,on:on,once:once,open:open$1,ping:ping,quit:quit,restore:restore,save:save,size:size,unmaximize:unmaximize});let sysId$8="";function initSysId$7(t){sysId$8||(sysId$8=t)}let index$2=-1,focusId$1=null;const info={bottomLastZIndex:999,lastZIndex:999999,topLastZIndex:99999999,locale:{en:{ok:"OK",yes:"Yes",no:"No",cancel:"Cancel",search:"Search",confirmExitStep:"This operation will exit the current process. Are you sure you want to exit?"},sc:{ok:"好",yes:"是",no:"否",cancel:"取消",search:"搜索",confirmExitStep:"此操作将退出当前流程,确定退出吗?"},tc:{ok:"好",yes:"是",no:"否",cancel:"取消",search:"檢索",confirmExitStep:"此操作將結束目前的流程,確定退出嗎?"},ja:{ok:"好",yes:"はい",no:"いいえ",cancel:"キャンセル",search:"検索",confirmExitStep:"この操作は現在のプロセスを終了します。本当に終了しますか?"},ko:{ok:"확인",yes:"예",no:"아니오",cancel:"취소",search:"검색",confirmExitStep:"이 작업은 현재 프로세스를 종료합니다. 종료하시겠습니까?"},th:{ok:"ตกลง",yes:"ใช่",no:"ไม่",cancel:"ยกเลิก",search:"ค้นหา",confirmExitStep:"การดำเนินการนี้จะออกจากกระบวนการปัจจุบัน ยืนยันที่จะออกไหม?"},es:{ok:"Aceptar",yes:"Sí",no:"No",cancel:"Cancelar",search:"Buscar",confirmExitStep:"Esta operación cerrará el proceso actual. ¿Estás seguro de que quieres salir?"},de:{ok:"OK",yes:"Ja",no:"Nein",cancel:"Abbrechen",search:"Suchen",confirmExitStep:"Diese Aktion beendet den aktuellen Prozess. Möchten Sie wirklich beenden?"},fr:{ok:"OK",yes:"Oui",no:"Non",cancel:"Annuler",search:"Rechercher",confirmExitStep:"Cette opération va quitter le processus en cours. Êtes-vous sûr de vouloir quitter ?"},pt:{ok:"OK",yes:"Sim",no:"Não",cancel:"Cancelar",search:"Buscar",confirmExitStep:"Esta operação encerrará o processo atual. Você tem certeza de que deseja sair?"},ru:{ok:"OK",yes:"Да",no:"Нет",cancel:"Отмена",search:"Поиск",confirmExitStep:"Эта операция завершит текущий процесс. Вы уверены, что хотите выйти?"},vi:{ok:"OK",yes:"Có",no:"Không",cancel:"Hủy bỏ",search:"Tìm kiếm",confirmExitStep:"Thao tác này sẽ thoát khỏi quy trình hiện tại. Bạn có chắc chắn muốn thoát không?"}}};class AbstractCommon{get filename(){return""}get controlName(){return"root"}set controlName(t){notify({title:"Error",content:`The software tries to modify the system variable "controlName".\nPath: ${this.path}`,type:"danger"})}get taskId(){return""}get formId(){return""}set formFocus(t){notify({title:"Error",content:`The software tries to modify the system variable "formFocus".\nPath: ${this.path}`,type:"danger"})}get path(){return""}get prep(){return""}get locale(){const t=getOrigin(this.taskId);return logicalOr(t?.locale.lang??"",config.locale)}get l(){const t=getOrigin(this.taskId);return(e,n,o=!1)=>{const r=t?.locale.data[this.locale]?.[e]??t?.locale.data.en?.[e]??(o?"":"[LocaleError]")+e;if(!n)return r;let s=-1;return r.replace(/\?/g,function(){return++s,n[s]?n[s]:""})}}get classPrepend(){return t=>"string"!=typeof t?t:`cg-task${this.taskId}_${t}${this.prep?" "+this.prep+t:""}`}watch(t,e,n={}){return this.$watch(t,e,n)}get refs(){return this.$refs}get element(){return this.$el}get nextTick(){return this.$nextTick}allowEvent(t){return modules.pointer.allowEvent(t)}async trigger(t,e="",n=""){["formTitleChanged","formIconChanged","formStateMinChanged","formStateMaxChanged","formShowChanged"].includes(t)&&await trigger(t,this.taskId,this.formId,e,n)}send(t,e){e.taskId=this.taskId,e.formId=this.formId,send(t,e)}onBeforeCreate(){}onCreated(){}onBeforeMount(){}onBeforeUpdate(){}onUpdated(){}onBeforeUnmount(){}onUnmounted(){}}class AbstractPanel extends AbstractCommon{get panelId(){return""}get rootForm(){return{}}get rootPanel(){return{}}get formHash(){return this.rootForm.formHash}set formHash(t){this.rootForm.formHash=t}get formHashData(){return this.rootForm.formHashData}set formHashData(t){this.rootForm.formHashData=t}async formHashBack(){await this.rootForm.formHashBack()}sendToRootPanel(t){this.rootPanel.send(t)}async enterStep(t){return this.rootForm.enterStep(t)}async doneStep(){await this.rootForm.doneStep()}qs={};clearQs(){this.qs={}}get formFocus(){return this.rootForm.formFocus??!1}onShow(){}onShowed(){}onHide(){}onMounted(){}onReceive(){}onQsChange(){}onQsChangeShow(){}}class AbstractForm extends AbstractCommon{isReady=!1;isNativeNoFrameFirst=!1;get findex(){return 0}get formHash(){return""}set formHash(t){}get formHashData(){return{}}set formHashData(t){}get topMost(){return!1}set topMost(t){}get bottomMost(){return!1}set bottomMost(t){}get isMask(){if(!getOrigin(this.taskId))return!1;const t=getRuntime(sysId$8,this.taskId);return!!t&&!(!t.dialogFormIds.length||t.dialogFormIds[t.dialogFormIds.length-1]===this.formId)}get formFocus(){return this._formFocus}get showInSystemTask(){return!1}set showInSystemTask(t){}ready(t){t()}async formHashBack(){const t=this;if(Date.now()-t.$data._lastFormHashData>300&&(t.$data._formHashData={}),!t.$data._historyHash.length){if(t.$data._formHash){if(this.inStep){if(!await confirm(this,{content:info.locale[this.locale].confirmExitStep}))return;this._inStep=!1,this.refs.form.stepHide()}return t.$data._formHash="",void await trigger("formHashChange",this.taskId,this.formId,"",t.$data._formHashData)}return}const e=t.$data._historyHash[t.$data._historyHash.length-1];if(this.inStep)if(this._stepValues.includes(e))this.refs.form.stepValue=e;else{if(!await confirm(this,{content:info.locale[this.locale].confirmExitStep}))return;this._inStep=!1,this.refs.form.stepHide()}t.$data._formHash=e,t.$data._historyHash.splice(-1),await trigger("formHashChange",this.taskId,this.formId,e,t.$data._formHashData)}sendToPanel(t,e){t.send(e)}_loading=!1;get loading(){return this._loading}set loading(t){this.lockLoading||(this._loading=t)}lockLoading=!1;_inStep=!1;get inStep(){return this._inStep}_stepValues=[];async enterStep(t){if(this._inStep)return!1;if(t[0].value!==this.formHash)return!1;this._inStep=!0,this._stepValues.length=0;for(const e of t)this._stepValues.push(e.value);return this.refs.form.stepData=t,this.refs.form.stepValue=this.formHash,await this.nextTick(),this.refs.form.stepShow(),!0}updateStep(t,e){return!this._inStep&&(void 0!==this._stepValues[t]&&(this._stepValues[t]=e,!0))}async doneStep(){this._inStep&&(this._inStep=!1,await this.refs.form.stepDone())}_firstShow=!0;async show(){if(this._firstShow){this._firstShow=!1;const t=getAvailArea();this.refs.form.stateMaxData||(-1===this.refs.form.left&&this.refs.form.setPropData("left",(t.width-this.element.offsetWidth)/2),-1===this.refs.form.top&&this.refs.form.setPropData("top",(t.height-this.element.offsetHeight)/2)),this.refs.form.$data.isShow=!0,await changeFocus(this.formId)}else this.refs.form.$data.isShow=!0}async showDialog(){if(!getOrigin(this.taskId))return"";const t=getRuntime(sysId$8,this.taskId);return t?(t.dialogFormIds.push(this.formId),await this.show(),this.topMost=!0,new Promise(t=>{this.cgDialogCallback=()=>{t(this.dialogResult)}})):""}hide(){this.$refs.form.$data.isShow=!1}close(){close(this.formId)}dialogResult="";onMounted(){}onReceive(){}onScreenResize(){}onConfigChanged(){}onFormCreated(){}onFormRemoved(){}onFormTitleChanged(){}onFormIconChanged(){}onFormStateMinChanged(){}onFormStateMaxChanged(){}onFormShowChanged(){}onFormFocused(){}onFormBlurred(){}onFormFlash(){}onFormShowInSystemTaskChange(){}onFormHashChange(){}onTaskStarted(){}onTaskEnded(){}onLauncherFolderNameChanged(){}onHashChanged(){}onKeydown(){}onKeyup(){}}const popInfo={list:[],elList:[],wayList:[],time:[],lastZIndex:0};let simpleSystemTaskRoot,launcherRoot,superConfirmHandler;const elements={wrap:document.createElement("div"),list:document.createElement("div"),popList:document.createElement("div"),circular:document.createElement("div"),rectangle:document.createElement("div"),keyboard:document.createElement("div"),notify:document.createElement("div"),alert:document.createElement("div"),simpletask:document.createElement("div"),launcher:document.createElement("div"),confirm:document.createElement("div"),init:function(){this.wrap.id="cg-wrap",document.getElementsByTagName("body")[0].appendChild(this.wrap),this.wrap.addEventListener("touchmove",function(t){t.target&&findParentByData(t.target,"cg-scroll")||t.cancelable&&t.preventDefault()},{passive:!1}),this.wrap.addEventListener("wheel",function(t){t.target&&(void 0!==t.target.dataset.cgScroll||findParentByData(t.target,"cg-scroll"))||t.preventDefault()},{passive:!1}),this.wrap.addEventListener("contextmenu",function(t){t.preventDefault()}),this.list.id="cg-form-list",this.wrap.appendChild(this.list),this.popList.id="cg-pop-list",this.wrap.appendChild(this.popList),this.circular.id="cg-circular",this.wrap.appendChild(this.circular),this.rectangle.setAttribute("data-pos",""),this.rectangle.id="cg-rectangle",this.wrap.appendChild(this.rectangle),this.notify.id="cg-notify",this.wrap.appendChild(this.notify),this.alert.id="cg-alert",this.wrap.appendChild(this.alert),this.simpletask.id="cg-simpletask",this.wrap.appendChild(this.simpletask);modules.vue.createApp({template:'<div v-for="(item, formId) of forms" class="cg-simpletask-item" @click="click(formId)"><div v-if="item.icon" class="cg-simpletask-icon" :style="{\'background-image\': \'url(\' + item.icon + \')\'}"></div><div>{{item.title}}</div></div>',data:function(){return{forms:{}}},watch:{forms:{handler:function(){Object.keys(this.forms).length>0?"0px"!==elements.simpletask.style.bottom&&(elements.simpletask.style.bottom="0px",trigger("screenResize").catch(()=>{})):"0px"===elements.simpletask.style.bottom&&(elements.simpletask.style.bottom="-46px",trigger("screenResize").catch(()=>{}))},deep:!0}},methods:{click:async function(t){await changeFocus(t)}},mounted:function(){simpleSystemTaskRoot=this}}).mount("#cg-simpletask"),this.launcher.id="cg-launcher",this.wrap.appendChild(this.launcher);const t=function(){if(!config)return void setTimeout(function(){t()},150);const e=modules.vue.createApp({template:'<div class="cg-launcher-search"><input v-if="folderName === \'\'" class="cg-launcher-sinput" :placeholder="search" v-model="name"><input v-else class="cg-launcher-foldername" :value="folderName" @change="folderNameChange"></div><div class="cg-launcher-list" @pointerdown="down" @click="listClick" :class="[folderName === \'\' ? \'\' : \'cg-folder-open\']"><div v-for="item of list" class="cg-launcher-item"><div class="cg-launcher-inner"><div v-if="!item.list || item.list.length === 0" class="cg-launcher-icon" :style="{\'background-image\': \'url(\' + item.icon + \')\'}" @click="iconClick($event, item)"></div><div v-else class="cg-launcher-folder" @click="openFolder($event, item)"><div><div v-for="sub of item.list" class="cg-launcher-item"><div class="cg-launcher-inner"><div class="cg-launcher-icon" :style="{\'background-image\': \'url(\' + sub.icon + \')\'}" @click="subIconClick($event, sub)"></div><div class="cg-launcher-name">{{sub.name}}</div></div><div class="cg-launcher-space"></div></div></div></div><div class="cg-launcher-name">{{item.name}}</div></div><div class="cg-launcher-space"></div></div></div>',data:function(){return{name:"",folderName:"",folderItem:{}}},computed:{search:function(){return info.locale[config.locale]?.search??info.locale.en.search},list:function(){if(""===this.name)return config["launcher.list"];const t=[];for(const e of config["launcher.list"])if(e.list&&e.list.length>0)for(const n of e.list)n.name.toLowerCase().includes(this.name.toLowerCase())&&t.push(n);else e.name.toLowerCase().includes(this.name.toLowerCase())&&t.push(e);return t}},methods:{down:function(t){this.md=t.pageX+t.pageY},listClick:function(t){this.md===t.pageX+t.pageY&&t.currentTarget===t.target&&(""===this.folderName?hideLauncher():this.closeFolder())},iconClick:async function(t,e){this.md===t.pageX+t.pageY&&(hideLauncher(),await run(sysId$8,e.path,{icon:e.icon}))},subIconClick:async function(t,e){this.md===t.pageX+t.pageY&&(hideLauncher(),await run(sysId$8,e.path,{icon:e.icon}))},closeFolder:function(){this.folderName="";const t=this.folderEl,e=t.parentNode.getBoundingClientRect();t.classList.remove("cg-show"),t.style.left=(e.left+30).toString()+"px",t.style.top=e.top.toString()+"px",t.style.width="",t.style.height="",setTimeout(()=>{t.style.position="",t.style.left="",t.style.top=""},150)},openFolder:function(t,e){if(this.md!==t.pageX+t.pageY)return;if(t.currentTarget.childNodes[0]!==t.target)return;if(""!==this.folderName)return void this.closeFolder();this.folderName=e.name,this.folderItem=e;const n=t.currentTarget.childNodes.item(0);this.folderEl=n;const o=document.getElementsByClassName("cg-launcher-search")[0],r=n.getBoundingClientRect();n.style.left=r.left.toString()+"px",n.style.top=r.top.toString()+"px",n.style.position="fixed",requestAnimationFrame(()=>{n.classList.add("cg-show"),n.style.left="50px",n.style.top=o.offsetHeight.toString()+"px",n.style.width="calc(100% - 100px)",n.style.height="calc(100% - 50px - "+o.offsetHeight.toString()+"px)"})},folderNameChange:function(t){const e=t.target,n=e.value.trim();""!==n?(this.folderName=n,trigger("launcherFolderNameChanged",this.folderItem.id??"",n).catch(()=>{})):e.value=this.folderName}},mounted:function(){launcherRoot=this}});e.mount("#cg-launcher")};t(),this.confirm.id="cg-confirm",this.wrap.appendChild(this.confirm),this.confirm.innerHTML='<div class="cg-confirm-box"><div id="cg-confirm-content"></div><div class="cg-confirm-controls"><div id="cg-confirm-cancel"></div><div id="cg-confirm-ok"></div></div></div>',this.confirm.style.display="none",document.getElementById("cg-confirm-cancel").addEventListener("click",()=>{superConfirmHandler?.(!1),this.confirm.style.display="none",getMaxZIndexID(sysId$8).then(t=>{t&&changeFocus(t).catch(()=>{})}).catch(()=>{})}),document.getElementById("cg-confirm-ok").addEventListener("click",()=>{superConfirmHandler?.(!0),this.confirm.style.display="none",getMaxZIndexID(sysId$8).then(t=>{t&&changeFocus(t).catch(()=>{})}).catch(()=>{})}),this.keyboard.id="cg-keyboard",this.wrap.appendChild(this.keyboard),this.keyboard.innerHTML='<div v-for="line of list"><div v-for="row of line" :style="{\'width\': row[2] ? (row[2] * 50 + \'px\') : \'50px\'}" :class="[!row[0]&&\'cg-keyboard-null\',row[0]===\'Caps\'&&caps&&\'cg-keyboard-checked\',row[0]===\'Shift\'&&shift&&\'cg-keyboard-checked\']" @click="click(row)"><div v-if="row[1]">{{row[1]}}</div><svg v-if="row[0] === \'[x]\'" width="24" height="24" viewBox="0 0 24 24" stroke="none"><path d="m7.53033 6.46967c-.29289-.29289-.76777-.29289-1.06066 0s-.29289.76777 0 1.06066l4.46963 4.46967-4.46963 4.4697c-.29289.2929-.29289.7677 0 1.0606s.76777.2929 1.06066 0l4.46967-4.4696 4.4697 4.4696c.2929.2929.7677.2929 1.0606 0s.2929-.7677 0-1.0606l-4.4696-4.4697 4.4696-4.46967c.2929-.29289.2929-.76777 0-1.06066s-.7677-.29289-1.0606 0l-4.4697 4.46963z" /></svg><div v-else>{{row[0]}}</div></div></div>';modules.vue.createApp({data:function(){return{caps:!1,shift:!1,list:[[["`","~"],["1","!"],["2","@"],["3","#"],["4","$"],["5","%"],["6","^"],["7","&"],["8","*"],["9","("],["0",")"],["-","_"],["=","+"],["Back","",1.2]],[["Tab","",1.2],["q","Q"],["w","W"],["e","E"],["r","R"],["t","T"],["y","Y"],["u","U"],["i","I"],["o","O"],["p","P"],["[","{"],["]","}"],["\\","|"]],[["Caps","",1.6],["a","A"],["s","S"],["d","D"],["f","F"],["g","G"],["h","H"],["j","J"],["k","K"],["l","L"],[";",":"],["'",'"'],["Enter","",1.6]],[["Shift","",2],["z","Z"],["x","X"],["c","C"],["v","V"],["b","B"],["n","N"],["m","M"],[",","<"],[".",">"],["/","?"],["","",2.2]],[["","",4.2],[" "," ",5.8],["[x]","",4.2]]]}},methods:{click:function(t){if(t[0])switch(t[0]){case"Tab":document.execCommand("insertText",!1,"\t");break;case"Back":document.execCommand("delete");break;case"Caps":this.caps=!this.caps;break;case"Enter":document.execCommand("insertText",!1,"\n");break;case"Shift":this.shift=!this.shift;break;case"[x]":hideKeyboard();break;case"`":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"0":case"-":case"=":document.execCommand("insertText",!1,t[this.shift?1:0]),this.shift&&(this.shift=!1);break;default:{let e=this.caps;this.shift&&(e=!e),document.execCommand("insertText",!1,t[e?1:0]),this.shift&&(this.shift=!1)}}}}}).mount("#cg-keyboard");this.keyboard.addEventListener("pointerdown",t=>{t.preventDefault(),t.stopPropagation(),modules.pointer.move(t,{object:t.currentTarget,move:(t,e)=>{this.keyboard.style.left=parseFloat(this.keyboard.style.left)+e.ox+"px",this.keyboard.style.top=parseFloat(this.keyboard.style.top)+e.oy+"px"}})})}};function superConfirm(t,e){return new Promise(n=>{t===sysId$8&&(void 0===superConfirmHandler?(elements.confirm.style.display="flex",document.getElementById("cg-confirm-content").innerHTML=e,document.getElementById("cg-confirm-cancel").innerHTML=info.locale[config.locale]?.cancel??info.locale.en.cancel,document.getElementById("cg-confirm-ok").innerHTML=info.locale[config.locale]?.ok??info.locale.en.ok,superConfirmHandler=t=>{superConfirmHandler=void 0,n(t)}):n(!1))})}function showKeyboard(){is.keyboard||(is.keyboard=!0,elements.keyboard.style.display="flex",requestAnimationFrame(()=>{elements.keyboard.style.left=(window.innerWidth-elements.keyboard.offsetWidth)/2+"px",elements.keyboard.style.top=window.innerHeight-elements.keyboard.offsetHeight-50+"px",requestAnimationFrame(()=>{elements.keyboard.style.opacity="1",elements.keyboard.style.transform="translateY(0)"})}))}function hideKeyboard(){elements.keyboard.style.opacity="0",elements.keyboard.style.transform="translateY(-10px)",window.setTimeout(()=>{elements.keyboard.style.display="none",is.keyboard=!1},300)}function changeState(t,e){const n=getOrigin(getTaskId(e));if(!n)return!1;switch(t){case"max":n.forms[e].vroot.$refs.form.maxMethod();break;case"min":n.forms[e].vroot.$refs.form.minMethod();break;default:remove$2(e)}return!0}function min(t){return changeState("min",t)}function max(t){return changeState("max",t)}function close(t){return changeState("close",t)}function bindResize(t,e){const n=findParentByClass(t.target,"cg-form-wrap");if(!n)return;const o=n.dataset.formId;if(!o)return;const r=getOrigin(getTaskId(o));r&&r.forms[o].vroot.$refs.form.resizeMethod(t,e)}function bindDrag(t){const e=findParentByClass(t.target,"cg-form-wrap");if(!e)return;const n=e.dataset.formId;if(!n)return;const o=getOrigin(getTaskId(n));o&&o.forms[n].vroot.$refs.form.moveMethod(t,!0)}function refreshMaxPosition(){const t=getAvailArea();for(let e=0;e<elements.list.children.length;++e){const n=elements.list.children.item(e),o=n.children.item(0);if(void 0===o.dataset.cgMax)continue;const r=n.getAttribute("data-task-id"),s=n.getAttribute("data-form-id"),i=getOrigin(r);if(!i)continue;const a=i.forms[s].vroot;void 0===o.dataset.cgBottomMost?(a.$refs.form.setPropData("left",t.left),a.$refs.form.setPropData("top",t.top),a.$refs.form.setPropData("width",t.width),a.$refs.form.setPropData("height",t.height)):(a.$refs.form.setPropData("width",t.owidth),a.$refs.form.setPropData("height",t.oheight))}}function getTaskId(t){const e=elements.list.querySelector(`[data-form-id='${t}']`);if(!e)return"";const n=e.getAttribute("data-task-id");return n||""}function get$3(t){const e=getTaskId(t);if(!e)return null;const n=getOrigin(e);if(!n)return null;if(!n.forms[t])return null;const o=n.forms[t];return{taskId:e,title:o.vroot.$refs.form.title,icon:o.vroot.$refs.form.iconDataUrl,stateMax:o.vroot.$refs.form.stateMaxData,stateMin:o.vroot.$refs.form.stateMinData,show:o.vroot.$refs.form.isShow,focus:o.vroot.formFocus,showInSystemTask:o.vroot.showInSystemTask}}function send(t,e){const n=getTaskId(t);if(!n)return;const o=getOrigin(n);if(!o)return;o.forms[t].vroot.onReceive(e)}function getList$1(t){"string"!=typeof t&&(t=t.taskId);const e=getOrigin(t);if(!e)return{};const n={};for(const o in e.forms){const r=e.forms[o];n[o]={taskId:t,title:r.vroot.$refs.form.title,icon:r.vroot.$refs.form.iconDataUrl,stateMax:r.vroot.$refs.form.stateMaxData,stateMin:r.vroot.$refs.form.stateMinData,show:r.vroot.$refs.form.isShow,focus:r.vroot.formFocus,showInSystemTask:r.vroot.showInSystemTask}}return n}function getFocus$1(){return focusId$1}const activePanels={};function getActivePanel(t){return activePanels[t]??[]}function removeActivePanel(t,e,n){"string"!=typeof t&&(t=t.taskId);const o=getOrigin(t);if(!o)return!1;if(!o.forms[e])return!1;if(!activePanels[e])return!0;const r=activePanels[e].indexOf(n);return-1===r||(activePanels[e].splice(r,1),activePanels[e].length||delete activePanels[e]),!0}function setActivePanel(t,e,n){"string"!=typeof t&&(t=t.taskId);const o=getOrigin(t);if(!o)return!1;if(!o.forms[e])return!1;activePanels[e]||(activePanels[e]=[]);return-1!==activePanels[e].indexOf(n)||activePanels[e].push(n),!0}function hash$1(t,e){const n=getTaskId(t);if(!n)return!1;const o=getOrigin(n);if(!o)return!1;const r=o.forms[t];return!!r&&(r.vroot.formHash=e,!0)}function getHash$1(t){const e=getTaskId(t);if(!e)return"";const n=getOrigin(e);if(!n)return"";const o=n.forms[t];return o?o.vroot.$data._formHash:""}async function hashBack(t){const e=getTaskId(t);if(!e)return!1;const n=getOrigin(e);if(!n)return!1;const o=n.forms[t];return!!o&&(await o.vroot.formHashBack(),!0)}async function changeFocus(t=""){const e=getFocus$1();if(e){if(e===t)return;{const t=await getFocus(sysId$8);if(!t)return;const n=getOrigin(t);if(!n)return;n.forms[e].vapp._container.removeAttribute("data-form-focus"),n.forms[e].vroot._formFocus=!1,trigger("formBlurred",n.id,e).catch(()=>{})}}if(focusId$1=null,setFocus(),!t)return;const n=elements.list.querySelector(`.cg-form-wrap[data-form-id='${t}']`);if(!n)return;void 0!==n.children.item(0).dataset.cgMin&&min(t);const o=n.getAttribute("data-task-id")??"";if(!o)return;const r=getOrigin(o);if(!r)return;const s=getRuntime(sysId$8,o);if(s)if(s.dialogFormIds.length){const e=s.dialogFormIds[s.dialogFormIds.length-1];get$3(e).stateMin&&min(e),r.forms[e].vroot._topMost?r.forms[e].vroot.$refs.form.$data.zIndex=++info.topLastZIndex:r.forms[e].vroot._bottomMost?r.forms[e].vroot.$refs.form.$data.zIndex=++info.bottomLastZIndex:r.forms[e].vroot.$refs.form.$data.zIndex=++info.lastZIndex,r.forms[e].vapp._container.dataset.formFocus="",r.forms[e].vroot._formFocus=!0,focusId$1=e,setFocus(r.id),trigger("formFocused",o,e).catch(()=>{}),e!==t&&await flash(o,e)}else r.forms[t].vroot._topMost?r.forms[t].vroot.$refs.form.$data.zIndex=++info.topLastZIndex:r.forms[t].vroot._bottomMost?r.forms[t].vroot.$refs.form.$data.zIndex=++info.bottomLastZIndex:r.forms[t].vroot.$refs.form.$data.zIndex=++info.lastZIndex,r.forms[t].vapp._container.dataset.formFocus="",r.forms[t].vroot._formFocus=!0,focusId$1=t,setFocus(r.id),trigger("formFocused",o,t).catch(()=>{})}async function getMaxZIndexID(t,e={}){if("string"!=typeof t&&(t=t.taskId),!(await checkPermission(t,"root"))[0])return null;let n=0,o=null;for(let t=0;t<elements.list.children.length;++t){const r=elements.list.children.item(t),s=r.children.item(0);if(!s)continue;const i=parseInt(s.style.zIndex);if(i<1e6)continue;if(void 0!==s.dataset.cgMin)continue;const a=r.getAttribute("data-task-id");if(a===systemTaskInfo.taskId)continue;if(e.taskIds?.includes(a))continue;const c=r.getAttribute("data-form-id");e.formIds?.includes(c)||i>n&&(n=i,o=c)}return o}async function changeFocusMaxZIndex(){const t=await getMaxZIndexID(sysId$8);t&&await changeFocus(t??void 0)}function getRectByBorder(t){const e=getAvailArea();let n,o,r,s;if("string"==typeof t)switch(t){case"lt":n=e.width/2,o=e.height/2,r=e.left,s=e.top;break;case"t":n=e.width,o=e.height,r=e.left,s=e.top;break;case"tr":n=e.width/2,o=e.height/2,r=e.left+e.width/2,s=e.top;break;case"r":n=e.width/2,o=e.height,r=e.left+e.width/2,s=e.top;break;case"rb":n=e.width/2,o=e.height/2,r=e.left+e.width/2,s=e.top+e.height/2;break;case"b":n=e.width,o=e.height/2,r=e.left,s=e.top+e.height/2;break;case"bl":n=e.width/2,o=e.height/2,r=e.left,s=e.top+e.height/2;break;case"l":n=e.width/2,o=e.height,r=e.left,s=e.top}else n=t.width??e.width,o=t.height??e.height,r=t.left??e.left,s=t.top??e.top;return{width:n,height:o,left:r,top:s}}function showCircular(t,e){elements.circular.style.transition="none",requestAnimationFrame(function(){elements.circular.style.width="6px",elements.circular.style.height="6px",elements.circular.style.left=(t-3).toString()+"px",elements.circular.style.top=(e-3).toString()+"px",elements.circular.style.opacity="1",requestAnimationFrame(function(){elements.circular.style.transition="all .3s var(--g-cubic)",requestAnimationFrame(function(){elements.circular.style.width="60px",elements.circular.style.height="60px",elements.circular.style.left=(t-30).toString()+"px",elements.circular.style.top=(e-30).toString()+"px",elements.circular.style.opacity="0"})})})}function moveRectangle(t){if("0"===(elements.rectangle.getAttribute("data-ready")??"0"))return;const e=elements.rectangle.getAttribute("data-border")??"",n="string"==typeof t?t:`o-${t.left}-${t.top??"n"}-${t.width}-${t.height??"n"}`;if(e===n)return;elements.rectangle.setAttribute("data-dir",n);const o=getRectByBorder(t),r=o.width-20,s=o.height-20,i=o.left+10,a=o.top+10;void 0!==r&&void 0!==s&&void 0!==i&&void 0!==a&&(elements.rectangle.style.width=r.toString()+"px",elements.rectangle.style.height=s.toString()+"px",elements.rectangle.style.left=i.toString()+"px",elements.rectangle.style.top=a.toString()+"px")}function showRectangle(t,e,n){elements.rectangle.style.transition="none",requestAnimationFrame(function(){elements.rectangle.style.width="5px",elements.rectangle.style.height="5px",elements.rectangle.style.left=(t-10).toString()+"px",elements.rectangle.style.top=(e-10).toString()+"px",elements.rectangle.style.opacity="1",elements.rectangle.setAttribute("data-ready","0"),elements.rectangle.setAttribute("data-dir",""),requestAnimationFrame(function(){elements.rectangle.style.transition="all .3s var(--g-cubic)",requestAnimationFrame(function(){elements.rectangle.setAttribute("data-ready","1"),moveRectangle(n)})})})}function hideRectangle(){elements.rectangle.style.opacity="0"}let alertBottom=0,alertId=0;function alert$1(t,e){const n=++alertId,o=document.createElement("div"),r=alertBottom;return o.classList.add("cg-alert-wrap"),o.classList.add("cg-"+(e??"default")),o.setAttribute("data-alertid",n.toString()),o.style.transform=`translateY(${r+10}px)`,o.style.opacity="0",o.innerHTML=`<div class="cg-alert-content"><div class="cg-alert-icon"></div><div>${escapeHTML(t)}</div></div>`,elements.alert.appendChild(o),alertBottom-=o.offsetHeight+10,requestAnimationFrame(function(){o.style.transform=`translateY(${r}px)`,o.style.opacity="1";const t=window.setTimeout(function(){clearTimeout(t);const e=o.offsetHeight;o.style.opacity="0",setTimeout(function(){alertBottom+=e+10;const t=document.getElementsByClassName("cg-alert-wrap");let n=!1;for(const r of t)r!==o?n&&(r.style.transform=r.style.transform.replace(/translateY\(([-0-9]+)px\)/,function(t,n){return`translateY(${parseInt(n)+e+10}px)`})):n=!0;o.remove()},100)},3e3)}),n}let notifyBottom=-10,notifyId=0;function notify(t){t.note&&!t.content&&(t.content="Notify");const e=++notifyId;let n=5e3;const o=6e5;void 0!==t.timeout&&(n=t.timeout<0?5e3:0===t.timeout||t.timeout>o?o:t.timeout),t.progress&&!t.type&&(t.type="progress");const r=document.createElement("div");let s=notifyBottom,i=-10;return systemTaskInfo.taskId&&("bottom"===config["task.position"]?s-=systemTaskInfo.length:"right"===config["task.position"]&&(i-=systemTaskInfo.length)),r.classList.add("cg-notify-wrap"),r.setAttribute("data-notifyid",e.toString()),r.style.transform=`translateY(${s}px) translateX(280px)`,r.style.opacity="0",r.classList.add(t.title&&t.content?"cg-notify-full":"cg-notify-only"),r.innerHTML=`<div class="cg-notify-icon cg-${escapeHTML(t.type??"primary")}"></div><div style="flex: 1;">`+(t.title?`<div class="cg-notify-title">${escapeHTML(t.title)}</div>`:"")+(t.content?`<div class="cg-notify-content">${escapeHTML(t.content).replace(/\r\n/g,"\n").replace(/\r/g,"\n").replace(/\n/g,"<br>")}</div>`:"")+(t.note?`<div class="cg-notify-note">${escapeHTML(t.note)}</div>`:"")+(t.progress?'<div class="cg-notify-progress"></div>':"")+"</div>",t.icon&&(r.childNodes.item(0).style.background="url("+t.icon+")",r.childNodes.item(0).style.backgroundSize="14px"),elements.notify.appendChild(r),notifyBottom-=r.offsetHeight+10,requestAnimationFrame(function(){r.style.transform=`translateY(${s}px) translateX(${i}px)`,r.style.opacity="1";const t=window.setTimeout(function(){hideNotify(e)},n);r.setAttribute("data-timer",t.toString())}),e}function notifyProgress(t,e){const n=elements.notify.querySelector(`[data-notifyid="${t}"]`);if(!n)return;const o=n.querySelector(".cg-notify-progress");if(o){if(e>100)e=100;else if(1===e){parseFloat(o.style.width)>1&&(e=100)}100===e&&(o.style.transitionDelay=".1s"),o.style.width=(e<1?100*e:e).toString()+"%"}}function notifyContent(t,e){const n=elements.notify.querySelector(`[data-notifyid="${t}"]`);if(n){if(e.title){const t=n.querySelector(".cg-notify-title");if(!t)return;t.innerHTML=escapeHTML(e.title)}if(e.content){const t=n.querySelector(".cg-notify-content");if(!t)return;t.innerHTML=escapeHTML(e.content)}if(e.note){const t=n.querySelector(".cg-notify-note");if(!t)return;t.innerHTML=escapeHTML(e.note)}e.progress&¬ifyProgress(t,e.progress),e.timeout&&setTimeout(function(){hideNotify(t)},e.timeout)}}function hideNotify(t){const e=elements.notify.querySelector(`[data-notifyid="${t}"]`);if(!e)return;clearTimeout(parseInt(e.getAttribute("data-timer")));const n=e.offsetHeight;e.style.opacity="0",setTimeout(function(){notifyBottom+=n+10;const t=document.getElementsByClassName("cg-notify-wrap");let o=!1;for(const r of t)r!==e?o&&(r.style.transform=r.style.transform.replace(/translateY\(([-0-9]+)px\)/,function(t,e){return`translateY(${parseInt(e)+n+10}px)`})):o=!0;e.remove()},100)}function appendToPop(t){elements.popList.appendChild(t)}function removeFromPop(t){elements.popList.removeChild(t)}function refreshPopPosition(t,e,n,o={}){const r=o.width??e.offsetWidth,s=o.height??e.offsetHeight;let i,a;if("string"==typeof n){const o=t.getBoundingClientRect();"v"===n?(i=o.left,a=o.top+o.height):"h"===n?(i=o.left+o.width-2,a=o.top-2):(e.removeAttribute("data-pop-t-bottom"),i=o.left+o.width/2-r/2,a=o.top-s-10),r+i>window.innerWidth&&(i="v"===n?o.left+o.width-r:"h"===n?o.left-r+2:window.innerWidth-r),s+a>window.innerHeight?"v"===n?a=o.top-s:"h"===n&&(a=o.top+o.height-s+2):a<0&&"t"===n&&(a=o.top+o.height+10,e.dataset.popTBottom="")}else{let t,e;n instanceof PointerEvent?(t=n.clientX,e=n.clientY):(t=n.x,e=n.y),i=t+5,a=e+7,r+i>window.innerWidth&&(i=t-r-5),s+a>window.innerHeight&&(a=e-s-5)}i<0&&(i=0),a<0&&(a=0),e.style.left=i.toString()+"px",e.style.top=a.toString()+"px",e.style.zIndex=(++popInfo.lastZIndex).toString(),o.width&&(e.style.width=o.width.toString()+"px"),o.height&&(e.style.height=o.height.toString()+"px")}let lastShowPopTime=0;function showPop(t,e,n,o={}){if(!(t instanceof Element)){if(!t.$el)return;t=t.$el}if(e&&!(e instanceof Element)){if(!e.$el)return;e=e.$el}if(o.null??=!1,o.size??={},o.flow??=!0,!e&&!o.null)return;if(e&&!o.flow)return e.removeAttribute("data-cg-pop-none"),e.dataset.cgFlow="",void sleep$1(34).then(()=>{void 0!==e.dataset.cgFlow&&(refreshPopPosition(t,e,n,o.size),o.autoPosition&&watchSize(sysId$8,e,()=>{refreshPopPosition(t,e,n,o.size)}),e.dataset.cgOpen="")}).catch(()=>{});const r=Date.now();if(r-lastShowPopTime<5)return void(lastShowPopTime=r);if(lastShowPopTime=r,void 0!==t.dataset.cgPopOpen)return;const s=findParentByData(t,"cg-pop");if(void 0!==s?.dataset.cgLevel){const t=parseInt(s.dataset.cgLevel)+1;popInfo.elList[t]&&hidePop(popInfo.elList[t])}else hidePop();if(!e)return popInfo.elList.push(t),t.dataset.cgPopOpen="",void(t.dataset.cgLevel=(popInfo.elList.length-1).toString());e.removeAttribute("data-cg-pop-none"),popInfo.list.push(e),popInfo.elList.push(t),popInfo.wayList.push(o.way??"normal"),popInfo.time.push(Date.now()),e.dataset.cgLevel=(popInfo.list.length-1).toString(),t.dataset.cgLevel=(popInfo.elList.length-1).toString(),sleep$1(34).then(()=>{void 0!==e.dataset.cgLevel&&(refreshPopPosition(t,e,n,o.size),o.autoPosition&&"string"==typeof n&&watchSize(sysId$8,e,()=>{refreshPopPosition(t,e,n,o.size)}),o.autoScroll&&"string"==typeof n&&watchPosition(t,()=>{refreshPopPosition(t,e,n,o.size)}),e.dataset.cgOpen="",t.dataset.cgPopOpen="")}).catch(()=>{})}function hidePop(t){if(t&&!(t instanceof HTMLElement)){if(!t.$el)return;t=t.$el}if(!t){if(0===popInfo.elList.length)return;return void hidePop(popInfo.elList[0])}if(void 0!==t.dataset.cgFlow)return t.removeAttribute("data-cg-flow"),t.removeAttribute("data-cg-open"),unwatchSize(t),void sleep$1(334).then(()=>{void 0===t.dataset.cgFlow&&(t.dataset.cgPopNone="")}).catch(()=>{});if(void 0===t.dataset.cgLevel)return;const e=void 0!==t.dataset.cgPop,n=t.dataset.cgLevel?parseInt(t.dataset.cgLevel):-1;if(-1!==n){if(popInfo.elList[n+1]&&hidePop(popInfo.elList[n+1]),e)t.removeAttribute("data-cg-open"),t.removeAttribute("data-cg-level"),unwatchSize(t),unwatchPosition(popInfo.elList[n]),popInfo.elList[n].removeAttribute("data-cg-pop-open"),popInfo.elList[n].removeAttribute("data-cg-level"),sleep$1(334).then(()=>{void 0===t.dataset.cgLevel&&(t.dataset.cgPopNone="")}).catch(()=>{});else{if(popInfo.list[n]){const e=popInfo.list[n];e.removeAttribute("data-cg-open"),e.removeAttribute("data-cg-level"),unwatchSize(popInfo.list[n]),unwatchPosition(t),sleep$1(334).then(()=>{void 0===e.dataset.cgLevel&&(e.dataset.cgPopNone="")}).catch(()=>{})}t.removeAttribute("data-cg-pop-open"),t.removeAttribute("data-cg-level")}popInfo.list.splice(n),popInfo.elList.splice(n),popInfo.wayList.splice(n),popInfo.time.splice(n)}}function isJustPop(t){if(t instanceof HTMLElement){const e=t.dataset.cgLevel;if(!e)return!1;t=parseInt(e)}const e=popInfo.time[t];return!(Date.now()-e>=100)}async function doFocusAndPopEvent(t){if(!t.target)return;const e=t.path??(t.composedPath?t.composedPath():[]);let n=null;for(const t of e)if(t.tagName)if(void 0===t.dataset.cgLevel||void 0!==t.dataset.cgPop){if(t.classList.contains("cg-form-wrap")){const e=t.getAttribute("data-form-id")??"";return await changeFocus(e),void(n&&isJustPop(n)||hidePop())}if("body"===t.tagName.toLowerCase())break}else n=t;for(const t of e)if(t.tagName){if("body"===t.tagName.toLowerCase())break;if(void 0!==t.dataset.cgPop){if(t.dataset.cgLevel){const e=parseInt(t.dataset.cgLevel)+1;"click"!==popInfo.wayList[e]||isJustPop(e)||hidePop(popInfo.list[e])}return}}hidePop(),await changeFocus()}function remove$2(t){const e=getTaskId(t),n=getOrigin(e);if(!n?.forms[t])return!1;if(n.forms[t].closed)return!1;const o=getRuntime(sysId$8,e);if(!o)return!1;n.forms[t].closed=!0;const r=n.forms[t].vroot.$refs.form.title,s=n.forms[t].vroot.$refs.form.iconDataUrl,i=o.dialogFormIds.indexOf(t);return i>-1&&o.dialogFormIds.splice(i,1),n.forms[t].vroot.$refs.form.$data.isShow=!1,setTimeout(()=>{(async()=>{const n=await getMaxZIndexID(sysId$8,{formIds:[t]});n?await changeFocus(n):await changeFocus();const o=getOrigin(e);if(!o)return!0;o.forms[t].vapp.unmount(),o.forms[t].vapp._container.remove(),elements.popList.querySelector('[data-form-id="'+t+'"]')?.remove(),i>-1&&o.forms[t].vroot.cgDialogCallback(),delete o.forms[t],removeStyle(e,"form",t),trigger("formRemoved",e,t,r,s).catch(()=>{}),clearWatchStyle(t),clearWatchProperty(t),clearWatchPosition(t),clear$2(t,e),delete activePanels[t],0===Object.keys(o.forms).length&&await end(e)})().catch(()=>{})},is.transition?300:0),!0}function removePanel(t,e,n){const o=findParentByClass(n,"cg-form-wrap");if(!o)return!1;const r=o.dataset.formId;if(!r)return!1;const s=o.dataset.taskId;if(!s)return!1;if(e.unmount(),e._container.remove(),n.querySelector('[data-panel-id="'+t+'"]')?.remove(),removeStyle(s,"form",r,t),clearWatchStyle(r,t),clearWatchProperty(r,t),clearWatchPosition(r,t),activePanels[r]){const e=activePanels[r].indexOf(t);e>=0&&activePanels[r].splice(e,1),activePanels[r].length||delete activePanels[r]}return!0}function getForm(t,e){const n=getOrigin(t);if(!n)return null;const o=n.forms[e];return o||null}async function createPanel(t,e,n={}){if("panel"!==t.element.dataset.cgControl){const t=new Error("form.createPanel: -0");throw trigger("error","","",t,t.message).catch(()=>{}),t}const o=findParentByData(t.element,"form-id");if(!o){const t=new Error("form.createPanel: -0");throw trigger("error","","",t,t.message).catch(()=>{}),t}const r=o.dataset.formId,s=getOrigin(t.taskId);if(!s){const t=new Error("form.createPanel: -1");throw trigger("error","","",t,t.message).catch(()=>{}),t}let i="";n.layout&&(i=n.layout);let a="",c="";n.style&&(a=n.style);let l="";if("string"==typeof e){if(l=urlResolve(n.path??"/",e)+".js",!i){const t=s.app.files[e+".xml"];if("string"!=typeof t){const t=new Error("form.createPanel: -2");throw trigger("error","","",t,t.message).catch(()=>{}),t}i=t}if(!a){const t=s.app.files[e+".css"];"string"==typeof t&&(a=t)}e=class extends AbstractPanel{get filename(){return l}}}const d=random(8,RANDOM_LUN);Object.defineProperty(e.prototype,"taskId",{get:()=>s.id,configurable:!0});const f=new e;l||(l=f.filename);const u=l.slice(0,l.lastIndexOf("/"));if(!i){const t=s.app.files[l.slice(0,-2)+"xml"];if("string"!=typeof t){const t=new Error("form.createPanel: -3");throw trigger("error","","",t,t.message).catch(()=>{}),t}i=t}if(!a){const t=s.app.files[l.slice(0,-2)+"css"];"string"==typeof t&&(a=t)}if(a){const t=stylePrepend(a);c=t.prep,a=await styleUrl2DataUrl(u+"/",t.style,s.app.files)}i=purify(i),i=layoutAddTagClassAndReTagName(i,!0);const m=["cg-task"+s.id+"_"];""!==c&&m.push(c),i=layoutClassPrepend(i,m),i=eventsAttrWrap(i),i.includes("<teleport")&&(i=teleportGlue(i,r)),i.includes('@click="')&&(i=i.replaceAll('@click="','@tap="'));const h=buildComponents(s.id,r,u);if(!h){const t=new Error("form.createPanel: -4");throw trigger("error","","",t,t.message).catch(()=>{}),t}const g={},p=Object.entries(f);for(const t of p)"access"!==t[0]&&(g[t[0]]=t[1]);const y=getClassPrototype(f),w=y.method,v=y.access;v.taskId={get:function(){return s.id},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "taskId".\nPath: ${this.filename}`,type:"danger"})}},v.formId={get:function(){return r},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "formId".\nPath: ${this.filename}`,type:"danger"})}},v.panelId={get:function(){return d},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "panelId".\nPath: ${this.filename}`,type:"danger"})}},v.path={get:function(){return u},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "path".\nPath: ${this.filename}`,type:"danger"})}},v.prep={get:function(){return c},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "prep".\nPath: ${this.filename}`,type:"danger"})}},v.rootForm={get:function(){return s.forms[r].vroot},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "rootForm".\nPath: ${this.filename}`,type:"danger"})}},v.rootPanel={get:function(){return t},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "rootPanel".\nPath: ${this.filename}`,type:"danger"})}},t.element.insertAdjacentHTML("beforeend",`<div data-panel-id="${d}"></div>`),a&&pushStyle(s.id,a,"form",r,d);const b=t.element.children.item(t.element.children.length-1);b.style.position="absolute",b.style.display="none";const k=await new Promise(function(t){const e=modules.vue.createApp({template:i.replace(/^<cg-panel([\s\S]+)-panel>$/,"<cg-layout$1-layout>"),data:function(){return clone(g)},methods:w,computed:v,beforeCreate:f.onBeforeCreate,created:function(){f.access&&(this.access=clone(f.access)),this.onCreated()},beforeMount:function(){this.onBeforeMount()},mounted:async function(){await this.$nextTick(),b.children.item(0).style.flex="1",t({vapp:e,vroot:this})},beforeUpdate:function(){this.onBeforeUpdate()},updated:async function(){await this.$nextTick(),this.onUpdated()},beforeUnmount:function(){this.onBeforeUnmount()},unmounted:async function(){await this.$nextTick(),this.onUnmounted()}});e.config.errorHandler=function(t,e,n){notify({title:"Runtime Error",content:`Message: ${t.message}\nTask id: ${e?.taskId??""}\nForm id: ${e?.formId??""}`,type:"danger"}),console.error("Runtime Error [form.createPanel.errorHandler]",`Message: ${t.message}\nTask id: ${e?.taskId??""}\nForm id: ${e?.formId??""}`,t,n),trigger("error",e?.taskId??"",e?.formId??"",t,n+"(-3,"+(e?.taskId??"")+","+(e?.formId??"")+")").catch(()=>{})};for(const t in h)e.component(t,h[t]);try{e.mount(b)}catch(t){notify({title:"Runtime Error",content:`Message: ${t.message}\nTask id: ${s.id}\nForm id: ${r}`,type:"danger"}),console.error("Runtime Error [form.createPanel.mount]",`Message: ${t.message}\nTask id: ${s.id}\nForm id: ${r}`,t),trigger("error",s.id,r,t,t.message).catch(()=>{})}});await sleep$1(34);try{await f.onMounted.call(k.vroot)}catch(t){trigger("error",k.vroot.taskId,k.vroot.formId,t,"Create panel mounted error: -5.").catch(()=>{});try{k.vapp.unmount()}catch(t){notify({title:"Panel Unmount Error",content:`Message: ${t.message}\nTask id: ${s.id}\nForm id: ${r}\nFunction: form.createPanel, unmount.`,type:"danger"})}throw k.vapp._container.remove(),clearWatchStyle(k.vroot.formId,d),clearWatchProperty(k.vroot.formId,d),clearWatchPosition(k.vroot.formId,d),removeStyle(k.vroot.taskId,"form",k.vroot.formId,d),t}return{id:d,vapp:k.vapp,vroot:k.vroot}}async function create(t,e,n,o={}){"string"!=typeof t&&(t=t.taskId);const r=getOrigin(t);if(!r){const t=new Error("form.create: -1");throw trigger("error","","",t,t.message).catch(()=>{}),t}let s="";o.layout&&(s=o.layout);let i="",a="";o.style&&(i=o.style);let c="";if("string"==typeof e){if(c=urlResolve(o.path??"/",e),!s){const t=r.app.files[c+".xml"];if("string"!=typeof t){const t=new Error("form.create: -2");throw trigger("error","","",t,t.message).catch(()=>{}),t}s=t}if(!i){const t=r.app.files[c+".css"];"string"==typeof t&&(i=t)}c+=".js",e=class extends AbstractForm{get filename(){return c}}}const l=random(8,RANDOM_LUN),d=++index$2;Object.defineProperty(e.prototype,"taskId",{get:()=>r.id,configurable:!0});const f=new e;c||(c=f.filename);const u=c.slice(0,c.lastIndexOf("/"));if(!s){const t=r.app.files[c.slice(0,-2)+"xml"];if("string"!=typeof t){const t=new Error("form.create: -3");throw trigger("error","","",t,t.message).catch(()=>{}),t}s=t}if(!i){const t=r.app.files[c.slice(0,-2)+"css"];"string"==typeof t&&(i=t)}if(i){const t=stylePrepend(i);a=t.prep,i=await styleUrl2DataUrl(u+"/",t.style,r.app.files)}s=purify(s),s=layoutAddTagClassAndReTagName(s,!0);const m=["cg-task"+r.id+"_"];""!==a&&m.push(a),s=layoutClassPrepend(s,m),s=eventsAttrWrap(s),s.includes("<teleport")&&(s=teleportGlue(s,l)),s.includes('@click="')&&(s=s.replaceAll('@click="','@tap="'));const h=buildComponents(r.id,l,u);if(!h){const t=new Error("form.create: -4");throw trigger("error","","",t,t.message).catch(()=>{}),t}const g={},p=Object.entries(f);for(const t of p)"access"!==t[0]&&(g[t[0]]=t[1]);g._formFocus=!1,isNative()&&0===d&&!hasFrame()&&(g.isNativeNoFrameFirst=!0);const y=getClassPrototype(f),w=y.method,v=y.access;v.findex={get:function(){return d},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "findex".\nPath: ${this.filename}`,type:"danger"})}},v.taskId={get:function(){return r.id},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "taskId".\nPath: ${this.filename}`,type:"danger"})}},v.formId={get:function(){return l},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "formId".\nPath: ${this.filename}`,type:"danger"})}},v.path={get:function(){return u},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "path".\nPath: ${this.filename}`,type:"danger"})}},v.prep={get:function(){return a},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "prep".\nPath: ${this.filename}`,type:"danger"})}},g._bottomMost=!1,v.bottomMost={get:function(){return this._bottomMost},set:function(t){t?(this._bottomMost=!0,this.$el.dataset.cgBottomMost="",this._topMost&&(this._topMost=!1),this.$refs.form.$data.zIndex=++info.bottomLastZIndex):(this._bottomMost=!1,this.$el.removeAttribute("data-cg-bottom-most"),this.$refs.form.$data.zIndex=++info.lastZIndex)}},g._topMost=!1,v.topMost={get:function(){return this._topMost},set:function(t){t?(this._topMost=!0,this._bottomMost&&(this._bottomMost=!1,this.$el.removeAttribute("data-cg-bottom-most")),this._formFocus?this.$refs.form.$data.zIndex=++info.topLastZIndex:changeFocus(this.formId).catch(()=>{})):(this._topMost=!1,this.$refs.form.$data.zIndex=++info.lastZIndex)}},g._historyHash=[],g._formHash="",v.formHash={get:function(){return this._formHash},set:function(e){e!==this._formHash&&(Date.now()-this._lastFormHashData>300&&(this._formHashData={}),this.inStep?(async()=>{if(this._stepValues.includes(e))this.$refs.form.stepValue=e;else{if(!await confirm(t,{content:info.locale[this.locale].confirmExitStep}))return;this._inStep=!1,this.$refs.form.stepHide()}this._formHash&&this._historyHash.push(this._formHash),this._formHash=e,trigger("formHashChange",r.id,l,e,this._formHashData).catch(()=>{})})():(this._formHash&&this._historyHash.push(this._formHash),this._formHash=e,trigger("formHashChange",r.id,l,e,this._formHashData).catch(()=>{})))}},g._lastFormHashData=0,g._formHashData={},v.formHashData={get:function(){return this._formHashData},set:function(t){this._formHashData=t,this._lastFormHashData=Date.now()}},g._showInSystemTask=!0,v.showInSystemTask={get:function(){return this._showInSystemTask},set:function(t){this._showInSystemTask=t,trigger("formShowInSystemTaskChange",r.id,l,t).catch(()=>{})}};const b=[];w.ready=function(t){this.isReady?t():b.push(t)},elements.list.insertAdjacentHTML("beforeend",`<div class="cg-form-wrap" data-form-id="${l}" data-task-id="${r.id}"></div>`),elements.popList.insertAdjacentHTML("beforeend",`<div data-form-id="${l}" data-task-id="${r.id}"></div>`),i&&pushStyle(r.id,i,"form",l);const k=elements.list.children.item(elements.list.children.length-1),S=await new Promise(function(e){const n=modules.vue.createApp({template:s.replace(/^<cg-form/,'<cg-form ref="form"'),data:function(){return clone(g)},methods:w,computed:v,beforeCreate:f.onBeforeCreate,created:function(){f.access&&(this.access=clone(f.access)),this.onCreated()},beforeMount:function(){this.onBeforeMount()},mounted:async function(){if(await this.$nextTick(),this.$refs.form.icon){const e=await getContent(t,this.$refs.form.icon);this.$refs.form.iconDataUrl=e instanceof Blob?await blob2DataUrl(e):""}e({vapp:n,vroot:this})},beforeUpdate:function(){this.onBeforeUpdate()},updated:async function(){await this.$nextTick(),this.onUpdated()},beforeUnmount:function(){this.onBeforeUnmount()},unmounted:async function(){await this.$nextTick(),this.onUnmounted()}});n.config.errorHandler=function(t,e,n){notify({title:"Runtime Error",content:`Message: ${t.message}\nTask id: ${e?.taskId??""}\nForm id: ${e?.formId??""}`,type:"danger"}),console.error("Runtime Error [form.create.errorHandler]",`Message: ${t.message}\nTask id: ${e?.taskId??""}\nForm id: ${e?.formId??""}`,t,n),trigger("error",e?.taskId??0,e?.formId??0,t,n+"(-3,"+e?.taskId+","+e?.formId+")").catch(()=>{})};for(const t in h)n.component(t,h[t]);try{n.mount(k)}catch(t){notify({title:"Runtime Error",content:`Message: ${t.message}\nTask id: ${r.id}\nForm id: ${l}`,type:"danger"}),console.error("Runtime Error [form.create.mount]",`Message: ${t.message}\nTask id: ${r.id}\nForm id: ${l}`,t),trigger("error",r.id,l,t,t.message).catch(()=>{})}}),$={id:l,vapp:S.vapp,vroot:S.vroot,closed:!1};r.forms[l]=$,await sleep$1(34);try{await f.onMounted.call(S.vroot,n??{})}catch(t){trigger("error",S.vroot.taskId,S.vroot.formId,t,"Create form mounted error: -6.").catch(()=>{}),delete r.forms[l];try{S.vapp.unmount()}catch(t){notify({title:"Form Unmount Error",content:`Message: ${t.message}\nTask id: ${r.id}\nForm id: ${l}\nFunction: form.create, unmount.`,type:"danger"})}throw S.vapp._container.remove(),elements.popList.querySelector('[data-form-id="'+S.vroot.formId+'"]')?.remove(),clearWatchStyle(S.vroot.formId),clearWatchProperty(S.vroot.formId),clearWatchPosition(S.vroot.formId),clear$2(l,r.id),removeStyle(S.vroot.taskId,"form",S.vroot.formId),t}trigger("formCreated",r.id,l,S.vroot.$refs.form.title,S.vroot.$refs.form.iconDataUrl,S.vroot.showInSystemTask).catch(()=>{}),S.vroot.isNativeNoFrameFirst&&(await invokeSys(sysId$8,"cg-set-size",S.vroot.$refs.form.$el.offsetWidth,S.vroot.$refs.form.$el.offsetHeight),window.addEventListener("resize",function(){S.vroot.$refs.form.setPropData("width",window.innerWidth),S.vroot.$refs.form.setPropData("height",window.innerHeight)})),S.vroot.isReady=!0;for(const t of b)t.call(S.vroot);return S.vroot}function dialog(t,e){return new Promise(function(n){"string"!=typeof t&&(t=t.taskId),"string"==typeof e&&(e={content:e});const o=urlResolve(e.path??"/","./tmp"+random(16,RANDOM_LN)+".js"),r=e,s=getOrigin(t);if(!s)return void n("");const i=s.locale.lang||config.locale;r.buttons??=[info.locale[i]?.ok??info.locale.en.ok];create(t,class extends AbstractForm{buttons=r.buttons;data=r.data??{};methods=r.methods??{};get filename(){return o}select(t){const e={go:!0,preventDefault:function(){this.go=!1},detail:{button:t}};r.select&&r.select.call(this,e,t),e.go&&(!1!==r.autoDialogResult&&(this.dialogResult=t),close(this.formId))}},void 0,{layout:`<form title="${r.title??"dialog"}" min="false" max="false" resize="false" height="0" width="0" border="${r.title?"normal":"plain"}" direction="v"><dialog :buttons="buttons" @select="select"${r.direction?` direction="${r.direction}"`:""}${r.gutter?` gutter="${r.gutter}"`:""}>${r.content}</dialog></form>`,style:r.style}).then(t=>{"number"!=typeof t?t.showDialog().then(t=>{n(t)}).catch(()=>{n("")}):n("")}).catch(()=>{n("")})})}async function confirm(t,e){"string"!=typeof t&&(t=t.taskId),"string"==typeof e&&(e={content:e});const n=getOrigin(t);if(!n)return!1;const o=n.locale.lang||config.locale,r=[info.locale[o]?.no??info.locale.en.no,info.locale[o]?.yes??info.locale.en.yes];e.cancel&&r.unshift(info.locale[o]?.cancel??info.locale.en.cancel);const s=await dialog(t,{title:e.title,content:e.content,buttons:r});return s===(info.locale[o]?.yes??info.locale.en.yes)||s===(info.locale[o]?.cancel??info.locale.en.cancel)&&0}async function prompt(t,e){"string"!=typeof t&&(t=t.taskId),"string"==typeof e&&(e={content:e});const n=getOrigin(t);if(!n)return"";const o=n.locale.lang||config.locale,r=[info.locale[o]?.ok??info.locale.en.ok],s=info.locale[o]?.cancel??info.locale.en.cancel;!0!==e.cancel&&void 0!==e.cancel||r.unshift(s);return await dialog(t,{title:e.title,direction:"v",gutter:10,content:"<block>"+e.content+'</block><text v-model="data.text" />',data:{text:e.text??""},select:function(t,n){const r=n===(info.locale[o]?.ok??info.locale.en.ok),i={go:!0,preventDefault:function(){this.go=!1},detail:{button:r,value:this.data.text}};e.select?.call(this,i,r),i.go||t.preventDefault(),t.detail.button!==s?this.dialogResult=this.data.text:this.dialogResult=""},buttons:r,autoDialogResult:!1})}async function flash(t,e){"string"!=typeof t&&(t=t.taskId);const n=getForm(t,e);n&&(n.vroot._formFocus||await changeFocus(n.id),n.vroot.$refs.form.flashTimer&&(clearTimeout(n.vroot.$refs.form.flashTimer),n.vroot.$refs.form.flashTimer=void 0),n.vroot.$refs.form.flashTimer=setTimeout(()=>{n.vroot.$refs.form&&(n.vroot.$refs.form.flashTimer=void 0)},1e3),await trigger("formFlash",t,e))}function showLauncher(){elements.launcher.style.display="flex",requestAnimationFrame(function(){elements.launcher.classList.add("cg-show")})}function hideLauncher(){elements.launcher.classList.remove("cg-show"),setTimeout(function(){""!==launcherRoot.folderName&&launcherRoot.closeFolder(),launcherRoot.name="",elements.launcher.style.display="none"},300)}window.addEventListener("pointerdown",t=>{doFocusAndPopEvent(t).catch(()=>{})});let inited$3=!1;function init$4(){inited$3||(inited$3=!0,elements.init())}var form=Object.freeze({__proto__:null,AbstractForm:AbstractForm,AbstractPanel:AbstractPanel,activePanels:activePanels,alert:alert$1,appendToPop:appendToPop,bindDrag:bindDrag,bindResize:bindResize,changeFocus:changeFocus,changeFocusMaxZIndex:changeFocusMaxZIndex,close:close,confirm:confirm,create:create,createPanel:createPanel,dialog:dialog,doFocusAndPopEvent:doFocusAndPopEvent,elements:elements,flash:flash,get:get$3,getActivePanel:getActivePanel,getFocus:getFocus$1,getHash:getHash$1,getList:getList$1,getMaxZIndexID:getMaxZIndexID,getRectByBorder:getRectByBorder,getTaskId:getTaskId,hash:hash$1,hashBack:hashBack,hideKeyboard:hideKeyboard,hideLauncher:hideLauncher,hideNotify:hideNotify,hidePop:hidePop,hideRectangle:hideRectangle,init:init$4,initSysId:initSysId$7,isJustPop:isJustPop,get launcherRoot(){return launcherRoot},max:max,min:min,moveRectangle:moveRectangle,notify:notify,notifyContent:notifyContent,notifyProgress:notifyProgress,prompt:prompt,refreshMaxPosition:refreshMaxPosition,remove:remove$2,removeActivePanel:removeActivePanel,removeFromPop:removeFromPop,removePanel:removePanel,send:send,setActivePanel:setActivePanel,showCircular:showCircular,showKeyboard:showKeyboard,showLauncher:showLauncher,showPop:showPop,showRectangle:showRectangle,get simpleSystemTaskRoot(){return simpleSystemTaskRoot},superConfirm:superConfirm});let sysId$7="";function initSysId$6(t){sysId$7||(sysId$7=t)}const topClass=["#cg-form-list","#cg-pop-list","#cg-notify","#cg-alert","#cg-keyboard","#cg-simpletask","#cg-launcher","#cg-confirm"];function classUnfold(t,e=[]){const n=[];for(const o of topClass)e.includes(o)||n.push(o+(t?" "+t:""));return n.join(", ")}const hueCount=11.25;let hueCssVar="";const hues=[];for(let t=0;t<32;++t){const e=(11.25*t).toFixed(2);hueCssVar+=`--hue-${t}:${e}; `,hues.push(e)}const styleList=document.createElement("div");function inPage(t){return document.body.contains(t)}styleList.style.display="none",document.getElementsByTagName("body")[0].appendChild(styleList),styleList.insertAdjacentHTML("beforeend","<style id='cg-global-cursor'></style>"),styleList.insertAdjacentHTML("beforeend","<style id='cg-global-transition'></style>"),styleList.insertAdjacentHTML("beforeend",`<style id='cg-global'>\n${classUnfold()} {-webkit-user-select: none; user-select: none; cursor: default; box-sizing: border-box; background-clip: padding-box;}\n${topClass.slice(0,4).join(", ")} {left: 0; top: 0; width: 0; height: 0; position: absolute;}\n${classUnfold("img")} {vertical-align: bottom;}\n${classUnfold("::selection",["#cg-launcher"])} {background-color: rgba(0, 0, 0, .1);}\n${classUnfold("*")}, ${classUnfold("*::after")}, ${classUnfold("*::before")} {box-sizing: border-box; background-clip: padding-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); flex-shrink: 0;}\n${classUnfold(" > div")} {font-family: var(--g-family); font-size: var(--g-size); line-height: 1; -webkit-font-smoothing: antialiased; text-shadow: 0 0 1px color-mix(in srgb, currentColor 40%, transparent); fill: currentColor; stroke: currentColor;}\n#cg-wrap { ${hueCssVar}}\n</style>`);const dpiDiv=document.createElement("div");dpiDiv.style.visibility="hidden",dpiDiv.style.width="1in",document.getElementsByTagName("body")[0].appendChild(dpiDiv);const dpi=dpiDiv.getBoundingClientRect().width;let globalCursorStyle,globalTransitionStyle;function setGlobalCursor(t){globalCursorStyle||(globalCursorStyle=document.getElementById("cg-global-cursor")),globalCursorStyle.innerHTML=t?`*, *::after, *::before {cursor: ${t} !important;}`:""}function setGlobalTransition(t){globalTransitionStyle||(globalTransitionStyle=document.getElementById("cg-global-transition")),globalTransitionStyle.innerHTML=t?"":"*, *::after, *::before {transition: none !important;}",is.transition=t}function createToStyleList(t){styleList.insertAdjacentHTML("beforeend",`<div id="cg-style-task${t}"><div class="cg-style-control"></div><div class="cg-style-theme"></div><style class="cg-style-global"></style><div class="cg-style-form"></div></div>`)}function removeFromStyleList(t){document.getElementById("cg-style-task"+t)?.remove()}function pushStyle(t,e,n="global",o="",r){const s=document.querySelector(`#cg-style-task${t} > .cg-style-${n}`);s&&("global"===n?s.innerHTML=e:"theme"===n||"control"===n?s.insertAdjacentHTML("beforeend",`<style data-name="${o}">${e}</style>`):s.insertAdjacentHTML("beforeend",`<style class="cg-style-form${o}" data-panel="${r?r.toString():""}">${e}</style>`))}function removeStyle(t,e="global",n="",o){const r=document.getElementById("cg-style-task"+t);if(r)if("global"===e){const t=r.querySelector(".cg-style-global");if(!t)return;t.innerHTML=""}else if("theme"===e||"control"===e)if(n){const t=r.querySelectorAll(`.cg-style-${e} > [data-name='${n}']`);for(let e=0;e<t.length;++e)t.item(e).remove()}else{const t=r.querySelector(`.cg-style-${e}`);if(!t)return;t.innerHTML=""}else{const t=r.querySelectorAll(".cg-style-form"+n.toString()+(o?'[data-panel="'+o.toString()+'"]':""));for(let e=0;e<t.length;++e)t.item(e).remove()}}function getStyleCount(t,e){return"string"!=typeof t&&(t=t.taskId),document.querySelectorAll(`#cg-style-task${t} > .cg-style-${e} > style`).length}dpiDiv.remove(),document.addEventListener("touchstart",function(){});const watchPositionObjects={};let watchPositionIndex=0;function watchPosition(t,e,n=!1){if(isWatchPosition(t))return!1;if(n)try{const t=e({position:!1,size:!1});t instanceof Promise&&t.catch(()=>{})}catch{}const o=findParentByData(t,"form-id");if(!o)return!1;const r=o.dataset.formId,s=findParentByData(t,"panel-id"),i=s?s.dataset.panelId:"default";return watchPositionObjects[r]||(watchPositionObjects[r]={}),watchPositionObjects[r][i]||(watchPositionObjects[r][i]={}),watchPositionObjects[r][i][watchPositionIndex]={el:t,rect:t.getBoundingClientRect(),handler:e},t.dataset.cgPoindex=watchPositionIndex.toString(),++watchPositionIndex,!0}function unwatchPosition(t){const e=t.dataset.cgPoindex;if(void 0===e)return;const n=findParentByData(t,"form-id");if(!n)return;const o=n.dataset.formId,r=findParentByData(t,"panel-id"),s=r?r.dataset.panelId:"default";t.removeAttribute("data-cg-poindex"),delete watchPositionObjects[o][s][e],Object.keys(watchPositionObjects[o][s]).length||(delete watchPositionObjects[o][s],Object.keys(watchPositionObjects[o]).length||delete watchPositionObjects[o])}function isWatchPosition(t){return!!t.dataset.cgPoindex}function clearWatchPosition(t,e){if(watchPositionObjects[t]){for(const n in watchPositionObjects[t])if(!e||n===e){for(const e in watchPositionObjects[t][n]){watchPositionObjects[t][n][e].el.removeAttribute("data-cg-poindex")}delete watchPositionObjects[t][n]}Object.keys(watchPositionObjects[t]).length||delete watchPositionObjects[t]}}const watchSizeList={};function getWatchSizeCount(t){if(!t)return Object.keys(watchSizeList).length;"string"!=typeof t&&(t=t.taskId);let e=0;for(const n in watchSizeList)watchSizeList[n].taskId===t&&++e;return e}let watchSizeIndex=0;const resizeObserver=new ResizeObserver(function(t){for(const e of t){const t=e.target;if(!document.body.contains(t)){resizeObserver.unobserve(t),watchSizeList[t.dataset.cgRoindex]&&delete watchSizeList[t.dataset.cgRoindex];continue}const n=watchSizeList[t.dataset.cgRoindex];try{const t=n.handler();t instanceof Promise&&t.catch(()=>{})}catch{}}});function watchSize(t,e,n,o=!1){if("string"!=typeof t&&(t=t.taskId),t!==sysId$7&&!getOrigin(t))return!1;if(isWatchSize(e))return!1;if(o)try{const t=n();t instanceof Promise&&t.catch(()=>{})}catch{}return resizeObserver.observe(e,{box:"border-box"}),watchSizeList[watchSizeIndex]={el:e,handler:n,taskId:t},e.dataset.cgRoindex=watchSizeIndex.toString(),++watchSizeIndex,!0}function unwatchSize(t){const e=t.dataset.cgRoindex;void 0!==e&&(resizeObserver.unobserve(t),t.removeAttribute("data-cg-roindex"),delete watchSizeList[e])}function isWatchSize(t){return!!t.dataset.cgRoindex}function clearWatchSize(t){"string"!=typeof t&&(t=t.taskId);for(const e in watchSizeList){const n=watchSizeList[e];t===n.taskId&&(resizeObserver.unobserve(n.el),n.el.removeAttribute("data-cg-roindex"),delete watchSizeList[e])}}const watchList={};function getWatchCount(t){if(!t)return Object.keys(watchList).length;let e=0;for(const n in watchList)watchList[n].taskId===t&&++e;return e}let watchIndex=0;function watch(t,e,n,o="default",r=!1){if("string"!=typeof t&&(t=t.taskId),t!==sysId$7&&!getOrigin(t))return!1;if(isWatch(e))return!1;if(r)try{const t=n([]);t instanceof Promise&&t.catch(()=>{})}catch{}const s=watchIndex;let i;switch(o){case"child":i={childList:!0};break;case"childsub":i={childList:!0,subtree:!0};break;case"style":i={attributeFilter:["style","class"],attributeOldValue:!0,attributes:!0};break;case"text":i={characterData:!0,childList:!0,subtree:!0};break;default:i={attributeFilter:["style","class"],attributeOldValue:!0,attributes:!0,characterData:!0,childList:!0,subtree:!0}}const a=new MutationObserver(t=>{if(!document.body.contains(e))return a.disconnect(),void(watchList[s]&&delete watchList[s]);try{const e=n(t);e instanceof Promise&&e.catch(()=>{})}catch{}});return a.observe(e,i),watchList[s]={el:e,mo:a,taskId:t},e.dataset.cgMoindex=s.toString(),++watchIndex,!0}function unwatch(t,e){"string"!=typeof t&&(t=t.taskId);const n=e.dataset.cgMoindex;if(void 0===n)return;watchList[n].taskId===t&&(e.removeAttribute("data-cg-moindex"),watchList[n].mo.disconnect(),delete watchList[n])}function isWatch(t){return!!t.dataset.cgMoindex}function clearWatch(t){"string"!=typeof t&&(t=t.taskId);for(const e in watchList){const n=watchList[e];t===n.taskId&&(n.el.removeAttribute("data-cg-moindex"),n.mo.disconnect(),delete watchList[e])}}const watchCgTimerHandler=function(){for(const t in watchSizeList){const e=watchSizeList[t];document.body.contains(e.el)||delete watchSizeList[t]}for(const t in watchList){const e=watchList[t];document.body.contains(e.el)||delete watchList[t]}window.setTimeout(watchCgTimerHandler,42e4)};watchCgTimerHandler();const watchStyleList={};let watchStyleIndex=0;function watchStyle(t,e,n,o=!1){"string"==typeof e&&(e=[e]);const r=findParentByData(t,"form-id");if(!r)return;const s=r.dataset.formId,i=findParentByData(t,"panel-id"),a=i?i.dataset.panelId:"default",c=t.dataset.cgStyleindex;if(c){const t=watchStyleList[s][a][c];for(const r of e)t.names[r]?t.names[r].cb.push(n):t.names[r]={val:t.sd[r],cb:[n]},o&&n(r,t.sd[r],"");return}watchStyleList[s]||(watchStyleList[s]={}),watchStyleList[s][a]||(watchStyleList[s][a]={});const l=getComputedStyle(t);watchStyleList[s][a][watchStyleIndex]={el:t,sd:l,names:{}};const d=watchStyleList[s][a][watchStyleIndex];for(const t of e)d.names[t]={val:d.sd[t],cb:[n]},o&&n(t,d.sd[t],"");t.dataset.cgStyleindex=watchStyleIndex.toString(),++watchStyleIndex}function isWatchStyle(t){return!!t.dataset.cgStyleindex}function clearWatchStyle(t,e){if(watchStyleList[t]){for(const n in watchStyleList[t])if(!e||n===e){for(const e in watchStyleList[t][n]){watchStyleList[t][n][e].el.removeAttribute("data-cg-styleindex")}delete watchStyleList[t][n]}Object.keys(watchStyleList[t]).length||delete watchStyleList[t]}}const watchPropertyObjects={};let watchPropertyIndex=0;function watchProperty(t,e,n,o=!1){"string"==typeof e&&(e=[e]);const r=findParentByData(t,"form-id");if(!r)return;const s=r.dataset.formId,i=findParentByData(t,"panel-id"),a=i?i.dataset.panelId:"default",c=t.dataset.cgPropertyindex;if(c){const t=watchPropertyObjects[s][a][c];for(const r of e)t.names[r]?t.names[r].cb.push(n):t.names[r]={val:t.el[r],cb:[n]},o&&n(r,t.el[r]);return}watchPropertyObjects[s]||(watchPropertyObjects[s]={}),watchPropertyObjects[s][a]||(watchPropertyObjects[s][a]={}),watchPropertyObjects[s][a][watchPropertyIndex]={el:t,names:{}};const l=watchPropertyObjects[s][a][watchPropertyIndex];for(const t of e)l.names[t]={val:l.el[t],cb:[n]},o&&n(t,l.el[t]);t.dataset.cgPropertyindex=watchPropertyIndex.toString(),++watchPropertyIndex}function isWatchProperty(t){return!!t.dataset.cgPropertyindex}function clearWatchProperty(t,e){if(watchPropertyObjects[t]){for(const n in watchPropertyObjects[t])if(!e||n===e){for(const e in watchPropertyObjects[t][n]){watchPropertyObjects[t][n][e].el.removeAttribute("data-cg-propertyindex")}delete watchPropertyObjects[t][n]}Object.keys(watchPropertyObjects[t]).length||delete watchPropertyObjects[t]}}function getWatchInfo(){const t={formId:"",default:{},panels:{}},e=getFocus$1();if(!e)return t;t.formId=e;const n=getActivePanel(e),o=(e,n,o)=>{o&&(t.panels[o]||(t.panels[o]={}));const r=o?t.panels[o]:t.default,s=e.el.dataset.cgControl??findParentByData(e.el,"cg-control")?.dataset.cgControl??"unknown";if(r[s]||(r[s]={style:{count:0,list:[]},property:{count:0,list:[]},position:{count:0}}),++r[s][n].count,e.names&&"position"!==n)for(const t in e.names)r[s][n].list.includes(t)||r[s][n].list.push(t)};if(watchStyleList[e]){if(watchStyleList[e].default)for(const t in watchStyleList[e].default)o(watchStyleList[e].default[t],"style");for(const t of n)if(watchStyleList[e][t])for(const n in watchStyleList[e][t])o(watchStyleList[e][t][n],"style",t.toString())}if(watchPropertyObjects[e]){if(watchPropertyObjects[e].default)for(const t in watchPropertyObjects[e].default)o(watchPropertyObjects[e].default[t],"property");for(const t of n)if(watchPropertyObjects[e]?.[t])for(const n in watchPropertyObjects[e][t])o(watchPropertyObjects[e][t][n],"property",t.toString())}if(watchPositionObjects[e]){if(watchPositionObjects[e].default)for(const t in watchPositionObjects[e].default)o(watchPositionObjects[e].default[t],"position");for(const t of n)if(watchPositionObjects[e]?.[t])for(const n in watchPositionObjects[e][t])o(watchPositionObjects[e][t][n],"position",t.toString())}return t}let watchTimer=0;const watchTimerHandler=function(){if(getFocus$1){const t=getFocus$1();if(t){const e=getActivePanel(t);if(watchStyleList[t]){const n=(e,n,o)=>{if(!document.body.contains(e.el))return delete watchStyleList[t][n][o],Object.keys(watchStyleList[t][n]).length||delete watchStyleList[t][n],void(Object.keys(watchStyleList[t]).length||delete watchStyleList[t]);for(const t in e.names){if(e.sd[t]===e.names[t].val)continue;const n=e.names[t].val;e.names[t].val=e.sd[t];for(const o of e.names[t].cb)o(t,e.sd[t],n)}};if(watchStyleList[t].default)for(const e in watchStyleList[t].default)n(watchStyleList[t].default[e],"default",e);for(const o of e)if(watchStyleList[t][o])for(const e in watchStyleList[t][o])n(watchStyleList[t][o][e],o.toString(),e)}if(watchPropertyObjects[t]){const n=(e,n,o)=>{if(!document.body.contains(e.el))return delete watchPropertyObjects[t][n][o],Object.keys(watchPropertyObjects[t][n]).length||delete watchPropertyObjects[t][n],void(Object.keys(watchPropertyObjects[t]).length||delete watchPropertyObjects[t]);for(const t in e.names)if(e.el[t]!==e.names[t].val){e.names[t].val=e.el[t];for(const n of e.names[t].cb)n(t,e.el[t])}};if(watchPropertyObjects[t].default)for(const e in watchPropertyObjects[t].default)n(watchPropertyObjects[t].default[e],"default",e);for(const o of e)if(watchPropertyObjects[t][o])for(const e in watchPropertyObjects[t][o])n(watchPropertyObjects[t][o][e],o.toString(),e)}if(watchPositionObjects[t]){const n=(e,n,o)=>{if(!document.body.contains(e.el))return delete watchPositionObjects[t][n][o],Object.keys(watchPositionObjects[t][n]).length||delete watchPositionObjects[t][n],void(Object.keys(watchPositionObjects[t]).length||delete watchPositionObjects[t]);const r=e.el.getBoundingClientRect();let s=!1,i=!1;e.rect.left===r.left&&e.rect.top===r.top||(s=!0),e.rect.width===r.width&&e.rect.height===r.height||(i=!0),(s||i)&&e.handler({position:s,size:i}),watchPositionObjects[t][n][o].rect=r};if(watchPositionObjects[t].default)for(const e in watchPositionObjects[t].default)n(watchPositionObjects[t].default[e],"default",e);for(const o of e)if(watchPositionObjects[t][o])for(const e in watchPositionObjects[t][o])n(watchPositionObjects[t][o][e],o.toString(),e)}}}watchTimer=requestAnimationFrame(watchTimerHandler)};let is;function findParentByData(t,e,n){let o=t.parentNode;for(;o;){if(!o.tagName)continue;if("body"===o.tagName.toLowerCase())break;const t=o.getAttribute("data-"+e);if(null!==t){if(n){if(n===t)return o;continue}return o}o=o.parentNode}return null}function findParentByClass(t,e){let n=t.parentNode;for(;n;)if(n.tagName){if("body"===n.tagName.toLowerCase())break;if(n.classList.contains(e))return n;n=n.parentNode}return null}function findParentByTag(t,e){let n=t.parentNode;for(;n;){if(!n.tagName)continue;const t=n.tagName.toLowerCase();if("body"===t)break;if(t===e)return n;n=n.parentNode}return null}function index$1(t){let e=0,n=t.previousElementSibling;for(;n;)++e,n=n.previousElementSibling;return e}function siblings(t){if(!t.parentNode)return[];const e=[];for(let n=0;n<t.parentNode.children.length;++n){const o=t.parentNode.children.item(n);o!==t&&e.push(o)}return e}function siblingsData(t,e){const n=siblings(t),o=[];for(const t of n)null!==t.getAttribute("data-"+e)&&o.push(t);return o}async function fullscreen(){const t=document.getElementsByTagName("html")[0];return t.webkitRequestFullscreen?(await t.webkitRequestFullscreen(),!0):!!t.requestFullscreen&&(await t.requestFullscreen(),!0)}async function exitFullscreen(){const t=document;return t.webkitExitFullscreen?(await t.webkitExitFullscreen(),!0):!!t.exitFullscreen&&(await t.exitFullscreen(),!0)}function createElement(t){return document.createElement(t)}function getElementRPosition(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return{left:n.left-o.left,top:n.top-o.top,width:n.width,height:n.height}}function getRectPoint(t,e,n){const o=getElementRPosition(t,e),r=o.left+o.width/2,s=o.top+o.height/2;switch(n){case"t":return{x:r,y:o.top};case"tr":return{x:o.left+o.width,y:o.top};case"r":return{x:o.left+o.width,y:s};case"rb":return{x:o.left+o.width,y:o.top+o.height};case"b":return{x:r,y:o.top+o.height};case"bl":return{x:o.left,y:o.top+o.height};case"l":return{x:o.left,y:s};case"lt":return{x:o.left,y:o.top};default:return{x:r,y:s}}}let micState=0,micWs=null;const blob=new Blob(["\nconst minRms = .2;\n\nclass MicrophoneProcessor extends AudioWorkletProcessor {\n constructor() {\n super();\n this.voice = false; // --- 当前是否是说话状态 ---\n this.voiceStart = 0; // --- 从静音到说话时的开始时间 ---\n this.voiceLast = 0; // --- 最后一次说话的时间 ---\n this.lastPost = 0; // --- 最后一次发送 buffer 的时间 ---\n }\n // --- 计算音频帧的平均音量(均方根) ---\n // --- 大于等于 minRms 代表可能在说话 ---\n calculateVolume(channel) {\n let sum = 0;\n for (let i = 0; i < channel.length; i++) {\n // --- 平方和 ---\n sum += channel[i] * channel[i];\n }\n // --- 均方根 ---\n const rms = Math.sqrt(sum / channel.length);\n return rms;\n }\n\n process(inputs, outputs) {\n // --- 获取输入音频数据(单声道) ---\n const input = inputs[0];\n const channel = input[0];\n const now = Date.now();\n \n // --- 计算当前帧的音量 ---\n const volume = this.calculateVolume(channel);\n this.port.postMessage({\n 'type': 'process',\n 'rms': volume,\n });\n if (volume > minRms) {\n this.voiceLast = now;\n }\n\n // --- 判断是否要发送 buffer ---\n if (this.voice) {\n // --- 说话中 ---\n if (volume >= minRms) {\n // --- 继续说话 ---\n }\n else {\n // --- 判断是否说话结束 ---\n if (now - this.voiceLast >= 1_000) {\n // --- 说话结束 ---\n this.voice = false;\n this.voiceStart = 0;\n this.port.postMessage({\n 'type': 'voice-end'\n });\n }\n // --- 不结束,等待到 1 秒观察 ---\n }\n }\n else {\n // --- 静音中 ---\n if (volume >= minRms) {\n // --- 判断是否要说话开始 ---\n if (this.voiceStart === 0) {\n this.voiceStart = now;\n }\n if (now - this.voiceStart >= 300) {\n // --- 说话开始 ---\n this.voice = true;\n this.port.postMessage({\n 'type': 'voice-start'\n });\n }\n // --- 不开始,等待到 300ms 观察 ---\n }\n else {\n // --- 当前没声音,判断是否是真的安静了 ---\n if (now - this.voiceLast > 300) {\n // --- 又安静了 ---\n this.voiceStart = 0;\n }\n }\n }\n\n if (\n (now - this.voiceLast >= 3_000) &&\n (now - this.lastPost < 15_000)\n ) {\n // --- 超过 3 秒没声音直接 buffer 都不发送 ---\n return true;\n }\n\n // --- 转换为 Int16 ---\n const output = new Int16Array(channel.length);\n for (let i = 0; i < channel.length; i++) {\n // --- 限制范围并转换 ---\n const sample = Math.max(-1, Math.min(1, channel[i]));\n output[i] = sample < 0 ? sample * 32768 : sample * 32767;\n }\n\n // --- 通过消息将处理后的数据发送到主线程 ---\n this.lastPost = now;\n this.port.postMessage(output.buffer, [output.buffer]);\n \n // --- 保持处理器运行 ---\n return true;\n }\n}\n\n// --- 注册处理器 ---\nregisterProcessor('microphone-processor', MicrophoneProcessor);\n"],{type:"application/javascript"}),micProcessor=URL.createObjectURL(blob),mic={start:async function(t,e={}){if(micState>0)return!0;micState=1;const n=e.rtn??=!0;try{const o=await navigator.mediaDevices.getUserMedia({audio:!0});micWs=new WebSocket(t),n&&(micWs.onmessage=async t=>{try{if(JSON.parse(t.data).result<=0)return void mic.stop();micState=2,await(e.onStart?.())}catch{mic.stop()}}),micWs.onopen=async()=>{n||(micState=2,await(e.onStart?.()))},micWs.onclose=()=>{micWs=null,micState=0};const r=new AudioContext({sampleRate:8e3}),s=r.createMediaStreamSource(o);await r.audioWorklet.addModule(micProcessor);const i=new AudioWorkletNode(r,"microphone-processor");return s.connect(i),i.connect(r.destination),i.port.onmessage=async t=>{if(!micWs){const t=o.getTracks();for(const e of t)e.stop();return await r.close(),i.port.close(),i.disconnect(),s.disconnect(),void await(e.onStop?.())}2===micState&&(micWs.readyState!==WebSocket.CLOSING&&micWs.readyState!==WebSocket.CLOSED?"voice-start"!==t.data.type?"voice-end"!==t.data.type?"process"!==t.data.type?micWs.send(t.data):await(e.onProcess?.({rms:t.data.rms})):await(e.onVoiceEnd?.()):await(e.onVoiceStart?.()):mic.stop())},!0}catch(t){return console.error("[LIB][DOM]",t),micState=0,!1}},stop:function(){micState=0,micWs&&micWs.close()}};let inited$2=!1;function init$3(){inited$2||(inited$2=!0,is=modules.vue.reactive({move:!1,shift:!1,ctrl:!1,meta:!1,full:!1,dark:window.matchMedia("(prefers-color-scheme: dark)").matches,keyboard:!1,transition:!0}),document.addEventListener("visibilitychange",function(){document.hidden?cancelAnimationFrame(watchTimer):watchTimer=requestAnimationFrame(watchTimerHandler)}),document.addEventListener("fullscreenchange",function(){document.webkitFullscreenElement||document.fullscreenElement?is.full=!0:is.full=!1}),window.addEventListener("keydown",function(t){switch(t.key){case"Shift":is.shift=!0;break;case"Control":is.ctrl=!0;break;case"Meta":is.meta=!0}trigger("keydown",t).catch(()=>{})}),window.addEventListener("keyup",function(t){switch(t.key){case"Shift":is.shift=!1;break;case"Control":is.ctrl=!1;break;case"Meta":is.meta=!1}trigger("keyup",t).catch(()=>{})}),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",t=>{is.dark=t.matches}),watchTimerHandler())}var dom=Object.freeze({__proto__:null,clearWatch:clearWatch,clearWatchPosition:clearWatchPosition,clearWatchProperty:clearWatchProperty,clearWatchSize:clearWatchSize,clearWatchStyle:clearWatchStyle,createElement:createElement,createToStyleList:createToStyleList,dpi:dpi,exitFullscreen:exitFullscreen,findParentByClass:findParentByClass,findParentByData:findParentByData,findParentByTag:findParentByTag,fullscreen:fullscreen,getElementRPosition:getElementRPosition,getRectPoint:getRectPoint,getStyleCount:getStyleCount,getWatchCount:getWatchCount,getWatchInfo:getWatchInfo,getWatchSizeCount:getWatchSizeCount,hues:hues,inPage:inPage,index:index$1,init:init$3,initSysId:initSysId$6,get is(){return is},isWatch:isWatch,isWatchPosition:isWatchPosition,isWatchProperty:isWatchProperty,isWatchSize:isWatchSize,isWatchStyle:isWatchStyle,mic:mic,pushStyle:pushStyle,removeFromStyleList:removeFromStyleList,removeStyle:removeStyle,setGlobalCursor:setGlobalCursor,setGlobalTransition:setGlobalTransition,siblings:siblings,siblingsData:siblingsData,unwatch:unwatch,unwatchPosition:unwatchPosition,unwatchSize:unwatchSize,watch:watch,watchPosition:watchPosition,watchProperty:watchProperty,watchSize:watchSize,watchStyle:watchStyle});class Zip{_zip;_path="/";constructor(t){this._zip=t,this._refreshList()}async getContent(t,e="string"){t=urlResolve(this._path,t);const n=this._zip.file(t.slice(1));return n?"string"===e?n.async("string"):n.async(e):null}putContent(t,e,n={}){t=urlResolve(this._path,t),this._zip.file(t.slice(1),e,{base64:n.base64,binary:n.binary,date:n.date}),this._refreshList()}unlink(t){t=urlResolve(this._path,t),this._zip.remove(t.slice(1)),this._refreshList()}stats(t){let e=(t=urlResolve(this._path,t)).endsWith("/")?t:t+"/";if(this._list[e]){if("/"===e)return{compressedSize:0,uncompressedSize:0,date:new Date,isFile:!1,isDirectory:!0};e=e.slice(0,-1);const t=e.lastIndexOf("/")+1,n=e.slice(0,t),o=e.slice(t);return{compressedSize:0,uncompressedSize:0,date:this._list[n][o].date,isFile:!1,isDirectory:!0}}{if(t.endsWith("/"))return null;const e=t.lastIndexOf("/")+1,n=t.slice(0,e),o=t.slice(e);if(!this._list[n])return null;const r=this._list[n][o];return r?{compressedSize:r.compressedSize,uncompressedSize:r.uncompressedSize,date:r.date,isFile:!0,isDirectory:!1}:null}}isDir(t){const e=this.stats(t);return!!e?.isDirectory&&e}isFile(t){const e=this.stats(t);return!!e?.isFile&&e}readDir(t,e={}){e.hasChildren??=!1,e.hasDir??=!0,e.pathAsKey??=!1,(t=t?urlResolve(this._path,t):this._path).endsWith("/")||(t+="/");if(!this._zip.folder(t.slice(1)))return e.pathAsKey?{}:[];if(!this._list[t])return e.pathAsKey?{}:[];if(!e.hasChildren){if(e.pathAsKey)return this._list[t];const n=[];for(const e in this._list[t])n.push(this._list[t][e]);return n}if(e.pathAsKey){const n={};for(const o in this._list[t]){const r=this._list[t][o];(r.isFile||e.hasDir)&&(n[r.path+r.name]=r),r.isDirectory&&Object.assign(n,this._readDir(r,{hasDir:e.hasDir,pathAsKey:e.pathAsKey}))}return n}{let n=[];for(const o in this._list[t]){const r=this._list[t][o];(r.isFile||e.hasDir)&&n.push(r),r.isDirectory&&(n=n.concat(this._readDir(r,{hasDir:e.hasDir,pathAsKey:e.pathAsKey})))}return n}}_readDir(t,e){if(e.pathAsKey){const n={};if(!this._list[t.path+t.name+"/"])return{};for(const o in this._list[t.path+t.name+"/"]){const r=this._list[t.path+t.name+"/"][o];(r.isFile||e.hasDir)&&(n[r.path+r.name]=r),r.isDirectory&&Object.assign(n,this._readDir(r,{hasDir:e.hasDir,pathAsKey:e.pathAsKey}))}return n}{let n=[];if(!this._list[t.path+t.name+"/"])return[];for(const o in this._list[t.path+t.name+"/"]){const r=this._list[t.path+t.name+"/"][o];(r.isFile||e.hasDir)&&n.push(r),r.isDirectory&&(n=n.concat(this._readDir(r,{hasDir:e.hasDir,pathAsKey:e.pathAsKey})))}return n}}_list={};_refreshList(){const t={};this._zip.forEach(function(e,n){e.startsWith("/")&&(e=e.slice(1));let o,r="/",s="";o=n.dir?e.slice(0,-1).lastIndexOf("/"):e.lastIndexOf("/"),-1!==o?(r="/"+e.slice(0,o+1),s=e.slice(o+1)):s=e,n.dir&&(s=s.slice(0,-1)),t[r]||(t[r]={}),t[r][s]={name:s,compressedSize:n._data.compressedSize??0,uncompressedSize:n._data.uncompressedSize??0,date:n.date,isFile:!n.dir,isDirectory:n.dir,path:r}}),this._list=t}pwd(){return this._path.slice(0,-1)}cd(t){return this._path=urlResolve(this._path,t),this._path.endsWith("/")||(this._path+="/"),this._path}generate(t={}){const e={};return void 0===t.type?e.type="blob":e.type=t.type,(void 0===t.level||t.level>9)&&(t.level=9),t.level>0&&(e.compression="DEFLATE"),this._zip.generateAsync(e,function(e){t.onUpdate?.(e.percent,e.currentFile)})}getList(){return new Promise(t=>{const e={},n=this.readDir("/",{hasChildren:!0,hasDir:!1});let o=0;for(const r of n){const s=getMimeByPath(r.name);["txt","json","js","css","xml","html"].includes(s.ext)?this.getContent(r.path+r.name,"string").then(function(s){s&&(e[r.path+r.name]=s),++o,o===n.length&&t(e)}).catch(function(){++o,o===n.length&&t(e)}):this.getContent(r.path+r.name,"arraybuffer").then(function(i){i&&(e[r.path+r.name]=new Blob([i],{type:s.mime})),++o,o===n.length&&t(e)}).catch(function(){++o,o===n.length&&t(e)})}return e})}}async function get$2(t){const e=modules.jszip();try{return t&&await e.loadAsync(t),new Zip(e)}catch{return null}}var zip=Object.freeze({__proto__:null,Zip:Zip,get:get$2});let sysId$6="";function initSysId$5(t){sysId$6||(sysId$6=t)}let global$1=null;async function read$1(t){const e=await get$2(t);if(!e)return!1;const n=await e.getContent("config.json");if(!n)return!1;const o=JSON.parse(n),r={},s=e.readDir("/",{hasChildren:!0});for(const t of s){const n=getMimeByPath(t.name);if(["txt","json","js","css","xml","html"].includes(n.ext)){const n=await e.getContent(t.path+t.name,"string");if(!n)continue;r[t.path+t.name]=n.replace(/^\ufeff/,"")}else{const o=await e.getContent(t.path+t.name,"arraybuffer");if(!o)continue;r[t.path+t.name]=new Blob([o],{type:n.mime})}}return{type:"theme",config:o,files:r}}async function load(t,e){"string"!=typeof t&&(t=t.taskId);const n=getOrigin(t);if(!n)return!1;const o=!e;if(n.customTheme&&o)return!0;if(!e){if(!global$1)return!0;e=global$1}let r=e.files[e.config.style+".css"];return!!r&&(r=stylePrepend(r,`cg-theme-task${t}-`).style,r=await styleUrl2DataUrl(e.config.style,r,e.files),r=r.replace(/\[CGTMP-GLOBAL\] +::selection/g,`#cg-form-list > [data-task-id="${t}"] ::selection, #cg-pop-list > [data-task-id="${t}"] ::selection`),r=r.replace(/\[CGTMP-GLOBAL\]/g,`#cg-form-list > [data-task-id="${t}"], #cg-pop-list > [data-task-id="${t}"]`),n.customTheme||(o||(n.customTheme=!0),removeStyle(t,"theme")),pushStyle(t,r,"theme",e.config.name),!0)}async function remove$1(t,e){"string"!=typeof t&&(t=t.taskId);const n=getOrigin(t);n&&n.customTheme&&(removeStyle(t,"theme",e),0===getStyleCount(t,"theme")&&(n.customTheme=!1,global$1&&await load(t)))}async function clear$1(t){"string"!=typeof t&&(t=t.taskId);const e=getOrigin(t);e&&e.customTheme&&(removeStyle(t,"theme"),e.customTheme=!1,global$1&&await load(t))}async function setGlobal(t,e=null){if("string"==typeof t){const n=await getContent(e,t+".cgt");if(!n)return 0;if("string"==typeof n)return-1;const o=await read$1(n);if(!o)return-2;t=o}global$1=t;const n=await getOriginList(sysId$6);for(const t in n)await load(t);return 1}async function clearGlobal(){if(!global$1)return;global$1=null;const t=await getOriginList(sysId$6);for(const e in t){const n=t[e];n.customTheme||removeStyle(n.id,"theme")}}function setMain(t,e){t?elements.wrap.style.setProperty("--main",t):elements.wrap.style.removeProperty("--main"),e?elements.wrap.style.setProperty("--main-hue",e.toString()):elements.wrap.style.removeProperty("--main-hue")}var theme=Object.freeze({__proto__:null,clear:clear$1,clearGlobal:clearGlobal,get global(){return global$1},initSysId:initSysId$5,load:load,read:read$1,remove:remove$1,setGlobal:setGlobal,setMain:setMain});let sysId$5="";function initSysId$4(t){sysId$5||(sysId$5=t)}function isSys(t){return t===sysId$5}let index=-1;const list$1={},runtime={};function getRuntime(t,e){return"string"!=typeof t&&(t=t.taskId),isSys(t)?runtime[e]:null}async function getOriginList(t){if("string"!=typeof t&&(t=t.taskId),isSys(t))return list$1;if(!list$1[t])return{};return(await checkPermission(t,"root"))[0]?list$1:{}}const getRetry={hour:"",count:0};function get$1(t){"string"!=typeof t&&(t=t.taskId);const e=getOrigin(t);return e?{name:e.app.config.name,locale:e.locale.lang,customTheme:e.customTheme,formCount:Object.keys(e.forms).length,icon:e.app.icon,path:e.path,current:e.current}:null}function getOrigin(t){if("string"!=typeof t&&(t=t.taskId),!list$1[t]){const t=new Date,e=`${t.getUTCFullYear()}${t.getUTCMonth().toString().padStart(2,"0")}${t.getUTCDate().toString().padStart(2,"0")}${t.getUTCHours().toString().padStart(2,"0")}`;if(getRetry.hour!==e)getRetry.hour=e,getRetry.count=0;else if(++getRetry.count,getRetry.count>10){const t=new Error(`task.get retry, ${e}: ${getRetry.count}`);trigger("error","","",t,t.message).catch(()=>{})}return null}return list$1[t]}let focusId=null;function setFocus(t){return t?!!list$1[t]&&(focusId=t,!0):(focusId=null,!0)}async function getFocus(t){if("string"!=typeof t&&(t=t.taskId),isSys(t))return focusId;if(!list$1[t])return null;return(await checkPermission(t,"root"))[0]?focusId:null}const localeData$2={en:{loading:"Loading..."},sc:{loading:"加载中……"},tc:{loading:"載入中……"},ja:{loading:"読み込み中..."},ko:{loading:"로딩 중..."},th:{loading:"กำลังโหลด..."},es:{loading:"Cargando..."},de:{loading:"Laden..."},fr:{loading:"Chargement en cours..."},pt:{loading:"Carregando..."},ru:{loading:"Загрузка..."},vi:{loading:"Đang tải..."}};let frameTimer=0;const frameMaps={};function onFrame(t,e,n={}){"string"!=typeof t&&(t=t.taskId);const o=n.formId;if(!t)return 0;const r=list$1[t];if(!r)return 0;if(o&&!r.forms[o])return 0;const s=++frameTimer,i=n.count??0;let a,c=0;const l=async()=>{if(++c,o&&void 0===r.forms[o])return delete r.timers["1x"+s.toString()],void delete frameMaps[s];if(await e(),null!=r.timers["1x"+s.toString()])if(i>1){if(c===i)return delete r.timers["1x"+s.toString()],void delete frameMaps[s];a=requestAnimationFrame(function(){l().catch(()=>{})}),frameMaps[s]=a}else 1===i?(delete r.timers["1x"+s.toString()],delete frameMaps[s]):(a=requestAnimationFrame(function(){l().catch(()=>{})}),frameMaps[s]=a)};return a=requestAnimationFrame(function(){l().catch(()=>{})}),frameMaps[s]=a,r.timers["1x"+s.toString()]=o??"",s}function offFrame(t,e){if("string"!=typeof t&&(t=t.taskId),!list$1[t])return;void 0!==list$1[t].timers["1x"+e.toString()]&&(cancelAnimationFrame(frameMaps[e]),delete list$1[t].timers["1x"+e.toString()],delete frameMaps[e])}function getPermissions(t){return"string"!=typeof t&&(t=t.taskId),void 0===list$1[t]?[]:clone(runtime[t].permissions)}function getList(){const t=[];for(const e in list$1){const n=list$1[e];t.push({name:n.app.config.name,locale:n.locale.lang,customTheme:n.customTheme,formCount:Object.keys(n.forms).length,icon:n.app.icon,path:n.path,current:n.current})}return t}var EIPTYPE;async function run(t,e,n={}){if("string"!=typeof t&&(t=t.taskId),!isSys(t)&&!list$1[t])return 0;let o="Load app ...";await(n.initProgress?.(0,7,EIPTYPE.APP,o));let r=getDirname()+"/icon.png";n.icon&&(r=n.icon),n.notify??=!0;const s=n.notify?notify({title:localeData$2[config.locale]?.loading??localeData$2.en.loading,content:"string"==typeof e?e:e.config.name,note:o,icon:r,timeout:0,progress:!0}):void 0;let i=null;if("string"==typeof e){if(!e.endsWith(".cga"))return s&¬ifyContent(s,{note:"Error -1",timeout:3e3}),-1;e.startsWith("/clickgo/")||e.startsWith("/storage/")||e.startsWith("/mounted/")||e.startsWith("/package/")||e.startsWith("/current/")||(e=urlResolve(location.href,e)),i=await fetchApp(t,e,{notify:{id:s,loaded:0,total:7},progress:async(t,o,r)=>{await(n.progress?.(t,o,"app",e)),await(n.perProgress?.(r))},after:n.after})}else{if("app"!==e.type)return s&¬ifyContent(s,{note:"Error -2",timeout:3e3}),-2;i=e}if(!i)return s&¬ifyContent(s,{note:"Error -3",timeout:3e3}),-3;let a="";do{a=random(8,RANDOM_LUN)}while(list$1[a]);const c=n.path??("string"==typeof e?e:"/runtime/"+random(16,RANDOM_LN)+".cga"),l=c.lastIndexOf("/"),d=c.slice(0,l);list$1[a]={id:a,app:i,class:null,customTheme:!1,locale:modules.vue.reactive({lang:"",data:{}}),path:c,current:d,forms:{},controls:{},timers:{},threads:{}};let f=n.permissions??[];if((await checkPermission(t,"root"))[0]||(f=[]),runtime[a]=modules.vue.reactive({dialogFormIds:[],permissions:f,index:++index}),i.config.locales)for(let t in i.config.locales){const e=i.config.locales[t];t.endsWith(".json")||(t+=".json"),o=`Load local '${t}' ...`,await(n.initProgress?.(1,7,EIPTYPE.LOCAL,o));const r=1/7;await(n.perProgress?.(r)),s&¬ifyContent(s,{note:o,progress:r});const c=await getContent(a,t,{encoding:"utf8"});if(c)try{loadLocaleData(a,e,JSON.parse(c),"")}catch{}}let u=[];try{if(i.config.modules?.length)for(const t of i.config.modules)if(!modules[t]&&checkModule(t)&&!await loadModule(t))return s&¬ifyContent(s,{note:"Error -4",timeout:3e3}),-4;const t=i.files["/app.js"];if("string"!=typeof t)return s&¬ifyContent(s,{note:"Error -5",timeout:3e3}),-5;let e=!0;if(stateMachine(t,0,t=>t.state!==ESTATE.WORD||(!["eval","Function"].includes(t.word)||(notify({title:"Error",content:`The "${t.word}" is prohibited.\nFile: "${c}".`,type:"danger"}),e=!1,!1))),!e)return s&¬ifyContent(s,{note:"Error -6",timeout:3e3}),-6;if(u=runIife(t),!u)return s&¬ifyContent(s,{note:"Error -7",timeout:3e3}),-7}catch(t){return delete list$1[a],trigger("error",a,"",t,t.message+"(-1)").catch(()=>{}),s&¬ifyContent(s,{note:"Error -8",timeout:3e3}),-8}createToStyleList(a),o="Control initialization ...",await(n.initProgress?.(2,7,EIPTYPE.CONTROL,o));const m=2/7;await(n.perProgress?.(m)),s&¬ifyContent(s,{note:o,progress:2/7});const h=await init(a,{progress:async(t,e,o)=>{await(n.progress?.(t,e,"control",o));let r=t/e;r=Math.min(2/7+1/7*r,1),await(n.perProgress?.(r)),s&¬ifyContent(s,{note:"Loaded "+o,progress:r})}});if(h<0)return removeFromStyleList(a),delete list$1[a],s&¬ifyContent(s,{note:"Error "+(-900+h).toString(),timeout:3e3}),-900+h;if(i.config.themes?.length)for(let t of i.config.themes){t+=".cgt",t=urlResolve("/",t),o=`Load theme '${t}' ...`,await(n.initProgress?.(3,7,EIPTYPE.THEME,o));const e=3/7;await(n.perProgress?.(e)),s&¬ifyContent(s,{note:o,progress:e});const r=await getContent(a,t);if(r&&"string"!=typeof r){const t=await read$1(r);t&&await load(a,t)}}else if(global$1){o="Load global theme ...",await(n.initProgress?.(3,7,EIPTYPE.THEME,o));const t=3/7;await(n.perProgress?.(t)),s&¬ifyContent(s,{note:o,progress:t}),await load(a)}if(i.config.style){const t=await getContent(a,i.config.style+".css",{encoding:"utf8"});if(t){const e=stylePrepend(t,"cg-task"+a.toString()+"_");o="Style initialization ...",await(n.initProgress?.(4,7,EIPTYPE.STYLE,o));const r=4/7;await(n.perProgress?.(r)),s&¬ifyContent(s,{note:o,progress:r}),pushStyle(a,await styleUrl2DataUrl(i.config.style,e.style,i.files))}}if(trigger("taskStarted",a).catch(()=>{}),i.config.permissions){o="Permission initialization ...",await(n.initProgress?.(5,7,EIPTYPE.PERMISSION,o));const t=5/7;await(n.perProgress?.(t)),s&¬ifyContent(s,{note:o,progress:t}),await checkPermission(a,i.config.permissions,!0,void 0)}const g=new u;g.filename=c,g.taskId=a,list$1[a].class=g,o="Starting ...",await(n.initProgress?.(6,7,EIPTYPE.START,o));const p=6/7;await(n.perProgress?.(p)),s&¬ifyContent(s,{note:o,progress:p}),await g.main(n.data??{}),o="Done.",await(n.initProgress?.(7,7,EIPTYPE.DONE,o));return await(n.perProgress?.(1)),s&¬ifyContent(s,{note:o,progress:1,timeout:3e3}),a}!function(t){t[t.APP=0]="APP",t[t.LOCAL=1]="LOCAL",t[t.CONTROL=2]="CONTROL",t[t.THEME=3]="THEME",t[t.STYLE=4]="STYLE",t[t.PERMISSION=5]="PERMISSION",t[t.START=6]="START",t[t.DONE=7]="DONE"}(EIPTYPE||(EIPTYPE={}));const locale={sc:{unknown:"未知权限",root:"<b>危险!</b>最高权限!请一定确认是否允许!","apply-permission":"正在申请权限,请您仔细确认","native.form":"实体窗体控制",hash:"可修改地址栏 hash",fs:"文件系统",readonly:"只读","read-write":"读写"},tc:{unknown:"未知許可權",root:"<b>危險!</b>最高許可權!請一定確認是否允許!","apply-permission":"正在申請許可權,請您仔細確認","native.form":"實體視窗控制",hash:"可修改位址列 hash",fs:"檔案系統",readonly:"唯讀","read-write":"讀寫"},en:{unknown:"Unknown",root:"<b>Danger!</b> Highest permission! Please confirm if you want to allow!","apply-permission":"Applying permission, please confirm carefully","native.form":"Native window control",hash:'Can modify address bar "hash"',fs:"File system",readonly:"Read-only","read-write":"Read and write"},ja:{unknown:"不明な権限",root:"<b>危険!</b>最高権限です!許可するかどうか必ず確認してください!","apply-permission":"権限を申請中です。よくご確認ください","native.form":"ネイティブフォームコントロール",hash:'アドレスバーの "hash" を変更できます',fs:"ファイルシステム",readonly:"読み取り専用","read-write":"読み書き可能"},ko:{unknown:"알 수 없는 권한",root:"<b>위험!</b> 최고 권한입니다! 반드시 허용할 것인지 확인하십시오!","apply-permission":"권한을 신청 중입니다. 주의 깊게 확인하십시오","native.form":"네이티브 폼 제어",hash:'주소 표시 줄 "hash" 를 수정할 수 있습니다',fs:"파일 시스템",readonly:"읽기 전용","read-write":"읽기 및 쓰기"},th:{unknown:"สิทธิ์ที่ไม่รู้จัก",root:"<b>อันตราย!</b> สิทธิ์สูงสุด! โปรดตรวจสอบว่าต้องการอนุญาตหรือไม่!","apply-permission":"กำลังขอสิทธิ์ โปรดตรวจสอบอย่างรอบคอบ","native.form":"การควบคุมแบบฟอร์มแบบ Native",hash:'สามารถแก้ไขแถบที่อยู่ "hash"',fs:"ระบบไฟล์",readonly:"อ่านได้อย่างเดียว","read-write":"อ่านและเขียนได้"},es:{unknown:"Permiso desconocido",root:"<b>¡Peligro!</b> ¡Permiso máximo! ¡Asegúrese de permitirlo!","apply-permission":"Solicitando permiso. Por favor, compruebe cuidadosamente","native.form":"Control de formulario nativo",hash:'Puede modificar el "hash" de la barra de direcciones',fs:"Sistema de archivos",readonly:"Solo lectura","read-write":"Lectura y escritura"},de:{unknown:"Unbekannte Berechtigung",root:"<b>Gefahr!</b> Höchste Berechtigung! Bitte stellen Sie unbedingt sicher, ob dies erlaubt ist!","apply-permission":"Bitte bestätigen Sie die Berechtigungsanfrage sorgfältig","native.form":"Natives Formularsteuerelement",hash:'Adressleisten "hash" bearbeiten',fs:"Dateisystem",readonly:"Schreibgeschützt","read-write":"Lesen/Schreiben"},fr:{unknown:"Autorisation inconnue",root:"<b>Danger !</b> Autorisation maximale ! Veuillez vous assurer que vous êtes autorisé à le faire !","apply-permission":"Demande d'autorisation en cours, veuillez vérifier attentivement","native.form":"Contrôle de formulaire natif",hash:'Modifier le "hash" de la barre d\'adresse',fs:"Système de fichiers",readonly:"Lecture seule","read-write":"Lecture/écriture"},pt:{unknown:"Permissão desconhecida",root:"<b>Perigo!</b> Permissão máxima! Certifique-se de ter permissão para fazê-lo!","apply-permission":"Solicitando permissão, por favor confirme cuidadosamente","native.form":"Controle de formulário nativo",hash:'Editar "hash" da barra de endereço',fs:"Sistema de arquivos",readonly:"Somente leitura","read-write":"Leitura/escrita"},ru:{unknown:"Неизвестное разрешение",root:"<b>Опасность!</b> Максимальное разрешение! Пожалуйста, обязательно убедитесь, что это разрешено!","apply-permission":"Выполняется запрос на разрешение, пожалуйста, внимательно подтвердите","native.form":"Нативный элемент формы",hash:'Изменить "hash" адресной строки',fs:"Файловая система",readonly:"Только для чтения","read-write":"Чтение/запись"},vi:{unknown:"Quyền không xác định",root:"<b>Nguy hiểm!</b> Quyền hạn cao nhất! Hãy đảm bảo rằng bạn được phép làm điều này!","apply-permission":"Đang yêu cầu quyền truy cập, vui lòng xác nhận cẩn thận","native.form":"Thiết bị kiểm soát biểu mẫu gốc",hash:'Chỉnh sửa "hash" thanh địa chỉ',fs:"Hệ thống tập tin",readonly:"Chỉ đọc","read-write":"Đọc/ghi"}};async function checkPermission(t,e,n=!1,o){if("string"!=typeof t&&(t=t.taskId),"string"==typeof e&&(e=[e]),isSys(t))return new Array(e.length).fill(!0);const r=list$1[t];if(!r)return new Array(e.length).fill(!1);const s=[],i=[];for(const o of e){if(runtime[t].permissions.includes("root")){s.push(!0);continue}if(o.startsWith("fs.")){let e=!1;const r=o.slice(3,-1);for(const n of runtime[t].permissions){if(!n.startsWith("fs."))continue;const t=n.slice(3,-1);if(t.endsWith("/")){if(!r.startsWith(t))continue}else if(t!==r)continue;if(!o.endsWith("w")||!n.endsWith("r")){e=!0;break}}s.push(e),!e&&n&&i.push(o);continue}const e=runtime[t].permissions.includes(o);!e&&n&&i.push(o),s.push(e)}if(i.length){let e='<div>"'+escapeHTML(r.app.config.name)+'" '+(locale[config.locale]?.["apply-permission"]??locale.en["apply-permission"])+":</div>";for(const t of i){if(t.startsWith("fs.")){const n=t.slice(3,-1);e+='<div style="margin-top: 10px;">'+(locale[config.locale]?.fs??locale.en.fs)+" "+escapeHTML(n)+" "+(t.endsWith("r")?locale[config.locale]?.readonly??locale.en.readonly:locale[config.locale]?.["read-write"]??locale.en["read-write"])+'<div style="color: hsl(0,0%,60%);">'+escapeHTML(t)+"</div></div>";continue}e+='<div style="margin-top: 10px;">'+(locale[config.locale]?.[t]??locale.en[t]??locale[config.locale]?.unknown??locale.en.unknown)+'<div style="color: hsl(0,0%,60%);">'+escapeHTML(t)+"</div></div>"}if(await superConfirm(sysId$5,e)){for(let t=0;t<s.length;++t)s[t]||(s[t]=!0);for(const e of i)runtime[t].permissions.push(e);try{await(o?.(i))}catch{}}}return s}async function end(t){"string"!=typeof t&&(t=t.taskId);const e=list$1[t];if(!e)return!0;isNative()&&1===Object.keys(list$1).length&&await close$1(sysId$5);for(const e in list$1[t].threads)await list$1[t].threads[e].end();const n=await getMaxZIndexID(sysId$5,{taskIds:[t]});await changeFocus(n??void 0);for(const n in e.forms){const o=e.forms[n];trigger("formRemoved",t,o.id,o.vroot.$refs.form.title,o.vroot.$refs.form.iconDataUrl).catch(()=>{});try{o.vapp.unmount()}catch(t){notify({title:"Form Unmount Error",content:`Message: ${t.message}\nTask id: ${e.id}\nForm id: ${n}\nFunction: task.end, unmount.`,type:"danger"})}o.vapp._container.remove(),elements.popList.querySelector('[data-form-id="'+o.id.toString()+'"]')?.remove(),clearWatchStyle(n),clearWatchProperty(n),clearWatchPosition(n),delete activePanels[n]}const o=elements.list.querySelectorAll('.cg-form-wrap[data-task-id="'+t.toString()+'"]');for(const t of o)t.remove();removeFromStyleList(t);for(const e in list$1[t].timers)if(e.startsWith("1x")){const t=e.slice(2);cancelAnimationFrame(frameMaps[t]),delete frameMaps[t]}else clearTimeout(parseFloat(e));return clearWatchSize(t),clearWatch(t),clear$2(t),delete list$1[t],delete runtime[t],trigger("taskEnded",t).catch(()=>{}),await clearSystem(t),!0}function loadLocaleData(t,e,n,o=""){if("string"!=typeof t&&(t=t.taskId),t){list$1[t].locale.data[e]||(list$1[t].locale.data[e]={});for(const r in n){const s=n[r];"object"==typeof s?loadLocaleData(t,e,s,o+r+"."):list$1[t].locale.data[e][o+r]=s}}}async function loadLocale(t,e,n){"string"!=typeof t&&(t=t.taskId);const o=list$1[t];if(!o)return!1;const r=await getContent(t,n+".json",{encoding:"utf8"});if(!r)return!1;try{const t=JSON.parse(r);return loadLocaleData(o.id,e,t,""),!0}catch{return!1}}function clearLocale(t){"string"!=typeof t&&(t=t.taskId);const e=list$1[t];e&&(e.locale.data={})}function setLocale(t,e,n){return clearLocale(t),loadLocale(t,e,n)}function setLocaleLang(t,e){"string"!=typeof t&&(t=t.taskId);const n=list$1[t];n&&(n.locale.lang=e)}function clearLocaleLang(t){"string"!=typeof t&&(t=t.taskId);const e=list$1[t];e&&(e.locale.lang="")}function createTimer(t,e,n,o={}){"string"!=typeof t&&(t=t.taskId);const r=o.formId,s=list$1[t];if(!s)return 0;if(r&&!s.forms[r])return 0;const i=o.count??0;let a,c=0;if(o.immediate){const t=e();if(t instanceof Promise&&t.catch(()=>{}),++c,i>0&&c===i)return 0}const l=()=>{if(++c,r&&void 0===s.forms[r])return clearTimeout(a),void delete s.timers[a];const t=e();return t instanceof Promise&&t.catch(()=>{}),i>0&&c===i?(clearTimeout(a),void delete s.timers[a]):void 0};return a=1===i?window.setTimeout(l,n):window.setInterval(l,n),s.timers[a]=r??"",a}function removeTimer(t,e){if("string"!=typeof t&&(t=t.taskId),!list$1[t])return;void 0!==list$1[t].timers[e]&&(clearTimeout(e),delete list$1[t].timers[e])}function sleep(t,e,n){return createTimer(t,e,n,{count:1})}const systemTaskInfoOrigin={taskId:"",formId:"",length:0};let systemTaskInfo;function setSystem(t,e){"string"!=typeof t&&(t=t.taskId);const n=list$1[t];if(!n)return!1;const o=n.forms[e];return!!o&&(void 0===o.vroot.position?(notify({title:"Warning",content:`Task id is "${t}" app is not an available task app, position not found.`,type:"warning"}),!1):(systemTaskInfo.taskId&¬ify({title:"Info",content:"More than 1 system-level task application is currently running.",type:"info"}),systemTaskInfo.taskId=t,systemTaskInfo.formId=e,simpleSystemTaskRoot.forms={},refreshSystemPosition(),!0))}async function clearSystem(t){if("string"!=typeof t&&(t=t.taskId),systemTaskInfo.taskId!==t)return!1;systemTaskInfo.taskId="",systemTaskInfo.formId="",systemTaskInfo.length=0,trigger("screenResize").catch(()=>{});const e=await getOriginList(sysId$5);for(const t in e){const e=getList$1(t);for(const t in e){const n=e[t];n.stateMin&&(simpleSystemTaskRoot.forms[t]={title:n.title,icon:n.icon})}}return!0}function refreshSystemPosition(){if(systemTaskInfo.taskId){const t=list$1[systemTaskInfo.taskId].forms[systemTaskInfo.formId];switch(config["task.position"]){case"left":case"right":t.vroot.$refs.form.setPropData("width",0),t.vroot.$refs.form.setPropData("height",window.innerHeight);break;case"top":case"bottom":t.vroot.$refs.form.setPropData("width",window.innerWidth),t.vroot.$refs.form.setPropData("height",0)}setTimeout(function(){switch(config["task.position"]){case"left":systemTaskInfo.length=t.vroot.$el.offsetWidth,t.vroot.$refs.form.setPropData("left",0),t.vroot.$refs.form.setPropData("top",0);break;case"right":systemTaskInfo.length=t.vroot.$el.offsetWidth,t.vroot.$refs.form.setPropData("left",window.innerWidth-systemTaskInfo.length),t.vroot.$refs.form.setPropData("top",0);break;case"top":systemTaskInfo.length=t.vroot.$el.offsetHeight,t.vroot.$refs.form.setPropData("left",0),t.vroot.$refs.form.setPropData("top",0);break;case"bottom":systemTaskInfo.length=t.vroot.$el.offsetHeight,t.vroot.$refs.form.setPropData("left",0),t.vroot.$refs.form.setPropData("top",window.innerHeight-systemTaskInfo.length)}trigger("screenResize").catch(()=>{})},50)}else trigger("screenResize").catch(()=>{})}let inited$1=!1;function init$2(){inited$1||(inited$1=!0,systemTaskInfo=modules.vue.reactive({taskId:"",formId:"",length:0}),modules.vue.watch(systemTaskInfo,function(){for(const t in systemTaskInfoOrigin)void 0===systemTaskInfo[t]&&(notify({title:"Warning",content:"There is a software that maliciously removed the system task info item.\nKey: "+t,type:"warning"}),systemTaskInfo[t]=systemTaskInfoOrigin[t]??0);for(const t in systemTaskInfo)Object.keys(systemTaskInfoOrigin).includes(t)?typeof systemTaskInfo[t]!=typeof systemTaskInfoOrigin[t]&&(notify({title:"Warning",content:"There is a software that maliciously modifies the system task info item.\nKey: "+t,type:"warning"}),systemTaskInfo[t]=systemTaskInfoOrigin[t]):(notify({title:"Warning",content:"There is a software that maliciously modifies the system task info item.\nKey: "+t,type:"warning"}),delete systemTaskInfo[t])},{deep:!0}))}class AbstractThread{get filename(){return""}taskId="";onMessage(){}onEnded(){}onError(){}send(t){self.postMessage(t)}close(){self.postMessage({cmd:"cg-terminate"})}}function runThread(t,e,n){"string"!=typeof t&&(t=t.taskId);const o=getOrigin(t);if(!o){const t=new Error("task.runThread: -1");throw trigger("error","","",t,t.message).catch(()=>{}),t}let r=e.toString();r=r.replace(/class (\w+) extends.+?AbstractThread *{/,"class cgCustomThread extends AbstractThread {");const s=/filename *\(\) *{ *return *"(.+?)"/.exec(r);if(!s){const t=new Error("task.runThread: -2");throw trigger("error","","",t,t.message).catch(()=>{}),t}if(o.threads[s[1]])return o.threads[s[1]];const i=new Blob([`${AbstractThread.toString()}\n${r}\nconst threadCls = new cgCustomThread();\nthreadCls.taskId = '${o.id}';\nself.onmessage = async function(e) {\n if (e.data.cmd === 'cg-init') {\n await threadCls.main(e.data.data);\n return;\n }\n if (e.data.cmd === 'cg-terminate') {\n await threadCls.onEnded();\n self.postMessage({\n 'cmd': 'cg-terminate',\n });\n return;\n }\n threadCls.onMessage(e);\n}\nself.onerror = function(e) {\n threadCls.onError(e);\n}\n`],{type:"application/javascript"}),a=URL.createObjectURL(i),c=new Worker(a);URL.revokeObjectURL(a),c.postMessage({cmd:"cg-init",data:n??{}});const l=[];c.onmessage=t=>{if("cg-terminate"===t.data.cmd)return c.terminate(),void delete o.threads[s[1]];for(const e of l)e(t)};const d={on:(t,e)=>{"message"===t&&l.push(e)},off:(t,e)=>{if("message"!==t)return;const n=l.indexOf(e);-1!==n&&l.splice(n,1)},send:t=>{c.postMessage(t)},end:()=>new Promise(t=>{c.postMessage({cmd:"cg-terminate"}),c.onmessage=()=>{t(),c.terminate(),delete o.threads[s[1]]}})};return o.threads[s[1]]=d,d}var task=Object.freeze({__proto__:null,AbstractThread:AbstractThread,get EIPTYPE(){return EIPTYPE},checkPermission:checkPermission,clearLocale:clearLocale,clearLocaleLang:clearLocaleLang,clearSystem:clearSystem,createTimer:createTimer,end:end,get:get$1,getFocus:getFocus,getList:getList,getOrigin:getOrigin,getOriginList:getOriginList,getPermissions:getPermissions,getRuntime:getRuntime,init:init$2,initSysId:initSysId$4,loadLocale:loadLocale,loadLocaleData:loadLocaleData,offFrame:offFrame,onFrame:onFrame,refreshSystemPosition:refreshSystemPosition,removeTimer:removeTimer,run:run,runThread:runThread,setFocus:setFocus,setLocale:setLocale,setLocaleLang:setLocaleLang,setSystem:setSystem,sleep:sleep,get systemTaskInfo(){return systemTaskInfo}});let sysId$4="";function initSysId$3(t){sysId$4||(sysId$4=t)}const clickgoFiles=["/app/","/app/demo.cga","/app/task.cga","/control/","/control/arteditor.cgc","/control/box.cgc","/control/captcha.cgc","/control/common.cgc","/control/cube.cgc","/control/desc.cgc","/control/drawer.cgc","/control/echarts.cgc","/control/fabric.cgc","/control/form.cgc","/control/iconview.cgc","/control/jodit.cgc","/control/map.cgc","/control/marked.cgc","/control/monaco.cgc","/control/mpegts.cgc","/control/nav.cgc","/control/novnc.cgc","/control/objviewer.cgc","/control/page.cgc","/control/pdf.cgc","/control/property.cgc","/control/qrcode.cgc","/control/table.cgc","/control/task.cgc","/control/tplink.cgc","/control/tuieditor.cgc","/control/tuiviewer.cgc","/control/tums.cgc","/control/web.cgc","/control/xterm.cgc","/ext/","/ext/toastui-editor-all.min.js","/ext/tplinkhd.min.js","/ext/tums-player/","/ext/tums-player/audio.wasm","/ext/tums-player/decoder.worker.js","/ext/tums-player/libaudio.js","/ext/tums-player/libaudio.wasm","/ext/tums-player/libffmpeg.js","/ext/tums-player/libffmpeg.wasm","/ext/tums-player/libs.worker.js","/ext/tums-player/tums-player.umd.min.js","/ext/tums-player/webgl.js","/ext/tums-player/webgl.worker.js","/global.css","/icon.png","/index.js","/notosans-regular.ttf","/theme/","/theme/admin.cgt","/theme/cyber.cgt","/theme/dark.cgt","/theme/light.cgt","/theme/modern.cgt"],localeData$1={en:{"apply-unmount":'Are you sure to unmount the "?" mount point?'},sc:{"apply-unmount":"确定卸载“?”挂载点吗?"},tc:{"apply-unmount":"確定卸載「?」掛載點嗎?"},ja:{"apply-unmount":"「?」マウントポイントをアンマウントしてよろしいですか?"},ko:{"apply-unmount":'"?" 마운트 지점을 언마운트하시겠습니까?'},th:{"apply-unmount":'คุณแน่ใจหรือว่าต้องการยกเลิกการติดตั้งจุดติดตั้ง "?"'},es:{"apply-unmount":'¿Está seguro de que desea desmontar el punto de montaje "?"'},de:{"apply-unmount":'Möchten Sie den Einhängepunkt "?" wirklich demontieren?'},fr:{"apply-unmount":'Voulez-vous vraiment démonter le point de montage "?"'},pt:{"apply-unmount":'Tem certeza de que deseja desmontar o ponto de montagem "?"'},ru:{"apply-unmount":'Вы уверены, что хотите отмонтировать точку монтирования "?"'},vi:{"apply-unmount":'Bạn có chắc chắn muốn tháo dỡ điểm gắn "?" không?'}},mounts={};function getMountName(t){const e=t.slice(9).indexOf("/");return-1===e?t.slice(9):t.slice(9,e+9)}function mount(t,e,n){if("string"!=typeof t&&(t=t.taskId),mounts[e])return!1;if(!/^[a-zA-Z][\w]+$/.test(e))return!1;if(t!==sysId$4&&getOrigin(t)){const n="fs./mounted/"+e+"/w",o=getRuntime(sysId$4,t);o&&(o.permissions.includes(n)||o.permissions.push(n))}return n.date=new Date,mounts[e]=n,!0}async function unmount(t){if(!mounts[t])return!0;const e=localeData$1[config.locale]?.["apply-unmount"]??localeData$1.en["apply-unmount"];return!!await superConfirm(sysId$4,e.replace("?","/mount/"+escapeHTML(t)+"/"))&&(delete mounts[t],!0)}async function getContent(t,e,n){t&&"string"!=typeof t&&(t=t.taskId);const o=(e=urlResolve("/",e)).slice(8);"string"==typeof n?n={encoding:n}:n??={};const r=n.encoding,s=n.start,i=n.end;if(!(e.startsWith("/clickgo/")||e.startsWith("http:")||e.startsWith("https:")||e.startsWith("file:"))){if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!t)return null;if(!(await checkPermission(t,"fs."+e+"r",!1,void 0))[0])return null;if(e.startsWith("/mounted/")){const t=getMountName(e),o=mounts[t];return o?o.getContent?.(e.slice(9+t.length),n)??null:null}n.progress&&delete n.progress;const r=await invokeSys(sysId$4,"cg-fs-getContent",o,n);return r?"string"==typeof r?r:new Blob([r],{type:getMimeByPath(e).mime}):null}if(e.startsWith("/package/")||e.startsWith("/current/")){if(!t)return null;const r=getOrigin(t);if(!r)return null;if(e.startsWith("/current/"))return getContent(t,r.current+o,n);const a=r.app.files[o];if(!a)return null;if("string"==typeof a)return a;if(!n.encoding)return void 0===s&&void 0===i?a:a.slice(s,i,a.type);const c=n.encoding;return new Promise(function(t){const e=new FileReader;e.addEventListener("load",function(){t(e.result)}),e.readAsText(a,c)})}return null}{let t="";if(e.startsWith("/clickgo/")){if(!clickgoFiles.includes(o))return null;t=getDirname()+o}else t=e+(n.after??"");try{let e=null;const o={};return(s??i)&&(o.range=`bytes=${s??"0"}-${i??""}`),e=n.progress?await request(t,{headers:o,progress:n.progress,responseType:"blob"}):await(await fetch(t,{headers:o})).blob(),e?r?await new Promise(function(t){const n=new FileReader;n.addEventListener("load",function(){t(n.result)}),n.readAsText(e,r)}):e:null}catch{return null}}}async function putContent(t,e,n,o={}){"string"!=typeof t&&(t=t.taskId);const r=(e=urlResolve("/",e)).slice(8);if(e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!(await checkPermission(t,"fs."+e+"w",!1,void 0))[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e),r=mounts[t];return!!r&&(r.putContent?.(e.slice(9+t.length),n,o)??!1)}let s;return n instanceof Blob&&(s=new Uint8Array(await n.arrayBuffer())),invokeSys(sysId$4,"cg-fs-putContent",r,s??n,o)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const e=getOrigin(t);return!!e&&putContent(t,e.current+r,n,o)}return!1}async function readLink(t,e,n){"string"!=typeof t&&(t=t.taskId);const o=(e=urlResolve("/",e)).slice(8);if(e.startsWith("/clickgo/"))return null;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!(await checkPermission(t,"fs."+e+"r",!1))[0])return null;if(e.startsWith("/mounted/")){const t=getMountName(e),o=mounts[t];return o?o.readLink?.(e.slice(9+t.length),n)??null:null}return invokeSys(sysId$4,"cg-fs-readLink",o,n)}if(e.startsWith("/package/"))return null;if(e.startsWith("/current/")){const e=getOrigin(t);return e?e.current:null}return null}async function symlink(t,e,n,o){if("string"!=typeof t&&(t=t.taskId),e=urlResolve("/",e),n=urlResolve("/",n),e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!(await checkPermission(t,"fs."+e+"w",!1))[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e);if(t!==getMountName(n))return!1;const r=mounts[t];return!!r&&(r.symlink?.(e.slice(9+t.length),n.slice(9+t.length),o)??!1)}return invokeSys(sysId$4,"cg-fs-symlink",e.slice(8),n.slice(8),o)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const r=getOrigin(t);return!!r&&(n.startsWith("/current/")&&(n=r.current+n.slice(8)),symlink(t,r.current+e.slice(8),n,o))}return!1}async function unlink(t,e){"string"!=typeof t&&(t=t.taskId);const n=(e=urlResolve("/",e)).slice(8);if(e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!(await checkPermission(t,"fs."+e+"w",!1))[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e),n=mounts[t];return!!n&&(n.unlink?.(e.slice(9+t.length))??!1)}return invokeSys(sysId$4,"cg-fs-unlink",n)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const e=getOrigin(t);return!!e&&unlink(t,e.current+n)}return!1}async function getClickGoStats(t){if(t.endsWith("/")){const t=new Date,e=t.getTime();return{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},size:0,blksize:0,atimeMs:e,mtimeMs:e,ctimeMs:e,birthtimeMs:e,atime:t,mtime:t,ctime:t,birthtime:t}}try{const e=await fetch(getDirname()+t,{headers:{range:"bytes=0-1"}}),n=e.headers.get("date"),o=e.headers.get("last-modified");let r=e.headers.get("content-range");if(r){const t=r.lastIndexOf("/");r=r.slice(t+1)}let s=new Date,i=s;n&&(s=new Date(n)),o&&(i=new Date(o));const a=s.getTime(),c=i.getTime();return{isFile:function(){return!0},isDirectory:function(){return!1},isSymbolicLink:function(){return!1},size:r?parseInt(r):0,blksize:r?parseInt(r):0,atimeMs:a,mtimeMs:c,ctimeMs:c,birthtimeMs:a,atime:s,mtime:i,ctime:i,birthtime:s}}catch{return null}}async function stats(t,e){if("string"!=typeof t&&(t=t.taskId),(e=urlResolve("/",e)).endsWith("/")&&(e=e.slice(0,-1)),["","/clickgo","/storage","/mounted","/package"].includes(e)){const t=new Date,e=t.getTime();return{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},size:0,blksize:0,atimeMs:e,mtimeMs:e,ctimeMs:e,birthtimeMs:e,atime:t,mtime:t,ctime:t,birthtime:t}}if("/current"===e){const t=new Date,e=t.getTime();return{isFile:function(){return!1},isDirectory:function(){return!1},isSymbolicLink:function(){return!0},size:0,blksize:0,atimeMs:e,mtimeMs:e,ctimeMs:e,birthtimeMs:e,atime:t,mtime:t,ctime:t,birthtime:t}}let n=e.slice(8);if(e.startsWith("/clickgo/")){if(!clickgoFiles.includes(n)){if(!clickgoFiles.includes(n+"/"))return null;n+="/"}return getClickGoStats(n)}if(e.startsWith("/storage/")){if(!(await checkPermission(t,"fs."+e+"r",!1))[0])return null;const o=await invokeSys(sysId$4,"cg-fs-stats",n);return o?{isFile:function(){return o.isFile},isDirectory:function(){return o.isDirectory},isSymbolicLink:function(){return o.isSymbolicLink},size:o.size,blksize:o.blksize,atimeMs:o.atimeMs,mtimeMs:o.mtimeMs,ctimeMs:o.ctimeMs,birthtimeMs:o.birthtimeMs,atime:o.atime,mtime:o.mtime,ctime:o.ctime,birthtime:o.birthtime}:null}if(e.startsWith("/mounted/")){const n=getMountName(e),o=mounts[n];if(!o)return null;if(e==="/mounted/"+n){const t=o.date.getTime();return{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},size:0,blksize:0,atimeMs:t,mtimeMs:t,ctimeMs:t,birthtimeMs:t,atime:o.date,mtime:o.date,ctime:o.date,birthtime:o.date}}return(await checkPermission(t,"fs."+e+"r",!1))[0]?o.stats?.(e.slice(9+n.length))??null:null}if(e.startsWith("/package/")||e.startsWith("/current/")){const o=getOrigin(t);if(!o)return null;if(e.startsWith("/current/"))return stats(t,o.current+n);if(o.app.files[n]){const t=o.app.files[n],e=new Date,r=e.getTime();let s=0;return s="string"!=typeof t?t.size:new Blob([t]).size,{isFile:function(){return!0},isDirectory:function(){return!1},isSymbolicLink:function(){return!1},size:s,blksize:s,atimeMs:r,mtimeMs:r,ctimeMs:r,birthtimeMs:r,atime:e,mtime:e,ctime:e,birthtime:e}}n.endsWith("/")||(n+="/");for(const t in o.app.files){if(!t.startsWith(n))continue;const e=new Date,o=e.getTime();return{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},size:0,blksize:0,atimeMs:o,mtimeMs:o,ctimeMs:o,birthtimeMs:o,atime:e,mtime:e,ctime:e,birthtime:e}}return null}return null}async function isDir(t,e){const n=await stats(t,e);return!!n?.isDirectory()&&n}async function isFile(t,e){const n=await stats(t,e);return!!n?.isFile()&&n}async function mkdir(t,e,n=493){if("string"!=typeof t&&(t=t.taskId),e=urlResolve("/",e),await isDir(t,e))return!0;const o=e.slice(8);if(e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!(await checkPermission(t,"fs."+e+"w",!1))[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e),o=mounts[t];return!!o&&(o.mkdir?.(e.slice(9+t.length),n)??!1)}return invokeSys(sysId$4,"cg-fs-mkdir",o,n)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const e=getOrigin(t);return!!e&&mkdir(t,e.current+o,n)}return!1}async function rmdir(t,e){"string"!=typeof t&&(t=t.taskId);const n=(e=urlResolve("/",e)).slice(8);if(e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!(await checkPermission(t,"fs."+e+"w",!1))[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e),n=mounts[t];return!!n&&(n.rmdir?.(e.slice(9+t.length))??!1)}return invokeSys(sysId$4,"cg-fs-rmdir",n)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const e=getOrigin(t);return!!e&&rmdir(t,e.current+n)}return!1}async function rmdirDeep(t,e){"string"!=typeof t&&(t=t.taskId),(e=urlResolve("/",e)).endsWith("/")||(e+="/");const n=await readDir(t,e);for(const o of n){const n=await stats(t,e+o.name);if(!n)return!1;if(n.isDirectory()){if(!await rmdirDeep(t,e+o.name))return!1}else{if(!await unlink(t,e+o.name))return!1}}return rmdir(t,e)}async function chmod(t,e,n){"string"!=typeof t&&(t=t.taskId);const o=(e=urlResolve("/",e)).slice(8);if(e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!(await checkPermission(t,"fs."+e+"w",!1))[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e),o=mounts[t];return!!o&&(o.chmod?.(e.slice(9+t.length),n)??!1)}return invokeSys(sysId$4,"cg-fs-chmod",o,n)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const e=getOrigin(t);return!!e&&chmod(t,e.current+o,n)}return!1}async function rename(t,e,n){if("string"!=typeof t&&(t=t.taskId),e=urlResolve("/",e),n=urlResolve("/",n),!e.startsWith(n.slice(0,9)))return!1;const o=e.slice(8),r=n.slice(8);if(e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){let s=await checkPermission(t,"fs."+e+"w",!1);if(!s[0])return!1;if(s=await checkPermission(t,"fs."+n+"w",!1,void 0),!s[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e);if(t!==getMountName(n))return!1;const o=mounts[t];return!!o&&(o.rename?.(e.slice(9+t.length),n.slice(9+t.length))??!1)}return invokeSys(sysId$4,"cg-fs-rename",o,r)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const e=getOrigin(t);return!!e&&rename(t,e.current+o,e.current+r)}return!1}async function readDir(t,e,n){if("string"!=typeof t&&(t=t.taskId),"/"===(e=urlResolve("/",e))){return[{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},name:"clickgo"},{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},name:"storage"},{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},name:"mounted"},{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},name:"package"},{isFile:function(){return!1},isDirectory:function(){return!1},isSymbolicLink:function(){return!0},name:"current"}]}e.endsWith("/")||(e+="/");const o=e.slice(8);if(e.startsWith("/clickgo/")){const t=[];for(const e of clickgoFiles){if(!e.startsWith(o))continue;if(o===e)continue;const n=e.slice(o.length);if(n.includes("/")){if(n.endsWith("/")){if(n.slice(0,-1).includes("/"))continue;t.push({isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},name:n.slice(0,-1)})}}else t.push({isFile:function(){return!0},isDirectory:function(){return!1},isSymbolicLink:function(){return!1},name:n})}return t}if(e.startsWith("/storage/")||e.startsWith("/mounted/")){const r=[];if("/mounted/"===e){for(const t in mounts)r.push({isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},name:t});return r}if(!(await checkPermission(t,"fs."+e+"r",!1))[0])return[];if(e.startsWith("/mounted/")){const t=getMountName(e),o=mounts[t];return o?o.readDir?.(e.slice(9+t.length),n)??[]:[]}const s=await invokeSys(sysId$4,"cg-fs-readDir",o,n);for(const t of s)r.push({isFile:function(){return t.isFile},isDirectory:function(){return t.isDirectory},isSymbolicLink:function(){return t.isSymbolicLink},name:t.name});return r}if(e.startsWith("/package/")||e.startsWith("/current/")){const r=getOrigin(t);if(!r)return[];if(e.startsWith("/current/"))return readDir(t,r.current+o,n);const s=[],i=[];for(const t in r.app.files){if(!t.startsWith(o))continue;const e=t.slice(o.length),n=e.indexOf("/");if(-1!==n){const t=e.slice(0,n);i.includes(t)||(i.push(t),s.push({isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},name:t}));continue}s.push({isFile:function(){return!0},isDirectory:function(){return!1},isSymbolicLink:function(){return!1},name:e})}return s}return[]}async function copyFolder(t,e,n,o=[]){"string"!=typeof t&&(t=t.taskId);let r=0;if(!await isDir(t,e))return 0;const s=await readDir(t,e);let i=!1;for(const a of s)if(a.isDirectory()){const s=await copyFolder(t,e+a.name+"/",n+a.name+"/",o);if(-1===s)return s;r+=s}else if(a.isFile()){if(o.length>0&&match(a.name,o))continue;if(!i){if(!await mkdir(t,n))return-1;i=!0}if(!await copyFile(t,e+a.name,n+a.name))continue;++r}return r}async function copyFile(t,e,n){if("string"!=typeof t&&(t=t.taskId),e=urlResolve("/",e),n=urlResolve("/",n),!e.startsWith(n.slice(0,9)))return!1;const o=e.slice(8),r=n.slice(8);if(e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||n.startsWith("/mounted/")){let s=await checkPermission(t,"fs."+e+"r",!1);if(!s[0])return!1;if(s=await checkPermission(t,"fs."+n+"w",!1),!s[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e);if(t!==getMountName(n))return!1;const o=mounts[t];return!!o&&(o.copyFile?.(e.slice(9+t.length),n.slice(9+t.length))??!1)}return invokeSys(sysId$4,"cg-fs-copyFile",o,r)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const e=getOrigin(t);return!!e&©File(t,e.current+o,e.current+r)}return!1}var fs=Object.freeze({__proto__:null,chmod:chmod,copyFile:copyFile,copyFolder:copyFolder,getContent:getContent,initSysId:initSysId$3,isDir:isDir,isFile:isFile,mkdir:mkdir,mount:mount,putContent:putContent,readDir:readDir,readLink:readLink,rename:rename,rmdir:rmdir,rmdirDeep:rmdirDeep,stats:stats,symlink:symlink,unlink:unlink,unmount:unmount});let sysId$3="";function initSysId$2(t){sysId$3||(sysId$3=t)}const configOrigin={locale:"en","task.position":"bottom","task.pin":{},"desktop.icon.storage":!0,"desktop.icon.recycler":!0,"desktop.wallpaper":null,"desktop.path":null,"launcher.list":[]};let config,boot;class AbstractApp{filename="";taskId="";async run(t){await t.show()}onError(){}onScreenResize(){}onConfigChanged(){}onFormCreated(){}onFormRemoved(){}onFormTitleChanged(){}onFormIconChanged(){}onFormStateMinChanged(){}onFormStateMaxChanged(){}onFormShowChanged(){}onFormFocused(){}onFormBlurred(){}onFormFlash(){}onFormShowInSystemTaskChange(){}onFormHashChange(){}onTaskStarted(){}onTaskEnded(){}onLauncherFolderNameChanged(){}onHashChanged(){}onKeydown(){}onKeyup(){}}function setBoot(t){boot||(t.setSysId(sysId$3),boot=t)}const globalEvents={screenResize:function(){refreshMaxPosition()},formRemoved:function(t,e){simpleSystemTaskRoot.forms[e]&&delete simpleSystemTaskRoot.forms[e]},formTitleChanged:function(t,e,n){simpleSystemTaskRoot.forms[e]&&(simpleSystemTaskRoot.forms[e].title=n)},formIconChanged:function(t,e,n){simpleSystemTaskRoot.forms[e]&&(simpleSystemTaskRoot.forms[e].icon=n)},formStateMinChanged:function(t,e,n){if(!systemTaskInfo.taskId)if(n){const t=get$3(e);if(!t)return;simpleSystemTaskRoot.forms[e]={title:t.title,icon:t.icon}}else{if(!simpleSystemTaskRoot.forms[e])return;delete simpleSystemTaskRoot.forms[e]}}};async function trigger(t,e="",n="",o="",r="",s=!0){const i=await getOriginList(sysId$3),a="on"+t[0].toUpperCase()+t.slice(1);switch(t){case"error":boot?.[a](e,n,o,r);for(const t in i){const s=i[t],c=getRuntime(sysId$3,t);if(!e||e===t||c?.permissions.includes("root")){s.class?.[a](e,n,o,r);for(const t in s.forms)s.forms[t].vroot[a]?.(e,n,o,r)}}break;case"screenResize":globalEvents.screenResize(),boot?.[a]();for(const t in i){const e=i[t];e.class?.[a]();for(const t in e.forms)e.forms[t].vroot[a]?.()}break;case"configChanged":boot?.[a]();for(const t in i){const o=i[t];o.class?.[a](e,n);for(const t in o.forms)o.forms[t].vroot[a]?.(e,n)}break;case"formCreated":case"formRemoved":globalEvents[t]?.(e,n,o,r,s),boot?.[a](e,n,o,r,s);for(const t in i){const c=i[t],l=getRuntime(sysId$3,t);if(e===t||l?.permissions.includes("root")){c.class?.[a](e,n,o,r,s);for(const t in c.forms)c.forms[t].vroot[a]?.(e,n,o,r,s)}}break;case"formTitleChanged":case"formIconChanged":globalEvents[t]?.(e,n,o),boot?.[a](e,n,o);for(const t in i){const r=i[t],s=getRuntime(sysId$3,t);if(e===t||s?.permissions.includes("root")){r.class?.[a](e,n,o);for(const t in r.forms)r.forms[t].vroot[a]?.(e,n,o)}}break;case"formStateMinChanged":case"formStateMaxChanged":case"formShowChanged":globalEvents[t]?.(e,n,o),boot?.[a](e,n,o);for(const t in i){const r=i[t],s=getRuntime(sysId$3,t);if(e===t||s?.permissions.includes("root")){r.class?.[a](e,n,o);for(const t in r.forms)r.forms[t].vroot[a]?.(e,n,o)}}break;case"formFocused":case"formBlurred":case"formFlash":globalEvents[t]?.(e,n),boot?.[a](e,n);for(const t in i){const o=i[t],r=getRuntime(sysId$3,t);if(e===t||r?.permissions.includes("root")){o.class?.[a](e,n);for(const t in o.forms)o.forms[t].vroot[a]?.(e,n)}}break;case"formShowInSystemTaskChange":globalEvents[t]?.(e,n,o),boot?.[a](e,n,o);for(const t in i){const r=i[t],s=getRuntime(sysId$3,t);if(e===t||s?.permissions.includes("root")){r.class?.[a](e,n,o);for(const t in r.forms)r.forms[t].vroot[a]?.(e,n,o)}}break;case"formHashChange":globalEvents[t]?.(e,n,o,r),boot?.[a](e,n,o,r);for(const t in i){const s=i[t],c=getRuntime(sysId$3,t);if(e===t||c?.permissions.includes("root")){s.class?.[a](e,n,o,r);for(const t in s.forms)s.forms[t].vroot[a]?.(e,n,o,r)}}break;case"taskStarted":case"taskEnded":globalEvents[t]?.(e,n),boot?.[a](e,n);for(const t in i){const n=i[t],o=getRuntime(sysId$3,t);if(e===t||o?.permissions.includes("root")){n.class?.[a](e);for(const t in n.forms)n.forms[t].vroot[a]?.(e)}}break;case"launcherFolderNameChanged":boot?.[a](e,n);for(const t in i){const o=i[t];o.class?.[a](e,n);for(const t in o.forms)o.forms[t].vroot[a]?.(e,n)}break;case"hashChanged":boot?.[a](e);for(const t in i){const n=i[t];n.class?.[a](e);for(const t in n.forms)n.forms[t].vroot[a]?.(e)}break;case"keydown":case"keyup":globalEvents[t]?.(e),boot?.[a](e);for(const t in i){const n=i[t];n.class?.[a](e);for(const t in n.forms)n.forms[t].vroot[a]?.(e)}}}async function readApp(t){if("-CGA-"!==await blob2Text(t.slice(0,5)))return!1;const e=parseInt(await t.slice(21,28).text());if(Number.isNaN(e))return!1;const n=e?await blob2DataUrl(t.slice(28,28+e)):"",o=new Blob([t.slice(5,21),t.slice(28+e)],{type:t.type}),r=await get$2(o);if(!r)return!1;const s={},i=await r.getContent("/config.json");if(!i)return!1;const a=JSON.parse(i),c=r.readDir("/",{hasChildren:!0});for(const t of c){const e=getMimeByPath(t.name);if(["txt","json","js","css","xml","html"].includes(e.ext)){const e=await r.getContent(t.path+t.name,"string");if(!e)continue;s[t.path+t.name]=e.replace(/^\ufeff/,"")}else{const n=await r.getContent(t.path+t.name,"arraybuffer");if(!n)continue;s[t.path+t.name]=new Blob([n],{type:e.mime})}}return{type:"app",config:a,files:s,icon:n}}async function fetchApp(t,e,n={}){const o=n.notify?"number"==typeof n.notify?{id:n.notify,loaded:0,total:0}:n.notify:{id:void 0,loaded:0,total:0},r=o.id,s=o.loaded??0,i=o.total??0;if(!e.endsWith(".cga"))return null;e.startsWith("/clickgo/")||e.startsWith("/storage/")||e.startsWith("/mounted/")||e.startsWith("/package/")||e.startsWith("/current/")||e.startsWith("http:")||e.startsWith("https:")||e.startsWith("file:")||(e=urlResolve(window.location.href,e));try{const o=await getContent(t,e,{progress:(t,e)=>{let o=t/e;o=i?Math.min(s/i+1/i*o,1):o,r&¬ifyProgress(r,o),n.progress&&n.progress(t,e,o)},after:n.after});return null===o||"string"==typeof o?null:(r&¬ifyProgress(r,i?(s+1)/i:1),await readApp(o)||null)}catch{return null}}function getAvailArea(){if(Object.keys(simpleSystemTaskRoot.forms).length>0)return{left:0,top:0,width:window.innerWidth,height:window.innerHeight-46,owidth:window.innerWidth,oheight:window.innerHeight};{let t=0,e=0,n=0,o=0;switch(config["task.position"]){case"left":t=systemTaskInfo.length,e=0,n=window.innerWidth-systemTaskInfo.length,o=window.innerHeight;break;case"right":t=0,e=0,n=window.innerWidth-systemTaskInfo.length,o=window.innerHeight;break;case"top":t=0,e=systemTaskInfo.length,n=window.innerWidth,o=window.innerHeight-systemTaskInfo.length;break;case"bottom":t=0,e=0,n=window.innerWidth,o=window.innerHeight-systemTaskInfo.length}return{left:t,top:e,width:n,height:o,owidth:window.innerWidth,oheight:window.innerHeight}}}async function hash(t,e){"string"!=typeof t&&(t=t.taskId);return!!(await checkPermission(t,"hash"))[0]&&(window.location.hash=e,!0)}function getHash(){return window.location.hash?decodeURIComponent(window.location.hash.slice(1)):""}function getHost(){const t=/https?:\/\/([-a-zA-Z0-9:.]+)/.exec(window.location.href);return t?t[1]:""}async function location$1(t,e){"string"!=typeof t&&(t=t.taskId);return!!(await checkPermission(t,"location"))[0]&&(window.location.href=e,!0)}function getLocation(){return window.location.href}async function back(t){"string"!=typeof t&&(t=t.taskId);return!!(await checkPermission(t,"location"))[0]&&(window.history.back(),!0)}function open(t){window.open(t)}window.addEventListener("hashchange",function(){trigger("hashChanged",window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"").catch(()=>{})});const modules$1={"monaco-editor":{func:async function(){return new Promise(t=>{fetch(getCdn()+"/npm/monaco-editor@0.52.2/min/vs/loader.js").then(t=>t.blob()).then(t=>blob2DataUrl(t)).then(e=>{t(e)}).catch(()=>{t(null)})})},loading:!1,resolve:[]},xterm:{func:async function(){if(await loadScripts([`${getCdn()}/npm/xterm@5.3.0/lib/xterm.js`,`${getCdn()}/npm/xterm-addon-fit@0.8.0/lib/xterm-addon-fit.js`,`${getCdn()}/npm/xterm-addon-webgl@0.16.0/lib/xterm-addon-webgl.js`]),!window.Terminal)throw Error("Xterm load failed.");return await loadLinks([`${getCdn()}/npm/xterm@5.3.0/css/xterm.min.css`]),loadStyle(".xterm-viewport::-webkit-scrollbar{display:none;}"),{Terminal:window.Terminal,FitAddon:window.FitAddon.FitAddon,WebglAddon:window.WebglAddon.WebglAddon}},loading:!1,resolve:[]},echarts:{func:async function(){if(await loadScript(`${getCdn()}/npm/echarts@6.0.0/dist/echarts.min.js`),!window.echarts)throw Error("Echarts load failed.");return window.echarts},loading:!1,resolve:[]},"@toast-ui/editor":{func:async function(){if(await loadScripts([urlResolve(getDirname()+"/","./ext/toastui-editor-all.min.js")]),!window.toastui.Editor)throw Error("Tuieditor load failed.");return await loadScripts([`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/zh-cn.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/zh-tw.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/ja-jp.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/ko-kr.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/es-es.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/de-de.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/fr-fr.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/pt-br.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/ru-ru.min.js`]),await loadLinks([`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/toastui-editor.min.css`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/theme/toastui-editor-dark.css`]),loadStyle(".toastui-editor-defaultUI-toolbar,.ProseMirror{box-sizing:initial !important}.toastui-editor-main{background:var(--g-plain-background);border-radius:0 0 3px 3px}.ProseMirror{cursor:text}.jodit ::-webkit-scrollbar{width:6px;cursor:default;}.jodit ::-webkit-scrollbar-thumb{background:rgba(0,0,0,.1);border-radius:3px;}.jodit ::-webkit-scrollbar-thumb:hover{background: rgba(0,0,0,.2);}"),window.toastui},loading:!1,resolve:[]},jodit:{func:async function(){return await loadScripts([`${getCdn()}/npm/jodit@4.2.27/es2015/jodit.fat.min.js`]),await loadLinks([`${getCdn()}/npm/jodit@4.2.27/es2015/jodit.fat.min.css`]),loadStyle(".jodit-container:not(.jodit_inline){border:none;display:flex;flex-direction:column;}.jodit-container:not(.jodit_inline) .jodit-workplace{cursor:text;flex:1;}.jodit-wysiwyg a{color:unset;}"),window.Jodit},loading:!1,resolve:[]},fabric:{func:async function(){if(await loadScripts([`${getCdn()}/npm/fabric@7.2.0/dist/index.min.js`]),!window.fabric)throw Error("fabric load failed.");return window.fabric},loading:!1,resolve:[]},pdfjs:{func:async function(){try{const t=await import(`${getCdn()}/npm/pdfjs-dist@5.4.54/+esm`);return t.GlobalWorkerOptions.workerSrc=`${getCdn()}/npm/pdfjs-dist@5.4.54/build/pdf.worker.min.mjs`,t}catch{throw Error("pdf.js load failed.")}},loading:!1,resolve:[]},qrcode:{func:async function(){if(await loadScripts([`${getCdn()}/npm/qrcode@1.5.1/build/qrcode.js`]),!window.QRCode)throw Error("QRCode load failed.");return window.QRCode},loading:!1,resolve:[]},mpegts:{func:async function(){if(await loadScripts([`${getCdn()}/npm/mpegts.js@1.7.3/dist/mpegts.min.js`]),!window.mpegts)throw Error("mpegts load failed.");return window.mpegts.LoggingControl.enableAll=!1,window.mpegts},loading:!1,resolve:[]},tplinkhd:{func:async function(){if(await loadScripts([`${getDirname()}/ext/tplinkhd.min.js`]),!window.HDPluginControl)throw Error("Tplink load failed.");return window.HDPluginControl},loading:!1,resolve:[]},"tums-player":{func:async function(){if(await loadScripts([`${getDirname()}/ext/tums-player/tums-player.umd.min.js`]),!window["tums-player"])throw Error("Tums load failed.");const t=document.createElement("div");t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.width="200px",t.style.height="100px",document.body.appendChild(t);const e=window["tums-player"].default;let n=null;return{default:e,startTalk:o=>new Promise(r=>{n&&(n.stopVoiceIntercom(),n.destroy(),n=null),n=new e(t,{type:"relay",url:"none",pluginPath:getDirname()+"/ext",talkEnable:!0,appKey:o.sid,appSecret:o.skey}),n.on("ready",()=>{n.startVoiceIntercom({url:o.url,mode:o.mode}),r()})}),stopTalk:()=>{n&&(n.stopVoiceIntercom(),n.destroy(),n=null)}}},loading:!1,resolve:[]},tjcaptcha:{func:async function(){if(await loadScripts(["https://turing.captcha.qcloud.com/TJCaptcha.js"]),!window.TencentCaptcha)throw Error("TJCaptcha load failed.");return window.TencentCaptcha},loading:!1,resolve:[]},turnstile:{func:async function(){if(await loadScripts(["https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit"]),!window.turnstile)throw Error("cft load failed.");return window.turnstile},loading:!1,resolve:[]},"@novnc/novnc":{version:"1.6.0",loading:!1,resolve:[]},marked:{func:async function(){if(await loadScripts([`${getCdn()}/npm/marked@17.0.0/lib/marked.umd.min.js`]),!window.marked)throw Error("marked load failed.");return window.marked},loading:!1,resolve:[]},"pdf-lib":{func:async function(){if(await loadScripts([`${getCdn()}/npm/pdf-lib@1.17.1/dist/pdf-lib.min.js`]),!window.PDFLib)throw Error("pdf-lib load failed.");return window.PDFLib},loading:!1,resolve:[]}};async function regModule(t,e,n){return!!(await checkPermission(t,"root"))[0]&&(!modules$1[e]&&(!modules[e]&&(modules$1[e]={version:n.version,func:n.func,loading:!1,resolve:[]},!0)))}function checkModule(t){return void 0!==modules$1[t]}async function getModule(t){return await loadModule(t)?modules[t]:null}async function loadModule(t){if(!modules$1[t])return!1;if(modules[t])return!0;try{if(modules$1[t].loading)return await new Promise(e=>{modules$1[t].resolve.push(()=>{e()})}),!0;if(modules$1[t].loading=!0,modules$1[t].version){const e=await import(`${getCdn()}/npm/${t}@${modules$1[t].version}/+esm`);modules[t]=e}if(modules$1[t].func){const e=await modules$1[t].func();modules[t]=e}modules$1[t].loading=!1;for(const e of modules$1[t].resolve)e();return modules$1[t].resolve.length=0,!0}catch{return!1}}let inited=!1;function init$1(){inited||(inited=!0,config=modules.vue.reactive({locale:lang.getCodeByAccept(),"task.position":"bottom","task.pin":{},"desktop.icon.storage":!0,"desktop.icon.recycler":!0,"desktop.wallpaper":null,"desktop.path":null,"launcher.list":[]}),modules.vue.watch(config,async function(){for(const t in configOrigin)void 0===config[t]&&(notify({title:"Warning",content:"There is a software that maliciously removed the system config item.\nKey: "+t,type:"warning"}),config[t]=configOrigin[t]);for(const t in config)if(Object.keys(configOrigin).includes(t))if("task.pin"===t){if(Object.keys(config["task.pin"]).sort().toString()===Object.keys(configOrigin["task.pin"]).sort().toString())continue;configOrigin["task.pin"]={};for(const t in config["task.pin"])configOrigin["task.pin"][t]=config["task.pin"][t];await trigger("configChanged","task.pin",config["task.pin"])}else{if(config[t]===configOrigin[t])continue;configOrigin[t]=config[t],"task.position"===t&&refreshSystemPosition(),await trigger("configChanged",t,config[t])}else notify({title:"Warning",content:"There is a software that maliciously modifies the system config.\nKey: "+t,type:"warning"}),delete config[t]},{deep:!0}),window.addEventListener("resize",function(){refreshSystemPosition()}))}var core=Object.freeze({__proto__:null,AbstractApp:AbstractApp,back:back,checkModule:checkModule,get config(){return config},fetchApp:fetchApp,getAvailArea:getAvailArea,getHash:getHash,getHost:getHost,getLocation:getLocation,getModule:getModule,hash:hash,init:init$1,initSysId:initSysId$2,loadModule:loadModule,location:location$1,open:open,readApp:readApp,regModule:regModule,setBoot:setBoot,trigger:trigger});let sysId$2="";function initSysId$1(t){sysId$2||(sysId$2=t)}class AbstractControl{get filename(){return""}get findex(){return 0}get controlName(){return""}get taskId(){return""}get formId(){return""}get path(){return""}get prep(){return""}get element(){return this.$el}_rootForm=null;get rootForm(){return this._rootForm||(this._rootForm=this.parentByName("root"),this._rootForm||notify({title:"Error",content:`The "rootForm" is not ready yet.\nFile: "${this.controlName}".`,type:"danger"})),this._rootForm}_rootControl=null;get rootControl(){return this._rootControl}get formFocus(){return this.rootForm?.formFocus??!1}get locale(){const t=getOrigin(this.taskId);return logicalOr(t?.locale.lang??"",config.locale)}get l(){return(t,e)=>{const n=this.localeData?.[this.locale][t]??"[LocaleError]"+t;if(!e)return n;let o=-1;return n.replace(/\?/g,function(){return++o,e[o]?e[o]:""})}}get fl(){return(t,e)=>t.startsWith("l:")?this.rootForm.l(t.slice(2),e,!0):t}get classPrepend(){return t=>"string"!=typeof t?t:t.startsWith("fa-")?`${t}`:`cg-theme-task${this.taskId}-${this.controlName}_${t}${this.prep?" "+this.prep+t:""}`}get alignHComp(){if(this.props.alignH){switch(this.props.alignH){case"center":return"center";case"left":case"start":return"flex-start"}return"flex-end"}}get alignVComp(){if(this.props.alignV){switch(this.props.alignV){case"center":return"center";case"top":case"start":return"flex-start"}return"flex-end"}}watch(t,e,n={}){return this.$watch(t,e,n)}get refs(){return this.$refs}get nextTick(){return this.$nextTick}allowEvent(t){return modules.pointer.allowEvent(t)}async trigger(t,e="",n=""){["formTitleChanged","formIconChanged","formStateMinChanged","formStateMaxChanged","formShowChanged"].includes(t)&&await trigger(t,this.taskId,this.formId,e,n)}packageFiles={};props={};emits={};slots={};get slotsAll(){return t=>{if(!this.slots[t])return[];const e=this.slots[t](),n=[];for(const t of e)if(t.props)n.push(t);else if("string"!=typeof t.children&&t.children.length)for(const e of t.children)n.push(e);return n}}get propBoolean(){return t=>getBoolean(this.props[t])}get propNumber(){return t=>getNumber(this.props[t])}get propInt(){return t=>Math.round(this.propNumber(t))}get propArray(){return t=>getArray(this.props[t])}emit(t,...e){this.$emit(t,...e)}get parent(){return this.$parent}get parentByName(){return t=>{let e=this.$parent;for(;;){if(!e)return null;if(e.controlName===t)return e;e=e.$parent}}}get parentByAccess(){return(t,e)=>{let n=this.$parent;for(;;){if(!n)return null;if(n.access){if(n.access[t]===e)return n;n=n.$parent}else n=n.$parent}}}onBeforeCreate(){}onCreated(){}onBeforeMount(){}onMounted(){}onBeforeUpdate(){}onUpdated(){}onBeforeUnmount(){}onUnmounted(){}}async function read(t){const e=await get$2(t);if(!e)return!1;const n={},o=e.readDir("/");for(const t of o){if(t.isFile)continue;const o=await e.getContent("/"+t.name+"/config.json");if(!o){notify({title:"Error",content:`Control file not found.\nFile: "${"/"+t.name+"/config.json"}".`,type:"danger"});continue}const r=JSON.parse(o);n[r.name]={type:"control",config:r,files:{}};const s=e.readDir("/"+t.name+"/",{hasChildren:!0});for(const t of s){const o=t.path.slice(r.name.length+1),s=getMimeByPath(t.name);if(["txt","json","js","css","xml","html"].includes(s.ext)){const s=await e.getContent(t.path+t.name,"string");if(!s)continue;n[r.name].files[o+t.name]=s.replace(/^\ufeff/,"")}else{const i=await e.getContent(t.path+t.name,"arraybuffer");if(!i)continue;n[r.name].files[o+t.name]=new Blob([i],{type:s.mime})}}}return n}async function init(t,e={}){const n=getOrigin(t);if(!n)return-1;let o=0;for(let r of n.app.config.controls){r.endsWith(".cgc")||(r+=".cgc"),r=urlResolve("/",r);const s=await getContent(t,r);if(s&&"string"!=typeof s){const e=await read(s);if(!e)return notify({title:"Error",content:"Control failed to load.\nTask id: "+n.id.toString()+"\nPath: "+r,type:"danger"}),-5;for(const o in e){const s=e[o];let i="";if(n.controls[o]={layout:"",files:s.files,config:s.config,props:{},emits:{},data:{},access:{},methods:{},computed:{}},n.controls[o].layout=s.files[s.config.layout+".html"],void 0===n.controls[o].layout)return-2;n.controls[o].layout=n.controls[o].layout.replace(/^(<[a-zA-Z0-9-]+)( |>)/,'$1 data-cg-control="'+o+'"$2');const a=s.files[s.config.style+".css"];if(a){const t=stylePrepend(a);i=t.prep,pushStyle(n.id,await styleUrl2DataUrl(s.config.style,t.style,s.files),"control",o)}const c=["cg-theme-task"+n.id.toString()+"-"+o+"_"];let l;if(""!==i&&c.push(i),n.controls[o].layout=layoutAddTagClassAndReTagName(n.controls[o].layout,!1),n.controls[o].layout=layoutClassPrepend(n.controls[o].layout,c),n.controls[o].layout.includes("<cg-")&&(n.controls[o].layout=layoutInsertAttr(n.controls[o].layout,":form-focus='formFocus'",{include:[/^cg-.+/]})),n.controls[o].layout=eventsAttrWrap(n.controls[o].layout),n.controls[o].layout.includes("<teleport")&&(n.controls[o].layout=teleportGlue(n.controls[o].layout,"{{{formId}}}")),n.controls[o].access.cgPCMap=random(8,RANDOM_LUNS,'"<>$'),n.controls[o].layout=n.controls[o].layout.replace(/(<cg-[a-zA-Z0-9-_]+)/g,`$1 data-cg-rootcontrol="${n.controls[o].access.cgPCMap}"`),s.files[s.config.code+".js"]){const e=s.files[s.config.code+".js"];if("string"!=typeof e)return-3;let n=!0;if(stateMachine(e,0,t=>t.state!==ESTATE.WORD||(!["eval","Function"].includes(t.word)||(notify({title:"Error",content:`The "${t.word}" is prohibited.\nFile: "${r}".`,type:"danger"}),n=!1,!1))),!n)return-6;if(s.config.modules?.length)for(const t of s.config.modules)if(!modules[t]&&checkModule(t)&&!await loadModule(t))return-4;const i=runIife(e);if(!i){const e='"default" not found on "'+s.config.code+'" of "'+o+'" control.';return await trigger("error",t,"",new Error(e),e),-7}l=new i}else l=new class extends AbstractControl{get filename(){return s.config.layout+".js"}};if(l.props)for(const t in l.props)n.controls[o].props[t]={default:l.props[t]};if(l.emits)for(const t in l.emits)n.controls[o].emits[t]=l.emits[t];const d=Object.entries(l);for(const t of d)"files"!==t[0]&&("access"!==t[0]?n.controls[o].data[t[0]]=t[1]:n.controls[o].access=t[1]);const f=getClassPrototype(l);n.controls[o].methods=f.method,Object.assign(n.controls[o].computed,f.access),n.controls[o].computed.controlName={get:function(){return o},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "controlName".\nControl: ${o}`,type:"danger"})}},n.controls[o].computed.taskId={get:function(){return t},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "taskId".\nControl: ${o}`,type:"danger"})}},n.controls[o].computed.prep={get:function(){return i},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "prep".\nControl: ${o}`,type:"danger"})}}}}e.progress?.(++o,n.app.config.controls.length,r)}return 1}function buildComponents(t,e,n){const o=getOrigin(t);if(!o)return!1;const r={};for(const t in o.controls){const s=o.controls[t],i=Object.assign({},s.computed);i.findex={get:function(){return o.forms[e].vroot.findex},set:function(){notify({title:"Error",content:`The control tries to modify the system variable "findex".\nControl: ${t}`,type:"danger"})}},i.formId={get:function(){return e},set:function(){notify({title:"Error",content:`The control tries to modify the system variable "formId".\nControl: ${t}`,type:"danger"})}},i.path={get:function(){return n},set:function(){notify({title:"Error",content:`The control tries to modify the system variable "path".\nControl: ${t}`,type:"danger"})}},r["cg-"+t]={template:s.layout.replace(/{{{formId}}}/g,e.toString()).replaceAll('@click="','@tap="'),props:s.props,emits:s.emits,data:function(){const t=clone(s.data);return t.props&&delete t.props,t.emits&&delete t.emits,t},methods:s.methods,computed:i,beforeCreate:s.methods.onBeforeCreate,created:function(){this.props=this.$props,this.slots=this.$slots,this.access=clone(s.access),this.packageFiles={};for(const t in s.files)this.packageFiles[t]=s.files[t];this.onCreated()},beforeMount:function(){this.onBeforeMount()},mounted:async function(){if(void 0!==this.element.dataset?.cgRootcontrol){const t=this.parentByAccess("cgPCMap",this.element.dataset.cgRootcontrol);t&&(this._rootControl=t)}await this.$nextTick(),this.onMounted()},beforeUpdate:function(){this.onBeforeUpdate()},updated:async function(){await this.$nextTick(),this.onUpdated()},beforeUnmount:function(){this.onBeforeUnmount()},unmounted:async function(){await this.$nextTick(),this.onUnmounted()}}}return r}var control=Object.freeze({__proto__:null,AbstractControl:AbstractControl,buildComponents:buildComponents,init:init,initSysId:initSysId$1,read:read});let sysId$1="";function initSysId(t){sysId$1||(sysId$1=t)}const localeData={en:{"sure-clear":'Are you sure you want to clear all temporary storage for the app "?"?'},sc:{"sure-clear":"确定清除应用“?”的所有临时存储吗?"},tc:{"sure-clear":"確定清除應用程式「?」的所有臨時儲存嗎?"},ja:{"sure-clear":"アプリ「?」の一時的な保存データをすべて削除しますか?"},ko:{"sure-clear":'"?" 앱의 모든 임시 저장소를 지우시겠습니까?'},th:{"sure-clear":'คุณแน่ใจหรือไม่ที่ต้องการล้างพื้นที่จัดเก็บชั่วคราวของแอป "?" ทั้งหมดหรือไม่?'},es:{"sure-clear":'¿Estás seguro de que quieres borrar todo el almacenamiento temporal de la aplicación "?"?'},de:{"sure-clear":'Möchten Sie wirklich alle temporären Speicher für die App "?" löschen?'},fr:{"sure-clear":'Êtes-vous sûr de vouloir effacer tous les stockages temporaires de l\'application "?" ?'},pt:{"sure-clear":'Tem a certeza de que pretende limpar todo o armazenamento temporário da aplicação "?"?'},ru:{"sure-clear":'Вы уверены, что хотите очистить все временные хранилища для приложения "?"?'},vi:{"sure-clear":'Bạn có chắc chắn muốn xóa tất cả lưu trữ tạm thời cho ứng dụng "?" không?'}},textEncoder=new TextEncoder;function get(t,e){"string"!=typeof t&&(t=t.taskId);const n=getOrigin(t);if(!n)return null;const o=localStorage.getItem("clickgo-item-"+n.path+"-"+e);if(null===o)return null;try{return JSON.parse(o)}catch{return null}}function set(t,e,n){"string"!=typeof t&&(t=t.taskId);const o=getOrigin(t);if(!o)return!1;if(void 0===n)return!1;const r=JSON.stringify(n),s=textEncoder.encode(r).length,i=localStorage.getItem("clickgo-size-"+o.path);if(null===i){if(s>1048576)return!1;localStorage.setItem("clickgo-size-"+o.path,JSON.stringify({[e]:s}))}else{const t=JSON.parse(i);t[e]=s;if(Object.values(t).reduce((t,e)=>t+e,0)>1048576)return!1;localStorage.setItem("clickgo-size-"+o.path,JSON.stringify(t))}return localStorage.setItem("clickgo-item-"+o.path+"-"+e,r),!0}function remove(t,e){"string"!=typeof t&&(t=t.taskId);const n=getOrigin(t);if(!n)return!1;const o=localStorage.getItem("clickgo-size-"+n.path);if(null===o)return!0;const r=JSON.parse(o);return void 0===r[e]||(delete r[e],Object.keys(r).length?localStorage.setItem("clickgo-size-"+n.path,JSON.stringify(r)):localStorage.removeItem("clickgo-size-"+n.path),localStorage.removeItem("clickgo-item-"+n.path+"-"+e)),!0}function list(t){"string"!=typeof t&&(t=t.taskId);const e=getOrigin(t);if(!e)return{};const n=localStorage.getItem("clickgo-size-"+e.path);return null===n?{}:JSON.parse(n)}function all(){const t={};for(let e=0;e<localStorage.length;e++){const n=localStorage.key(e);if(!n?.startsWith("clickgo-size-"))continue;const o=localStorage.getItem(n);if(!o)continue;const r=JSON.parse(o),s=Object.values(r).reduce((t,e)=>t+e,0);t[n.slice(13)]=s}return t}async function clear(t){if(!t)return 0;const e=localeData[config.locale]?.["sure-clear"]??localeData.en["sure-clear"];if(!await superConfirm(sysId$1,e.replace("?",escapeHTML(t))))return 0;let n=0;localStorage.removeItem("clickgo-size-"+t);const o="clickgo-item-"+t+"-";for(let t=0;t<localStorage.length;t++){const e=localStorage.key(t);e?.startsWith(o)&&(localStorage.removeItem(e),++n)}return n}var storage=Object.freeze({__proto__:null,all:all,clear:clear,get:get,initSysId:initSysId,list:list,remove:remove,set:set});const sysId=random(16,RANDOM_LUN);initSysId$4(sysId),initSysId$1(sysId),initSysId$2(sysId),initSysId$6(sysId),initSysId$7(sysId),initSysId$3(sysId),initSysId(sysId),initSysId$5(sysId),initSysId$8(sysId);const modules={clickgo:clickgo},version="5.9.1";function getVersion(){return version}const native=!!navigator.userAgent.includes("electron");function isNative(){return native}const dirname=import.meta.url.slice(0,import.meta.url.lastIndexOf("/"));function getDirname(){return dirname}let platform="web",frame=!1;window.clickgo||(window.clickgo={}),window.clickgo.modules=modules;const userClickGo=window.clickgo,global=userClickGo.global??{},cdn=userClickGo.config?.cdn??"https://cdn.jsdelivr.net";function getCdn(){return cdn}if(native){const t=/electron\/(.+?) (.+?)\/(.+?) frame\/([0-9])/.exec(navigator.userAgent);t&&(platform=t[2],frame="0"!==t[4])}function getPlatform(){return platform}let device={type:"unknown",os:"unknown"};function getDevice(){if("unknown"!==device.type)return device;const t=navigator.userAgent.toLowerCase();return t.includes("android")?device.os="android":t.includes("iphone")||t.includes("ipad")||t.includes("ipod")?device.os="ios":t.includes("windows")||t.includes("win32")?device.os="windows":t.includes("mac os")||t.includes("darwin")?device.os="macos":t.includes("linux")&&(device.os="linux"),device.type=["windows","macos","linux"].includes(device.os)?"desktop":"mobile",device}function hasFrame(){return frame}class AbstractBoot{_debug=!1;_sysId="";setSysId(t){this._sysId||(this._sysId=t)}isDebug(){return this._debug}constructor(t={}){t.debug&&(this._debug=!0)}onError(){}onScreenResize(){}onConfigChanged(){}onFormCreated(){}onFormRemoved(){}onFormTitleChanged(){}onFormIconChanged(){}onFormStateMinChanged(){}onFormStateMaxChanged(){}onFormShowChanged(){}onFormFocused(){}onFormBlurred(){}onFormFlash(){}onFormShowInSystemTaskChange(){}onFormHashChange(){}onTaskStarted(){}onTaskEnded(){}onLauncherFolderNameChanged(){}onHashChanged(){}onKeydown(){}onKeyup(){}onRuntimeFileLoad(){}onRuntimeFileLoaded(){}}async function launcher(t){await loadScripts([`${cdn}/npm/vue@3.5.26/dist/vue.global${t.isDebug()?"":".prod.min"}.js`]),await loadScripts([`${cdn}/npm/jszip@3.10.1/dist/jszip.min.js`,`${cdn}/npm/@litert/pointer@1.7.3/dist/index.umd.min.js`]),await loadLinks([`${cdn}/npm/@fortawesome/fontawesome-free@7.2.0/css/all.min.css`]),modules.vue=window.Vue,modules.jszip=window.JSZip,modules.pointer=window.pointer,modules.pointer.addMoveHook("down",()=>{is.move=!0}),modules.pointer.addMoveHook("up",()=>{is.move=!1});const e=`${dirname}/global.css`;try{let t=await(await fetch(e)).text();const n=/url\(['"]?([/\w.-]+)['"]?\)/g;let o=null;for(;o=n.exec(t);)t=t.replace(o[0],`url('${urlResolve(dirname+"/",o[1])}')`);document.getElementById("cg-global")?.insertAdjacentHTML("afterbegin",t)}catch{alert(`ClickGo: "${e}" load failed.`)}init$4(),init$1(),init$3(),init$2(),init$5(),setBoot(t),window.TouchEvent||(window.TouchEvent=CustomEvent),await t.main()}export{AbstractBoot,control,core,dom,form,fs,getCdn,getDevice,getDirname,getPlatform,getVersion,global,hasFrame,isNative,launcher,modules,native$1 as native,storage,task,theme,tool,zip};
|
|
1
|
+
var clickgo=Object.freeze({__proto__:null,get AbstractBoot(){return AbstractBoot},get control(){return control},get core(){return core},get dom(){return dom},get form(){return form},get fs(){return fs},get getCdn(){return getCdn},get getDevice(){return getDevice},get getDirname(){return getDirname},get getPlatform(){return getPlatform},get getVersion(){return getVersion},get global(){return global},get hasFrame(){return hasFrame},get isNative(){return isNative},get launcher(){return launcher},get modules(){return modules},get native(){return native$1},get storage(){return storage},get task(){return task},get theme(){return theme},get tool(){return tool},get zip(){return zip}});let compressorjs=null;function runIife(t){return new Function(t+"\nreturn emodule;")()}async function compressor(t,e={}){if(!compressorjs)try{const t=window.clickgo.config?.cdn??"https://cdn.jsdelivr.net";if(await loadScript(t+"/npm/compressorjs@1.2.1/dist/compressor.min.js"),!window.Compressor)throw Error("Compressor load failed.");compressorjs=window.Compressor}catch{return!1}return new Promise(n=>{compressorjs?new compressorjs(t,{quality:e.quality,maxWidth:e.maxWidth,maxHeight:e.maxHeight,success:e=>{!(t instanceof File)||e instanceof File?n(e):n(new File([e],t.name,{lastModified:t.lastModified,type:t.type}))},error:()=>{n(!1)}}):n(!1)})}function getClassPrototype(t,e=[],n=0){if(0===n)return getClassPrototype(Object.getPrototypeOf(t),e,n+1);const o={method:{},access:{}},r=Object.getOwnPropertyNames(t);if(r.includes("toString"))return o;for(const n of r){if("constructor"===n)continue;if(e.includes(n))continue;const r=Object.getOwnPropertyDescriptor(t,n);r&&(e.push(n),r.value?o.method[n]=r.value:(r.get??r.set)&&(o.access[n]||(o.access[n]={get:r.get??(()=>{}),set:r.set??(()=>{})})))}const s=getClassPrototype(Object.getPrototypeOf(t),e,n+1);return Object.assign(o.method,s.method),Object.assign(o.access,s.access),o}function blob2ArrayBuffer(t){return new Promise(function(e){const n=new FileReader;n.addEventListener("load",function(){e(n.result)}),n.readAsArrayBuffer(t)})}function sizeFormat(t,e=" "){const n=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];let o=0;for(;o<n.length-1&&t>=1024;)t/=1024,o++;return(Math.round(100*t)/100).toString()+e+n[o]}function weightFormat(t,e=" "){let n=0;for(;n<3&&t>=1e3;++n)t/=1e3;return(Math.round(100*t)/100).toString()+e+["mg","g","kg"][n]}function clone(t){if(Array.isArray(t)){const e=[];for(let n=0;n<t.length;++n)if(t[n]instanceof Date)e[n]=new Date(t[n].getTime());else if(t[n]instanceof FormData){const o=new FormData;for(const e of t[n])o.append(e[0],e[1]);e[n]=o}else null===t[n]?e[n]=null:"object"==typeof t[n]?e[n]=clone(t[n]):e[n]=t[n];return e}const e={};for(const n in t)if(t[n]instanceof Date)e[n]=new Date(t[n].getTime());else if(t[n]instanceof FormData){const o=new FormData;for(const e of t[n])o.append(e[0],e[1]);e[n]=o}else null===t[n]?e[n]=null:"object"==typeof t[n]?e[n]=clone(t[n]):e[n]=t[n];return e}function sleep$1(t=0){return new Promise(function(e){t>3e4?e(!1):window.setTimeout(function(){e(!0)},t)})}function nextFrame(){return new Promise(function(t){requestAnimationFrame(()=>{t()})})}async function sleepFrame(t){t>10&&(t=10);for(let e=0;e<t;++e)await nextFrame()}function purify(t){const e=[];let n=-1;return(t=(t=">"+t+"<").replace(/<!--([\s\S]*?)-->/g,"").replace(/<script[\s\S]+?<\/script>/g,function(t){return e.push(t),"[SCRIPT]"}).replace(/>([\s\S]*?)</g,function(t,e){return">"+e.replace(/\t|\r\n| {2}/g,"").replace(/\n|\r/g,"")+"<"}).replace(/\[SCRIPT\]/g,function(){return++n,e[n]})).slice(1,-1)}function match(t,e){for(const n of e)if(n.test(t))return!0;return!1}async function styleUrl2DataUrl(t,e,n){const o=/url\(["']{0,1}(.+?)["']{0,1}\)/gi;let r=null;for(;r=o.exec(e);){let o=urlResolve(t,r[1]);o.startsWith("/package/")&&(o=o.slice(8)),n[o]&&("string"!=typeof n[o]&&(e=e.replace(r[0],`url('${await blob2DataUrl(n[o])}')`)))}return e}function layoutAddTagClassAndReTagName(t,e){const n=[];t=(t=t.replace(/(\S+)=(".+?"|'.+?')/g,function(t,e){return"class"===e?t:(n.push(t),'"CG-PLACEHOLDER"')})).replace(/<(\/{0,1})([\w-]+)([\s\S]*?>)/g,function(t,n,o,r){return["template","slot","teleport"].includes(o)?t:"/"===n?"block"===o?"</div"+r:e?"</cg-"+o+r:t:(r=r.toLowerCase().includes(" class")?r.replace(/ class=(["']{0,1})/i," class=$1tag-"+o+" "):` class="tag-${o}"`+r,"block"===o?"<div"+r:e?"<cg-"+o+r:"<"+o+r)});let o=-1;return t.replace(/"CG-PLACEHOLDER"/g,function(){return n[++o]})}function layoutInsertAttr(t,e,n={}){return t.replace(/<([\w-]+)[\s\S]*?>/g,function(t,o){if(n.ignore)for(const e of n.ignore)if(e.test(o))return t;if(n.include){let e=!1;for(const t of n.include)if(t.test(o)){e=!0;break}if(!e)return t}return t.replace(/<[\w-]+/,function(t){return t+" "+e})})}function layoutClassPrependObject(t){return`{${(t=t.slice(1,-1).trim()).replace(/([ a-zA-Z0-9'"`[\]\-_]+)(\s*:)/g,(t,e,n)=>{if((e=e.trim()).startsWith("["))e=`[classPrepend(${e.slice(1,-1)})]`;else{let t="";e.startsWith("'")||e.startsWith('"')||e.startsWith("`")?(t=e[0],e=e.slice(1,-1)):t="'",e=`[classPrepend(${t}${e}${t})]`}return`${e}${n}`})}}`}function layoutClassPrepend(t,e){return t.replace(/ class=["'](.*?)["']/gi,function(t,n){const o=(n=n.trim()).split(/\s+/),r=[];for(const t of o)if(t)for(const n of e)t.startsWith("fa-")?r.push(`${t}`):r.push(`${n}${t}`);return` class="${r.join(" ")}"`}).replace(/ :class=(["']).*?["']((\s+[a-zA-Z0-9-_:@]+(=|\s*>))|(\s*)>)/gi,function(t,e){return t.replace(new RegExp(`:class=${e}([^${e}]+?)${e}`,"gi"),function(t,e){if((e=e.trim()).startsWith("[")){const t=parseArrayString(e);for(let e=0;e<t.length;++e)t[e]=t[e].trim(),t[e].startsWith("{")?t[e]=layoutClassPrependObject(t[e]):t[e]=`classPrepend(${t[e]})`;e=`[${t.join(",")}]`}else e=e.startsWith("{")?layoutClassPrependObject(e):`classPrepend(${e})`;return`:class="${e}"`})}).replace(/ id=(["'])/gi,` id=$1${e[0]}`)}function eventsAttrWrap(t){const e=new RegExp(`@(${["click","dblclick","pointerdown","pointerenter","pointerleave","pointerup","mousedown","mouseenter","mouseleave","mouseup","touchstart","touchmove","touchend","keydown","keypress","keyup","contextmenu"].join("|")})="(.+?)"`,"g");return t.replace(e,function(t,e,n){return/^[\w]+$/.test(n)?`@${e}="allowEvent($event) && ${n}($event)"`:`@${e}=";if(allowEvent($event)){${n}}"`})}function teleportGlue(t,e){return t.replace(/<teleport([\s\S]+?)to="(.+?)"([\s\S]+?<[\w-]+)/g,(t,n,o,r)=>"system"!==o?t:"<teleport"+n+"to=\"#cg-pop-list > [data-form-id='"+e+"']\""+r+" data-cg-pop data-cg-pop-none")}function stylePrepend(t,e=""){""===e&&(e="cg-scope"+Math.round(1e15*Math.random()).toString()+"_"),t=t.replace(/([\s\S]+?){([\s\S]+?)}/g,function(t,n,o){return n=n.replace(/(^|[ >,}\r\n])([a-zA-Z-_][a-zA-Z0-9-_]*)/g,function(t,e,n){return"global"===n?"[CGTMP-GLOBAL]":e+".tag-"+n}),n=(n=n.replace(/keyframes \.tag-([a-zA-Z0-9-_]+)/g,function(t,e){return"keyframes "+e})).replace(/([.#])([a-zA-Z0-9-_]+)/g,function(t,n,o){return n+e+o})+"{"+o+"}"});const n=[];t=t.replace(/(@font-face[\s\S]+?font-family\s*:\s*["']{0,1})(.+?)(["']{0,1}\s*[;\r\n }])/gi,function(t,o,r,s){return n.push(r),o+e+r+s});for(const o of n){const n=new RegExp(`(font.+?[: "'])(${o})`,"gi");t=t.replace(n,function(t,n,o){return n+e+o})}const o=[];t=t.replace(/([-@]keyframes *["']{0,1})([\w-]+)(["']{0,1}\s*?\{)/gi,function(t,n,r,s){return o.includes(r)||o.push(r),n+e+r+s});for(const n of o){let o=new RegExp(`(animation[ :\\r\\n]+)(${n})([ ;}\\r\\n])`,"gi");t=t.replace(o,function(t,n,o,r){return n+e+o+r}),o=new RegExp(`(animation-name[ :\\r\\n]+)(${n})([ ;}\\r\\n])`,"gi"),t=t.replace(o,function(t,n,o,r){return n+e+o+r})}return{prep:e,style:t}}function getMimeByPath(t){const e=t.lastIndexOf("."),n=(-1===e?t:t.slice(e+1)).toLowerCase();return{mime:{eot:"application/vnd.ms-fontobject",woff:"font/woff",ttf:"font/ttf",svg:"image/svg+xml",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",png:"image/png"}[n]??"application/octet-stream",ext:n}}function rand(t,e,n=0){if(n<0&&(n=0),0===n)return Math.floor(Math.random()*(e-t+1))+t;const o=Math.pow(10,n);return Math.round((Math.random()*(e-t)+t)*o)/o}const RANDOM_N="0123456789",RANDOM_U="ABCDEFGHIJKLMNOPQRSTUVWXYZ",RANDOM_L="abcdefghijklmnopqrstuvwxyz",RANDOM_UN=RANDOM_U+RANDOM_N,RANDOM_LN=RANDOM_L+RANDOM_N,RANDOM_LU=RANDOM_L+RANDOM_U,RANDOM_LUN=RANDOM_L+RANDOM_U+RANDOM_N,RANDOM_V="ACEFGHJKLMNPRSTWXY34567",RANDOM_LUNS=RANDOM_LUN+"()`~!@#$%^&*-+=_|{}[]:;'<>,.?/]\"";function random(t=8,e=RANDOM_LN,n=""){let o=n.length;if(o>0)for(let t=0;t<o;++t)e=e.replace(n[t],"");if(o=e.length,0===o)return"";let r="";for(let n=0;n<t;++n)r+=e[rand(0,o-1)];return r}function getBoolean(t){const e=typeof t;return"boolean"===e?t:"string"===e?"false"!==t:!!t}function getNumber(t){return"number"==typeof t?t:parseFloat(t)}function getArray(t){if("string"!=typeof t)return t;let e=[];if((t=t.trim()).startsWith("["))try{e=JSON.parse(t)}catch{return[]}else e=(t=t.replace(/ /g,"")).split(",");return e}function escapeHTML(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function unescapeHTML(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}function formatColor(t){const e=/[0-9.%, ]+/.exec(t);if(!e)return[];return e[0].split(",").map(t=>parseFloat(t))}function rgb2hex(t,e,n,o=1){if(void 0===e||void 0===n){if("string"!=typeof t)return"";const r=formatColor(t);t=Math.round(r[0]),e=Math.round(r[1]),n=Math.round(r[2]),o=r[3]??1}else"string"==typeof t&&(t=Math.round(parseFloat(t))),"string"==typeof e&&(e=Math.round(parseFloat(e))),"string"==typeof n&&(n=Math.round(parseFloat(n))),"string"==typeof o&&(o=parseFloat(o));return((t<<16)+(e<<8)+n).toString(16).padStart(6,"0")+(1===o?"":Math.round(255*o).toString(16).padStart(2,"0"))}function hex2rgb(t){const e={r:0,g:0,b:0,a:1,rgb:"rgb"};let n=!1,o=t.slice(t.startsWith("#")?1:0);3===o.length?o=[...o].map(t=>t+t).join(""):8===o.length&&(n=!0);const r=parseInt(o,16);return e.r=r>>>(n?24:16),e.g=(r&(n?16711680:65280))>>>(n?16:8),e.b=(r&(n?65280:255))>>>(n?8:0),n&&(e.a=Math.round((255&r)/255*100)/1e3),e.rgb=`${n?"a":""}(${e.r},${e.g},${e.b}${n?","+e.a:""})`,e}function rgb2hsl(t,e,n,o=1,r=!1){const s={h:0,s:0,l:0,a:1,hsl:"hsl"};if(void 0===e||void 0===n){if("string"!=typeof t)return s;const r=formatColor(t);t=r[0],e=r[1],n=r[2],o=r[3]??1}else"string"==typeof t&&(t=parseFloat(t)),"string"==typeof e&&(e=parseFloat(e)),"string"==typeof n&&(n=parseFloat(n)),"string"==typeof o&&(o=parseFloat(o));t/=255,e/=255,n/=255;const i=Math.min(t,e,n),a=Math.max(t,e,n),c=a-i;let l=0,d=0,f=0;return l=0==c?0:a==t?(e-n)/c%6:a==e?(n-t)/c+2:(t-e)/c+4,l=Math.round(60*l),l<0&&(l+=360),f=(a+i)/2,d=0==c?0:c/(1-Math.abs(2*f-1)),d*=100,f*=100,s.h=l,s.s=d,s.l=f,s.a=o,r||(s.h=Math.round(s.h),s.s=Math.round(s.s),s.l=Math.round(s.l)),s.hsl+=(1===s.a?"":"a")+`(${s.h},${s.s}%,${s.l}%${1===s.a?"":","+s.a})`,s}function hsl2rgb(t,e,n,o=1,r=!1){const s={r:0,g:0,b:0,a:1,rgb:"rgb"};if(void 0===e||void 0===n){if("string"!=typeof t)return s;const r=formatColor(t);t=r[0],e=r[1],n=r[2],o=r[3]??1}else"string"==typeof t&&(t=parseFloat(t)),"string"==typeof e&&(e=parseFloat(e)),"string"==typeof n&&(n=parseFloat(n)),"string"==typeof o&&(o=parseFloat(o));n/=100;const i=e=>(e+t/30)%12,a=(e/=100)*Math.min(n,1-n),c=t=>n-a*Math.max(-1,Math.min(i(t)-3,Math.min(9-i(t),1)));return s.r=255*c(0),s.g=255*c(8),s.b=255*c(4),s.a=o,r||(s.r=Math.round(s.r),s.g=Math.round(s.g),s.b=Math.round(s.b)),s.rgb+=(1===s.a?"":"a")+`(${s.r},${s.g},${s.b}${1===s.a?"":","+s.a})`,s}function request(t,e){return new Promise(function(n){const o=new XMLHttpRequest;if(!1===e.credentials&&(o.withCredentials=!1),o.upload.onloadstart=function(t){const n=e.uploadStart?.(t.total);n&&n instanceof Promise&&n.catch(()=>{})},o.upload.onprogress=function(t){const n=e.uploadProgress?.(t.loaded,t.total);n&&n instanceof Promise&&n.catch(()=>{})},o.upload.onloadend=function(){const t=e.uploadEnd?.();t&&t instanceof Promise&&t.catch(()=>{})},o.onloadstart=function(t){const n=e.start?.(t.total);n&&n instanceof Promise&&n.catch(()=>{})},o.onprogress=function(t){const n=e.progress?.(t.loaded,t.total);n&&n instanceof Promise&&n.catch(()=>{})},o.onloadend=function(){const t=e.end?.();t&&t instanceof Promise&&t.catch(()=>{})},o.onload=function(){let t=this.response;if(this.getResponseHeader("content-type")?.includes("json"))try{t=JSON.parse(t)}catch{t=this.response}const o=e.load?.(t);o&&o instanceof Promise&&o.catch(()=>{}),n(t)},o.onerror=function(){const t=e.error?.();t&&t instanceof Promise&&t.catch(()=>{}),n(null)},e.responseType&&(o.responseType=e.responseType),e.timeout&&(o.timeout=e.timeout),e.headers&&!Array.isArray(e.headers))for(const t in e.headers)o.setRequestHeader(t,e.headers[t]);o.open(e.method??"GET",t,!0),o.send(e.body)})}async function fetch$1(t,e){try{const n=await window.fetch(t,e);if(200===n.status||304===n.status){const t=n.headers.get("content-type")?.toLowerCase()??"";return["text/","javascript","json","css","xml","html"].some(e=>t.includes(e))?await n.text():await n.blob()}return null}catch{return null}}const retryTimes=[300,1e3,2e3];async function get$4(t,e,n={}){e??={},e.method="GET";const o=n.retry??3;for(let n=0;n<=o;++n){const r=await fetch$1(t,e);if(null!==r)return r;if(n===o)return null;await sleep$1(retryTimes[n])}return null}async function post(t,e,n){n??={},n.method="POST",n.headers??={},e instanceof FormData||(n.headers instanceof Headers?n.headers.set("content-type","application/json"):n.headers["content-type"]="application/json"),n.body=e instanceof FormData?e:JSON.stringify(e);return await fetch$1(t,n)}async function getResponseJson(t,e){const n=await get$4(t,e);if(!n)return null;if("string"!=typeof n)return null;try{return JSON.parse(n)}catch{return null}}function postResponseEventStream(t,e,n={}){const o=new AbortController;return setTimeout(()=>{(async()=>{try{const r=(await window.fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:o.signal})).body;if(!r)return void await(n.onTimeout?.());await(n.onStart?.());const s=r.getReader(),i=new TextDecoder("utf8");let a="";for(;;)try{const{value:t,done:e}=await s.read();if(e)break;if(a+=i.decode(t,{stream:!0}),!a.includes("\n\n"))continue;const o=a.split("\n\n");a=o.pop()??"";for(const t of o){const e=JSON.parse(t.slice(5).trim());e.init?await(n.onInit?.(e.init)):await(n.onData?.("string"==typeof e?e:e.choices?.[0]?.delta?.content??""))}}catch{break}await(n.onEnd?.())}catch{return void await(n.onTimeout?.())}})().catch(()=>{})},0),o}async function postResponseJson(t,e,n){const o=await post(t,e,n);if(!o)return null;if("string"!=typeof o)return null;try{return JSON.parse(o)}catch{return null}}function parseUrl(t){const e={protocol:null,auth:null,user:null,pass:null,host:null,hostname:null,port:null,pathname:"/",path:null,query:null,hash:null},n=t.indexOf("#");n>-1&&(e.hash=t.slice(n+1),t=t.slice(0,n));const o=t.indexOf("?");o>-1&&(e.query=t.slice(o+1),t=t.slice(0,o));const r=t.indexOf(":");if(r>-1){e.protocol=t.slice(0,r+1).toLowerCase(),(t=t.slice(r+1)).startsWith("//")&&(t=t.slice(2));let n=t.indexOf("/");-1===n&&(n=t.indexOf("\\")),n>-1&&(e.pathname=t.slice(n),t=t.slice(0,n));const o=t.indexOf("@");if(o>-1){const n=t.slice(0,o),r=n.indexOf(":");r>-1?(e.user=n.slice(0,r),e.pass=n.slice(r+1),e.auth=e.user+":"+e.pass):(e.user=n,e.auth=n),t=t.slice(o+1)}if(t){const n=t.indexOf(":");n>-1?(e.hostname=t.slice(0,n).toLowerCase(),e.port=t.slice(n+1),e.host=e.hostname+(e.port?":"+e.port:"")):(e.hostname=t.toLowerCase(),e.host=e.hostname)}}else e.pathname=t;return e.path=e.pathname+(e.query?"?"+e.query:""),e}function urlResolve(t,e){if(t=t.replace(/\\/g,"/"),""===(e=e.replace(/\\/g,"/")))return urlAtom(t);const n=parseUrl(t);if(e.startsWith("//"))return urlAtom(n.protocol?n.protocol+e:e);n.protocol&&(t=n.protocol+t.slice(n.protocol.length));const o=parseUrl(e);if(o.protocol)return urlAtom(o.protocol+e.slice(o.protocol.length));if(e.startsWith("#")||e.startsWith("?")){const n=t.indexOf(e[0]);return urlAtom(-1!==n?t.slice(0,n)+e:t+e)}let r=(n.auth?n.auth+"@":"")+(n.host??"");if(e.startsWith("/"))r+=e;else{r+=n.pathname.replace(/\/[^/]*$/g,"")+"/"+e}return n.protocol&&"file:"!==n.protocol&&!n.host?urlAtom(n.protocol+r):urlAtom((n.protocol?n.protocol+"//":"")+r)}function urlAtom(t){for(;t.includes("/./");)t=t.replace(/\/\.\//g,"/");for(;/\/(?!\.\.)[^/]+\/\.\.\//.test(t);)t=t.replace(/\/(?!\.\.)[^/]+\/\.\.\//g,"/");return t=t.replace(/\.\.\//g,"")}function blob2Text(t){return new Promise(function(e){const n=new FileReader;n.addEventListener("load",function(t){t.target?e(t.target.result):e("")}),n.readAsText(t)})}function blob2DataUrl(t){return new Promise(function(e){const n=new FileReader;n.addEventListener("load",function(t){t.target?e(t.target.result):e("")}),n.readAsDataURL(t)})}function execCommand(t){["copy","cut"].includes(t)&&document.execCommand(t)}function compar(t,e){const n={remove:{},add:{},length:{remove:0,add:0}};for(let o=0;o<t.length;++o){const r=t[o];e.includes(r)||(n.remove[r]=o,++n.length.remove)}for(let o=0;o<e.length;++o){const r=e[o];t.includes(r)||(n.add[r]=o,++n.length.add)}return n}function formatSecond(t){const e=Math.floor(t/3600);t-=3600*e;const n=Math.floor(t/60),o=Math.floor(t-60*n);return(e?e.toString().padStart(2,"0")+":":"")+n.toString().padStart(2,"0")+":"+o.toString().padStart(2,"0")}function formatTime(t,e){const n={date:"",time:"",zone:""};"number"==typeof t&&(t=new Date(t));const o=e??-t.getTimezoneOffset()/60;return t.setTime(t.getTime()+60*o*6e4),n.date=t.getUTCFullYear().toString()+"-"+(t.getUTCMonth()+1).toString().padStart(2,"0")+"-"+t.getUTCDate().toString().padStart(2,"0"),n.time=t.getUTCHours().toString().padStart(2,"0")+":"+t.getUTCMinutes().toString().padStart(2,"0")+":"+t.getUTCSeconds().toString().padStart(2,"0"),n.zone="UTC"+(o>=0?"+":"")+o.toString(),n}function isMs(t){return t>1e12}function queryStringify(t,e=!0){return e?Object.entries(t).map(([t,e])=>Array.isArray(e)?e.map(e=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&"):`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&"):Object.entries(t).map(([t,e])=>Array.isArray(e)?e.map(e=>`${t}=${e}}`).join("&"):`${t}=${e}`).join("&")}function queryParse(t){const e={},n={};for(const o of t.split("&")){if(!o.length)continue;const t=o.indexOf("="),r=decodeURIComponent(-1===t?o:o.slice(0,t)),s=-1===t?"":decodeURIComponent(o.slice(t+1));n[r]?e[r].push(s):void 0===e[r]?e[r]=s:(e[r]=[e[r],s],n[r]=!0)}return e}function isEscaped(t,e){let n=0;for(let o=e-1;o>=0&&"\\"===t[o];o--)n++;return n%2!=0}function parseArrayString(t){const e=t.trim().slice(1,-1),n=[];let o="",r=0,s=!1,i="";for(let t=0;t<e.length;t++){const a=e[t];if('"'!==a&&"'"!==a||s?a===i&&s&&!isEscaped(e,t)&&(s=!1,i=""):(s=!0,i=a),!s)if("{"===a||"["===a||"("===a)r++;else if("}"===a||"]"===a||")"===a)r--;else if(","===a&&0===r){o.trim()&&n.push(o.trim()),o="";continue}o+=a}return o.trim()&&n.push(o.trim()),n}function isEscapeChar(t,e){let n=t[e-1],o=0;for(;"\\"===n;)n=t[e-++o-1];return o%2!=0}var ESTATE;function stateMachine(t,e,n){let o=ESTATE.NORMAL;t=t.replace(/\r\n/g,"\n").replace(/\r/g,"\n");const r={s:0,m:0,l:0};let s="",i="",a={state:ESTATE.NORMAL,word:"",nonnull:""};for(let c=e;c<t.length;++c){const e=t[c];switch(o){case ESTATE.COMMENT:if("*"===s){if("*"===e&&"/"===t[c+1]){if(i+=e+t[++c],c>=0&&!n({state:o,start:c-i.length+1,end:c,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const l=i.trim();l&&(a.nonnull=l),o=ESTATE.NORMAL,i="",s=""}else i+=e;break}if("\n"===e){if(--c,!n({state:o,start:c-i.length+1,end:c,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.NORMAL,i="",s=""}else i+=e;break;case ESTATE.REG:switch(e){case"[":isEscapeChar(t,c)||(s="["),i+=e;break;case"]":isEscapeChar(t,c)||"["!==s||(s="/"),i+=e;break;case"/":isEscapeChar(t,c)||"/"!==s||(s="e"),i+=e;break;default:{if("e"!==s){i+=e;break}if(/\w/.test(e)){i+=e;break}if(--c,!n({state:o,start:c-i.length+1,end:c,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.NORMAL,i="",s=""}}break;case ESTATE.STRING:if(i+=e,e===s&&!isEscapeChar(t,c)){if(!n({state:o,start:c-i.length+1,end:c,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.NORMAL,i="",s=""}break;case ESTATE.WORD:if(!/[$\w]/.test(e)){if(--c,!n({state:o,start:c-i.length+1,end:c,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.NORMAL,i="",s="";break}i+=e;break;default:switch(e){case'"':case"'":case"`":{if(c-1>=0&&!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.STRING,i=e,s=e;break}case"/":{if("/"===t[c+1]){if(c-1>=0&&!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const l=i.trim();l&&(a.nonnull=l),o=ESTATE.COMMENT,i=e+t[++c],s=e;break}if("*"===t[c+1]){if(c-1>=0&&!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const l=i.trim();l&&(a.nonnull=l),o=ESTATE.COMMENT,i=e+t[++c],s=t[c];break}let l="";for(let d=c-1;d>=0;--d)if(l){if(!/[$\w]/.test(t[d]))break;l=t[d]+l}else{if(/\s/.test(t[d]))continue;if(")"===t[d]||"]"===t[d])break;if(!/[$\w]/.test(t[d])){if(c-1>=0&&!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.REG,i=e,s=e;break}l=t[d]}if(l&&"return"===l){if(c-1>=0&&!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.REG,i=e,s=e}o!==ESTATE.REG&&(i+=e);break}case"(":if(i.includes("(")||i.includes(")")){if(!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.word=i;const t=i.trim();t&&(a.nonnull=t),i="",s=""}i+=e,++r.s;break;case")":if(i.includes("(")||i.includes(")")){if(!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.word=i;const t=i.trim();t&&(a.nonnull=t),i="",s=""}i+=e,--r.s;break;case"[":if(i.includes("[")||i.includes("]")){if(!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.word=i;const t=i.trim();t&&(a.nonnull=t),i="",s=""}i+=e,++r.m;break;case"]":if(i.includes("[")||i.includes("]")){if(!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.word=i;const t=i.trim();t&&(a.nonnull=t),i="",s=""}i+=e,--r.m;break;case"{":if(i.includes("{")||i.includes("}")){if(!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.word=i;const t=i.trim();t&&(a.nonnull=t),i="",s=""}i+=e,++r.l;break;case"}":if(i.includes("{")||i.includes("}")){if(!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.word=i;const t=i.trim();t&&(a.nonnull=t),i="",s=""}i+=e,--r.l;break;default:if(/[$\w]/.test(e)){if(c-1>=0&&!n({state:o,start:c-1-i.length+1,end:c-1,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r}))return;a.state=o,a.word=i;const t=i.trim();t&&(a.nonnull=t),o=ESTATE.WORD,i=e,s=e;break}i+=e}}}if(i){const e=t.length-1;n({state:o,start:e-i.length+1,end:e,word:i,pre:{state:a.state,word:a.word,nonnull:a.nonnull},bracket:r})}}let headElement;function getHeadElement(){if(!headElement){const t=document.querySelectorAll("head");headElement=t[t.length-1]}return headElement}async function loadScript(t){return new Promise(e=>{const n=document.createElement("script");n.addEventListener("load",function(){e(!0)}),n.addEventListener("error",function(){e(!1)}),n.src=t,getHeadElement().appendChild(n)})}async function loadScripts(t,e={}){await Promise.all(t.map(async t=>{const n=await loadScript(t);e.loaded?.(t,n?1:0)}))}async function loadLink(t,e="after"){return new Promise(n=>{const o=getHeadElement(),r=document.createElement("link");r.addEventListener("load",function(){n(!0)}),r.addEventListener("error",function(){n(!1)}),r.href=t,r.rel="stylesheet","before"===e?o.insertBefore(r,o.firstChild):o.appendChild(r)})}async function loadLinks(t,e={}){await Promise.all(t.map(async t=>{const n=await loadLink(t);e.loaded?.(t,n?1:0)}))}function loadStyle(t){const e=document.createElement("style");e.innerHTML=t,getHeadElement().appendChild(e)}function isFalsy(t){return null==t||""===t||!1===t||0===t}function isTruthy(t){return!isFalsy(t)}function logicalOr(t,e){return isFalsy(t)?e:t}!function(t){t[t.NORMAL=0]="NORMAL",t[t.WORD=1]="WORD",t[t.STRING=2]="STRING",t[t.REG=3]="REG",t[t.COMMENT=4]="COMMENT"}(ESTATE||(ESTATE={}));const lang={codes:["sc","tc","ja","ko","th","vi","ar","id","en","es","de","fr","pt","ru","it","tr"],names:["简体中文","繁體中文","日本語","한국어","ไทย","Tiếng việt","العربية","Bahasa Indonesia","English","Español","Deutsch","Français","Português","Русский","Italiano","Türkçe"],map:{cn:"sc",zh:"tc",ja:"ja",ko:"ko",th:"th",vi:"vi",ar:"ar",id:"id",en:"en",es:"es",de:"de",fr:"fr",pt:"pt",ru:"ru",it:"it",tr:"tr"},getCodeByAccept:t=>{if(t??=navigator.language,"*"===t)return"sc";const e=t.toLowerCase();for(const t in lang.map)if(e.includes(t))return lang.map[t];return"en"}};var tool=Object.freeze({__proto__:null,get ESTATE(){return ESTATE},RANDOM_L:RANDOM_L,RANDOM_LN:RANDOM_LN,RANDOM_LU:RANDOM_LU,RANDOM_LUN:RANDOM_LUN,RANDOM_LUNS:RANDOM_LUNS,RANDOM_N:RANDOM_N,RANDOM_U:RANDOM_U,RANDOM_UN:RANDOM_UN,RANDOM_V:RANDOM_V,blob2ArrayBuffer:blob2ArrayBuffer,blob2DataUrl:blob2DataUrl,blob2Text:blob2Text,clone:clone,compar:compar,compressor:compressor,escapeHTML:escapeHTML,eventsAttrWrap:eventsAttrWrap,execCommand:execCommand,fetch:fetch$1,formatColor:formatColor,formatSecond:formatSecond,formatTime:formatTime,get:get$4,getArray:getArray,getBoolean:getBoolean,getClassPrototype:getClassPrototype,getMimeByPath:getMimeByPath,getNumber:getNumber,getResponseJson:getResponseJson,hex2rgb:hex2rgb,hsl2rgb:hsl2rgb,isEscapeChar:isEscapeChar,isEscaped:isEscaped,isFalsy:isFalsy,isMs:isMs,isTruthy:isTruthy,lang:lang,layoutAddTagClassAndReTagName:layoutAddTagClassAndReTagName,layoutClassPrepend:layoutClassPrepend,layoutInsertAttr:layoutInsertAttr,loadLink:loadLink,loadLinks:loadLinks,loadScript:loadScript,loadScripts:loadScripts,loadStyle:loadStyle,logicalOr:logicalOr,match:match,nextFrame:nextFrame,parseArrayString:parseArrayString,parseUrl:parseUrl,post:post,postResponseEventStream:postResponseEventStream,postResponseJson:postResponseJson,purify:purify,queryParse:queryParse,queryStringify:queryStringify,rand:rand,random:random,request:request,rgb2hex:rgb2hex,rgb2hsl:rgb2hsl,runIife:runIife,sizeFormat:sizeFormat,sleep:sleep$1,sleepFrame:sleepFrame,stateMachine:stateMachine,stylePrepend:stylePrepend,styleUrl2DataUrl:styleUrl2DataUrl,teleportGlue:teleportGlue,unescapeHTML:unescapeHTML,urlAtom:urlAtom,urlResolve:urlResolve,weightFormat:weightFormat});let sysId$9="";function initSysId$8(t){sysId$9||(sysId$9=t)}const token=random(32,RANDOM_LUNS),methods={};function on(t,e,n,o=!1,r){"string"!=typeof t&&(t=t.taskId),getOrigin(t)&&(methods[t]||(methods[t]={}),methods[t][e+"-"+(r?r.toString():"")]={once:o,handler:n})}function once(t,e,n,o){on(t,e,n,!0,o)}function off(t,e,n){if("string"!=typeof t&&(t=t.taskId),!methods[t])return;const o=e+"-"+(n?n.toString():"");methods[t][o]&&delete methods[t][o]}function clear$2(t,e){if("string"!=typeof t&&(t=t.taskId),methods[t])if(e)for(const n in methods[t])n.endsWith("-"+e.toString())&&delete methods[t][n];else delete methods[t]}function getListenerList(t){void 0!==t&&"string"!=typeof t&&(t=t.taskId);const e={};for(const n in methods)if(!t||n===t){e[n]={};for(const t in methods[n]){const o=t.lastIndexOf("-"),r=t.slice(0,o),s=t.slice(o+1);e[n][s]||(e[n][s]={}),e[n][s][r]?++e[n][s][r]:e[n][s][r]=1}}return e}async function invoke(t,...e){return isNative()?window.clickgoNative.invoke(t,...e):null}async function invokeSys(t,e,...n){if(t===sysId$9)return invoke(e,token,...n)}async function quit(t){return!!(await checkPermission(t,"root"))[0]&&(await invoke("cg-quit",token),!0)}async function size(t,e,n){return!!(await checkPermission(t,"native.form"))[0]&&(await invoke("cg-set-size",token,e,n),!0)}async function max$1(t){return!!(await checkPermission(t,"native.form"))[0]&&(await invoke("cg-set-state",token,"max"),!0)}async function min$1(t){return!!(await checkPermission(t,"native.form"))[0]&&(await invoke("cg-set-state",token,"min"),!0)}async function unmaximize(t){return!!(await checkPermission(t,"native.form"))[0]&&(await invoke("cg-set-state",token,"unmaximize"),!0)}async function restore(t){return!!(await checkPermission(t,"native.form"))[0]&&(await invoke("cg-set-state",token,"restore"),!0)}async function activate(t){return!!(await checkPermission(t,"native.form"))[0]&&(await invoke("cg-activate",token),!0)}async function close$1(t){return!!(await checkPermission(t,"root"))[0]&&(await invoke("cg-close",token),!0)}async function maximizable(t,e){return!!(await checkPermission(t,"native.form"))[0]&&(await invoke("cg-maximizable",token,e),!0)}function open$1(t={}){return invoke("cg-form-open",token,t)}function save(t={}){return invoke("cg-form-save",token,t)}function dialog$1(t={}){return invoke("cg-form-dialog",token,t)}async function ping(t){return invoke("cg-ping",t)}async function isMax(){return invoke("cg-is-max")}window.clickgoNativeWeb={invoke:function(t,...e){for(const n in methods)for(const o in methods[n])o.startsWith(t+"-")&&(methods[n][o].handler(...e),methods[n][o].once&&(delete methods[n][o],Object.keys(methods[n]).length||delete methods[n]))}};let inited$4=!1;function init$5(){inited$4||(inited$4=!0,invoke("cg-init",token))}var native$1=Object.freeze({__proto__:null,activate:activate,clear:clear$2,close:close$1,dialog:dialog$1,getListenerList:getListenerList,init:init$5,initSysId:initSysId$8,invoke:invoke,invokeSys:invokeSys,isMax:isMax,max:max$1,maximizable:maximizable,min:min$1,off:off,on:on,once:once,open:open$1,ping:ping,quit:quit,restore:restore,save:save,size:size,unmaximize:unmaximize});let sysId$8="";function initSysId$7(t){sysId$8||(sysId$8=t)}let index$2=-1,focusId$1=null;const info={bottomLastZIndex:999,lastZIndex:999999,topLastZIndex:99999999,locale:{en:{ok:"OK",yes:"Yes",no:"No",cancel:"Cancel",search:"Search",confirmExitStep:"This operation will exit the current process. Are you sure you want to exit?"},sc:{ok:"好",yes:"是",no:"否",cancel:"取消",search:"搜索",confirmExitStep:"此操作将退出当前流程,确定退出吗?"},tc:{ok:"好",yes:"是",no:"否",cancel:"取消",search:"檢索",confirmExitStep:"此操作將結束目前的流程,確定退出嗎?"},ja:{ok:"好",yes:"はい",no:"いいえ",cancel:"キャンセル",search:"検索",confirmExitStep:"この操作は現在のプロセスを終了します。本当に終了しますか?"},ko:{ok:"확인",yes:"예",no:"아니오",cancel:"취소",search:"검색",confirmExitStep:"이 작업은 현재 프로세스를 종료합니다. 종료하시겠습니까?"},th:{ok:"ตกลง",yes:"ใช่",no:"ไม่",cancel:"ยกเลิก",search:"ค้นหา",confirmExitStep:"การดำเนินการนี้จะออกจากกระบวนการปัจจุบัน ยืนยันที่จะออกไหม?"},es:{ok:"Aceptar",yes:"Sí",no:"No",cancel:"Cancelar",search:"Buscar",confirmExitStep:"Esta operación cerrará el proceso actual. ¿Estás seguro de que quieres salir?"},de:{ok:"OK",yes:"Ja",no:"Nein",cancel:"Abbrechen",search:"Suchen",confirmExitStep:"Diese Aktion beendet den aktuellen Prozess. Möchten Sie wirklich beenden?"},fr:{ok:"OK",yes:"Oui",no:"Non",cancel:"Annuler",search:"Rechercher",confirmExitStep:"Cette opération va quitter le processus en cours. Êtes-vous sûr de vouloir quitter ?"},pt:{ok:"OK",yes:"Sim",no:"Não",cancel:"Cancelar",search:"Buscar",confirmExitStep:"Esta operação encerrará o processo atual. Você tem certeza de que deseja sair?"},ru:{ok:"OK",yes:"Да",no:"Нет",cancel:"Отмена",search:"Поиск",confirmExitStep:"Эта операция завершит текущий процесс. Вы уверены, что хотите выйти?"},vi:{ok:"OK",yes:"Có",no:"Không",cancel:"Hủy bỏ",search:"Tìm kiếm",confirmExitStep:"Thao tác này sẽ thoát khỏi quy trình hiện tại. Bạn có chắc chắn muốn thoát không?"}}};class AbstractCommon{get filename(){return""}get controlName(){return"root"}set controlName(t){notify({title:"Error",content:`The software tries to modify the system variable "controlName".\nPath: ${this.path}`,type:"danger"})}get taskId(){return""}get formId(){return""}set formFocus(t){notify({title:"Error",content:`The software tries to modify the system variable "formFocus".\nPath: ${this.path}`,type:"danger"})}get path(){return""}get prep(){return""}get locale(){const t=getOrigin(this.taskId);return logicalOr(t?.locale.lang??"",config.locale)}get l(){const t=getOrigin(this.taskId);return(e,n,o=!1)=>{const r=t?.locale.data[this.locale]?.[e]??t?.locale.data.en?.[e]??(o?"":"[LocaleError]")+e;if(!n)return r;let s=-1;return r.replace(/\?/g,function(){return++s,n[s]?n[s]:""})}}get classPrepend(){return t=>"string"!=typeof t?t:`cg-task${this.taskId}_${t}${this.prep?" "+this.prep+t:""}`}watch(t,e,n={}){return this.$watch(t,e,n)}get refs(){return this.$refs}get element(){return this.$el}get nextTick(){return this.$nextTick}allowEvent(t){return modules.pointer.allowEvent(t)}async trigger(t,e="",n=""){["formTitleChanged","formIconChanged","formStateMinChanged","formStateMaxChanged","formShowChanged"].includes(t)&&await trigger(t,this.taskId,this.formId,e,n)}send(t,e){e.taskId=this.taskId,e.formId=this.formId,send(t,e)}onBeforeCreate(){}onCreated(){}onBeforeMount(){}onBeforeUpdate(){}onUpdated(){}onBeforeUnmount(){}onUnmounted(){}}class AbstractPanel extends AbstractCommon{get panelId(){return""}get rootForm(){return{}}get rootPanel(){return{}}get formHash(){return this.rootForm.formHash}set formHash(t){this.rootForm.formHash=t}get formHashData(){return this.rootForm.formHashData}set formHashData(t){this.rootForm.formHashData=t}async formHashBack(){await this.rootForm.formHashBack()}sendToRootPanel(t){this.rootPanel.send(t)}async enterStep(t){return this.rootForm.enterStep(t)}async doneStep(){await this.rootForm.doneStep()}qs={};clearQs(){this.qs={}}get formFocus(){return this.rootForm.formFocus??!1}onShow(){}onShowed(){}onHide(){}onMounted(){}onReceive(){}onQsChange(){}onQsChangeShow(){}}class AbstractForm extends AbstractCommon{isReady=!1;isNativeNoFrameFirst=!1;get findex(){return 0}get formHash(){return""}set formHash(t){}get formHashData(){return{}}set formHashData(t){}get topMost(){return!1}set topMost(t){}get bottomMost(){return!1}set bottomMost(t){}get isMask(){if(!getOrigin(this.taskId))return!1;const t=getRuntime(sysId$8,this.taskId);return!!t&&!(!t.dialogFormIds.length||t.dialogFormIds[t.dialogFormIds.length-1]===this.formId)}get formFocus(){return this._formFocus}get showInSystemTask(){return!1}set showInSystemTask(t){}ready(t){t()}async formHashBack(){const t=this;if(Date.now()-t.$data._lastFormHashData>300&&(t.$data._formHashData={}),!t.$data._historyHash.length){if(t.$data._formHash){if(this.inStep){if(!await confirm(this,{content:info.locale[this.locale].confirmExitStep}))return;this._inStep=!1,this.refs.form.stepHide()}return t.$data._formHash="",void await trigger("formHashChange",this.taskId,this.formId,"",t.$data._formHashData)}return}const e=t.$data._historyHash[t.$data._historyHash.length-1];if(this.inStep)if(this._stepValues.includes(e))this.refs.form.stepValue=e;else{if(!await confirm(this,{content:info.locale[this.locale].confirmExitStep}))return;this._inStep=!1,this.refs.form.stepHide()}t.$data._formHash=e,t.$data._historyHash.splice(-1),await trigger("formHashChange",this.taskId,this.formId,e,t.$data._formHashData)}sendToPanel(t,e){t.send(e)}_loading=!1;get loading(){return this._loading}set loading(t){this.lockLoading||(this._loading=t)}lockLoading=!1;_inStep=!1;get inStep(){return this._inStep}_stepValues=[];async enterStep(t){if(this._inStep)return!1;if(t[0].value!==this.formHash)return!1;this._inStep=!0,this._stepValues.length=0;for(const e of t)this._stepValues.push(e.value);return this.refs.form.stepData=t,this.refs.form.stepValue=this.formHash,await this.nextTick(),this.refs.form.stepShow(),!0}updateStep(t,e){return!this._inStep&&(void 0!==this._stepValues[t]&&(this._stepValues[t]=e,!0))}async doneStep(){this._inStep&&(this._inStep=!1,await this.refs.form.stepDone())}_firstShow=!0;async show(){if(this._firstShow){this._firstShow=!1;const t=getAvailArea();this.refs.form.stateMaxData||(-1===this.refs.form.left&&this.refs.form.setPropData("left",(t.width-this.element.offsetWidth)/2),-1===this.refs.form.top&&this.refs.form.setPropData("top",(t.height-this.element.offsetHeight)/2)),this.refs.form.$data.isShow=!0,await changeFocus(this.formId)}else this.refs.form.$data.isShow=!0}async showDialog(){if(!getOrigin(this.taskId))return"";const t=getRuntime(sysId$8,this.taskId);return t?(t.dialogFormIds.push(this.formId),await this.show(),this.topMost=!0,new Promise(t=>{this.cgDialogCallback=()=>{t(this.dialogResult)}})):""}hide(){this.$refs.form.$data.isShow=!1}close(){close(this.formId)}dialogResult="";onMounted(){}onReceive(){}onScreenResize(){}onConfigChanged(){}onFormCreated(){}onFormRemoved(){}onFormTitleChanged(){}onFormIconChanged(){}onFormStateMinChanged(){}onFormStateMaxChanged(){}onFormShowChanged(){}onFormFocused(){}onFormBlurred(){}onFormFlash(){}onFormShowInSystemTaskChange(){}onFormHashChange(){}onTaskStarted(){}onTaskEnded(){}onLauncherFolderNameChanged(){}onHashChanged(){}onKeydown(){}onKeyup(){}}const popInfo={list:[],elList:[],wayList:[],time:[],lastZIndex:0};let simpleSystemTaskRoot,launcherRoot,superConfirmHandler;const elements={wrap:document.createElement("div"),list:document.createElement("div"),popList:document.createElement("div"),circular:document.createElement("div"),rectangle:document.createElement("div"),keyboard:document.createElement("div"),notify:document.createElement("div"),alert:document.createElement("div"),simpletask:document.createElement("div"),launcher:document.createElement("div"),confirm:document.createElement("div"),init:function(){this.wrap.id="cg-wrap",document.getElementsByTagName("body")[0].appendChild(this.wrap),this.wrap.addEventListener("touchmove",function(t){t.target&&findParentByData(t.target,"cg-scroll")||t.cancelable&&t.preventDefault()},{passive:!1}),this.wrap.addEventListener("wheel",function(t){t.target&&(void 0!==t.target.dataset.cgScroll||findParentByData(t.target,"cg-scroll"))||t.preventDefault()},{passive:!1}),this.wrap.addEventListener("contextmenu",function(t){t.preventDefault()}),this.list.id="cg-form-list",this.wrap.appendChild(this.list),this.popList.id="cg-pop-list",this.wrap.appendChild(this.popList),this.circular.id="cg-circular",this.wrap.appendChild(this.circular),this.rectangle.setAttribute("data-pos",""),this.rectangle.id="cg-rectangle",this.wrap.appendChild(this.rectangle),this.notify.id="cg-notify",this.wrap.appendChild(this.notify),this.alert.id="cg-alert",this.wrap.appendChild(this.alert),this.simpletask.id="cg-simpletask",this.wrap.appendChild(this.simpletask);modules.vue.createApp({template:'<div v-for="(item, formId) of forms" class="cg-simpletask-item" @click="click(formId)"><div v-if="item.icon" class="cg-simpletask-icon" :style="{\'background-image\': \'url(\' + item.icon + \')\'}"></div><div>{{item.title}}</div></div>',data:function(){return{forms:{}}},watch:{forms:{handler:function(){Object.keys(this.forms).length>0?"0px"!==elements.simpletask.style.bottom&&(elements.simpletask.style.bottom="0px",trigger("screenResize").catch(()=>{})):"0px"===elements.simpletask.style.bottom&&(elements.simpletask.style.bottom="-46px",trigger("screenResize").catch(()=>{}))},deep:!0}},methods:{click:async function(t){await changeFocus(t)}},mounted:function(){simpleSystemTaskRoot=this}}).mount("#cg-simpletask"),this.launcher.id="cg-launcher",this.wrap.appendChild(this.launcher);const t=function(){if(!config)return void setTimeout(function(){t()},150);const e=modules.vue.createApp({template:'<div class="cg-launcher-search"><input v-if="folderName === \'\'" class="cg-launcher-sinput" :placeholder="search" v-model="name"><input v-else class="cg-launcher-foldername" :value="folderName" @change="folderNameChange"></div><div class="cg-launcher-list" @pointerdown="down" @click="listClick" :class="[folderName === \'\' ? \'\' : \'cg-folder-open\']"><div v-for="item of list" class="cg-launcher-item"><div class="cg-launcher-inner"><div v-if="!item.list || item.list.length === 0" class="cg-launcher-icon" :style="{\'background-image\': \'url(\' + item.icon + \')\'}" @click="iconClick($event, item)"></div><div v-else class="cg-launcher-folder" @click="openFolder($event, item)"><div><div v-for="sub of item.list" class="cg-launcher-item"><div class="cg-launcher-inner"><div class="cg-launcher-icon" :style="{\'background-image\': \'url(\' + sub.icon + \')\'}" @click="subIconClick($event, sub)"></div><div class="cg-launcher-name">{{sub.name}}</div></div><div class="cg-launcher-space"></div></div></div></div><div class="cg-launcher-name">{{item.name}}</div></div><div class="cg-launcher-space"></div></div></div>',data:function(){return{name:"",folderName:"",folderItem:{}}},computed:{search:function(){return info.locale[config.locale]?.search??info.locale.en.search},list:function(){if(""===this.name)return config["launcher.list"];const t=[];for(const e of config["launcher.list"])if(e.list&&e.list.length>0)for(const n of e.list)n.name.toLowerCase().includes(this.name.toLowerCase())&&t.push(n);else e.name.toLowerCase().includes(this.name.toLowerCase())&&t.push(e);return t}},methods:{down:function(t){this.md=t.pageX+t.pageY},listClick:function(t){this.md===t.pageX+t.pageY&&t.currentTarget===t.target&&(""===this.folderName?hideLauncher():this.closeFolder())},iconClick:async function(t,e){this.md===t.pageX+t.pageY&&(hideLauncher(),await run(sysId$8,e.path,{icon:e.icon}))},subIconClick:async function(t,e){this.md===t.pageX+t.pageY&&(hideLauncher(),await run(sysId$8,e.path,{icon:e.icon}))},closeFolder:function(){this.folderName="";const t=this.folderEl,e=t.parentNode.getBoundingClientRect();t.classList.remove("cg-show"),t.style.left=(e.left+30).toString()+"px",t.style.top=e.top.toString()+"px",t.style.width="",t.style.height="",setTimeout(()=>{t.style.position="",t.style.left="",t.style.top=""},150)},openFolder:function(t,e){if(this.md!==t.pageX+t.pageY)return;if(t.currentTarget.childNodes[0]!==t.target)return;if(""!==this.folderName)return void this.closeFolder();this.folderName=e.name,this.folderItem=e;const n=t.currentTarget.childNodes.item(0);this.folderEl=n;const o=document.getElementsByClassName("cg-launcher-search")[0],r=n.getBoundingClientRect();n.style.left=r.left.toString()+"px",n.style.top=r.top.toString()+"px",n.style.position="fixed",requestAnimationFrame(()=>{n.classList.add("cg-show"),n.style.left="50px",n.style.top=o.offsetHeight.toString()+"px",n.style.width="calc(100% - 100px)",n.style.height="calc(100% - 50px - "+o.offsetHeight.toString()+"px)"})},folderNameChange:function(t){const e=t.target,n=e.value.trim();""!==n?(this.folderName=n,trigger("launcherFolderNameChanged",this.folderItem.id??"",n).catch(()=>{})):e.value=this.folderName}},mounted:function(){launcherRoot=this}});e.mount("#cg-launcher")};t(),this.confirm.id="cg-confirm",this.wrap.appendChild(this.confirm),this.confirm.innerHTML='<div class="cg-confirm-box"><div id="cg-confirm-content"></div><div class="cg-confirm-controls"><div id="cg-confirm-cancel"></div><div id="cg-confirm-ok"></div></div></div>',this.confirm.style.display="none",document.getElementById("cg-confirm-cancel").addEventListener("click",()=>{superConfirmHandler?.(!1),this.confirm.style.display="none",getMaxZIndexID(sysId$8).then(t=>{t&&changeFocus(t).catch(()=>{})}).catch(()=>{})}),document.getElementById("cg-confirm-ok").addEventListener("click",()=>{superConfirmHandler?.(!0),this.confirm.style.display="none",getMaxZIndexID(sysId$8).then(t=>{t&&changeFocus(t).catch(()=>{})}).catch(()=>{})}),this.keyboard.id="cg-keyboard",this.wrap.appendChild(this.keyboard),this.keyboard.innerHTML='<div v-for="line of list"><div v-for="row of line" :style="{\'width\': row[2] ? (row[2] * 50 + \'px\') : \'50px\'}" :class="[!row[0]&&\'cg-keyboard-null\',row[0]===\'Caps\'&&caps&&\'cg-keyboard-checked\',row[0]===\'Shift\'&&shift&&\'cg-keyboard-checked\']" @click="click(row)"><div v-if="row[1]">{{row[1]}}</div><svg v-if="row[0] === \'[x]\'" width="24" height="24" viewBox="0 0 24 24" stroke="none"><path d="m7.53033 6.46967c-.29289-.29289-.76777-.29289-1.06066 0s-.29289.76777 0 1.06066l4.46963 4.46967-4.46963 4.4697c-.29289.2929-.29289.7677 0 1.0606s.76777.2929 1.06066 0l4.46967-4.4696 4.4697 4.4696c.2929.2929.7677.2929 1.0606 0s.2929-.7677 0-1.0606l-4.4696-4.4697 4.4696-4.46967c.2929-.29289.2929-.76777 0-1.06066s-.7677-.29289-1.0606 0l-4.4697 4.46963z" /></svg><div v-else>{{row[0]}}</div></div></div>';modules.vue.createApp({data:function(){return{caps:!1,shift:!1,list:[[["`","~"],["1","!"],["2","@"],["3","#"],["4","$"],["5","%"],["6","^"],["7","&"],["8","*"],["9","("],["0",")"],["-","_"],["=","+"],["Back","",1.2]],[["Tab","",1.2],["q","Q"],["w","W"],["e","E"],["r","R"],["t","T"],["y","Y"],["u","U"],["i","I"],["o","O"],["p","P"],["[","{"],["]","}"],["\\","|"]],[["Caps","",1.6],["a","A"],["s","S"],["d","D"],["f","F"],["g","G"],["h","H"],["j","J"],["k","K"],["l","L"],[";",":"],["'",'"'],["Enter","",1.6]],[["Shift","",2],["z","Z"],["x","X"],["c","C"],["v","V"],["b","B"],["n","N"],["m","M"],[",","<"],[".",">"],["/","?"],["","",2.2]],[["","",4.2],[" "," ",5.8],["[x]","",4.2]]]}},methods:{click:function(t){if(t[0])switch(t[0]){case"Tab":document.execCommand("insertText",!1,"\t");break;case"Back":document.execCommand("delete");break;case"Caps":this.caps=!this.caps;break;case"Enter":document.execCommand("insertText",!1,"\n");break;case"Shift":this.shift=!this.shift;break;case"[x]":hideKeyboard();break;case"`":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"0":case"-":case"=":document.execCommand("insertText",!1,t[this.shift?1:0]),this.shift&&(this.shift=!1);break;default:{let e=this.caps;this.shift&&(e=!e),document.execCommand("insertText",!1,t[e?1:0]),this.shift&&(this.shift=!1)}}}}}).mount("#cg-keyboard");this.keyboard.addEventListener("pointerdown",t=>{t.preventDefault(),t.stopPropagation(),modules.pointer.move(t,{object:t.currentTarget,move:(t,e)=>{this.keyboard.style.left=parseFloat(this.keyboard.style.left)+e.ox+"px",this.keyboard.style.top=parseFloat(this.keyboard.style.top)+e.oy+"px"}})})}};function superConfirm(t,e){return new Promise(n=>{t===sysId$8&&(void 0===superConfirmHandler?(elements.confirm.style.display="flex",document.getElementById("cg-confirm-content").innerHTML=e,document.getElementById("cg-confirm-cancel").innerHTML=info.locale[config.locale]?.cancel??info.locale.en.cancel,document.getElementById("cg-confirm-ok").innerHTML=info.locale[config.locale]?.ok??info.locale.en.ok,superConfirmHandler=t=>{superConfirmHandler=void 0,n(t)}):n(!1))})}function showKeyboard(){is.keyboard||(is.keyboard=!0,elements.keyboard.style.display="flex",requestAnimationFrame(()=>{elements.keyboard.style.left=(window.innerWidth-elements.keyboard.offsetWidth)/2+"px",elements.keyboard.style.top=window.innerHeight-elements.keyboard.offsetHeight-50+"px",requestAnimationFrame(()=>{elements.keyboard.style.opacity="1",elements.keyboard.style.transform="translateY(0)"})}))}function hideKeyboard(){elements.keyboard.style.opacity="0",elements.keyboard.style.transform="translateY(-10px)",window.setTimeout(()=>{elements.keyboard.style.display="none",is.keyboard=!1},300)}function changeState(t,e){const n=getOrigin(getTaskId(e));if(!n)return!1;switch(t){case"max":n.forms[e].vroot.$refs.form.maxMethod();break;case"min":n.forms[e].vroot.$refs.form.minMethod();break;default:remove$2(e)}return!0}function min(t){return changeState("min",t)}function max(t){return changeState("max",t)}function close(t){return changeState("close",t)}function bindResize(t,e){const n=findParentByClass(t.target,"cg-form-wrap");if(!n)return;const o=n.dataset.formId;if(!o)return;const r=getOrigin(getTaskId(o));r&&r.forms[o].vroot.$refs.form.resizeMethod(t,e)}function bindDrag(t){const e=findParentByClass(t.target,"cg-form-wrap");if(!e)return;const n=e.dataset.formId;if(!n)return;const o=getOrigin(getTaskId(n));o&&o.forms[n].vroot.$refs.form.moveMethod(t,!0)}function refreshMaxPosition(){const t=getAvailArea();for(let e=0;e<elements.list.children.length;++e){const n=elements.list.children.item(e),o=n.children.item(0);if(void 0===o.dataset.cgMax)continue;const r=n.getAttribute("data-task-id"),s=n.getAttribute("data-form-id"),i=getOrigin(r);if(!i)continue;const a=i.forms[s].vroot;void 0===o.dataset.cgBottomMost?(a.$refs.form.setPropData("left",t.left),a.$refs.form.setPropData("top",t.top),a.$refs.form.setPropData("width",t.width),a.$refs.form.setPropData("height",t.height)):(a.$refs.form.setPropData("width",t.owidth),a.$refs.form.setPropData("height",t.oheight))}}function getTaskId(t){const e=elements.list.querySelector(`[data-form-id='${t}']`);if(!e)return"";const n=e.getAttribute("data-task-id");return n||""}function get$3(t){const e=getTaskId(t);if(!e)return null;const n=getOrigin(e);if(!n)return null;if(!n.forms[t])return null;const o=n.forms[t];return{taskId:e,title:o.vroot.$refs.form.title,icon:o.vroot.$refs.form.iconDataUrl,stateMax:o.vroot.$refs.form.stateMaxData,stateMin:o.vroot.$refs.form.stateMinData,show:o.vroot.$refs.form.isShow,focus:o.vroot.formFocus,showInSystemTask:o.vroot.showInSystemTask}}function send(t,e){const n=getTaskId(t);if(!n)return;const o=getOrigin(n);if(!o)return;o.forms[t].vroot.onReceive(e)}function getList$1(t){"string"!=typeof t&&(t=t.taskId);const e=getOrigin(t);if(!e)return{};const n={};for(const o in e.forms){const r=e.forms[o];n[o]={taskId:t,title:r.vroot.$refs.form.title,icon:r.vroot.$refs.form.iconDataUrl,stateMax:r.vroot.$refs.form.stateMaxData,stateMin:r.vroot.$refs.form.stateMinData,show:r.vroot.$refs.form.isShow,focus:r.vroot.formFocus,showInSystemTask:r.vroot.showInSystemTask}}return n}function getFocus$1(){return focusId$1}const activePanels={};function getActivePanel(t){return activePanels[t]??[]}function removeActivePanel(t,e,n){"string"!=typeof t&&(t=t.taskId);const o=getOrigin(t);if(!o)return!1;if(!o.forms[e])return!1;if(!activePanels[e])return!0;const r=activePanels[e].indexOf(n);return-1===r||(activePanels[e].splice(r,1),activePanels[e].length||delete activePanels[e]),!0}function setActivePanel(t,e,n){"string"!=typeof t&&(t=t.taskId);const o=getOrigin(t);if(!o)return!1;if(!o.forms[e])return!1;activePanels[e]||(activePanels[e]=[]);return-1!==activePanels[e].indexOf(n)||activePanels[e].push(n),!0}function hash$1(t,e){const n=getTaskId(t);if(!n)return!1;const o=getOrigin(n);if(!o)return!1;const r=o.forms[t];return!!r&&(r.vroot.formHash=e,!0)}function getHash$1(t){const e=getTaskId(t);if(!e)return"";const n=getOrigin(e);if(!n)return"";const o=n.forms[t];return o?o.vroot.$data._formHash:""}async function hashBack(t){const e=getTaskId(t);if(!e)return!1;const n=getOrigin(e);if(!n)return!1;const o=n.forms[t];return!!o&&(await o.vroot.formHashBack(),!0)}async function changeFocus(t=""){const e=getFocus$1();if(e){if(e===t)return;{const t=await getFocus(sysId$8);if(!t)return;const n=getOrigin(t);if(!n)return;n.forms[e].vapp._container.removeAttribute("data-form-focus"),n.forms[e].vroot._formFocus=!1,trigger("formBlurred",n.id,e).catch(()=>{})}}if(focusId$1=null,setFocus(),!t)return;const n=elements.list.querySelector(`.cg-form-wrap[data-form-id='${t}']`);if(!n)return;void 0!==n.children.item(0).dataset.cgMin&&min(t);const o=n.getAttribute("data-task-id")??"";if(!o)return;const r=getOrigin(o);if(!r)return;const s=getRuntime(sysId$8,o);if(s)if(s.dialogFormIds.length){const e=s.dialogFormIds[s.dialogFormIds.length-1];get$3(e).stateMin&&min(e),r.forms[e].vroot._topMost?r.forms[e].vroot.$refs.form.$data.zIndex=++info.topLastZIndex:r.forms[e].vroot._bottomMost?r.forms[e].vroot.$refs.form.$data.zIndex=++info.bottomLastZIndex:r.forms[e].vroot.$refs.form.$data.zIndex=++info.lastZIndex,r.forms[e].vapp._container.dataset.formFocus="",r.forms[e].vroot._formFocus=!0,focusId$1=e,setFocus(r.id),trigger("formFocused",o,e).catch(()=>{}),e!==t&&await flash(o,e)}else r.forms[t].vroot._topMost?r.forms[t].vroot.$refs.form.$data.zIndex=++info.topLastZIndex:r.forms[t].vroot._bottomMost?r.forms[t].vroot.$refs.form.$data.zIndex=++info.bottomLastZIndex:r.forms[t].vroot.$refs.form.$data.zIndex=++info.lastZIndex,r.forms[t].vapp._container.dataset.formFocus="",r.forms[t].vroot._formFocus=!0,focusId$1=t,setFocus(r.id),trigger("formFocused",o,t).catch(()=>{})}async function getMaxZIndexID(t,e={}){if("string"!=typeof t&&(t=t.taskId),!(await checkPermission(t,"root"))[0])return null;let n=0,o=null;for(let t=0;t<elements.list.children.length;++t){const r=elements.list.children.item(t),s=r.children.item(0);if(!s)continue;const i=parseInt(s.style.zIndex);if(i<1e6)continue;if(void 0!==s.dataset.cgMin)continue;const a=r.getAttribute("data-task-id");if(a===systemTaskInfo.taskId)continue;if(e.taskIds?.includes(a))continue;const c=r.getAttribute("data-form-id");e.formIds?.includes(c)||i>n&&(n=i,o=c)}return o}async function changeFocusMaxZIndex(){const t=await getMaxZIndexID(sysId$8);t&&await changeFocus(t??void 0)}function getRectByBorder(t){const e=getAvailArea();let n,o,r,s;if("string"==typeof t)switch(t){case"lt":n=e.width/2,o=e.height/2,r=e.left,s=e.top;break;case"t":n=e.width,o=e.height,r=e.left,s=e.top;break;case"tr":n=e.width/2,o=e.height/2,r=e.left+e.width/2,s=e.top;break;case"r":n=e.width/2,o=e.height,r=e.left+e.width/2,s=e.top;break;case"rb":n=e.width/2,o=e.height/2,r=e.left+e.width/2,s=e.top+e.height/2;break;case"b":n=e.width,o=e.height/2,r=e.left,s=e.top+e.height/2;break;case"bl":n=e.width/2,o=e.height/2,r=e.left,s=e.top+e.height/2;break;case"l":n=e.width/2,o=e.height,r=e.left,s=e.top}else n=t.width??e.width,o=t.height??e.height,r=t.left??e.left,s=t.top??e.top;return{width:n,height:o,left:r,top:s}}function showCircular(t,e){elements.circular.style.transition="none",requestAnimationFrame(function(){elements.circular.style.width="6px",elements.circular.style.height="6px",elements.circular.style.left=(t-3).toString()+"px",elements.circular.style.top=(e-3).toString()+"px",elements.circular.style.opacity="1",requestAnimationFrame(function(){elements.circular.style.transition="all .3s var(--g-cubic)",requestAnimationFrame(function(){elements.circular.style.width="60px",elements.circular.style.height="60px",elements.circular.style.left=(t-30).toString()+"px",elements.circular.style.top=(e-30).toString()+"px",elements.circular.style.opacity="0"})})})}function moveRectangle(t){if("0"===(elements.rectangle.getAttribute("data-ready")??"0"))return;const e=elements.rectangle.getAttribute("data-border")??"",n="string"==typeof t?t:`o-${t.left}-${t.top??"n"}-${t.width}-${t.height??"n"}`;if(e===n)return;elements.rectangle.setAttribute("data-dir",n);const o=getRectByBorder(t),r=o.width-20,s=o.height-20,i=o.left+10,a=o.top+10;void 0!==r&&void 0!==s&&void 0!==i&&void 0!==a&&(elements.rectangle.style.width=r.toString()+"px",elements.rectangle.style.height=s.toString()+"px",elements.rectangle.style.left=i.toString()+"px",elements.rectangle.style.top=a.toString()+"px")}function showRectangle(t,e,n){elements.rectangle.style.transition="none",requestAnimationFrame(function(){elements.rectangle.style.width="5px",elements.rectangle.style.height="5px",elements.rectangle.style.left=(t-10).toString()+"px",elements.rectangle.style.top=(e-10).toString()+"px",elements.rectangle.style.opacity="1",elements.rectangle.setAttribute("data-ready","0"),elements.rectangle.setAttribute("data-dir",""),requestAnimationFrame(function(){elements.rectangle.style.transition="all .3s var(--g-cubic)",requestAnimationFrame(function(){elements.rectangle.setAttribute("data-ready","1"),moveRectangle(n)})})})}function hideRectangle(){elements.rectangle.style.opacity="0"}let alertBottom=0,alertId=0;function alert$1(t,e){const n=++alertId,o=document.createElement("div"),r=alertBottom;return o.classList.add("cg-alert-wrap"),o.classList.add("cg-"+(e??"default")),o.setAttribute("data-alertid",n.toString()),o.style.transform=`translateY(${r+10}px)`,o.style.opacity="0",o.innerHTML=`<div class="cg-alert-content"><div class="cg-alert-icon"></div><div>${escapeHTML(t)}</div></div>`,elements.alert.appendChild(o),alertBottom-=o.offsetHeight+10,requestAnimationFrame(function(){o.style.transform=`translateY(${r}px)`,o.style.opacity="1";const t=window.setTimeout(function(){clearTimeout(t);const e=o.offsetHeight;o.style.opacity="0",setTimeout(function(){alertBottom+=e+10;const t=document.getElementsByClassName("cg-alert-wrap");let n=!1;for(const r of t)r!==o?n&&(r.style.transform=r.style.transform.replace(/translateY\(([-0-9]+)px\)/,function(t,n){return`translateY(${parseInt(n)+e+10}px)`})):n=!0;o.remove()},100)},3e3)}),n}let notifyBottom=-10,notifyId=0;function notify(t){t.note&&!t.content&&(t.content="Notify");const e=++notifyId;let n=5e3;const o=6e5;void 0!==t.timeout&&(n=t.timeout<0?5e3:0===t.timeout||t.timeout>o?o:t.timeout),t.progress&&!t.type&&(t.type="progress");const r=document.createElement("div");let s=notifyBottom,i=-10;return systemTaskInfo.taskId&&("bottom"===config["task.position"]?s-=systemTaskInfo.length:"right"===config["task.position"]&&(i-=systemTaskInfo.length)),r.classList.add("cg-notify-wrap"),r.setAttribute("data-notifyid",e.toString()),r.style.transform=`translateY(${s}px) translateX(280px)`,r.style.opacity="0",r.classList.add(t.title&&t.content?"cg-notify-full":"cg-notify-only"),r.innerHTML=`<div class="cg-notify-icon cg-${escapeHTML(t.type??"primary")}"></div><div style="flex: 1;">`+(t.title?`<div class="cg-notify-title">${escapeHTML(t.title)}</div>`:"")+(t.content?`<div class="cg-notify-content">${escapeHTML(t.content).replace(/\r\n/g,"\n").replace(/\r/g,"\n").replace(/\n/g,"<br>")}</div>`:"")+(t.note?`<div class="cg-notify-note">${escapeHTML(t.note)}</div>`:"")+(t.progress?'<div class="cg-notify-progress"></div>':"")+"</div>",t.icon&&(r.childNodes.item(0).style.background="url("+t.icon+")",r.childNodes.item(0).style.backgroundSize="14px"),elements.notify.appendChild(r),notifyBottom-=r.offsetHeight+10,requestAnimationFrame(function(){r.style.transform=`translateY(${s}px) translateX(${i}px)`,r.style.opacity="1";const t=window.setTimeout(function(){hideNotify(e)},n);r.setAttribute("data-timer",t.toString())}),e}function notifyProgress(t,e){const n=elements.notify.querySelector(`[data-notifyid="${t}"]`);if(!n)return;const o=n.querySelector(".cg-notify-progress");if(o){if(e>100)e=100;else if(1===e){parseFloat(o.style.width)>1&&(e=100)}100===e&&(o.style.transitionDelay=".1s"),o.style.width=(e<1?100*e:e).toString()+"%"}}function notifyContent(t,e){const n=elements.notify.querySelector(`[data-notifyid="${t}"]`);if(n){if(e.title){const t=n.querySelector(".cg-notify-title");if(!t)return;t.innerHTML=escapeHTML(e.title)}if(e.content){const t=n.querySelector(".cg-notify-content");if(!t)return;t.innerHTML=escapeHTML(e.content)}if(e.note){const t=n.querySelector(".cg-notify-note");if(!t)return;t.innerHTML=escapeHTML(e.note)}e.progress&¬ifyProgress(t,e.progress),e.timeout&&setTimeout(function(){hideNotify(t)},e.timeout)}}function hideNotify(t){const e=elements.notify.querySelector(`[data-notifyid="${t}"]`);if(!e)return;clearTimeout(parseInt(e.getAttribute("data-timer")));const n=e.offsetHeight;e.style.opacity="0",setTimeout(function(){notifyBottom+=n+10;const t=document.getElementsByClassName("cg-notify-wrap");let o=!1;for(const r of t)r!==e?o&&(r.style.transform=r.style.transform.replace(/translateY\(([-0-9]+)px\)/,function(t,e){return`translateY(${parseInt(e)+n+10}px)`})):o=!0;e.remove()},100)}function appendToPop(t){elements.popList.appendChild(t)}function removeFromPop(t){elements.popList.removeChild(t)}function refreshPopPosition(t,e,n,o={}){const r=o.width??e.offsetWidth,s=o.height??e.offsetHeight;let i,a;if("string"==typeof n){const o=t.getBoundingClientRect();"v"===n?(i=o.left,a=o.top+o.height):"h"===n?(i=o.left+o.width-2,a=o.top-2):(e.removeAttribute("data-pop-t-bottom"),i=o.left+o.width/2-r/2,a=o.top-s-10),r+i>window.innerWidth&&(i="v"===n?o.left+o.width-r:"h"===n?o.left-r+2:window.innerWidth-r),s+a>window.innerHeight?"v"===n?a=o.top-s:"h"===n&&(a=o.top+o.height-s+2):a<0&&"t"===n&&(a=o.top+o.height+10,e.dataset.popTBottom="")}else{let t,e;n instanceof PointerEvent?(t=n.clientX,e=n.clientY):(t=n.x,e=n.y),i=t+5,a=e+7,r+i>window.innerWidth&&(i=t-r-5),s+a>window.innerHeight&&(a=e-s-5)}i<0&&(i=0),a<0&&(a=0),e.style.left=i.toString()+"px",e.style.top=a.toString()+"px",e.style.zIndex=(++popInfo.lastZIndex).toString(),o.width&&(e.style.width=o.width.toString()+"px"),o.height&&(e.style.height=o.height.toString()+"px")}let lastShowPopTime=0;function showPop(t,e,n,o={}){if(!(t instanceof Element)){if(!t.$el)return;t=t.$el}if(e&&!(e instanceof Element)){if(!e.$el)return;e=e.$el}if(o.null??=!1,o.size??={},o.flow??=!0,!e&&!o.null)return;if(e&&!o.flow)return e.removeAttribute("data-cg-pop-none"),e.dataset.cgFlow="",void sleep$1(34).then(()=>{void 0!==e.dataset.cgFlow&&(refreshPopPosition(t,e,n,o.size),o.autoPosition&&watchSize(sysId$8,e,()=>{refreshPopPosition(t,e,n,o.size)}),e.dataset.cgOpen="")}).catch(()=>{});const r=Date.now();if(r-lastShowPopTime<5)return void(lastShowPopTime=r);if(lastShowPopTime=r,void 0!==t.dataset.cgPopOpen)return;const s=findParentByData(t,"cg-pop");if(void 0!==s?.dataset.cgLevel){const t=parseInt(s.dataset.cgLevel)+1;popInfo.elList[t]&&hidePop(popInfo.elList[t])}else hidePop();if(!e)return popInfo.elList.push(t),t.dataset.cgPopOpen="",void(t.dataset.cgLevel=(popInfo.elList.length-1).toString());e.removeAttribute("data-cg-pop-none"),popInfo.list.push(e),popInfo.elList.push(t),popInfo.wayList.push(o.way??"normal"),popInfo.time.push(Date.now()),e.dataset.cgLevel=(popInfo.list.length-1).toString(),t.dataset.cgLevel=(popInfo.elList.length-1).toString(),sleep$1(34).then(()=>{void 0!==e.dataset.cgLevel&&(refreshPopPosition(t,e,n,o.size),o.autoPosition&&"string"==typeof n&&watchSize(sysId$8,e,()=>{refreshPopPosition(t,e,n,o.size)}),o.autoScroll&&"string"==typeof n&&watchPosition(t,()=>{refreshPopPosition(t,e,n,o.size)}),e.dataset.cgOpen="",t.dataset.cgPopOpen="")}).catch(()=>{})}function hidePop(t){if(t&&!(t instanceof HTMLElement)){if(!t.$el)return;t=t.$el}if(!t){if(0===popInfo.elList.length)return;return void hidePop(popInfo.elList[0])}if(void 0!==t.dataset.cgFlow)return t.removeAttribute("data-cg-flow"),t.removeAttribute("data-cg-open"),unwatchSize(t),void sleep$1(334).then(()=>{void 0===t.dataset.cgFlow&&(t.dataset.cgPopNone="")}).catch(()=>{});if(void 0===t.dataset.cgLevel)return;const e=void 0!==t.dataset.cgPop,n=t.dataset.cgLevel?parseInt(t.dataset.cgLevel):-1;if(-1!==n){if(popInfo.elList[n+1]&&hidePop(popInfo.elList[n+1]),e)t.removeAttribute("data-cg-open"),t.removeAttribute("data-cg-level"),unwatchSize(t),unwatchPosition(popInfo.elList[n]),popInfo.elList[n].removeAttribute("data-cg-pop-open"),popInfo.elList[n].removeAttribute("data-cg-level"),sleep$1(334).then(()=>{void 0===t.dataset.cgLevel&&(t.dataset.cgPopNone="")}).catch(()=>{});else{if(popInfo.list[n]){const e=popInfo.list[n];e.removeAttribute("data-cg-open"),e.removeAttribute("data-cg-level"),unwatchSize(popInfo.list[n]),unwatchPosition(t),sleep$1(334).then(()=>{void 0===e.dataset.cgLevel&&(e.dataset.cgPopNone="")}).catch(()=>{})}t.removeAttribute("data-cg-pop-open"),t.removeAttribute("data-cg-level")}popInfo.list.splice(n),popInfo.elList.splice(n),popInfo.wayList.splice(n),popInfo.time.splice(n)}}function isJustPop(t){if(t instanceof HTMLElement){const e=t.dataset.cgLevel;if(!e)return!1;t=parseInt(e)}const e=popInfo.time[t];return!(Date.now()-e>=100)}async function doFocusAndPopEvent(t){if(!t.target)return;const e=t.path??(t.composedPath?t.composedPath():[]);let n=null;for(const t of e)if(t.tagName)if(void 0===t.dataset.cgLevel||void 0!==t.dataset.cgPop){if(t.classList.contains("cg-form-wrap")){const e=t.getAttribute("data-form-id")??"";return await changeFocus(e),void(n&&isJustPop(n)||hidePop())}if("body"===t.tagName.toLowerCase())break}else n=t;for(const t of e)if(t.tagName){if("body"===t.tagName.toLowerCase())break;if(void 0!==t.dataset.cgPop){if(t.dataset.cgLevel){const e=parseInt(t.dataset.cgLevel)+1;"click"!==popInfo.wayList[e]||isJustPop(e)||hidePop(popInfo.list[e])}return}}hidePop(),await changeFocus()}function remove$2(t){const e=getTaskId(t),n=getOrigin(e);if(!n?.forms[t])return!1;if(n.forms[t].closed)return!1;const o=getRuntime(sysId$8,e);if(!o)return!1;n.forms[t].closed=!0;const r=n.forms[t].vroot.$refs.form.title,s=n.forms[t].vroot.$refs.form.iconDataUrl,i=o.dialogFormIds.indexOf(t);return i>-1&&o.dialogFormIds.splice(i,1),n.forms[t].vroot.$refs.form.$data.isShow=!1,setTimeout(()=>{(async()=>{const n=await getMaxZIndexID(sysId$8,{formIds:[t]});n?await changeFocus(n):await changeFocus();const o=getOrigin(e);if(!o)return!0;o.forms[t].vapp.unmount(),o.forms[t].vapp._container.remove(),elements.popList.querySelector('[data-form-id="'+t+'"]')?.remove(),i>-1&&o.forms[t].vroot.cgDialogCallback(),delete o.forms[t],removeStyle(e,"form",t),trigger("formRemoved",e,t,r,s).catch(()=>{}),clearWatchStyle(t),clearWatchProperty(t),clearWatchPosition(t),clear$2(t,e),delete activePanels[t],0===Object.keys(o.forms).length&&await end(e)})().catch(()=>{})},is.transition?300:0),!0}function removePanel(t,e,n){const o=findParentByClass(n,"cg-form-wrap");if(!o)return!1;const r=o.dataset.formId;if(!r)return!1;const s=o.dataset.taskId;if(!s)return!1;if(e.unmount(),e._container.remove(),n.querySelector('[data-panel-id="'+t+'"]')?.remove(),removeStyle(s,"form",r,t),clearWatchStyle(r,t),clearWatchProperty(r,t),clearWatchPosition(r,t),activePanels[r]){const e=activePanels[r].indexOf(t);e>=0&&activePanels[r].splice(e,1),activePanels[r].length||delete activePanels[r]}return!0}function getForm(t,e){const n=getOrigin(t);if(!n)return null;const o=n.forms[e];return o||null}async function createPanel(t,e,n={}){if("panel"!==t.element.dataset.cgControl){const t=new Error("form.createPanel: -0");throw trigger("error","","",t,t.message).catch(()=>{}),t}const o=findParentByData(t.element,"form-id");if(!o){const t=new Error("form.createPanel: -0");throw trigger("error","","",t,t.message).catch(()=>{}),t}const r=o.dataset.formId,s=getOrigin(t.taskId);if(!s){const t=new Error("form.createPanel: -1");throw trigger("error","","",t,t.message).catch(()=>{}),t}let i="";n.layout&&(i=n.layout);let a="",c="";n.style&&(a=n.style);let l="";if("string"==typeof e){if(l=urlResolve(n.path??"/",e)+".js",!i){const t=s.app.files[e+".xml"];if("string"!=typeof t){const t=new Error("form.createPanel: -2");throw trigger("error","","",t,t.message).catch(()=>{}),t}i=t}if(!a){const t=s.app.files[e+".css"];"string"==typeof t&&(a=t)}e=class extends AbstractPanel{get filename(){return l}}}const d=random(8,RANDOM_LUN);Object.defineProperty(e.prototype,"taskId",{get:()=>s.id,configurable:!0});const f=new e;l||(l=f.filename);const u=l.slice(0,l.lastIndexOf("/"));if(!i){const t=s.app.files[l.slice(0,-2)+"xml"];if("string"!=typeof t){const t=new Error("form.createPanel: -3");throw trigger("error","","",t,t.message).catch(()=>{}),t}i=t}if(!a){const t=s.app.files[l.slice(0,-2)+"css"];"string"==typeof t&&(a=t)}if(a){const t=stylePrepend(a);c=t.prep,a=await styleUrl2DataUrl(u+"/",t.style,s.app.files)}i=purify(i),i=layoutAddTagClassAndReTagName(i,!0);const m=["cg-task"+s.id+"_"];""!==c&&m.push(c),i=layoutClassPrepend(i,m),i=eventsAttrWrap(i),i.includes("<teleport")&&(i=teleportGlue(i,r)),i.includes('@click="')&&(i=i.replaceAll('@click="','@tap="'));const h=buildComponents(s.id,r,u);if(!h){const t=new Error("form.createPanel: -4");throw trigger("error","","",t,t.message).catch(()=>{}),t}const g={},p=Object.entries(f);for(const t of p)"access"!==t[0]&&(g[t[0]]=t[1]);const y=getClassPrototype(f),w=y.method,v=y.access;v.taskId={get:function(){return s.id},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "taskId".\nPath: ${this.filename}`,type:"danger"})}},v.formId={get:function(){return r},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "formId".\nPath: ${this.filename}`,type:"danger"})}},v.panelId={get:function(){return d},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "panelId".\nPath: ${this.filename}`,type:"danger"})}},v.path={get:function(){return u},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "path".\nPath: ${this.filename}`,type:"danger"})}},v.prep={get:function(){return c},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "prep".\nPath: ${this.filename}`,type:"danger"})}},v.rootForm={get:function(){return s.forms[r].vroot},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "rootForm".\nPath: ${this.filename}`,type:"danger"})}},v.rootPanel={get:function(){return t},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "rootPanel".\nPath: ${this.filename}`,type:"danger"})}},t.element.insertAdjacentHTML("beforeend",`<div data-panel-id="${d}"></div>`),a&&pushStyle(s.id,a,"form",r,d);const b=t.element.children.item(t.element.children.length-1);b.style.position="absolute",b.style.display="none";const k=await new Promise(function(t){const e=modules.vue.createApp({template:i.replace(/^<cg-panel([\s\S]+)-panel>$/,"<cg-layout$1-layout>"),data:function(){return clone(g)},methods:w,computed:v,beforeCreate:f.onBeforeCreate,created:function(){f.access&&(this.access=clone(f.access)),this.onCreated()},beforeMount:function(){this.onBeforeMount()},mounted:async function(){await this.$nextTick(),b.children.item(0).style.flex="1",t({vapp:e,vroot:this})},beforeUpdate:function(){this.onBeforeUpdate()},updated:async function(){await this.$nextTick(),this.onUpdated()},beforeUnmount:function(){this.onBeforeUnmount()},unmounted:async function(){await this.$nextTick(),this.onUnmounted()}});e.config.errorHandler=function(t,e,n){notify({title:"Runtime Error",content:`Message: ${t.message}\nTask id: ${e?.taskId??""}\nForm id: ${e?.formId??""}`,type:"danger"}),console.error("Runtime Error [form.createPanel.errorHandler]",`Message: ${t.message}\nTask id: ${e?.taskId??""}\nForm id: ${e?.formId??""}`,t,n),trigger("error",e?.taskId??"",e?.formId??"",t,n+"(-3,"+(e?.taskId??"")+","+(e?.formId??"")+")").catch(()=>{})};for(const t in h)e.component(t,h[t]);try{e.mount(b)}catch(t){notify({title:"Runtime Error",content:`Message: ${t.message}\nTask id: ${s.id}\nForm id: ${r}`,type:"danger"}),console.error("Runtime Error [form.createPanel.mount]",`Message: ${t.message}\nTask id: ${s.id}\nForm id: ${r}`,t),trigger("error",s.id,r,t,t.message).catch(()=>{})}});await sleep$1(34);try{await f.onMounted.call(k.vroot)}catch(t){trigger("error",k.vroot.taskId,k.vroot.formId,t,"Create panel mounted error: -5.").catch(()=>{});try{k.vapp.unmount()}catch(t){notify({title:"Panel Unmount Error",content:`Message: ${t.message}\nTask id: ${s.id}\nForm id: ${r}\nFunction: form.createPanel, unmount.`,type:"danger"})}throw k.vapp._container.remove(),clearWatchStyle(k.vroot.formId,d),clearWatchProperty(k.vroot.formId,d),clearWatchPosition(k.vroot.formId,d),removeStyle(k.vroot.taskId,"form",k.vroot.formId,d),t}return{id:d,vapp:k.vapp,vroot:k.vroot}}async function create(t,e,n,o={}){"string"!=typeof t&&(t=t.taskId);const r=getOrigin(t);if(!r){const t=new Error("form.create: -1");throw trigger("error","","",t,t.message).catch(()=>{}),t}let s="";o.layout&&(s=o.layout);let i="",a="";o.style&&(i=o.style);let c="";if("string"==typeof e){if(c=urlResolve(o.path??"/",e),!s){const t=r.app.files[c+".xml"];if("string"!=typeof t){const t=new Error("form.create: -2");throw trigger("error","","",t,t.message).catch(()=>{}),t}s=t}if(!i){const t=r.app.files[c+".css"];"string"==typeof t&&(i=t)}c+=".js",e=class extends AbstractForm{get filename(){return c}}}const l=random(8,RANDOM_LUN),d=++index$2;Object.defineProperty(e.prototype,"taskId",{get:()=>r.id,configurable:!0});const f=new e;c||(c=f.filename);const u=c.slice(0,c.lastIndexOf("/"));if(!s){const t=r.app.files[c.slice(0,-2)+"xml"];if("string"!=typeof t){const t=new Error("form.create: -3");throw trigger("error","","",t,t.message).catch(()=>{}),t}s=t}if(!i){const t=r.app.files[c.slice(0,-2)+"css"];"string"==typeof t&&(i=t)}if(i){const t=stylePrepend(i);a=t.prep,i=await styleUrl2DataUrl(u+"/",t.style,r.app.files)}s=purify(s),s=layoutAddTagClassAndReTagName(s,!0);const m=["cg-task"+r.id+"_"];""!==a&&m.push(a),s=layoutClassPrepend(s,m),s=eventsAttrWrap(s),s.includes("<teleport")&&(s=teleportGlue(s,l)),s.includes('@click="')&&(s=s.replaceAll('@click="','@tap="'));const h=buildComponents(r.id,l,u);if(!h){const t=new Error("form.create: -4");throw trigger("error","","",t,t.message).catch(()=>{}),t}const g={},p=Object.entries(f);for(const t of p)"access"!==t[0]&&(g[t[0]]=t[1]);g._formFocus=!1,isNative()&&0===d&&!hasFrame()&&(g.isNativeNoFrameFirst=!0);const y=getClassPrototype(f),w=y.method,v=y.access;v.findex={get:function(){return d},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "findex".\nPath: ${this.filename}`,type:"danger"})}},v.taskId={get:function(){return r.id},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "taskId".\nPath: ${this.filename}`,type:"danger"})}},v.formId={get:function(){return l},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "formId".\nPath: ${this.filename}`,type:"danger"})}},v.path={get:function(){return u},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "path".\nPath: ${this.filename}`,type:"danger"})}},v.prep={get:function(){return a},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "prep".\nPath: ${this.filename}`,type:"danger"})}},g._bottomMost=!1,v.bottomMost={get:function(){return this._bottomMost},set:function(t){t?(this._bottomMost=!0,this.$el.dataset.cgBottomMost="",this._topMost&&(this._topMost=!1),this.$refs.form.$data.zIndex=++info.bottomLastZIndex):(this._bottomMost=!1,this.$el.removeAttribute("data-cg-bottom-most"),this.$refs.form.$data.zIndex=++info.lastZIndex)}},g._topMost=!1,v.topMost={get:function(){return this._topMost},set:function(t){t?(this._topMost=!0,this._bottomMost&&(this._bottomMost=!1,this.$el.removeAttribute("data-cg-bottom-most")),this._formFocus?this.$refs.form.$data.zIndex=++info.topLastZIndex:changeFocus(this.formId).catch(()=>{})):(this._topMost=!1,this.$refs.form.$data.zIndex=++info.lastZIndex)}},g._historyHash=[],g._formHash="",v.formHash={get:function(){return this._formHash},set:function(e){e!==this._formHash&&(Date.now()-this._lastFormHashData>300&&(this._formHashData={}),this.inStep?(async()=>{if(this._stepValues.includes(e))this.$refs.form.stepValue=e;else{if(!await confirm(t,{content:info.locale[this.locale].confirmExitStep}))return;this._inStep=!1,this.$refs.form.stepHide()}this._formHash&&this._historyHash.push(this._formHash),this._formHash=e,trigger("formHashChange",r.id,l,e,this._formHashData).catch(()=>{})})():(this._formHash&&this._historyHash.push(this._formHash),this._formHash=e,trigger("formHashChange",r.id,l,e,this._formHashData).catch(()=>{})))}},g._lastFormHashData=0,g._formHashData={},v.formHashData={get:function(){return this._formHashData},set:function(t){this._formHashData=t,this._lastFormHashData=Date.now()}},g._showInSystemTask=!0,v.showInSystemTask={get:function(){return this._showInSystemTask},set:function(t){this._showInSystemTask=t,trigger("formShowInSystemTaskChange",r.id,l,t).catch(()=>{})}};const b=[];w.ready=function(t){this.isReady?t():b.push(t)},elements.list.insertAdjacentHTML("beforeend",`<div class="cg-form-wrap" data-form-id="${l}" data-task-id="${r.id}"></div>`),elements.popList.insertAdjacentHTML("beforeend",`<div data-form-id="${l}" data-task-id="${r.id}"></div>`),i&&pushStyle(r.id,i,"form",l);const k=elements.list.children.item(elements.list.children.length-1),S=await new Promise(function(e){const n=modules.vue.createApp({template:s.replace(/^<cg-form/,'<cg-form ref="form"'),data:function(){return clone(g)},methods:w,computed:v,beforeCreate:f.onBeforeCreate,created:function(){f.access&&(this.access=clone(f.access)),this.onCreated()},beforeMount:function(){this.onBeforeMount()},mounted:async function(){if(await this.$nextTick(),this.$refs.form.icon){const e=await getContent(t,this.$refs.form.icon);this.$refs.form.iconDataUrl=e instanceof Blob?await blob2DataUrl(e):""}e({vapp:n,vroot:this})},beforeUpdate:function(){this.onBeforeUpdate()},updated:async function(){await this.$nextTick(),this.onUpdated()},beforeUnmount:function(){this.onBeforeUnmount()},unmounted:async function(){await this.$nextTick(),this.onUnmounted()}});n.config.errorHandler=function(t,e,n){notify({title:"Runtime Error",content:`Message: ${t.message}\nTask id: ${e?.taskId??""}\nForm id: ${e?.formId??""}`,type:"danger"}),console.error("Runtime Error [form.create.errorHandler]",`Message: ${t.message}\nTask id: ${e?.taskId??""}\nForm id: ${e?.formId??""}`,t,n),trigger("error",e?.taskId??0,e?.formId??0,t,n+"(-3,"+e?.taskId+","+e?.formId+")").catch(()=>{})};for(const t in h)n.component(t,h[t]);try{n.mount(k)}catch(t){notify({title:"Runtime Error",content:`Message: ${t.message}\nTask id: ${r.id}\nForm id: ${l}`,type:"danger"}),console.error("Runtime Error [form.create.mount]",`Message: ${t.message}\nTask id: ${r.id}\nForm id: ${l}`,t),trigger("error",r.id,l,t,t.message).catch(()=>{})}}),$={id:l,vapp:S.vapp,vroot:S.vroot,closed:!1};r.forms[l]=$,await sleep$1(34);try{await f.onMounted.call(S.vroot,n??{})}catch(t){trigger("error",S.vroot.taskId,S.vroot.formId,t,"Create form mounted error: -6.").catch(()=>{}),delete r.forms[l];try{S.vapp.unmount()}catch(t){notify({title:"Form Unmount Error",content:`Message: ${t.message}\nTask id: ${r.id}\nForm id: ${l}\nFunction: form.create, unmount.`,type:"danger"})}throw S.vapp._container.remove(),elements.popList.querySelector('[data-form-id="'+S.vroot.formId+'"]')?.remove(),clearWatchStyle(S.vroot.formId),clearWatchProperty(S.vroot.formId),clearWatchPosition(S.vroot.formId),clear$2(l,r.id),removeStyle(S.vroot.taskId,"form",S.vroot.formId),t}trigger("formCreated",r.id,l,S.vroot.$refs.form.title,S.vroot.$refs.form.iconDataUrl,S.vroot.showInSystemTask).catch(()=>{}),S.vroot.isNativeNoFrameFirst&&(await invokeSys(sysId$8,"cg-set-size",S.vroot.$refs.form.$el.offsetWidth,S.vroot.$refs.form.$el.offsetHeight),window.addEventListener("resize",function(){S.vroot.$refs.form.setPropData("width",window.innerWidth),S.vroot.$refs.form.setPropData("height",window.innerHeight)})),S.vroot.isReady=!0;for(const t of b)t.call(S.vroot);return S.vroot}function dialog(t,e){return new Promise(function(n){"string"!=typeof t&&(t=t.taskId),"string"==typeof e&&(e={content:e});const o=urlResolve(e.path??"/","./tmp"+random(16,RANDOM_LN)+".js"),r=e,s=getOrigin(t);if(!s)return void n("");const i=s.locale.lang||config.locale;r.buttons??=[info.locale[i]?.ok??info.locale.en.ok];create(t,class extends AbstractForm{buttons=r.buttons;data=r.data??{};methods=r.methods??{};get filename(){return o}select(t){const e={go:!0,preventDefault:function(){this.go=!1},detail:{button:t}};r.select&&r.select.call(this,e,t),e.go&&(!1!==r.autoDialogResult&&(this.dialogResult=t),close(this.formId))}},void 0,{layout:`<form title="${r.title??"dialog"}" min="false" max="false" resize="false" height="0" width="0" border="${r.title?"normal":"plain"}" direction="v"><dialog :buttons="buttons" @select="select"${r.direction?` direction="${r.direction}"`:""}${r.gutter?` gutter="${r.gutter}"`:""}>${r.content}</dialog></form>`,style:r.style}).then(t=>{"number"!=typeof t?t.showDialog().then(t=>{n(t)}).catch(()=>{n("")}):n("")}).catch(()=>{n("")})})}async function confirm(t,e){"string"!=typeof t&&(t=t.taskId),"string"==typeof e&&(e={content:e});const n=getOrigin(t);if(!n)return!1;const o=n.locale.lang||config.locale,r=[info.locale[o]?.no??info.locale.en.no,info.locale[o]?.yes??info.locale.en.yes];e.cancel&&r.unshift(info.locale[o]?.cancel??info.locale.en.cancel);const s=await dialog(t,{title:e.title,content:e.content,buttons:r});return s===(info.locale[o]?.yes??info.locale.en.yes)||s===(info.locale[o]?.cancel??info.locale.en.cancel)&&0}async function prompt(t,e){"string"!=typeof t&&(t=t.taskId),"string"==typeof e&&(e={content:e});const n=getOrigin(t);if(!n)return"";const o=n.locale.lang||config.locale,r=[info.locale[o]?.ok??info.locale.en.ok],s=info.locale[o]?.cancel??info.locale.en.cancel;!0!==e.cancel&&void 0!==e.cancel||r.unshift(s);return await dialog(t,{title:e.title,direction:"v",gutter:10,content:"<block>"+e.content+'</block><text v-model="data.text" />',data:{text:e.text??""},select:function(t,n){const r=n===(info.locale[o]?.ok??info.locale.en.ok),i={go:!0,preventDefault:function(){this.go=!1},detail:{button:r,value:this.data.text}};e.select?.call(this,i,r),i.go||t.preventDefault(),t.detail.button!==s?this.dialogResult=this.data.text:this.dialogResult=""},buttons:r,autoDialogResult:!1})}async function flash(t,e){"string"!=typeof t&&(t=t.taskId);const n=getForm(t,e);n&&(n.vroot._formFocus||await changeFocus(n.id),n.vroot.$refs.form.flashTimer&&(clearTimeout(n.vroot.$refs.form.flashTimer),n.vroot.$refs.form.flashTimer=void 0),n.vroot.$refs.form.flashTimer=setTimeout(()=>{n.vroot.$refs.form&&(n.vroot.$refs.form.flashTimer=void 0)},1e3),await trigger("formFlash",t,e))}function showLauncher(){elements.launcher.style.display="flex",requestAnimationFrame(function(){elements.launcher.classList.add("cg-show")})}function hideLauncher(){elements.launcher.classList.remove("cg-show"),setTimeout(function(){""!==launcherRoot.folderName&&launcherRoot.closeFolder(),launcherRoot.name="",elements.launcher.style.display="none"},300)}window.addEventListener("pointerdown",t=>{doFocusAndPopEvent(t).catch(()=>{})});let inited$3=!1;function init$4(){inited$3||(inited$3=!0,elements.init())}var form=Object.freeze({__proto__:null,AbstractForm:AbstractForm,AbstractPanel:AbstractPanel,activePanels:activePanels,alert:alert$1,appendToPop:appendToPop,bindDrag:bindDrag,bindResize:bindResize,changeFocus:changeFocus,changeFocusMaxZIndex:changeFocusMaxZIndex,close:close,confirm:confirm,create:create,createPanel:createPanel,dialog:dialog,doFocusAndPopEvent:doFocusAndPopEvent,elements:elements,flash:flash,get:get$3,getActivePanel:getActivePanel,getFocus:getFocus$1,getHash:getHash$1,getList:getList$1,getMaxZIndexID:getMaxZIndexID,getRectByBorder:getRectByBorder,getTaskId:getTaskId,hash:hash$1,hashBack:hashBack,hideKeyboard:hideKeyboard,hideLauncher:hideLauncher,hideNotify:hideNotify,hidePop:hidePop,hideRectangle:hideRectangle,init:init$4,initSysId:initSysId$7,isJustPop:isJustPop,get launcherRoot(){return launcherRoot},max:max,min:min,moveRectangle:moveRectangle,notify:notify,notifyContent:notifyContent,notifyProgress:notifyProgress,prompt:prompt,refreshMaxPosition:refreshMaxPosition,remove:remove$2,removeActivePanel:removeActivePanel,removeFromPop:removeFromPop,removePanel:removePanel,send:send,setActivePanel:setActivePanel,showCircular:showCircular,showKeyboard:showKeyboard,showLauncher:showLauncher,showPop:showPop,showRectangle:showRectangle,get simpleSystemTaskRoot(){return simpleSystemTaskRoot},superConfirm:superConfirm});let sysId$7="";function initSysId$6(t){sysId$7||(sysId$7=t)}const topClass=["#cg-form-list","#cg-pop-list","#cg-notify","#cg-alert","#cg-keyboard","#cg-simpletask","#cg-launcher","#cg-confirm"];function classUnfold(t,e=[]){const n=[];for(const o of topClass)e.includes(o)||n.push(o+(t?" "+t:""));return n.join(", ")}const hueCount=11.25;let hueCssVar="";const hues=[];for(let t=0;t<32;++t){const e=(11.25*t).toFixed(2);hueCssVar+=`--hue-${t}:${e}; `,hues.push(e)}const styleList=document.createElement("div");function inPage(t){return document.body.contains(t)}styleList.style.display="none",document.getElementsByTagName("body")[0].appendChild(styleList),styleList.insertAdjacentHTML("beforeend","<style id='cg-global-cursor'></style>"),styleList.insertAdjacentHTML("beforeend","<style id='cg-global-transition'></style>"),styleList.insertAdjacentHTML("beforeend",`<style id='cg-global'>\n${classUnfold()} {-webkit-user-select: none; user-select: none; cursor: default; box-sizing: border-box; background-clip: padding-box;}\n${topClass.slice(0,4).join(", ")} {left: 0; top: 0; width: 0; height: 0; position: absolute;}\n${classUnfold("img")} {vertical-align: bottom;}\n${classUnfold("::selection",["#cg-launcher"])} {background-color: rgba(0, 0, 0, .1);}\n${classUnfold("*")}, ${classUnfold("*::after")}, ${classUnfold("*::before")} {box-sizing: border-box; background-clip: padding-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); flex-shrink: 0;}\n${classUnfold(" > div")} {font-family: var(--g-family); font-size: var(--g-size); line-height: 1; -webkit-font-smoothing: antialiased; text-shadow: 0 0 1px color-mix(in srgb, currentColor 40%, transparent); fill: currentColor; stroke: currentColor;}\n#cg-wrap { ${hueCssVar}}\n</style>`);const dpiDiv=document.createElement("div");dpiDiv.style.visibility="hidden",dpiDiv.style.width="1in",document.getElementsByTagName("body")[0].appendChild(dpiDiv);const dpi=dpiDiv.getBoundingClientRect().width;let globalCursorStyle,globalTransitionStyle;function setGlobalCursor(t){globalCursorStyle||(globalCursorStyle=document.getElementById("cg-global-cursor")),globalCursorStyle.innerHTML=t?`*, *::after, *::before {cursor: ${t} !important;}`:""}function setGlobalTransition(t){globalTransitionStyle||(globalTransitionStyle=document.getElementById("cg-global-transition")),globalTransitionStyle.innerHTML=t?"":"*, *::after, *::before {transition: none !important;}",is.transition=t}function createToStyleList(t){styleList.insertAdjacentHTML("beforeend",`<div id="cg-style-task${t}"><div class="cg-style-control"></div><div class="cg-style-theme"></div><style class="cg-style-global"></style><div class="cg-style-form"></div></div>`)}function removeFromStyleList(t){document.getElementById("cg-style-task"+t)?.remove()}function pushStyle(t,e,n="global",o="",r){const s=document.querySelector(`#cg-style-task${t} > .cg-style-${n}`);s&&("global"===n?s.innerHTML=e:"theme"===n||"control"===n?s.insertAdjacentHTML("beforeend",`<style data-name="${o}">${e}</style>`):s.insertAdjacentHTML("beforeend",`<style class="cg-style-form${o}" data-panel="${r?r.toString():""}">${e}</style>`))}function removeStyle(t,e="global",n="",o){const r=document.getElementById("cg-style-task"+t);if(r)if("global"===e){const t=r.querySelector(".cg-style-global");if(!t)return;t.innerHTML=""}else if("theme"===e||"control"===e)if(n){const t=r.querySelectorAll(`.cg-style-${e} > [data-name='${n}']`);for(let e=0;e<t.length;++e)t.item(e).remove()}else{const t=r.querySelector(`.cg-style-${e}`);if(!t)return;t.innerHTML=""}else{const t=r.querySelectorAll(".cg-style-form"+n.toString()+(o?'[data-panel="'+o.toString()+'"]':""));for(let e=0;e<t.length;++e)t.item(e).remove()}}function getStyleCount(t,e){return"string"!=typeof t&&(t=t.taskId),document.querySelectorAll(`#cg-style-task${t} > .cg-style-${e} > style`).length}dpiDiv.remove(),document.addEventListener("touchstart",function(){});const watchPositionObjects={};let watchPositionIndex=0;function watchPosition(t,e,n=!1){if(isWatchPosition(t))return!1;if(n)try{const t=e({position:!1,size:!1});t instanceof Promise&&t.catch(()=>{})}catch{}const o=findParentByData(t,"form-id");if(!o)return!1;const r=o.dataset.formId,s=findParentByData(t,"panel-id"),i=s?s.dataset.panelId:"default";return watchPositionObjects[r]||(watchPositionObjects[r]={}),watchPositionObjects[r][i]||(watchPositionObjects[r][i]={}),watchPositionObjects[r][i][watchPositionIndex]={el:t,rect:t.getBoundingClientRect(),handler:e},t.dataset.cgPoindex=watchPositionIndex.toString(),++watchPositionIndex,!0}function unwatchPosition(t){const e=t.dataset.cgPoindex;if(void 0===e)return;const n=findParentByData(t,"form-id");if(!n)return;const o=n.dataset.formId,r=findParentByData(t,"panel-id"),s=r?r.dataset.panelId:"default";t.removeAttribute("data-cg-poindex"),delete watchPositionObjects[o][s][e],Object.keys(watchPositionObjects[o][s]).length||(delete watchPositionObjects[o][s],Object.keys(watchPositionObjects[o]).length||delete watchPositionObjects[o])}function isWatchPosition(t){return!!t.dataset.cgPoindex}function clearWatchPosition(t,e){if(watchPositionObjects[t]){for(const n in watchPositionObjects[t])if(!e||n===e){for(const e in watchPositionObjects[t][n]){watchPositionObjects[t][n][e].el.removeAttribute("data-cg-poindex")}delete watchPositionObjects[t][n]}Object.keys(watchPositionObjects[t]).length||delete watchPositionObjects[t]}}const watchSizeList={};function getWatchSizeCount(t){if(!t)return Object.keys(watchSizeList).length;"string"!=typeof t&&(t=t.taskId);let e=0;for(const n in watchSizeList)watchSizeList[n].taskId===t&&++e;return e}let watchSizeIndex=0;const resizeObserver=new ResizeObserver(function(t){for(const e of t){const t=e.target;if(!document.body.contains(t)){resizeObserver.unobserve(t),watchSizeList[t.dataset.cgRoindex]&&delete watchSizeList[t.dataset.cgRoindex];continue}const n=watchSizeList[t.dataset.cgRoindex];try{const t=n.handler();t instanceof Promise&&t.catch(()=>{})}catch{}}});function watchSize(t,e,n,o=!1){if("string"!=typeof t&&(t=t.taskId),t!==sysId$7&&!getOrigin(t))return!1;if(isWatchSize(e))return!1;if(o)try{const t=n();t instanceof Promise&&t.catch(()=>{})}catch{}return resizeObserver.observe(e,{box:"border-box"}),watchSizeList[watchSizeIndex]={el:e,handler:n,taskId:t},e.dataset.cgRoindex=watchSizeIndex.toString(),++watchSizeIndex,!0}function unwatchSize(t){const e=t.dataset.cgRoindex;void 0!==e&&(resizeObserver.unobserve(t),t.removeAttribute("data-cg-roindex"),delete watchSizeList[e])}function isWatchSize(t){return!!t.dataset.cgRoindex}function clearWatchSize(t){"string"!=typeof t&&(t=t.taskId);for(const e in watchSizeList){const n=watchSizeList[e];t===n.taskId&&(resizeObserver.unobserve(n.el),n.el.removeAttribute("data-cg-roindex"),delete watchSizeList[e])}}const watchList={};function getWatchCount(t){if(!t)return Object.keys(watchList).length;let e=0;for(const n in watchList)watchList[n].taskId===t&&++e;return e}let watchIndex=0;function watch(t,e,n,o="default",r=!1){if("string"!=typeof t&&(t=t.taskId),t!==sysId$7&&!getOrigin(t))return!1;if(isWatch(e))return!1;if(r)try{const t=n([]);t instanceof Promise&&t.catch(()=>{})}catch{}const s=watchIndex;let i;switch(o){case"child":i={childList:!0};break;case"childsub":i={childList:!0,subtree:!0};break;case"style":i={attributeFilter:["style","class"],attributeOldValue:!0,attributes:!0};break;case"text":i={characterData:!0,childList:!0,subtree:!0};break;default:i={attributeFilter:["style","class"],attributeOldValue:!0,attributes:!0,characterData:!0,childList:!0,subtree:!0}}const a=new MutationObserver(t=>{if(!document.body.contains(e))return a.disconnect(),void(watchList[s]&&delete watchList[s]);try{const e=n(t);e instanceof Promise&&e.catch(()=>{})}catch{}});return a.observe(e,i),watchList[s]={el:e,mo:a,taskId:t},e.dataset.cgMoindex=s.toString(),++watchIndex,!0}function unwatch(t,e){"string"!=typeof t&&(t=t.taskId);const n=e.dataset.cgMoindex;if(void 0===n)return;watchList[n].taskId===t&&(e.removeAttribute("data-cg-moindex"),watchList[n].mo.disconnect(),delete watchList[n])}function isWatch(t){return!!t.dataset.cgMoindex}function clearWatch(t){"string"!=typeof t&&(t=t.taskId);for(const e in watchList){const n=watchList[e];t===n.taskId&&(n.el.removeAttribute("data-cg-moindex"),n.mo.disconnect(),delete watchList[e])}}const watchCgTimerHandler=function(){for(const t in watchSizeList){const e=watchSizeList[t];document.body.contains(e.el)||delete watchSizeList[t]}for(const t in watchList){const e=watchList[t];document.body.contains(e.el)||delete watchList[t]}window.setTimeout(watchCgTimerHandler,42e4)};watchCgTimerHandler();const watchStyleList={};let watchStyleIndex=0;function watchStyle(t,e,n,o=!1){"string"==typeof e&&(e=[e]);const r=findParentByData(t,"form-id");if(!r)return;const s=r.dataset.formId,i=findParentByData(t,"panel-id"),a=i?i.dataset.panelId:"default",c=t.dataset.cgStyleindex;if(c){const t=watchStyleList[s][a][c];for(const r of e)t.names[r]?t.names[r].cb.push(n):t.names[r]={val:t.sd[r],cb:[n]},o&&n(r,t.sd[r],"");return}watchStyleList[s]||(watchStyleList[s]={}),watchStyleList[s][a]||(watchStyleList[s][a]={});const l=getComputedStyle(t);watchStyleList[s][a][watchStyleIndex]={el:t,sd:l,names:{}};const d=watchStyleList[s][a][watchStyleIndex];for(const t of e)d.names[t]={val:d.sd[t],cb:[n]},o&&n(t,d.sd[t],"");t.dataset.cgStyleindex=watchStyleIndex.toString(),++watchStyleIndex}function isWatchStyle(t){return!!t.dataset.cgStyleindex}function clearWatchStyle(t,e){if(watchStyleList[t]){for(const n in watchStyleList[t])if(!e||n===e){for(const e in watchStyleList[t][n]){watchStyleList[t][n][e].el.removeAttribute("data-cg-styleindex")}delete watchStyleList[t][n]}Object.keys(watchStyleList[t]).length||delete watchStyleList[t]}}const watchPropertyObjects={};let watchPropertyIndex=0;function watchProperty(t,e,n,o=!1){"string"==typeof e&&(e=[e]);const r=findParentByData(t,"form-id");if(!r)return;const s=r.dataset.formId,i=findParentByData(t,"panel-id"),a=i?i.dataset.panelId:"default",c=t.dataset.cgPropertyindex;if(c){const t=watchPropertyObjects[s][a][c];for(const r of e)t.names[r]?t.names[r].cb.push(n):t.names[r]={val:t.el[r],cb:[n]},o&&n(r,t.el[r]);return}watchPropertyObjects[s]||(watchPropertyObjects[s]={}),watchPropertyObjects[s][a]||(watchPropertyObjects[s][a]={}),watchPropertyObjects[s][a][watchPropertyIndex]={el:t,names:{}};const l=watchPropertyObjects[s][a][watchPropertyIndex];for(const t of e)l.names[t]={val:l.el[t],cb:[n]},o&&n(t,l.el[t]);t.dataset.cgPropertyindex=watchPropertyIndex.toString(),++watchPropertyIndex}function isWatchProperty(t){return!!t.dataset.cgPropertyindex}function clearWatchProperty(t,e){if(watchPropertyObjects[t]){for(const n in watchPropertyObjects[t])if(!e||n===e){for(const e in watchPropertyObjects[t][n]){watchPropertyObjects[t][n][e].el.removeAttribute("data-cg-propertyindex")}delete watchPropertyObjects[t][n]}Object.keys(watchPropertyObjects[t]).length||delete watchPropertyObjects[t]}}function getWatchInfo(){const t={formId:"",default:{},panels:{}},e=getFocus$1();if(!e)return t;t.formId=e;const n=getActivePanel(e),o=(e,n,o)=>{o&&(t.panels[o]||(t.panels[o]={}));const r=o?t.panels[o]:t.default,s=e.el.dataset.cgControl??findParentByData(e.el,"cg-control")?.dataset.cgControl??"unknown";if(r[s]||(r[s]={style:{count:0,list:[]},property:{count:0,list:[]},position:{count:0}}),++r[s][n].count,e.names&&"position"!==n)for(const t in e.names)r[s][n].list.includes(t)||r[s][n].list.push(t)};if(watchStyleList[e]){if(watchStyleList[e].default)for(const t in watchStyleList[e].default)o(watchStyleList[e].default[t],"style");for(const t of n)if(watchStyleList[e][t])for(const n in watchStyleList[e][t])o(watchStyleList[e][t][n],"style",t.toString())}if(watchPropertyObjects[e]){if(watchPropertyObjects[e].default)for(const t in watchPropertyObjects[e].default)o(watchPropertyObjects[e].default[t],"property");for(const t of n)if(watchPropertyObjects[e]?.[t])for(const n in watchPropertyObjects[e][t])o(watchPropertyObjects[e][t][n],"property",t.toString())}if(watchPositionObjects[e]){if(watchPositionObjects[e].default)for(const t in watchPositionObjects[e].default)o(watchPositionObjects[e].default[t],"position");for(const t of n)if(watchPositionObjects[e]?.[t])for(const n in watchPositionObjects[e][t])o(watchPositionObjects[e][t][n],"position",t.toString())}return t}let watchTimer=0;const watchTimerHandler=function(){if(getFocus$1){const t=getFocus$1();if(t){const e=getActivePanel(t);if(watchStyleList[t]){const n=(e,n,o)=>{if(!document.body.contains(e.el))return delete watchStyleList[t][n][o],Object.keys(watchStyleList[t][n]).length||delete watchStyleList[t][n],void(Object.keys(watchStyleList[t]).length||delete watchStyleList[t]);for(const t in e.names){if(e.sd[t]===e.names[t].val)continue;const n=e.names[t].val;e.names[t].val=e.sd[t];for(const o of e.names[t].cb)o(t,e.sd[t],n)}};if(watchStyleList[t].default)for(const e in watchStyleList[t].default)n(watchStyleList[t].default[e],"default",e);for(const o of e)if(watchStyleList[t][o])for(const e in watchStyleList[t][o])n(watchStyleList[t][o][e],o.toString(),e)}if(watchPropertyObjects[t]){const n=(e,n,o)=>{if(!document.body.contains(e.el))return delete watchPropertyObjects[t][n][o],Object.keys(watchPropertyObjects[t][n]).length||delete watchPropertyObjects[t][n],void(Object.keys(watchPropertyObjects[t]).length||delete watchPropertyObjects[t]);for(const t in e.names)if(e.el[t]!==e.names[t].val){e.names[t].val=e.el[t];for(const n of e.names[t].cb)n(t,e.el[t])}};if(watchPropertyObjects[t].default)for(const e in watchPropertyObjects[t].default)n(watchPropertyObjects[t].default[e],"default",e);for(const o of e)if(watchPropertyObjects[t][o])for(const e in watchPropertyObjects[t][o])n(watchPropertyObjects[t][o][e],o.toString(),e)}if(watchPositionObjects[t]){const n=(e,n,o)=>{if(!document.body.contains(e.el))return delete watchPositionObjects[t][n][o],Object.keys(watchPositionObjects[t][n]).length||delete watchPositionObjects[t][n],void(Object.keys(watchPositionObjects[t]).length||delete watchPositionObjects[t]);const r=e.el.getBoundingClientRect();let s=!1,i=!1;e.rect.left===r.left&&e.rect.top===r.top||(s=!0),e.rect.width===r.width&&e.rect.height===r.height||(i=!0),(s||i)&&e.handler({position:s,size:i}),watchPositionObjects[t][n][o].rect=r};if(watchPositionObjects[t].default)for(const e in watchPositionObjects[t].default)n(watchPositionObjects[t].default[e],"default",e);for(const o of e)if(watchPositionObjects[t][o])for(const e in watchPositionObjects[t][o])n(watchPositionObjects[t][o][e],o.toString(),e)}}}watchTimer=requestAnimationFrame(watchTimerHandler)};let is;function findParentByData(t,e,n){let o=t.parentNode;for(;o;){if(!o.tagName)continue;if("body"===o.tagName.toLowerCase())break;const t=o.getAttribute("data-"+e);if(null!==t){if(n){if(n===t)return o;continue}return o}o=o.parentNode}return null}function findParentByClass(t,e){let n=t.parentNode;for(;n;)if(n.tagName){if("body"===n.tagName.toLowerCase())break;if(n.classList.contains(e))return n;n=n.parentNode}return null}function findParentByTag(t,e){let n=t.parentNode;for(;n;){if(!n.tagName)continue;const t=n.tagName.toLowerCase();if("body"===t)break;if(t===e)return n;n=n.parentNode}return null}function index$1(t){let e=0,n=t.previousElementSibling;for(;n;)++e,n=n.previousElementSibling;return e}function siblings(t){if(!t.parentNode)return[];const e=[];for(let n=0;n<t.parentNode.children.length;++n){const o=t.parentNode.children.item(n);o!==t&&e.push(o)}return e}function siblingsData(t,e){const n=siblings(t),o=[];for(const t of n)null!==t.getAttribute("data-"+e)&&o.push(t);return o}async function fullscreen(){const t=document.getElementsByTagName("html")[0];return t.webkitRequestFullscreen?(await t.webkitRequestFullscreen(),!0):!!t.requestFullscreen&&(await t.requestFullscreen(),!0)}async function exitFullscreen(){const t=document;return t.webkitExitFullscreen?(await t.webkitExitFullscreen(),!0):!!t.exitFullscreen&&(await t.exitFullscreen(),!0)}function createElement(t){return document.createElement(t)}function getElementRPosition(t,e){const n=t.getBoundingClientRect(),o=e.getBoundingClientRect();return{left:n.left-o.left,top:n.top-o.top,width:n.width,height:n.height}}function getRectPoint(t,e,n){const o=getElementRPosition(t,e),r=o.left+o.width/2,s=o.top+o.height/2;switch(n){case"t":return{x:r,y:o.top};case"tr":return{x:o.left+o.width,y:o.top};case"r":return{x:o.left+o.width,y:s};case"rb":return{x:o.left+o.width,y:o.top+o.height};case"b":return{x:r,y:o.top+o.height};case"bl":return{x:o.left,y:o.top+o.height};case"l":return{x:o.left,y:s};case"lt":return{x:o.left,y:o.top};default:return{x:r,y:s}}}let micState=0,micWs=null;const blob=new Blob(["\nconst minRms = .2;\n\nclass MicrophoneProcessor extends AudioWorkletProcessor {\n constructor() {\n super();\n this.voice = false; // --- 当前是否是说话状态 ---\n this.voiceStart = 0; // --- 从静音到说话时的开始时间 ---\n this.voiceLast = 0; // --- 最后一次说话的时间 ---\n this.lastPost = 0; // --- 最后一次发送 buffer 的时间 ---\n }\n // --- 计算音频帧的平均音量(均方根) ---\n // --- 大于等于 minRms 代表可能在说话 ---\n calculateVolume(channel) {\n let sum = 0;\n for (let i = 0; i < channel.length; i++) {\n // --- 平方和 ---\n sum += channel[i] * channel[i];\n }\n // --- 均方根 ---\n const rms = Math.sqrt(sum / channel.length);\n return rms;\n }\n\n process(inputs, outputs) {\n // --- 获取输入音频数据(单声道) ---\n const input = inputs[0];\n const channel = input[0];\n const now = Date.now();\n \n // --- 计算当前帧的音量 ---\n const volume = this.calculateVolume(channel);\n this.port.postMessage({\n 'type': 'process',\n 'rms': volume,\n });\n if (volume > minRms) {\n this.voiceLast = now;\n }\n\n // --- 判断是否要发送 buffer ---\n if (this.voice) {\n // --- 说话中 ---\n if (volume >= minRms) {\n // --- 继续说话 ---\n }\n else {\n // --- 判断是否说话结束 ---\n if (now - this.voiceLast >= 1_000) {\n // --- 说话结束 ---\n this.voice = false;\n this.voiceStart = 0;\n this.port.postMessage({\n 'type': 'voice-end'\n });\n }\n // --- 不结束,等待到 1 秒观察 ---\n }\n }\n else {\n // --- 静音中 ---\n if (volume >= minRms) {\n // --- 判断是否要说话开始 ---\n if (this.voiceStart === 0) {\n this.voiceStart = now;\n }\n if (now - this.voiceStart >= 300) {\n // --- 说话开始 ---\n this.voice = true;\n this.port.postMessage({\n 'type': 'voice-start'\n });\n }\n // --- 不开始,等待到 300ms 观察 ---\n }\n else {\n // --- 当前没声音,判断是否是真的安静了 ---\n if (now - this.voiceLast > 300) {\n // --- 又安静了 ---\n this.voiceStart = 0;\n }\n }\n }\n\n if (\n (now - this.voiceLast >= 3_000) &&\n (now - this.lastPost < 15_000)\n ) {\n // --- 超过 3 秒没声音直接 buffer 都不发送 ---\n return true;\n }\n\n // --- 转换为 Int16 ---\n const output = new Int16Array(channel.length);\n for (let i = 0; i < channel.length; i++) {\n // --- 限制范围并转换 ---\n const sample = Math.max(-1, Math.min(1, channel[i]));\n output[i] = sample < 0 ? sample * 32768 : sample * 32767;\n }\n\n // --- 通过消息将处理后的数据发送到主线程 ---\n this.lastPost = now;\n this.port.postMessage(output.buffer, [output.buffer]);\n \n // --- 保持处理器运行 ---\n return true;\n }\n}\n\n// --- 注册处理器 ---\nregisterProcessor('microphone-processor', MicrophoneProcessor);\n"],{type:"application/javascript"}),micProcessor=URL.createObjectURL(blob),mic={start:async function(t,e={}){if(micState>0)return!0;micState=1;const n=e.rtn??=!0;try{const o=await navigator.mediaDevices.getUserMedia({audio:!0});micWs=new WebSocket(t),n&&(micWs.onmessage=async t=>{try{if(JSON.parse(t.data).result<=0)return void mic.stop();micState=2,await(e.onStart?.())}catch{mic.stop()}}),micWs.onopen=async()=>{n||(micState=2,await(e.onStart?.()))},micWs.onclose=()=>{micWs=null,micState=0};const r=new AudioContext({sampleRate:8e3}),s=r.createMediaStreamSource(o);await r.audioWorklet.addModule(micProcessor);const i=new AudioWorkletNode(r,"microphone-processor");return s.connect(i),i.connect(r.destination),i.port.onmessage=async t=>{if(!micWs){const t=o.getTracks();for(const e of t)e.stop();return await r.close(),i.port.close(),i.disconnect(),s.disconnect(),void await(e.onStop?.())}2===micState&&(micWs.readyState!==WebSocket.CLOSING&&micWs.readyState!==WebSocket.CLOSED?"voice-start"!==t.data.type?"voice-end"!==t.data.type?"process"!==t.data.type?micWs.send(t.data):await(e.onProcess?.({rms:t.data.rms})):await(e.onVoiceEnd?.()):await(e.onVoiceStart?.()):mic.stop())},!0}catch(t){return console.error("[LIB][DOM]",t),micState=0,!1}},stop:function(){micState=0,micWs&&micWs.close()}};let inited$2=!1;function init$3(){inited$2||(inited$2=!0,is=modules.vue.reactive({move:!1,shift:!1,ctrl:!1,meta:!1,full:!1,dark:window.matchMedia("(prefers-color-scheme: dark)").matches,keyboard:!1,transition:!0}),document.addEventListener("visibilitychange",function(){document.hidden?cancelAnimationFrame(watchTimer):watchTimer=requestAnimationFrame(watchTimerHandler)}),document.addEventListener("fullscreenchange",function(){document.webkitFullscreenElement||document.fullscreenElement?is.full=!0:is.full=!1}),window.addEventListener("keydown",function(t){switch(t.key){case"Shift":is.shift=!0;break;case"Control":is.ctrl=!0;break;case"Meta":is.meta=!0}trigger("keydown",t).catch(()=>{})}),window.addEventListener("keyup",function(t){switch(t.key){case"Shift":is.shift=!1;break;case"Control":is.ctrl=!1;break;case"Meta":is.meta=!1}trigger("keyup",t).catch(()=>{})}),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",t=>{is.dark=t.matches}),watchTimerHandler())}var dom=Object.freeze({__proto__:null,clearWatch:clearWatch,clearWatchPosition:clearWatchPosition,clearWatchProperty:clearWatchProperty,clearWatchSize:clearWatchSize,clearWatchStyle:clearWatchStyle,createElement:createElement,createToStyleList:createToStyleList,dpi:dpi,exitFullscreen:exitFullscreen,findParentByClass:findParentByClass,findParentByData:findParentByData,findParentByTag:findParentByTag,fullscreen:fullscreen,getElementRPosition:getElementRPosition,getRectPoint:getRectPoint,getStyleCount:getStyleCount,getWatchCount:getWatchCount,getWatchInfo:getWatchInfo,getWatchSizeCount:getWatchSizeCount,hues:hues,inPage:inPage,index:index$1,init:init$3,initSysId:initSysId$6,get is(){return is},isWatch:isWatch,isWatchPosition:isWatchPosition,isWatchProperty:isWatchProperty,isWatchSize:isWatchSize,isWatchStyle:isWatchStyle,mic:mic,pushStyle:pushStyle,removeFromStyleList:removeFromStyleList,removeStyle:removeStyle,setGlobalCursor:setGlobalCursor,setGlobalTransition:setGlobalTransition,siblings:siblings,siblingsData:siblingsData,unwatch:unwatch,unwatchPosition:unwatchPosition,unwatchSize:unwatchSize,watch:watch,watchPosition:watchPosition,watchProperty:watchProperty,watchSize:watchSize,watchStyle:watchStyle});class Zip{_zip;_path="/";constructor(t){this._zip=t,this._refreshList()}async getContent(t,e="string"){t=urlResolve(this._path,t);const n=this._zip.file(t.slice(1));return n?"string"===e?n.async("string"):n.async(e):null}putContent(t,e,n={}){t=urlResolve(this._path,t),this._zip.file(t.slice(1),e,{base64:n.base64,binary:n.binary,date:n.date}),this._refreshList()}unlink(t){t=urlResolve(this._path,t),this._zip.remove(t.slice(1)),this._refreshList()}stats(t){let e=(t=urlResolve(this._path,t)).endsWith("/")?t:t+"/";if(this._list[e]){if("/"===e)return{compressedSize:0,uncompressedSize:0,date:new Date,isFile:!1,isDirectory:!0};e=e.slice(0,-1);const t=e.lastIndexOf("/")+1,n=e.slice(0,t),o=e.slice(t);return{compressedSize:0,uncompressedSize:0,date:this._list[n][o].date,isFile:!1,isDirectory:!0}}{if(t.endsWith("/"))return null;const e=t.lastIndexOf("/")+1,n=t.slice(0,e),o=t.slice(e);if(!this._list[n])return null;const r=this._list[n][o];return r?{compressedSize:r.compressedSize,uncompressedSize:r.uncompressedSize,date:r.date,isFile:!0,isDirectory:!1}:null}}isDir(t){const e=this.stats(t);return!!e?.isDirectory&&e}isFile(t){const e=this.stats(t);return!!e?.isFile&&e}readDir(t,e={}){e.hasChildren??=!1,e.hasDir??=!0,e.pathAsKey??=!1,(t=t?urlResolve(this._path,t):this._path).endsWith("/")||(t+="/");if(!this._zip.folder(t.slice(1)))return e.pathAsKey?{}:[];if(!this._list[t])return e.pathAsKey?{}:[];if(!e.hasChildren){if(e.pathAsKey)return this._list[t];const n=[];for(const e in this._list[t])n.push(this._list[t][e]);return n}if(e.pathAsKey){const n={};for(const o in this._list[t]){const r=this._list[t][o];(r.isFile||e.hasDir)&&(n[r.path+r.name]=r),r.isDirectory&&Object.assign(n,this._readDir(r,{hasDir:e.hasDir,pathAsKey:e.pathAsKey}))}return n}{let n=[];for(const o in this._list[t]){const r=this._list[t][o];(r.isFile||e.hasDir)&&n.push(r),r.isDirectory&&(n=n.concat(this._readDir(r,{hasDir:e.hasDir,pathAsKey:e.pathAsKey})))}return n}}_readDir(t,e){if(e.pathAsKey){const n={};if(!this._list[t.path+t.name+"/"])return{};for(const o in this._list[t.path+t.name+"/"]){const r=this._list[t.path+t.name+"/"][o];(r.isFile||e.hasDir)&&(n[r.path+r.name]=r),r.isDirectory&&Object.assign(n,this._readDir(r,{hasDir:e.hasDir,pathAsKey:e.pathAsKey}))}return n}{let n=[];if(!this._list[t.path+t.name+"/"])return[];for(const o in this._list[t.path+t.name+"/"]){const r=this._list[t.path+t.name+"/"][o];(r.isFile||e.hasDir)&&n.push(r),r.isDirectory&&(n=n.concat(this._readDir(r,{hasDir:e.hasDir,pathAsKey:e.pathAsKey})))}return n}}_list={};_refreshList(){const t={};this._zip.forEach(function(e,n){e.startsWith("/")&&(e=e.slice(1));let o,r="/",s="";o=n.dir?e.slice(0,-1).lastIndexOf("/"):e.lastIndexOf("/"),-1!==o?(r="/"+e.slice(0,o+1),s=e.slice(o+1)):s=e,n.dir&&(s=s.slice(0,-1)),t[r]||(t[r]={}),t[r][s]={name:s,compressedSize:n._data.compressedSize??0,uncompressedSize:n._data.uncompressedSize??0,date:n.date,isFile:!n.dir,isDirectory:n.dir,path:r}}),this._list=t}pwd(){return this._path.slice(0,-1)}cd(t){return this._path=urlResolve(this._path,t),this._path.endsWith("/")||(this._path+="/"),this._path}generate(t={}){const e={};return void 0===t.type?e.type="blob":e.type=t.type,(void 0===t.level||t.level>9)&&(t.level=9),t.level>0&&(e.compression="DEFLATE"),this._zip.generateAsync(e,function(e){t.onUpdate?.(e.percent,e.currentFile)})}getList(){return new Promise(t=>{const e={},n=this.readDir("/",{hasChildren:!0,hasDir:!1});let o=0;for(const r of n){const s=getMimeByPath(r.name);["txt","json","js","css","xml","html"].includes(s.ext)?this.getContent(r.path+r.name,"string").then(function(s){s&&(e[r.path+r.name]=s),++o,o===n.length&&t(e)}).catch(function(){++o,o===n.length&&t(e)}):this.getContent(r.path+r.name,"arraybuffer").then(function(i){i&&(e[r.path+r.name]=new Blob([i],{type:s.mime})),++o,o===n.length&&t(e)}).catch(function(){++o,o===n.length&&t(e)})}return e})}}async function get$2(t){const e=modules.jszip();try{return t&&await e.loadAsync(t),new Zip(e)}catch{return null}}var zip=Object.freeze({__proto__:null,Zip:Zip,get:get$2});let sysId$6="";function initSysId$5(t){sysId$6||(sysId$6=t)}let global$1=null;async function read$1(t){const e=await get$2(t);if(!e)return!1;const n=await e.getContent("config.json");if(!n)return!1;const o=JSON.parse(n),r={},s=e.readDir("/",{hasChildren:!0});for(const t of s){const n=getMimeByPath(t.name);if(["txt","json","js","css","xml","html"].includes(n.ext)){const n=await e.getContent(t.path+t.name,"string");if(!n)continue;r[t.path+t.name]=n.replace(/^\ufeff/,"")}else{const o=await e.getContent(t.path+t.name,"arraybuffer");if(!o)continue;r[t.path+t.name]=new Blob([o],{type:n.mime})}}return{type:"theme",config:o,files:r}}async function load(t,e){"string"!=typeof t&&(t=t.taskId);const n=getOrigin(t);if(!n)return!1;const o=!e;if(n.customTheme&&o)return!0;if(!e){if(!global$1)return!0;e=global$1}let r=e.files[e.config.style+".css"];return!!r&&(r=stylePrepend(r,`cg-theme-task${t}-`).style,r=await styleUrl2DataUrl(e.config.style,r,e.files),r=r.replace(/\[CGTMP-GLOBAL\] +::selection/g,`#cg-form-list > [data-task-id="${t}"] ::selection, #cg-pop-list > [data-task-id="${t}"] ::selection`),r=r.replace(/\[CGTMP-GLOBAL\]/g,`#cg-form-list > [data-task-id="${t}"], #cg-pop-list > [data-task-id="${t}"]`),n.customTheme||(o||(n.customTheme=!0),removeStyle(t,"theme")),pushStyle(t,r,"theme",e.config.name),!0)}async function remove$1(t,e){"string"!=typeof t&&(t=t.taskId);const n=getOrigin(t);n&&n.customTheme&&(removeStyle(t,"theme",e),0===getStyleCount(t,"theme")&&(n.customTheme=!1,global$1&&await load(t)))}async function clear$1(t){"string"!=typeof t&&(t=t.taskId);const e=getOrigin(t);e&&e.customTheme&&(removeStyle(t,"theme"),e.customTheme=!1,global$1&&await load(t))}async function setGlobal(t,e=null){if("string"==typeof t){const n=await getContent(e,t+".cgt");if(!n)return 0;if("string"==typeof n)return-1;const o=await read$1(n);if(!o)return-2;t=o}global$1=t;const n=await getOriginList(sysId$6);for(const t in n)await load(t);return 1}async function clearGlobal(){if(!global$1)return;global$1=null;const t=await getOriginList(sysId$6);for(const e in t){const n=t[e];n.customTheme||removeStyle(n.id,"theme")}}function setMain(t,e){t?elements.wrap.style.setProperty("--main",t):elements.wrap.style.removeProperty("--main"),e?elements.wrap.style.setProperty("--main-hue",e.toString()):elements.wrap.style.removeProperty("--main-hue")}var theme=Object.freeze({__proto__:null,clear:clear$1,clearGlobal:clearGlobal,get global(){return global$1},initSysId:initSysId$5,load:load,read:read$1,remove:remove$1,setGlobal:setGlobal,setMain:setMain});let sysId$5="";function initSysId$4(t){sysId$5||(sysId$5=t)}function isSys(t){return t===sysId$5}let index=-1;const list$1={},runtime={};function getRuntime(t,e){return"string"!=typeof t&&(t=t.taskId),isSys(t)?runtime[e]:null}async function getOriginList(t){if("string"!=typeof t&&(t=t.taskId),isSys(t))return list$1;if(!list$1[t])return{};return(await checkPermission(t,"root"))[0]?list$1:{}}const getRetry={hour:"",count:0};function get$1(t){"string"!=typeof t&&(t=t.taskId);const e=getOrigin(t);return e?{name:e.app.config.name,locale:e.locale.lang,customTheme:e.customTheme,formCount:Object.keys(e.forms).length,icon:e.app.icon,path:e.path,current:e.current}:null}function getOrigin(t){if("string"!=typeof t&&(t=t.taskId),!list$1[t]){const t=new Date,e=`${t.getUTCFullYear()}${t.getUTCMonth().toString().padStart(2,"0")}${t.getUTCDate().toString().padStart(2,"0")}${t.getUTCHours().toString().padStart(2,"0")}`;if(getRetry.hour!==e)getRetry.hour=e,getRetry.count=0;else if(++getRetry.count,getRetry.count>10){const t=new Error(`task.get retry, ${e}: ${getRetry.count}`);trigger("error","","",t,t.message).catch(()=>{})}return null}return list$1[t]}let focusId=null;function setFocus(t){return t?!!list$1[t]&&(focusId=t,!0):(focusId=null,!0)}async function getFocus(t){if("string"!=typeof t&&(t=t.taskId),isSys(t))return focusId;if(!list$1[t])return null;return(await checkPermission(t,"root"))[0]?focusId:null}const localeData$2={en:{loading:"Loading..."},sc:{loading:"加载中……"},tc:{loading:"載入中……"},ja:{loading:"読み込み中..."},ko:{loading:"로딩 중..."},th:{loading:"กำลังโหลด..."},es:{loading:"Cargando..."},de:{loading:"Laden..."},fr:{loading:"Chargement en cours..."},pt:{loading:"Carregando..."},ru:{loading:"Загрузка..."},vi:{loading:"Đang tải..."}};let frameTimer=0;const frameMaps={};function onFrame(t,e,n={}){"string"!=typeof t&&(t=t.taskId);const o=n.formId;if(!t)return 0;const r=list$1[t];if(!r)return 0;if(o&&!r.forms[o])return 0;const s=++frameTimer,i=n.count??0;let a,c=0;const l=async()=>{if(++c,o&&void 0===r.forms[o])return delete r.timers["1x"+s.toString()],void delete frameMaps[s];if(await e(),null!=r.timers["1x"+s.toString()])if(i>1){if(c===i)return delete r.timers["1x"+s.toString()],void delete frameMaps[s];a=requestAnimationFrame(function(){l().catch(()=>{})}),frameMaps[s]=a}else 1===i?(delete r.timers["1x"+s.toString()],delete frameMaps[s]):(a=requestAnimationFrame(function(){l().catch(()=>{})}),frameMaps[s]=a)};return a=requestAnimationFrame(function(){l().catch(()=>{})}),frameMaps[s]=a,r.timers["1x"+s.toString()]=o??"",s}function offFrame(t,e){if("string"!=typeof t&&(t=t.taskId),!list$1[t])return;void 0!==list$1[t].timers["1x"+e.toString()]&&(cancelAnimationFrame(frameMaps[e]),delete list$1[t].timers["1x"+e.toString()],delete frameMaps[e])}function getPermissions(t){return"string"!=typeof t&&(t=t.taskId),void 0===list$1[t]?[]:clone(runtime[t].permissions)}function getList(){const t=[];for(const e in list$1){const n=list$1[e];t.push({name:n.app.config.name,locale:n.locale.lang,customTheme:n.customTheme,formCount:Object.keys(n.forms).length,icon:n.app.icon,path:n.path,current:n.current})}return t}var EIPTYPE;async function run(t,e,n={}){if("string"!=typeof t&&(t=t.taskId),!isSys(t)&&!list$1[t])return 0;let o="Load app ...";await(n.initProgress?.(0,7,EIPTYPE.APP,o));let r=getDirname()+"/icon.png";n.icon&&(r=n.icon),n.notify??=!0;const s=n.notify?notify({title:localeData$2[config.locale]?.loading??localeData$2.en.loading,content:"string"==typeof e?e:e.config.name,note:o,icon:r,timeout:0,progress:!0}):void 0;let i=null;if("string"==typeof e){if(!e.endsWith(".cga"))return s&¬ifyContent(s,{note:"Error -1",timeout:3e3}),-1;e.startsWith("/clickgo/")||e.startsWith("/storage/")||e.startsWith("/mounted/")||e.startsWith("/package/")||e.startsWith("/current/")||(e=urlResolve(location.href,e)),i=await fetchApp(t,e,{notify:{id:s,loaded:0,total:7},progress:async(t,o,r)=>{await(n.progress?.(t,o,"app",e)),await(n.perProgress?.(r))},after:n.after})}else{if("app"!==e.type)return s&¬ifyContent(s,{note:"Error -2",timeout:3e3}),-2;i=e}if(!i)return s&¬ifyContent(s,{note:"Error -3",timeout:3e3}),-3;let a="";do{a=random(8,RANDOM_LUN)}while(list$1[a]);const c=n.path??("string"==typeof e?e:"/runtime/"+random(16,RANDOM_LN)+".cga"),l=c.lastIndexOf("/"),d=c.slice(0,l);list$1[a]={id:a,app:i,class:null,customTheme:!1,locale:modules.vue.reactive({lang:"",data:{}}),path:c,current:d,forms:{},controls:{},timers:{},threads:{}};let f=n.permissions??[];if((await checkPermission(t,"root"))[0]||(f=[]),runtime[a]=modules.vue.reactive({dialogFormIds:[],permissions:f,index:++index}),i.config.locales)for(let t in i.config.locales){const e=i.config.locales[t];t.endsWith(".json")||(t+=".json"),o=`Load local '${t}' ...`,await(n.initProgress?.(1,7,EIPTYPE.LOCAL,o));const r=1/7;await(n.perProgress?.(r)),s&¬ifyContent(s,{note:o,progress:r});const c=await getContent(a,t,{encoding:"utf8"});if(c)try{loadLocaleData(a,e,JSON.parse(c),"")}catch{}}let u=[];try{if(i.config.modules?.length)for(const t of i.config.modules)if(!modules[t]&&checkModule(t)&&!await loadModule(t))return s&¬ifyContent(s,{note:"Error -4",timeout:3e3}),-4;const t=i.files["/app.js"];if("string"!=typeof t)return s&¬ifyContent(s,{note:"Error -5",timeout:3e3}),-5;let e=!0;if(stateMachine(t,0,t=>t.state!==ESTATE.WORD||(!["eval","Function"].includes(t.word)||(notify({title:"Error",content:`The "${t.word}" is prohibited.\nFile: "${c}".`,type:"danger"}),e=!1,!1))),!e)return s&¬ifyContent(s,{note:"Error -6",timeout:3e3}),-6;if(u=runIife(t),!u)return s&¬ifyContent(s,{note:"Error -7",timeout:3e3}),-7}catch(t){return delete list$1[a],trigger("error",a,"",t,t.message+"(-1)").catch(()=>{}),s&¬ifyContent(s,{note:"Error -8",timeout:3e3}),-8}createToStyleList(a),o="Control initialization ...",await(n.initProgress?.(2,7,EIPTYPE.CONTROL,o));const m=2/7;await(n.perProgress?.(m)),s&¬ifyContent(s,{note:o,progress:2/7});const h=await init(a,{progress:async(t,e,o)=>{await(n.progress?.(t,e,"control",o));let r=t/e;r=Math.min(2/7+1/7*r,1),await(n.perProgress?.(r)),s&¬ifyContent(s,{note:"Loaded "+o,progress:r})}});if(h<0)return removeFromStyleList(a),delete list$1[a],s&¬ifyContent(s,{note:"Error "+(-900+h).toString(),timeout:3e3}),-900+h;if(i.config.themes?.length)for(let t of i.config.themes){t+=".cgt",t=urlResolve("/",t),o=`Load theme '${t}' ...`,await(n.initProgress?.(3,7,EIPTYPE.THEME,o));const e=3/7;await(n.perProgress?.(e)),s&¬ifyContent(s,{note:o,progress:e});const r=await getContent(a,t);if(r&&"string"!=typeof r){const t=await read$1(r);t&&await load(a,t)}}else if(global$1){o="Load global theme ...",await(n.initProgress?.(3,7,EIPTYPE.THEME,o));const t=3/7;await(n.perProgress?.(t)),s&¬ifyContent(s,{note:o,progress:t}),await load(a)}if(i.config.style){const t=await getContent(a,i.config.style+".css",{encoding:"utf8"});if(t){const e=stylePrepend(t,"cg-task"+a.toString()+"_");o="Style initialization ...",await(n.initProgress?.(4,7,EIPTYPE.STYLE,o));const r=4/7;await(n.perProgress?.(r)),s&¬ifyContent(s,{note:o,progress:r}),pushStyle(a,await styleUrl2DataUrl(i.config.style,e.style,i.files))}}if(trigger("taskStarted",a).catch(()=>{}),i.config.permissions){o="Permission initialization ...",await(n.initProgress?.(5,7,EIPTYPE.PERMISSION,o));const t=5/7;await(n.perProgress?.(t)),s&¬ifyContent(s,{note:o,progress:t}),await checkPermission(a,i.config.permissions,!0,void 0)}const g=new u;g.filename=c,g.taskId=a,list$1[a].class=g,o="Starting ...",await(n.initProgress?.(6,7,EIPTYPE.START,o));const p=6/7;await(n.perProgress?.(p)),s&¬ifyContent(s,{note:o,progress:p}),await g.main(n.data??{}),o="Done.",await(n.initProgress?.(7,7,EIPTYPE.DONE,o));return await(n.perProgress?.(1)),s&¬ifyContent(s,{note:o,progress:1,timeout:3e3}),a}!function(t){t[t.APP=0]="APP",t[t.LOCAL=1]="LOCAL",t[t.CONTROL=2]="CONTROL",t[t.THEME=3]="THEME",t[t.STYLE=4]="STYLE",t[t.PERMISSION=5]="PERMISSION",t[t.START=6]="START",t[t.DONE=7]="DONE"}(EIPTYPE||(EIPTYPE={}));const locale={sc:{unknown:"未知权限",root:"<b>危险!</b>最高权限!请一定确认是否允许!","apply-permission":"正在申请权限,请您仔细确认","native.form":"实体窗体控制",hash:"可修改地址栏 hash",fs:"文件系统",readonly:"只读","read-write":"读写"},tc:{unknown:"未知許可權",root:"<b>危險!</b>最高許可權!請一定確認是否允許!","apply-permission":"正在申請許可權,請您仔細確認","native.form":"實體視窗控制",hash:"可修改位址列 hash",fs:"檔案系統",readonly:"唯讀","read-write":"讀寫"},en:{unknown:"Unknown",root:"<b>Danger!</b> Highest permission! Please confirm if you want to allow!","apply-permission":"Applying permission, please confirm carefully","native.form":"Native window control",hash:'Can modify address bar "hash"',fs:"File system",readonly:"Read-only","read-write":"Read and write"},ja:{unknown:"不明な権限",root:"<b>危険!</b>最高権限です!許可するかどうか必ず確認してください!","apply-permission":"権限を申請中です。よくご確認ください","native.form":"ネイティブフォームコントロール",hash:'アドレスバーの "hash" を変更できます',fs:"ファイルシステム",readonly:"読み取り専用","read-write":"読み書き可能"},ko:{unknown:"알 수 없는 권한",root:"<b>위험!</b> 최고 권한입니다! 반드시 허용할 것인지 확인하십시오!","apply-permission":"권한을 신청 중입니다. 주의 깊게 확인하십시오","native.form":"네이티브 폼 제어",hash:'주소 표시 줄 "hash" 를 수정할 수 있습니다',fs:"파일 시스템",readonly:"읽기 전용","read-write":"읽기 및 쓰기"},th:{unknown:"สิทธิ์ที่ไม่รู้จัก",root:"<b>อันตราย!</b> สิทธิ์สูงสุด! โปรดตรวจสอบว่าต้องการอนุญาตหรือไม่!","apply-permission":"กำลังขอสิทธิ์ โปรดตรวจสอบอย่างรอบคอบ","native.form":"การควบคุมแบบฟอร์มแบบ Native",hash:'สามารถแก้ไขแถบที่อยู่ "hash"',fs:"ระบบไฟล์",readonly:"อ่านได้อย่างเดียว","read-write":"อ่านและเขียนได้"},es:{unknown:"Permiso desconocido",root:"<b>¡Peligro!</b> ¡Permiso máximo! ¡Asegúrese de permitirlo!","apply-permission":"Solicitando permiso. Por favor, compruebe cuidadosamente","native.form":"Control de formulario nativo",hash:'Puede modificar el "hash" de la barra de direcciones',fs:"Sistema de archivos",readonly:"Solo lectura","read-write":"Lectura y escritura"},de:{unknown:"Unbekannte Berechtigung",root:"<b>Gefahr!</b> Höchste Berechtigung! Bitte stellen Sie unbedingt sicher, ob dies erlaubt ist!","apply-permission":"Bitte bestätigen Sie die Berechtigungsanfrage sorgfältig","native.form":"Natives Formularsteuerelement",hash:'Adressleisten "hash" bearbeiten',fs:"Dateisystem",readonly:"Schreibgeschützt","read-write":"Lesen/Schreiben"},fr:{unknown:"Autorisation inconnue",root:"<b>Danger !</b> Autorisation maximale ! Veuillez vous assurer que vous êtes autorisé à le faire !","apply-permission":"Demande d'autorisation en cours, veuillez vérifier attentivement","native.form":"Contrôle de formulaire natif",hash:'Modifier le "hash" de la barre d\'adresse',fs:"Système de fichiers",readonly:"Lecture seule","read-write":"Lecture/écriture"},pt:{unknown:"Permissão desconhecida",root:"<b>Perigo!</b> Permissão máxima! Certifique-se de ter permissão para fazê-lo!","apply-permission":"Solicitando permissão, por favor confirme cuidadosamente","native.form":"Controle de formulário nativo",hash:'Editar "hash" da barra de endereço',fs:"Sistema de arquivos",readonly:"Somente leitura","read-write":"Leitura/escrita"},ru:{unknown:"Неизвестное разрешение",root:"<b>Опасность!</b> Максимальное разрешение! Пожалуйста, обязательно убедитесь, что это разрешено!","apply-permission":"Выполняется запрос на разрешение, пожалуйста, внимательно подтвердите","native.form":"Нативный элемент формы",hash:'Изменить "hash" адресной строки',fs:"Файловая система",readonly:"Только для чтения","read-write":"Чтение/запись"},vi:{unknown:"Quyền không xác định",root:"<b>Nguy hiểm!</b> Quyền hạn cao nhất! Hãy đảm bảo rằng bạn được phép làm điều này!","apply-permission":"Đang yêu cầu quyền truy cập, vui lòng xác nhận cẩn thận","native.form":"Thiết bị kiểm soát biểu mẫu gốc",hash:'Chỉnh sửa "hash" thanh địa chỉ',fs:"Hệ thống tập tin",readonly:"Chỉ đọc","read-write":"Đọc/ghi"}};async function checkPermission(t,e,n=!1,o){if("string"!=typeof t&&(t=t.taskId),"string"==typeof e&&(e=[e]),isSys(t))return new Array(e.length).fill(!0);const r=list$1[t];if(!r)return new Array(e.length).fill(!1);const s=[],i=[];for(const o of e){if(runtime[t].permissions.includes("root")){s.push(!0);continue}if(o.startsWith("fs.")){let e=!1;const r=o.slice(3,-1);for(const n of runtime[t].permissions){if(!n.startsWith("fs."))continue;const t=n.slice(3,-1);if(t.endsWith("/")){if(!r.startsWith(t))continue}else if(t!==r)continue;if(!o.endsWith("w")||!n.endsWith("r")){e=!0;break}}s.push(e),!e&&n&&i.push(o);continue}const e=runtime[t].permissions.includes(o);!e&&n&&i.push(o),s.push(e)}if(i.length){let e='<div>"'+escapeHTML(r.app.config.name)+'" '+(locale[config.locale]?.["apply-permission"]??locale.en["apply-permission"])+":</div>";for(const t of i){if(t.startsWith("fs.")){const n=t.slice(3,-1);e+='<div style="margin-top: 10px;">'+(locale[config.locale]?.fs??locale.en.fs)+" "+escapeHTML(n)+" "+(t.endsWith("r")?locale[config.locale]?.readonly??locale.en.readonly:locale[config.locale]?.["read-write"]??locale.en["read-write"])+'<div style="color: hsl(0,0%,60%);">'+escapeHTML(t)+"</div></div>";continue}e+='<div style="margin-top: 10px;">'+(locale[config.locale]?.[t]??locale.en[t]??locale[config.locale]?.unknown??locale.en.unknown)+'<div style="color: hsl(0,0%,60%);">'+escapeHTML(t)+"</div></div>"}if(await superConfirm(sysId$5,e)){for(let t=0;t<s.length;++t)s[t]||(s[t]=!0);for(const e of i)runtime[t].permissions.push(e);try{await(o?.(i))}catch{}}}return s}async function end(t){"string"!=typeof t&&(t=t.taskId);const e=list$1[t];if(!e)return!0;isNative()&&1===Object.keys(list$1).length&&await close$1(sysId$5);for(const e in list$1[t].threads)await list$1[t].threads[e].end();const n=await getMaxZIndexID(sysId$5,{taskIds:[t]});await changeFocus(n??void 0);for(const n in e.forms){const o=e.forms[n];trigger("formRemoved",t,o.id,o.vroot.$refs.form.title,o.vroot.$refs.form.iconDataUrl).catch(()=>{});try{o.vapp.unmount()}catch(t){notify({title:"Form Unmount Error",content:`Message: ${t.message}\nTask id: ${e.id}\nForm id: ${n}\nFunction: task.end, unmount.`,type:"danger"})}o.vapp._container.remove(),elements.popList.querySelector('[data-form-id="'+o.id.toString()+'"]')?.remove(),clearWatchStyle(n),clearWatchProperty(n),clearWatchPosition(n),delete activePanels[n]}const o=elements.list.querySelectorAll('.cg-form-wrap[data-task-id="'+t.toString()+'"]');for(const t of o)t.remove();removeFromStyleList(t);for(const e in list$1[t].timers)if(e.startsWith("1x")){const t=e.slice(2);cancelAnimationFrame(frameMaps[t]),delete frameMaps[t]}else clearTimeout(parseFloat(e));return clearWatchSize(t),clearWatch(t),clear$2(t),delete list$1[t],delete runtime[t],trigger("taskEnded",t).catch(()=>{}),await clearSystem(t),!0}function loadLocaleData(t,e,n,o=""){if("string"!=typeof t&&(t=t.taskId),t){list$1[t].locale.data[e]||(list$1[t].locale.data[e]={});for(const r in n){const s=n[r];"object"==typeof s?loadLocaleData(t,e,s,o+r+"."):list$1[t].locale.data[e][o+r]=s}}}async function loadLocale(t,e,n){"string"!=typeof t&&(t=t.taskId);const o=list$1[t];if(!o)return!1;const r=await getContent(t,n+".json",{encoding:"utf8"});if(!r)return!1;try{const t=JSON.parse(r);return loadLocaleData(o.id,e,t,""),!0}catch{return!1}}function clearLocale(t){"string"!=typeof t&&(t=t.taskId);const e=list$1[t];e&&(e.locale.data={})}function setLocale(t,e,n){return clearLocale(t),loadLocale(t,e,n)}function setLocaleLang(t,e){"string"!=typeof t&&(t=t.taskId);const n=list$1[t];n&&(n.locale.lang=e)}function clearLocaleLang(t){"string"!=typeof t&&(t=t.taskId);const e=list$1[t];e&&(e.locale.lang="")}function createTimer(t,e,n,o={}){"string"!=typeof t&&(t=t.taskId);const r=o.formId,s=list$1[t];if(!s)return 0;if(r&&!s.forms[r])return 0;const i=o.count??0;let a,c=0;if(o.immediate){const t=e();if(t instanceof Promise&&t.catch(()=>{}),++c,i>0&&c===i)return 0}const l=()=>{if(++c,r&&void 0===s.forms[r])return clearTimeout(a),void delete s.timers[a];const t=e();return t instanceof Promise&&t.catch(()=>{}),i>0&&c===i?(clearTimeout(a),void delete s.timers[a]):void 0};return a=1===i?window.setTimeout(l,n):window.setInterval(l,n),s.timers[a]=r??"",a}function removeTimer(t,e){if("string"!=typeof t&&(t=t.taskId),!list$1[t])return;void 0!==list$1[t].timers[e]&&(clearTimeout(e),delete list$1[t].timers[e])}function sleep(t,e,n){return createTimer(t,e,n,{count:1})}const systemTaskInfoOrigin={taskId:"",formId:"",length:0};let systemTaskInfo;function setSystem(t,e){"string"!=typeof t&&(t=t.taskId);const n=list$1[t];if(!n)return!1;const o=n.forms[e];return!!o&&(void 0===o.vroot.position?(notify({title:"Warning",content:`Task id is "${t}" app is not an available task app, position not found.`,type:"warning"}),!1):(systemTaskInfo.taskId&¬ify({title:"Info",content:"More than 1 system-level task application is currently running.",type:"info"}),systemTaskInfo.taskId=t,systemTaskInfo.formId=e,simpleSystemTaskRoot.forms={},refreshSystemPosition(),!0))}async function clearSystem(t){if("string"!=typeof t&&(t=t.taskId),systemTaskInfo.taskId!==t)return!1;systemTaskInfo.taskId="",systemTaskInfo.formId="",systemTaskInfo.length=0,trigger("screenResize").catch(()=>{});const e=await getOriginList(sysId$5);for(const t in e){const e=getList$1(t);for(const t in e){const n=e[t];n.stateMin&&(simpleSystemTaskRoot.forms[t]={title:n.title,icon:n.icon})}}return!0}function refreshSystemPosition(){if(systemTaskInfo.taskId){const t=list$1[systemTaskInfo.taskId].forms[systemTaskInfo.formId];switch(config["task.position"]){case"left":case"right":t.vroot.$refs.form.setPropData("width",0),t.vroot.$refs.form.setPropData("height",window.innerHeight);break;case"top":case"bottom":t.vroot.$refs.form.setPropData("width",window.innerWidth),t.vroot.$refs.form.setPropData("height",0)}setTimeout(function(){switch(config["task.position"]){case"left":systemTaskInfo.length=t.vroot.$el.offsetWidth,t.vroot.$refs.form.setPropData("left",0),t.vroot.$refs.form.setPropData("top",0);break;case"right":systemTaskInfo.length=t.vroot.$el.offsetWidth,t.vroot.$refs.form.setPropData("left",window.innerWidth-systemTaskInfo.length),t.vroot.$refs.form.setPropData("top",0);break;case"top":systemTaskInfo.length=t.vroot.$el.offsetHeight,t.vroot.$refs.form.setPropData("left",0),t.vroot.$refs.form.setPropData("top",0);break;case"bottom":systemTaskInfo.length=t.vroot.$el.offsetHeight,t.vroot.$refs.form.setPropData("left",0),t.vroot.$refs.form.setPropData("top",window.innerHeight-systemTaskInfo.length)}trigger("screenResize").catch(()=>{})},50)}else trigger("screenResize").catch(()=>{})}let inited$1=!1;function init$2(){inited$1||(inited$1=!0,systemTaskInfo=modules.vue.reactive({taskId:"",formId:"",length:0}),modules.vue.watch(systemTaskInfo,function(){for(const t in systemTaskInfoOrigin)void 0===systemTaskInfo[t]&&(notify({title:"Warning",content:"There is a software that maliciously removed the system task info item.\nKey: "+t,type:"warning"}),systemTaskInfo[t]=systemTaskInfoOrigin[t]??0);for(const t in systemTaskInfo)Object.keys(systemTaskInfoOrigin).includes(t)?typeof systemTaskInfo[t]!=typeof systemTaskInfoOrigin[t]&&(notify({title:"Warning",content:"There is a software that maliciously modifies the system task info item.\nKey: "+t,type:"warning"}),systemTaskInfo[t]=systemTaskInfoOrigin[t]):(notify({title:"Warning",content:"There is a software that maliciously modifies the system task info item.\nKey: "+t,type:"warning"}),delete systemTaskInfo[t])},{deep:!0}))}class AbstractThread{get filename(){return""}taskId="";onMessage(){}onEnded(){}onError(){}send(t){self.postMessage(t)}close(){self.postMessage({cmd:"cg-terminate"})}}function runThread(t,e,n){"string"!=typeof t&&(t=t.taskId);const o=getOrigin(t);if(!o){const t=new Error("task.runThread: -1");throw trigger("error","","",t,t.message).catch(()=>{}),t}let r=e.toString();r=r.replace(/class (\w+) extends.+?AbstractThread *{/,"class cgCustomThread extends AbstractThread {");const s=/filename *\(\) *{ *return *"(.+?)"/.exec(r);if(!s){const t=new Error("task.runThread: -2");throw trigger("error","","",t,t.message).catch(()=>{}),t}if(o.threads[s[1]])return o.threads[s[1]];const i=new Blob([`${AbstractThread.toString()}\n${r}\nconst threadCls = new cgCustomThread();\nthreadCls.taskId = '${o.id}';\nself.onmessage = async function(e) {\n if (e.data.cmd === 'cg-init') {\n await threadCls.main(e.data.data);\n return;\n }\n if (e.data.cmd === 'cg-terminate') {\n await threadCls.onEnded();\n self.postMessage({\n 'cmd': 'cg-terminate',\n });\n return;\n }\n threadCls.onMessage(e);\n}\nself.onerror = function(e) {\n threadCls.onError(e);\n}\n`],{type:"application/javascript"}),a=URL.createObjectURL(i),c=new Worker(a);URL.revokeObjectURL(a),c.postMessage({cmd:"cg-init",data:n??{}});const l=[];c.onmessage=t=>{if("cg-terminate"===t.data.cmd)return c.terminate(),void delete o.threads[s[1]];for(const e of l)e(t)};const d={on:(t,e)=>{"message"===t&&l.push(e)},off:(t,e)=>{if("message"!==t)return;const n=l.indexOf(e);-1!==n&&l.splice(n,1)},send:t=>{c.postMessage(t)},end:()=>new Promise(t=>{c.postMessage({cmd:"cg-terminate"}),c.onmessage=()=>{t(),c.terminate(),delete o.threads[s[1]]}})};return o.threads[s[1]]=d,d}var task=Object.freeze({__proto__:null,AbstractThread:AbstractThread,get EIPTYPE(){return EIPTYPE},checkPermission:checkPermission,clearLocale:clearLocale,clearLocaleLang:clearLocaleLang,clearSystem:clearSystem,createTimer:createTimer,end:end,get:get$1,getFocus:getFocus,getList:getList,getOrigin:getOrigin,getOriginList:getOriginList,getPermissions:getPermissions,getRuntime:getRuntime,init:init$2,initSysId:initSysId$4,loadLocale:loadLocale,loadLocaleData:loadLocaleData,offFrame:offFrame,onFrame:onFrame,refreshSystemPosition:refreshSystemPosition,removeTimer:removeTimer,run:run,runThread:runThread,setFocus:setFocus,setLocale:setLocale,setLocaleLang:setLocaleLang,setSystem:setSystem,sleep:sleep,get systemTaskInfo(){return systemTaskInfo}});let sysId$4="";function initSysId$3(t){sysId$4||(sysId$4=t)}const clickgoFiles=["/app/","/app/demo.cga","/app/task.cga","/control/","/control/arteditor.cgc","/control/box.cgc","/control/captcha.cgc","/control/common.cgc","/control/cube.cgc","/control/desc.cgc","/control/drawer.cgc","/control/echarts.cgc","/control/fabric.cgc","/control/form.cgc","/control/iconview.cgc","/control/jodit.cgc","/control/map.cgc","/control/marked.cgc","/control/monaco.cgc","/control/mpegts.cgc","/control/nav.cgc","/control/novnc.cgc","/control/objviewer.cgc","/control/page.cgc","/control/pdf.cgc","/control/property.cgc","/control/qrcode.cgc","/control/table.cgc","/control/task.cgc","/control/tplink.cgc","/control/tuieditor.cgc","/control/tuiviewer.cgc","/control/tums.cgc","/control/waterfall.cgc","/control/web.cgc","/control/xterm.cgc","/ext/","/ext/toastui-editor-all.min.js","/ext/tplinkhd.min.js","/ext/tums-player/","/ext/tums-player/audio.wasm","/ext/tums-player/decoder.worker.js","/ext/tums-player/libaudio.js","/ext/tums-player/libaudio.wasm","/ext/tums-player/libffmpeg.js","/ext/tums-player/libffmpeg.wasm","/ext/tums-player/libs.worker.js","/ext/tums-player/tums-player.umd.min.js","/ext/tums-player/webgl.js","/ext/tums-player/webgl.worker.js","/global.css","/icon.png","/index.js","/notosans-regular.ttf","/theme/","/theme/admin.cgt","/theme/cyber.cgt","/theme/dark.cgt","/theme/light.cgt","/theme/modern.cgt"],localeData$1={en:{"apply-unmount":'Are you sure to unmount the "?" mount point?'},sc:{"apply-unmount":"确定卸载“?”挂载点吗?"},tc:{"apply-unmount":"確定卸載「?」掛載點嗎?"},ja:{"apply-unmount":"「?」マウントポイントをアンマウントしてよろしいですか?"},ko:{"apply-unmount":'"?" 마운트 지점을 언마운트하시겠습니까?'},th:{"apply-unmount":'คุณแน่ใจหรือว่าต้องการยกเลิกการติดตั้งจุดติดตั้ง "?"'},es:{"apply-unmount":'¿Está seguro de que desea desmontar el punto de montaje "?"'},de:{"apply-unmount":'Möchten Sie den Einhängepunkt "?" wirklich demontieren?'},fr:{"apply-unmount":'Voulez-vous vraiment démonter le point de montage "?"'},pt:{"apply-unmount":'Tem certeza de que deseja desmontar o ponto de montagem "?"'},ru:{"apply-unmount":'Вы уверены, что хотите отмонтировать точку монтирования "?"'},vi:{"apply-unmount":'Bạn có chắc chắn muốn tháo dỡ điểm gắn "?" không?'}},mounts={};function getMountName(t){const e=t.slice(9).indexOf("/");return-1===e?t.slice(9):t.slice(9,e+9)}function mount(t,e,n){if("string"!=typeof t&&(t=t.taskId),mounts[e])return!1;if(!/^[a-zA-Z][\w]+$/.test(e))return!1;if(t!==sysId$4&&getOrigin(t)){const n="fs./mounted/"+e+"/w",o=getRuntime(sysId$4,t);o&&(o.permissions.includes(n)||o.permissions.push(n))}return n.date=new Date,mounts[e]=n,!0}async function unmount(t){if(!mounts[t])return!0;const e=localeData$1[config.locale]?.["apply-unmount"]??localeData$1.en["apply-unmount"];return!!await superConfirm(sysId$4,e.replace("?","/mount/"+escapeHTML(t)+"/"))&&(delete mounts[t],!0)}async function getContent(t,e,n){t&&"string"!=typeof t&&(t=t.taskId);const o=(e=urlResolve("/",e)).slice(8);"string"==typeof n?n={encoding:n}:n??={};const r=n.encoding,s=n.start,i=n.end;if(!(e.startsWith("/clickgo/")||e.startsWith("http:")||e.startsWith("https:")||e.startsWith("file:"))){if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!t)return null;if(!(await checkPermission(t,"fs."+e+"r",!1,void 0))[0])return null;if(e.startsWith("/mounted/")){const t=getMountName(e),o=mounts[t];return o?o.getContent?.(e.slice(9+t.length),n)??null:null}n.progress&&delete n.progress;const r=await invokeSys(sysId$4,"cg-fs-getContent",o,n);return r?"string"==typeof r?r:new Blob([r],{type:getMimeByPath(e).mime}):null}if(e.startsWith("/package/")||e.startsWith("/current/")){if(!t)return null;const r=getOrigin(t);if(!r)return null;if(e.startsWith("/current/"))return getContent(t,r.current+o,n);const a=r.app.files[o];if(!a)return null;if("string"==typeof a)return a;if(!n.encoding)return void 0===s&&void 0===i?a:a.slice(s,i,a.type);const c=n.encoding;return new Promise(function(t){const e=new FileReader;e.addEventListener("load",function(){t(e.result)}),e.readAsText(a,c)})}return null}{let t="";if(e.startsWith("/clickgo/")){if(!clickgoFiles.includes(o))return null;t=getDirname()+o}else t=e+(n.after??"");try{let e=null;const o={};return(s??i)&&(o.range=`bytes=${s??"0"}-${i??""}`),e=n.progress?await request(t,{headers:o,progress:n.progress,responseType:"blob"}):await(await fetch(t,{headers:o})).blob(),e?r?await new Promise(function(t){const n=new FileReader;n.addEventListener("load",function(){t(n.result)}),n.readAsText(e,r)}):e:null}catch{return null}}}async function putContent(t,e,n,o={}){"string"!=typeof t&&(t=t.taskId);const r=(e=urlResolve("/",e)).slice(8);if(e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!(await checkPermission(t,"fs."+e+"w",!1,void 0))[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e),r=mounts[t];return!!r&&(r.putContent?.(e.slice(9+t.length),n,o)??!1)}let s;return n instanceof Blob&&(s=new Uint8Array(await n.arrayBuffer())),invokeSys(sysId$4,"cg-fs-putContent",r,s??n,o)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const e=getOrigin(t);return!!e&&putContent(t,e.current+r,n,o)}return!1}async function readLink(t,e,n){"string"!=typeof t&&(t=t.taskId);const o=(e=urlResolve("/",e)).slice(8);if(e.startsWith("/clickgo/"))return null;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!(await checkPermission(t,"fs."+e+"r",!1))[0])return null;if(e.startsWith("/mounted/")){const t=getMountName(e),o=mounts[t];return o?o.readLink?.(e.slice(9+t.length),n)??null:null}return invokeSys(sysId$4,"cg-fs-readLink",o,n)}if(e.startsWith("/package/"))return null;if(e.startsWith("/current/")){const e=getOrigin(t);return e?e.current:null}return null}async function symlink(t,e,n,o){if("string"!=typeof t&&(t=t.taskId),e=urlResolve("/",e),n=urlResolve("/",n),e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!(await checkPermission(t,"fs."+e+"w",!1))[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e);if(t!==getMountName(n))return!1;const r=mounts[t];return!!r&&(r.symlink?.(e.slice(9+t.length),n.slice(9+t.length),o)??!1)}return invokeSys(sysId$4,"cg-fs-symlink",e.slice(8),n.slice(8),o)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const r=getOrigin(t);return!!r&&(n.startsWith("/current/")&&(n=r.current+n.slice(8)),symlink(t,r.current+e.slice(8),n,o))}return!1}async function unlink(t,e){"string"!=typeof t&&(t=t.taskId);const n=(e=urlResolve("/",e)).slice(8);if(e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!(await checkPermission(t,"fs."+e+"w",!1))[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e),n=mounts[t];return!!n&&(n.unlink?.(e.slice(9+t.length))??!1)}return invokeSys(sysId$4,"cg-fs-unlink",n)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const e=getOrigin(t);return!!e&&unlink(t,e.current+n)}return!1}async function getClickGoStats(t){if(t.endsWith("/")){const t=new Date,e=t.getTime();return{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},size:0,blksize:0,atimeMs:e,mtimeMs:e,ctimeMs:e,birthtimeMs:e,atime:t,mtime:t,ctime:t,birthtime:t}}try{const e=await fetch(getDirname()+t,{headers:{range:"bytes=0-1"}}),n=e.headers.get("date"),o=e.headers.get("last-modified");let r=e.headers.get("content-range");if(r){const t=r.lastIndexOf("/");r=r.slice(t+1)}let s=new Date,i=s;n&&(s=new Date(n)),o&&(i=new Date(o));const a=s.getTime(),c=i.getTime();return{isFile:function(){return!0},isDirectory:function(){return!1},isSymbolicLink:function(){return!1},size:r?parseInt(r):0,blksize:r?parseInt(r):0,atimeMs:a,mtimeMs:c,ctimeMs:c,birthtimeMs:a,atime:s,mtime:i,ctime:i,birthtime:s}}catch{return null}}async function stats(t,e){if("string"!=typeof t&&(t=t.taskId),(e=urlResolve("/",e)).endsWith("/")&&(e=e.slice(0,-1)),["","/clickgo","/storage","/mounted","/package"].includes(e)){const t=new Date,e=t.getTime();return{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},size:0,blksize:0,atimeMs:e,mtimeMs:e,ctimeMs:e,birthtimeMs:e,atime:t,mtime:t,ctime:t,birthtime:t}}if("/current"===e){const t=new Date,e=t.getTime();return{isFile:function(){return!1},isDirectory:function(){return!1},isSymbolicLink:function(){return!0},size:0,blksize:0,atimeMs:e,mtimeMs:e,ctimeMs:e,birthtimeMs:e,atime:t,mtime:t,ctime:t,birthtime:t}}let n=e.slice(8);if(e.startsWith("/clickgo/")){if(!clickgoFiles.includes(n)){if(!clickgoFiles.includes(n+"/"))return null;n+="/"}return getClickGoStats(n)}if(e.startsWith("/storage/")){if(!(await checkPermission(t,"fs."+e+"r",!1))[0])return null;const o=await invokeSys(sysId$4,"cg-fs-stats",n);return o?{isFile:function(){return o.isFile},isDirectory:function(){return o.isDirectory},isSymbolicLink:function(){return o.isSymbolicLink},size:o.size,blksize:o.blksize,atimeMs:o.atimeMs,mtimeMs:o.mtimeMs,ctimeMs:o.ctimeMs,birthtimeMs:o.birthtimeMs,atime:o.atime,mtime:o.mtime,ctime:o.ctime,birthtime:o.birthtime}:null}if(e.startsWith("/mounted/")){const n=getMountName(e),o=mounts[n];if(!o)return null;if(e==="/mounted/"+n){const t=o.date.getTime();return{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},size:0,blksize:0,atimeMs:t,mtimeMs:t,ctimeMs:t,birthtimeMs:t,atime:o.date,mtime:o.date,ctime:o.date,birthtime:o.date}}return(await checkPermission(t,"fs."+e+"r",!1))[0]?o.stats?.(e.slice(9+n.length))??null:null}if(e.startsWith("/package/")||e.startsWith("/current/")){const o=getOrigin(t);if(!o)return null;if(e.startsWith("/current/"))return stats(t,o.current+n);if(o.app.files[n]){const t=o.app.files[n],e=new Date,r=e.getTime();let s=0;return s="string"!=typeof t?t.size:new Blob([t]).size,{isFile:function(){return!0},isDirectory:function(){return!1},isSymbolicLink:function(){return!1},size:s,blksize:s,atimeMs:r,mtimeMs:r,ctimeMs:r,birthtimeMs:r,atime:e,mtime:e,ctime:e,birthtime:e}}n.endsWith("/")||(n+="/");for(const t in o.app.files){if(!t.startsWith(n))continue;const e=new Date,o=e.getTime();return{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},size:0,blksize:0,atimeMs:o,mtimeMs:o,ctimeMs:o,birthtimeMs:o,atime:e,mtime:e,ctime:e,birthtime:e}}return null}return null}async function isDir(t,e){const n=await stats(t,e);return!!n?.isDirectory()&&n}async function isFile(t,e){const n=await stats(t,e);return!!n?.isFile()&&n}async function mkdir(t,e,n=493){if("string"!=typeof t&&(t=t.taskId),e=urlResolve("/",e),await isDir(t,e))return!0;const o=e.slice(8);if(e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!(await checkPermission(t,"fs."+e+"w",!1))[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e),o=mounts[t];return!!o&&(o.mkdir?.(e.slice(9+t.length),n)??!1)}return invokeSys(sysId$4,"cg-fs-mkdir",o,n)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const e=getOrigin(t);return!!e&&mkdir(t,e.current+o,n)}return!1}async function rmdir(t,e){"string"!=typeof t&&(t=t.taskId);const n=(e=urlResolve("/",e)).slice(8);if(e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!(await checkPermission(t,"fs."+e+"w",!1))[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e),n=mounts[t];return!!n&&(n.rmdir?.(e.slice(9+t.length))??!1)}return invokeSys(sysId$4,"cg-fs-rmdir",n)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const e=getOrigin(t);return!!e&&rmdir(t,e.current+n)}return!1}async function rmdirDeep(t,e){"string"!=typeof t&&(t=t.taskId),(e=urlResolve("/",e)).endsWith("/")||(e+="/");const n=await readDir(t,e);for(const o of n){const n=await stats(t,e+o.name);if(!n)return!1;if(n.isDirectory()){if(!await rmdirDeep(t,e+o.name))return!1}else{if(!await unlink(t,e+o.name))return!1}}return rmdir(t,e)}async function chmod(t,e,n){"string"!=typeof t&&(t=t.taskId);const o=(e=urlResolve("/",e)).slice(8);if(e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){if(!(await checkPermission(t,"fs."+e+"w",!1))[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e),o=mounts[t];return!!o&&(o.chmod?.(e.slice(9+t.length),n)??!1)}return invokeSys(sysId$4,"cg-fs-chmod",o,n)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const e=getOrigin(t);return!!e&&chmod(t,e.current+o,n)}return!1}async function rename(t,e,n){if("string"!=typeof t&&(t=t.taskId),e=urlResolve("/",e),n=urlResolve("/",n),!e.startsWith(n.slice(0,9)))return!1;const o=e.slice(8),r=n.slice(8);if(e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||e.startsWith("/mounted/")){let s=await checkPermission(t,"fs."+e+"w",!1);if(!s[0])return!1;if(s=await checkPermission(t,"fs."+n+"w",!1,void 0),!s[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e);if(t!==getMountName(n))return!1;const o=mounts[t];return!!o&&(o.rename?.(e.slice(9+t.length),n.slice(9+t.length))??!1)}return invokeSys(sysId$4,"cg-fs-rename",o,r)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const e=getOrigin(t);return!!e&&rename(t,e.current+o,e.current+r)}return!1}async function readDir(t,e,n){if("string"!=typeof t&&(t=t.taskId),"/"===(e=urlResolve("/",e))){return[{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},name:"clickgo"},{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},name:"storage"},{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},name:"mounted"},{isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},name:"package"},{isFile:function(){return!1},isDirectory:function(){return!1},isSymbolicLink:function(){return!0},name:"current"}]}e.endsWith("/")||(e+="/");const o=e.slice(8);if(e.startsWith("/clickgo/")){const t=[];for(const e of clickgoFiles){if(!e.startsWith(o))continue;if(o===e)continue;const n=e.slice(o.length);if(n.includes("/")){if(n.endsWith("/")){if(n.slice(0,-1).includes("/"))continue;t.push({isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},name:n.slice(0,-1)})}}else t.push({isFile:function(){return!0},isDirectory:function(){return!1},isSymbolicLink:function(){return!1},name:n})}return t}if(e.startsWith("/storage/")||e.startsWith("/mounted/")){const r=[];if("/mounted/"===e){for(const t in mounts)r.push({isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},name:t});return r}if(!(await checkPermission(t,"fs."+e+"r",!1))[0])return[];if(e.startsWith("/mounted/")){const t=getMountName(e),o=mounts[t];return o?o.readDir?.(e.slice(9+t.length),n)??[]:[]}const s=await invokeSys(sysId$4,"cg-fs-readDir",o,n);for(const t of s)r.push({isFile:function(){return t.isFile},isDirectory:function(){return t.isDirectory},isSymbolicLink:function(){return t.isSymbolicLink},name:t.name});return r}if(e.startsWith("/package/")||e.startsWith("/current/")){const r=getOrigin(t);if(!r)return[];if(e.startsWith("/current/"))return readDir(t,r.current+o,n);const s=[],i=[];for(const t in r.app.files){if(!t.startsWith(o))continue;const e=t.slice(o.length),n=e.indexOf("/");if(-1!==n){const t=e.slice(0,n);i.includes(t)||(i.push(t),s.push({isFile:function(){return!1},isDirectory:function(){return!0},isSymbolicLink:function(){return!1},name:t}));continue}s.push({isFile:function(){return!0},isDirectory:function(){return!1},isSymbolicLink:function(){return!1},name:e})}return s}return[]}async function copyFolder(t,e,n,o=[]){"string"!=typeof t&&(t=t.taskId);let r=0;if(!await isDir(t,e))return 0;const s=await readDir(t,e);let i=!1;for(const a of s)if(a.isDirectory()){const s=await copyFolder(t,e+a.name+"/",n+a.name+"/",o);if(-1===s)return s;r+=s}else if(a.isFile()){if(o.length>0&&match(a.name,o))continue;if(!i){if(!await mkdir(t,n))return-1;i=!0}if(!await copyFile(t,e+a.name,n+a.name))continue;++r}return r}async function copyFile(t,e,n){if("string"!=typeof t&&(t=t.taskId),e=urlResolve("/",e),n=urlResolve("/",n),!e.startsWith(n.slice(0,9)))return!1;const o=e.slice(8),r=n.slice(8);if(e.startsWith("/clickgo/"))return!1;if(e.startsWith("/storage/")||n.startsWith("/mounted/")){let s=await checkPermission(t,"fs."+e+"r",!1);if(!s[0])return!1;if(s=await checkPermission(t,"fs."+n+"w",!1),!s[0])return!1;if(e.startsWith("/mounted/")){const t=getMountName(e);if(t!==getMountName(n))return!1;const o=mounts[t];return!!o&&(o.copyFile?.(e.slice(9+t.length),n.slice(9+t.length))??!1)}return invokeSys(sysId$4,"cg-fs-copyFile",o,r)}if(e.startsWith("/package/"))return!1;if(e.startsWith("/current/")){const e=getOrigin(t);return!!e&©File(t,e.current+o,e.current+r)}return!1}var fs=Object.freeze({__proto__:null,chmod:chmod,copyFile:copyFile,copyFolder:copyFolder,getContent:getContent,initSysId:initSysId$3,isDir:isDir,isFile:isFile,mkdir:mkdir,mount:mount,putContent:putContent,readDir:readDir,readLink:readLink,rename:rename,rmdir:rmdir,rmdirDeep:rmdirDeep,stats:stats,symlink:symlink,unlink:unlink,unmount:unmount});let sysId$3="";function initSysId$2(t){sysId$3||(sysId$3=t)}const configOrigin={locale:"en","task.position":"bottom","task.pin":{},"desktop.icon.storage":!0,"desktop.icon.recycler":!0,"desktop.wallpaper":null,"desktop.path":null,"launcher.list":[]};let config,boot;class AbstractApp{filename="";taskId="";async run(t){await t.show()}onError(){}onScreenResize(){}onConfigChanged(){}onFormCreated(){}onFormRemoved(){}onFormTitleChanged(){}onFormIconChanged(){}onFormStateMinChanged(){}onFormStateMaxChanged(){}onFormShowChanged(){}onFormFocused(){}onFormBlurred(){}onFormFlash(){}onFormShowInSystemTaskChange(){}onFormHashChange(){}onTaskStarted(){}onTaskEnded(){}onLauncherFolderNameChanged(){}onHashChanged(){}onKeydown(){}onKeyup(){}}function setBoot(t){boot||(t.setSysId(sysId$3),boot=t)}const globalEvents={screenResize:function(){refreshMaxPosition()},formRemoved:function(t,e){simpleSystemTaskRoot.forms[e]&&delete simpleSystemTaskRoot.forms[e]},formTitleChanged:function(t,e,n){simpleSystemTaskRoot.forms[e]&&(simpleSystemTaskRoot.forms[e].title=n)},formIconChanged:function(t,e,n){simpleSystemTaskRoot.forms[e]&&(simpleSystemTaskRoot.forms[e].icon=n)},formStateMinChanged:function(t,e,n){if(!systemTaskInfo.taskId)if(n){const t=get$3(e);if(!t)return;simpleSystemTaskRoot.forms[e]={title:t.title,icon:t.icon}}else{if(!simpleSystemTaskRoot.forms[e])return;delete simpleSystemTaskRoot.forms[e]}}};async function trigger(t,e="",n="",o="",r="",s=!0){const i=await getOriginList(sysId$3),a="on"+t[0].toUpperCase()+t.slice(1);switch(t){case"error":boot?.[a](e,n,o,r);for(const t in i){const s=i[t],c=getRuntime(sysId$3,t);if(!e||e===t||c?.permissions.includes("root")){s.class?.[a](e,n,o,r);for(const t in s.forms)s.forms[t].vroot[a]?.(e,n,o,r)}}break;case"screenResize":globalEvents.screenResize(),boot?.[a]();for(const t in i){const e=i[t];e.class?.[a]();for(const t in e.forms)e.forms[t].vroot[a]?.()}break;case"configChanged":boot?.[a]();for(const t in i){const o=i[t];o.class?.[a](e,n);for(const t in o.forms)o.forms[t].vroot[a]?.(e,n)}break;case"formCreated":case"formRemoved":globalEvents[t]?.(e,n,o,r,s),boot?.[a](e,n,o,r,s);for(const t in i){const c=i[t],l=getRuntime(sysId$3,t);if(e===t||l?.permissions.includes("root")){c.class?.[a](e,n,o,r,s);for(const t in c.forms)c.forms[t].vroot[a]?.(e,n,o,r,s)}}break;case"formTitleChanged":case"formIconChanged":globalEvents[t]?.(e,n,o),boot?.[a](e,n,o);for(const t in i){const r=i[t],s=getRuntime(sysId$3,t);if(e===t||s?.permissions.includes("root")){r.class?.[a](e,n,o);for(const t in r.forms)r.forms[t].vroot[a]?.(e,n,o)}}break;case"formStateMinChanged":case"formStateMaxChanged":case"formShowChanged":globalEvents[t]?.(e,n,o),boot?.[a](e,n,o);for(const t in i){const r=i[t],s=getRuntime(sysId$3,t);if(e===t||s?.permissions.includes("root")){r.class?.[a](e,n,o);for(const t in r.forms)r.forms[t].vroot[a]?.(e,n,o)}}break;case"formFocused":case"formBlurred":case"formFlash":globalEvents[t]?.(e,n),boot?.[a](e,n);for(const t in i){const o=i[t],r=getRuntime(sysId$3,t);if(e===t||r?.permissions.includes("root")){o.class?.[a](e,n);for(const t in o.forms)o.forms[t].vroot[a]?.(e,n)}}break;case"formShowInSystemTaskChange":globalEvents[t]?.(e,n,o),boot?.[a](e,n,o);for(const t in i){const r=i[t],s=getRuntime(sysId$3,t);if(e===t||s?.permissions.includes("root")){r.class?.[a](e,n,o);for(const t in r.forms)r.forms[t].vroot[a]?.(e,n,o)}}break;case"formHashChange":globalEvents[t]?.(e,n,o,r),boot?.[a](e,n,o,r);for(const t in i){const s=i[t],c=getRuntime(sysId$3,t);if(e===t||c?.permissions.includes("root")){s.class?.[a](e,n,o,r);for(const t in s.forms)s.forms[t].vroot[a]?.(e,n,o,r)}}break;case"taskStarted":case"taskEnded":globalEvents[t]?.(e,n),boot?.[a](e,n);for(const t in i){const n=i[t],o=getRuntime(sysId$3,t);if(e===t||o?.permissions.includes("root")){n.class?.[a](e);for(const t in n.forms)n.forms[t].vroot[a]?.(e)}}break;case"launcherFolderNameChanged":boot?.[a](e,n);for(const t in i){const o=i[t];o.class?.[a](e,n);for(const t in o.forms)o.forms[t].vroot[a]?.(e,n)}break;case"hashChanged":boot?.[a](e);for(const t in i){const n=i[t];n.class?.[a](e);for(const t in n.forms)n.forms[t].vroot[a]?.(e)}break;case"keydown":case"keyup":globalEvents[t]?.(e),boot?.[a](e);for(const t in i){const n=i[t];n.class?.[a](e);for(const t in n.forms)n.forms[t].vroot[a]?.(e)}}}async function readApp(t){if("-CGA-"!==await blob2Text(t.slice(0,5)))return!1;const e=parseInt(await t.slice(21,28).text());if(Number.isNaN(e))return!1;const n=e?await blob2DataUrl(t.slice(28,28+e)):"",o=new Blob([t.slice(5,21),t.slice(28+e)],{type:t.type}),r=await get$2(o);if(!r)return!1;const s={},i=await r.getContent("/config.json");if(!i)return!1;const a=JSON.parse(i),c=r.readDir("/",{hasChildren:!0});for(const t of c){const e=getMimeByPath(t.name);if(["txt","json","js","css","xml","html"].includes(e.ext)){const e=await r.getContent(t.path+t.name,"string");if(!e)continue;s[t.path+t.name]=e.replace(/^\ufeff/,"")}else{const n=await r.getContent(t.path+t.name,"arraybuffer");if(!n)continue;s[t.path+t.name]=new Blob([n],{type:e.mime})}}return{type:"app",config:a,files:s,icon:n}}async function fetchApp(t,e,n={}){const o=n.notify?"number"==typeof n.notify?{id:n.notify,loaded:0,total:0}:n.notify:{id:void 0,loaded:0,total:0},r=o.id,s=o.loaded??0,i=o.total??0;if(!e.endsWith(".cga"))return null;e.startsWith("/clickgo/")||e.startsWith("/storage/")||e.startsWith("/mounted/")||e.startsWith("/package/")||e.startsWith("/current/")||e.startsWith("http:")||e.startsWith("https:")||e.startsWith("file:")||(e=urlResolve(window.location.href,e));try{const o=await getContent(t,e,{progress:(t,e)=>{let o=t/e;o=i?Math.min(s/i+1/i*o,1):o,r&¬ifyProgress(r,o),n.progress&&n.progress(t,e,o)},after:n.after});return null===o||"string"==typeof o?null:(r&¬ifyProgress(r,i?(s+1)/i:1),await readApp(o)||null)}catch{return null}}function getAvailArea(){if(Object.keys(simpleSystemTaskRoot.forms).length>0)return{left:0,top:0,width:window.innerWidth,height:window.innerHeight-46,owidth:window.innerWidth,oheight:window.innerHeight};{let t=0,e=0,n=0,o=0;switch(config["task.position"]){case"left":t=systemTaskInfo.length,e=0,n=window.innerWidth-systemTaskInfo.length,o=window.innerHeight;break;case"right":t=0,e=0,n=window.innerWidth-systemTaskInfo.length,o=window.innerHeight;break;case"top":t=0,e=systemTaskInfo.length,n=window.innerWidth,o=window.innerHeight-systemTaskInfo.length;break;case"bottom":t=0,e=0,n=window.innerWidth,o=window.innerHeight-systemTaskInfo.length}return{left:t,top:e,width:n,height:o,owidth:window.innerWidth,oheight:window.innerHeight}}}async function hash(t,e){"string"!=typeof t&&(t=t.taskId);return!!(await checkPermission(t,"hash"))[0]&&(window.location.hash=e,!0)}function getHash(){return window.location.hash?decodeURIComponent(window.location.hash.slice(1)):""}function getHost(){const t=/https?:\/\/([-a-zA-Z0-9:.]+)/.exec(window.location.href);return t?t[1]:""}async function location$1(t,e){"string"!=typeof t&&(t=t.taskId);return!!(await checkPermission(t,"location"))[0]&&(window.location.href=e,!0)}function getLocation(){return window.location.href}async function back(t){"string"!=typeof t&&(t=t.taskId);return!!(await checkPermission(t,"location"))[0]&&(window.history.back(),!0)}function open(t){window.open(t)}window.addEventListener("hashchange",function(){trigger("hashChanged",window.location.hash?decodeURIComponent(window.location.hash.slice(1)):"").catch(()=>{})});const modules$1={"monaco-editor":{func:async function(){return new Promise(t=>{fetch(getCdn()+"/npm/monaco-editor@0.52.2/min/vs/loader.js").then(t=>t.blob()).then(t=>blob2DataUrl(t)).then(e=>{t(e)}).catch(()=>{t(null)})})},loading:!1,resolve:[]},xterm:{func:async function(){if(await loadScripts([`${getCdn()}/npm/xterm@5.3.0/lib/xterm.js`,`${getCdn()}/npm/xterm-addon-fit@0.8.0/lib/xterm-addon-fit.js`,`${getCdn()}/npm/xterm-addon-webgl@0.16.0/lib/xterm-addon-webgl.js`]),!window.Terminal)throw Error("Xterm load failed.");return await loadLinks([`${getCdn()}/npm/xterm@5.3.0/css/xterm.min.css`]),loadStyle(".xterm-viewport::-webkit-scrollbar{display:none;}"),{Terminal:window.Terminal,FitAddon:window.FitAddon.FitAddon,WebglAddon:window.WebglAddon.WebglAddon}},loading:!1,resolve:[]},echarts:{func:async function(){if(await loadScript(`${getCdn()}/npm/echarts@6.0.0/dist/echarts.min.js`),!window.echarts)throw Error("Echarts load failed.");return window.echarts},loading:!1,resolve:[]},"@toast-ui/editor":{func:async function(){if(await loadScripts([urlResolve(getDirname()+"/","./ext/toastui-editor-all.min.js")]),!window.toastui.Editor)throw Error("Tuieditor load failed.");return await loadScripts([`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/zh-cn.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/zh-tw.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/ja-jp.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/ko-kr.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/es-es.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/de-de.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/fr-fr.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/pt-br.min.js`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/i18n/ru-ru.min.js`]),await loadLinks([`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/toastui-editor.min.css`,`${getCdn()}/npm/@toast-ui/editor@3.2.2/dist/theme/toastui-editor-dark.css`]),loadStyle(".toastui-editor-defaultUI-toolbar,.ProseMirror{box-sizing:initial !important}.toastui-editor-main{background:var(--g-plain-background);border-radius:0 0 3px 3px}.ProseMirror{cursor:text}.jodit ::-webkit-scrollbar{width:6px;cursor:default;}.jodit ::-webkit-scrollbar-thumb{background:rgba(0,0,0,.1);border-radius:3px;}.jodit ::-webkit-scrollbar-thumb:hover{background: rgba(0,0,0,.2);}"),window.toastui},loading:!1,resolve:[]},jodit:{func:async function(){return await loadScripts([`${getCdn()}/npm/jodit@4.2.27/es2015/jodit.fat.min.js`]),await loadLinks([`${getCdn()}/npm/jodit@4.2.27/es2015/jodit.fat.min.css`]),loadStyle(".jodit-container:not(.jodit_inline){border:none;display:flex;flex-direction:column;}.jodit-container:not(.jodit_inline) .jodit-workplace{cursor:text;flex:1;}.jodit-wysiwyg a{color:unset;}"),window.Jodit},loading:!1,resolve:[]},fabric:{func:async function(){if(await loadScripts([`${getCdn()}/npm/fabric@7.2.0/dist/index.min.js`]),!window.fabric)throw Error("fabric load failed.");return window.fabric},loading:!1,resolve:[]},pdfjs:{func:async function(){try{const t=await import(`${getCdn()}/npm/pdfjs-dist@5.4.54/+esm`);return t.GlobalWorkerOptions.workerSrc=`${getCdn()}/npm/pdfjs-dist@5.4.54/build/pdf.worker.min.mjs`,t}catch{throw Error("pdf.js load failed.")}},loading:!1,resolve:[]},qrcode:{func:async function(){if(await loadScripts([`${getCdn()}/npm/qrcode@1.5.1/build/qrcode.js`]),!window.QRCode)throw Error("QRCode load failed.");return window.QRCode},loading:!1,resolve:[]},mpegts:{func:async function(){if(await loadScripts([`${getCdn()}/npm/mpegts.js@1.7.3/dist/mpegts.min.js`]),!window.mpegts)throw Error("mpegts load failed.");return window.mpegts.LoggingControl.enableAll=!1,window.mpegts},loading:!1,resolve:[]},tplinkhd:{func:async function(){if(await loadScripts([`${getDirname()}/ext/tplinkhd.min.js`]),!window.HDPluginControl)throw Error("Tplink load failed.");return window.HDPluginControl},loading:!1,resolve:[]},"tums-player":{func:async function(){if(await loadScripts([`${getDirname()}/ext/tums-player/tums-player.umd.min.js`]),!window["tums-player"])throw Error("Tums load failed.");const t=document.createElement("div");t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.width="200px",t.style.height="100px",document.body.appendChild(t);const e=window["tums-player"].default;let n=null;return{default:e,startTalk:o=>new Promise(r=>{n&&(n.stopVoiceIntercom(),n.destroy(),n=null),n=new e(t,{type:"relay",url:"none",pluginPath:getDirname()+"/ext",talkEnable:!0,appKey:o.sid,appSecret:o.skey}),n.on("ready",()=>{n.startVoiceIntercom({url:o.url,mode:o.mode}),r()})}),stopTalk:()=>{n&&(n.stopVoiceIntercom(),n.destroy(),n=null)}}},loading:!1,resolve:[]},tjcaptcha:{func:async function(){if(await loadScripts(["https://turing.captcha.qcloud.com/TJCaptcha.js"]),!window.TencentCaptcha)throw Error("TJCaptcha load failed.");return window.TencentCaptcha},loading:!1,resolve:[]},turnstile:{func:async function(){if(await loadScripts(["https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit"]),!window.turnstile)throw Error("cft load failed.");return window.turnstile},loading:!1,resolve:[]},"@novnc/novnc":{version:"1.6.0",loading:!1,resolve:[]},marked:{func:async function(){if(await loadScripts([`${getCdn()}/npm/marked@17.0.0/lib/marked.umd.min.js`]),!window.marked)throw Error("marked load failed.");return window.marked},loading:!1,resolve:[]},"pdf-lib":{func:async function(){if(await loadScripts([`${getCdn()}/npm/pdf-lib@1.17.1/dist/pdf-lib.min.js`]),!window.PDFLib)throw Error("pdf-lib load failed.");return window.PDFLib},loading:!1,resolve:[]}};async function regModule(t,e,n){return!!(await checkPermission(t,"root"))[0]&&(!modules$1[e]&&(!modules[e]&&(modules$1[e]={version:n.version,func:n.func,loading:!1,resolve:[]},!0)))}function checkModule(t){return void 0!==modules$1[t]}async function getModule(t){return await loadModule(t)?modules[t]:null}async function loadModule(t){if(!modules$1[t])return!1;if(modules[t])return!0;try{if(modules$1[t].loading)return await new Promise(e=>{modules$1[t].resolve.push(()=>{e()})}),!0;if(modules$1[t].loading=!0,modules$1[t].version){const e=await import(`${getCdn()}/npm/${t}@${modules$1[t].version}/+esm`);modules[t]=e}if(modules$1[t].func){const e=await modules$1[t].func();modules[t]=e}modules$1[t].loading=!1;for(const e of modules$1[t].resolve)e();return modules$1[t].resolve.length=0,!0}catch{return!1}}let inited=!1;function init$1(){inited||(inited=!0,config=modules.vue.reactive({locale:lang.getCodeByAccept(),"task.position":"bottom","task.pin":{},"desktop.icon.storage":!0,"desktop.icon.recycler":!0,"desktop.wallpaper":null,"desktop.path":null,"launcher.list":[]}),modules.vue.watch(config,async function(){for(const t in configOrigin)void 0===config[t]&&(notify({title:"Warning",content:"There is a software that maliciously removed the system config item.\nKey: "+t,type:"warning"}),config[t]=configOrigin[t]);for(const t in config)if(Object.keys(configOrigin).includes(t))if("task.pin"===t){if(Object.keys(config["task.pin"]).sort().toString()===Object.keys(configOrigin["task.pin"]).sort().toString())continue;configOrigin["task.pin"]={};for(const t in config["task.pin"])configOrigin["task.pin"][t]=config["task.pin"][t];await trigger("configChanged","task.pin",config["task.pin"])}else{if(config[t]===configOrigin[t])continue;configOrigin[t]=config[t],"task.position"===t&&refreshSystemPosition(),await trigger("configChanged",t,config[t])}else notify({title:"Warning",content:"There is a software that maliciously modifies the system config.\nKey: "+t,type:"warning"}),delete config[t]},{deep:!0}),window.addEventListener("resize",function(){refreshSystemPosition()}))}var core=Object.freeze({__proto__:null,AbstractApp:AbstractApp,back:back,checkModule:checkModule,get config(){return config},fetchApp:fetchApp,getAvailArea:getAvailArea,getHash:getHash,getHost:getHost,getLocation:getLocation,getModule:getModule,hash:hash,init:init$1,initSysId:initSysId$2,loadModule:loadModule,location:location$1,open:open,readApp:readApp,regModule:regModule,setBoot:setBoot,trigger:trigger});let sysId$2="";function initSysId$1(t){sysId$2||(sysId$2=t)}class AbstractControl{get filename(){return""}get findex(){return 0}get controlName(){return""}get taskId(){return""}get formId(){return""}get path(){return""}get prep(){return""}get element(){return this.$el}_rootForm=null;get rootForm(){return this._rootForm||(this._rootForm=this.parentByName("root"),this._rootForm||notify({title:"Error",content:`The "rootForm" is not ready yet.\nFile: "${this.controlName}".`,type:"danger"})),this._rootForm}_rootControl=null;get rootControl(){return this._rootControl}get formFocus(){return this.rootForm?.formFocus??!1}get locale(){const t=getOrigin(this.taskId);return logicalOr(t?.locale.lang??"",config.locale)}get l(){return(t,e)=>{const n=this.localeData?.[this.locale][t]??"[LocaleError]"+t;if(!e)return n;let o=-1;return n.replace(/\?/g,function(){return++o,e[o]?e[o]:""})}}get fl(){return(t,e)=>t.startsWith("l:")?this.rootForm.l(t.slice(2),e,!0):t}get classPrepend(){return t=>"string"!=typeof t?t:t.startsWith("fa-")?`${t}`:`cg-theme-task${this.taskId}-${this.controlName}_${t}${this.prep?" "+this.prep+t:""}`}get alignHComp(){if(this.props.alignH){switch(this.props.alignH){case"center":return"center";case"left":case"start":return"flex-start"}return"flex-end"}}get alignVComp(){if(this.props.alignV){switch(this.props.alignV){case"center":return"center";case"top":case"start":return"flex-start"}return"flex-end"}}watch(t,e,n={}){return this.$watch(t,e,n)}get refs(){return this.$refs}get nextTick(){return this.$nextTick}allowEvent(t){return modules.pointer.allowEvent(t)}async trigger(t,e="",n=""){["formTitleChanged","formIconChanged","formStateMinChanged","formStateMaxChanged","formShowChanged"].includes(t)&&await trigger(t,this.taskId,this.formId,e,n)}packageFiles={};props={};emits={};slots={};get slotsAll(){return t=>{if(!this.slots[t])return[];const e=this.slots[t](),n=[];for(const t of e)if(t.props)n.push(t);else if("string"!=typeof t.children&&t.children.length)for(const e of t.children)n.push(e);return n}}get propBoolean(){return t=>getBoolean(this.props[t])}get propNumber(){return t=>getNumber(this.props[t])}get propInt(){return t=>Math.round(this.propNumber(t))}get propArray(){return t=>getArray(this.props[t])}emit(t,...e){this.$emit(t,...e)}get parent(){return this.$parent}get parentByName(){return t=>{let e=this.$parent;for(;;){if(!e)return null;if(e.controlName===t)return e;e=e.$parent}}}get parentByAccess(){return(t,e)=>{let n=this.$parent;for(;;){if(!n)return null;if(n.access){if(n.access[t]===e)return n;n=n.$parent}else n=n.$parent}}}onBeforeCreate(){}onCreated(){}onBeforeMount(){}onMounted(){}onBeforeUpdate(){}onUpdated(){}onBeforeUnmount(){}onUnmounted(){}}async function read(t){const e=await get$2(t);if(!e)return!1;const n={},o=e.readDir("/");for(const t of o){if(t.isFile)continue;const o=await e.getContent("/"+t.name+"/config.json");if(!o){notify({title:"Error",content:`Control file not found.\nFile: "${"/"+t.name+"/config.json"}".`,type:"danger"});continue}const r=JSON.parse(o);n[r.name]={type:"control",config:r,files:{}};const s=e.readDir("/"+t.name+"/",{hasChildren:!0});for(const t of s){const o=t.path.slice(r.name.length+1),s=getMimeByPath(t.name);if(["txt","json","js","css","xml","html"].includes(s.ext)){const s=await e.getContent(t.path+t.name,"string");if(!s)continue;n[r.name].files[o+t.name]=s.replace(/^\ufeff/,"")}else{const i=await e.getContent(t.path+t.name,"arraybuffer");if(!i)continue;n[r.name].files[o+t.name]=new Blob([i],{type:s.mime})}}}return n}async function init(t,e={}){const n=getOrigin(t);if(!n)return-1;let o=0;for(let r of n.app.config.controls){r.endsWith(".cgc")||(r+=".cgc"),r=urlResolve("/",r);const s=await getContent(t,r);if(s&&"string"!=typeof s){const e=await read(s);if(!e)return notify({title:"Error",content:"Control failed to load.\nTask id: "+n.id.toString()+"\nPath: "+r,type:"danger"}),-5;for(const o in e){const s=e[o];let i="";if(n.controls[o]={layout:"",files:s.files,config:s.config,props:{},emits:{},data:{},access:{},methods:{},computed:{}},n.controls[o].layout=s.files[s.config.layout+".html"],void 0===n.controls[o].layout)return-2;n.controls[o].layout=n.controls[o].layout.replace(/^(<[a-zA-Z0-9-]+)( |>)/,'$1 data-cg-control="'+o+'"$2');const a=s.files[s.config.style+".css"];if(a){const t=stylePrepend(a);i=t.prep,pushStyle(n.id,await styleUrl2DataUrl(s.config.style,t.style,s.files),"control",o)}const c=["cg-theme-task"+n.id.toString()+"-"+o+"_"];let l;if(""!==i&&c.push(i),n.controls[o].layout=layoutAddTagClassAndReTagName(n.controls[o].layout,!1),n.controls[o].layout=layoutClassPrepend(n.controls[o].layout,c),n.controls[o].layout.includes("<cg-")&&(n.controls[o].layout=layoutInsertAttr(n.controls[o].layout,":form-focus='formFocus'",{include:[/^cg-.+/]})),n.controls[o].layout=eventsAttrWrap(n.controls[o].layout),n.controls[o].layout.includes("<teleport")&&(n.controls[o].layout=teleportGlue(n.controls[o].layout,"{{{formId}}}")),n.controls[o].access.cgPCMap=random(8,RANDOM_LUNS,'"<>$'),n.controls[o].layout=n.controls[o].layout.replace(/(<cg-[a-zA-Z0-9-_]+)/g,`$1 data-cg-rootcontrol="${n.controls[o].access.cgPCMap}"`),s.files[s.config.code+".js"]){const e=s.files[s.config.code+".js"];if("string"!=typeof e)return-3;let n=!0;if(stateMachine(e,0,t=>t.state!==ESTATE.WORD||(!["eval","Function"].includes(t.word)||(notify({title:"Error",content:`The "${t.word}" is prohibited.\nFile: "${r}".`,type:"danger"}),n=!1,!1))),!n)return-6;if(s.config.modules?.length)for(const t of s.config.modules)if(!modules[t]&&checkModule(t)&&!await loadModule(t))return-4;const i=runIife(e);if(!i){const e='"default" not found on "'+s.config.code+'" of "'+o+'" control.';return await trigger("error",t,"",new Error(e),e),-7}l=new i}else l=new class extends AbstractControl{get filename(){return s.config.layout+".js"}};if(l.props)for(const t in l.props)n.controls[o].props[t]={default:l.props[t]};if(l.emits)for(const t in l.emits)n.controls[o].emits[t]=l.emits[t];const d=Object.entries(l);for(const t of d)"files"!==t[0]&&("access"!==t[0]?n.controls[o].data[t[0]]=t[1]:n.controls[o].access=t[1]);const f=getClassPrototype(l);n.controls[o].methods=f.method,Object.assign(n.controls[o].computed,f.access),n.controls[o].computed.controlName={get:function(){return o},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "controlName".\nControl: ${o}`,type:"danger"})}},n.controls[o].computed.taskId={get:function(){return t},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "taskId".\nControl: ${o}`,type:"danger"})}},n.controls[o].computed.prep={get:function(){return i},set:function(){notify({title:"Error",content:`The software tries to modify the system variable "prep".\nControl: ${o}`,type:"danger"})}}}}e.progress?.(++o,n.app.config.controls.length,r)}return 1}function buildComponents(t,e,n){const o=getOrigin(t);if(!o)return!1;const r={};for(const t in o.controls){const s=o.controls[t],i=Object.assign({},s.computed);i.findex={get:function(){return o.forms[e].vroot.findex},set:function(){notify({title:"Error",content:`The control tries to modify the system variable "findex".\nControl: ${t}`,type:"danger"})}},i.formId={get:function(){return e},set:function(){notify({title:"Error",content:`The control tries to modify the system variable "formId".\nControl: ${t}`,type:"danger"})}},i.path={get:function(){return n},set:function(){notify({title:"Error",content:`The control tries to modify the system variable "path".\nControl: ${t}`,type:"danger"})}},r["cg-"+t]={template:s.layout.replace(/{{{formId}}}/g,e.toString()).replaceAll('@click="','@tap="'),props:s.props,emits:s.emits,data:function(){const t=clone(s.data);return t.props&&delete t.props,t.emits&&delete t.emits,t},methods:s.methods,computed:i,beforeCreate:s.methods.onBeforeCreate,created:function(){this.props=this.$props,this.slots=this.$slots,this.access=clone(s.access),this.packageFiles={};for(const t in s.files)this.packageFiles[t]=s.files[t];this.onCreated()},beforeMount:function(){this.onBeforeMount()},mounted:async function(){if(void 0!==this.element.dataset?.cgRootcontrol){const t=this.parentByAccess("cgPCMap",this.element.dataset.cgRootcontrol);t&&(this._rootControl=t)}await this.$nextTick(),this.onMounted()},beforeUpdate:function(){this.onBeforeUpdate()},updated:async function(){await this.$nextTick(),this.onUpdated()},beforeUnmount:function(){this.onBeforeUnmount()},unmounted:async function(){await this.$nextTick(),this.onUnmounted()}}}return r}var control=Object.freeze({__proto__:null,AbstractControl:AbstractControl,buildComponents:buildComponents,init:init,initSysId:initSysId$1,read:read});let sysId$1="";function initSysId(t){sysId$1||(sysId$1=t)}const localeData={en:{"sure-clear":'Are you sure you want to clear all temporary storage for the app "?"?'},sc:{"sure-clear":"确定清除应用“?”的所有临时存储吗?"},tc:{"sure-clear":"確定清除應用程式「?」的所有臨時儲存嗎?"},ja:{"sure-clear":"アプリ「?」の一時的な保存データをすべて削除しますか?"},ko:{"sure-clear":'"?" 앱의 모든 임시 저장소를 지우시겠습니까?'},th:{"sure-clear":'คุณแน่ใจหรือไม่ที่ต้องการล้างพื้นที่จัดเก็บชั่วคราวของแอป "?" ทั้งหมดหรือไม่?'},es:{"sure-clear":'¿Estás seguro de que quieres borrar todo el almacenamiento temporal de la aplicación "?"?'},de:{"sure-clear":'Möchten Sie wirklich alle temporären Speicher für die App "?" löschen?'},fr:{"sure-clear":'Êtes-vous sûr de vouloir effacer tous les stockages temporaires de l\'application "?" ?'},pt:{"sure-clear":'Tem a certeza de que pretende limpar todo o armazenamento temporário da aplicação "?"?'},ru:{"sure-clear":'Вы уверены, что хотите очистить все временные хранилища для приложения "?"?'},vi:{"sure-clear":'Bạn có chắc chắn muốn xóa tất cả lưu trữ tạm thời cho ứng dụng "?" không?'}},textEncoder=new TextEncoder;function get(t,e){"string"!=typeof t&&(t=t.taskId);const n=getOrigin(t);if(!n)return null;const o=localStorage.getItem("clickgo-item-"+n.path+"-"+e);if(null===o)return null;try{return JSON.parse(o)}catch{return null}}function set(t,e,n){"string"!=typeof t&&(t=t.taskId);const o=getOrigin(t);if(!o)return!1;if(void 0===n)return!1;const r=JSON.stringify(n),s=textEncoder.encode(r).length,i=localStorage.getItem("clickgo-size-"+o.path);if(null===i){if(s>1048576)return!1;localStorage.setItem("clickgo-size-"+o.path,JSON.stringify({[e]:s}))}else{const t=JSON.parse(i);t[e]=s;if(Object.values(t).reduce((t,e)=>t+e,0)>1048576)return!1;localStorage.setItem("clickgo-size-"+o.path,JSON.stringify(t))}return localStorage.setItem("clickgo-item-"+o.path+"-"+e,r),!0}function remove(t,e){"string"!=typeof t&&(t=t.taskId);const n=getOrigin(t);if(!n)return!1;const o=localStorage.getItem("clickgo-size-"+n.path);if(null===o)return!0;const r=JSON.parse(o);return void 0===r[e]||(delete r[e],Object.keys(r).length?localStorage.setItem("clickgo-size-"+n.path,JSON.stringify(r)):localStorage.removeItem("clickgo-size-"+n.path),localStorage.removeItem("clickgo-item-"+n.path+"-"+e)),!0}function list(t){"string"!=typeof t&&(t=t.taskId);const e=getOrigin(t);if(!e)return{};const n=localStorage.getItem("clickgo-size-"+e.path);return null===n?{}:JSON.parse(n)}function all(){const t={};for(let e=0;e<localStorage.length;e++){const n=localStorage.key(e);if(!n?.startsWith("clickgo-size-"))continue;const o=localStorage.getItem(n);if(!o)continue;const r=JSON.parse(o),s=Object.values(r).reduce((t,e)=>t+e,0);t[n.slice(13)]=s}return t}async function clear(t){if(!t)return 0;const e=localeData[config.locale]?.["sure-clear"]??localeData.en["sure-clear"];if(!await superConfirm(sysId$1,e.replace("?",escapeHTML(t))))return 0;let n=0;localStorage.removeItem("clickgo-size-"+t);const o="clickgo-item-"+t+"-";for(let t=0;t<localStorage.length;t++){const e=localStorage.key(t);e?.startsWith(o)&&(localStorage.removeItem(e),++n)}return n}var storage=Object.freeze({__proto__:null,all:all,clear:clear,get:get,initSysId:initSysId,list:list,remove:remove,set:set});const sysId=random(16,RANDOM_LUN);initSysId$4(sysId),initSysId$1(sysId),initSysId$2(sysId),initSysId$6(sysId),initSysId$7(sysId),initSysId$3(sysId),initSysId(sysId),initSysId$5(sysId),initSysId$8(sysId);const modules={clickgo:clickgo},version="5.10.0";function getVersion(){return version}const native=!!navigator.userAgent.includes("electron");function isNative(){return native}const dirname=import.meta.url.slice(0,import.meta.url.lastIndexOf("/"));function getDirname(){return dirname}let platform="web",frame=!1;window.clickgo||(window.clickgo={}),window.clickgo.modules=modules;const userClickGo=window.clickgo,global=userClickGo.global??{},cdn=userClickGo.config?.cdn??"https://cdn.jsdelivr.net";function getCdn(){return cdn}if(native){const t=/electron\/(.+?) (.+?)\/(.+?) frame\/([0-9])/.exec(navigator.userAgent);t&&(platform=t[2],frame="0"!==t[4])}function getPlatform(){return platform}let device={type:"unknown",os:"unknown"};function getDevice(){if("unknown"!==device.type)return device;const t=navigator.userAgent.toLowerCase();return t.includes("android")?device.os="android":t.includes("iphone")||t.includes("ipad")||t.includes("ipod")?device.os="ios":t.includes("windows")||t.includes("win32")?device.os="windows":t.includes("mac os")||t.includes("darwin")?device.os="macos":t.includes("linux")&&(device.os="linux"),device.type=["windows","macos","linux"].includes(device.os)?"desktop":"mobile",device}function hasFrame(){return frame}class AbstractBoot{_debug=!1;_sysId="";setSysId(t){this._sysId||(this._sysId=t)}isDebug(){return this._debug}constructor(t={}){t.debug&&(this._debug=!0)}onError(){}onScreenResize(){}onConfigChanged(){}onFormCreated(){}onFormRemoved(){}onFormTitleChanged(){}onFormIconChanged(){}onFormStateMinChanged(){}onFormStateMaxChanged(){}onFormShowChanged(){}onFormFocused(){}onFormBlurred(){}onFormFlash(){}onFormShowInSystemTaskChange(){}onFormHashChange(){}onTaskStarted(){}onTaskEnded(){}onLauncherFolderNameChanged(){}onHashChanged(){}onKeydown(){}onKeyup(){}onRuntimeFileLoad(){}onRuntimeFileLoaded(){}}async function launcher(t){await loadScripts([`${cdn}/npm/vue@3.5.26/dist/vue.global${t.isDebug()?"":".prod.min"}.js`]),await loadScripts([`${cdn}/npm/jszip@3.10.1/dist/jszip.min.js`,`${cdn}/npm/@litert/pointer@1.7.3/dist/index.umd.min.js`]),await loadLinks([`${cdn}/npm/@fortawesome/fontawesome-free@7.2.0/css/all.min.css`]),modules.vue=window.Vue,modules.jszip=window.JSZip,modules.pointer=window.pointer,modules.pointer.addMoveHook("down",()=>{is.move=!0}),modules.pointer.addMoveHook("up",()=>{is.move=!1});const e=`${dirname}/global.css`;try{let t=await(await fetch(e)).text();const n=/url\(['"]?([/\w.-]+)['"]?\)/g;let o=null;for(;o=n.exec(t);)t=t.replace(o[0],`url('${urlResolve(dirname+"/",o[1])}')`);document.getElementById("cg-global")?.insertAdjacentHTML("afterbegin",t)}catch{alert(`ClickGo: "${e}" load failed.`)}init$4(),init$1(),init$3(),init$2(),init$5(),setBoot(t),window.TouchEvent||(window.TouchEvent=CustomEvent),await t.main()}export{AbstractBoot,control,core,dom,form,fs,getCdn,getDevice,getDirname,getPlatform,getVersion,global,hasFrame,isNative,launcher,modules,native$1 as native,storage,task,theme,tool,zip};
|
package/doc/clickgo-rag.md
CHANGED
|
@@ -7233,6 +7233,76 @@ TUMS 监控组件。
|
|
|
7233
7233
|
<video :src="videoUrl" v-model:play="isPlaying" v-model:current="currentTime"></video>
|
|
7234
7234
|
```
|
|
7235
7235
|
|
|
7236
|
+
## waterfall
|
|
7237
|
+
---
|
|
7238
|
+
|
|
7239
|
+
这是一个用于实现虚拟滚动瀑布流布局的控件,支持高度不一的元素在多列显示中按照贪心算法填入最短列,从而形成典型的瀑布流体验。底层利用虚拟化机制(Virtualization),仅渲染在视口(及其上下缓冲区域)内可见的 `DOM` 节点,能够支持超大数据量的平滑滚动和渲染。
|
|
7240
|
+
|
|
7241
|
+
### 参数
|
|
7242
|
+
|
|
7243
|
+
#### data
|
|
7244
|
+
|
|
7245
|
+
`any[]`
|
|
7246
|
+
|
|
7247
|
+
瀑布流的数据源,默认 `[]`。
|
|
7248
|
+
|
|
7249
|
+
#### columns
|
|
7250
|
+
|
|
7251
|
+
`number` | `string`
|
|
7252
|
+
|
|
7253
|
+
瀑布流的列数,默认 2。
|
|
7254
|
+
|
|
7255
|
+
#### gap
|
|
7256
|
+
|
|
7257
|
+
`number` | `string`
|
|
7258
|
+
|
|
7259
|
+
列与列、行与行的间距(以像素为单位),默认 10。
|
|
7260
|
+
|
|
7261
|
+
#### sizes
|
|
7262
|
+
|
|
7263
|
+
`Record<string, number | undefined>`
|
|
7264
|
+
|
|
7265
|
+
高度映射对象,用于告诉组件每个数据项需要渲染的高度。键为数据项索引或唯一 `id`,值为该项对应的像素高度。当前虚拟化强依赖于预知高度。默认的键值为 `{}`。
|
|
7266
|
+
|
|
7267
|
+
### 事件
|
|
7268
|
+
|
|
7269
|
+
#### scroll
|
|
7270
|
+
|
|
7271
|
+
瀑布流内容发生滚动时触发。
|
|
7272
|
+
|
|
7273
|
+
- `e`: `Event`
|
|
7274
|
+
|
|
7275
|
+
### 方法
|
|
7276
|
+
|
|
7277
|
+
暂无供外部调用的公开方法。
|
|
7278
|
+
|
|
7279
|
+
### 插槽
|
|
7280
|
+
|
|
7281
|
+
#### default
|
|
7282
|
+
|
|
7283
|
+
每一项的具体展现内容,可访问当前遍历的当前行。
|
|
7284
|
+
|
|
7285
|
+
- `row`: 当前行数据对象
|
|
7286
|
+
- `index`: 当前行对应的下标。
|
|
7287
|
+
|
|
7288
|
+
### 样式
|
|
7289
|
+
|
|
7290
|
+
该控件包裹在一个带有 `overflow-y` 设置为 `auto` 的滚动区域内。内部有一层相对于外层采取相对定位(`position: relative`)用来支撑所有列表项总高度的 `inner` 容器。
|
|
7291
|
+
|
|
7292
|
+
每一个子项则通过绝对定位并通过 `transform: translate(X, Y)` 去改变它们在 `inner` 中停留的具体坐标系。子项切换位置时默认带有轻微的位移过渡动画(`transition: transform 0.2s`),以防数据或尺寸重计算导致页面内容瞬间闪烁。
|
|
7293
|
+
|
|
7294
|
+
同时内部所有距离包括列宽、坐标计算等都会自动减去容器组件设置的 `padding` 大小。
|
|
7295
|
+
|
|
7296
|
+
### 示例
|
|
7297
|
+
|
|
7298
|
+
```xml
|
|
7299
|
+
<waterfall :data="[{'id': 1}, {'id': 2}]" :columns="2" :gap="15" :sizes="{'1': 100, '2': 250}">
|
|
7300
|
+
<template v-slot="scope">
|
|
7301
|
+
<div style="background: red;">内容: {{ scope.row.id }} - 下标: {{ scope.index }}</div>
|
|
7302
|
+
</template>
|
|
7303
|
+
</waterfall>
|
|
7304
|
+
```
|
|
7305
|
+
|
|
7236
7306
|
## web
|
|
7237
7307
|
---
|
|
7238
7308
|
|