diff --git a/build.js b/build.js index e8c926d2..6eab299d 100644 --- a/build.js +++ b/build.js @@ -6,15 +6,15 @@ const config = JSON.parse(fs.readFileSync(path.join(__dirname, "config.json"), " const outputName = config.info.name const distEntryPath = path.join(__dirname, `dist/${outputName}.js`) -const entryFile = "main.js" +const entryFileContent = fs.readFileSync(path.join(__dirname, "main.js"), "utf-8") + +const entryFile = "main.build.js" const entryFilePath = path.join(__dirname, entryFile) -const entryFileContent = fs.readFileSync(entryFilePath, "utf-8") function injectContent() { const stringsFolder = path.join(__dirname, "strings") const stringsFiles = fs.readdirSync(stringsFolder) const localizedText = {} - stringsFiles.forEach(fileName => { if (path.extname(fileName) !== ".strings") { return @@ -33,7 +33,6 @@ function injectContent() { } }) }) - const stringsText = `$app.strings = ${JSON.stringify(localizedText)};` const configSettings = Object.keys(config.settings) @@ -154,7 +153,7 @@ async function build() { } } finally { // 恢复文件内容 - fs.writeFileSync(entryFilePath, entryFileContent) + fs.unlinkSync(entryFilePath) fs.writeFileSync(packageJsonPath, packageJsonContent) } } diff --git a/config.json b/config.json index 5eeb16c3..804ecfa1 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,7 @@ { "info": { "name": "CAIO", - "version": "1.10.8", + "version": "1.11.0", "author": "ipuppet", "module": false }, @@ -13,4 +13,4 @@ "keyboardToolbarEnabled": true, "rotateDisabled": false } -} +} \ No newline at end of file diff --git a/dist/CAIO-en.json b/dist/CAIO-en.json new file mode 100644 index 00000000..c12a9d75 --- /dev/null +++ b/dist/CAIO-en.json @@ -0,0 +1,29 @@ +{ + "actions": [ + { + "type": "@comment", + "parameters": { + "text": { + "value": "GitHub: https://github.com/ipuppet/CAIO" + } + } + }, + { + "type": "@flow.javascript", + "parameters": { + "script": { + "value": "(()=>{var $parcel$global=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;let $9ca6ee6eeae53f7f$var$AppInstance;switch(null==parcelRequire&&(parcelRequire=function(t){if(t in $parcel$modules)return $parcel$modules[t].exports;if(t in $parcel$inits){var e=$parcel$inits[t];delete $parcel$inits[t];var i={id:t,exports:{}};return $parcel$modules[t]=i,e.call(i.exports,i,i.exports),i.exports}var s=new Error(\"Cannot find module '\"+t+\"'\");throw s.code=\"MODULE_NOT_FOUND\",s},parcelRequire.register=function(t,e){$parcel$inits[t]=e},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register(\"8Makm\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.UIKit,r=i.ViewController,n=i.TabBarController,a=parcelRequire(\"34tpw\").AppKernelBase,o=parcelRequire(\"gYDdO\"),l=parcelRequire(\"9RsVy\");class h extends a{constructor(){super(),this.query=$context.query,l(this)}}class c{static kernel=$app.env!==$env.widget?new h:void 0;static renderMainUI(){const t={clips:{icon:\"doc.on.clipboard\",title:$l10n(\"CLIPS\")},actions:{icon:\"command\",title:$l10n(\"ACTIONS\")},setting:{icon:\"gear\",title:$l10n(\"SETTING\")}};if(this.kernel.setting.setEvent(\"onSet\",(t=>{\"mainUIDisplayMode\"===t&&$delay(.3,(()=>$addin.restart()))})),0===this.kernel.setting.get(\"mainUIDisplayMode\"))this.kernel.useJsboxNav(),this.kernel.setting.useJsboxNav(),this.kernel.setNavButtons([{symbol:t.setting.icon,title:t.setting.title,handler:()=>{s.push({title:t.setting.title,views:[this.kernel.setting.getListView()]})}},{symbol:t.actions.icon,title:t.actions.title,handler:()=>{this.kernel.actionManager.present()}}]),this.kernel.UIRender(this.kernel.clips.getNavigationView().getPage());else{this.kernel.fileManager.setViewController(new r),this.kernel.tabBarController=new n;const e=this.kernel.clips.getNavigationView();this.kernel.tabBarController.setPages({clips:e.getPage(),actions:this.kernel.actionManager.getPage(),setting:this.kernel.setting.getPage()}).setCells({clips:t.clips,actions:t.actions,setting:t.setting}),this.kernel.UIRender(this.kernel.tabBarController.generateView().definition)}}}t.exports={run:()=>{o(c.kernel),c.renderMainUI()}}})),parcelRequire.register(\"gxpqj\",(function(module,exports){var VERSION=\"1.4.3\",AlertAction=class{title;handler;constructor({title:t=$l10n(\"OK\"),disabled:e=!1,style:i=$alertActionType.default,handler:s=(()=>{})}={}){this.title=t,this.disabled=e,this.style=i,this.handler=s}},Alert=class t{id=$text.uuid;title;message;actions;titleFont=$font(\"bold\",20);messageFont=$font(14);actionButtonFontSize=16;actionButtonHighlight=$color($rgba(0,0,0,.2),$rgba(255,255,255,.2));actionButtonHeight=35;actionButtonBoderWidth=.5;actionButtonBorderColor=$color(\"#C9C9C9\",\"#383838\");boxWidth=250;textVerticalMargin=20;textHorizontalMargin=50;constructor({title:t=\"\",message:e=\"\",actions:i=[]}={}){this.title=t,this.message=e,this.actions=i,0===this.actions.length&&this.actions.push(new AlertAction),this.titleSize=UIKit.getContentSize(this.titleFont,this.title,this.boxWidth-2*this.textHorizontalMargin),this.messageSize=UIKit.getContentSize(this.messageFont,this.message,this.boxWidth-2*this.textHorizontalMargin)}textView(){return{type:\"view\",views:[{type:\"label\",props:{lines:0,font:this.titleFont,text:this.title,color:$color(\"tint\"),align:$align.center},layout:(t,e)=>{t.centerX.equalTo(e.super),t.width.equalTo(this.boxWidth-2*this.textHorizontalMargin),t.height.equalTo(this.titleSize.height),t.top.equalTo(this.textVerticalMargin)}},{type:\"label\",props:{lines:0,font:this.messageFont,text:this.message,align:$align.center},layout:(t,e)=>{t.centerX.equalTo(e.super),t.width.equalTo(this.boxWidth-2*this.textHorizontalMargin),t.height.equalTo(this.messageSize.height),t.top.equalTo(e.prev.bottom)}}],layout:(t,e)=>{t.top.width.equalTo(e.super),t.height.equalTo(this.titleSize.height+this.messageSize.height+2*this.textVerticalMargin)}}}actionView(){let t=(t,e)=>{let i=t=>2===this.actions.length?t.y>=0&&t.x>=0&&t.y<=this.actionButtonHeight&&t.x<=this.boxWidth/2:t.y>=0&&t.x>=0&&t.y<=this.actionButtonHeight&&t.x<=this.boxWidth,s=async(s,r,n)=>{t.disabled||(s.bgcolor=$color(\"clear\"),i(r)&&(\"function\"==typeof t.handler&&await t.handler({index:e,title:t.title}),this.dismiss()))},r=$color(\"tint\"),n=$font(this.actionButtonFontSize);return t.disabled?r=$color(\"gray\"):t.style===$alertActionType.destructive?r=$color(\"red\"):t.style===$alertActionType.cancel&&(n=$font(\"bold\",this.actionButtonFontSize)),{type:\"label\",props:{lines:1,text:t.title,align:$align.center,font:n,color:r,borderWidth:this.actionButtonBoderWidth,borderColor:this.actionButtonBorderColor,bgcolor:$color(\"clear\")},events:{tapped:()=>{},touchesBegan:e=>{t.disabled||(e.bgcolor=this.actionButtonHighlight)},touchesEnded:s,touchesCancelled:s,touchesMoved:(e,s,r)=>{t.disabled||(i(s)?e.bgcolor=this.actionButtonHighlight:e.bgcolor=$color(\"clear\"))}},layout:(t,e)=>{2===this.actions.length?e.prev?(t.left.equalTo(e.prev.right).offset(-this.actionButtonBoderWidth),t.width.equalTo(e.super).dividedBy(2).offset(this.actionButtonBoderWidth)):t.width.equalTo(e.super).dividedBy(2):(t.width.equalTo(e.super),e.prev&&t.top.equalTo(e.prev.bottom).offset(-this.actionButtonBoderWidth)),t.height.equalTo(this.actionButtonHeight)}}};return{type:\"view\",views:this.actions.map(((e,i)=>t(e,i))),layout:(t,e)=>{t.left.equalTo(e.super).offset(-this.actionButtonBoderWidth),t.width.equalTo(e.super).offset(2*this.actionButtonBoderWidth),t.bottom.equalTo(e.super),t.top.equalTo(e.prev.bottom)}}}getView(){let t={type:\"view\",props:{id:this.id+\"-box\",smoothCorners:!0,cornerRadius:20,bgcolor:$color(\"#FFFFFF\",\"#000000\")},views:[this.textView(),this.actionView()],layout:(t,e)=>{t.center.equalTo(e.super.safeArea);let i=this.titleSize.height+this.messageSize.height+2*this.textVerticalMargin,s=this.actions.length>2?this.actions.length:1;i+=this.actionButtonHeight*s,i-=this.actionButtonBoderWidth*s;let r=this.boxWidth-2*this.actionButtonBoderWidth;t.size.equalTo($size(r,i))}};return{type:\"view\",props:{id:this.id,alpha:0,bgcolor:$rgba(0,0,0,.6)},views:[t],layout:$layout.fill}}present(){let t=$ui.create(this.getView());$ui.controller.view.hidden?$ui.controller.view.super.insertAtIndex(t,0):$ui.controller.view.insertAtIndex(t,0);let e=$(this.id);e.layout($layout.fill),e.moveToFront(),$ui.animate({duration:.3,animation:()=>{e.alpha=1}})}dismiss(){let t=$(this.id);$ui.animate({duration:.3,animation:()=>{t.alpha=0},completion:()=>{t.remove()}})}static fromJsbox(e){return new Promise(((i,s)=>{new t({title:e.title,message:e.message,actions:e?.actions?.map((t=>(t.handler||(t.handler=t=>{i(t)}),new AlertAction(t))))}).present()}))}},Controller=class{events={};setEvents(t){return Object.keys(t).forEach((e=>this.setEvent(e,t[e]))),this}setEvent(t,e){return this.events[t]=e,this}appendEvent(t,e){let i=this.events[t];return\"function\"==typeof i?this.events[t]=(...t)=>{i(...t),e(...t)}:this.setEvent(t,e),this}callEvent(t,...e){\"function\"==typeof this.events[t]&&this.events[t](...e)}},FileManager=class{viewController;constructor(){this.listId=\"file-manager-list\",this.edges=10,this.iconSize=25}setViewController(t){this.viewController=t}get menu(){return{items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:async(t,e)=>{let i=t.object(e).info.info;$share.sheet([$file.absolutePath(i.path)])}}]}}delete(t){$file.delete(t.path)}edit(t){let e=$file.read(t.path);if(e.info?.mimeType?.startsWith(\"image\"))Sheet.quickLookImage(e,t.path.substring(t.path.lastIndexOf(\"/\")+1));else{let i=new Sheet,s=$text.uuid;i.setView({type:\"code\",layout:$layout.fill,props:{id:s,lineNumbers:!0,theme:$device.isDarkMode?\"atom-one-dark\":\"atom-one-light\",text:e.string,insets:$insets(15,15,15,15)}}).addNavBar({title:t.file,popButton:{title:$l10n(\"CLOSE\")},rightButtons:[{title:$l10n(\"SAVE\"),tapped:()=>{$file.write({data:$data({string:$(s).text}),path:t.path}),$ui.success($l10n(\"SAVE_SUCCESS\"))}}]}),i.init().present()}}getFiles(t=\"\"){return $file.list(t).map((e=>{let i=t+\"/\"+e,s=$file.isDirectory(i);return{info:{info:{path:i,file:e,isDirectory:s}},icon:{symbol:s?\"folder.fill\":\"doc\"},name:{text:e},size:{text:s?\"\":\"--\"}}})).sort(((t,e)=>t.info.info.isDirectory!==e.info.info.isDirectory?t.info.info.isDirectory?-1:1:t.info.info.isDirectory===e.info.info.isDirectory?t.info.info.file.localeCompare(e.info.info.file):void 0))}async loadFileSize(t){return t.map(((e,i)=>{let s=e.info.info;if(!s.isDirectory)try{t[i].size.text=UIKit.bytesToSize($file.read(s.path).info.size)}catch(e){t[i].size.text=e}})),t}get listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{props:{id:\"info\"}},{type:\"image\",props:{id:\"icon\"},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(this.edges),t.size.equalTo(this.iconSize)}},{type:\"view\",views:[{type:\"label\",props:{id:\"size\",color:$color(\"secondaryText\"),lines:1},layout:(t,e)=>{t.height.equalTo(e.super),t.right.inset(this.edges)}},{type:\"label\",props:{id:\"name\",lines:1},layout:(t,e)=>{t.height.left.equalTo(e.super),t.right.equalTo(e.prev.left).offset(-this.edges)}}],layout:(t,e)=>{t.height.right.equalTo(e.super),t.left.equalTo(e.prev.right).offset(this.edges)}}]}}#t(t,e){if(this.viewController){let i=new NavigationView;i.setView(e).navigationBarTitle(t),i.navigationBar.setLargeTitleDisplayMode(NavigationBar.largeTitleDisplayModeNever),this.viewController.push(i)}else UIKit.push({title:t,views:[e]})}getListView(t=\"\"){return{type:\"list\",props:{id:this.listId,menu:this.menu,info:{basePath:t},bgcolor:UIKit.primaryViewBackgroundColor,separatorInset:$insets(0,this.edges,0,0),data:[],template:this.listTemplate,actions:[{title:\" \"+$l10n(\"DELETE\")+\" \",color:$color(\"red\"),handler:(t,e)=>{let i=t.object(e).info.info;UIKit.deleteConfirm($l10n(\"FILE_MANAGER_DELETE_CONFIRM_MSG\")+' \"'+i.file+'\" ?',(()=>{this.delete(i),t.delete(e)}))}}]},layout:$layout.fill,events:{ready:()=>{let e=this.getFiles(t);$(this.listId).data=e,this.loadFileSize(e).then((t=>{$(this.listId).data=t}))},pulled:async t=>{let e=this.getFiles($(this.listId).info.basePath);$(this.listId).data=e,$(this.listId).data=await this.loadFileSize(e),$delay(.5,(()=>{t.endRefreshing()}))},didSelect:(t,e,i)=>{let s=i.info.info;s.isDirectory?this.#t(s.file,this.getListView(s.path)):this.edit(s)}}}}push(t=\"\"){let e=t.substring(t.lastIndexOf(\"/\"));this.#t(e,this.getListView(t))}},FileStorage=class t{basePath;constructor({basePath:t=\"storage\"}={}){this.basePath=t,this.#t(this.basePath)}static join(...t){let e=t.length,i=t[0];if(e<2)return i;for(let s=0;st&&(s=e.substring(t+1),e=e.substring(0,t+1))}return i&&this.#t(e),e+s}exists(t=\"\"){return t=this.filePath(t,!1),!!$file.exists(t)}write(t=\"\",e){return new Promise(((i,s)=>{try{let r=this.writeSync(t,e);r?i(r):s(r)}catch(t){s(t)}}))}writeSync(t=\"\",e){if(!e)throw new FileStorageParameterError(\"data\");return $file.write({data:e,path:this.filePath(t)})}read(t=\"\"){return new Promise(((e,i)=>{try{let s=this.readSync(t);s?e(s):i()}catch(t){i(t)}}))}readSync(t=\"\"){if(t=this.filePath(t),!$file.exists(t))throw new FileStorageFileNotFoundError(t);return $file.isDirectory(t)?$file.list(t):$file.read(t)}readAsJSON(t=\"\",e=null){try{let e=this.readSync(t)?.string;return JSON.parse(e)}catch{return e}}static readFromRoot(e=\"\"){return new Promise(((i,s)=>{try{let r=t.readFromRootSync(e);r?i(r):s()}catch(t){s(t)}}))}static readFromRootSync(t=\"\"){if(!t)throw new FileStorageParameterError(\"path\");if(!$file.exists(t))throw new FileStorageFileNotFoundError(t);return $file.isDirectory(t)?$file.list(t):$file.read(t)}static readFromRootAsJSON(e=\"\",i=null){try{let i=t.readFromRootSync(e)?.string;return JSON.parse(i)}catch{return i}}delete(t=\"\"){return $file.delete(this.filePath(t,!1))}copy(t,e){t=this.filePath(t),e=this.filePath(e),$file.copy({src:t,dst:e})}move(t,e){t=this.filePath(t),e=this.filePath(e),$file.move({src:t,dst:e})}},Kernel=class t{startTime=Date.now();isUseJsboxNav=!1;title=$addin?.current?.name;constructor(){$app.isDebugging&&this.debug(),L10n.init()}static isTaio=$app.info.bundleID.includes(\"taio\");static objectEqual(e,i){let s=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(i);if(s.length!==r.length)return!1;for(let r=0;rt?i[t]:0,r=isNaN(Number(e))?e.charCodeAt():Number(e),a=s.length>t?s[t]:0,o=isNaN(Number(a))?a.charCodeAt():Number(a);if(ro){n=1;break}}return n}debug(t,e){this.debugMode=!0,$app.idleTimerDisabled=!0,\"function\"==typeof t&&(this.debugPrint=t),\"function\"==typeof e&&(this.debugError=e),this.print(\"You are running EasyJsBox in debug mode.\")}print(t){this.debugMode&&(\"function\"==typeof this.debugPrint?this.debugPrint(t):console.log(t))}error(t){this.debugMode&&(\"function\"==typeof this.debugError?this.debugError(t):console.error(t))}useJsboxNav(){return this.isUseJsboxNav=!0,this}setTitle(t){this.isUseJsboxNav&&($ui.title=t),this.title=t}setNavButtons(t){this.navButtons=t}openInJsbox(){$app.openURL(`jsbox://run?name=${this.title}`)}UIRender(t={}){let e=$context.query;if(\"alertFromKeyboard\"===e.type){let t=JSON.parse($text.URLDecode(e.value));return t.actions=[{title:$l10n(\"CANCEL\")}],void $ui.alert(t)}try{t.props=Object.assign({title:this.title,navBarHidden:!this.isUseJsboxNav,navButtons:this.navButtons??[],statusBarStyle:0},t.props),t.events||(t.events={});let e=t.events.layoutSubviews;t.events.layoutSubviews=()=>{$app.notify({name:\"interfaceOrientationEvent\",object:{statusBarOrientation:UIKit.statusBarOrientation,isHorizontal:UIKit.isHorizontal}}),\"function\"==typeof e&&e()},$ui.render(t)}catch(t){this.print(t)}}KeyboardRender(t={}){t.id||(t.id=$text.uuid),$ui.render({events:t.events??{}}),$delay(0,(()=>{$ui.controller.view=$ui.create(t),$ui.controller.view.layout(t.layout)}))}async checkUpdate(){let e=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/src/version.js\");if(e.error)throw e.error;let i=e.data.match(/.*VERSION.+\\\"([0-9\\.]+)\\\"/)[1];if(this.print(`easy-jsbox latest version: ${i}`),t.versionCompare(i,VERSION)>0){let t=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/dist/easy-jsbox.js\");if(t.error)throw t.error;return t.data}return!1}},L10n=class{static l10n(t,e,i){if(\"string\"==typeof e){let t={};e.split(\";\").forEach((e=>{if(\"\"!==(e=e.trim())){let i=e.split(\"=\");t[i[0].trim().slice(1,-1)]=i[1].trim().slice(1,-1)}})),e=t}let s=$app.strings;if(i)Object.assign(s[t],e);else for(let i in e)s[t][i]||(s[t][i]=e[i]);$app.strings=s}static set(t,e){this.l10n(t,e,!0)}static add(t,e){this.l10n(t,e,!1)}static init(){this.add(\"zh-Hans\",{OK:\"好\",DONE:\"完成\",CANCEL:\"取消\",CLEAR:\"清除\",BACK:\"返回\",ERROR:\"发生错误\",SUCCESS:\"成功\",INVALID_VALUE:\"非法参数\",CONFIRM_CHANGES:\"数据已变化,确认修改?\",SETTING:\"设置\",GENERAL:\"一般\",ADVANCED:\"高级\",TIPS:\"小贴士\",COLOR:\"颜色\",COPY:\"复制\",COPIED:\"复制成功\",JSBOX_ICON:\"JSBox 内置图标\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"图片 / base64\",PREVIEW:\"预览\",SELECT_IMAGE_PHOTO:\"从相册选择图片\",SELECT_IMAGE_ICLOUD:\"从 iCloud 选择图片\",CLEAR_IMAGE:\"清除图片\",NO_IMAGE:\"无图片\",ABOUT:\"关于\",VERSION:\"Version\",AUTHOR:\"作者\",AT_BOTTOM:\"已经到底啦~\"}),this.add(\"en\",{OK:\"OK\",DONE:\"Done\",CANCEL:\"Cancel\",CLEAR:\"Clear\",BACK:\"Back\",ERROR:\"Error\",SUCCESS:\"Success\",INVALID_VALUE:\"Invalid value\",CONFIRM_CHANGES:\"The data has changed, confirm the modification?\",SETTING:\"Setting\",GENERAL:\"General\",ADVANCED:\"Advanced\",TIPS:\"Tips\",COLOR:\"Color\",COPY:\"Copy\",COPIED:\"Copide\",JSBOX_ICON:\"JSBox in app icon\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"Image / base64\",PREVIEW:\"Preview\",SELECT_IMAGE_PHOTO:\"Select From Photo\",SELECT_IMAGE_ICLOUD:\"Select From iCloud\",CLEAR_IMAGE:\"Clear Image\",NO_IMAGE:\"No Image\",ABOUT:\"About\",VERSION:\"Version\",AUTHOR:\"Author\",AT_BOTTOM:\"It's the end~\"}),this.add(\"zh-Hans\",{DELETE_CONFIRM_TITLE:\"删除前确认\"}),this.add(\"en\",{DELETE_CONFIRM_TITLE:\"Delete Confirmation\"}),this.add(\"zh-Hans\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"确认要删除吗\",DELETE:\"删除\",CANCEL:\"取消\",CLOSE:\"关闭\",SHARE:\"分享\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\"}),this.add(\"en\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"Are you sure you want to delete\",DELETE:\"Delete\",CANCEL:\"Cancel\",CLOSE:\"Close\",SHARE:\"Share\",SAVE:\"Save\",SAVE_SUCCESS:\"Save Success\"})}},Logger=class{print;constructor(t){this.print=t??console.log}printToFile(t,e){this.print=i=>{t.exists(e)&&(i=(t.readSync(e)?.string??\"\")+i),t.writeSync(e,$data({string:i}))}}format(t,e){return`${(new Date).toUTCString()} [${e}] ${t}\\n`}log(t,e){this.print(this.format(t,e))}info(t){this.log(t,\"INFO\")}error(t){this.log(t,\"ERROR\")}alert(t){this.log(t,\"ALERT\")}},NavigationBarItems=class{rightButtons=[];leftButtons=[];#t={};hasbutton=!1;isPinTitleView=!1;setTitleView(t){return this.titleView=t,this}pinTitleView(){return this.isPinTitleView=!0,this}setFixedFooterView(t){return this.fixedFooterView=t,this}setRightButtons(t){return t.forEach((t=>this.addRightButton(t))),this.hasbutton||(this.hasbutton=!0),this}setLeftButtons(t){return t.forEach((t=>this.addLeftButton(t))),this.hasbutton||(this.hasbutton=!0),this}addRightButton({id:t,symbol:e,title:i,tapped:s,menu:r,events:n,color:a}={}){let o=BarButtonItem.creat({id:t,symbol:e,title:i,tapped:s,menu:r,events:n,color:a,align:UIKit.align.right});return this.rightButtons.push(o),this.#t[t??o.id]=o,this.hasbutton||(this.hasbutton=!0),this}addLeftButton({id:t,symbol:e,title:i,tapped:s,menu:r,events:n,color:a}={}){let o=BarButtonItem.creat({id:t,symbol:e,title:i,tapped:s,menu:r,events:n,color:a,align:UIKit.align.left});return this.leftButtons.push(o),this.#t[t??o.id]=o,this.hasbutton||(this.hasbutton=!0),this}getButton(t){return this.#t[t]}addPopButton(t,e,i){return t||(t=$l10n(\"BACK\")),this.popButtonView=e??{type:\"button\",props:{bgcolor:$color(\"clear\"),symbol:\"chevron.left\",tintColor:UIKit.linkColor,title:` ${t}`,titleColor:UIKit.linkColor,font:$font(\"bold\",16)},layout:(t,e)=>{t.left.equalTo(e.super.safeArea).offset(BarButtonItem.style.edges),t.centerY.equalTo(e.super.safeArea)},events:{tapped:()=>{$ui.pop(),\"function\"==typeof i&&i()}}},this}removePopButton(){return this.popButtonView=void 0,this}},Plist=class{constructor(t){this.content=t}valueToJs(t){switch(t.tag){case\"dict\":return this.dictToJs(t);case\"true\":case\"false\":return\"true\"===t.tag;case\"integer\":return t.number;case\"key\":case\"string\":return t.string;case\"date\":return new Date(t.string);case\"array\":return this.arrayToJs(t);default:return t.node}}arrayToJs(t){let e=[];return t.children().forEach((t=>{e.push(this.valueToJs(t))})),e}dictToJs(t){let e=[],i=[];return t.children().forEach((t=>{\"key\"===t.tag?e.push(this.valueToJs(t)):i.push(this.valueToJs(t))})),Object.fromEntries(e.map(((t,e)=>[t,i[e]])))}getObject(){if(!this.content)return!1;let t=$xml.parse({string:this.content,mode:\"xml\"});return this.valueToJs(t.rootElement.firstChild({xPath:\"//plist/dict\"}))}static get(t){return new this(t).getObject()}},Request=class t{static method={get:\"GET\",post:\"POST\",put:\"PUT\",delete:\"DELETE\",patch:\"PATCH\",head:\"HEAD\",options:\"OPTIONS\"};static errorType={http:0,network:1};cacheContainerKey=$addin?.current?.name+\".request.cache\";#t;#e=!1;#i=!1;cacheLife=2592e6;#s=!1;timeout=5;logger;constructor(t){\"function\"==typeof t&&(this.logger=t)}get cache(){return $cache.get(this.cacheContainerKey)??{}}#r(t){this.#s&&\"function\"==typeof this.logger&&this.logger(t)}logRequest(t){return this.#s=!0,\"function\"==typeof t&&(this.logger=t),this}disableLogRequest(){this.#s=!1}getCacheKey(t){return $text.MD5(t)}getCache(t,e=null){return this.cache[t]??e}setCache(t,e){if(!e)return;let i=this.cache;i[t]=e,$cache.set(this.cacheContainerKey,i)}removeCache(t){let e=this.cache;delete e[t],$cache.set(this.cacheContainerKey,e)}clearCache(){$cache.remove(this.cacheContainerKey)}clearNSURLCache(){this.#t||(this.#t=$objc(\"NSURLCache\").$sharedURLCache()),this.#t.$removeAllCachedResponses()}enableCache(){return this.#e=!0,this}disableCache(){return this.#e=!1,this}ignoreCacheExp(){this.#i=!0}async request(e,i,s={},r={},n=this.cacheLife,a){let o,l=this.#e&&i===t.method.get;if(l){o=this.getCacheKey(e);let t=this.getCache(o);if(t&&(this.#i||t.exp>Date.now()))return this.#r(\"get data from cache: \"+e),t.data}this.#r(`sending request [${i}]: ${e}`);let h=await $http.request(Object.assign({header:r,url:e,method:i,body:i===t.method.get?null:s,timeout:this.timeout},a));if(h.error)throw new RequestError({type:t.errorType.network,message:h.error.localizedDescription,code:h.error.code});if(h?.response?.statusCode>=400){let e=h.data;throw\"object\"==typeof e&&(e=JSON.stringify(e)),new RequestError({type:t.errorType.http,message:e,code:h.response.statusCode})}return l&&this.setCache(o,{exp:Date.now()+n,data:h}),h}},SettingItem=class _SettingItem{static rowHeight=50;static edgeOffset=10;static iconSize=30;static iconDefaultColor=\"#00CC00\";setting;#n;#a;#o;title;#l={};constructor({setting:t,key:e,title:i,icon:s,value:r=null}={}){this.setting=t,this.key=e,this.title=$l10n(i),this.icon=s,this.default=r}get method(){return this.setting.method}set key(t){return this.#a=t??$text.uuid,this.#n=void 0,this}get key(){return this.#a}get id(){return this.#n||(this.#n=`setting-${this.setting.name}-${this.key}`),this.#n}set icon(t){return t?Array.isArray(t)||(t=[t,_SettingItem.iconDefaultColor]):t=[\"square.grid.2x2.fill\",_SettingItem.iconDefaultColor],Array.isArray(t[0])||(t[0]=[t[0],t[0]]),t[1]?Array.isArray(t[1])||(t[1]=[t[1],t[1]]):t[1]=[_SettingItem.iconDefaultColor,_SettingItem.iconDefaultColor],this.#o=t,this}get icon(){return this.#o}get options(){return this.#l}set options(t){return this.#l=t??{},this}set(t){return this.setting.set(this.key,t)}get(t=this.default){return this.setting.getOriginal(this.key,t)}evalValues(object){let result;return result=\"string\"==typeof object?object.startsWith(\"this.method\")?eval(`(()=>{return ${object}()})()`):eval(`(()=>{return ${object}})()`):\"function\"==typeof object?object():object??[],result}createLineLabel(){return{type:\"view\",views:[{type:\"view\",props:{bgcolor:$color(this.icon[1][0],this.icon[1][1]),cornerRadius:5,smoothCorners:!0},views:[{type:\"image\",props:{tintColor:$color(\"white\"),image:$image(this.icon[0][0],this.icon[0][1])},layout:(t,e)=>{t.center.equalTo(e.super),t.size.equalTo(20)}}],layout:(t,e)=>{t.centerY.equalTo(e.super),t.size.equalTo(_SettingItem.iconSize),t.left.inset(_SettingItem.edgeOffset)}},{type:\"label\",props:{text:this.title,lines:1,align:$align.left},layout:(t,e)=>{t.centerY.equalTo(e.super),t.height.equalTo(e.super),t.left.equalTo(e.prev.right).offset(_SettingItem.edgeOffset),t.width.greaterThanOrEqualTo(10)}}],layout:(t,e)=>{t.height.centerY.equalTo(e.super),t.left.inset(0)}}}getView(){}create(){return this.getView(this.options)}},Sheet=class t{#t=()=>{};#e=()=>{};style=t.UIModalPresentationStyle.PageSheet;#i=!1;#s;static UIModalPresentationStyle={Automatic:-2,FullScreen:0,PageSheet:1,FormSheet:2,CurrentContext:3,Custom:4,OverFullScreen:5,OverCurrentContext:6,Popover:7,BlurOverFullScreen:8};navigationView;init(){this.initNavBar();let{width:t,height:e}=$device.info.screen,i=$objc(\"UIView\").invoke(\"initWithFrame\",$rect(0,0,t,e)),s=$objc(\"UIViewController\").invoke(\"alloc.init\"),r=s.$view();return r.$addSubview(i),s.$setModalPresentationStyle(this.style),s.$setModalInPresentation(this.#i),this.#t=()=>{r.jsValue().add(this.navigationView?.getPage().definition??this.view),$ui.vc.ocValue().invoke(\"presentViewController:animated:completion:\",s,!0,void 0)},this.#e=()=>s.invoke(\"dismissViewControllerAnimated:completion:\",!0,void 0),this}initNavBar(){if(!this.#s)return;let{title:e=\"\",popButton:i={title:$l10n(\"CLOSE\")},rightButtons:s=[]}=this.#s;if(void 0===this.view)throw new SheetViewUndefinedError;this.navigationView=new NavigationView;let r=this.navigationView.navigationBar;r.setLargeTitleDisplayMode(NavigationBar.largeTitleDisplayModeNever),r.navigationBarLargeTitleHeight-=r.navigationBarNormalHeight,r.navigationBarNormalHeight=NavigationBar.pageSheetNavigationBarHeight,r.navigationBarLargeTitleHeight+=r.navigationBarNormalHeight,this.style===t.UIModalPresentationStyle.FullScreen||this.style===t.UIModalPresentationStyle.OverFullScreen||this.style===t.UIModalPresentationStyle.BlurOverFullScreen?r.setTopSafeArea():r.removeTopSafeArea(),i.events=Object.assign({tapped:()=>{this.dismiss(),\"function\"==typeof i.tapped&&i.tapped()}},i.events??{}),this.navigationView.navigationBarItems.addLeftButton(i).setRightButtons(s),this.navigationView.setView(this.view).navigationBarTitle(e),this.view.props?.bgcolor&&this.navigationView?.getPage().setProp(\"bgcolor\",this.view.props?.bgcolor)}preventDismiss(){return this.#i=!0,this}setStyle(t){return this.style=t,this}setView(t={}){if(\"object\"!=typeof t)throw new SheetViewTypeError(\"view\",\"object\");return this.view=t,this}addNavBar(t){return this.#s=t,this}present(){this.#t()}dismiss(){this.#e()}static quickLookImage(e,i=$l10n(\"PREVIEW\")){(new t).setView({type:\"view\",views:[{type:\"scroll\",props:{zoomEnabled:!0,maxZoomScale:3},layout:$layout.fill,views:[{type:\"image\",props:{data:e},layout:$layout.fill}]}],layout:$layout.fill}).addNavBar({title:i,rightButtons:[{symbol:\"square.and.arrow.up\",tapped:()=>$share.sheet(e)}]}).init().present()}},Tasks=class{#t={};addTask(t,e=0){let i=$text.uuid;return this.#t[i]=$delay(e,(async()=>{await t(),delete this.#t[i]})),i}cancelTask(t){this.#t[t].cancel()}clearTasks(){Object.values(this.#t).forEach((t=>t.cancel()))}},Toast=class t{static type={info:void 0,success:\"checkmark\",warning:\"exclamationmark.triangle\",error:\"xmark.circle\"};static edges=40;static iconSize=100;static labelTopMargin=10;static defaultFont=$font(\"default\",26);width=Math.min(.6*UIKit.windowSize.width,260);labelWidth=this.width-2*t.edges;id=$text.uuid;#t=\"\";font=t.defaultFont;type=t.type.info;labelLines=2;constructor(e,i=t.type.info,s=2,r=t.defaultFont){this.type=i,this.message=e,this.labelLines=s,this.font=r}get message(){return this.#t}set message(e){this.#t=e,this.fontHeight=UIKit.getContentSize(this.font,this.message,this.labelWidth,this.labelLines).height,this.height=(this.hasIcon?t.labelTopMargin+t.iconSize:0)+this.fontHeight+2*t.edges}get hasIcon(){return void 0!==this.type}get blurBox(){let e=UIKit.blurBox({id:this.id,cornerRadius:15,alpha:0},[{type:\"image\",props:{symbol:this.type,hidden:!this.hasIcon,tintColor:$color(\"lightGray\")},layout:(e,i)=>{e.top.inset(t.edges),e.size.equalTo(t.iconSize),e.centerX.equalTo(i.super)}},{type:\"label\",props:{font:this.font,text:this.message,align:$align.center,lines:this.labelLines,color:$color(\"lightGray\")},layout:(e,i)=>{e.bottom.equalTo(i.supper).offset(-t.edges),e.width.equalTo(this.labelWidth),e.height.equalTo(this.fontHeight),e.centerX.equalTo(i.super)}}]);return e.events={tapped:()=>{this.remove()}},e}show(){let t=$ui.create(this.blurBox);$ui.controller.view.hidden?$ui.controller.view.super.insertAtIndex(t,0):$ui.controller.view.insertAtIndex(t,0);let e=$(this.id);e.layout(((t,e)=>{t.center.equalTo(e.super),t.size.equalTo($size(this.width,this.height))})),e.moveToFront(),$ui.animate({duration:.2,animation:()=>{e.alpha=1}})}remove(){let t=$(this.id);t&&$ui.animate({duration:.2,animation:()=>{t.alpha=0},completion:()=>{t.remove()}})}static toast({message:e,type:i=t.type.info,show:s=!0,displayTime:r=2,labelLines:n=2,font:a=t.defaultFont}){let o=new t(e,i,n,a);return s&&(o.show(),$delay(r,(()=>{o.remove()}))),o}static info(e,i={}){return t.toast(Object.assign({message:e,type:t.type.info},i))}static success(e,i={}){return t.toast(Object.assign({message:e,type:t.type.success},i))}static warning(e,i={}){return t.toast(Object.assign({message:e,type:t.type.warning},i))}static error(e,i={}){return t.toast(Object.assign({message:e,type:t.type.error},i))}},UIKit=class t{static#t=$objc(\"UIApplication\").$sharedApplication();static#e=$objc(\"UINotificationFeedbackGenerator\").$new();static feedbackSuccess(){t.#e.$notificationOccurred(0)}static feedbackError(){t.#e.$notificationOccurred(2)}static align={left:0,right:1,top:2,bottom:3};static textColor=$color(\"primaryText\");static linkColor=$color(\"systemLink\");static primaryViewBackgroundColor=$color(\"primarySurface\");static scrollViewBackgroundColor=$color(\"insetGroupedBackground\");static scrollViewList=[\"list\",\"matrix\"];static isLargeScreen=$device.isIpad||$device.isIpadPro;static get windowSize(){return $objc(\"UIWindow\").$keyWindow().jsValue().size}static NavigationBarNormalHeight=$objc(\"UINavigationController\").invoke(\"alloc.init\").$navigationBar().jsValue().frame.height;static NavigationBarLargeTitleHeight=$objc(\"UITabBarController\").invoke(\"alloc.init\").$tabBar().jsValue().frame.height+t.NavigationBarNormalHeight;static get isSplitScreenMode(){return t.isLargeScreen&&$device.info.screen.width!==t.windowSize.width}static get topSafeAreaInsets(){return t.#t?.$keyWindow()?.$safeAreaInsets()?.top??0}static get bottomSafeAreaInsets(){return t.#t?.$keyWindow()?.$safeAreaInsets()?.bottom??0}static get statusBarOrientation(){return t.#t.$statusBarOrientation()}static get consoleBarHeight(){if($app.isDebugging){let e=t.#t.$statusBarFrame().height+26;return $device.isIphoneX&&(e+=30),e}return 0}static get isHorizontal(){return 3===t.statusBarOrientation||4===t.statusBarOrientation}static loading(){let e=$ui.create(t.blurBox({cornerRadius:15},[{type:\"spinner\",props:{loading:!0,style:0},layout:(t,e)=>{t.size.equalTo(e.prev),t.center.equalTo(e.super)}}]));return{start:()=>{$ui.controller.view.insertAtIndex(e,0),e.layout(((e,i)=>{e.center.equalTo(i.super);let s=Math.min(.6*Math.min(t.windowSize.width,t.windowSize.height),260);e.size.equalTo($size(s,s))})),e.moveToFront()},end:()=>{e.remove()}}}static defaultBackgroundColor(e){return t.scrollViewList.indexOf(e)>-1?t.scrollViewBackgroundColor:t.primaryViewBackgroundColor}static separatorLine(e={},i=t.align.bottom){return{type:\"canvas\",props:e,layout:(e,s)=>{void 0===s.prev?e.top.equalTo(s.super):i===t.align.bottom?e.top.equalTo(s.prev.bottom):e.top.equalTo(s.prev.top),e.height.equalTo(1/$device.info.screen.scale),e.left.right.inset(0)},events:{draw:(t,i)=>{i.strokeColor=e.bgcolor??$color(\"separatorColor\"),i.setLineWidth(1),i.moveToPoint(0,0),i.addLineToPoint(t.frame.width,0),i.strokePath()}}}}static blurBox(t={},e=[],i=$layout.fill){return{type:\"blur\",props:Object.assign({style:$blurStyle.thinMaterial},t),views:e,layout:i}}static getContentSize(e,i=\"A\",s=t.windowSize.width,r){let n={text:i,width:s,font:e};return void 0!==r&&(n.lineSpacing=r),$text.sizeThatFits(n)}static getSymbolSize(t,e){let i=(t=\"string\"==typeof t?$image(t):t).size.width/t.size.height;return t.size.width>t.size.height?$size(e,e/i):$size(e*i,e)}static push({views:t,statusBarStyle:e=0,title:i=\"\",navButtons:s=[{title:\"\"}],bgcolor:r=t[0]?.props?.bgcolor??\"primarySurface\",titleView:n,disappeared:a}={}){let o={statusBarStyle:e,navButtons:s,title:i,bgcolor:\"string\"==typeof r?$color(r):r};n&&(o.titleView=n),$ui.push({props:o,events:{disappeared:()=>{void 0!==a&&a()}},views:[{type:\"view\",views:t,layout:(t,e)=>{t.top.equalTo(e.super.safeArea),t.bottom.equalTo(e.super),t.left.right.equalTo(e.super.safeArea)}}]})}static compressImage(t,e=921600){let i=$imagekit.info(t);if(i.height*i.width>e){let s=e/(i.height*i.width);t=$imagekit.scaleBy(t,s)}return t}static deleteConfirm(t,e){$ui.alert({title:$l10n(\"DELETE_CONFIRM_TITLE\"),message:t,actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{e()}},{title:$l10n(\"CANCEL\")}]})}static bytesToSize(t){if(0===t)return\"0 B\";let e=Math.floor(Math.log(t)/Math.log(1024));return(t/Math.pow(1024,e)).toPrecision(3)+\" \"+[\"B\",\"KB\",\"MB\",\"GB\",\"TB\",\"PB\",\"EB\",\"ZB\",\"YB\"][e]}},UILoading=class{#t;text=\"\";interval;fullScreen=!1;#e=()=>{};constructor(){this.#t=$text.uuid}updateText(t){$(this.#t).text=t}setLoop(t){if(\"function\"!=typeof t)throw\"loop must be a function\";this.#e=t}done(){clearInterval(this.interval)}load(){$ui.render({props:{navBarHidden:this.fullScreen},views:[{type:\"spinner\",props:{loading:!0},layout:(t,e)=>{t.centerY.equalTo(e.super).offset(-15),t.width.equalTo(e.super)}},{type:\"label\",props:{id:this.#t,align:$align.center,text:\"\"},layout:(t,e)=>{t.top.equalTo(e.prev.bottom).offset(10),t.left.right.equalTo(e.super)}}],layout:$layout.fill,events:{appeared:()=>{this.interval=setInterval((()=>{this.#e()}),100)}}})}},View=class t{id=$text.uuid;type;props;views;events;layout;#t=void 0;#e=null;constructor({type:t=\"view\",props:e={},views:i=[],events:s={},layout:r=$layout.fill}={}){this.type=t,this.props=e,this.views=i,this.events=s,this.layout=r,this.props.id?this.id=this.props.id:this.props.id=this.id}static create(t){return new this(t)}static createFromViews(t){return new this({views:t})}get scrollableView(){return this.scrollable?this.#e:null}set scrollableView(t){this.#e=t}get scrollable(){if(void 0===this.#t)if(this.#t=!1,UIKit.scrollViewList.indexOf(this.type)>-1)this.scrollableView=this,this.#t=!0;else if(this.views.length>0){let e=i=>{if(!this.#t&&i?.length>0)for(let s=0;s-1)return typeof i[s]!==t&&(i[s]=t.create(i[s])),this.scrollableView=i[s],void(this.#t=!0);e(i[s].views)}};e(this.views)}return this.#t}set scrollable(t){throw new Error(\"[scrollable] is readonly prop.\")}setProps(t){return Object.keys(t).forEach((e=>this.setProp(e,t[e]))),this}setProp(t,e){return\"id\"===t&&(this.id=e),this.props[t]=e,this}setViews(t){return this.views=t,this.#t=void 0,this}setEvents(t){return Object.keys(t).forEach((e=>this.setEvent(e,t[e]))),this}setEvent(t,e){return this.events[t]=e,this}eventMiddleware(t,e){let i=this.events[t];return this.events[t]=(...t)=>{\"function\"==typeof i&&e(i,...t)},this}assignEvent(t,e){let i=this.events[t];return this.events[t]=(...t)=>{\"function\"==typeof i&&i(...t),e(...t)},this}setLayout(t){return this.layout=t,this}getView(){return this}get definition(){return this.getView()}},FileStorageParameterError=class extends Error{constructor(t){super(`Parameter [${t}] is required.`),this.name=\"FileStorageParameterError\"}},FileStorageFileNotFoundError=class extends Error{constructor(t){super(`File not found: ${t}`),this.name=\"FileStorageFileNotFoundError\"}},RequestError=class extends Error{constructor({message:t,code:e,type:i}={}){super(t),this.name=\"RequestError\",this.code=e,this.type=i}},SettingLoadConfigError=class extends Error{constructor(){super(\"Call loadConfig() first.\"),this.name=\"SettingLoadConfigError\"}},SettingReadonlyError=class extends Error{constructor(){super(\"Attempted to assign to readonly property.\"),this.name=\"SettingReadonlyError\"}},SheetViewUndefinedError=class extends Error{constructor(){super(\"Please call setView(view) first.\"),this.name=\"SheetViewUndefinedError\"}},ValidationError=class extends Error{constructor(t,e){super(`The type of the parameter '${t}' must be '${e}'`),this.name=\"ValidationError\"}},FixedFooterView=class extends View{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",UIKit.primaryViewBackgroundColor),this.layout=(t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.height)},this.views=[View.create({props:this.props,views:this.views,layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.height.equalTo(this.height)}})],this}},Matrix=class extends View{titleStyle={font:$font(\"bold\",21),height:30};#t;#e;templateIdByIndex(t){return void 0===this.props.template.views[t]?.props?.id&&(void 0===this.props.template.views[t].props&&(this.props.template.views[t].props={}),this.props.template.views[t].props.id=$text.uuid),this.props.template.views[t].props.id}get templateHiddenStatus(){if(!this.#e){this.#e={};for(let t=0;t{t.items=t.items.filter((t=>!0===t?.__title?.hidden)),e.push(t)})),e}set data(t){this.props.data=this.rebuildData(t),$(this.id).data=this.props.data}#i(t){let e={...this.hiddenViews};return Object.assign(e,{__templateProps:{hidden:!0},__title:{hidden:!1,text:t,info:{title:!0}}}),e}rebuildData(t=[]){return t.map((t=>(t.items=t.items.map((t=>(Object.keys(t).forEach((e=>{t[e].hidden=this.templateHiddenStatus[e]??!1})),Object.keys(this.templateHiddenStatus).forEach((e=>{t[e]||(t[e]={}),t[e].hidden=this.templateHiddenStatus[e]})),t.__templateProps={hidden:!1},t.__title={hidden:!0},t))),t.title&&t.items.unshift(this.#i(t.title)),t)))}rebuildTemplate(){let t={};void 0!==this.props.template.props&&(void 0!==this.props.template.props.cornerRadius&&(this.props.template.props.clipsToBounds=!1),t=Object.assign(this.props.template.props,{id:\"__templateProps\",hidden:!1}));let e=[{type:\"view\",props:t,layout:$layout.fill},{type:\"label\",props:{id:\"__title\",hidden:!0,font:this.titleStyle.font},layout:(t,e)=>{t.top.inset(-this.titleStyle.height/4*3),t.height.equalTo(this.titleStyle.height),t.width.equalTo(e.super.safeArea)}}].concat(this.props.template.views);this.props.template.views=e}insert(t,e=!0){return t.indexPath=this.indexPath(t.indexPath,e),$(this.id).insert(t)}delete(t,e=!0){return t=this.indexPath(t,e),$(this.id).delete(t)}object(t,e=!0){return t=this.indexPath(t,e),$(this.id).object(t)}cell(t,e=!0){return t=this.indexPath(t,e),$(this.id).cell(t)}indexPath(t,e){let i=e?1:0;return t=\"number\"==typeof t?$indexPath(0,t+i):$indexPath(t.section,t.row+i)}getView(){return this.props.data=this.rebuildData(this.props.data),this.rebuildTemplate(),this.setEvent(\"itemSize\",((t,e)=>{if(t.object(e)?.__title?.info?.title)return $size(Math.max($device.info.screen.width,$device.info.screen.height),0);let i=this.props.columns??2,s=this.props.spacing??15,r=this.props.itemWidth??this.props.itemSize?.width??(t.super.frame.width-s*(i+1))/i,n=this.props.itemHeight??this.props.itemSize?.height??100;return $size(r,n)})),this}},BarTitleView=class extends View{controller={};setController(t){return this.controller=t,this}},BarButtonItem=class t extends View{static#t;edges=15;buttonEdges=this.edges/2;iconSize=24;fontSize=17;color=UIKit.textColor;title;#e;align=UIKit.align.right;get symbol(){return this.#e}set symbol(t){this.#e=\"string\"==typeof t?$image(t):t}get width(){if(this.title){let t=$text.sizeThatFits({text:this.title,width:UIKit.windowSize.width,font:$font(this.fontSize)});return Math.ceil(t.width)+this.edges}return this.iconSize+this.edges}static get style(){return void 0===this.#t&&(this.#t=new t),this.#t}setEdges(t){return this.edges=t,this}setFontSize(t){return this.fontSize=t,this}setColor(t=UIKit.textColor){return this.color=t,this}setTitle(t){return this.title=t,this}setSymbol(t){return this.symbol=t,this}setMenu(t){return this.menu=t,this}setAlign(t){return this.align=t,this}setLoading(t){t?($(this.id).hidden=!0,$(\"spinner-\"+this.id).hidden=!1):($(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0)}#i(){let t=$(`icon-button-${this.id}`),e=$(`icon-checkmark-${this.id}`);t.alpha=0,$(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0,$ui.animate({duration:.6,animation:()=>{e.alpha=1},completion:()=>{$delay(.3,(()=>$ui.animate({duration:.6,animation:()=>{e.alpha=0},completion:()=>{$ui.animate({duration:.4,animation:()=>{t.alpha=1},completion:()=>{t.alpha=1}})}})))}})}getView(){let t=this.events.tapped;return this.events.tapped=e=>{t&&t({start:()=>this.setLoading(!0),done:()=>this.#i(),cancel:()=>this.setLoading(!1)},e)},{type:\"view\",props:{info:{align:this.align}},views:[{type:\"button\",props:Object.assign({id:this.id,bgcolor:$color(\"clear\"),font:$font(this.fontSize),titleColor:this.color,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},this.menu?{menu:this.menu}:{},this.title?{title:this.title}:{},this.props),views:[{type:\"image\",props:Object.assign({id:`icon-button-${this.id}`,hidden:void 0===this.symbol,tintColor:this.color},this.symbol?{image:this.symbol}:{}),layout:(t,e)=>{this.symbol&&t.size.equalTo(UIKit.getSymbolSize(this.symbol,this.iconSize)),t.center.equalTo(e.super)}},{type:\"image\",props:{id:`icon-checkmark-${this.id}`,alpha:0,tintColor:this.color,symbol:\"checkmark\"},layout:(t,e)=>{t.center.equalTo(e.super),t.size.equalTo(UIKit.getSymbolSize(\"checkmark\",this.iconSize))}}],events:this.events,layout:$layout.fill},{type:\"spinner\",props:{id:\"spinner-\"+this.id,loading:!0,hidden:!0},layout:$layout.fill}],layout:(t,e)=>{if(t.size.equalTo($size(this.width,UIKit.NavigationBarNormalHeight)),t.centerY.equalTo(e.super),e.prev&&e.prev?.info?.align===this.align)this.align===UIKit.align.right?t.right.equalTo(e.prev.left).offset(-this.buttonEdges):t.left.equalTo(e.prev.right).offset(this.buttonEdges);else{let e=this.edges/2;this.align===UIKit.align.right?t.right.inset(e):t.left.inset(e)}}}}static creat({id:e,symbol:i,title:s,tapped:r,menu:n,events:a,color:o,align:l=UIKit.align.right}={}){let h=new t;return h.setEvents(Object.assign({tapped:r},a)).setAlign(l).setSymbol(i).setTitle(s).setColor(o).setMenu(n),e&&h.setProp(\"id\",e),h}},NavigationBar=class t extends View{static largeTitleDisplayModeAutomatic=0;static largeTitleDisplayModeAlways=1;static largeTitleDisplayModeNever=2;static pageSheetNavigationBarHeight=56;navigationBarItems;title=\"\";prefersLargeTitles=!0;largeTitleDisplayMode=t.largeTitleDisplayModeAutomatic;fontFamily=\"bold\";largeTitleFontSize=34;largeTitleFontHeight=$text.sizeThatFits({text:\"A\",width:100,font:$font(this.fontFamily,this.largeTitleFontSize)}).height;navigationBarTitleFontSize=17;topSafeArea=!0;contentViewHeightOffset=10;navigationBarNormalHeight=UIKit.NavigationBarNormalHeight;navigationBarLargeTitleHeight=UIKit.NavigationBarLargeTitleHeight;setTopSafeArea(){return this.topSafeArea=!0,this}removeTopSafeArea(){return this.topSafeArea=!1,this}setLargeTitleDisplayMode(t){return this.largeTitleDisplayMode=t,this}setBackgroundColor(t){return this.backgroundColor=t,this}setTitle(t){return this.title=t,this}setPrefersLargeTitles(t){return this.prefersLargeTitles=t,this}setContentViewHeightOffset(t){return this.contentViewHeightOffset=t,this}getLargeTitleView(){return this.prefersLargeTitles&&this.largeTitleDisplayMode!==t.largeTitleDisplayModeNever?{type:\"label\",props:{id:this.id+\"-large-title\",text:this.title,textColor:UIKit.textColor,align:$align.left,font:$font(this.fontFamily,this.largeTitleFontSize),line:1},layout:(t,e)=>{t.left.equalTo(e.super.safeArea).offset(15),t.height.equalTo(this.largeTitleFontHeight),t.top.equalTo(e.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}:{props:{id:this.id+\"-large-title\"},layout:(t,e)=>{t.left.top.right.inset(0),t.bottom.equalTo(e.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}}getNavigationBarView(){let e=(t,e)=>{let i=(t,i)=>{t.top.equalTo(i.super.safeAreaTop),t.bottom.equalTo(i.super.safeAreaTop).offset(this.navigationBarNormalHeight),e===UIKit.align.left?t.left.equalTo(i.super.safeArea):t.right.equalTo(i.super.safeArea)};if(t&&!Array.isArray(t))return{type:\"view\",views:[t],layout:i};let s=0,r=[];t.forEach((t=>{s+=t.width,r.push(t.definition)}));let n=t[0]?.edges??0;return s+=t.length>=2?2*n:n,t.length>0?{type:\"view\",views:r,info:{width:s},layout:(t,e)=>{i(t,e),t.width.equalTo(s)}}:{type:\"view\",layout:t=>t.size.equalTo(0)}},i=e(this.navigationBarItems.popButtonView??this.navigationBarItems.leftButtons,UIKit.align.left),s=e(this.navigationBarItems.rightButtons,UIKit.align.right),r=this.prefersLargeTitles,n=!this.prefersLargeTitles||this.largeTitleDisplayMode===t.largeTitleDisplayModeNever;return{type:\"view\",props:{id:this.id+\"-navigation\",bgcolor:$color(\"clear\")},layout:(t,e)=>{t.left.top.right.inset(0),t.bottom.equalTo(e.super.safeAreaTop).offset(this.navigationBarNormalHeight)},views:[this.backgroundColor?{type:\"view\",props:{hidden:r,bgcolor:this.backgroundColor,id:this.id+\"-background\"},layout:$layout.fill}:UIKit.blurBox({hidden:r,id:this.id+\"-background\"}),UIKit.separatorLine({id:this.id+\"-underline\",alpha:r?0:1}),{type:\"view\",props:{alpha:0,bgcolor:$color(\"clear\"),id:this.id+\"-large-title-mask\"},events:{ready:t=>{t.bgcolor=$(this.id+\"-large-title\")?.prev.bgcolor}},layout:$layout.fill},i,s,{type:\"view\",views:[{type:\"label\",props:{id:this.id+\"-small-title\",alpha:n?1:0,text:this.title,font:$font(this.fontFamily,this.navigationBarTitleFontSize),align:$align.center,bgcolor:$color(\"clear\"),textColor:UIKit.textColor},layout:(t,e)=>{t.edges.equalTo(e.super.safeArea);let r=UIKit.getContentSize($font(this.fontFamily,this.navigationBarTitleFontSize),e.text).width,n=Math.max(i.info?.width??0,s.info?.width??0);UIKit.windowSize.width-2*n>r&&t.centerX.equalTo(e.super.super)}}],layout:(t,e)=>{t.top.bottom.equalTo(e.super.safeArea),t.left.equalTo(e.prev.prev.right),t.right.equalTo(e.prev.left)}}]}}},NavigationBarController=class t extends Controller{static largeTitleViewSmallMode=0;static largeTitleViewLargeMode=1;navigationBar;updateSelector(){this.selector={navigation:$(this.navigationBar.id+\"-navigation\"),largeTitleView:$(this.navigationBar.id+\"-large-title\"),smallTitleView:$(this.navigationBar.id+\"-small-title\"),underlineView:this.navigationBar.navigationBarItems.isPinTitleView?$(this.navigationBar.id+\"-title-view-underline\"):$(this.navigationBar.id+\"-underline\"),largeTitleMaskView:$(this.navigationBar.id+\"-large-title-mask\"),backgroundView:$(this.navigationBar.id+\"-background\"),titleViewBackgroundView:$(this.navigationBar.id+\"-title-view-background\")}}toNormal(t=!0){this.updateSelector(),this.selector.backgroundView.hidden=!1,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=1,this.selector.smallTitleView.alpha=1,this.selector.largeTitleView.alpha=0}}),t&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=NavigationBar.largeTitleDisplayModeNever)}toLargeTitle(t=!0){this.updateSelector(),this.selector.backgroundView.hidden=!0,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=0,this.selector.smallTitleView.alpha=0,this.selector.largeTitleView.alpha=1}}),t&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=NavigationBar.largeTitleDisplayModeAlways)}#t(e){let i=e===t.largeTitleViewSmallMode;this.selector.largeTitleView.alpha=i?0:1,$ui.animate({duration:.2,animation:()=>{this.selector.smallTitleView.alpha=i?1:0}})}#e(e){if(this.selector.largeTitleView.updateLayout(((t,i)=>{this.navigationBar.navigationBarNormalHeight-e>0?t.top.equalTo(i.super.safeAreaTop).offset(this.navigationBar.navigationBarNormalHeight-e):t.top.equalTo(i.super.safeAreaTop).offset(0)})),e>0)e>=this.navigationBar.navigationBarNormalHeight?this.#t(t.largeTitleViewSmallMode):this.#t(t.largeTitleViewLargeMode);else{this.#t(t.largeTitleViewLargeMode);let i=this.navigationBar.largeTitleFontSize-.04*e;i>40&&(i=40),this.selector.largeTitleView.font=$font(this.navigationBar.fontFamily,i)}}#i(t){let e=this.navigationBar.largeTitleDisplayMode===NavigationBar.largeTitleDisplayModeNever?5:this.navigationBar.navigationBarNormalHeight,i=void 0!==this.selector.titleViewBackgroundView;if(t>e){this.selector.backgroundView.hidden=!1;let s=()=>{i&&this.navigationBar.navigationBarItems.isPinTitleView&&(this.selector.titleViewBackgroundView.alpha=1),this.selector.largeTitleMaskView.alpha=0,this.selector.underlineView.alpha=1};(t-e)/3>=1?s():$ui.animate({duration:.2,animation:()=>{s()}})}else this.selector.largeTitleMaskView.alpha=t>0?1:0,this.selector.underlineView.alpha=0,i&&(this.selector.titleViewBackgroundView.alpha=0),this.selector.backgroundView.hidden=!0}didScroll(t){if(!this.navigationBar.prefersLargeTitles)return;let e=this.navigationBar.largeTitleDisplayMode;if(e!==NavigationBar.largeTitleDisplayModeAlways)if(this.updateSelector(),e===NavigationBar.largeTitleDisplayModeAutomatic){if(!this.navigationBar.navigationBarItems?.isPinTitleView&&(this.navigationBar.navigationBarItems?.titleView?.controller.didScroll(t),t>0)){(t-=this.navigationBar.navigationBarItems?.titleView?.height??0)<0&&(t=0)}this.#e(t),this.#i(t)}else e===NavigationBar.largeTitleDisplayModeNever&&this.#i(t)}didEndDragging(t,e,i,s){if(!this.navigationBar.prefersLargeTitles)return;let r=this.navigationBar.largeTitleDisplayMode;if(r!==NavigationBar.largeTitleDisplayModeAlways&&(this.updateSelector(),r===NavigationBar.largeTitleDisplayModeAutomatic)){let r=0;this.navigationBar.navigationBarItems?.isPinTitleView||(this.navigationBar.navigationBarItems?.titleView?.controller.didEndDragging(t,e,i,s),r=this.navigationBar.navigationBarItems?.titleView?.height??0,t-=r),t>=0&&t<=this.navigationBar.largeTitleFontHeight&&i($point(0,t>=this.navigationBar.largeTitleFontHeight/2?this.navigationBar.navigationBarNormalHeight+r-s:r-s))}}},NavigationViewTypeError=class extends ValidationError{constructor(t,e){super(t,e),this.name=\"NavigationViewTypeError\"}},NavigationView=class extends Controller{page;navigationController=new NavigationBarController;navigationBar=new NavigationBar;navigationBarItems=new NavigationBarItems;constructor(){super(),this.navigationBar.navigationBarItems=this.navigationBarItems,this.navigationController.navigationBar=this.navigationBar}navigationBarTitle(t){return this.navigationBar.setTitle(t),this}setView(t){if(\"object\"!=typeof t)throw new NavigationViewTypeError(\"view\",\"object\");return this.view=View.create(t),this}#t(){if(!(this.view instanceof View))throw new NavigationViewTypeError(\"view\",\"View\");let t=this.view.scrollableView,e=$app.isDebugging||Kernel.isTaio?0:UIKit.topSafeAreaInsets,i=this.navigationBar.largeTitleDisplayMode===NavigationBar.largeTitleDisplayModeNever?this.navigationBar.navigationBarNormalHeight:this.navigationBar.navigationBarLargeTitleHeight,s=this.navigationBar.contentViewHeightOffset+i;if(this.navigationBarItems.titleView&&(s+=this.navigationBarItems.titleView.topOffset,s+=this.navigationBarItems.titleView.height,s+=this.navigationBarItems.titleView.bottomOffset),!this.view.scrollable||!1===t.props.associateWithNavigationBar)return void(this.view.layout=(t,i)=>{t.left.right.equalTo(i.super.safeArea),t.bottom.equalTo(i.super);let r=s-this.navigationBar.contentViewHeightOffset;(!UIKit.isHorizontal||UIKit.isLargeScreen)&&this.navigationBar.topSafeArea&&(r+=e),t.top.equalTo(r)});t.props.stickyHeader&&(s-=i,s+=this.navigationBar.largeTitleFontHeight),t.props.header?t.props.header={type:\"view\",props:{height:s+(t.props.header?.props?.height??0)},views:[{type:\"view\",props:{clipsToBounds:!0},views:[t.props.header],layout:(t,e)=>{t.top.equalTo(s),t.bottom.width.equalTo(e.super)}}]}:t.props.header={props:{height:s}},t.props.footer=Object.assign({props:{}},t.props.footer??{}),t.props.footer.props.height=(this.navigationBarItems.fixedFooterView?.height??0)+(t.props.footer.props?.height??0);let r=this.navigationBarItems.isPinTitleView?this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset+this.navigationBar.contentViewHeightOffset:0;if(t.props.indicatorInsets){let e=t.props.indicatorInsets;t.props.indicatorInsets=$insets(e.top+this.navigationBar.navigationBarNormalHeight+r,e.left,e.bottom+(this.navigationBarItems.fixedFooterView?.height??0),e.right)}else t.props.indicatorInsets=$insets(this.navigationBar.navigationBarNormalHeight+r,0,this.navigationBarItems.fixedFooterView?.height??0,0);t.layout=(e,i)=>{t.props.stickyHeader?e.top.equalTo(i.super.safeArea).offset(this.navigationBar.navigationBarNormalHeight):e.top.equalTo(i.super),e.left.right.equalTo(i.super.safeArea),e.bottom.equalTo(i.super)},t.assignEvent(\"didScroll\",(i=>{let s=i.contentOffset.y;(!UIKit.isHorizontal||UIKit.isLargeScreen)&&this.navigationBar.topSafeArea&&!t.props.stickyHeader&&(s+=e),this.navigationController.didScroll(s)})).assignEvent(\"didEndDragging\",((i,s)=>{let r=i.contentOffset.y,n=0;(!UIKit.isHorizontal||UIKit.isLargeScreen)&&this.navigationBar.topSafeArea&&!t.props.stickyHeader&&(r+=e,n=e),this.navigationController.didEndDragging(r,s,((...t)=>i.scrollToOffset(...t)),n)})).assignEvent(\"didEndDecelerating\",((...e)=>{e[0].tracking||t.events?.didEndDragging(...e)}))}#e(){if(this.navigationBar.prefersLargeTitles){this.#t();let t={};if(this.navigationBarItems.titleView){let e=this.navigationBar.largeTitleDisplayMode===NavigationBar.largeTitleDisplayModeNever?1:0;t=View.create({views:[this.navigationBar.backgroundColor?{type:\"view\",props:{alpha:e,bgcolor:this.navigationBar.backgroundColor,id:this.navigationBar.id+\"-title-view-background\"},layout:$layout.fill}:UIKit.blurBox({alpha:e,id:this.navigationBar.id+\"-title-view-background\"}),UIKit.separatorLine({id:this.navigationBar.id+\"-title-view-underline\",alpha:e}),this.navigationBarItems.titleView.definition],layout:(t,e)=>{t.top.equalTo(e.prev.bottom),t.width.equalTo(e.super),t.height.equalTo(this.navigationBarItems.titleView.topOffset+this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset)}})}this.page=PageView.createFromViews([this.view,this.navigationBar.getLargeTitleView(),t,this.navigationBar.getNavigationBarView(),this.navigationBarItems.fixedFooterView?.definition??{}])}else this.page=PageView.createFromViews([this.view]);this.view.props?.bgcolor?this.page.setProp(\"bgcolor\",this.view.props.bgcolor):this.page.setProp(\"bgcolor\",UIKit.defaultBackgroundColor(this.view.type))}getPage(){return this.page||this.#e(),this.page}},SearchBar=class extends BarTitleView{height=35;topOffset=15;bottomOffset=10;horizontalOffset=15;kbType=$kbType.search;placeholder=$l10n(\"SEARCH\");inputEvents={};keyboardView;accessoryView;cancelButtonFont=$font(16);constructor(t){super(t),this.setController(new SearchBarController),this.controller.setSearchBar(this)}get cancelButtonWidth(){return UIKit.getContentSize(this.cancelButtonFont,$l10n(\"CANCEL\")).width}setEvent(t,e){return this.inputEvents[t]=e,this}setPlaceholder(t){return this.placeholder=t,this}setKbType(t){return this.kbType=t,this}setKeyboardView(t){return this.keyboardView=t,this}setAccessoryView(t){return this.accessoryView=t,this}onBeginEditingAnimate(){$ui.animate({duration:.3,animation:()=>{let t=this.cancelButtonWidth;$(this.id+\"-cancel-button\").updateLayout(((e,i)=>{e.left.equalTo(i.super.right).offset(-t)})),$(this.id+\"-cancel-button\").alpha=1,$(this.id+\"-cancel-button\").relayout(),$(this.id+\"-input\").updateLayout((e=>{e.right.inset(t+this.horizontalOffset/2)})),$(this.id+\"-input\").relayout()}})}onEndEditingAnimate(){$ui.animate({duration:.3,animation:()=>{$(this.id+\"-cancel-button\").updateLayout(((t,e)=>{t.left.equalTo(e.super.right)})),$(this.id+\"-cancel-button\").alpha=0,$(this.id+\"-cancel-button\").relayout(),$(this.id+\"-input\").updateLayout($layout.fill),$(this.id+\"-input\").relayout()}})}cancel(){$(this.id+\"-input\").blur(),$(this.id+\"-input\").text=\"\",this.onEndEditingAnimate(),this.controller.callEvent(\"onCancel\")}getView(){return this.props={id:this.id,smoothCorners:!0,cornerRadius:6},this.views=[{type:\"input\",props:{id:this.id+\"-input\",type:this.kbType,bgcolor:$color(\"#EEF1F1\",\"#212121\"),placeholder:this.placeholder,keyboardView:this.keyboardView,accessoryView:this.accessoryView},layout:$layout.fill,events:Object.assign({didBeginEditing:t=>{this.onBeginEditingAnimate(),this.controller.callEvent(\"onBeginEditing\",t.text)},didEndEditing:t=>{this.controller.callEvent(\"onEndEditing\",t.text)},changed:t=>this.controller.callEvent(\"onChange\",t.text),returned:t=>this.controller.callEvent(\"onReturn\",t.text)},this.inputEvents)},{type:\"button\",props:{id:this.id+\"-cancel-button\",title:$l10n(\"CANCEL\"),font:this.cancelButtonFont,titleColor:$color(\"tintColor\"),bgcolor:$color(\"clear\"),alpha:0,hidden:!1},events:{tapped:()=>this.cancel()},layout:(t,e)=>{t.height.equalTo(e.super),t.width.equalTo(this.cancelButtonWidth),t.left.equalTo(e.super.right)}}],this.layout=(t,e)=>{t.height.equalTo(this.height),t.top.equalTo(e.super.safeArea).offset(this.topOffset),t.left.equalTo(e.super.safeArea).offset(this.horizontalOffset),t.right.equalTo(e.super.safeArea).offset(-this.horizontalOffset)},this}},SearchBarController=class extends Controller{setSearchBar(t){return this.searchBar=t,this}updateSelector(){this.selector={inputBox:$(this.searchBar.id),input:$(this.searchBar.id+\"-input\")}}hide(){this.updateSelector(),this.selector.inputBox.updateLayout((t=>{t.height.equalTo(0)}))}show(){this.updateSelector(),this.selector.inputBox.updateLayout((t=>{t.height.equalTo(this.searchBar.height)}))}didScroll(t){this.updateSelector();let e=this.searchBar.height-t;if(e=e>0?e>this.searchBar.height?this.searchBar.height:e:0,this.selector.inputBox.updateLayout((t=>{t.height.equalTo(e)})),t>0){let e=(this.searchBar.height/2-5-t)/10;this.selector.input.alpha=e}else this.selector.input.alpha=1}didEndDragging(t,e,i){this.updateSelector(),t>=0&&t<=this.searchBar.height&&i($point(0,t>=this.searchBar.height/2?this.searchBar.height:0))}},ViewController=class extends Controller{#t=[];#e(t){t.callEvent(\"onPop\"),this.callEvent(\"onPop\",t),this.#t.pop()}push(t){let e=this.#t[this.#t.length-1];t.navigationBarItems.addPopButton(e?.navigationBar.title),this.#t.push(t),$ui.push({props:{statusBarStyle:0,navBarHidden:!0},events:{dealloc:()=>{this.#e(t)}},views:[t.getPage().definition],layout:$layout.fill})}},SettingInfo=class extends SettingItem{getView(){let t=Array.isArray(this.default),e=t?this.default[0]:this.default,i=t?this.default[1]:this.default;return{type:\"view\",props:{selectable:!0},views:[this.createLineLabel(),{type:\"label\",props:{text:e,align:$align.right,textColor:$color(\"darkGray\")},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(SettingItem.edgeOffset),t.width.equalTo(180)}},{type:\"view\",events:{tapped:()=>{$ui.alert({title:this.title,message:i,actions:[{title:$l10n(\"COPY\"),handler:()=>{$clipboard.text=i,$ui.toast($l10n(\"COPIED\"))}},{title:$l10n(\"OK\")}]})}},layout:(t,e)=>{t.right.inset(0),t.size.equalTo(e.super)}}],layout:$layout.fill}}},SettingSwitch=class extends SettingItem{getView(){return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"switch\",props:{on:this.get(),onColor:$color(\"#00CC00\")},events:{changed:t=>{try{this.set(t.on)}catch(e){throw t.on=!t.on,e}}},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(SettingItem.edgeOffset)}}],layout:$layout.fill}}},SettingString=class extends SettingItem{getView(){return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"button\",props:{symbol:\"square.and.pencil\",bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\")},events:{tapped:t=>{let e=$ui.popover({sourceView:t,sourceRect:t.bounds,directions:$popoverDirection.down,size:$size(320,150),views:[{type:\"text\",props:{id:`${this.id}-string`,align:$align.left,text:this.get()},layout:t=>{t.left.right.inset(10),t.top.inset(20),t.height.equalTo(90)}},{type:\"button\",props:{symbol:\"checkmark\",bgcolor:$color(\"clear\"),titleEdgeInsets:10,contentEdgeInsets:0},layout:t=>{t.right.inset(10),t.bottom.inset(25),t.size.equalTo(30)},events:{tapped:()=>{this.set($(`${this.id}-string`).text),e.dismiss()}}}]})}},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(0),t.size.equalTo(50)}}],layout:$layout.fill}}},SettingStepper=class extends SettingItem{with({min:t,max:e}={}){return this.options={min:t,max:e},this}getView({min:t,max:e}={}){let i=`${this.id}-label`;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"label\",props:{id:i,text:this.get(),align:$align.left},layout:(t,e)=>{t.height.equalTo(e.super),t.right.inset(120)}},{type:\"stepper\",props:{min:t,max:e,value:this.get()},events:{changed:t=>{$(i).text=t.value;try{this.set(t.value)}catch(t){throw $(i).text=this.get(),t}}},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(SettingItem.edgeOffset)}}],layout:$layout.fill}}},SettingScript=class extends SettingItem{#h;#c(){$(this.id).bgcolor=$color(\"systemFill\")}#d(t=.3){0===t?$(this.id).bgcolor=$color(\"clear\"):$ui.animate({duration:t,animation:()=>{$(this.id).bgcolor=$color(\"clear\")}})}#p(t,e=!1,i=0){if(t=Object.assign(t,{touchesBegan:()=>{this.#c(),this.#h=$delay(1,(()=>this.#d(0)))},touchesMoved:()=>{this.#h?.cancel(),this.#d(0)}}),e){let e=t.tapped;t.tapped=()=>{this.#c(),$delay(i,(()=>this.#d())),\"function\"==typeof e&&e()}}return t}with({script:t}={}){return this.options={script:t},this}getView({script:script}={}){let buttonId=`${this.id}-button`,rightSymbol=\"chevron.right\",start=()=>{$(buttonId).alpha=0,$(`${buttonId}-spinner`).alpha=1,this.#c()},cancel=()=>{$(buttonId).alpha=1,$(`${buttonId}-spinner`).alpha=0,this.#d()},done=()=>{$(`${buttonId}-spinner`).alpha=0,this.#d();let t=$(buttonId);t.symbol=\"checkmark\",$ui.animate({duration:.6,animation:()=>t.alpha=1,completion:()=>{$ui.animate({duration:.4,animation:()=>t.alpha=0,completion:()=>{t.symbol=rightSymbol,$ui.animate({duration:.4,animation:()=>t.alpha=1})}})}}),$delay(.6,(()=>{}))};return{type:\"view\",props:{id:this.id},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"button\",props:{id:buttonId,symbol:rightSymbol,bgcolor:$color(\"clear\"),tintColor:$color(\"secondaryText\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.right.inset(0),t.height.equalTo(e.super)}},{type:\"spinner\",props:{id:`${buttonId}-spinner`,loading:!0,alpha:0},layout:(t,e)=>{t.size.equalTo(15),t.centerY.equalTo(e.super),t.right.equalTo(e.prev)}}],layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}},{type:\"view\",layout:$layout.fill}],events:this.#p({tapped:()=>{let animate={start:start,cancel:cancel,done:done,touchHighlightStart:()=>this.#c(),touchHighlightEnd:()=>this.#d()};\"function\"==typeof script?script(animate):script.startsWith(\"this.method\")?eval(`(()=>{return ${script}(animate)})()`):eval(script)}}),layout:$layout.fill}}},SettingTab=class extends SettingItem{with({items:t,values:e}={}){return Array.isArray(t)&&(t=t.map((t=>$l10n(t)))),this.options={items:t,values:e},this}getView({items:t,values:e}={}){t=this.evalValues(t),e=this.evalValues(e);let i=t?.length>0&&e?.length===t?.length;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"tab\",props:{items:t??[],index:i?e.indexOf(this.get()):this.get(),dynamicWidth:!0},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.prev)},events:{changed:t=>{i?this.set(e[t.index]):this.set(t.index)}}}],layout:$layout.fill}}},SettingMenu=class extends SettingItem{with({items:t,values:e,pullDown:i}={}){return Array.isArray(t)&&(t=t.map((t=>$l10n(t)))),this.options={items:t,values:e,pullDown:i},this}getView({items:t,values:e,pullDown:i}={}){let s=`${this.id}-label`,r=this.evalValues(t),n=this.evalValues(e),a=r?.length>0&&n?.length===r?.length,o=(t,i)=>{if(a){let t=this.evalValues(e);this.set(t[i])}else this.set(i);$(s).title=t},l=()=>{i||$ui.menu({items:this.evalValues(t),handler:o})};return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"button\",props:{menu:i?{pullDown:!0,asPrimary:!0,items:r.map(((t,e)=>({title:t,handler:()=>o(t,e)})))}:void 0,title:a?r[n.indexOf(this.get())]:r[this.get()],titleColor:$color(\"secondaryText\"),bgcolor:$color(\"clear\"),id:s},events:{tapped:l},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(e.super)}}],layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}}],events:{tapped:l},layout:$layout.fill}}},SettingColor=class extends SettingItem{get(t=null){let e=super.get(t);return e?\"string\"==typeof e?$color(e):$rgba(e.red,e.green,e.blue,e.alpha):t}getView(){let t=`${this.id}-color`;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"view\",props:{id:t,bgcolor:this.get(),circular:!0,borderWidth:1,borderColor:$color(\"#e3e3e3\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.right.inset(SettingItem.edgeOffset),t.size.equalTo(20)}},{type:\"view\",events:{tapped:async()=>{let e=await $picker.color({color:this.get()});this.set(e.components),$(t).bgcolor=$rgba(e.components.red,e.components.green,e.components.blue,e.components.alpha)}},layout:(t,e)=>{t.right.inset(0),t.height.width.equalTo(e.super.height)}}],layout:(t,e)=>{t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},SettingDate=class extends SettingItem{with({mode:t=2}={}){return this.options={mode:t},this}getView({mode:t=2}={}){let e=e=>{let i=\"\";switch(\"number\"==typeof e&&(e=new Date(e)),t){case 0:i=e.toLocaleTimeString();break;case 1:i=e.toLocaleDateString();break;case 2:i=e.toLocaleString()}return i};return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"label\",props:{id:`${this.id}-label`,color:$color(\"secondaryText\"),text:this.get()?e(this.get()):\"None\"},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(e.super)}}],events:{tapped:async()=>{let i=this.get(),s=await $picker.date({props:{mode:t,date:i||Date.now()}});this.set(s.getTime()),$(`${this.id}-label`).text=e(s)}},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},SettingInput=class extends SettingItem{with({secure:t=!1,kbType:e=$kbType.default,saveFunc:i}={}){return this.options={secure:t,kbType:e,saveFunc:i},this}getView({secure:t=!1,kbType:e=$kbType.default,saveFunc:i}={}){void 0===i&&(i=t=>this.set(t));let s=this.id+\"-input\";return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"input\",props:{id:s,type:e,align:$align.right,bgcolor:$color(\"clear\"),textColor:$color(\"secondaryText\"),text:this.get(),font:$font(16),secure:t,accessoryView:UIKit.blurBox({height:44},[UIKit.separatorLine({},UIKit.align.top),{type:\"button\",props:{title:$l10n(\"DONE\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.super)},events:{tapped:()=>{$(s).blur()}}},{type:\"button\",props:{title:$l10n(\"CANCEL\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(t,e)=>{t.left.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.super)},events:{tapped:()=>{let t=$(s),e=this.get(\"\");t.text!==e&&(t.text=e),t.blur()}}}])},layout:(t,e)=>{t.left.equalTo(e.prev.get(\"label\").right).offset(SettingItem.edgeOffset),t.right.inset(SettingItem.edgeOffset);let i=UIKit.getContentSize($font(16),this.get(\"\")).width;t.width.greaterThanOrEqualTo(i+30),t.height.equalTo(e.super)},events:{didBeginEditing:t=>{t.secure=!1,$app.autoKeyboardEnabled||($app.autoKeyboardEnabled=!0)},returned:t=>{t.blur()},didEndEditing:async e=>{let s=this.get(\"\");i(e.text)||(e.text=s),t&&(e.secure=t)}}}],layout:$layout.fill}}},SettingNumber=class extends SettingItem{getView(){return new SettingInput(this).getView({secure:!1,kbType:$kbType.decimal,saveFunc:t=>\"\"!==t&&/^[0-9]+.?[0-9]*$/.test(t)?this.set(Number(t)):($ui.toast($l10n(\"INVALID_VALUE\")),!1)})}},SettingIcon=class extends SettingItem{with({bgcolor:t=\"#000000\"}={}){return this.options={bgcolor:t},this}getView({bgcolor:t=\"#000000\"}={}){let e=`${this.id}-image`;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"image\",props:{cornerRadius:8,bgcolor:\"string\"==typeof t?$color(t):t,smoothCorners:!0},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.super),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:e,image:$image(this.get()),icon:$icon(this.get()?.slice(5,this.get().indexOf(\".\")),$color(\"#ffffff\")),tintColor:$color(\"#ffffff\")},layout:(t,e)=>{t.right.equalTo(e.prev).offset(-5),t.centerY.equalTo(e.super),t.size.equalTo($size(20,20))}}],events:{tapped:()=>{$ui.menu({items:[$l10n(\"JSBOX_ICON\"),$l10n(\"SF_SYMBOLS\"),$l10n(\"IMAGE_BASE64\")],handler:async(t,i)=>{if(0===i){let t=await $ui.selectIcon();this.set(t),$(e).icon=$icon(t.slice(5,t.indexOf(\".\")),$color(\"#ffffff\"))}else(1===i||2===i)&&$input.text({text:\"\",placeholder:t,handler:t=>{\"\"!==t?(this.set(t),1===i?$(e).symbol=t:$(e).image=$image(t)):$ui.toast($l10n(\"INVALID_VALUE\"))}})}})}},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},SettingPush=class extends SettingItem{with({view:t,tapped:e}={}){return this.options={view:t,tapped:e},this}getView({view:view,tapped:tapped}={}){return{type:\"view\",layout:$layout.fill,props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"button\",props:{symbol:\"chevron.right\",bgcolor:$color(\"clear\"),tintColor:$color(\"secondaryText\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.right.inset(SettingItem.edgeOffset),t.height.equalTo(e.super)}},{type:\"view\",layout:$layout.fill}],events:{tapped:()=>{let push=view=>{if(\"string\"==typeof view&&view.startsWith(\"this.method\")?view=eval(`(()=>{return ${view}()})()`):\"function\"==typeof view&&(view=view()),this.setting.isUseJsboxNav)UIKit.push({title:this.title,props:view.props??{},views:[view]});else{let t=new NavigationView;t.setView(view).navigationBarTitle(this.title),t.navigationBarItems.addPopButton(),t.navigationBar.setLargeTitleDisplayMode(NavigationBar.largeTitleDisplayModeNever),this.setting.hasSectionTitle(view)&&t.navigationBar.setContentViewHeightOffset(-10),this.setting.viewController.push(t)}};\"function\"==typeof tapped?tapped(push):push(view)}}}}},SettingChild=class extends SettingItem{with({children:t}={}){return this.options={children:t},this}getView({children:t}={}){return new SettingPush(this).getView({tapped:e=>{this.setting.events?.onChildPush?this.setting.callEvent(\"onChildPush\",this.setting.getListView(t,{}),this.title):e(this.setting.getListView(t,{}))}})}},SettingImage=class extends SettingItem{getImagePath(t=!1){let e=$text.MD5(this.key)+\".jpg\";return t&&(e=\"compress.\"+e),this.setting.imagePath+e}getImage(t=!1){try{return this.setting.fileStorage.readSync(this.getImagePath(t))}catch(t){if(t instanceof FileStorageFileNotFoundError)return null;throw t}}get(t=null){return this.getImage(!1)??null}getView(){let t=`${this.id}-image`,e=$image(\"questionmark.square.dashed\"),i=e=>async()=>{$(t).hidden=!0,$(`${t}-spinner`).hidden=!1,await $wait(.1);try{await e()}catch(t){$ui.alert({title:$l10n(\"ERROR\"),message:String(t)})}await $wait(.1),$(`${t}-spinner`).hidden=!0,$(t).hidden=!1},s=[{title:$l10n(\"PREVIEW\"),handler:i((()=>{let t=this.getImage(!1);t?Sheet.quickLookImage(t):$ui.toast($l10n(\"NO_IMAGE\"))}))},{inline:!0,items:[{title:$l10n(\"SELECT_IMAGE_PHOTO\"),handler:i((async()=>{let e=await $photo.pick({format:\"data\"});if(!e.status||!e.data){if(\"canceled\"!==e?.error?.description)throw new Error(e?.error?.description);return}let i=UIKit.compressImage(e.data.image);this.setting.fileStorage.write(this.getImagePath(!0),i.jpg(.8)),this.setting.fileStorage.write(this.getImagePath(),e.data),$(t).image=i,$ui.success($l10n(\"SUCCESS\"))}))},{title:$l10n(\"SELECT_IMAGE_ICLOUD\"),handler:i((async()=>{let e=await $drive.open();if(!e)return;let i=UIKit.compressImage(e.image);this.setting.fileStorage.write(this.getImagePath(!0),i.jpg(.8)),this.setting.fileStorage.write(this.getImagePath(),e),$(t).image=i,$ui.success($l10n(\"SUCCESS\"))}))}]},{title:$l10n(\"CLEAR_IMAGE\"),destructive:!0,handler:i((()=>{this.setting.fileStorage.delete(this.getImagePath(!0)),this.setting.fileStorage.delete(this.getImagePath()),$(t).image=e,$ui.success($l10n(\"SUCCESS\"))}))}];return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"image\",props:{id:t,image:this.getImage(!0)?.image??e},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.super),t.size.equalTo($size(30,30))}},{type:\"spinner\",props:{id:`${t}-spinner`,loading:!0,hidden:!0},layout:(t,e)=>{t.size.equalTo(e.prev),t.left.top.equalTo(e.prev)}},{type:\"button\",props:{menu:{pullDown:!0,asPrimary:!0,items:s},bgcolor:$color(\"clear\")},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.super),t.size.equalTo($size(30,30))}}],layout:(t,e)=>{t.right.inset(0),t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},Setting=class extends Controller{name;setting={};settingItems={};userData;fileStorage;imagePath;viewController=new ViewController;method={readme:()=>{let t=(()=>{let t=$device.info?.language?.startsWith(\"zh\")?\"README_CN.md\":\"README.md\";try{return __README__[t]??__README__[\"README.md\"]}catch{return $file.read(t)?.string??$file.read(\"README.md\")?.string}})();(new Sheet).setView({type:\"markdown\",props:{content:t},layout:(t,e)=>{t.size.equalTo(e.super)}}).init().present()}};#t=!1;#e=!1;#i;constructor(t={}){super(),\"function\"==typeof t.set&&\"function\"==typeof t.get?(this.set=t.set,this.getOriginal=t.get,this.setUserData(t.userData??{})):(this.fileStorage=t.fileStorage??new FileStorage,this.dataFile=t.dataFile??\"setting.json\"),t.structure?this.setStructure(t.structure):this.setStructurePath(t.structurePath??\"setting.json\"),this.isUseJsboxNav=t.isUseJsboxNav??!1,this.imagePath=(t.name??\"default\")+\".image/\",this.setName(t.name??$text.uuid)}useJsboxNav(){return this.isUseJsboxNav=!0,this}#s(){if(!this.#e)throw new SettingLoadConfigError}loader(t){t.setting=this;let e=null;switch(t.type){case\"info\":e=new SettingInfo(t);break;case\"switch\":e=new SettingSwitch(t);break;case\"string\":e=new SettingString(t);break;case\"stepper\":e=new SettingStepper(t).with({min:t.min??1,max:t.max??12});break;case\"script\":e=new SettingScript(t).with({script:t.script??t.value});break;case\"tab\":e=new SettingTab(t).with({items:t.items,values:t.values});break;case\"menu\":e=new SettingMenu(t).with({items:t.items,values:t.values,pullDown:t.pullDown??!1});break;case\"color\":e=new SettingColor(t);break;case\"date\":e=new SettingDate(t).with({mode:t.mode});break;case\"input\":e=new SettingInput(t).with({secure:t.secure});break;case\"number\":e=new SettingNumber(t);break;case\"icon\":e=new SettingIcon(t).with({bgcolor:t.bgcolor});break;case\"push\":e=new SettingPush(t).with({view:t.view});break;case\"child\":e=new SettingChild(t).with({children:t.children});break;case\"image\":e=new SettingImage(t)}return e}loadConfig(){this.#e=!1;let t=this.userData??this.fileStorage.readAsJSON(this.dataFile,{}),e=t=>t instanceof SettingItem?t instanceof SettingScript||t instanceof SettingInfo:[\"script\",\"info\"].includes(t.type),i=s=>{for(let r in s)for(let n in s[r].items){let a=s[r].items[n];a instanceof SettingItem||(s[r].items[n]=this.loader(a)),s[r].items[n].setting||(s[r].items[n].setting=this),s[r].items[n]instanceof SettingChild?i(s[r].items[n].options.children):e(a)||(a.key in t?this.setting[a.key]=t[a.key]:this.setting[a.key]=a.value??a.default,this.settingItems[a.key]=s[r].items[n])}};return i(this.structure),this.#e=!0,this}hasSectionTitle(t){return this.#s(),!!t[0]?.title}setUserData(t){return this.userData=t,this}setStructure(t){return this.structure=t,this.loadConfig()}setStructurePath(t){return this.structure||this.setStructure(FileStorage.readFromRootAsJSON(t)),this}setName(t){return this.name=t,this}setFooter(t){return this.#i=t,this}set footer(t){this.#i=t}get footer(){if(void 0===this.#i){let t=FileStorage.readFromRootAsJSON(\"config.json\",{}).info??{};if(!t.version||!t.author)try{t=__INFO__}catch{}this.#i={},t.version&&t.author&&(this.#i={type:\"view\",props:{height:70},views:[{type:\"label\",props:{font:$font(14),text:`${$l10n(\"VERSION\")} ${t.version} ♥ ${t.author}`,textColor:$color({light:\"#C0C0C0\",dark:\"#545454\"}),align:$align.center},layout:t=>{t.left.right.inset(0),t.top.inset(10)}}]})}return this.#i}setReadonly(){return this.#t=!0,this}set(t,e){if(this.#t)throw new SettingReadonlyError;return this.#s(),this.setting[t]=e,this.fileStorage.write(this.dataFile,$data({string:JSON.stringify(this.setting)})),this.callEvent(\"onSet\",t,e),!0}getOriginal(t,e=null){return this.#s(),Object.prototype.hasOwnProperty.call(this.setting,t)?this.setting[t]:e}getItem(t){return this.settingItems[t]}get(t,e=null){return this.#s(),this.getItem(t)?this.getItem(t).get(e):this.getOriginal(t,e)}#r(t){let e=[];for(let i of t){let t=[];for(let e of i.items)e instanceof SettingItem&&t.push(e.create());e.push({title:$l10n(i.title??\"\"),rows:t})}return e}getListView(t=this.structure,e=this.footer){return{type:\"list\",props:{id:this.name,style:2,separatorInset:$insets(0,SettingItem.iconSize+2*SettingItem.edgeOffset,0,SettingItem.edgeOffset),footer:e,data:this.#r(t)},layout:$layout.fill,events:{rowHeight:(t,e)=>(t.object(e)?.props?.info??{}).rowHeight??SettingItem.rowHeight}}}getNavigationView(){let t=new NavigationView;return t.setView(this.getListView(this.structure)).navigationBarTitle($l10n(\"SETTING\")),this.hasSectionTitle(this.structure)&&t.navigationBar.setContentViewHeightOffset(-10),t}getPage(){return this.getNavigationView().getPage()}},SheetViewTypeError=class extends ValidationError{constructor(t,e){super(t,e),this.name=\"SheetViewTypeError\"}},TabBarCellView=class extends View{constructor(t={}){super(t),this.setIcon(t.icon),this.setTitle(t.title),void 0!==t.activeStatus&&(this.activeStatus=t.activeStatus)}setIcon(t){return this.icon=t instanceof Array?t:[t,t],this}setTitle(t){return this.title=t,this}active(){$(`${this.props.id}-icon`).image=$image(this.icon[1]),$(`${this.props.id}-icon`).tintColor=$color(\"systemLink\"),$(`${this.props.id}-title`).textColor=$color(\"systemLink\"),this.activeStatus=!0}inactive(){$(`${this.props.id}-icon`).image=$image(this.icon[0]),$(`${this.props.id}-icon`).tintColor=$color(\"lightGray\"),$(`${this.props.id}-title`).textColor=$color(\"lightGray\"),this.activeStatus=!1}getView(){return this.views=[{type:\"image\",props:{id:`${this.props.id}-icon`,image:$image(this.activeStatus?this.icon[1]:this.icon[0]),bgcolor:$color(\"clear\"),tintColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(t,e)=>{t.centerX.equalTo(e.super);let i=TabBarController.tabBarHeight/2;t.size.equalTo(i),t.top.inset((TabBarController.tabBarHeight-i-13)/2)}},{type:\"label\",props:{id:`${this.props.id}-title`,text:this.title,font:$font(10),textColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(t,e)=>{t.centerX.equalTo(e.prev),t.top.equalTo(e.prev.bottom).offset(3)}}],this}},TabBarHeaderView=class extends View{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",this.props.bgcolor??UIKit.primaryViewBackgroundColor),this.layout=(t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.height-TabBarController.tabBarHeight)},this.views=[View.create({props:this.props,views:this.views,layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.height.equalTo(this.height)}})],this}},TabBarController=class t extends Controller{static tabBarHeight=50;#t={};#e={};#i;#s;#r=$text.uuid;#u=$text.uuid;bottomSafeAreaInsets=$app.isDebugging?0:UIKit.bottomSafeAreaInsets;get selected(){return this.#s}set selected(t){this.switchPageTo(t)}get contentOffset(){return t.tabBarHeight+(this.#i?.height??0)}setPages(t={}){return Object.keys(t).forEach((e=>this.setPage(e,t[e]))),this}setPage(t,e){return void 0===this.#s&&(this.#s=t),this.#t[t]=e instanceof PageView?e:PageView.create(e),this.#s!==t&&(this.#t[t].activeStatus=!1),this}switchPageTo(t){if(this.#t[t]){if(this.#s===t)return;$ui.animate({duration:.4,animation:()=>{this.#e[t].active()}}),this.#e[this.#s].inactive(),this.#t[this.#s].hide(),this.#t[t].show(),this.callEvent(\"onChange\",this.#s,t),this.#s=t,this.initBackground()}}hideBackground(t=!0){$(this.#u).hidden=!0,$ui.animate({duration:t?.2:1e-4,animation:()=>{$(this.#r).alpha=0}})}showBackground(t=!0){$(this.#u).hidden=!1,$ui.animate({duration:t?.2:1e-4,animation:()=>{$(this.#r).alpha=1}})}initBackground(){let t=this.#t[this.selected];t.scrollable&&$delay(0,(()=>{let e=$(t.id).get(t.scrollableView.id),i=e.contentOffset.y;e.contentSize.height+this.bottomSafeAreaInsets-e.frame.height-i<=0?this.hideBackground(!1):this.showBackground(!1)}))}setCells(t={}){return Object.keys(t).forEach((e=>this.setCell(e,t[e]))),this}setCell(t,e){return void 0===this.#s&&(this.#s=t),e instanceof TabBarCellView||(e=new TabBarCellView({props:{info:{key:t}},icon:e.icon,title:e.title,activeStatus:this.#s===t})),this.#e[t]=e,this}setHeader(t){return this.#i=t,this}#g(){let t=[];return Object.values(this.#e).forEach((e=>{e.setEvent(\"tapped\",(t=>{let e=t.info.key;this.switchPageTo(e)})),t.push(e.getView())})),t}#y(){return Object.values(this.#t).map((t=>{if(t.scrollable){let e=t.scrollableView;if(e.props.indicatorInsets){let t=e.props.indicatorInsets;e.props.indicatorInsets=$insets(t.top,t.left,t.bottom+this.contentOffset,t.right)}else e.props.indicatorInsets=$insets(0,0,this.contentOffset,0);e.props.footer=Object.assign({props:{}},e.props.footer??{}),e.props.footer.props.height?e.props.footer.props.height+=this.contentOffset:e.props.footer.props.height=this.contentOffset,\"function\"==typeof e.assignEvent&&e.assignEvent(\"didScroll\",(t=>{let e=t.contentOffset.y;t.contentSize.height+this.bottomSafeAreaInsets-t.frame.height-e<=1?this.hideBackground():this.showBackground()}))}return t.definition}))}generateView(){let e={type:\"view\",layout:(e,i)=>{e.centerX.equalTo(i.super),e.width.equalTo(i.super),e.top.equalTo(i.super.safeAreaBottom).offset(-t.tabBarHeight),e.bottom.equalTo(i.super)},views:[UIKit.blurBox({id:this.#r}),{type:\"stack\",layout:$layout.fillSafeArea,props:{axis:$stackViewAxis.horizontal,distribution:$stackViewDistribution.fillEqually,spacing:0,stack:{views:this.#g()}}},UIKit.separatorLine({id:this.#u},UIKit.align.top)],events:{ready:()=>this.initBackground()}};return View.createFromViews(this.#y().concat(this.#i?.definition??[],e))}},PageView=class extends View{constructor(t={}){super(t),this.activeStatus=!0}show(){$(this.props.id).hidden=!1,this.activeStatus=!0}hide(){$(this.props.id).hidden=!0,this.activeStatus=!1}setHorizontalSafeArea(t){return this.horizontalSafeArea=t,this}#t(t,e){t.top.bottom.equalTo(e.super),this.horizontalSafeArea?t.left.right.equalTo(e.super.safeArea):t.left.right.equalTo(e.super)}getView(){return this.layout=this.#t,this.props.clipsToBounds=!0,this.props.hidden=!this.activeStatus,super.getView()}},WebDAV=class extends Request{#t;user;password;#e;namespace=\"JSBox.WebDAV\";lockTokenCacheKey=this.namespace+\".lockToken\";get host(){return this.#t}set host(t){for(this.#t=t.trim();this.#t.endsWith(\"/\");)this.#t=this.#t.substring(0,this.#t.length-1);this.#t.startsWith(\"http\")||(this.#t=\"http://\"+this.#t)}get basepath(){return this.#e}set basepath(t){for(this.#e=t.trim();this.#e.endsWith(\"/\");)this.#e=this.#e.substring(0,this.#e.length-1);for(;this.#e.startsWith(\"/\");)this.#e=this.#e.substring(1);this.#e=\"/\"+this.#e}constructor({host:t,user:e,password:i,basepath:s=\"\"}={}){super((t=>console.log(t))),this.host=t,this.user=e,this.password=i,this.basepath=s}#i(t){return t=(t=t.trim()).startsWith(\"/\")?t:\"/\"+t,this.basepath+t}async request(t,e,i=null,s={}){return s=Object.assign({\"Content-Type\":\"text/xml; charset=UTF-8\",Authorization:\"Basic \"+$text.base64Encode(`${this.user}:${this.password}`)},s),await super.request(this.host+this.#i(t),e,i,s)}async allow(t){let e=await this.request(t,Request.method.options);return(e.response.headers?.allow??e.response.headers?.Allow)?.split(\",\").map((t=>t.trim().toUpperCase()))??[]}async propfind(t,e=[],i=0){Array.isArray(e)||(e=[e]);let s=`${e.map((t=>``)).join()}`,r=await this.request(t,\"PROPFIND\",s,{Depth:i});return $xml.parse({string:r.data})}async propfindAll(t,e=0){let i=await this.request(t,\"PROPFIND\",'',{Depth:e});return $xml.parse({string:i.data})}async ls(t,e=1){let i=await this.request(t,\"PROPFIND\",null,{Depth:e});return $xml.parse({string:i.data})}async exists(t){try{return(await this.allow(t)).includes(Request.method.get)?await this.request(t,Request.method.head):await this.ls(t,0),!0}catch(t){if(404===t?.code)return!1;throw t}}async mkdir(t){return await this.request(t,\"MKCOL\")}async get(t){return await this.request(t,Request.method.get,null)}async put(t,e,{withLock:i=!0,waitInterval:s=2,maxTry:r=3}={}){let n={};for(;await this.isLocked(t);){if(--r<=0)throw new Error(\"Resource Locked\");await $wait(s)}if(i)try{await this.lock(t),n.If=`(${this.#r(t)})`}catch(t){if(404!==t.code)throw t;i=!1}await this.request(t,Request.method.put,e,n),i&&await this.unlock(t)}async delete(t){if(!t)throw new Error(\"path empty\");return await this.request(t,Request.method.delete)}#s(t,e){let i=$cache.get(this.lockTokenCacheKey)??{};i[t]=e,$cache.set(this.lockTokenCacheKey,i)}#r(t){return($cache.get(this.lockTokenCacheKey)??{})[t]}async isSupportLock(t){try{return!!(await this.propfind(t,\"supportedlock\")).rootElement.firstChild({xPath:\"//D:response/D:propstat/D:prop/D:supportedlock/D:lockentry\"}).firstChild({xPath:\"//D:locktype/D:write\"})}catch(t){if(404!==t.code)return!1;throw t}}async lock(t,{infinity:e=!1,timeout:i=\"Second-10\"}={}){if(!await this.isSupportLock(t))throw new Error(\"Your WebDAV service does not support the `LOCK` method.\");let s=`${this.namespace}`,r=await this.request(t,\"LOCK\",s,{Timeout:i,Depth:e?\"infinity\":0}),n=r.response.headers[\"lock-token\"]??r.response.headers[\"Lock-Token\"];return this.#s(t,n),$xml.parse({string:r.data})}async isLocked(t){try{let e=(await this.propfind(t,\"lockdiscovery\")).rootElement;if(e.firstChild({xPath:\"//D:response/D:propstat/D:status\"}).string.includes(\"404\"))await this.lock(t,{timeout:\"Second-0\"});else{let i=e.firstChild({xPath:\"//D:response/D:propstat/D:prop/D:lockdiscovery\"}).children()??[];for(let e=0;e10240){const t=n.join(this.logPath,`caio.${Date.now()}.log`);this.fileStorage.move(this.logFilePath,t)}}t instanceof Error&&(t=`${t}\\n${t.stack}`),super.error(t),this.logger.error(t)}initComponents(){this.clips=new c(this),this.actionManager=new d(this),this.fileManager=new o}}t.exports={AppKernelBase:p}})),parcelRequire.register(\"2EAPF\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingInfo,r=i.SettingScript,n=i.SettingTab,a=parcelRequire(\"3dE3D\"),o=parcelRequire(\"2jPf3\"),l=parcelRequire(\"iN4Y6\"),h=parcelRequire(\"knZRr\"),c=parcelRequire(\"aziQd\"),d=parcelRequire(\"5xoIG\"),p=parcelRequire(\"fEWdA\");const u={items:[a,o,l,h,c,d]},g={items:[new n({icon:[\"rectangle.topthird.inset.filled\",\"#A569BD\"],title:\"DISPLAY_MODE\",key:\"mainUIDisplayMode\",value:0}).with({items:[\"CLASSIC\",\"MODERN\"]}),new r({icon:[\"folder.fill\",\"#FF9900\"],title:\"FILE_MANAGEMENT\"}).with({script:\"this.method.fileManager\"})]},y={items:[p]},m={items:[new s({icon:[\"/assets/icon/github.com.jpeg\",\"white\"],title:\"Github\",value:[\"ipuppet/CAIO\",\"https://github.com/ipuppet/CAIO\"]}),new s({icon:[\"/assets/icon/telegram.png\",\"white\"],title:\"Telegram\",value:[\"JSBoxTG\",\"https://t.me/JSBoxTG\"]}),new s({icon:[\"person.fill\",\"#FF9900\"],title:\"AUTHOR\",value:[\"ipuppet\",\"https://blog.ultagic.com\"]}),new r({icon:\"arrow.2.circlepath\",title:\"CHECK_UPDATE\"}).with({script:\"this.method.checkUpdate\"}),new r({icon:[\"book.fill\",\"#A569BD\"],title:\"README\"}).with({script:\"this.method.readme\"})]};t.exports=[u,g,y,m]})),parcelRequire.register(\"3dE3D\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingSwitch,r=i.SettingScript,n=i.SettingNumber,a=i.SettingPush,o=i.SettingChild;t.exports=new o({icon:[\"doc.on.clipboard\",\"#FFCC66\"],title:\"CLIPS\"}).with({children:[{items:[new s({icon:[\"link\",\"#FF6633\"],title:\"UNIVERSAL_CLIPBOARD\",key:\"clipboard.universal\",value:!0}),new r({icon:[\"cursorarrow.rays\",\"#FF6633\"],title:\"Tips\"}).with({script:\"$ui.alert({title:$l10n('UNIVERSAL_CLIPBOARD'),message:$l10n('UNIVERSAL_CLIPBOARD_TIPS')})\"})]},{items:[new a({icon:[\"trash\",\"red\"],title:\"RECYCLE_BIN\",key:\"clipboard.recycleBin\"}).with({view:\"this.method.recycleBin\"})]},{items:[new n({icon:[\"text.alignleft\",\"#FFCC66\"],title:\"MAX_ITEM_LENGTH\",key:\"clipboard.maxItemLength\",value:100}),new s({icon:[\"square.and.arrow.down.on.square\",\"#FF6633\"],title:\"AUTO_SAVE\",key:\"clipboard.autoSave\",value:!0})]},{items:[new r({icon:\"square.and.arrow.up\",title:\"EXPORT\"}).with({script:\"this.method.exportClipboard\"}),new r({icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\"}).with({script:\"this.method.importClipboard\"})]},{items:[new r({icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_DATABASE\"}).with({script:\"this.method.rebuildDatabase\"}),new r({icon:[\"trash\",\"red\"],title:\"DELETE_ALL_DATA\"}).with({script:\"this.method.deleteAllData\"})]}]})})),parcelRequire.register(\"2jPf3\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingScript,r=i.SettingChild;t.exports=new r({icon:[\"bolt.circle\",\"#FF6633\"],title:\"ACTIONS\"}).with({children:[{items:[new s({icon:[\"bolt.circle\",\"#FF6633\"],title:\"IMPORT_EXAMPLE_ACTIONS\",value:\"this.method.importExampleAction\"}).with({script:\"this.method.importExampleAction\"})]},{items:[new s({icon:\"square.and.arrow.up\",title:\"EXPORT\"}).with({script:\"this.method.exportAction\"}),new s({icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\"}).with({script:\"this.method.importAction\"})]},{items:[new s({icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_ACTION_DATABASE\"}).with({script:\"this.method.rebuildAction\"})]}]})})),parcelRequire.register(\"iN4Y6\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingSwitch,r=i.SettingInput,n=i.SettingNumber,a=i.SettingChild;t.exports=new a({icon:[\"pencil.circle\",\"#CC0099\"],title:\"EDITOR\"}).with({children:[{title:\"CLIPS\",items:[new n({icon:[\"wand.and.stars\",\"#FF6633\"],title:\"TEXT_INSETS\",key:\"editor.text.insets\",value:300})]},{title:\"CODE\",items:[new s({icon:[\"list.number\",\"#6699CC\"],title:\"SHOW_LINE_NUMBER\",key:\"editor.code.lineNumbers\",value:!1}),new r({icon:[\"wand.and.stars\",\"#FF6633\"],title:\"LIGHT_MODE_THEME\",key:\"editor.code.lightTheme\",value:\"atom-one-light\"}),new r({icon:[\"wand.and.stars\",\"#FF6633\"],title:\"DARK_MODE_THEME\",key:\"editor.code.darkTheme\",value:\"atom-one-dark\"})]}]})})),parcelRequire.register(\"knZRr\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingSwitch,r=i.SettingStepper,n=i.SettingScript,a=i.SettingTab,o=i.SettingNumber,l=i.SettingPush,h=i.SettingChild,c=i.SettingImage;t.exports=new h({icon:[\"keyboard\",\"#a2a5a6\"],title:\"KEYBOARD\"}).with({children:[{items:[new l({icon:\"rectangle.3.offgrid.fill\",title:\"PREVIEW\",key:\"keyboard.previewAndHeight\",value:267}).with({view:\"this.method.previewKeyboard\"})]},{items:[new a({icon:[\"rectangle.topthird.inset.filled\",\"#A569BD\"],title:\"DISPLAY_MODE\",key:\"keyboard.displayMode\",value:0}).with({items:[\"list\",\"matrix\"]}),new s({icon:[\"checkerboard.rectangle\",\"#1899c4\"],title:\"USE_BLUR\",key:\"keyboard.blur\",value:!1}),new c({icon:[\"photo\",\"#FFCC66\"],title:\"BACKGROUND_IMAGE\",key:\"keyboard.background.image\"})]},{items:[new s({icon:[\"globe\",\"#1899c4\"],title:\"SWITCH_AFTER_INSERT\",key:\"keyboard.switchAfterInsert\",value:!1}),new s({icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE\",key:\"keyboard.tapticEngine\",value:!0}),new r({icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE_LEVEL\",key:\"keyboard.tapticEngineLevel\",value:1}).with({min:0,max:2}),new n({icon:\"paperplane\",title:\"QUICK_START_SCRIPTS\"}).with({script:\"this.method.setKeyboardQuickStart\"})]},{items:[new o({icon:[\"rays\",\"#FFCC33\"],title:\"DELETE_DELAY\",key:\"keyboard.deleteDelay\",value:.05})]}]})})),parcelRequire.register(\"aziQd\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingScript,r=i.SettingMenu,n=i.SettingChild;t.exports=new n({icon:[\"rectangle.3.offgrid.fill\",\"#1899c4\"],title:\"WIDGET\"}).with({children:[{items:[new s({icon:\"rectangle.3.offgrid.fill\",title:\"PREVIEW\"}).with({script:\"this.method.previewWidget\"})]},{title:\"2x2\",items:[new r({icon:\"link\",title:\"CLICK_ACTION\",key:\"widget.2x2.widgetURL\",value:2}).with({pullDown:!0,items:[\"ADD\",\"ACTIONS\",\"CLIPS\"]})]}]})})),parcelRequire.register(\"5xoIG\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingScript,r=i.SettingChild;t.exports=new r({icon:[\"filemenu.and.selection\",\"#ebcc34\"],title:\"TODAY_WIDGET\"}).with({children:[{items:[new s({icon:\"rectangle.3.offgrid.fill\",title:\"PREVIEW\"}).with({script:\"this.method.previewTodayWidget\"})]},{items:[new s({icon:\"bolt.circle\",title:\"ACTIONS\"}).with({script:\"this.method.setTodayWidgetActions\"})]}]})})),parcelRequire.register(\"fEWdA\",(function(t,e){var i=parcelRequire(\"gxpqj\").SettingChild,s=parcelRequire(\"fiqsI\");t.exports=new i({icon:\"wrench.and.screwdriver\",title:\"EXPERIMENTAL\"}).with({children:[{items:[s]}]})})),parcelRequire.register(\"fiqsI\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingSwitch,r=i.SettingInput,n=i.SettingChild;t.exports=new n({icon:[\"cloud\",\"#FF9900\"],title:\"WebDAV\"}).with({children:[{items:[new s({icon:[\"cloud\",\"#FF9900\"],title:\"WebDAV\",key:\"webdav.status\",value:!1})]},{items:[new r({icon:\"link\",title:\"HOST\",key:\"webdav.host\",value:\"\"}),new r({icon:\"person\",title:\"USER\",type:\"input\",key:\"webdav.user\",value:\"\"}),new r({icon:\"person.badge.key\",title:\"PASSWORD\",type:\"input\",key:\"webdav.password\",value:\"\"}),new r({icon:\"link\",title:\"BASEPATH\",type:\"input\",key:\"webdav.basepath\",value:\"\"})]}]})})),parcelRequire.register(\"jEwwi\",(function(t,e){var i=parcelRequire(\"gxpqj\").UIKit,s=parcelRequire(\"7GYtH\");class r{fileStorage;fsPath;imagePath;#f;static isImage(t=\"\"){return t?.startsWith(\"@image=\")}static pathToKey(t){return`@image=${t=JSON.stringify(t)}`}static keyToPath(t){if(r.isImage(t)){return JSON.parse(t.slice(7))}return!1}constructor({uuid:t,section:e,text:i=\"\",md5:s,tag:r=null,prev:n=null,next:a=null}={}){if(!t)throw new Error(\"Clip create faild: uuid undefined\");if(!e)throw new Error(\"Clip create faild: section undefined\");this.uuid=t,this.section=e,this.text=i,this.md5=s??$text.MD5(this.text),this.tag=r,this.prev=n,this.next=a}get text(){return this.#f}set text(t){this.#f=t,r.isImage(t)&&this.#w(r.keyToPath(t))}get hasTag(){return null!==this.tag}get image(){return r.isImage(this.text)}get imageOriginal(){return this.#b(\"original\")}get imagePreview(){return this.#b(\"preview\")}#b(t){if(this.image&&this.fileStorage.exists(this.fsPath[t]))return this.fileStorage.readSync(this.fsPath[t])}#w(t){this.fileStorage&&(this.fsPath=t,this.imagePath={original:this.fileStorage.filePath(t.original),preview:this.fileStorage.filePath(t.preview)})}}class n{sqlite;constructor(t){this.kernel=t,this.dbName=\"CAIO.db\",this.localDb=`/${this.dbName}`;const e=\"/image\";this.imagePath={base:e,original:`${e}/original`,preview:`${e}/preview`},this.tempPath=\"/temp\",this.tempDbFile=`${this.tempPath}/${this.dbName}`,this.tempImagePath=`${this.tempPath}/image`,this.exportFileName=\"CAIO.zip\",this.initWebdavSync(),this.init()}async initWebdavSync(){if(this.kernel.setting.get(\"webdav.status\"))try{this.webdavSync=new s({kernel:this.kernel,host:this.kernel.setting.get(\"webdav.host\"),user:this.kernel.setting.get(\"webdav.user\"),password:this.kernel.setting.get(\"webdav.password\"),basepath:this.kernel.setting.get(\"webdav.basepath\")}),await this.webdavSync.init()}catch(t){throw this.kernel.error(t),t}}needUpload(){this.kernel.setting.get(\"webdav.status\")&&this.webdavSync.needUpload()}sync(){this.kernel.setting.get(\"webdav.status\")&&this.webdavSync.sync()}init(){this.sqlite&&this.sqlite.close(),this.sqlite=$sqlite.open(this.kernel.fileStorage.filePath(this.localDb)),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS clips(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS favorite(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS tag(uuid TEXT PRIMARY KEY NOT NULL, tag TEXT)\"),this.kernel.print(\"init database\")}rebuild(){const t=this.tempPath+\"/rebuild.db\";this.kernel.fileStorage.delete(t);const e=new n(this.kernel);e.localDb=t,e.init();const i=(t,i)=>{const s=[];t.forEach((t=>{const n=new r({uuid:t.uuid,text:t.text,section:t.section,md5:t.md5,tag:t.tag,prev:null,next:s[0]?.uuid??null});e.beginTransaction();try{e.insert(n),n.next&&(s[0].prev=n.uuid,s[0].section=i,e.update(s[0])),e.commit(),s.unshift(n)}catch(t){throw e.rollback(),this.kernel.error(t),t}}))};[\"clips\",\"favorite\"].map((t=>{let e=this.all(t);try{const t=this.sort(e);if(t.length>e.length)throw new Error;e=t.reverse()}catch{}i(e,t)}));const s=this.sqlite.query(\"SELECT * FROM tag\");this.parseTag(s).forEach((t=>{e.beginTransaction();try{e.setTag(t.uuid,t.tag),e.commit()}catch(t){throw e.rollback(),this.kernel.error(t),t}})),this.kernel.fileStorage.copy(t,this.localDb),this.needUpload(),this.kernel.print(\"database rebuild\")}deleteAllData(){this.kernel.fileStorage.delete(this.imagePath.base),this.kernel.fileStorage.delete(this.localDb),this.needUpload(),this.kernel.print(\"delete all database\")}clearTemp(){this.kernel.fileStorage.delete(this.tempPath)}async export(t){this.clearTemp(),this.kernel.fileStorage.copy(this.localDb,this.tempDbFile),this.kernel.fileStorage.copy(this.imagePath.base,this.tempImagePath);const e=this.tempPath+\"/\"+this.exportFileName;await $archiver.zip({directory:this.kernel.fileStorage.filePath(this.tempPath),dest:this.kernel.fileStorage.filePath(e)}),$share.sheet({items:[{name:this.exportFileName,data:$data({path:this.kernel.fileStorage.filePath(e)})}],handler:i=>{this.kernel.fileStorage.delete(e),t(i)}})}async import(t){if(\"db\"===t.fileName.slice(-2)){if(!this.kernel.fileStorage.writeSync(this.localDb,t))throw new Error(\"WRITE_DB_FILE_FAILED\")}else if(\"zip\"===t.fileName.slice(-3)){if(!await $archiver.unzip({file:t,dest:this.kernel.fileStorage.filePath(this.tempPath)}))throw new Error(\"UNZIP_FAILED\");this.kernel.fileStorage.move(this.tempDbFile,this.localDb),this.kernel.fileStorage.move(this.tempImagePath,this.imagePath.base)}this.webdavSync&&this.webdavSync.updateLocalTimestamp()}sort(t,e=9e3){const i={};let s=0,r=null;t.forEach((t=>{i[t.uuid]=t,null===t.prev&&(r=t.uuid),s++}));const n=[];if(s>0)try{let t=i[r];for(;null!==t.next&&e>0;)e--,n.push(t),t=i[t.next];n.push(t)}catch(t){throw\"Unable to sort: \"+t}return n}replaceString(t){return[\"\\\\\",'\"',\"'\",\"%\",\"-\",\"_\",\";\"].forEach((e=>{t=t.replaceAll(e,`\\\\${e}`)})),t}parse(t){const e=t.result,i=t.error,s=[];try{if(null!==i)throw new Error(`Code [${i.code}] ${i.domain} ${i.localizedDescription}`);for(;e.next();){const t=e.get(\"text\"),i=new r({uuid:e.get(\"uuid\"),section:e.get(\"section\"),md5:e.get(\"md5\"),tag:e.get(\"tag\"),prev:e.get(\"prev\"),next:e.get(\"next\")});r.isImage(t)&&(i.fileStorage=this.kernel.fileStorage),i.text=t,s.push(i)}}catch(i){throw i}finally{e.close()}return s}parseTag(t){if(null!==t.error)throw t.error;const e=[];for(;t.result.next();)e.push({uuid:t.result.get(\"uuid\"),tag:t.result.get(\"tag\")});return t.result.close(),e}beginTransaction(){this.sqlite.beginTransaction()}commit(){this.sqlite.commit()}rollback(){this.sqlite.rollback()}getByUUID(t=\"\"){const e=this.sqlite.query({sql:\"\\n SELECT a.*, tag from\\n (SELECT *, 'clips' AS section FROM clips WHERE uuid = ?\\n UNION\\n SELECT *, 'favorite' AS section FROM favorite WHERE uuid = ?) a\\n LEFT JOIN tag ON a.uuid = tag.uuid\\n \",args:[t,t]});return this.parse(e)[0]}getByMD5(t=\"\"){const e=this.sqlite.query({sql:\"\\n SELECT a.*, tag from\\n (SELECT *, 'clips' AS section FROM clips WHERE md5 = ?\\n UNION\\n SELECT *, 'favorite' AS section FROM favorite WHERE md5 = ?) a\\n LEFT JOIN tag ON a.uuid = tag.uuid\\n \",args:[t,t]});return this.parse(e)[0]}async search(t){const e=(await $text.tokenize({text:t})).map((t=>this.replaceString(t))),i=`%${e.join(\"%\")}%`,s=this.sqlite.query({sql:`\\n SELECT a.*, tag from\\n (SELECT *, 'clips' AS section FROM clips WHERE text like \"${i}\"\\n UNION\\n SELECT *, 'favorite' AS section FROM favorite WHERE text like \"${i}\") a\\n LEFT JOIN tag ON a.uuid = tag.uuid\\n `});return{result:this.parse(s),keyword:e}}searchByTag(t){t.startsWith(\"#\")&&(t=t.substring(1));const e=this.sqlite.query({sql:`SELECT * FROM tag WHERE tag like \"%${this.replaceString(t)}%\"`}),i=this.parseTag(e),s=[];return i.forEach((t=>{s.push(this.getByUUID(t.uuid))})),{result:s,keyword:[t]}}deleteTable(t){const e=this.sqlite.update(`DELETE FROM ${t}`);if(!e.result)throw e.error;this.needUpload(),this.kernel.print(`delete table ${t}`)}all(t){const e=this.sqlite.query(`SELECT ${t}.*, tag, '${t}' AS section FROM ${t} LEFT JOIN tag ON ${t}.uuid = tag.uuid`);return this.parse(e)}saveImage(t){if(\"object\"==typeof t){const e=$text.uuid,s={original:`${this.imagePath.original}/${e}.png`,preview:`${this.imagePath.preview}/${e}.jpg`};return this.kernel.fileStorage.write(s.original,t.png),this.kernel.fileStorage.write(s.preview,i.compressImage(t).jpg(.8)),r.pathToKey(s)}throw new Error(\"saveImageError: image not an object\")}insert(t){const e=this.sqlite.update({sql:`INSERT INTO ${t.section} (uuid, text, md5, prev, next) values (?, ?, ?, ?, ?)`,args:[t.uuid,t.text,$text.MD5(t.text),t.prev,t.next]});if(!e.result)throw e.error;this.needUpload()}update(t){if(Object.keys(t).length<4||\"string\"!=typeof t.uuid)return;const e=this.sqlite.update({sql:`UPDATE ${t.section} SET text = ?, md5 = ?, prev = ?, next = ? WHERE uuid = ?`,args:[t.text,$text.MD5(t.text),t.prev,t.next,t.uuid]});if(!e.result)throw e.error;this.needUpload()}updateText(t,e,i){if(\"string\"!=typeof e)return;const s=this.sqlite.update({sql:`UPDATE ${t} SET text = ?, md5 = ? WHERE uuid = ?`,args:[i,$text.MD5(i),e]});if(!s.result)throw s.error;this.needUpload()}delete(t,e){this.getByUUID(e);const i=this.sqlite.update({sql:`DELETE FROM ${t} WHERE uuid = ?`,args:[e]});if(!i.result)throw i.error;this.needUpload()}isEmpty(){const t=this.sqlite.query(\"SELECT * FROM clips limit 1\").result,e=this.sqlite.query(\"SELECT * FROM favorite limit 1\").result;return t.next(),e.next(),t.isNull(0)&&e.isNull(0)}allImageFromDb(t=!0){const e=this.sqlite.query(\"\\n SELECT a.* from\\n (SELECT *, 'clips' AS section FROM clips WHERE text like \\\"@image=%\\\"\\n UNION\\n SELECT *, 'favorite' AS section FROM favorite WHERE text like \\\"@image=%\\\") a\\n LEFT JOIN tag ON a.uuid = tag.uuid\\n \"),i=this.parse(e)?.map((t=>{if(t.image){const e=t.fsPath;return e.preview=e.preview.replaceAll(this.imagePath.preview,\"\"),e.preview.startsWith(\"/\")&&(e.preview=e.preview.substring(1)),e.original=e.original.replaceAll(this.imagePath.original,\"\"),e.original.startsWith(\"/\")&&(e.original=e.original.substring(1)),e}})),s=[],r=[];return t||i.forEach((t=>{s.push(t.original),r.push(t.preview)})),t?i:{original:s,preview:r}}localImagesFromFile(){return{original:this.kernel.fileStorage.readSync(this.kernel.storage.imagePath.original),preview:this.kernel.fileStorage.readSync(this.kernel.storage.imagePath.preview)}}setTag(t,e){const i=this.sqlite.update({sql:\"INSERT OR REPLACE INTO tag (uuid, tag) values (?, ?)\",args:[t,e]});if(!i.result)throw i.error;this.needUpload()}deleteTag(t){const e=this.sqlite.update({sql:\"DELETE FROM tag WHERE uuid = ?\",args:[t]});if(!e.result)throw e.error;this.needUpload()}}t.exports={Clip:r,Storage:n}})),parcelRequire.register(\"7GYtH\",(function(t,e){var i=parcelRequire(\"gxpqj\").FileStorage,s=parcelRequire(\"2VUvw\");class r extends s{localSyncDataPath=\"/sync.json\";webdavSyncDataPath=\"/sync.json\";webdavDbPath=\"/CAIO.db\";webdavImagePath=\"/image\";get localDb(){return $data({path:this.kernel.fileStorage.filePath(this.kernel.storage.localDb)})}set localDb(t){this.kernel.fileStorage.writeSync(this.kernel.storage.localDb,t)}get localImagePath(){return this.kernel.fileStorage.filePath(\"/image\")}async init(){await super.init(),await this.initImagePath(),this.sync()}async initImagePath(){if(!await this.webdav.exists(this.webdavImagePath)){await this.webdav.mkdir(this.webdavImagePath);[\"/image/original\",\"/image/preview\"].map((async t=>{await this.webdav.exists(t)||await this.webdav.mkdir(t)}))}}isNew(){return this.kernel.storage.isEmpty()}async webdavImages(){const t=(await this.webdav.ls(this.webdavImagePath,\"infinity\")).rootElement,e=t.firstChild({xPath:\"//D:response/D:href\"}).string,i=[],s=[];return t.children().map((t=>{const r=t.firstChild({tag:\"href\"})?.string?.replaceAll(e,\"\");r.endsWith(\"/\")||(r.startsWith(\"original\")?i.push(r.substring(9)):r.startsWith(\"preview\")&&s.push(r.substring(8)))})),{original:i,preview:s}}async syncImages(){const t=await this.webdavImages(),e=this.kernel.storage.allImageFromDb(!1),s=this.kernel.storage.localImagesFromFile();Object.keys(s).map((t=>{s[t].forEach((async s=>{if(!e[t].includes(s)){const e=i.join(this.kernel.storage.imagePath[t],s);this.kernel.fileStorage.delete(e),this.kernel.print(`Local image deleted: ${e}`)}}))})),Object.keys(e).map((s=>{e[s].forEach((async e=>{const r=i.join(this.webdavImagePath,s,e),n=i.join(this.kernel.storage.imagePath[s],e);if(t[s].includes(e)&&!this.kernel.fileStorage.exists(n)){const t=await this.webdav.get(r);this.kernel.fileStorage.writeSync(n,t.rawData),this.kernel.print(`WebDAV image downloaded: ${n}`)}else if(!t[s].includes(e)){const t=this.kernel.fileStorage.readSync(n);await this.webdav.put(r,t),this.kernel.print(`WebDAV image uploaded: ${r}`)}}))})),Object.keys(t).map((s=>{t[s].forEach((async t=>{if(!e[s].includes(t)){const e=i.join(this.webdavImagePath,s,t);await this.webdav.delete(e),this.kernel.print(`WebDAV image deleted: ${e}`)}}))}))}async pull(){this.webdav.clearNSURLCache();let t=await this.webdav.get(this.webdavDbPath);this.localDb=t.rawData,await this.downloadSyncData(),this.kernel.storage.init(),await this.syncImages(),this.kernel.print(\"clip webdav sync: pulled\")}async push(){await this.webdav.put(this.webdavDbPath,this.localDb),await this.uploadSyncData(),await this.syncImages(),this.kernel.print(\"clip webdav sync: pushed\")}notify(t){$app.notify({name:\"clipSyncStatus\",object:t})}async#$(){let t=!1;try{const e=await this.nextSyncStep();if(this.kernel.print(`clip nextSyncStep: ${s.stepName[e]}`),e===s.step.needPush||e===s.step.init)await this.push();else if(e===s.step.needPull)await this.pull(),t=!0;else{if(e!==s.step.conflict)return void this.notify({status:s.status.nochange});await this.conflict($l10n(\"CLIPS\"))===r.conflictKeep.webdav&&(t=!0)}}catch(t){throw this.notify({status:s.status.fail,error:t}),this.kernel.error(\"clip sync error\"),this.kernel.error(t),t}finally{this.notify({status:s.status.success,updateList:t})}}sync(){this.notify({status:s.status.syncing,animate:!0}),this.syncTimer&&this.syncTimer.cancel(),this.syncTimer=$delay(.5,(()=>{this.#$()}))}needUpload(){this.notify({status:s.status.syncing}),this.uploadTimer&&this.uploadTimer.cancel(),this.uploadTimer=$delay(.5,(()=>{this.updateLocalTimestamp(),this.#$()}))}}t.exports=r})),parcelRequire.register(\"2VUvw\",(function(t,e){var i=parcelRequire(\"gxpqj\").WebDAV;class s{static step={init:-1,stay:0,needPush:2,needPull:3,conflict:4};static stepName=(()=>{const t={};return Object.keys(s.step).map((e=>{const i=s.step[e];t[i]=String(e)})),t})();static status={syncing:0,success:1,nochange:2,fail:3};static conflictKeep={local:0,webdav:1,cancel:2};static initLocalTimestamp=0;webdav;kernel;localSyncDataPath;webdavSyncDataPath;constructor({host:t,user:e,password:s,basepath:r,kernel:n}={}){this.kernel=n,this.webdav=new i({host:t,user:e,password:s,basepath:r}),this.webdav.namespace=\"JSBox.CAIO\"}get mustLocalSyncDataPath(){if(!this.localSyncDataPath)throw new Error(\"localSyncDataPath not set\");return this.localSyncDataPath}get mustWebdavSyncDataPath(){if(!this.webdavSyncDataPath)throw new Error(\"webdavSyncDataPath not set\");return this.webdavSyncDataPath}get localSyncData(){return this.kernel.fileStorage.exists(this.mustLocalSyncDataPath)||(this.localSyncData={timestamp:s.initLocalTimestamp}),this.kernel.fileStorage.readSync(this.mustLocalSyncDataPath)}set localSyncData(t){this.kernel.fileStorage.writeSync(this.mustLocalSyncDataPath,$data({string:JSON.stringify(t)}))}get localTimestamp(){return Number(JSON.parse(this.localSyncData.string).timestamp)}set localTimestamp(t){this.localSyncData=Object.assign(this.localSyncData,{timestamp:t})}async init(t=this.webdav.basepath){const e=new i({host:this.webdav.host,user:this.webdav.user,password:this.webdav.password,basepath:t});if(!await e.exists(\"/\"))try{await e.mkdir(\"/\")}catch(e){if(409===e.code)return await this.init(t.substring(0,t.lastIndexOf(\"/\"))),void await this.init(t);throw e}}isNew(){return!1}async webdavSyncData(){this.webdav.clearNSURLCache();let t=(await this.webdav.get(this.mustWebdavSyncDataPath)).data;return\"string\"==typeof t&&(t=JSON.parse(t)),t}async webdavTimestamp(){try{let t=await this.webdavSyncData();return Number(t.timestamp)}catch(t){if(404===t.code)return s.step.init;throw t}}updateLocalTimestamp(){this.localTimestamp!==s.initLocalTimestamp&&(this.localTimestamp=Date.now())}async uploadSyncData(){this.localTimestamp===s.initLocalTimestamp&&(this.localTimestamp=Date.now()),await this.webdav.put(this.mustWebdavSyncDataPath,this.localSyncData)}async downloadSyncData(){this.localSyncData=await this.webdavSyncData()}async nextSyncStep(){const t=this.localTimestamp,e=await this.webdavTimestamp();return e===s.step.init?s.step.init:e===s.initLocalTimestamp?(this.localTimestamp=Date.now(),await this.push(),s.step.stay):t>e?s.step.needPush:t===e?s.step.stay:t{this.updateList(!0),$delay(.5,(()=>{this.readClipboard()}))},clipSyncStatus:t=>{const e=$(this.listId);t.status===w.status.success?(t.updateList&&this.updateList(!0),e&&e.endRefreshing()):t.status===w.status.syncing&&t.animate&&e&&e.beginRefreshing()}})}listReady(){this.updateList(),r.isTaio||($delay(.5,(()=>{if($context.query.copy){const t=$context.query.copy;this.setCopied(t),$ui.success($l10n(\"COPIED\"))}else $context.query.add?this.getAddTextView():$context.query.actions&&(this.kernel.isUseJsboxNav?this.kernel.actionManager.present():this.kernel.tabBarController.switchPageTo(\"actions\"))})),$delay(.5,(()=>{this.readClipboard()})),this.appListen())}updateList(t=!1){t&&this.setNeedReload(),$(this.listId).data=this.clips.map((t=>this.lineData(t,this.copied.uuid===t.uuid))),this.updateListBackground()}updateListBackground(){const t=$(this.listId+\"-empty-background\");t&&(t.hidden=this.clips.length>0)}updateCopied(t=null){const e=this.copied?.uuid;$delay(.3,(()=>{try{const i=$(this.listId),s=i.cell($indexPath(0,this.getIndexByUUID(e)));s&&(s.get(\"copied\").hidden=!0),t&&(i.cell($indexPath(0,this.getIndexByUUID(t.uuid))).get(\"copied\").hidden=!1)}catch(t){this.kernel.error(\"set copied error\"),this.kernel.error(t)}})),t?Object.assign(this.copied,t):this.copied={},this.kernel.print(`this.copied: ${JSON.stringify(this.copied,null,2)}`),$cache.set(\"clips.copied\",this.copied)}setCopied(t){if(!t||t===this.copied.uuid&&this.tabIndex===this.copied?.tabIndex)return;let e={};this.copied.uuid!==t&&(e=this.getClip(t)??{}),e.tabIndex=this.tabIndex,this.updateCopied(e),this.setClipboardText(e.text)}clearCopied(){const t=$(this.listId).cell($indexPath(0,this.getIndexByUUID(this.copied.uuid)));t&&(t.get(\"copied\").hidden=!0),this.updateCopied(null)}async readClipboard(t=!1){if(t||this.kernel.setting.get(\"clipboard.autoSave\")){if(this.kernel.print(\"read clipboard\"),!t&&!this.isChanged)return;if($clipboard.images?.length>0)return t?(await $wait(.1),void $clipboard.images.forEach((t=>{this.add(t)}))):void 0;const e=$clipboard.text;if(!e||\"\"===e)return void this.clearCopied();if(this.getClip(this.copied?.uuid)?.text===e)return void(t&&$ui.toast($l10n(\"CLIPBOARD_NO_CHANGE\")));if(this.exists(e)){const t=this.kernel.storage.getByMD5($text.MD5(e));this.switchTab(this.tabItemsMap[t.section],!0),this.setCopied(t.uuid)}else{this.switchTab(1,!0);const t=this.add(e);this.setCopied(t.uuid)}}}add(t){try{const e=super.addItem(t);return this.updateListBackground(),$(this.listId).insert({indexPath:$indexPath(0,0),value:this.lineData(e)}),e}catch(t){$ui.alert(t)}}delete(t){try{super.deleteItem(t),this.copied.uuid===t&&(this.updateCopied(null),$clipboard.clear()),this.updateListBackground()}catch(t){$ui.alert(t)}}update(t,e){try{return super.updateItem(t,e),this.updateList(),e===this.copied.uuid&&this.setClipboardText(t),!0}catch(t){return $ui.alert(t),!1}}move(t,e,i=!0){if(t!==e)try{if(super.moveItem(t,e),!i)return;const s=$(this.listId);t{i.text?$share.sheet(i.text):$ui.warning($l10n(\"NONE\"))}}];if(this.kernel.isUseJsboxNav)i.uikitPush(t,(t=>e(t)),s);else{const r=i.getNavigationView(t,(t=>e(t)),s);this.viewController.push(r)}}getAddTextView(){this.edit(\"\",(t=>{\"\"!==t&&this.add(t)}))}menuItems(t=!1){const e=[{inline:!0,items:[{title:$l10n(\"TAG\"),symbol:\"tag\",handler:(t,e)=>{const i=this.getByIndex(e);$input.text({placeholder:$l10n(\"ADD_TAG\"),text:i.tag,handler:t=>{(t=t.trim()).length>0?this.kernel.storage.setTag(i.uuid,t):this.kernel.storage.deleteTag(i.uuid),this.updateList(!0)}})}}]},{inline:!0,items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:(t,e)=>{const i=this.getByIndex(e);$share.sheet(i.image?i.imageOriginal:i.text)}},{title:$l10n(\"COPY\"),symbol:\"square.on.square\",handler:(t,e)=>this.copy(this.getByIndex(e).uuid)},{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,items:[{title:$l10n(\"CONFIRM\"),destructive:!0,handler:(t,e)=>{t.delete(e),this.delete(this.getByIndex(e).uuid),$delay(.25,(()=>t.reload()))}}]}]}];if(t)return e;const i=t=>{const e=this.kernel.actionManager.getActionHandler(t.type,t.dir);return t.handler=(t,i)=>{const s=this.getByIndex(i),r=new m({env:f.clipboard,text:s.text,section:s.section,uuid:s.uuid});e(r)},t.title=t.name,t.symbol=t.icon,t},s=this.kernel.actionManager.getActions(\"clipboard\"),r={inline:!0,items:s.slice(0,this.menuItemActionMaxCount).map(i)};return s.length>this.menuItemActionMaxCount&&r.items.push({title:$l10n(\"MORE_ACTIONS\"),symbol:\"square.grid.2x2\",items:s.slice(this.menuItemActionMaxCount).map(i)}),[r,...e]}switchTab(t,e=!1){this.tabIndex=t,this.updateList(),e&&($(this.listId+\"-tab\").index=this.tabIndex)}tabView(){return{type:\"tab\",props:{id:this.listId+\"-tab\",items:this.tabItems,index:this.tabIndex,dynamicWidth:!0},events:{changed:t=>this.switchTab(t.index)},layout:(t,e)=>{t.centerY.equalTo(e.super),e.prev?t.left.equalTo(e.prev.right).offset(this.tabLeftMargin):t.left.inset(this.tabLeftMargin)}}}lineData(t,e=!1){const i={hidden:!0},s={text:\"\"},r={hidden:!t?.hasTag};return t.image?(i.src=t.imagePath.preview,i.hidden=!1):(t.textStyledText?s.styledText=t.textStyledText:s.text=t.text,t.tagStyledText?r.styledText=t.tagStyledText:r.text=t.tag),{copied:{hidden:!e},image:i,tag:r,content:s}}listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{type:\"view\",views:[{type:\"view\",props:{id:\"copied\",circular:this.copiedIndicatorSize,hidden:!0,bgcolor:$color(\"green\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.size.equalTo(this.copiedIndicatorSize),t.left.equalTo(e.super).inset(this.horizontalMargin/2-this.copiedIndicatorSize/2)}},{type:\"label\",props:{id:\"content\",lines:this.#v?1:2,font:$font(this.fontSize)},layout:(t,e)=>{t.left.right.equalTo(e.super).inset(this.horizontalMargin),t.top.equalTo(this.verticalMargin)}},{type:\"label\",props:{id:\"tag\",lines:1,color:this.tagColor,autoFontSize:!0,align:$align.leading},layout:(t,e)=>{t.bottom.equalTo(e.super),t.left.right.equalTo(e.prev),t.height.equalTo(this.tagHeight)}}],layout:$layout.fill},{type:\"image\",props:{id:\"image\",hidden:!0},layout:$layout.fill}]}}getEmptyBackground(t=this.listId){return{type:\"label\",props:{id:t+\"-empty-background\",color:$color(\"secondaryText\"),hidden:this.clips.length>0,text:$l10n(\"NONE\"),align:$align.center},layout:$layout.center}}getListView(t=this.listId,e=[]){const i={type:\"list\",props:{id:t,associateWithNavigationBar:!1,bgcolor:$color(\"clear\"),separatorInset:$insets(0,this.horizontalMargin,0,0),menu:{items:this.menuItems()},data:e,template:this.listTemplate(),actions:[{title:$l10n(\"COPY\"),color:$color(\"systemLink\"),handler:(t,e)=>this.copy(this.getByIndex(e).uuid)},{title:$l10n(\"FAVORITE\"),color:$color(\"orange\"),handler:(t,e)=>this.favorite(e.row)},{title:\"delete\",handler:(t,e)=>{this.delete(this.getByIndex(e).uuid),$delay(.25,(()=>t.reload()))}}]},layout:$layout.fill,events:{ready:()=>this.listReady(),rowHeight:(t,e)=>{const i=this.getByIndex(e),s=i?.hasTag?this.tagHeight:this.verticalMargin,r=i.image?this.imageContentHeight:this.getContentHeight(i.text);return this.verticalMargin+r+s},didSelect:(t,e)=>{const i=this.getByIndex(e);i.image?a.quickLookImage(i.imageOriginal):this.edit(i.text,(t=>{i.md5!==$text.MD5(t)&&this.update(t,i.uuid)}))},pulled:t=>{this.updateList(!0),this.kernel.storage.sync(),this.kernel.setting.get(\"webdav.status\")||$delay(.5,(()=>t.endRefreshing()))}}};return s.createFromViews([i,this.getEmptyBackground(t)])}getNavigationView(){const t=new a,e=e=>{const{keyword:i,result:s,isTagKeyword:r}=e,n=this.getListView(this.listId+\"-search-result\",s.map((t=>{const e=r?t.tag:t.text;let s=[];return i.forEach((t=>{let i=e.indexOf(t);for(;i>-1;)s.push({range:$range(i,t.length),color:$color(\"red\")}),i=e.indexOf(t,i+1)})),t.styledText={},r?t.tagStyledText={color:this.tagColor,text:e,styles:s}:t.textStyledText={text:e,styles:s},this.lineData(t,!1)})));return delete n.views[0].events.pulled,n.views[0].events.rowHeight=(t,e)=>{const i=s[e.row],r=i?.hasTag?this.tagHeight:this.verticalMargin,n=i.image?this.imageContentHeight:this.getContentHeight(i.text);return this.verticalMargin+n+r},n.views[0].events.didSelect=(e,i)=>{const r=s[i.row];r.image?a.quickLookImage(r.imageOriginal):(t.dismiss(),this.edit(r.text,(t=>{r.md5!==$text.MD5(t)&&this.update(t,r.uuid)})))},n},i=new u(this.kernel);i.setCallback((s=>{t.setView(e(s)).addNavBar({title:$l10n(\"SEARCH_RESULT\"),popButton:{title:$l10n(\"DONE\"),tapped:()=>i.dismiss()}}).init().present()}));const s=this.tabView();s.type=\"menu\",s.layout=(t,e)=>{t.top.left.right.equalTo(e.super),t.height.equalTo(this.tabHeight)};const r=this.getListView();r.views.unshift(s),r.views[1].layout=(t,e)=>{t.bottom.left.right.equalTo(e.super),t.top.equalTo(e.prev.bottom)},r.views.push(i.getSearchHistoryView());const o=(new l).navigationBarTitle($l10n(\"CLIPS\")).setView(r);return o.navigationBarItems.setTitleView(i.getSearchBarView()).pinTitleView().setRightButtons([{symbol:\"plus.circle\",tapped:()=>this.getAddTextView()}]).setLeftButtons([{title:$l10n(\"EDIT\"),tapped:()=>{new g(this).presentSheet()}},{symbol:\"square.and.arrow.down.on.square\",tapped:async t=>{t.start();try{await this.readClipboard(!0),t.done()}catch(e){t.cancel(),this.kernel.error(e)}}}]),o.navigationBar.setBackgroundColor(n.primaryViewBackgroundColor).setLargeTitleDisplayMode(h.largeTitleDisplayModeNever),this.kernel.isUseJsboxNav&&o.navigationBar.removeTopSafeArea(),o}}})),parcelRequire.register(\"f0nX9\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.UIKit,r=i.NavigationBar,n=i.NavigationView,a=i.Sheet,o=parcelRequire(\"eSp9Z\"),l=o.ActionEnv,h=o.ActionData;t.exports=class{#f=\"\";constructor(t){this.kernel=t,this.id=\"editor\",this.originalContent=void 0}set text(t=\"\"){void 0===this.originalContent&&(this.originalContent=t),this.#f=t}get text(){return this.#f}getActionButton(){return{symbol:\"bolt.circle\",tapped:(t,e)=>{e&&(t=e);const i=$(this.id).selectedRange,s=new h({env:l.editor,editor:{setContent:t=>this.setContent(t)},text:i.length>0?this.text.slice(i.location,i.location+i.length):this.text,selectedRange:i}),r=$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actionManager.getActionListView((t=>{r.dismiss(),$delay(.5,(()=>t(s)))}))]})}}}setContent(t){this.text=t,$(this.id).text=t}getView(t=\"text\"){return{type:t,layout:$layout.fill,props:{id:this.id,lineNumbers:this.kernel.setting.get(\"editor.code.lineNumbers\"),theme:this.kernel.setting.get($device.isDarkMode?\"editor.code.darkTheme\":\"editor.code.lightTheme\"),text:this.text,insets:$insets(15,15,\"text\"===t?this.kernel.setting.get(\"editor.text.insets\"):15,15)},events:{ready:t=>{\"\"===this.text&&$delay(.5,(()=>t.focus()))},didChange:t=>{this.text=t.text}}}}pageSheet(t=\"\",e,i,s=[],r=\"text\"){this.text=t,s.unshift(this.getActionButton());const n=new a;n.setView(this.getView(r)).addNavBar({title:i,popButton:{title:$l10n(\"DONE\"),tapped:()=>e(this.text)},rightButtons:s}).init(),n.navigationView.navigationBar.contentViewHeightOffset=0,n.present()}uikitPush(t=\"\",e,i=[],r=\"text\"){this.text=t,i.unshift(this.getActionButton()),s.push({title:\"\",navButtons:i.map((t=>(t.handler=t.tapped,t.tapped=void 0,t))),views:[this.getView(r)],disappeared:()=>e(this.text)})}getNavigationView(t=\"\",e,i=[],s=\"text\"){this.text=t,i.unshift(this.getActionButton());const a=new n;return a.navigationBar.contentViewHeightOffset=0,a.navigationBar.setLargeTitleDisplayMode(r.largeTitleDisplayModeNever),a.navigationBarItems.setRightButtons(i),a.setView(this.getView(s)).navigationBarTitle(\"\"),a.setEvent(\"onPop\",(()=>e(this.text))),a}}})),parcelRequire.register(\"eSp9Z\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.L10n,r=i.Sheet,n=parcelRequire(\"jVlss\").SecureFunction;class a{static build=-1;static today=0;static editor=1;static clipboard=2;static action=3;static keyboard=4}class o{env;args;text;originalContent;section;uuid;selectedRange;textBeforeInput;textAfterInput;editor;constructor({env:t,args:e,text:i,section:s=null,uuid:r=null,selectedRange:n=null,textBeforeInput:a=null,textAfterInput:o=null,editor:l=null}={}){this.env=t,this.args=e,this.text=i,this.originalContent=i,this.section=s,this.uuid=r,this.selectedRange=n,this.textBeforeInput=a,this.textAfterInput=o,this.editor=l}}t.exports={ActionEnv:a,ActionData:o,Action:class{#S;secureFunction;constructor(t,e,i){this.#S=t,this.config=e,this.secureFunction=new n(this.#S,this.config),i.env===a.build&&((i=this.preview()).env=a.build),Object.assign(this,i),this.originalContent=String(this.text);const r=this.l10n();Object.keys(r).forEach((t=>{s.add(t,r[t])}))}preview(){return new o({env:a.build})}l10n(){return{}}pageSheet({view:t,title:e=\"\",done:i,doneText:s=$l10n(\"DONE\"),rightButtons:n=[]}){(new r).setView(t).addNavBar({title:e,popButton:{title:s,tapped:()=>{i&&i()}},rightButtons:n}).init().present()}quickLookImage(t){r.quickLookImage(t)}getAllClips(){return{favorite:this.#S.storage.all(\"favorite\").map((t=>t.text)),clips:this.#S.storage.all(\"clips\").map((t=>t.text))}}async clearAllClips(){if(0!==(await $ui.alert({title:$l10n(\"DELETE_DATA\"),message:$l10n(\"DELETE_TABLE\").replaceAll(\"${table}\",$l10n(\"CLIPS\")),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index)return!1;try{return this.#S.storage.deleteTable(\"clips\"),!0}catch(t){throw this.#S.error(t),t}}setContent(t){this.text=t,this.env===a.editor?this.editor.setContent(t):this.env===a.clipboard&&(this.#S.storage.updateText(this.section,this.uuid,t),this.#S.clips.updateList(!0))}getAction(t,e,i){return this.#S.actionManager.getAction(t,e,i)}async runAction(t,e){const i=this.getAction(t,e);return await i.do()}async request(t,e,i,s){return this.secureFunction.http.request({url:t,method:e,body:i,header:s,timeout:3})}getUrls(){return(this.text??\"\").match(/(https?:\\/\\/)([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([:0-9])*([\\/\\w\\#\\.\\-\\?\\=\\&])*\\s?/gi)??[]}}}})),parcelRequire.register(\"jVlss\",(function(t,e){class i{#S;#A;notAllowed='\"The parameter or method is not allowed in Action.\"';constructor(t,e){if(this.#S=t,this.#A=JSON.parse(JSON.stringify(e)),!this.#A?.name||\"undefined\"===this.#A?.name)throw new Error(\"Cannot get Action name.\")}get name(){return this.#A.name}set name(t){const e=$l10n(\"ACTION_RESET_NAME_WARNING\").replaceAll(\"${name}\",this.name).replaceAll(\"${to_name}\",t);throw $ui.alert({title:$l10n(\"ACTION_SAFETY_WARNING\"),message:e}),new Error(e)}print(t){this.#S.print(t)}error(t){this.#S.error(t)}}class s extends i{rootPath=this.notAllowed;extensions=this.notAllowed;read(){throw new Error(this.notAllowed)}async download(){throw new Error(this.notAllowed)}write(){throw new Error(this.notAllowed)}delete(){throw new Error(this.notAllowed)}list(){throw new Error(this.notAllowed)}copy(){throw new Error(this.notAllowed)}move(){throw new Error(this.notAllowed)}mkdir(){throw new Error(this.notAllowed)}exists(){throw new Error(this.notAllowed)}isDirectory(){throw new Error(this.notAllowed)}merge(){throw new Error(this.notAllowed)}absolutePath(){throw new Error(this.notAllowed)}}class r extends i{#I=\"ActionHttpPermission\";get#C(){const t=$cache.get(this.#I);return t||(this.#C={},{})}set#C(t={}){return $cache.set(this.#I,t)}async#x(){if(0===(await $ui.alert({title:$l10n(\"ACTION_PERMISSION_REQUEST\"),message:$l10n(\"ACTION_NETWORK_PERMISSION_MESSAGE\").replaceAll(\"${name}\",this.name),actions:[{title:$l10n(\"OK\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index){const t=this.#C;return t[this.name]=!0,this.#C=t,!0}return!1}async#k(){const t=this.#C;return\"boolean\"==typeof t[this.name]?t[this.name]:!!await this.#x()}async request(t={}){try{if(!await this.#k())throw new Error(\"No network permission.\");this.print(`sending request [${t.method}]: ${t.url}`);const e=await $http.request(Object.assign({timeout:3},t));if(\"function\"==typeof t?.handler&&t?.handler(e),e.error)throw e.error;if(e?.response?.statusCode>=400){let t=e.data;throw\"object\"==typeof t&&(t=JSON.stringify(t)),new Error(\"http error: [\"+e.response.statusCode+\"] \"+t)}return e}catch(t){throw t.code&&(t=new Error(\"network error: [\"+t.code+\"] \"+t.localizedDescription)),this.error(`Action request error: ${this.name}`),this.error(t),t}}async get(t){return\"string\"==typeof t&&(t={url:t}),t.method=\"GET\",await this.request(t)}async post(t){return\"string\"==typeof t&&(t={url:t}),t.method=\"POST\",await this.request(t)}async download(){throw new Error(this.notAllowed)}async upload(){throw new Error(this.notAllowed)}async startServer(){throw new Error(this.notAllowed)}async stopServer(){throw new Error(this.notAllowed)}async shorten(t){return await $http.shorten(t)}async lengthen(t){return await $http.lengthen(t)}}t.exports={SecureFunction:class extends i{constructor(...t){super(...t),this.file=new s(...t),this.http=new r(...t)}addin(){throw new Error(this.notAllowed)}},SecureScript:class{script;sf=\"this.secureFunction\";constructor(t){this.script=t}#B(t,e){this.script=this.script.replaceAll(t,e)}replaceEval(){this.#B(/\\$addin\\.*[a-zA-Z0-9\\[\\]'\"`]+/gi,`${this.sf}.addin()`),this.#B(\"eval\",`${this.sf}.addin()`)}replaceFile(){this.#B(\"$file\",`${this.sf}.file`)}replaceHttp(){this.#B(\"$http\",`${this.sf}.http`)}secure(){return this.replaceEval(),this.replaceFile(),this.replaceHttp(),this.script}}}})),parcelRequire.register(\"ZnuTV\",(function(t,e){var i=parcelRequire(\"gxpqj\").UIKit,s=parcelRequire(\"jEwwi\").Clip;t.exports=class{kernel;pasteboard=$objc(\"UIPasteboard\").$generalPasteboard();#D=[];clipsUUIDMap={};clipsMD5Map={};tabItems=[$l10n(\"FAVORITE\"),$l10n(\"CLIPS\")];tabItemsIndex=[\"favorite\",\"clips\"];tabItemsMap=function(t){const e={};return t.forEach(((t,i)=>{e[t]=i})),e}(this.tabItemsIndex);constructor(t){this.kernel=t}get tabIndex(){return $cache.get(\"caio.main.tab.index\")??0}set tabIndex(t){$cache.set(\"caio.main.tab.index\",t)}get table(){return this.tabItemsIndex[this.tabIndex]}get tableL10n(){return this.tabItems[this.tabIndex]}get allClips(){return this.tabItemsIndex.forEach(((t,e)=>{this.#D[e]||(this.#D[e]=this.#L(t),this.kernel.print(`init clips: ${t}`))})),this.#D}get clips(){return this.#D[this.tabIndex]||(this.#D[this.tabIndex]=this.#L(this.table),this.kernel.print(`init clips: ${this.table}`)),this.#D[this.tabIndex]}get isChanged(){const t=this.pasteboard.$changeCount(),e=$cache.get(\"clipboard.changeCount\");return $cache.set(\"clipboard.changeCount\",t),e!==t}#L(t){try{const e=this.kernel.storage.all(t),i=this.kernel.storage.sort(e,this.kernel.setting.get(\"clipboard.maxItemLength\"));return i.forEach(((e,i)=>{this.clipsMD5Map[e.md5]=!0,this.clipsUUIDMap[e.uuid]={tab:t,index:i}})),this.#R(i)}catch(t){this.kernel.error(t),this.rebuildDatabase()}}#R(t){return new Proxy(t??[],{set:(t,e,i)=>Reflect.set(t,e,i),get:(t,e)=>Reflect.get(t,e)})}rebuildDatabase(){$ui.alert({title:$l10n(\"REBUILD_DATABASE\"),message:$l10n(\"CLIPS_STRUCTURE_ERROR\"),actions:[{title:$l10n(\"OK\"),handler:()=>{const t=i.loading();t.start(),this.kernel.storage.rebuild(),t.end(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\")}]})}setNeedReload(t){t?this.#D[this.tabItemsMap[t]]=null:this.#D=[],this.kernel.print(`set need reload: ${t??\"all\"}`)}getClipCopy(t,e={}){if(!t.uuid)return t;const i=new s(t);return i.fileStorage=t.fileStorage,Object.assign(i,e),i}getIndexByUUID(t){return this.clipsUUIDMap[t]?.index??-1}getClip(t){const e=this.clips[this.getIndexByUUID(t)];return e||this.kernel.storage.getByUUID(t)}exists(t){return Boolean(this.clipsMD5Map[$text.MD5(t)])}setClipboardText(t){this.kernel.setting.get(\"clipboard.universal\")?$clipboard.text=t:$clipboard.setTextLocalOnly(t)}addItem(t){const e=new s({uuid:$text.uuid,section:this.table,md5:null,prev:null,next:this.clips[0]?this.clips[0].uuid:null});if(\"string\"==typeof t){if(\"\"===t.trim())return;e.text=t}else{if(\"object\"!=typeof t)return;e.fileStorage=this.kernel.fileStorage,e.text=this.kernel.storage.saveImage(t)}try{return this.kernel.storage.beginTransaction(),this.kernel.storage.insert(e),e.next&&(this.clips[0].prev=e.uuid,this.kernel.storage.update(this.clips[0])),this.kernel.storage.commit(),this.setNeedReload(this.table),e}catch(t){throw this.kernel.storage.rollback(),this.kernel.error(t),t}}getRecycleBin(){return $cache.get(\"caio.recycleBin\")??[]}moveToRecycleBin(t){const e=this.getRecycleBin();e.push({text:t.text,tag:t.tag}),$cache.set(\"caio.recycleBin\",e)}removeFromRecycleBin(t){const e=this.getRecycleBin();e.splice(t,1),$cache.set(\"caio.recycleBin\",e)}deleteItem(t,e=!0){const i=this.getIndexByUUID(t),s=this.clips[i],r=this.clips[i-1],n=this.clips[i+1];try{this.kernel.storage.beginTransaction(),this.kernel.storage.delete(this.table,t),r&&(r.next=s.next,this.kernel.storage.update(r)),n&&(n.prev=s.prev,this.kernel.storage.update(n)),this.kernel.storage.commit(),e&&(this.kernel.storage.deleteTag(t),s?.image?(this.kernel.fileStorage.delete(s.fsPath.original),this.kernel.fileStorage.delete(s.fsPath.preview)):this.moveToRecycleBin(s)),this.setNeedReload(this.table)}catch(t){throw this.kernel.storage.rollback(),this.kernel.error(t),t}}updateItem(t,e){const i=$text.MD5(t),s=this.getClip(e);delete this.clipsMD5Map[s.md5],this.clipsMD5Map[i]=!0;const r=s.text;Object.assign(s,{text:t,md5:i});try{this.kernel.storage.updateText(this.table,s.uuid,t),this.kernel.print(`data changed at index [${this.getIndexByUUID(e)}]\\n${r}\\n↓\\n${t}`)}catch(t){throw this.kernel.error(t),t}}moveItem(t,e){if(t!==e){t{};onBegin=()=>{};onDismiss=()=>{};constructor(t){this.kernel=t,this.searchBar=new r,this.searchBarId=this.searchBar.id+\"-input\"}get searchHistoryView(){return{hide:()=>$(this.listId+\"-history\").hidden=!0,show:()=>$(this.listId+\"-history\").hidden=!1}}get searchHistory(){return[{title:$l10n(\"SEARCH_HISTORY\"),rows:$cache.get(\"caio.search.history\")?.reverse()??[]}]}getAccessoryView(){return s.blurBox({height:50},[{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"xmark.circle\"},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(e.super),t.width.equalTo(e.super.height)},events:{tapped:()=>this.dismiss()}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"keyboard.chevron.compact.down\"},layout:(t,e)=>{t.right.equalTo(e.prev.left),t.height.equalTo(e.super),t.width.equalTo(e.super.height)},events:{tapped:()=>$(this.searchBarId).blur()}}])}getSearchHistoryView(){return{type:\"list\",props:{id:this.listId+\"-history\",hidden:!0,stickyHeader:!0,data:this.searchHistory,separatorInset:$insets(0,13,0,0),actions:[{title:$l10n(\"DELETE\"),handler:(t,e)=>{const i=t.data;this.updateSearchHistory(i[0].rows.reverse())}}]},events:{didSelect:(t,e,i)=>{this.searchAction(i),$(this.searchBarId).text=i}},layout:$layout.fill}}setCallback(t){this.callback=t}setOnBegin(t){this.onBegin=t}setOnDismiss(t){this.onDismiss=t}begin(){this.searchHistoryView.show(),this.onBegin()}dismiss(){this.searchBar.cancel()}async searchAction(t){try{if(\"\"!==t){let e,i=t.startsWith(\"#\");e=i?this.kernel.storage.searchByTag(t.substring(1)):await this.kernel.storage.search(t);const{result:s,keyword:r}=e;s&&s.length>0?($(this.searchBarId).blur(),this.callback({keyword:r,result:s,isTagKeyword:i})):$ui.toast($l10n(\"NO_SEARCH_RESULT\")),this.pushSearchHistory(t)}}catch(t){throw t}}pushSearchHistory(t){let e=$cache.get(\"caio.search.history\")??[];-1===e.indexOf(t)&&(e.push(t),e.length>20&&(e=e.slice(-20)),$cache.set(\"caio.search.history\",e),$(this.listId+\"-history\").data=this.searchHistory)}updateSearchHistory(t=[]){$cache.set(\"caio.search.history\",t)}getSearchBarView(){return this.searchBar.controller.setEvent(\"onReturn\",(t=>{\"\"!==t?this.searchAction(t):this.searchHistoryView.show()})),this.searchBar.controller.setEvent(\"onChange\",(t=>{\"\"===t&&this.searchHistoryView.show()})),this.searchBar.controller.setEvent(\"onBeginEditing\",(t=>{\"\"===t&&this.begin()})),this.searchBar.controller.setEvent(\"onCancel\",(()=>{this.searchHistoryView.hide(),this.onDismiss()})),this.searchBar.setAccessoryView(this.getAccessoryView()),this.searchBar}}})),parcelRequire.register(\"9LqeL\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.View,r=i.UIKit,n=i.Sheet;class a{static symbol={selected:\"checkmark.circle.fill\",unselected:\"circle\"};#E={};listId=\"clips-list-editor\";reorder={};toolBarHeight=44;containerMargin=30;#N=void 0;#O={};constructor(t){this.clipsInstance=t,this.kernel=t.kernel}get editorSelectedIsEmpty(){let t=!0;const e=this.editorSelected;for(const i of Object.keys(e))if(e[i]){t=!1;break}return t}get editorSelectedIsFull(){let t=0,e=0;const i=this.editorSelected;for(const s of Object.keys(i))++e,i[s]&&++t;return e===t}get editorSelected(){return void 0===this.#N&&(Array(this.clipsInstance.clips.length).fill(0).map(((t,e)=>this.#O[e]=!1)),this.#N=new Proxy(this.#O,{set:(t,e,i,s)=>(Reflect.set(t,e,i,s),e=Number(e),this.updateToolBar(),$(this.listId).data=this.clipsInstance.clips.map(((e,i)=>{const s=this.lineData(e);return s.checkmark={symbol:t[i]?a.symbol.selected:a.symbol.unselected},s})),!0)})),this.#N}getTextHeight(t){return this.#E[t]||(this.#E[t]=Math.min($text.sizeThatFits({text:t,width:r.windowSize.width-2*(this.clipsInstance.horizontalMargin+this.containerMargin),font:$font(this.clipsInstance.fontSize)}).height,2*this.clipsInstance.singleLineContentHeight)),this.#E[t]}selectAll(){const t=this.editorSelectedIsFull;this.clipsInstance.clips.forEach(((e,i)=>{this.editorSelected[i]=!t}))}deleteSelected(){r.deleteConfirm($l10n(\"DELETE_CONFIRM_MSG\"),(()=>{const t=Object.keys(this.editorSelected);if(t.filter((t=>this.editorSelected[t])).length===this.clipsInstance.clips.length)return void this.deleteTable();const e=$(this.listId),i=$(this.clipsInstance.listId);t.reverse().forEach((t=>{if(this.editorSelected[t]){t=Number(t);const s=this.clipsInstance.clips[t];this.kernel.print(`delete selected: [${t}]\\n${s.text}`),this.clipsInstance.delete(s.uuid),i.delete(t),e.delete(t)}})),this.#N=void 0,this.updateToolBar()}))}deleteTable(){try{this.kernel.storage.deleteTable(this.clipsInstance.table),this.sheet.dismiss(),this.clipsInstance.updateList(!0)}catch(t){this.kernel.error(t),$ui.error(t)}}updateToolBar(){const t=this.editorSelectedIsEmpty,e=$(this.listId+\"-select-button\"),i=$(this.listId+\"-delete-button\");e.title=this.editorSelectedIsFull?$l10n(\"DESELECT_ALL\"):$l10n(\"SELECT_ALL\"),i.hidden=t,$(this.listId).reorder=t}getToolBarView(){return r.blurBox({},[r.separatorLine(),{type:\"view\",views:[{type:\"button\",props:{id:this.listId+\"-select-button\",title:$l10n(\"SELECT_ALL\"),titleColor:$color(\"tint\"),bgcolor:$color(\"clear\")},layout:(t,e)=>{t.left.inset(this.clipsInstance.horizontalMargin),t.centerY.equalTo(e.super)},events:{tapped:()=>this.selectAll()}},{type:\"button\",props:{id:this.listId+\"-delete-button\",symbol:\"trash\",hidden:!0,tintColor:$color(\"red\"),bgcolor:$color(\"clear\")},layout:(t,e)=>{t.height.equalTo(e.super),t.width.equalTo(2*this.clipsInstance.horizontalMargin),t.right.inset(this.clipsInstance.horizontalMargin/2),t.centerY.equalTo(e.super)},events:{tapped:()=>this.deleteSelected()}}],layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom)}}],((t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.toolBarHeight)}))}lineData(t){const e=this.clipsInstance.lineData(t);return e.checkmark={symbol:a.symbol.unselected},e}listTemplate(){const t=this.clipsInstance.listTemplate();return t.views[0].layout=(t,e)=>{t.height.right.equalTo(e.super),t.left.inset(this.containerMargin)},t.views.push({type:\"image\",props:{id:\"checkmark\",symbol:a.symbol.unselected,contentMode:$contentMode.scaleAspectFit},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(this.containerMargin/2),t.size.equalTo($size(25,25))}}),t}getListEditerView(){return{type:\"list\",props:{id:this.listId,bgcolor:r.primaryViewBackgroundColor,separatorInset:$insets(0,this.clipsInstance.horizontalMargin,0,0),indicatorInsets:$insets(0,0,this.toolBarHeight,0),data:this.clipsInstance.clips.map((t=>this.lineData(t))),template:this.listTemplate(),reorder:!0,footer:{height:this.toolBarHeight},crossSections:!1},events:{rowHeight:(t,e)=>{if(this.reorder.began){const t=e.row;t===this.reorder.to?e=this.reorder.from:this.reorder.tothis.reorder.to&&t<=this.reorder.from&&(e=t-1):this.reorder.to>this.reorder.from&&t=this.reorder.from&&(e=t+1)}const i=this.clipsInstance.getByIndex(e),s=i.hasTag?this.clipsInstance.tagHeight:this.clipsInstance.verticalMargin,r=i.image?this.clipsInstance.imageContentHeight:this.clipsInstance.getContentHeight(i.text);return this.clipsInstance.verticalMargin+r+s},reorderBegan:t=>{this.reorder.began=!0,this.reorder.from=t.row,this.reorder.to=t.row},reorderMoved:(t,e)=>{this.reorder.to=e.row},reorderFinished:()=>{this.reorder.began=!1,this.reorder.to!==this.reorder.from&&this.clipsInstance.move(this.reorder.from,this.reorder.to)},didSelect:(t,e,i)=>{this.editorSelected[e.row]=!this.editorSelected[e.row]}},layout:$layout.fill}}presentSheet(){this.sheet=new n,this.sheet.setView(s.createFromViews([this.getListEditerView(),this.getToolBarView()])).addNavBar({title:\"\",popButton:{title:$l10n(\"CLOSE\")},rightButtons:[{title:$l10n(\"CLEAR\"),color:$color(\"red\"),tapped:async()=>{0===(await $ui.alert({title:$l10n(\"DELETE_DATA\"),message:$l10n(\"DELETE_TABLE\").replaceAll(\"${table}\",this.clipsInstance.tableL10n),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index&&this.deleteTable()}}]}).init().present()}}t.exports=a})),parcelRequire.register(\"44eiF\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.Matrix,r=i.Setting,n=i.NavigationView,a=i.BarButtonItem,o=i.Sheet,l=i.UIKit,h=parcelRequire(\"f0nX9\"),c=parcelRequire(\"7TSVv\"),d=parcelRequire(\"eSp9Z\"),p=d.ActionEnv,u=d.ActionData,g=parcelRequire(\"2VUvw\");t.exports=class extends c{matrix;reorder={};addActionButtonId=\"action-manager-button-add\";sortActionButtonId=\"action-manager-button-sort\";syncButtonId=\"action-manager-button-sync\";syncLabelId=\"action-manager-sync-label\";get actionList(){return super.actions.map((t=>{const e=[];return t.items.forEach((t=>{e.push(this.actionToData(t))})),{title:t.title,items:e}}))}actionSyncStatus(){$app.listen({actionSyncStatus:t=>{if(t.status===g.status.syncing&&t.animate)this.updateNavButton(!0),this.updateSyncLabel($l10n(\"SYNCING\"));else if(t.status===g.status.success)try{this.matrix.data=this.actionList}catch(t){this.kernel.error(t),this.updateSyncLabel(t)}finally{this.updateSyncLabel(),this.updateNavButton(!1),$(this.matrix.id)?.endRefreshing()}}})}getColor(t,e=null){return t?\"string\"==typeof t?$color(t):$rgba(t.red,t.green,t.blue,t.alpha):e}editActionInfoPageSheet(t,e){const i=this.getActionTypes(),s=!Boolean(t);s?this.editingActionInfo={type:i[0],name:\"MyAction\",color:\"#CC00CC\",icon:\"icon_062.png\",readme:\"\"}:(this.editingActionInfo=t,this.editingActionInfo.readme=this.getActionReadme(t.type,t.dir));const n=new r({structure:[],set:(t,e)=>(this.editingActionInfo[t]=e,!0),get:(t,e=null)=>Object.prototype.hasOwnProperty.call(this.editingActionInfo,t)?this.editingActionInfo[t]:e}),a=n.loader({type:\"input\",key:\"name\",icon:[\"pencil.circle\",\"#FF3366\"],title:$l10n(\"NAME\")}).create(),l=n.loader({type:\"color\",key:\"color\",icon:[\"pencil.tip.crop.circle\",\"#0066CC\"],title:$l10n(\"COLOR\")}).create(),h=n.loader({type:\"icon\",key:\"icon\",icon:[\"star.circle\",\"#FF9933\"],title:$l10n(\"ICON\"),bgcolor:this.getColor(this.editingActionInfo.color)}).create(),c=n.loader({type:\"menu\",key:\"type\",icon:[\"tag.circle\",\"#33CC33\"],title:$l10n(\"TYPE\"),items:i,values:i,pullDown:!0}).create(),d={type:\"view\",views:[{type:\"text\",props:{id:\"action-text\",textColor:$color(\"#000000\",\"secondaryText\"),bgcolor:$color(\"systemBackground\"),text:this.editingActionInfo.readme,insets:$insets(10,10,10,10)},layout:$layout.fill,events:{tapped:t=>{$(\"actionInfoPageSheetList\").scrollToOffset($point(0,s?280:230)),$delay(.2,(()=>t.focus()))},didChange:t=>{this.editingActionInfo.readme=t.text}}}],layout:$layout.fill},p=[{title:$l10n(\"INFORMATION\"),rows:[a,l,h]},{title:$l10n(\"DESCRIPTION\"),rows:[d]}];s&&(p[0].rows=p[0].rows.concat(c));const u=new o,g=async()=>{if(s){if(this.editingActionInfo.dir=$text.MD5(this.editingActionInfo.name),this.exists(this.editingActionInfo)){if(1===(await $ui.alert({title:$l10n(\"UNABLE_CREATE_ACTION\"),message:$l10n(\"ACTION_NAME_ALREADY_EXISTS\").replaceAll(\"${name}\",this.editingActionInfo.name)})).index)return}const t=this.getActionOrder(this.editingActionInfo.type,!0);t.unshift(this.editingActionInfo.dir),this.saveOrder(this.editingActionInfo.type,t)}u.dismiss(),this.saveActionInfo(this.editingActionInfo),await $wait(.3),e&&e(this.editingActionInfo)};u.setView({type:\"list\",props:{id:\"actionInfoPageSheetList\",bgcolor:$color(\"insetGroupedBackground\"),style:2,separatorInset:$insets(0,50,0,10),data:p},layout:$layout.fill,events:{rowHeight:(t,e)=>1===e.section?120:50}}).addNavBar({title:\"\",popButton:{title:$l10n(\"CANCEL\")},rightButtons:[{title:$l10n(\"DONE\"),tapped:async()=>await g()}]}).init().present()}editActionMainJs(t=\"\",e){const i=new h(this.kernel);i.pageSheet(t,(t=>{this.saveMainJs(e,t)}),e.name,[{symbol:\"book.circle\",tapped:()=>{const t=$file.read(\"scripts/action/README.md\").string;(new o).setView({type:\"markdown\",props:{content:t},layout:(t,e)=>{t.size.equalTo(e.super)}}).init().present()}},{symbol:\"play.circle\",tapped:async()=>{this.saveMainJs(e,i.text);let t=await this.getActionHandler(e.type,e.dir)(new u({env:p.build}));if(void 0!==t){\"object\"==typeof t&&(t=JSON.stringify(t,null,2));(new o).setView({type:\"code\",props:{lineNumbers:!0,editable:!1,text:t},layout:$layout.fill}).addNavBar({title:\"\",popButton:{title:$l10n(\"DONE\")}}).init().present()}}}],\"code\")}move(t,e){if(t.section===e.section&&t.row===e.row)return;super.move(t,e);const i=this.matrix,s=this.actionToData(this.actions[e.section].items[e.row]);t.row{const i=t.cell(e),s=i.get(\"info\").info;this.editActionInfoPageSheet(s,(t=>{i.get(\"info\").info=t,i.get(\"color\").bgcolor=this.getColor(t.color),i.get(\"name\").text=t.name,\"icon_\"===t.icon.slice(0,5)?i.get(\"icon\").icon=$icon(t.icon.slice(5,t.icon.indexOf(\".\")),$color(\"#ffffff\")):i.get(\"icon\").image=$image(t.icon)}))}},{title:$l10n(\"EDIT_SCRIPT\"),symbol:\"square.and.pencil\",handler:(t,e,i)=>{const s=i.info.info;if(!s)return;const r=`${this.userActionPath}/${s.type}/${s.dir}/main.js`,n=$file.read(r).string;this.editActionMainJs(n,s)}},{inline:!0,items:[{title:\"README\",symbol:\"book\",handler:(t,e)=>{const i=t.cell(e).get(\"info\").info;let s;try{s=__ACTIONS__[i.type][i.dir][\"README.md\"]}catch{s=this.getActionReadme(i.type,i.dir)}(new o).setView({type:\"markdown\",props:{content:s},layout:(t,e)=>{t.size.equalTo(e.super)}}).init().present()}}]},{inline:!0,items:[{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,handler:(t,e,i)=>{l.deleteConfirm($l10n(\"DELETE_CONFIRM_MSG\"),(()=>{this.delete(i.info.info),t.delete(e)}))}}]}]}getNavButtons(){return[{symbol:\"plus.circle\",id:this.addActionButtonId,menu:{pullDown:!0,asPrimary:!0,items:[{title:$l10n(\"CREATE_NEW_ACTION\"),handler:()=>{this.editActionInfoPageSheet(null,(async t=>{this.matrix.insert({indexPath:$indexPath(this.getActionTypes().indexOf(t.type),0),value:this.actionToData(t)});const e=$file.read(`${this.actionPath}/template.js`).string;this.saveMainJs(t,e),await $wait(.3),this.editActionMainJs(e,t)}))}},{title:$l10n(\"CREATE_NEW_TYPE\"),handler:()=>{$input.text({text:\"\",placeholder:$l10n(\"CREATE_NEW_TYPE\"),handler:t=>{if(\"\"===(t=t.trim()))return void $ui.toast($l10n(\"INVALID_VALUE\"));const e=`${this.userActionPath}/${t}`;$file.isDirectory(e)?$ui.warning($l10n(\"TYPE_ALREADY_EXISTS\")):($file.mkdir(e),$ui.success($l10n(\"SUCCESS\")))}})}}]}},{symbol:\"arrow.up.arrow.down.circle\",id:this.sortActionButtonId,tapped:(t,e)=>{$ui.popover({sourceView:e,directions:$popoverDirection.up,size:$size(200,300),views:[this.getActionListView(void 0,{reorder:!0,actions:[{title:\"delete\",handler:(t,e)=>{const i=this.matrix,s=i.object(e,!1).info.info;this.delete(s),i.delete(e,!1)}}]},{reorderBegan:t=>{this.reorder.from=t,this.reorder.to=void 0},reorderMoved:(t,e)=>{this.reorder.to=e},reorderFinished:t=>{void 0!==this.reorder.to&&this.move(this.reorder.from,this.reorder.to,t)}})]})}}]}actionToData(t){return{name:{text:t.name},icon:\"icon_\"===t?.icon?.slice(0,5)?{icon:$icon(t.icon.slice(5,t.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(t?.icon)},color:{bgcolor:this.getColor(t.color)},info:{info:t}}}updateSyncLabel(t){t||(t=$l10n(\"MODIFIED\")+this.getLocalSyncData().toLocaleString()),$(this.syncLabelId)&&($(this.syncLabelId).text=t)}updateNavButton(t){const e=this.navigationView?.navigationBarItems?.getButton(this.addActionButtonId);e&&e.setLoading(t);const i=this.navigationView?.navigationBarItems?.getButton(this.sortActionButtonId);i&&i.setLoading(t);const s=this.navigationView?.navigationBarItems?.getButton(this.syncButtonId);s&&s.setLoading(t)}getActionListView(t,e={},i={}){return t&&(i.didSelect=(e,i,s)=>{const r=s.info.info,n=this.getActionHandler(r.type,r.dir);t(n)}),{type:\"list\",layout:(t,e)=>{t.top.width.equalTo(e.super.safeArea),t.bottom.inset(0)},events:i,props:Object.assign({reorder:!1,bgcolor:$color(\"clear\"),rowHeight:60,sectionTitleHeight:30,stickyHeader:!0,data:(()=>{const t=this.actionList;return t.map((t=>(t.rows=t.items,t))),t})(),template:{props:{bgcolor:$color(\"clear\")},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(15),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(20),t.size.equalTo($size(20,20))}},{type:\"label\",props:{id:\"name\",lines:1,font:$font(16)},layout:(t,e)=>{t.height.equalTo(30),t.centerY.equalTo(e.super),t.left.equalTo(e.prev.right).offset(15)}},{type:\"label\",props:{id:\"info\"}}]}},e)}}getActionMiniView(t,e){e||(e=[],super.actions.forEach((t=>{e=e.concat(t.items)})));return{type:\"matrix\",props:{bgcolor:$color(\"clear\"),columns:2,itemHeight:50,spacing:8,data:[],template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color($rgba(255,255,255,.3),$rgba(0,0,0,.3))},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:t=>{t.top.left.inset(10),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(t,e)=>{t.edges.equalTo(e.prev).insets(5)}},{type:\"label\",props:{id:\"name\",font:$font(14)},layout:(t,e)=>{t.bottom.top.inset(10),t.left.equalTo(e.prev.prev.right).offset(10),t.right.inset(10)}},{type:\"view\",props:{id:\"info\",hidden:!0}}]}},layout:$layout.fill,events:{ready:t=>{t.data=e.map((t=>this.actionToData(t)))},didSelect:async(e,i,s)=>{const r=s.info.info,n=await t(r);this.getActionHandler(r.type,r.dir)(n)}}}}getMatrixView({columns:t=2,spacing:e=15,itemHeight:i=100}={}){return this.matrix=s.create({type:\"matrix\",props:{columns:t,itemHeight:i,spacing:e,bgcolor:l.scrollViewBackgroundColor,menu:{items:this.menuItems()},data:this.actionList,template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color(\"#ffffff\",\"#242424\")},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:t=>{t.top.left.inset(10),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:t=>{t.top.left.inset(15),t.size.equalTo($size(20,20))}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:l.textColor,titleColor:l.textColor,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},views:[{type:\"image\",props:{symbol:\"ellipsis.circle\"},layout:(t,e)=>{t.center.equalTo(e.super),t.size.equalTo(a.style.iconSize)}}],events:{tapped:t=>{const e=t.next.info;if(!e)return;const i=`${this.userActionPath}/${e.type}/${e.dir}/main.js`,s=$file.read(i).string;this.editActionMainJs(s,e)}},layout:t=>{t.top.right.inset(0),t.size.equalTo(a.style.width)}},{type:\"view\",props:{id:\"info\",hidden:!0}},{type:\"label\",props:{id:\"name\",font:$font(16)},layout:(t,e)=>{t.bottom.left.inset(10),t.width.equalTo(e.super)}}]},footer:{type:\"view\",props:{hidden:!this.kernel.setting.get(\"webdav.status\"),height:this.kernel.setting.get(\"webdav.status\")?50:0},views:[{type:\"label\",props:{id:this.syncLabelId,color:$color(\"secondaryText\"),font:$font(12),text:$l10n(\"MODIFIED\")+this.getLocalSyncData().toLocaleString()},layout:(t,i)=>{t.size.equalTo(i.super),t.top.inset(-30),t.left.inset(e)}}]}},layout:$layout.fill,events:{didSelect:(t,e,i)=>{const s=i.info.info,r=new u({env:p.action,text:\"clipboard\"===s.type||\"uncategorized\"===s.type?$clipboard.text:null});this.getActionHandler(s.type,s.dir)(r)},pulled:async t=>{this.isEnableWebDavSync?this.syncWithWebDav():(this.updateNavButton(!0),await this.sync(),this.matrix.data=this.actionList,this.updateSyncLabel(),this.updateNavButton(!1),t.endRefreshing())}}}),this.actionSyncStatus(),this.matrix.definition}getPage(){return this.navigationView=new n,this.navigationView.navigationBarItems.setRightButtons(this.getNavButtons()),this.navigationView.setView(this.getMatrixView()).navigationBarTitle($l10n(\"ACTIONS\")),this.navigationView.getPage()}present(){const t=new o,e=this.getNavButtons();this.kernel.setting.get(\"webdav.status\")&&e.push({id:this.syncButtonId,symbol:\"arrow.triangle.2.circlepath.circle\",tapped:async(t,e)=>{this.isEnableWebDavSync?this.syncWithWebDav():(this.updateNavButton(!0),await this.sync(),this.matrix.data=this.actionList,this.updateSyncLabel(),this.updateNavButton(!1))}}),t.setView(this.getMatrixView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{symbol:\"xmark.circle\"},rightButtons:e}).init(),this.navigationView=t.navigationView,t.present()}}})),parcelRequire.register(\"7TSVv\",(function(t,e){var i=parcelRequire(\"gxpqj\").FileStorage,s=parcelRequire(\"eSp9Z\"),r=s.ActionEnv,n=s.ActionData,a=s.Action,o=parcelRequire(\"jVlss\").SecureScript,l=parcelRequire(\"7pN8M\");t.exports=class{#q;constructor(t){this.kernel=t,this.actionPath=\"scripts/action\",this.actionOrderFile=\"order.json\",this.tempPath=`${this.kernel.fileStorage.basePath}/temp`,this.userActionPath=`${this.kernel.fileStorage.basePath}/user_action`,this.localSyncFile=this.userActionPath+\"/sync.json\",this.typeNameMap={},this.checkUserAction(),this.sync()}get actions(){return this.#q||(this.#q=this.getActionTypes().map((t=>({title:this.getTypeName(t),items:this.getActions(t)}))),this.kernel.print(\"init actions\")),this.#q}get isNew(){return $cache.get(\"caio.action.isNew\")??!1}set isNew(t){$cache.get(\"caio.action.isNew\",t)}get isEnableWebDavSync(){return this.kernel.setting.get(\"webdav.status\")}setNeedReload(){this.#q=void 0,this.isEnableWebDavSync&&this.webdavSync.needUpload()}importExampleAction(){try{Object.keys(__ACTIONS__).forEach((t=>{const e=`${this.userActionPath}/${t}`;Object.keys(__ACTIONS__[t]).forEach((i=>{$file.exists(`${e}/${i}/main.js`)||($file.mkdir(e),$file.mkdir(`${e}/${i}`),$file.write({data:$data({string:__ACTIONS__[t][i][\"main.js\"]}),path:`${e}/${i}/main.js`}),$file.write({data:$data({string:__ACTIONS__[t][i][\"config.json\"]}),path:`${e}/${i}/config.json`}),$file.write({data:$data({string:__ACTIONS__[t][i][\"README.md\"]}),path:`${e}/${i}/README.md`}))}))}))}catch{$file.list(this.actionPath).forEach((t=>{const e=`${this.actionPath}/${t}`;if($file.isDirectory(e)){const i=`${this.userActionPath}/${t}`;$file.list(e).forEach((t=>{$file.exists(`${i}/${t}/main.js`)||($file.mkdir(i),$file.copy({src:`${e}/${t}`,dst:`${i}/${t}`}))}))}}))}this.setNeedReload()}getLocalSyncData(){const t=JSON.parse($file.read(this.localSyncFile)?.string??\"{}\");return new Date(t.timestamp)}async sync(){this.kernel.setting.get(\"webdav.status\")&&(this.webdavSync?await this.webdavSync.init():await this.initSyncWithWebDav())}async initSyncWithWebDav(){if(this.isEnableWebDavSync)try{this.webdavSync=new l({kernel:this.kernel,host:this.kernel.setting.get(\"webdav.host\"),user:this.kernel.setting.get(\"webdav.user\"),password:this.kernel.setting.get(\"webdav.password\"),basepath:this.kernel.setting.get(\"webdav.basepath\")}),await this.webdavSync.init()}catch(t){throw this.kernel.error(`${t}\\n${t.stack}`),t}}syncWithWebDav(){this.isEnableWebDavSync&&this.webdavSync.sync()}checkUserAction(){$file.exists(this.userActionPath)&&0!==$file.list(this.userActionPath).length||($file.mkdir(this.userActionPath),this.isNew=!1,this.importExampleAction())}getActionTypes(){const t=[\"clipboard\",\"editor\"];return t.concat($file.list(this.userActionPath).filter((e=>$file.isDirectory(`${this.userActionPath}/${e}`)&&t.indexOf(e)<0)))}getActionOrder(t,e=!1){const i=`${this.userActionPath}/${t}`,s=`${i}/${this.actionOrderFile}`;if($file.exists(s)){const e=JSON.parse($file.read(s).string),r=e.filter((t=>!!$file.exists(`${i}/${t}`)));return r.length!==e.length&&this.saveOrder(t,r),r}if(e){const t=[];return $file.list(i).forEach((e=>{t.push(e)})),t}return[]}getActionPath(t,e){return`${this.userActionPath}/${t}/${e}`}getActionConfig(t,e){return JSON.parse($file.read(`${this.getActionPath(t,e)}/config.json`).string)}getActionReadme(t,e){return $file.read(`${this.getActionPath(t,e)}/README.md`).string}getAction(t,e,i){$file.exists(this.getActionPath(t,e))||(e=$text.MD5(e));const s=this.getActionPath(t,e),l=this.getActionConfig(t,e);try{const t=$file.read(`${s}/main.js`).string,e=new o(t),h=new Function(\"Action\",\"ActionEnv\",\"ActionData\",`${e.secure()}\\n return MyAction`)(a,r,n);return new h(this.kernel,l,i)}catch(t){throw this.kernel.error(t),t}}getActionHandler(t,e){return async i=>{try{const s=this.getAction(t,e,i);return await s.do()}catch(t){throw this.kernel.error(t),t}}}getActions(t){const e=[],i=`${this.userActionPath}/${t}`;if(!$file.exists(i))return[];const s=s=>{const r=`${i}/${s}/`;if($file.isDirectory(r)){const i=this.getActionConfig(t,s);e.push(Object.assign(i,{dir:s,type:t,name:i.name??s,icon:i.icon,color:i.color}))}},r=this.getActionOrder(t);return r.forEach((t=>s(t))),$file.list(i).forEach((t=>{-1===r.indexOf(t)&&s(t)})),e}getTypeName(t){const e=t.toUpperCase(),i=$l10n(e),s=i===e?t:i;return this.typeNameMap[s]=t,s}getTypeDir(t){return this.typeNameMap[t]??t}#P(t,...e){\"string\"!=typeof t&&(t=JSON.stringify(t));const s=i.join(this.userActionPath,...e),r=s.substring(0,s.lastIndexOf(\"/\"));$file.exists(r)||$file.mkdir(r);const n=$file.read(s)?.string;let a;try{a=JSON.stringify(JSON.parse(n))}catch{a=n}t!==a&&($file.write({data:$data({string:t}),path:s}),this.setNeedReload())}saveActionInfo(t){this.#P({icon:t.icon,color:t.color,name:t.name},t.type,t.dir,\"config.json\"),this.#P(t.readme,t.type,t.dir,\"README.md\")}saveMainJs(t,e){this.#P(e,t.type,t.dir,\"main.js\")}saveOrder(t,e){this.#P(JSON.stringify(e),t,this.actionOrderFile)}move(t,e){if(t.section===e.section&&t.row===e.row)return;const i=this.actions[t.section];let s=i.items;const r=this.getTypeDir(i.title),n=t=>t.map((t=>t.dir));if(t.section===e.section){const i=t.rowe.row?t.row+1:t.row;s.splice(i,0,s[t.row]),s=s.filter(((t,e)=>e!==a)),this.saveOrder(r,n(s))}else{const i=this.actions[e.section],a=i.items,o=this.getTypeDir(i.title);a.splice(e.row,0,s[t.row]),s=s.filter(((e,i)=>i!==t.row)),$file.move({src:`${this.userActionPath}/${r}/${a[e.row].dir}`,dst:`${this.userActionPath}/${o}/${a[e.row].dir}`}),this.saveOrder(o,n(a)),this.saveOrder(r,n(s))}}delete(t){$file.delete(`${this.userActionPath}/${t.type}/${t.dir}`),this.setNeedReload()}exists(t){const e=`${this.userActionPath}/${t.type}/${t.dir}`;return!!$file.exists(e)}}})),parcelRequire.register(\"7pN8M\",(function(t,e){var i=parcelRequire(\"gxpqj\").FileStorage,s=parcelRequire(\"2VUvw\");class r extends s{localSyncDataPath=\"/user_action/sync.json\";webdavSyncDataPath=\"/sync.json\";tempPath=\"/temp\";webdavActionsPath=\"/actions.zip\";localActionsPath=\"/user_action\";constructor({host:t,user:e,password:s,basepath:r,kernel:n}={}){super({host:t,user:e,password:s,basepath:r=i.join(r,\"user_action\"),kernel:n})}async init(){await super.init(),this.sync()}isNew(){return this.kernel.actionManager.isNew}async pull(){const t=i.join(this.tempPath,\"user_action\"),e=this.kernel.fileStorage.filePath(t),s=await this.webdav.get(this.webdavActionsPath);if(!await $archiver.unzip({file:s.rawData,dest:e}))throw new Error(\"unzip failed\");await this.downloadSyncData(),this.kernel.fileStorage.move(t,this.localActionsPath),this.kernel.print(\"action webdav sync: pulled\")}async push(){const t=i.join(this.tempPath,\"actions.zip\");if(!$archiver.zip({directory:this.kernel.fileStorage.filePath(this.localActionsPath),dest:this.kernel.fileStorage.filePath(t)}))throw new Error(\"zip failed\");await $wait(.5),await this.webdav.put(this.webdavActionsPath,this.kernel.fileStorage.readSync(t)),await this.uploadSyncData(),this.kernel.fileStorage.delete(t),this.kernel.print(\"action webdav sync: pushed\")}notify(t){$app.notify({name:\"actionSyncStatus\",object:t})}async#$(){let t=!1;try{const e=await this.nextSyncStep();if(this.kernel.print(`action nextSyncStep: ${s.stepName[e]}`),e===s.step.needPush||e===s.step.init)await this.push();else if(e===s.step.needPull)await this.pull(),t=!0;else{if(e!==s.step.conflict)return void this.notify({status:s.status.nochange});await this.conflict($l10n(\"ACTIONS\"))===r.conflictKeep.webdav&&(t=!0)}}catch(t){throw this.notify({status:s.status.fail,error:t}),t}finally{this.notify({status:s.status.success,updateList:t})}}sync(){this.notify({status:s.status.syncing,animate:!0}),this.syncTimer&&this.syncTimer.cancel(),this.syncTimer=$delay(.5,(()=>{this.#$(!0)}))}needUpload(){this.notify({status:s.status.syncing}),this.uploadTimer&&this.uploadTimer.cancel(),this.uploadTimer=$delay(.5,(()=>{this.updateLocalTimestamp(),this.#$()}))}}t.exports=r})),parcelRequire.register(\"gYDdO\",(function(t,e){class i{files=[];databases=[];actions={};constructor(t){this.kernel=t}deleteFiles(t){t.forEach((t=>{this.files.includes(t)||this.files.push(t)}))}#_(){this.files.forEach((t=>{$file.exists(t)&&(this.kernel.print(`delete file: ${t}`),$file.delete(t))}))}rebuildDatabase(t,e){this.databases.push([t,e])}#V(){const t=(t,e)=>{const i=this.kernel.storage.sqlite.query(`SELECT count(*), name FROM sqlite_master WHERE type = \"table\" AND name = \"${t}\"`);if(null!==i.error)throw new Error(`Code [${i.error.code}] ${i.error.domain} ${i.error.localizedDescription}`);i.result.next();const s=i.result.get(0);i.result.close(),s>0&&(this.kernel.print(`copy data from old table: ${t}`),this.kernel.storage.sqlite.update(`INSERT INTO ${e} SELECT * FROM ${t}`),this.kernel.print(`drop table: ${t}`),this.kernel.storage.sqlite.update(`DROP TABLE ${t}`))};this.databases.forEach((e=>{t(e[0],e[1])}))}rebuildUserActions(t={}){for(let e of Object.keys(t))t[e].forEach((t=>{this.actions[e]||(this.actions[e]=[]),this.actions[e].includes(t)||this.actions[e].push(t)}))}async#M(){if(0===Object.keys(this.actions).length)return;const t=\"scripts/action\",e=`${this.kernel.fileStorage.basePath}/user_action`,i=[];for(let e of Object.keys(this.actions))this.actions[e].forEach((s=>{const r=JSON.parse($file.read(`${t}/${e}/${s}/config.json`).string);i.push(r.name)}));if(1!==(await $ui.alert({title:$l10n(\"compatibility.rebuildUserAction.alert.title\"),message:$l10n(\"compatibility.rebuildUserAction.alert.message\")+\"\\n\"+JSON.stringify(i,null,2)+\"\\n\"+$l10n(\"compatibility.rebuildUserAction.alert.message2\"),actions:[{title:$l10n(\"OK\")},{title:$l10n(\"CANCEL\")}]})).index){for(let i of Object.keys(this.actions))this.actions[i].forEach((s=>{$file.exists(`${e}/${i}/${s}`)&&(this.kernel.print(`rebuild user action: ${i}/${s}`),$file.copy({src:`${t}/${i}/${s}/main.js`,dst:`${e}/${i}/${s}/main.js`}))}));this.kernel.actionManager.setNeedReload()}}async do(){this.#_(),this.#V(),await this.#M()}}class s{version=7;userVersion=$cache.get(\"compatibility.version\")??0;constructor(t){this.kernel=t,this.compatibility=new i(this.kernel)}do(){this.userVersionthis.kernel.error(t))),$cache.set(\"compatibility.version\",this.version)}call(t){if(\"function\"!=typeof this[`ver${t}`])throw new ReferenceError(`version ${t} undefined`);this[`ver${t}`]()}ver1(){this.compatibility.deleteFiles([\"scripts/action/clipboard/ClearClipboard\",\"scripts/ui/clipboard.js\",\"scripts/ui/clipboard-data.js\",\"scripts/ui/clipboard-search.js\"]),this.compatibility.rebuildDatabase(\"clipboard\",\"clips\"),this.compatibility.rebuildUserActions({uncategorized:[\"ExportAllContent\",\"DisplayClipboard\"],clipboard:[\"B23Clean\"]}),$cache.get(\"caio.keyboard.height\")&&(this.kernel.setting.set(\"keyboard.previewAndHeight\",$cache.get(\"caio.keyboard.height\")),$cache.remove(\"caio.keyboard.height\"))}ver2(){this.compatibility.deleteFiles([\"scripts/storage.js\",\"scripts/ui/clips-data.js\",\"scripts/ui/components/action-manager-data.js\"]),this.compatibility.rebuildDatabase(\"pin\",\"favorite\"),this.compatibility.rebuildUserActions({uncategorized:[\"ExportAllContent\"]})}ver3(){this.compatibility.rebuildUserActions({clipboard:[\"SendToWin\"]})}ver4(){const t=\"/storage/user_action/data.json\";if($file.exists(t)){const e=JSON.parse($file.read(t).string).date;$file.write({data:$data({string:JSON.stringify({timestamp:e})}),path:\"/storage/user_action/sync.json\"}),$file.delete(t)}}ver5(){this.compatibility.rebuildUserActions({uncategorized:[\"DisplayClipboard\"]})}ver6(){this.compatibility.rebuildUserActions({clipboard:[\"GetFromWin\"]})}ver7(){this.compatibility.rebuildUserActions({uncategorized:[\"Replace\"]})}}t.exports=async function(t){if(t)try{new s(t).do()}catch(e){throw t.error(e),e}}})),parcelRequire.register(\"9RsVy\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.Kernel,r=i.UIKit,n=parcelRequire(\"2aNLD\"),a=parcelRequire(\"ilpYs\");let o;function l(){o.setting.method.exportClipboard=t=>{t.start(),o.storage.export((e=>{e?t.done():t.cancel()}))},o.setting.method.importClipboard=t=>{t.start(),$ui.alert({title:$l10n(\"ALERT_INFO\"),message:$l10n(\"OVERWRITE_ALERT\"),actions:[{title:$l10n(\"OK\"),handler:()=>{$drive.open({handler:e=>{void 0!==e?\"db\"===e.fileName.slice(-2)||\"zip\"===e.fileName.slice(-3)?o.storage.import(e).then((()=>{t.done(),$delay(.3,(()=>{$addin.restart()}))})).catch((e=>{$ui.error(e),o.error(e),t.cancel()})):($ui.warning($l10n(\"FILE_TYPE_ERROR\")),t.cancel()):t.cancel()}})}},{title:$l10n(\"CANCEL\"),handler:()=>t.cancel()}]})},o.setting.method.rebuildDatabase=t=>{t.start();$ui.alert({title:$l10n(\"REBUILD_DATABASE_ALERT\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{(()=>{try{o.storage.rebuild(),t.done(),$delay(.8,(()=>$addin.restart()))}catch(e){t.cancel(),$ui.alert(e)}})()}},{title:$l10n(\"CANCEL\"),handler:()=>{t.cancel()}}]})},o.setting.method.deleteAllData=t=>{t.start(),$ui.alert({title:$l10n(\"DELETE_ALL_DATA_ALERT\"),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{o.storage.deleteAllData(),t.done(),$delay(.5,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\"),handler:()=>{t.cancel()}}]})},o.setting.method.recycleBin=()=>({type:\"list\",props:{data:o.clips.getRecycleBin().map((t=>t?.text??\"None\")),actions:[{title:$l10n(\"DELETE\"),handler:(t,e)=>{o.clips.removeFromRecycleBin(e.row)}}]},events:{didSelect:(t,e)=>{const i=o.clips.getRecycleBin()[e.row]??{};if(i.text){const s=o.clips.addItem(i.text);i.tag&&o.storage.setTag(s.uuid,i.tag),o.clips.removeFromRecycleBin(e.row),o.clips.updateList(!0),t.delete(e)}}},layout:$layout.fill})}t.exports=function(t){o=t,o.setting.method.checkUpdate=async t=>{t.start();const e=\"scripts/libs/easy-jsbox.js\";if($file.exists(e))try{const t=await o.checkUpdate();t&&($file.write({data:$data({string:t}),path:e}),$ui.toast(\"The framework has been updated.\"))}catch{}$http.get({url:\"https://raw.githubusercontent.com/ipuppet/CAIO/master/config.json\",handler:e=>{const i=e.data?.info.version;let r;try{r=__INFO__}catch{r=JSON.parse($file.read(\"config.json\").string).info}s.versionCompare(i,r.version)>0?$ui.alert({title:\"New Version\",message:`New version found: ${i}\\nUpdate via Github or click the button to open Erots.`,actions:[{title:$l10n(\"CANCEL\")},{title:\"Erots\",handler:()=>{$addin.run({name:\"Erots\",query:{q:\"show\",objectId:\"603e6eaaca0dd64fcef93e2d\"}})}}]}):$ui.toast(\"No need to update\"),t.done()}})},o.setting.method.previewWidget=t=>{const{Widget:e}=parcelRequire(\"gD12U\"),i={};try{JSON.parse($file.read(\"widget-options.json\").string).forEach((t=>{i[t.name]=t.value}))}catch(t){return void $ui.error(t)}$ui.menu({items:Object.keys(i),handler:t=>{e.render(i[t])}})},o.setting.method.fileManager=()=>{o.fileManager.push(\"storage\")},l(),o.setting.method.exportAction=t=>{t.start();const e=\"actions.zip\",i=`/${e}`,s=o.fileStorage.filePath(i);$archiver.zip({directory:o.actionManager.userActionPath,dest:s,handler:()=>{$share.sheet({items:[{name:e,data:$data({path:s})}],handler:e=>{e?t.done():t.cancel(),o.fileStorage.delete(i)}})}})},o.setting.method.importAction=t=>{t.start(),$drive.open({handler:e=>{if(void 0!==e)if(\"zip\"===e.fileName.slice(-3)){const i=`${o.fileStorage.basePath}/action_import`;$archiver.unzip({file:e,dest:i,handler:()=>{$file.list(i).forEach((t=>{$file.isDirectory(`${i}/${t}`)&&$file.copy({src:`${i}/${t}`,dst:`${o.actionManager.userActionPath}/${t}`})})),$file.delete(i),t.done()}})}else $ui.warning($l10n(\"FILE_TYPE_ERROR\")),t.cancel();else t.cancel()}})},o.setting.method.importExampleAction=t=>{t.start(),o.actionManager.importExampleAction(),t.done()},o.setting.method.rebuildAction=t=>{t.start(),$ui.alert({title:$l10n(\"REBUILD_ACTION_DATABASE_ALERT_TITLE\"),message:$l10n(\"REBUILD_ACTION_DATABASE_ALERT_MESSAGE\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{$file.delete(o.actionManager.userActionPath),o.actionManager.setNeedReload(),t.done(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\"),handler:()=>t.cancel()}]})},function(){const t=parcelRequire(\"7eNYp\"),e=200;o.setting.method.previewKeyboard=()=>{const i=new t(o),s=t=>{i.setKeyboardHeight(t),$(i.keyboardId).updateLayout((t=>{t.height.equalTo(i.keyboardHeight)})),1===i.keyboardDisplayMode&&$(i.keyboardId).get(i.listId).reload()},n=t=>(t-e)/200;return{views:[{type:\"label\",layout:(t,e)=>{t.top.inset(20),t.centerX.equalTo(e.super)},events:{ready:t=>t.text=i.keyboardHeight,tapped:t=>{$input.text({type:$kbType.number,text:i.keyboardHeight,handler:i=>{if(/^[0-9]+$/.test(i)){let r=Number(i);r=Math.min(r,400),r=Math.max(r,e),t.text=r,t.next.value=n(r),s(r)}else $ui.toast(\"Only integers can be entered.\")}})}}},{type:\"slider\",props:{max:1,min:0},layout:(t,e)=>{t.top.equalTo(e.prev.bottom),t.right.inset(20),t.width.equalTo(e.super).offset(-40)},events:{ready:t=>t.value=n(i.keyboardHeight),changed:t=>{const i=Math.floor(200*t.value+e);t.prev.text=i,s(i)}}},i.getView()],layout:(t,e)=>{t.left.right.bottom.equalTo(e.super.safeArea);let i=0;1===o.setting.get(\"mainUIDisplayMode\")&&(i=r.NavigationBarNormalHeight),t.top.equalTo(e.super.safeArea).inset(i)}}},o.setting.method.setKeyboardQuickStart=()=>n.sheet()}(),o.setting.method.previewTodayWidget=t=>{t.touchHighlightStart();const e=new(parcelRequire(\"49je6\"))(o).getView();r.push({views:[e],disappeared:()=>t.touchHighlightEnd()})},o.setting.method.setTodayWidgetActions=t=>{a.sheet(o)}}})),parcelRequire.register(\"2aNLD\",(function(t,e){var i=parcelRequire(\"gxpqj\").Sheet;class s{constructor(){this.listId=\"keyboard-script-list\"}static getAddins(){const t=$cache.get(\"keyboard.addins\");if(!t)return[];if($cache.get(\"keyboard.addins.all\")){const t=$addin.current.name;return $addin.list?.filter((e=>t!==e.displayName)).map((t=>t.displayName))}try{return JSON.parse(t)}catch(t){return[]}}static setAddins(t=[]){t.map(((e,i)=>{null===e&&t.splice(i,1)}));try{$cache.set(\"keyboard.addins\",JSON.stringify(t))}catch(t){$cache.set(\"keyboard.addins\",void 0)}}static setAllAddins(t){$cache.set(\"keyboard.addins.all\",t)}getUnsetAddins(){const t=$addin.current.name,e=s.getAddins();return $addin.list?.filter((i=>-1===e.indexOf(i.displayName)&&t!==i.displayName)).map((t=>t.displayName))}add(){const t={type:\"list\",props:{data:this.getUnsetAddins()},events:{didSelect:(t,e,i)=>{const r=s.getAddins();r.unshift(i),s.setAddins(r),$(this.listId).insert({indexPath:$indexPath(0,0),value:i}),t.delete(e)}},layout:$layout.fill};(new i).setView(t).addNavBar({title:$l10n(\"ADD\")}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListView(){return{type:\"list\",props:{id:this.listId,reorder:!0,data:s.getAddins(),actions:[{title:\"delete\",handler:(t,e)=>{s.setAddins(t.data)}}]},events:{reorderFinished:t=>{s.setAddins(t)}},layout:$layout.fill}}static async sheet(){if(0===(await $ui.menu({items:[$l10n(\"ALL_SCRIPTS\"),$l10n(\"SELECT_SCRIPTS\")]})).index)s.setAllAddins(!0);else{s.setAllAddins(!1);const t=new i,e=new s;t.setView(e.getListView()).addNavBar({title:$l10n(\"QUICK_START_SCRIPTS\"),popButton:{title:$l10n(\"DONE\")},rightButtons:e.getNavButtons()}),t.init().present()}}}t.exports=s})),parcelRequire.register(\"ilpYs\",(function(t,e){var i=parcelRequire(\"gxpqj\").Sheet;class s{constructor(t){this.listId=\"today-action-list\",this.kernel=t}getActions(){let t=$cache.get(\"today.actions\")??[];\"string\"==typeof t&&(t=JSON.parse(t),this.setActions(t));const e={};this.kernel.actionManager.getActionTypes().forEach((t=>{this.kernel.actionManager.getActions(t).forEach((t=>{e[t.type+t.dir]=t}))}));const i=[];let s=!1;return t.forEach((t=>{const r=e[t.type+t.dir];r?i.push(r):s=!0})),s&&this.setActions(i),i}setActions(t=[]){t.map(((e,i)=>{e||t.splice(i,1)})),$cache.set(\"today.actions\",t)}getAllActions(){let t=[];return this.kernel.actionManager.getActionTypes().forEach((e=>{t=t.concat(this.kernel.actionManager.getActions(e))})),t}getUnsetActions(){const t=this.getActions().map((t=>t.name)),e=[];return this.getAllActions().forEach((i=>{const s=i.name;-1===t.indexOf(s)&&e.push(i)})),e}getListData(t){return t.map((t=>({action:{text:t.name,info:t},icon:\"icon_\"===t.icon.slice(0,5)?{icon:$icon(t.icon.slice(5,t.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(t.icon)},color:{bgcolor:this.kernel.actionManager.getColor(t.color)}})))}getListTemplate(){return{views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:t=>{t.top.left.inset(10),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:t=>{t.top.left.inset(15),t.size.equalTo($size(20,20))}},{type:\"label\",props:{id:\"action\"},layout:(t,e)=>{t.bottom.top.inset(10),t.left.equalTo(e.prev.prev.right).offset(10),t.right.inset(10)}}]}}add(){const t={type:\"list\",props:{data:this.getListData(this.getUnsetActions()),template:this.getListTemplate(),rowHeight:50},events:{didSelect:(t,e,i)=>{const s=i.action.info,r=this.getActions();r.unshift(s),this.setActions(r),$(this.listId).insert({indexPath:$indexPath(0,0),value:this.getListData([s])[0]}),t.delete(e)}},layout:$layout.fill};(new i).setView(t).addNavBar({title:$l10n(\"ADD\"),popButton:{title:$l10n(\"CLOSE\")}}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListView(){return{type:\"list\",props:{id:this.listId,data:this.getListData(this.getActions()),template:this.getListTemplate(),rowHeight:50,reorder:!0,actions:[{title:\"delete\",handler:(t,e)=>{this.setActions(t.data.map((t=>t.action.info)))}}]},events:{reorderFinished:t=>{const e=[];t.forEach((t=>{e.push(t.action.info)})),this.setActions(e)}},layout:$layout.fill}}static sheet(t){const e=new i,r=new s(t);e.setView(r.getListView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{title:$l10n(\"CLOSE\")},rightButtons:r.getNavButtons()}),e.init().present()}}t.exports=s})),parcelRequire.register(\"7eNYp\",(function(t,e){var i=parcelRequire(\"eSp9Z\"),s=i.ActionData,r=i.ActionEnv,n=parcelRequire(\"gxpqj\"),a=n.View,o=n.UIKit,l=n.Sheet,h=n.BarButtonItem,c=parcelRequire(\"imdB1\"),d=parcelRequire(\"2aNLD\");t.exports=class extends c{#F;keyboardId=\"keyboard.main\";listId=\"keyboard-clips-list\";actionsId=\"keyboard-list-actions\";keyboardSwitchLockId=\"keyboard-switch-lock\";keyboardSwitchLockKey=\"caio.keyboard.switch.lock\";deleteTimer=void 0;continuousDeleteTimer=void 0;continuousDeleteTapticTimer=void 0;continuousDeleteDelay=.5;horizontalMargin=15;verticalMargin=12;copiedIndicatorSize=5;containerMargin=4;fontSize=14;tagHeight=this.verticalMargin+3;matrixBoxMargin=10;navHeight=50;bottomBarHeight=50;bottomButtonSize=$size(46,40);menuItemActionMaxCount=3;itemBackground=$color(\"#FFFFFF\",$rgba(151,151,151,.4));buttonBackground=$color($rgba(0,0,0,.15),$rgba(117,117,117,.4));constructor(t){super(t),this.keyboardDisplayMode=this.kernel.setting.get(\"keyboard.displayMode\"),this.backgroundImage=this.kernel.setting.get(\"keyboard.background.image\")?.image,this.useBlur=this.backgroundImage&&this.kernel.setting.get(\"keyboard.blur\"),this.deleteDelay=this.kernel.setting.get(\"keyboard.deleteDelay\"),\"boolean\"!=typeof $cache.get(this.keyboardSwitchLockKey)&&$cache.set(this.keyboardSwitchLockKey,!1)}get keyboardHeight(){return this.kernel.setting.get(\"keyboard.previewAndHeight\")}setKeyboardHeight(t){this.kernel.setting.set(\"keyboard.previewAndHeight\",t)}getKeyboardSwitchLock(){const t=$cache.get(this.keyboardSwitchLockKey);return\"boolean\"!=typeof t&&$cache.set(this.keyboardSwitchLockKey,!0),t}switchKeyboardSwitchLock(){const t=$cache.get(this.keyboardSwitchLockKey);$cache.set(this.keyboardSwitchLockKey,!t),$(this.keyboardSwitchLockId).symbol=t?\"lock.open\":\"lock\"}listReady(){this.updateList(),this.kernel.setting.get(\"clipboard.autoSave\")&&$app.env===$env.keyboard&&(this.#F=$timer.schedule({interval:1,handler:()=>{this.kernel.setting.get(\"clipboard.autoSave\")?this.readClipboard():this.#F.invalidate()}}))}keyboardTapped(t,e=!0){return async(...i)=>{if(e&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(this.kernel.setting.get(\"keyboard.tapticEngineLevel\")),\"function\"==typeof t)try{await t(...i)}catch(t){throw this.kernel.error(t),t}}}getTopButtons(){const t=[{symbol:\"keyboard.chevron.compact.down\",tapped:this.keyboardTapped((()=>$keyboard.dismiss()))},{symbol:\"square.and.arrow.down.on.square\",tapped:this.keyboardTapped((async t=>{t.start();try{await this.readClipboard(!0),t.done()}catch(e){throw t.cancel(),e}}))},{symbol:\"bolt.circle\",tapped:this.keyboardTapped((()=>{let t=!0===$(this.actionsId).hidden;$(this.listId+\"-container\").hidden=t,$(this.actionsId).hidden=!t}))}];return{type:\"view\",views:t.map(((t,e)=>{const i=new h;return i.buttonEdges=0,i.setAlign(o.align.right).setSymbol(t.symbol).setEvent(\"tapped\",t.tapped).definition})),layout:(e,i)=>{const s=new h;e.height.equalTo(i.super),e.right.inset(this.containerMargin-s.edges),e.width.equalTo(s.width*t.length+s.edges)}}}getTopBarView(){return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[{type:\"label\",props:{text:$l10n(\"CAIO\"),font:$font(\"bold\",20)},events:{tapped:()=>this.kernel.openInJsbox(),ready:t=>{$cache.get(\"tips.keyboard.title\")||($cache.set(\"tips.keyboard.title\",!0),$ui.popover({sourceView:t,size:$size(200,60),directions:$popoverDirection.up,views:[{type:\"label\",props:{lines:0,text:$l10n(\"CLICK_TO_OPEN_JSBOX\"),align:$align.center},layout:$layout.fillSafeArea}]}))}},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.equalTo(e.super).offset(this.containerMargin)}}].concat(this.tabView(),this.getTopButtons())}],layout:(t,e)=>{t.top.width.equalTo(e.super),t.height.equalTo(this.navHeight)}}}getBottomButtonView(t,e){const i=this.bottomButtonSize,s=this.containerMargin,r=(r,n)=>{if(t.title){const e=$text.sizeThatFits({text:t.title,width:o.windowSize.width,font:$font(16)}),n=Math.ceil(e.width)+2*(s+12);r.size.equalTo($size(n,i.height))}else r.size.equalTo(i);r.centerY.equalTo(n.super),n.prev&&n.prev.info.align===e?e===o.align.right?r.right.equalTo(n.prev.left).offset(1.5*-s):r.left.equalTo(n.prev.right).offset(1.5*s):e===o.align.right?r.right.inset(s):r.left.inset(s)},n={type:\"button\",props:Object.assign({smoothCorners:!1,cornerRadius:5,symbol:t.symbol,title:t.title,id:t.id??$text.uuid,font:$font(16),bgcolor:this.useBlur?$color(\"clear\"):this.buttonBackground,tintColor:o.textColor,titleColor:o.textColor,info:{align:e}},t.menu?{menu:t.menu}:{}),events:Object.assign({},t.tapped?{tapped:t.tapped}:{},t.events),layout:$layout.fill};return this.useBlur?o.blurBox({info:{align:e},style:$blurStyle.ultraThinMaterial,smoothCorners:!1,cornerRadius:5},[n],r):{type:\"view\",props:{info:{align:e}},views:[n],layout:r}}getBottomBarView(){const t=[],e=[];$device.hasFaceID&&!$device.isIpadPro||t.push({symbol:\"globe\",tapped:this.keyboardTapped((()=>$keyboard.next())),menu:{pullDown:!0,items:[{title:$l10n(\"SWITCH_KEYBOARD\"),handler:this.keyboardTapped((()=>$keyboard.next()))},{title:$l10n(\"OPEN_IN_JSBOX\"),handler:()=>this.kernel.openInJsbox()}]}}),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&t.push({symbol:this.getKeyboardSwitchLock()?\"lock\":\"lock.open\",id:this.keyboardSwitchLockId,tapped:this.keyboardTapped((()=>this.switchKeyboardSwitchLock()))}),t.push({symbol:\"paperplane\",menu:{pullDown:!0,asPrimary:!0,items:d.getAddins().reverse().map((t=>({title:t,handler:this.keyboardTapped((()=>$addin.run(t)))})))}}),e.push({title:$l10n(\"SEND\"),tapped:this.keyboardTapped((()=>$keyboard.send()))},{symbol:\"delete.left\",events:{touchesBegan:this.keyboardTapped((async()=>{$keyboard.delete(),this.continuousDeleteTapticTimer=$delay(this.continuousDeleteDelay,(()=>this.keyboardTapped()())),this.continuousDeleteTimer=$delay(this.continuousDeleteDelay,(()=>{this.deleteTimer=$timer.schedule({interval:this.deleteDelay,handler:()=>$keyboard.delete()})}))})),touchesEnded:()=>{this.deleteTimer?.invalidate(),this.continuousDeleteTimer?.cancel(),this.continuousDeleteTapticTimer?.cancel(),this.deleteTimer=void 0,this.continuousDeleteTimer=void 0}}});const i={type:\"button\",props:{smoothCorners:!1,cornerRadius:5,title:$l10n(\"SPACE\"),font:$font(16),bgcolor:this.itemBackground,titleColor:o.textColor},events:{tapped:this.keyboardTapped((()=>{$keyboard.insert(\" \")}))},layout:(t,i)=>{let s=i.prev;for(let t=0;tthis.getBottomButtonView(t,o.align.left))),...e.map((t=>this.getBottomButtonView(t,o.align.right))),i],layout:(t,e)=>{t.bottom.equalTo(e.super.safeArea).offset(-2),t.left.right.equalTo(e.super.safeArea),t.height.equalTo(this.bottomBarHeight)}}}menuItems(){const t=super.menuItems();return[t[0],t[2]]}itemContainer(t){return this.useBlur?o.blurBox({style:$blurStyle.ultraThinMaterial},t,$layout.fill):{type:\"view\",props:{bgcolor:this.itemBackground},views:t,layout:$layout.fill}}get matrixTemplate(){return{props:{smoothCorners:!0,cornerRadius:2*this.containerMargin},views:[this.itemContainer([{type:\"view\",props:{id:\"copied\",circular:this.copiedIndicatorSize,hidden:!0,bgcolor:$color(\"green\")},layout:(t,e)=>{t.size.equalTo(this.copiedIndicatorSize),t.left.top.inset(this.matrixBoxMargin/2)}},{type:\"label\",props:{id:\"content\",lines:0,font:$font(20)},layout:(t,e)=>{t.top.left.right.equalTo(e.super).inset(this.matrixBoxMargin),t.height.lessThanOrEqualTo(e.super).offset(2*-this.matrixBoxMargin-this.tagHeight)}},{type:\"label\",props:{id:\"tag\",lines:1,color:this.tagColor,autoFontSize:!0,align:$align.leading},layout:(t,e)=>{t.left.right.equalTo(e.prev),t.height.equalTo(this.tagHeight),t.bottom.equalTo(e.super).inset(this.matrixBoxMargin)}}]),{type:\"image\",props:{id:\"image\",hidden:!0},layout:$layout.fill}]}}get itemSelect(){return(t,e)=>{const i=this.clips[e.row];i.image?l.quickLookImage(i.imageOriginal):($keyboard.insert(i.text),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&!this.getKeyboardSwitchLock()&&$keyboard.next())}}getMatrixView(){const t={type:\"matrix\",props:{id:this.listId,bgcolor:$color(\"clear\"),menu:{items:this.menuItems()},direction:$scrollDirection.horizontal,square:!0,alwaysBounceVertical:!1,showsHorizontalIndicator:!1,alwaysBounceHorizontal:!0,columns:1,spacing:this.matrixBoxMargin,template:this.matrixTemplate},layout:(t,e)=>{t.top.inset(0),t.width.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom).offset(-1*(this.bottomBarHeight-this.navHeight))},events:{ready:()=>this.listReady(),didSelect:this.itemSelect,itemSize:(t,e)=>{let i=this.keyboardHeight-this.navHeight-this.bottomBarHeight;return i-=2*this.matrixBoxMargin,$size(i,i)}}},e=a.createFromViews([t,this.getEmptyBackground(this.listId)]);return e.setProp(\"id\",this.listId+\"-container\"),e}getListView(){const t=super.getListView();t.setProp(\"id\",this.listId+\"-container\"),t.layout=(t,e)=>{t.top.equalTo(this.navHeight-1),t.width.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom).offset(-this.bottomBarHeight-this.containerMargin)};const e=t.views[0];e.events.didSelect=this.itemSelect,e.props.separatorColor=$color(\"lightGray\"),e.props.separatorInset=$insets(0,this.horizontalMargin,0,this.horizontalMargin),delete e.events.pulled,e.props.header={props:{height:1}},e.props.style=2;const i=e.props.template.views[0].views;return e.props.template.views[0]=this.itemContainer(i),t}getDataView(){return 0===this.keyboardDisplayMode?this.getListView():this.getMatrixView()}getActionView(){return{type:\"view\",props:{id:this.actionsId,hidden:!0},views:[this.kernel.actionManager.getActionMiniView((async()=>new s({env:r.keyboard,textBeforeInput:$keyboard.textBeforeInput,textAfterInput:$keyboard.textAfterInput,text:$keyboard.selectedText??await $keyboard.getAllText()})))],layout:(t,e)=>{t.top.equalTo(this.navHeight),t.left.equalTo(this.containerMargin),t.right.equalTo(-this.containerMargin),t.bottom.equalTo(-this.bottomBarHeight)}}}getView(){const t={type:\"view\",views:[{type:\"image\",props:{image:this.backgroundImage},layout:$layout.fill},{type:\"view\",props:{bgcolor:$color(\"clear\",$rgba(0,0,0,.3))},layout:$layout.fill}],layout:$layout.fill};return{type:\"view\",props:{id:this.keyboardId},views:[this.backgroundImage?t:{},this.getDataView(),this.getTopBarView(),this.getBottomBarView(),this.getActionView()],layout:(t,e)=>{t.width.bottom.equalTo(e.super),t.height.equalTo(this.keyboardHeight)}}}}})),parcelRequire.register(\"49je6\",(function(t,e){var i=parcelRequire(\"eSp9Z\"),s=i.ActionData,r=i.ActionEnv,n=parcelRequire(\"gxpqj\"),a=n.View,o=n.UIKit,l=n.BarButtonItem,h=parcelRequire(\"imdB1\"),c=parcelRequire(\"ilpYs\");t.exports=class extends h{actionsId=\"today-list-actions\";listContainerId=\"today-list-container\";readClipboardButtonId=\"today-nav-readClipboard\";listId=\"today-list\";pageIndexId=\"today-list-page-index\";tabLeftMargin=8;horizontalMargin=15;verticalMargin=5;copiedIndicatorSize=5;fontSize=14;tagHeight=12;tagColor=$color(\"gray\",\"lightGray\");navHeight=34;taptic=1;inLauncher=$app.env===$env.today&&-1===$app.widgetIndex;launcherNavHeight=44;constructor(t){super(t),this.tabItems.push($l10n(\"ACTIONS\")),this.todayActions=new c(this.kernel),this.setClipboarPageSize($widget.mode),this.listPageNow=[0,0],this.listSection=Math.min(this.tabIndex,1),this.setSingleLine()}get isActionPage(){return 2===this.tabIndex}set tabIndex(t){$cache.set(\"caio.today.tab.index\",t)}get tabIndex(){return $cache.get(\"caio.today.tab.index\")??0}listReady(){$widget.modeChanged=t=>{this.setClipboarPageSize(t),this.isActionPage||this.updateList()},this.setClipboarPageSize($widget.mode),this.isActionPage||this.updateList(),this.appListen(),$delay(.5,(()=>this.readClipboard()))}async readClipboard(t=!1){this.isActionPage||$app.env!==$env.today||await super.readClipboard(t)}setClipboarPageSize(t){if(0===t)this.listPageSize=1;else{const t=(($app.env===$env.app?o.windowSize.height:$widget.height)-2*this.navHeight-(this.inLauncher?this.launcherNavHeight:0))/(this.singleLineContentHeight+this.verticalMargin+Math.max(this.tagHeight,this.verticalMargin)),e=Math.floor(t);this.listPageSize=e,t-e>=.6&&this.listPageSize++}}buttonTapped(t,e=!0){return async(...i)=>{e&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(this.taptic),await t(...i)}}switchTab(t){this.tabIndex=t,this.isActionPage?($(this.listContainerId).hidden=!0,$(this.actionsId).hidden=!1,$(this.readClipboardButtonId).hidden=!0):(this.listSection=t,$(this.actionsId).hidden=!0,$(this.listContainerId).hidden=!1,$(this.readClipboardButtonId).hidden=!1,this.updateList())}getNavBarView(){const t=[{symbol:\"square.and.arrow.down.on.square\",props:{id:this.readClipboardButtonId,hidden:this.isActionPage},tapped:this.buttonTapped((async t=>{t.start();try{await this.readClipboard(!0),t.done()}catch(e){throw t.cancel(),e}}))}].map((t=>{const e=new l;return e.setAlign(o.align.right).setSymbol(t.symbol).setEvent(\"tapped\",t.tapped).setProps(t.props??{}),e.definition}));return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[this.tabView(),...t]}],layout:(t,e)=>{t.top.width.equalTo(e.super),t.height.equalTo(this.navHeight)}}}getBottomBarView(){const t=t=>({type:\"button\",props:{symbol:t===o.align.left?\"chevron.backward.circle\":\"chevron.forward.circle\",bgcolor:$color(\"clear\"),tintColor:o.textColor},layout:i=>{t===o.align.left?i.left.inset(this.horizontalMargin):i.right.inset(this.horizontalMargin),i.centerY.equalTo(e.super)},events:{tapped:this.buttonTapped((()=>{t===o.align.left?this.clipboardPrevPage():this.clipboardNextPage()}))}}),e={type:\"view\",views:[t(o.align.left),t(o.align.right),{type:\"label\",props:{id:this.pageIndexId,align:$align.center,text:this.listPageNow[this.listSection]+1},layout:(t,e)=>{t.bottom.left.right.equalTo(e.super.safeArea),t.center.equalTo(e.super)}}],layout:(t,e)=>{t.bottom.left.right.equalTo(e.super.safeArea),t.height.equalTo(this.navHeight)}};return e}delete(...t){super.delete(...t),this.updateList()}updateList(t=!1){t&&this.setNeedReload();const e=this.listPageNow[this.listSection]*this.listPageSize,i=e+this.listPageSize,s=this.clips;$(this.listId).data=s.slice(e,i).map((t=>this.lineData(t,this.copied.uuid===t.uuid)));const r=this.listPageNow[this.listSection]+1,n=Math.ceil(s.length/this.listPageSize);$(this.pageIndexId).text=`${r}/${n}`}clipboardPrevPage(){this.listPageNow[this.listSection]>0&&(this.listPageNow[this.listSection]--,this.updateList())}clipboardNextPage(){const t=Math.ceil(this.clips.length/this.listPageSize);this.listPageNow[this.listSection]this.listReady(),rowHeight:(t,e)=>{const i=this.listPageSize*this.listPageNow[this.listSection],s=this.getByIndex(e.row+i),r=s.hasTag?this.tagHeight:this.verticalMargin,n=s.image?this.imageContentHeight:this.getContentHeight(s.text);return this.verticalMargin+n+r},didSelect:this.buttonTapped(((t,e)=>{const i=this.clips[e.row];i.image?$clipboard.image=i.imageOriginal:(this.setClipboardText(i.text),this.setCopied(i.uuid)),$ui.toast($l10n(\"COPIED\"))}))},layout:(t,e)=>{t.top.width.equalTo(e.super),t.bottom.equalTo(e.super).offset(-this.navHeight)}},this.getBottomBarView()],layout:(t,e)=>{t.top.equalTo(this.navHeight),t.bottom.left.right.equalTo(e.super.safeArea)}}}getActionView(){let t=this.todayActions.getActions();return 0===t.length&&(t=this.todayActions.getAllActions()),{type:\"view\",props:{id:this.actionsId,hidden:!this.isActionPage},views:[this.kernel.actionManager.getActionMiniView((t=>new s({env:r.today,text:\"clipboard\"===t.type||\"uncategorized\"===t.type?$clipboard.text:null})),t)],layout:(t,e)=>{t.top.equalTo(this.navHeight),t.left.right.bottom.equalTo(e.super.safeArea)}}}getView(){return a.create({props:{titleColor:o.textColor,barColor:o.primaryViewBackgroundColor},views:[{type:\"view\",views:[this.getNavBarView(),this.getActionView(),this.getListView()],layout:$layout.fill}],events:{appeared:async()=>{if($app.env!==$env.today)return;const t=$timer.schedule({interval:0,handler:()=>{$ui.animate({duration:.3,animation:()=>{$ui.vc.ocValue().$view().$setBackgroundColor($color(\"clear\"))},completion:()=>{t.invalidate()}})}})}}})}}})),parcelRequire.register(\"gD12U\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.Logger,r=i.Setting,n=i.FileStorage,a=parcelRequire(\"2EAPF\"),o=parcelRequire(\"jEwwi\").Storage;const l=new n;class h{static widgetInstance(t,...e){if($file.exists(`/scripts/widget/${t}.js`)){const{Widget:i}=require(`./widget/${t}.js`);return new i(...e)}return!1}static kernel(){const t=new s;t.printToFile(l,\"logs/widget.log\");const e={setting:new r({fileStorage:l,structure:a}),fileStorage:l,print:()=>{},error:e=>{t.error(e)}};e.setting.setReadonly();const i=new o(e);return e.storage=i,e}static renderError(){$widget.setTimeline({render:()=>({type:\"text\",props:{text:\"Invalid argument\"}})})}static renderClipboard(){(new r).setReadonly();h.widgetInstance(\"Clipboard\",h.kernel()).render()}static render(t=$widget.inputValue){\"Clipboard\"===(t=t??\"Clipboard\")?h.renderClipboard():h.renderError()}}t.exports={Widget:h,run:()=>{h.render()}}})),parcelRequire.register(\"ljE8b\",(function(t,e){var i=parcelRequire(\"34tpw\").AppKernelBase;class s extends i{constructor(){super(),this.setting.setReadonly()}addOpenInJsboxButton(){this.useJsboxNav(),this.setNavButtons([{image:$image(\"assets/icon.png\"),handler:()=>this.openInJsbox()}])}}class r{static kernel=$app.env!==$env.widget?new s:void 0;static renderKeyboardUI(){this.kernel.addOpenInJsboxButton();const t=new(parcelRequire(\"7eNYp\"))(this.kernel);this.kernel.KeyboardRender(t.getView())}static renderTodayUI(){this.kernel.addOpenInJsboxButton();const t=new(parcelRequire(\"49je6\"))(this.kernel);this.kernel.UIRender(t.getView())}}t.exports={run:()=>{$app.env===$env.today?r.renderTodayUI():$app.env===$env.keyboard&&r.renderKeyboardUI()}}})),$app.strings={en:{ALERT_INFO:\"Alert\",NONE:\"Nothing\",DONE:\"Done\",CLOSE:\"Close\",FAILED_TO_LOAD_VIEW:\"Faild to load view\",VIEW_NOT_PROVIDED:\"The view is not provided\",UNCATEGORIZED:\"Uncategorized\",SHARE:\"Share\",CLICK_TO_OPEN_JSBOX:\"Click the title to open the main app.\",CLIPS:\"Clips\",CLIPBOARD:\"Clipboard\",UNIVERSAL_CLIPBOARD:\"Universal Clipboard\",UNIVERSAL_CLIPBOARD_TIPS:\"Universal Clipboard allows you to copy something on your iPhone, and paste it on your Mac–or vice-versa–using iCloud.\",CLIPS_STRUCTURE_ERROR:\"Clips data structure is abnormal\",CLIPBOARD_NO_CHANGE:\"Clipboard no change\",RECYCLE_BIN:\"Recycle Bin\",ADD:\"Add\",TAG:\"Tag\",ADD_TAG:\"Add Tag\",EDIT:\"Edit\",SEARCH:\"Search\",SEARCH_HISTORY:\"Search History\",SEARCH_RESULT:\"Search Result\",NO_SEARCH_RESULT:\"No item found.\",FAVORITE:\"Favorite\",COPY:\"Copy\",COPIED:\"Copied\",SORT:\"Sort\",ACTIONS:\"Actions\",MORE_ACTIONS:\"More Actions\",PREVIEW:\"Preview\",MAX_ITEM_LENGTH:\"Line Limit\",TEXT_MAX_LENGTH:\"Display Character Length\",AUTO_SAVE:\"Auto Save\",AUTO_SYNC:\"Auto Sync\",SYNC_NOW:\"Sync Now\",UNZIP_FAILED:\"Unzip file failed\",REBUILD:\"Rebuild\",REBUILD_DATABASE:\"Rebuild Database\",REBUILD_DATABASE_ALERT:\"Rebuilding the database will lose the order information, do you want to confirm the rebuild?\",DELETE_ALL_DATA:\"Delete All Data\",DELETE_ALL_DATA_ALERT:\"Are you sure you want to delete all your data?\",DELETE_DATA:\"Delete Data\",DELETE_TABLE:\"Delete all data from `${table}`?\",SELECT_ALL:\"Select All\",DESELECT_ALL:\"Deselect All\",EDITOR:\"Editor\",CREATE_NEW:\"Create New\",CREATE_NEW_ACTION:\"New Action\",CREATE_NEW_TYPE:\"New Category\",TYPE_ALREADY_EXISTS:\"This category already exists\",EDIT_DETAILS:\"Edit Details\",EDIT_SCRIPT:\"Edit Script\",INFORMATION:\"Information\",NAME:\"Name\",ICON:\"Icon\",TYPE:\"Category\",DESCRIPTION:\"Description\",CODE:\"Code\",TEXT_INSETS:\"Text bottom margin\",SHOW_LINE_NUMBER:\"Show line number\",LIGHT_MODE_THEME:\"Light Mode Theme\",DARK_MODE_THEME:\"Dark Mode Theme\",SAVE:\"Save\",SAVE_SUCCESS:\"Save success\",SAVE_ERROR:\"Save failed\",DELETE:\"Delete\",CONFIRM:\"Confirm\",DELETE_CONFIRM_MSG:\"Are you sure you want to delete?\",DELETE_SUCCESS:\"Delete success\",DELETE_ERROR:\"Delete failed\",IMPORT_EXAMPLE_ACTIONS:\"Import example actions\",REBUILD_ACTION_DATABASE:\"Rebuild Action Database\",REBUILD_ACTION_DATABASE_ALERT_TITLE:\"Are you sure you want to rebuild?\",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:\"Rebuild also deletes the data saved in WebDAV Drive! (If enabled)\",EXPORT:\"Export\",IMPORT:\"Import\",FILE_TYPE_ERROR:\"File type does not match\",OVERWRITE_ALERT:\"This operation will overwrite the current data. Do you want to continue?\",UNABLE_CREATE_ACTION:\"Unable to create action\",ACTION_NAME_ALREADY_EXISTS:\"Action `${name}` already exists\",KEYBOARD:\"Keyboard\",KEYBOARD_HEIGHT:\"Keyboard Height\",USE_BLUR:\"Use Blur\",BACKGROUND_IMAGE:\"Background Image\",DELETE_DELAY:\"Delete Delay\",SWITCH_AFTER_INSERT:\"Switch After Insert\",JSBOX_TOOLBAR:\"JSBox Toolbar\",QUICK_START_SCRIPTS:\"Quick Start Scripts\",SEND:\"Send\",OPEN_IN_JSBOX:\"Open in JSBox\",SWITCH_KEYBOARD:\"Switch Keyboard\",TAPTIC_ENGINE:\"Taptic Engine\",TAPTIC_ENGINE_LEVEL:\"Taptic Engine Level\",TAPTIC_ENGINE_FOR_DELETE:\"Taptic Engine For Delete\",SPACE:\"Space\",ALL_SCRIPTS:\"All Scripts\",SELECT_SCRIPTS:\"Select Scripts\",CHECK_UPDATE:\"Check Update\",UPDATE:\"Update\",WIDGET:\"Widget\",RECENT:\"Recent\",CLICK_ACTION:\"Click Action\",TODAY_WIDGET:\"Today Widget\",PREV_PAGE:\"Prev\",NEXT_PAGE:\"Next\",DISPLAY_MODE:\"Display Mode\",CLASSIC:\"Classic\",MODERN:\"Modern\",FILE_MANAGEMENT:\"File Management\",\"compatibility.rebuildUserAction.alert.title\":\"We need to rebuild some of the action!\",\"compatibility.rebuildUserAction.alert.message\":\"If you tap the OK button, the following actions will be rebuilt:\",\"compatibility.rebuildUserAction.alert.message2\":\"Only the action logic will be changed, and the name and icon will remain as it is.\",EXPERIMENTAL:\"Experimental\",SYNC_ACTIONS:\"Sync Actions\",SYNCING:\"Syncing...\",LAST_SYNC_AT:\"Last sync at: \",MODIFIED:\"Modified: \",HOST:\"Host\",USER:\"User\",PASSWORD:\"Password\",BASEPATH:\"Base Path\",DATA_CONFLICT:\"A data synchronization conflict occurred\",DATA_CONFLICT_MESSAGE:\"Select the data you want to keep\",WEBDAV_DATA:\"WebDAV data\",LOCAL_DATA:\"Local data\",ACTION_SAFETY_WARNING:\"Action safety warning\",ACTION_PERMISSION_REQUEST:\"Action permission request\",ACTION_RESET_NAME_WARNING:\"Action `${name}` is attempting to change its name to `${to_name}`, which may result in it gaining all permissions associated with `${to_name}`.\",ACTION_NETWORK_PERMISSION_MESSAGE:\"Would you like to grant Action `${name}` network permissions?\"},\"zh-Hans\":{ALERT_INFO:\"提示\",NONE:\"什么都没有\",DONE:\"完成\",CLOSE:\"关闭\",FAILED_TO_LOAD_VIEW:\"加载视图失败\",VIEW_NOT_PROVIDED:\"未提供该视图\",UNCATEGORIZED:\"未分类\",SHARE:\"分享\",CLICK_TO_OPEN_JSBOX:\"点击标题打开主应用。\",CLIPS:\"剪切板\",CLIPBOARD:\"剪切板\",UNIVERSAL_CLIPBOARD:\"通用剪贴板\",UNIVERSAL_CLIPBOARD_TIPS:\"用剪贴板允许您在 iPhone 上复制某些内容,然后使用 iCloud 将其粘贴到 Mac 上(反之亦然)。\",CLIPS_STRUCTURE_ERROR:\"剪切板数据结构异常\",CLIPBOARD_NO_CHANGE:\"剪切板无变化\",RECYCLE_BIN:\"回收站\",ADD:\"添加\",TAG:\"标签\",ADD_TAG:\"添加标签\",EDIT:\"编辑\",SEARCH:\"搜索\",SEARCH_HISTORY:\"搜索历史\",SEARCH_RESULT:\"搜索结果\",NO_SEARCH_RESULT:\"搜索无结果\",FAVORITE:\"收藏\",COPY:\"复制\",COPIED:\"已复制\",SORT:\"排序\",ACTIONS:\"动作\",MORE_ACTIONS:\"更多动作\",PREVIEW:\"预览\",MAX_ITEM_LENGTH:\"行数限制\",TEXT_MAX_LENGTH:\"显示字符长度\",AUTO_SAVE:\"自动保存\",AUTO_SYNC:\"自动同步\",SYNC_NOW:\"立即同步\",UNZIP_FAILED:\"解压文件失败\",REBUILD:\"重建\",REBUILD_DATABASE:\"重建数据库\",REBUILD_DATABASE_ALERT:\"重建数据库将会丢失顺序信息,是否确认重建?\",DELETE_ALL_DATA:\"删除所有数据\",DELETE_ALL_DATA_ALERT:\"确定要删除所有数据吗?\",DELETE_DATA:\"删除数据\",DELETE_TABLE:\"删除 `${table}` 的所有数据?\",SELECT_ALL:\"全选\",DESELECT_ALL:\"取消全选\",EDITOR:\"编辑器\",CREATE_NEW:\"新建\",CREATE_NEW_ACTION:\"新建动作\",CREATE_NEW_TYPE:\"新建分类\",TYPE_ALREADY_EXISTS:\"该类别已经存在\",EDIT_DETAILS:\"编辑信息\",EDIT_SCRIPT:\"编辑脚本\",INFORMATION:\"信息\",NAME:\"名称\",ICON:\"图标\",TYPE:\"分类\",DESCRIPTION:\"描述\",CODE:\"代码\",TEXT_INSETS:\"文本下边距\",SHOW_LINE_NUMBER:\"显示行号\",LIGHT_MODE_THEME:\"浅色模式主题\",DARK_MODE_THEME:\"深色模式主题\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\",SAVE_ERROR:\"保存失败\",DELETE:\"删除\",CONFIRM:\"确认\",DELETE_CONFIRM_MSG:\"确认要删除吗?\",DELETE_SUCCESS:\"删除成功\",DELETE_ERROR:\"删除失败\",IMPORT_EXAMPLE_ACTIONS:\"导入示例动作\",REBUILD_ACTION_DATABASE:\"重建动作库\",REBUILD_ACTION_DATABASE_ALERT_TITLE:\"您确认要重建?\",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:\"重建会同时删除保存在 WebDAV 中的数据!(如果开启的话)\",EXPORT:\"导出\",IMPORT:\"导入\",FILE_TYPE_ERROR:\"文件类型不符\",OVERWRITE_ALERT:\"该操作将会覆盖当前数据,是否继续?\",UNABLE_CREATE_ACTION:\"无法创建动作\",ACTION_NAME_ALREADY_EXISTS:\"动作 `${name}` 已存在\",KEYBOARD:\"键盘\",KEYBOARD_HEIGHT:\"键盘高度\",USE_BLUR:\"使用模糊效果\",BACKGROUND_IMAGE:\"背景图片\",DELETE_DELAY:\"删除延时\",SWITCH_AFTER_INSERT:\"输入后切换\",JSBOX_TOOLBAR:\"JSBox 工具栏\",QUICK_START_SCRIPTS:\"快速启动脚本\",SEND:\"发送\",OPEN_IN_JSBOX:\"在 JSBox 中打开\",SWITCH_KEYBOARD:\"切换键盘\",TAPTIC_ENGINE:\"触感反馈\",TAPTIC_ENGINE_LEVEL:\"触感反馈强度\",TAPTIC_ENGINE_FOR_DELETE:\"删除按钮触感反馈\",SPACE:\"空格\",ALL_SCRIPTS:\"所有脚本\",SELECT_SCRIPTS:\"选择脚本\",CHECK_UPDATE:\"检查更新\",UPDATE:\"更新\",WIDGET:\"小组件\",RECENT:\"最近内容\",CLICK_ACTION:\"点击事件\",TODAY_WIDGET:\"通知中心小组件\",PREV_PAGE:\"上一页\",NEXT_PAGE:\"下一页\",DISPLAY_MODE:\"显示模式\",CLASSIC:\"经典\",MODERN:\"现代\",FILE_MANAGEMENT:\"文件管理\",\"compatibility.rebuildUserAction.alert.title\":\"我们需要重建部分动作!\",\"compatibility.rebuildUserAction.alert.message\":\"如果您点击 好,以下动作将会被重建:\",\"compatibility.rebuildUserAction.alert.message2\":\"只有动作逻辑会被更改,名称和图标将维持现状。\",EXPERIMENTAL:\"实验功能\",SYNC_ACTIONS:\"动作同步\",SYNCING:\"正在同步...\",LAST_SYNC_AT:\"最后同步:\",MODIFIED:\"最近修改:\",HOST:\"Host\",USER:\"User\",PASSWORD:\"Password\",BASEPATH:\"Base Path\",DATA_CONFLICT:\"数据同步发生冲突\",DATA_CONFLICT_MESSAGE:\"请选择想要保留的数据\",WEBDAV_DATA:\"WebDAV 数据\",LOCAL_DATA:\"本地数据\",ACTION_SAFETY_WARNING:\"动作安全警告\",ACTION_PERMISSION_REQUEST:\"动作权限申请\",ACTION_RESET_NAME_WARNING:\"动作 `${name}` 正在尝试将名称改为 `${to_name}`,这可能导致其获取 `${to_name}` 的所有权限\",ACTION_NETWORK_PERMISSION_MESSAGE:\"是否允许动作 `${name}` 获取网络权限?\"}},$app.theme=\"auto\",$app.minSDKVer=\"2.19.0\",$app.minOSVer=\"14.0.0\",$app.idleTimerDisabled=!1,$app.keyboardToolbarEnabled=!0,$app.rotateDisabled=!1,__INFO__={name:\"CAIO\",version:\"1.10.8\",author:\"ipuppet\",module:!1},__README__={\"README.md\":\"# CAIO\\r\\n\\r\\n> Clipboard all in one.\\r\\n> \\r\\n> A Clipboard tool based on JSBox.\\r\\n\\r\\nSupport for home widget and notification center widgets.\\r\\n\\r\\n## Build Taio Action\\r\\n\\r\\nBuild script depend on [Parcel](https://parceljs.org/).\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\nYou can also use the packaged files directly [dist/CAIO-en.json](./dist/CAIO-en.json).\\r\\n\\r\\n## Actions\\r\\n\\r\\n> For details on how to write, see `scripts/action/README.md` or the book button in the upper right corner of the `Action` edit page in the app.\\r\\n\\r\\n### `Action` data difference in different environments\\r\\n\\r\\n- The data processed by the `Action` button at the top of the home page is the currently copied content.\\r\\n- The data processed by the `Action` menu that pops up by long-pressing the list is the selected content.\\r\\n- The data processed by the `Action` button in the editor is whatever is being edited.\\r\\n\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> Click to copy, long press to trigger the action.\\r\\n\\r\\nPlease try to avoid using the Today Widget when JSBox is running CAIO.\\r\\n\\r\\n## WebDAV\\r\\n\\r\\n> Sync data with WebDAV.\\r\\n\\r\\nConfig Example: \\r\\nHost: https://example.com/dav \\r\\nUser: guest \\r\\nPassword: password123 \\r\\nBast Path: /path/to/save/appdata\\r\\n\",\"README_CN.md\":\"# CAIO\\r\\n\\r\\n> Clipboard all in one.\\r\\n> \\r\\n> A Clipboard tool based on JSBox.\\r\\n\\r\\n支持桌面小组件和通知中心小组件\\r\\n\\r\\n## 构建 Taio 动作\\r\\n\\r\\n构建脚本依赖 [Parcel](https://parceljs.org/)\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\n您也可以直接使用已打包好的文件 [dist/CAIO-zh-Hans.json](./dist/CAIO-zh-Hans.json)\\r\\n\\r\\n## Actions\\r\\n\\r\\n> 编写方式详见 `scripts/action/README.md` 或应用内 `Action` 编辑页面右上角图书按钮。\\r\\n\\r\\n### 不同环境中 `Action` 数据区别\\r\\n\\r\\n- 首页顶部 `Action` 按钮处理的数据为当前复制的内容\\r\\n- 长按列表弹出的 `Action` 菜单处理的数据为被选中的内容\\r\\n- 编辑器中顶部 `Action` 按钮(闪电图形按钮)处理的数据为正在编辑的所有内容\\r\\n\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> 点击复制,长按触发动作。\\r\\n\\r\\n请尽量避免在 JSBox 运行 CAIO 时使用 Today Widget\\r\\n\\r\\n## WebDAV\\r\\n\\r\\n> 通过 WebDAV 同步数据\\r\\n\\r\\n示例配置: \\r\\nHost: https://example.com/dav \\r\\nUser: guest \\r\\nPassword: password123 \\r\\nBast Path: /path/to/save/appdata\\r\\n\"},__ACTIONS__={clipboard:{B23Clean:{\"config.json\":'{\\n \"icon\": \"trash\",\\n \"color\": \"#FF0000\",\\n \"name\": \"b23 清除追踪\"\\n}',\"main.js\":'/**\\n * @typedef {import(\"../../action\").Action} Action\\n */\\nclass MyAction extends Action {\\n l10n() {\\n return {\\n \"zh-Hans\": {\\n \"b23clean.converting\": \"正在转换...\",\\n \"b23clean.noUrl\": \"未检测到链接\",\\n \"b23clean.noBiliUrl\": \"未检测到 bilibili 链接\",\\n \"b23clean.success\": \"已转换为 BV 视频链接\",\\n \"b23clean.noChange\": \"无变化\",\\n \"b23clean.multipleLinks\": \"多条链接仅在编辑模式下可用。\"\\n },\\n en: {\\n \"b23clean.converting\": \"Converting...\",\\n \"b23clean.noUrl\": \"No link detected\",\\n \"b23clean.noBiliUrl\": \"bilibili link not detected\",\\n \"b23clean.success\": \"Converted to BV video link\",\\n \"b23clean.noChange\": \"No change\",\\n \"b23clean.multipleLinks\": \"Multiple links are only available in edit mode.\"\\n }\\n }\\n }\\n\\n async cleanUrl(b23url) {\\n if (b23url.indexOf(\"bilibili.com\") === -1 && b23url.indexOf(\"b23.tv\") === -1) {\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\n }\\n\\n let url = b23url\\n if (b23url.indexOf(\"b23.tv\") >= 0) {\\n const resp = await $http.get(b23url)\\n url = resp.response.url\\n }\\n\\n const queryStart = url.indexOf(\"?\")\\n if (queryStart > -1) {\\n url = url.substring(0, queryStart - 1)\\n }\\n\\n return url\\n }\\n\\n /**\\n * 系统会调用 do() 方法\\n */\\n async do() {\\n $ui.toast($l10n(\"b23clean.converting\"), 1000)\\n\\n try {\\n const b23url = this.getUrls()\\n if (b23url.length === 0) {\\n throw new Error($l10n(\"b23clean.noUrl\"))\\n }\\n\\n if (b23url.length === 1) {\\n let url = await this.cleanUrl(b23url[0])\\n $ui.clearToast()\\n $ui.alert({\\n title: $l10n(\"b23clean.success\"),\\n message: url,\\n actions: [\\n { title: $l10n(\"OK\") },\\n {\\n title: $l10n(\"COPY\"),\\n handler: () => {\\n $clipboard.text = url\\n $ui.success($l10n(\"COPIED\"))\\n }\\n }\\n ]\\n })\\n } else {\\n if (this.env !== ActionEnv.editor) {\\n $ui.toast($l10n(\"b23clean.multipleLinks\"))\\n return\\n }\\n let flag = false\\n for (let i = 0; i < b23url.length; i++) {\\n try {\\n const url = b23url[i].trim()\\n const replacedUrl = await this.cleanUrl(url)\\n flag = true\\n\\n if (url !== replacedUrl) {\\n const newText = this.text.replace(url, replacedUrl)\\n this.setContent(newText)\\n }\\n } catch {}\\n }\\n if (!flag) {\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\n } else {\\n $ui.toast($l10n(\"b23clean.noChange\"))\\n }\\n }\\n } catch (error) {\\n $ui.clearToast()\\n $delay(0.5, () => $ui.error(error))\\n }\\n }\\n}\\n',\"README.md\":\"## B23Clean\\r\\n\\r\\n清除 b23.tv 分享链接中的追踪参数,转换为 BV 视频链接。\"},CleanClipboard:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"清除剪切板\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"clipboard.clean.success\": \"剪切板已清空\"\\r\\n },\\r\\n en: {\\r\\n \"clipboard.clean.success\": \"Clipboard is cleaned\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n do() {\\r\\n $clipboard.clear()\\r\\n $ui.success($l10n(\"clipboard.clean.success\"))\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## CleanClipboard\\r\\n\\r\\n清空当前剪切板内容。\"},DownloadFromUrl:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.down\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"从链接下载\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n async downloadContent(url) {\\r\\n const response = await $http.get({\\r\\n url,\\r\\n showsProgress: true\\r\\n })\\r\\n if (response.error) {\\r\\n $ui.alert(response.error.localizedDescription)\\r\\n } else {\\r\\n return response\\r\\n }\\r\\n }\\r\\n\\r\\n async do() {\\r\\n const url = this.getUrls()\\r\\n let response = undefined\\r\\n if (url.length > 1) {\\r\\n $ui.menu({\\r\\n items: url,\\r\\n handler: async (title, index) => {\\r\\n response = await this.downloadContent(url[index])\\r\\n }\\r\\n })\\r\\n } else if (url.length === 1) {\\r\\n response = await this.downloadContent(url[0])\\r\\n } else {\\r\\n $ui.warning(\"未检测到链接\")\\r\\n return\\r\\n }\\r\\n $share.sheet([\\r\\n {\\r\\n name: response.response.suggestedFilename,\\r\\n data: response.data\\r\\n }\\r\\n ])\\r\\n return response\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DownloadFromUrl\\r\\n\\r\\n从链接下载内容,如 js 文件内容等。\"},GetFromWin:{\"config.json\":'{\\n \"icon\": \"square.and.arrow.down\",\\n \"color\": \"#33CC33\",\\n \"name\": \"读取 clipsync\"\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"GET\")\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n $clipboard.text = resp.data.data\\r\\n if ($app.env === $env.keyboard) {\\r\\n $keyboard.insert(resp.data.data)\\r\\n }\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## GetFromWin\\r\\n\\r\\n通 clipsync 读取 PC 剪切板。\\r\\n\\r\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\r\\n\"},OpenUrl:{\"config.json\":'{\\r\\n \"icon\": \"link\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"打开链接\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"openLink.nourl\": \"未检测到链接\"\\r\\n },\\r\\n en: {\\r\\n \"openLink.nourl\": \"No link detected\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n openUrl(url) {\\r\\n $app.openURL(url.trim())\\r\\n }\\r\\n\\r\\n do() {\\r\\n const url = this.getUrls()\\r\\n if (url.length > 1) {\\r\\n $ui.menu({\\r\\n items: url,\\r\\n handler: (title, index) => {\\r\\n this.openUrl(url[index])\\r\\n }\\r\\n })\\r\\n } else if (url.length === 1) {\\r\\n this.openUrl(url[0])\\r\\n } else {\\r\\n $ui.warning($l10n(\"openLink.nourl\"))\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## OpenUrl\\r\\n\\r\\n提取文本中的URL并打开。\"},RawRepoConverter:{\"config.json\":'{\\r\\n \"icon\": \"link\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"RawRepoConverter\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n #component\\r\\n\\r\\n get component() {\\r\\n if (!this.#component) {\\r\\n const url = String(this.text)\\r\\n const path = url.substring(url.indexOf(\"/\", \"https://\".length) + 1)\\r\\n this.#component = path.split(\"/\")\\r\\n }\\r\\n return this.#component\\r\\n }\\r\\n\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"openLink.nourl\": \"未检测到链接\"\\r\\n },\\r\\n en: {\\r\\n \"openLink.nourl\": \"No link detected\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n githubusercontent() {\\r\\n const user = this.component[0],\\r\\n repository = this.component[1],\\r\\n branch = this.component[2],\\r\\n file = this.component.slice(3).join(\"/\")\\r\\n return `https://github.com/${user}/${repository}/blob/${branch}/${file}`\\r\\n }\\r\\n\\r\\n github() {\\r\\n const user = this.component[0],\\r\\n repository = this.component[1],\\r\\n blob = this.component[2],\\r\\n branch = this.component[3],\\r\\n file = this.component.slice(4).join(\"/\")\\r\\n return `https://raw.githubusercontent.com/${user}/${repository}/${branch}/${file}`\\r\\n }\\r\\n\\r\\n do() {\\r\\n let result\\r\\n const url = String(this.text)\\r\\n if (url.includes(\"raw.githubusercontent.com\")) {\\r\\n result = this.githubusercontent(url)\\r\\n } else if (url.includes(\"github.com\")) {\\r\\n if (url.includes(\"?raw=true\")) {\\r\\n result = url.replace(\"?raw=true\", \"\")\\r\\n } else {\\r\\n result = this.github()\\r\\n }\\r\\n } else {\\r\\n $ui.warning($l10n(\"openLink.nourl\"))\\r\\n return\\r\\n }\\r\\n\\r\\n $ui.success($l10n(\"COPIED\"))\\r\\n $clipboard.text = result\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## RawRepoConverter\\r\\n\\r\\nGithub Raw 链接和 Repository 链接转换器\\r\\n\"},SendToWin:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#33CC33\",\\r\\n \"name\": \"推送 clipsync\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"POST\", {\\r\\n data: this.text\\r\\n })\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## SendToWin\\r\\n\\r\\n通 clipsync 推送剪切板至 PC。\\r\\n\\r\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\r\\n\"},Tokenize:{\"config.json\":'{\\r\\n \"icon\": \"pencil.and.ellipsis.rectangle\",\\r\\n \"color\": \"#0099FF\",\\r\\n \"name\": \"分词复制\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n getView() {\\r\\n const color = {\\r\\n background: {\\r\\n normal: $color(\"#E7F2FF\", \"#E7F2FF\"),\\r\\n highlight: $color(\"##074FF\", \"#BBDAFF\")\\r\\n },\\r\\n text: {\\r\\n normal: $color(\"##074FF\", \"##074FF\"),\\r\\n highlight: $color(\"#FFFFFF\", \"#ADADAD\")\\r\\n }\\r\\n }\\r\\n const fontSize = 16\\r\\n const edges = 10\\r\\n return {\\r\\n type: \"matrix\",\\r\\n layout: $layout.fill,\\r\\n props: {\\r\\n spacing: edges,\\r\\n data: this.results.map(item => ({ label: { text: item } })),\\r\\n template: {\\r\\n views: [{\\r\\n type: \"label\",\\r\\n props: {\\r\\n id: \"label\",\\r\\n align: $align.center,\\r\\n cornerRadius: edges,\\r\\n bgcolor: color.background.normal,\\r\\n font: $font(fontSize),\\r\\n textColor: color.text.normal\\r\\n },\\r\\n layout: $layout.fill\\r\\n }]\\r\\n }\\r\\n },\\r\\n events: {\\r\\n highlighted: () => { },\\r\\n itemSize: (sender, indexPath) => {\\r\\n const width = fontSize * this.results[indexPath.item].length + 1\\r\\n if (this.maxtrixItemHeight === undefined)\\r\\n this.maxtrixItemHeight = fontSize + edges * 2\\r\\n return $size(width + edges * 2, this.maxtrixItemHeight)\\r\\n },\\r\\n didSelect: (sender, indexPath) => {\\r\\n const index = this.selected.indexOf(indexPath.item)\\r\\n const label = sender.cell(indexPath).get(\"label\")\\r\\n if (index === -1) {\\r\\n this.selected.push(indexPath.item)\\r\\n label.bgcolor = color.background.highlight\\r\\n label.textColor = color.text.highlight\\r\\n } else {\\r\\n this.selected.splice(index, 1)\\r\\n label.bgcolor = color.background.normal\\r\\n label.textColor = color.text.normal\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n do() {\\r\\n this.selected = []\\r\\n this.results = []\\r\\n $text.tokenize({\\r\\n text: this.text,\\r\\n handler: results => {\\r\\n this.results = results\\r\\n this.pageSheet({\\r\\n view: this.getView(),\\r\\n done: () => {\\r\\n const result = []\\r\\n this.selected.sort().forEach(i => {\\r\\n result.push(this.results[i])\\r\\n })\\r\\n if (result.length > 0) {\\r\\n const text = result.join(\"\")\\r\\n $clipboard.text = text\\r\\n $ui.alert({\\r\\n title: \"完成\",\\r\\n message: `已复制内容:${text}`\\r\\n })\\r\\n }\\r\\n }\\r\\n })\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## Tokenize\\r\\n\\r\\n将文本分词处理后复制。\"}},editor:{PreviewMarkdown:{\"config.json\":'{\\r\\n \"icon\": \"book\",\\r\\n \"color\": \"#9900CC\",\\r\\n \"name\": \"预览Markdown\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n do() {\\r\\n this.pageSheet({\\r\\n view: {\\r\\n type: \"markdown\",\\r\\n props: { content: this.text },\\r\\n layout: $layout.fill\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## PreviewMarkdown\\r\\n\\r\\n预览Markdown。\"},SelectedText:{\"config.json\":'{\\r\\n \"icon\": \"crop\",\\r\\n \"color\": \"#6699CC\",\\r\\n \"name\": \"选中的文本\"\\r\\n}',\"main.js\":\"class MyAction extends Action {\\r\\n do() {\\r\\n if (this.selectedRange.length > 0) {\\r\\n const selectedText = this.text\\r\\n $ui.alert(selectedText)\\r\\n }\\r\\n }\\r\\n}\\r\\n\",\"README.md\":\"## SelectedText\\r\\n\\r\\n显示选中的文本。\"}},uncategorized:{ActionEditPreview:{\"config.json\":'{\\r\\n \"icon\": \"play\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"编辑动作即时预览示例\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n * @typedef {import(\"../../action\").ActionData} ActionData\\r\\n * @typedef {import(\"../../action\").ActionEnv} ActionEnv\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n preview() {\\r\\n return new ActionData({\\r\\n text: \"hello word\"\\r\\n })\\r\\n }\\r\\n\\r\\n async do() {\\r\\n try {\\r\\n if (this.env !== ActionEnv.build) {\\r\\n $ui.toast(\"action editor only\")\\r\\n return\\r\\n }\\r\\n return this.text\\r\\n } catch (error) {\\r\\n $ui.alert(error)\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## ActionEditPreview\\r\\n\\r\\n编辑动作即时预览示例。\"},DeleteClips:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"删除所有剪切板\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n async do() {\\r\\n try {\\r\\n const action = await this.clearAllClips()\\r\\n if (action) {\\r\\n $ui.success($l10n(\"DONE\"))\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.error(error)\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DeleteClips\\r\\n\\r\\n删除所有已保存的剪切板(不包括收藏)。\"},DisplayClipboard:{\"config.json\":'{\\r\\n \"icon\": \"option\",\\r\\n \"color\": \"#FF6633\",\\r\\n \"name\": \"显示剪切板\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n const image = $clipboard.image\\r\\n if (image) {\\r\\n this.quickLookImage(image)\\r\\n } else {\\r\\n this.pageSheet({\\r\\n view: {\\r\\n type: \"label\",\\r\\n props: {\\r\\n lines: 0,\\r\\n text: $clipboard.text,\\r\\n align: $align.center\\r\\n },\\r\\n layout: $layout.fill\\r\\n }\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DisplayClipboard\\r\\n\\r\\n显示当前剪切板内的内容。\"},ExportAllContent:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#FF3300\",\\r\\n \"name\": \"导出数据\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n do() {\\r\\n const data = this.getAllClips()\\r\\n if (data.clips.length > 0 || data.favorite.length > 0) {\\r\\n $share.sheet(JSON.stringify(data, null, 2))\\r\\n } else {\\r\\n $ui.alert(\"无数据\")\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## ExportAllContent\\r\\n\\r\\n导出所有保存的数据。\"},Replace:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#FF3300\",\\r\\n \"name\": \"查找替换\"\\r\\n}',\"main.js\":'function HtmlTemplate(html) {\\r\\n return `\\r\\n\\r\\n\\r\\n \\r\\n\\r\\n\\r\\n${html}\\r\\n\\r\\n\\r\\n`\\r\\n}\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n $ui.menu({\\r\\n items: [\"忽略大小写\", \"大小写敏感\", \"正则表达式\"],\\r\\n handler: async (title, idx) => {\\r\\n const patternText = await $input.text({\\r\\n placeholder: \"查找内容\"\\r\\n })\\r\\n const replaceString = await $input.text({\\r\\n placeholder: \"替换内容\"\\r\\n })\\r\\n let pattern = undefined\\r\\n if (idx === 0) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"gi\")\\r\\n } else if (idx === 1) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"g\")\\r\\n } else if (idx === 2) {\\r\\n pattern = new RegExp(patternText, \"g\")\\r\\n }\\r\\n\\r\\n const matchResultPreview = this.text.replaceAll(pattern, `${replaceString}`)\\r\\n const matchResult = this.text.replaceAll(pattern, replaceString)\\r\\n this.pageSheet({\\r\\n title: \"替换预览\",\\r\\n doneText: \"替换\",\\r\\n view: {\\r\\n type: \"web\",\\r\\n props: {\\r\\n html: HtmlTemplate(matchResultPreview)\\r\\n },\\r\\n layout: $layout.fill\\r\\n },\\r\\n done: () => {\\r\\n this.setContent(matchResult)\\r\\n }\\r\\n })\\r\\n }\\r\\n })\\r\\n // this.setContent(\"Hello world!\")\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## Replace\\r\\n\\r\\n查找替换\"}}},$app.env){case $env.app:case $env.action:$9ca6ee6eeae53f7f$var$AppInstance=parcelRequire(\"8Makm\");break;case $env.today:case $env.keyboard:$9ca6ee6eeae53f7f$var$AppInstance=parcelRequire(\"ljE8b\");break;case $env.widget:$9ca6ee6eeae53f7f$var$AppInstance=parcelRequire(\"gD12U\");break;default:$intents.finish(\"不支持在此环境中运行\"),$ui.render({views:[{type:\"label\",props:{text:\"不支持在此环境中运行\",align:$align.center},layout:$layout.fill}]})}$9ca6ee6eeae53f7f$var$AppInstance&&$9ca6ee6eeae53f7f$var$AppInstance.run()})();" + } + } + } + ], + "buildVersion": 1, + "clientMinVersion": 1, + "clientVersion": 592, + "icon": { + "glyph": "heart.text.square", + "color": "#FF6633" + }, + "summary": "A Clipboard tool based on JSBox.", + "name": "CAIO" +} \ No newline at end of file diff --git a/dist/CAIO-zh-Hans.json b/dist/CAIO-zh-Hans.json new file mode 100644 index 00000000..c12a9d75 --- /dev/null +++ b/dist/CAIO-zh-Hans.json @@ -0,0 +1,29 @@ +{ + "actions": [ + { + "type": "@comment", + "parameters": { + "text": { + "value": "GitHub: https://github.com/ipuppet/CAIO" + } + } + }, + { + "type": "@flow.javascript", + "parameters": { + "script": { + "value": "(()=>{var $parcel$global=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;let $9ca6ee6eeae53f7f$var$AppInstance;switch(null==parcelRequire&&(parcelRequire=function(t){if(t in $parcel$modules)return $parcel$modules[t].exports;if(t in $parcel$inits){var e=$parcel$inits[t];delete $parcel$inits[t];var i={id:t,exports:{}};return $parcel$modules[t]=i,e.call(i.exports,i,i.exports),i.exports}var s=new Error(\"Cannot find module '\"+t+\"'\");throw s.code=\"MODULE_NOT_FOUND\",s},parcelRequire.register=function(t,e){$parcel$inits[t]=e},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register(\"8Makm\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.UIKit,r=i.ViewController,n=i.TabBarController,a=parcelRequire(\"34tpw\").AppKernelBase,o=parcelRequire(\"gYDdO\"),l=parcelRequire(\"9RsVy\");class h extends a{constructor(){super(),this.query=$context.query,l(this)}}class c{static kernel=$app.env!==$env.widget?new h:void 0;static renderMainUI(){const t={clips:{icon:\"doc.on.clipboard\",title:$l10n(\"CLIPS\")},actions:{icon:\"command\",title:$l10n(\"ACTIONS\")},setting:{icon:\"gear\",title:$l10n(\"SETTING\")}};if(this.kernel.setting.setEvent(\"onSet\",(t=>{\"mainUIDisplayMode\"===t&&$delay(.3,(()=>$addin.restart()))})),0===this.kernel.setting.get(\"mainUIDisplayMode\"))this.kernel.useJsboxNav(),this.kernel.setting.useJsboxNav(),this.kernel.setNavButtons([{symbol:t.setting.icon,title:t.setting.title,handler:()=>{s.push({title:t.setting.title,views:[this.kernel.setting.getListView()]})}},{symbol:t.actions.icon,title:t.actions.title,handler:()=>{this.kernel.actionManager.present()}}]),this.kernel.UIRender(this.kernel.clips.getNavigationView().getPage());else{this.kernel.fileManager.setViewController(new r),this.kernel.tabBarController=new n;const e=this.kernel.clips.getNavigationView();this.kernel.tabBarController.setPages({clips:e.getPage(),actions:this.kernel.actionManager.getPage(),setting:this.kernel.setting.getPage()}).setCells({clips:t.clips,actions:t.actions,setting:t.setting}),this.kernel.UIRender(this.kernel.tabBarController.generateView().definition)}}}t.exports={run:()=>{o(c.kernel),c.renderMainUI()}}})),parcelRequire.register(\"gxpqj\",(function(module,exports){var VERSION=\"1.4.3\",AlertAction=class{title;handler;constructor({title:t=$l10n(\"OK\"),disabled:e=!1,style:i=$alertActionType.default,handler:s=(()=>{})}={}){this.title=t,this.disabled=e,this.style=i,this.handler=s}},Alert=class t{id=$text.uuid;title;message;actions;titleFont=$font(\"bold\",20);messageFont=$font(14);actionButtonFontSize=16;actionButtonHighlight=$color($rgba(0,0,0,.2),$rgba(255,255,255,.2));actionButtonHeight=35;actionButtonBoderWidth=.5;actionButtonBorderColor=$color(\"#C9C9C9\",\"#383838\");boxWidth=250;textVerticalMargin=20;textHorizontalMargin=50;constructor({title:t=\"\",message:e=\"\",actions:i=[]}={}){this.title=t,this.message=e,this.actions=i,0===this.actions.length&&this.actions.push(new AlertAction),this.titleSize=UIKit.getContentSize(this.titleFont,this.title,this.boxWidth-2*this.textHorizontalMargin),this.messageSize=UIKit.getContentSize(this.messageFont,this.message,this.boxWidth-2*this.textHorizontalMargin)}textView(){return{type:\"view\",views:[{type:\"label\",props:{lines:0,font:this.titleFont,text:this.title,color:$color(\"tint\"),align:$align.center},layout:(t,e)=>{t.centerX.equalTo(e.super),t.width.equalTo(this.boxWidth-2*this.textHorizontalMargin),t.height.equalTo(this.titleSize.height),t.top.equalTo(this.textVerticalMargin)}},{type:\"label\",props:{lines:0,font:this.messageFont,text:this.message,align:$align.center},layout:(t,e)=>{t.centerX.equalTo(e.super),t.width.equalTo(this.boxWidth-2*this.textHorizontalMargin),t.height.equalTo(this.messageSize.height),t.top.equalTo(e.prev.bottom)}}],layout:(t,e)=>{t.top.width.equalTo(e.super),t.height.equalTo(this.titleSize.height+this.messageSize.height+2*this.textVerticalMargin)}}}actionView(){let t=(t,e)=>{let i=t=>2===this.actions.length?t.y>=0&&t.x>=0&&t.y<=this.actionButtonHeight&&t.x<=this.boxWidth/2:t.y>=0&&t.x>=0&&t.y<=this.actionButtonHeight&&t.x<=this.boxWidth,s=async(s,r,n)=>{t.disabled||(s.bgcolor=$color(\"clear\"),i(r)&&(\"function\"==typeof t.handler&&await t.handler({index:e,title:t.title}),this.dismiss()))},r=$color(\"tint\"),n=$font(this.actionButtonFontSize);return t.disabled?r=$color(\"gray\"):t.style===$alertActionType.destructive?r=$color(\"red\"):t.style===$alertActionType.cancel&&(n=$font(\"bold\",this.actionButtonFontSize)),{type:\"label\",props:{lines:1,text:t.title,align:$align.center,font:n,color:r,borderWidth:this.actionButtonBoderWidth,borderColor:this.actionButtonBorderColor,bgcolor:$color(\"clear\")},events:{tapped:()=>{},touchesBegan:e=>{t.disabled||(e.bgcolor=this.actionButtonHighlight)},touchesEnded:s,touchesCancelled:s,touchesMoved:(e,s,r)=>{t.disabled||(i(s)?e.bgcolor=this.actionButtonHighlight:e.bgcolor=$color(\"clear\"))}},layout:(t,e)=>{2===this.actions.length?e.prev?(t.left.equalTo(e.prev.right).offset(-this.actionButtonBoderWidth),t.width.equalTo(e.super).dividedBy(2).offset(this.actionButtonBoderWidth)):t.width.equalTo(e.super).dividedBy(2):(t.width.equalTo(e.super),e.prev&&t.top.equalTo(e.prev.bottom).offset(-this.actionButtonBoderWidth)),t.height.equalTo(this.actionButtonHeight)}}};return{type:\"view\",views:this.actions.map(((e,i)=>t(e,i))),layout:(t,e)=>{t.left.equalTo(e.super).offset(-this.actionButtonBoderWidth),t.width.equalTo(e.super).offset(2*this.actionButtonBoderWidth),t.bottom.equalTo(e.super),t.top.equalTo(e.prev.bottom)}}}getView(){let t={type:\"view\",props:{id:this.id+\"-box\",smoothCorners:!0,cornerRadius:20,bgcolor:$color(\"#FFFFFF\",\"#000000\")},views:[this.textView(),this.actionView()],layout:(t,e)=>{t.center.equalTo(e.super.safeArea);let i=this.titleSize.height+this.messageSize.height+2*this.textVerticalMargin,s=this.actions.length>2?this.actions.length:1;i+=this.actionButtonHeight*s,i-=this.actionButtonBoderWidth*s;let r=this.boxWidth-2*this.actionButtonBoderWidth;t.size.equalTo($size(r,i))}};return{type:\"view\",props:{id:this.id,alpha:0,bgcolor:$rgba(0,0,0,.6)},views:[t],layout:$layout.fill}}present(){let t=$ui.create(this.getView());$ui.controller.view.hidden?$ui.controller.view.super.insertAtIndex(t,0):$ui.controller.view.insertAtIndex(t,0);let e=$(this.id);e.layout($layout.fill),e.moveToFront(),$ui.animate({duration:.3,animation:()=>{e.alpha=1}})}dismiss(){let t=$(this.id);$ui.animate({duration:.3,animation:()=>{t.alpha=0},completion:()=>{t.remove()}})}static fromJsbox(e){return new Promise(((i,s)=>{new t({title:e.title,message:e.message,actions:e?.actions?.map((t=>(t.handler||(t.handler=t=>{i(t)}),new AlertAction(t))))}).present()}))}},Controller=class{events={};setEvents(t){return Object.keys(t).forEach((e=>this.setEvent(e,t[e]))),this}setEvent(t,e){return this.events[t]=e,this}appendEvent(t,e){let i=this.events[t];return\"function\"==typeof i?this.events[t]=(...t)=>{i(...t),e(...t)}:this.setEvent(t,e),this}callEvent(t,...e){\"function\"==typeof this.events[t]&&this.events[t](...e)}},FileManager=class{viewController;constructor(){this.listId=\"file-manager-list\",this.edges=10,this.iconSize=25}setViewController(t){this.viewController=t}get menu(){return{items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:async(t,e)=>{let i=t.object(e).info.info;$share.sheet([$file.absolutePath(i.path)])}}]}}delete(t){$file.delete(t.path)}edit(t){let e=$file.read(t.path);if(e.info?.mimeType?.startsWith(\"image\"))Sheet.quickLookImage(e,t.path.substring(t.path.lastIndexOf(\"/\")+1));else{let i=new Sheet,s=$text.uuid;i.setView({type:\"code\",layout:$layout.fill,props:{id:s,lineNumbers:!0,theme:$device.isDarkMode?\"atom-one-dark\":\"atom-one-light\",text:e.string,insets:$insets(15,15,15,15)}}).addNavBar({title:t.file,popButton:{title:$l10n(\"CLOSE\")},rightButtons:[{title:$l10n(\"SAVE\"),tapped:()=>{$file.write({data:$data({string:$(s).text}),path:t.path}),$ui.success($l10n(\"SAVE_SUCCESS\"))}}]}),i.init().present()}}getFiles(t=\"\"){return $file.list(t).map((e=>{let i=t+\"/\"+e,s=$file.isDirectory(i);return{info:{info:{path:i,file:e,isDirectory:s}},icon:{symbol:s?\"folder.fill\":\"doc\"},name:{text:e},size:{text:s?\"\":\"--\"}}})).sort(((t,e)=>t.info.info.isDirectory!==e.info.info.isDirectory?t.info.info.isDirectory?-1:1:t.info.info.isDirectory===e.info.info.isDirectory?t.info.info.file.localeCompare(e.info.info.file):void 0))}async loadFileSize(t){return t.map(((e,i)=>{let s=e.info.info;if(!s.isDirectory)try{t[i].size.text=UIKit.bytesToSize($file.read(s.path).info.size)}catch(e){t[i].size.text=e}})),t}get listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{props:{id:\"info\"}},{type:\"image\",props:{id:\"icon\"},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(this.edges),t.size.equalTo(this.iconSize)}},{type:\"view\",views:[{type:\"label\",props:{id:\"size\",color:$color(\"secondaryText\"),lines:1},layout:(t,e)=>{t.height.equalTo(e.super),t.right.inset(this.edges)}},{type:\"label\",props:{id:\"name\",lines:1},layout:(t,e)=>{t.height.left.equalTo(e.super),t.right.equalTo(e.prev.left).offset(-this.edges)}}],layout:(t,e)=>{t.height.right.equalTo(e.super),t.left.equalTo(e.prev.right).offset(this.edges)}}]}}#t(t,e){if(this.viewController){let i=new NavigationView;i.setView(e).navigationBarTitle(t),i.navigationBar.setLargeTitleDisplayMode(NavigationBar.largeTitleDisplayModeNever),this.viewController.push(i)}else UIKit.push({title:t,views:[e]})}getListView(t=\"\"){return{type:\"list\",props:{id:this.listId,menu:this.menu,info:{basePath:t},bgcolor:UIKit.primaryViewBackgroundColor,separatorInset:$insets(0,this.edges,0,0),data:[],template:this.listTemplate,actions:[{title:\" \"+$l10n(\"DELETE\")+\" \",color:$color(\"red\"),handler:(t,e)=>{let i=t.object(e).info.info;UIKit.deleteConfirm($l10n(\"FILE_MANAGER_DELETE_CONFIRM_MSG\")+' \"'+i.file+'\" ?',(()=>{this.delete(i),t.delete(e)}))}}]},layout:$layout.fill,events:{ready:()=>{let e=this.getFiles(t);$(this.listId).data=e,this.loadFileSize(e).then((t=>{$(this.listId).data=t}))},pulled:async t=>{let e=this.getFiles($(this.listId).info.basePath);$(this.listId).data=e,$(this.listId).data=await this.loadFileSize(e),$delay(.5,(()=>{t.endRefreshing()}))},didSelect:(t,e,i)=>{let s=i.info.info;s.isDirectory?this.#t(s.file,this.getListView(s.path)):this.edit(s)}}}}push(t=\"\"){let e=t.substring(t.lastIndexOf(\"/\"));this.#t(e,this.getListView(t))}},FileStorage=class t{basePath;constructor({basePath:t=\"storage\"}={}){this.basePath=t,this.#t(this.basePath)}static join(...t){let e=t.length,i=t[0];if(e<2)return i;for(let s=0;st&&(s=e.substring(t+1),e=e.substring(0,t+1))}return i&&this.#t(e),e+s}exists(t=\"\"){return t=this.filePath(t,!1),!!$file.exists(t)}write(t=\"\",e){return new Promise(((i,s)=>{try{let r=this.writeSync(t,e);r?i(r):s(r)}catch(t){s(t)}}))}writeSync(t=\"\",e){if(!e)throw new FileStorageParameterError(\"data\");return $file.write({data:e,path:this.filePath(t)})}read(t=\"\"){return new Promise(((e,i)=>{try{let s=this.readSync(t);s?e(s):i()}catch(t){i(t)}}))}readSync(t=\"\"){if(t=this.filePath(t),!$file.exists(t))throw new FileStorageFileNotFoundError(t);return $file.isDirectory(t)?$file.list(t):$file.read(t)}readAsJSON(t=\"\",e=null){try{let e=this.readSync(t)?.string;return JSON.parse(e)}catch{return e}}static readFromRoot(e=\"\"){return new Promise(((i,s)=>{try{let r=t.readFromRootSync(e);r?i(r):s()}catch(t){s(t)}}))}static readFromRootSync(t=\"\"){if(!t)throw new FileStorageParameterError(\"path\");if(!$file.exists(t))throw new FileStorageFileNotFoundError(t);return $file.isDirectory(t)?$file.list(t):$file.read(t)}static readFromRootAsJSON(e=\"\",i=null){try{let i=t.readFromRootSync(e)?.string;return JSON.parse(i)}catch{return i}}delete(t=\"\"){return $file.delete(this.filePath(t,!1))}copy(t,e){t=this.filePath(t),e=this.filePath(e),$file.copy({src:t,dst:e})}move(t,e){t=this.filePath(t),e=this.filePath(e),$file.move({src:t,dst:e})}},Kernel=class t{startTime=Date.now();isUseJsboxNav=!1;title=$addin?.current?.name;constructor(){$app.isDebugging&&this.debug(),L10n.init()}static isTaio=$app.info.bundleID.includes(\"taio\");static objectEqual(e,i){let s=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(i);if(s.length!==r.length)return!1;for(let r=0;rt?i[t]:0,r=isNaN(Number(e))?e.charCodeAt():Number(e),a=s.length>t?s[t]:0,o=isNaN(Number(a))?a.charCodeAt():Number(a);if(ro){n=1;break}}return n}debug(t,e){this.debugMode=!0,$app.idleTimerDisabled=!0,\"function\"==typeof t&&(this.debugPrint=t),\"function\"==typeof e&&(this.debugError=e),this.print(\"You are running EasyJsBox in debug mode.\")}print(t){this.debugMode&&(\"function\"==typeof this.debugPrint?this.debugPrint(t):console.log(t))}error(t){this.debugMode&&(\"function\"==typeof this.debugError?this.debugError(t):console.error(t))}useJsboxNav(){return this.isUseJsboxNav=!0,this}setTitle(t){this.isUseJsboxNav&&($ui.title=t),this.title=t}setNavButtons(t){this.navButtons=t}openInJsbox(){$app.openURL(`jsbox://run?name=${this.title}`)}UIRender(t={}){let e=$context.query;if(\"alertFromKeyboard\"===e.type){let t=JSON.parse($text.URLDecode(e.value));return t.actions=[{title:$l10n(\"CANCEL\")}],void $ui.alert(t)}try{t.props=Object.assign({title:this.title,navBarHidden:!this.isUseJsboxNav,navButtons:this.navButtons??[],statusBarStyle:0},t.props),t.events||(t.events={});let e=t.events.layoutSubviews;t.events.layoutSubviews=()=>{$app.notify({name:\"interfaceOrientationEvent\",object:{statusBarOrientation:UIKit.statusBarOrientation,isHorizontal:UIKit.isHorizontal}}),\"function\"==typeof e&&e()},$ui.render(t)}catch(t){this.print(t)}}KeyboardRender(t={}){t.id||(t.id=$text.uuid),$ui.render({events:t.events??{}}),$delay(0,(()=>{$ui.controller.view=$ui.create(t),$ui.controller.view.layout(t.layout)}))}async checkUpdate(){let e=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/src/version.js\");if(e.error)throw e.error;let i=e.data.match(/.*VERSION.+\\\"([0-9\\.]+)\\\"/)[1];if(this.print(`easy-jsbox latest version: ${i}`),t.versionCompare(i,VERSION)>0){let t=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/dist/easy-jsbox.js\");if(t.error)throw t.error;return t.data}return!1}},L10n=class{static l10n(t,e,i){if(\"string\"==typeof e){let t={};e.split(\";\").forEach((e=>{if(\"\"!==(e=e.trim())){let i=e.split(\"=\");t[i[0].trim().slice(1,-1)]=i[1].trim().slice(1,-1)}})),e=t}let s=$app.strings;if(i)Object.assign(s[t],e);else for(let i in e)s[t][i]||(s[t][i]=e[i]);$app.strings=s}static set(t,e){this.l10n(t,e,!0)}static add(t,e){this.l10n(t,e,!1)}static init(){this.add(\"zh-Hans\",{OK:\"好\",DONE:\"完成\",CANCEL:\"取消\",CLEAR:\"清除\",BACK:\"返回\",ERROR:\"发生错误\",SUCCESS:\"成功\",INVALID_VALUE:\"非法参数\",CONFIRM_CHANGES:\"数据已变化,确认修改?\",SETTING:\"设置\",GENERAL:\"一般\",ADVANCED:\"高级\",TIPS:\"小贴士\",COLOR:\"颜色\",COPY:\"复制\",COPIED:\"复制成功\",JSBOX_ICON:\"JSBox 内置图标\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"图片 / base64\",PREVIEW:\"预览\",SELECT_IMAGE_PHOTO:\"从相册选择图片\",SELECT_IMAGE_ICLOUD:\"从 iCloud 选择图片\",CLEAR_IMAGE:\"清除图片\",NO_IMAGE:\"无图片\",ABOUT:\"关于\",VERSION:\"Version\",AUTHOR:\"作者\",AT_BOTTOM:\"已经到底啦~\"}),this.add(\"en\",{OK:\"OK\",DONE:\"Done\",CANCEL:\"Cancel\",CLEAR:\"Clear\",BACK:\"Back\",ERROR:\"Error\",SUCCESS:\"Success\",INVALID_VALUE:\"Invalid value\",CONFIRM_CHANGES:\"The data has changed, confirm the modification?\",SETTING:\"Setting\",GENERAL:\"General\",ADVANCED:\"Advanced\",TIPS:\"Tips\",COLOR:\"Color\",COPY:\"Copy\",COPIED:\"Copide\",JSBOX_ICON:\"JSBox in app icon\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"Image / base64\",PREVIEW:\"Preview\",SELECT_IMAGE_PHOTO:\"Select From Photo\",SELECT_IMAGE_ICLOUD:\"Select From iCloud\",CLEAR_IMAGE:\"Clear Image\",NO_IMAGE:\"No Image\",ABOUT:\"About\",VERSION:\"Version\",AUTHOR:\"Author\",AT_BOTTOM:\"It's the end~\"}),this.add(\"zh-Hans\",{DELETE_CONFIRM_TITLE:\"删除前确认\"}),this.add(\"en\",{DELETE_CONFIRM_TITLE:\"Delete Confirmation\"}),this.add(\"zh-Hans\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"确认要删除吗\",DELETE:\"删除\",CANCEL:\"取消\",CLOSE:\"关闭\",SHARE:\"分享\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\"}),this.add(\"en\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"Are you sure you want to delete\",DELETE:\"Delete\",CANCEL:\"Cancel\",CLOSE:\"Close\",SHARE:\"Share\",SAVE:\"Save\",SAVE_SUCCESS:\"Save Success\"})}},Logger=class{print;constructor(t){this.print=t??console.log}printToFile(t,e){this.print=i=>{t.exists(e)&&(i=(t.readSync(e)?.string??\"\")+i),t.writeSync(e,$data({string:i}))}}format(t,e){return`${(new Date).toUTCString()} [${e}] ${t}\\n`}log(t,e){this.print(this.format(t,e))}info(t){this.log(t,\"INFO\")}error(t){this.log(t,\"ERROR\")}alert(t){this.log(t,\"ALERT\")}},NavigationBarItems=class{rightButtons=[];leftButtons=[];#t={};hasbutton=!1;isPinTitleView=!1;setTitleView(t){return this.titleView=t,this}pinTitleView(){return this.isPinTitleView=!0,this}setFixedFooterView(t){return this.fixedFooterView=t,this}setRightButtons(t){return t.forEach((t=>this.addRightButton(t))),this.hasbutton||(this.hasbutton=!0),this}setLeftButtons(t){return t.forEach((t=>this.addLeftButton(t))),this.hasbutton||(this.hasbutton=!0),this}addRightButton({id:t,symbol:e,title:i,tapped:s,menu:r,events:n,color:a}={}){let o=BarButtonItem.creat({id:t,symbol:e,title:i,tapped:s,menu:r,events:n,color:a,align:UIKit.align.right});return this.rightButtons.push(o),this.#t[t??o.id]=o,this.hasbutton||(this.hasbutton=!0),this}addLeftButton({id:t,symbol:e,title:i,tapped:s,menu:r,events:n,color:a}={}){let o=BarButtonItem.creat({id:t,symbol:e,title:i,tapped:s,menu:r,events:n,color:a,align:UIKit.align.left});return this.leftButtons.push(o),this.#t[t??o.id]=o,this.hasbutton||(this.hasbutton=!0),this}getButton(t){return this.#t[t]}addPopButton(t,e,i){return t||(t=$l10n(\"BACK\")),this.popButtonView=e??{type:\"button\",props:{bgcolor:$color(\"clear\"),symbol:\"chevron.left\",tintColor:UIKit.linkColor,title:` ${t}`,titleColor:UIKit.linkColor,font:$font(\"bold\",16)},layout:(t,e)=>{t.left.equalTo(e.super.safeArea).offset(BarButtonItem.style.edges),t.centerY.equalTo(e.super.safeArea)},events:{tapped:()=>{$ui.pop(),\"function\"==typeof i&&i()}}},this}removePopButton(){return this.popButtonView=void 0,this}},Plist=class{constructor(t){this.content=t}valueToJs(t){switch(t.tag){case\"dict\":return this.dictToJs(t);case\"true\":case\"false\":return\"true\"===t.tag;case\"integer\":return t.number;case\"key\":case\"string\":return t.string;case\"date\":return new Date(t.string);case\"array\":return this.arrayToJs(t);default:return t.node}}arrayToJs(t){let e=[];return t.children().forEach((t=>{e.push(this.valueToJs(t))})),e}dictToJs(t){let e=[],i=[];return t.children().forEach((t=>{\"key\"===t.tag?e.push(this.valueToJs(t)):i.push(this.valueToJs(t))})),Object.fromEntries(e.map(((t,e)=>[t,i[e]])))}getObject(){if(!this.content)return!1;let t=$xml.parse({string:this.content,mode:\"xml\"});return this.valueToJs(t.rootElement.firstChild({xPath:\"//plist/dict\"}))}static get(t){return new this(t).getObject()}},Request=class t{static method={get:\"GET\",post:\"POST\",put:\"PUT\",delete:\"DELETE\",patch:\"PATCH\",head:\"HEAD\",options:\"OPTIONS\"};static errorType={http:0,network:1};cacheContainerKey=$addin?.current?.name+\".request.cache\";#t;#e=!1;#i=!1;cacheLife=2592e6;#s=!1;timeout=5;logger;constructor(t){\"function\"==typeof t&&(this.logger=t)}get cache(){return $cache.get(this.cacheContainerKey)??{}}#r(t){this.#s&&\"function\"==typeof this.logger&&this.logger(t)}logRequest(t){return this.#s=!0,\"function\"==typeof t&&(this.logger=t),this}disableLogRequest(){this.#s=!1}getCacheKey(t){return $text.MD5(t)}getCache(t,e=null){return this.cache[t]??e}setCache(t,e){if(!e)return;let i=this.cache;i[t]=e,$cache.set(this.cacheContainerKey,i)}removeCache(t){let e=this.cache;delete e[t],$cache.set(this.cacheContainerKey,e)}clearCache(){$cache.remove(this.cacheContainerKey)}clearNSURLCache(){this.#t||(this.#t=$objc(\"NSURLCache\").$sharedURLCache()),this.#t.$removeAllCachedResponses()}enableCache(){return this.#e=!0,this}disableCache(){return this.#e=!1,this}ignoreCacheExp(){this.#i=!0}async request(e,i,s={},r={},n=this.cacheLife,a){let o,l=this.#e&&i===t.method.get;if(l){o=this.getCacheKey(e);let t=this.getCache(o);if(t&&(this.#i||t.exp>Date.now()))return this.#r(\"get data from cache: \"+e),t.data}this.#r(`sending request [${i}]: ${e}`);let h=await $http.request(Object.assign({header:r,url:e,method:i,body:i===t.method.get?null:s,timeout:this.timeout},a));if(h.error)throw new RequestError({type:t.errorType.network,message:h.error.localizedDescription,code:h.error.code});if(h?.response?.statusCode>=400){let e=h.data;throw\"object\"==typeof e&&(e=JSON.stringify(e)),new RequestError({type:t.errorType.http,message:e,code:h.response.statusCode})}return l&&this.setCache(o,{exp:Date.now()+n,data:h}),h}},SettingItem=class _SettingItem{static rowHeight=50;static edgeOffset=10;static iconSize=30;static iconDefaultColor=\"#00CC00\";setting;#n;#a;#o;title;#l={};constructor({setting:t,key:e,title:i,icon:s,value:r=null}={}){this.setting=t,this.key=e,this.title=$l10n(i),this.icon=s,this.default=r}get method(){return this.setting.method}set key(t){return this.#a=t??$text.uuid,this.#n=void 0,this}get key(){return this.#a}get id(){return this.#n||(this.#n=`setting-${this.setting.name}-${this.key}`),this.#n}set icon(t){return t?Array.isArray(t)||(t=[t,_SettingItem.iconDefaultColor]):t=[\"square.grid.2x2.fill\",_SettingItem.iconDefaultColor],Array.isArray(t[0])||(t[0]=[t[0],t[0]]),t[1]?Array.isArray(t[1])||(t[1]=[t[1],t[1]]):t[1]=[_SettingItem.iconDefaultColor,_SettingItem.iconDefaultColor],this.#o=t,this}get icon(){return this.#o}get options(){return this.#l}set options(t){return this.#l=t??{},this}set(t){return this.setting.set(this.key,t)}get(t=this.default){return this.setting.getOriginal(this.key,t)}evalValues(object){let result;return result=\"string\"==typeof object?object.startsWith(\"this.method\")?eval(`(()=>{return ${object}()})()`):eval(`(()=>{return ${object}})()`):\"function\"==typeof object?object():object??[],result}createLineLabel(){return{type:\"view\",views:[{type:\"view\",props:{bgcolor:$color(this.icon[1][0],this.icon[1][1]),cornerRadius:5,smoothCorners:!0},views:[{type:\"image\",props:{tintColor:$color(\"white\"),image:$image(this.icon[0][0],this.icon[0][1])},layout:(t,e)=>{t.center.equalTo(e.super),t.size.equalTo(20)}}],layout:(t,e)=>{t.centerY.equalTo(e.super),t.size.equalTo(_SettingItem.iconSize),t.left.inset(_SettingItem.edgeOffset)}},{type:\"label\",props:{text:this.title,lines:1,align:$align.left},layout:(t,e)=>{t.centerY.equalTo(e.super),t.height.equalTo(e.super),t.left.equalTo(e.prev.right).offset(_SettingItem.edgeOffset),t.width.greaterThanOrEqualTo(10)}}],layout:(t,e)=>{t.height.centerY.equalTo(e.super),t.left.inset(0)}}}getView(){}create(){return this.getView(this.options)}},Sheet=class t{#t=()=>{};#e=()=>{};style=t.UIModalPresentationStyle.PageSheet;#i=!1;#s;static UIModalPresentationStyle={Automatic:-2,FullScreen:0,PageSheet:1,FormSheet:2,CurrentContext:3,Custom:4,OverFullScreen:5,OverCurrentContext:6,Popover:7,BlurOverFullScreen:8};navigationView;init(){this.initNavBar();let{width:t,height:e}=$device.info.screen,i=$objc(\"UIView\").invoke(\"initWithFrame\",$rect(0,0,t,e)),s=$objc(\"UIViewController\").invoke(\"alloc.init\"),r=s.$view();return r.$addSubview(i),s.$setModalPresentationStyle(this.style),s.$setModalInPresentation(this.#i),this.#t=()=>{r.jsValue().add(this.navigationView?.getPage().definition??this.view),$ui.vc.ocValue().invoke(\"presentViewController:animated:completion:\",s,!0,void 0)},this.#e=()=>s.invoke(\"dismissViewControllerAnimated:completion:\",!0,void 0),this}initNavBar(){if(!this.#s)return;let{title:e=\"\",popButton:i={title:$l10n(\"CLOSE\")},rightButtons:s=[]}=this.#s;if(void 0===this.view)throw new SheetViewUndefinedError;this.navigationView=new NavigationView;let r=this.navigationView.navigationBar;r.setLargeTitleDisplayMode(NavigationBar.largeTitleDisplayModeNever),r.navigationBarLargeTitleHeight-=r.navigationBarNormalHeight,r.navigationBarNormalHeight=NavigationBar.pageSheetNavigationBarHeight,r.navigationBarLargeTitleHeight+=r.navigationBarNormalHeight,this.style===t.UIModalPresentationStyle.FullScreen||this.style===t.UIModalPresentationStyle.OverFullScreen||this.style===t.UIModalPresentationStyle.BlurOverFullScreen?r.setTopSafeArea():r.removeTopSafeArea(),i.events=Object.assign({tapped:()=>{this.dismiss(),\"function\"==typeof i.tapped&&i.tapped()}},i.events??{}),this.navigationView.navigationBarItems.addLeftButton(i).setRightButtons(s),this.navigationView.setView(this.view).navigationBarTitle(e),this.view.props?.bgcolor&&this.navigationView?.getPage().setProp(\"bgcolor\",this.view.props?.bgcolor)}preventDismiss(){return this.#i=!0,this}setStyle(t){return this.style=t,this}setView(t={}){if(\"object\"!=typeof t)throw new SheetViewTypeError(\"view\",\"object\");return this.view=t,this}addNavBar(t){return this.#s=t,this}present(){this.#t()}dismiss(){this.#e()}static quickLookImage(e,i=$l10n(\"PREVIEW\")){(new t).setView({type:\"view\",views:[{type:\"scroll\",props:{zoomEnabled:!0,maxZoomScale:3},layout:$layout.fill,views:[{type:\"image\",props:{data:e},layout:$layout.fill}]}],layout:$layout.fill}).addNavBar({title:i,rightButtons:[{symbol:\"square.and.arrow.up\",tapped:()=>$share.sheet(e)}]}).init().present()}},Tasks=class{#t={};addTask(t,e=0){let i=$text.uuid;return this.#t[i]=$delay(e,(async()=>{await t(),delete this.#t[i]})),i}cancelTask(t){this.#t[t].cancel()}clearTasks(){Object.values(this.#t).forEach((t=>t.cancel()))}},Toast=class t{static type={info:void 0,success:\"checkmark\",warning:\"exclamationmark.triangle\",error:\"xmark.circle\"};static edges=40;static iconSize=100;static labelTopMargin=10;static defaultFont=$font(\"default\",26);width=Math.min(.6*UIKit.windowSize.width,260);labelWidth=this.width-2*t.edges;id=$text.uuid;#t=\"\";font=t.defaultFont;type=t.type.info;labelLines=2;constructor(e,i=t.type.info,s=2,r=t.defaultFont){this.type=i,this.message=e,this.labelLines=s,this.font=r}get message(){return this.#t}set message(e){this.#t=e,this.fontHeight=UIKit.getContentSize(this.font,this.message,this.labelWidth,this.labelLines).height,this.height=(this.hasIcon?t.labelTopMargin+t.iconSize:0)+this.fontHeight+2*t.edges}get hasIcon(){return void 0!==this.type}get blurBox(){let e=UIKit.blurBox({id:this.id,cornerRadius:15,alpha:0},[{type:\"image\",props:{symbol:this.type,hidden:!this.hasIcon,tintColor:$color(\"lightGray\")},layout:(e,i)=>{e.top.inset(t.edges),e.size.equalTo(t.iconSize),e.centerX.equalTo(i.super)}},{type:\"label\",props:{font:this.font,text:this.message,align:$align.center,lines:this.labelLines,color:$color(\"lightGray\")},layout:(e,i)=>{e.bottom.equalTo(i.supper).offset(-t.edges),e.width.equalTo(this.labelWidth),e.height.equalTo(this.fontHeight),e.centerX.equalTo(i.super)}}]);return e.events={tapped:()=>{this.remove()}},e}show(){let t=$ui.create(this.blurBox);$ui.controller.view.hidden?$ui.controller.view.super.insertAtIndex(t,0):$ui.controller.view.insertAtIndex(t,0);let e=$(this.id);e.layout(((t,e)=>{t.center.equalTo(e.super),t.size.equalTo($size(this.width,this.height))})),e.moveToFront(),$ui.animate({duration:.2,animation:()=>{e.alpha=1}})}remove(){let t=$(this.id);t&&$ui.animate({duration:.2,animation:()=>{t.alpha=0},completion:()=>{t.remove()}})}static toast({message:e,type:i=t.type.info,show:s=!0,displayTime:r=2,labelLines:n=2,font:a=t.defaultFont}){let o=new t(e,i,n,a);return s&&(o.show(),$delay(r,(()=>{o.remove()}))),o}static info(e,i={}){return t.toast(Object.assign({message:e,type:t.type.info},i))}static success(e,i={}){return t.toast(Object.assign({message:e,type:t.type.success},i))}static warning(e,i={}){return t.toast(Object.assign({message:e,type:t.type.warning},i))}static error(e,i={}){return t.toast(Object.assign({message:e,type:t.type.error},i))}},UIKit=class t{static#t=$objc(\"UIApplication\").$sharedApplication();static#e=$objc(\"UINotificationFeedbackGenerator\").$new();static feedbackSuccess(){t.#e.$notificationOccurred(0)}static feedbackError(){t.#e.$notificationOccurred(2)}static align={left:0,right:1,top:2,bottom:3};static textColor=$color(\"primaryText\");static linkColor=$color(\"systemLink\");static primaryViewBackgroundColor=$color(\"primarySurface\");static scrollViewBackgroundColor=$color(\"insetGroupedBackground\");static scrollViewList=[\"list\",\"matrix\"];static isLargeScreen=$device.isIpad||$device.isIpadPro;static get windowSize(){return $objc(\"UIWindow\").$keyWindow().jsValue().size}static NavigationBarNormalHeight=$objc(\"UINavigationController\").invoke(\"alloc.init\").$navigationBar().jsValue().frame.height;static NavigationBarLargeTitleHeight=$objc(\"UITabBarController\").invoke(\"alloc.init\").$tabBar().jsValue().frame.height+t.NavigationBarNormalHeight;static get isSplitScreenMode(){return t.isLargeScreen&&$device.info.screen.width!==t.windowSize.width}static get topSafeAreaInsets(){return t.#t?.$keyWindow()?.$safeAreaInsets()?.top??0}static get bottomSafeAreaInsets(){return t.#t?.$keyWindow()?.$safeAreaInsets()?.bottom??0}static get statusBarOrientation(){return t.#t.$statusBarOrientation()}static get consoleBarHeight(){if($app.isDebugging){let e=t.#t.$statusBarFrame().height+26;return $device.isIphoneX&&(e+=30),e}return 0}static get isHorizontal(){return 3===t.statusBarOrientation||4===t.statusBarOrientation}static loading(){let e=$ui.create(t.blurBox({cornerRadius:15},[{type:\"spinner\",props:{loading:!0,style:0},layout:(t,e)=>{t.size.equalTo(e.prev),t.center.equalTo(e.super)}}]));return{start:()=>{$ui.controller.view.insertAtIndex(e,0),e.layout(((e,i)=>{e.center.equalTo(i.super);let s=Math.min(.6*Math.min(t.windowSize.width,t.windowSize.height),260);e.size.equalTo($size(s,s))})),e.moveToFront()},end:()=>{e.remove()}}}static defaultBackgroundColor(e){return t.scrollViewList.indexOf(e)>-1?t.scrollViewBackgroundColor:t.primaryViewBackgroundColor}static separatorLine(e={},i=t.align.bottom){return{type:\"canvas\",props:e,layout:(e,s)=>{void 0===s.prev?e.top.equalTo(s.super):i===t.align.bottom?e.top.equalTo(s.prev.bottom):e.top.equalTo(s.prev.top),e.height.equalTo(1/$device.info.screen.scale),e.left.right.inset(0)},events:{draw:(t,i)=>{i.strokeColor=e.bgcolor??$color(\"separatorColor\"),i.setLineWidth(1),i.moveToPoint(0,0),i.addLineToPoint(t.frame.width,0),i.strokePath()}}}}static blurBox(t={},e=[],i=$layout.fill){return{type:\"blur\",props:Object.assign({style:$blurStyle.thinMaterial},t),views:e,layout:i}}static getContentSize(e,i=\"A\",s=t.windowSize.width,r){let n={text:i,width:s,font:e};return void 0!==r&&(n.lineSpacing=r),$text.sizeThatFits(n)}static getSymbolSize(t,e){let i=(t=\"string\"==typeof t?$image(t):t).size.width/t.size.height;return t.size.width>t.size.height?$size(e,e/i):$size(e*i,e)}static push({views:t,statusBarStyle:e=0,title:i=\"\",navButtons:s=[{title:\"\"}],bgcolor:r=t[0]?.props?.bgcolor??\"primarySurface\",titleView:n,disappeared:a}={}){let o={statusBarStyle:e,navButtons:s,title:i,bgcolor:\"string\"==typeof r?$color(r):r};n&&(o.titleView=n),$ui.push({props:o,events:{disappeared:()=>{void 0!==a&&a()}},views:[{type:\"view\",views:t,layout:(t,e)=>{t.top.equalTo(e.super.safeArea),t.bottom.equalTo(e.super),t.left.right.equalTo(e.super.safeArea)}}]})}static compressImage(t,e=921600){let i=$imagekit.info(t);if(i.height*i.width>e){let s=e/(i.height*i.width);t=$imagekit.scaleBy(t,s)}return t}static deleteConfirm(t,e){$ui.alert({title:$l10n(\"DELETE_CONFIRM_TITLE\"),message:t,actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{e()}},{title:$l10n(\"CANCEL\")}]})}static bytesToSize(t){if(0===t)return\"0 B\";let e=Math.floor(Math.log(t)/Math.log(1024));return(t/Math.pow(1024,e)).toPrecision(3)+\" \"+[\"B\",\"KB\",\"MB\",\"GB\",\"TB\",\"PB\",\"EB\",\"ZB\",\"YB\"][e]}},UILoading=class{#t;text=\"\";interval;fullScreen=!1;#e=()=>{};constructor(){this.#t=$text.uuid}updateText(t){$(this.#t).text=t}setLoop(t){if(\"function\"!=typeof t)throw\"loop must be a function\";this.#e=t}done(){clearInterval(this.interval)}load(){$ui.render({props:{navBarHidden:this.fullScreen},views:[{type:\"spinner\",props:{loading:!0},layout:(t,e)=>{t.centerY.equalTo(e.super).offset(-15),t.width.equalTo(e.super)}},{type:\"label\",props:{id:this.#t,align:$align.center,text:\"\"},layout:(t,e)=>{t.top.equalTo(e.prev.bottom).offset(10),t.left.right.equalTo(e.super)}}],layout:$layout.fill,events:{appeared:()=>{this.interval=setInterval((()=>{this.#e()}),100)}}})}},View=class t{id=$text.uuid;type;props;views;events;layout;#t=void 0;#e=null;constructor({type:t=\"view\",props:e={},views:i=[],events:s={},layout:r=$layout.fill}={}){this.type=t,this.props=e,this.views=i,this.events=s,this.layout=r,this.props.id?this.id=this.props.id:this.props.id=this.id}static create(t){return new this(t)}static createFromViews(t){return new this({views:t})}get scrollableView(){return this.scrollable?this.#e:null}set scrollableView(t){this.#e=t}get scrollable(){if(void 0===this.#t)if(this.#t=!1,UIKit.scrollViewList.indexOf(this.type)>-1)this.scrollableView=this,this.#t=!0;else if(this.views.length>0){let e=i=>{if(!this.#t&&i?.length>0)for(let s=0;s-1)return typeof i[s]!==t&&(i[s]=t.create(i[s])),this.scrollableView=i[s],void(this.#t=!0);e(i[s].views)}};e(this.views)}return this.#t}set scrollable(t){throw new Error(\"[scrollable] is readonly prop.\")}setProps(t){return Object.keys(t).forEach((e=>this.setProp(e,t[e]))),this}setProp(t,e){return\"id\"===t&&(this.id=e),this.props[t]=e,this}setViews(t){return this.views=t,this.#t=void 0,this}setEvents(t){return Object.keys(t).forEach((e=>this.setEvent(e,t[e]))),this}setEvent(t,e){return this.events[t]=e,this}eventMiddleware(t,e){let i=this.events[t];return this.events[t]=(...t)=>{\"function\"==typeof i&&e(i,...t)},this}assignEvent(t,e){let i=this.events[t];return this.events[t]=(...t)=>{\"function\"==typeof i&&i(...t),e(...t)},this}setLayout(t){return this.layout=t,this}getView(){return this}get definition(){return this.getView()}},FileStorageParameterError=class extends Error{constructor(t){super(`Parameter [${t}] is required.`),this.name=\"FileStorageParameterError\"}},FileStorageFileNotFoundError=class extends Error{constructor(t){super(`File not found: ${t}`),this.name=\"FileStorageFileNotFoundError\"}},RequestError=class extends Error{constructor({message:t,code:e,type:i}={}){super(t),this.name=\"RequestError\",this.code=e,this.type=i}},SettingLoadConfigError=class extends Error{constructor(){super(\"Call loadConfig() first.\"),this.name=\"SettingLoadConfigError\"}},SettingReadonlyError=class extends Error{constructor(){super(\"Attempted to assign to readonly property.\"),this.name=\"SettingReadonlyError\"}},SheetViewUndefinedError=class extends Error{constructor(){super(\"Please call setView(view) first.\"),this.name=\"SheetViewUndefinedError\"}},ValidationError=class extends Error{constructor(t,e){super(`The type of the parameter '${t}' must be '${e}'`),this.name=\"ValidationError\"}},FixedFooterView=class extends View{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",UIKit.primaryViewBackgroundColor),this.layout=(t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.height)},this.views=[View.create({props:this.props,views:this.views,layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.height.equalTo(this.height)}})],this}},Matrix=class extends View{titleStyle={font:$font(\"bold\",21),height:30};#t;#e;templateIdByIndex(t){return void 0===this.props.template.views[t]?.props?.id&&(void 0===this.props.template.views[t].props&&(this.props.template.views[t].props={}),this.props.template.views[t].props.id=$text.uuid),this.props.template.views[t].props.id}get templateHiddenStatus(){if(!this.#e){this.#e={};for(let t=0;t{t.items=t.items.filter((t=>!0===t?.__title?.hidden)),e.push(t)})),e}set data(t){this.props.data=this.rebuildData(t),$(this.id).data=this.props.data}#i(t){let e={...this.hiddenViews};return Object.assign(e,{__templateProps:{hidden:!0},__title:{hidden:!1,text:t,info:{title:!0}}}),e}rebuildData(t=[]){return t.map((t=>(t.items=t.items.map((t=>(Object.keys(t).forEach((e=>{t[e].hidden=this.templateHiddenStatus[e]??!1})),Object.keys(this.templateHiddenStatus).forEach((e=>{t[e]||(t[e]={}),t[e].hidden=this.templateHiddenStatus[e]})),t.__templateProps={hidden:!1},t.__title={hidden:!0},t))),t.title&&t.items.unshift(this.#i(t.title)),t)))}rebuildTemplate(){let t={};void 0!==this.props.template.props&&(void 0!==this.props.template.props.cornerRadius&&(this.props.template.props.clipsToBounds=!1),t=Object.assign(this.props.template.props,{id:\"__templateProps\",hidden:!1}));let e=[{type:\"view\",props:t,layout:$layout.fill},{type:\"label\",props:{id:\"__title\",hidden:!0,font:this.titleStyle.font},layout:(t,e)=>{t.top.inset(-this.titleStyle.height/4*3),t.height.equalTo(this.titleStyle.height),t.width.equalTo(e.super.safeArea)}}].concat(this.props.template.views);this.props.template.views=e}insert(t,e=!0){return t.indexPath=this.indexPath(t.indexPath,e),$(this.id).insert(t)}delete(t,e=!0){return t=this.indexPath(t,e),$(this.id).delete(t)}object(t,e=!0){return t=this.indexPath(t,e),$(this.id).object(t)}cell(t,e=!0){return t=this.indexPath(t,e),$(this.id).cell(t)}indexPath(t,e){let i=e?1:0;return t=\"number\"==typeof t?$indexPath(0,t+i):$indexPath(t.section,t.row+i)}getView(){return this.props.data=this.rebuildData(this.props.data),this.rebuildTemplate(),this.setEvent(\"itemSize\",((t,e)=>{if(t.object(e)?.__title?.info?.title)return $size(Math.max($device.info.screen.width,$device.info.screen.height),0);let i=this.props.columns??2,s=this.props.spacing??15,r=this.props.itemWidth??this.props.itemSize?.width??(t.super.frame.width-s*(i+1))/i,n=this.props.itemHeight??this.props.itemSize?.height??100;return $size(r,n)})),this}},BarTitleView=class extends View{controller={};setController(t){return this.controller=t,this}},BarButtonItem=class t extends View{static#t;edges=15;buttonEdges=this.edges/2;iconSize=24;fontSize=17;color=UIKit.textColor;title;#e;align=UIKit.align.right;get symbol(){return this.#e}set symbol(t){this.#e=\"string\"==typeof t?$image(t):t}get width(){if(this.title){let t=$text.sizeThatFits({text:this.title,width:UIKit.windowSize.width,font:$font(this.fontSize)});return Math.ceil(t.width)+this.edges}return this.iconSize+this.edges}static get style(){return void 0===this.#t&&(this.#t=new t),this.#t}setEdges(t){return this.edges=t,this}setFontSize(t){return this.fontSize=t,this}setColor(t=UIKit.textColor){return this.color=t,this}setTitle(t){return this.title=t,this}setSymbol(t){return this.symbol=t,this}setMenu(t){return this.menu=t,this}setAlign(t){return this.align=t,this}setLoading(t){t?($(this.id).hidden=!0,$(\"spinner-\"+this.id).hidden=!1):($(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0)}#i(){let t=$(`icon-button-${this.id}`),e=$(`icon-checkmark-${this.id}`);t.alpha=0,$(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0,$ui.animate({duration:.6,animation:()=>{e.alpha=1},completion:()=>{$delay(.3,(()=>$ui.animate({duration:.6,animation:()=>{e.alpha=0},completion:()=>{$ui.animate({duration:.4,animation:()=>{t.alpha=1},completion:()=>{t.alpha=1}})}})))}})}getView(){let t=this.events.tapped;return this.events.tapped=e=>{t&&t({start:()=>this.setLoading(!0),done:()=>this.#i(),cancel:()=>this.setLoading(!1)},e)},{type:\"view\",props:{info:{align:this.align}},views:[{type:\"button\",props:Object.assign({id:this.id,bgcolor:$color(\"clear\"),font:$font(this.fontSize),titleColor:this.color,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},this.menu?{menu:this.menu}:{},this.title?{title:this.title}:{},this.props),views:[{type:\"image\",props:Object.assign({id:`icon-button-${this.id}`,hidden:void 0===this.symbol,tintColor:this.color},this.symbol?{image:this.symbol}:{}),layout:(t,e)=>{this.symbol&&t.size.equalTo(UIKit.getSymbolSize(this.symbol,this.iconSize)),t.center.equalTo(e.super)}},{type:\"image\",props:{id:`icon-checkmark-${this.id}`,alpha:0,tintColor:this.color,symbol:\"checkmark\"},layout:(t,e)=>{t.center.equalTo(e.super),t.size.equalTo(UIKit.getSymbolSize(\"checkmark\",this.iconSize))}}],events:this.events,layout:$layout.fill},{type:\"spinner\",props:{id:\"spinner-\"+this.id,loading:!0,hidden:!0},layout:$layout.fill}],layout:(t,e)=>{if(t.size.equalTo($size(this.width,UIKit.NavigationBarNormalHeight)),t.centerY.equalTo(e.super),e.prev&&e.prev?.info?.align===this.align)this.align===UIKit.align.right?t.right.equalTo(e.prev.left).offset(-this.buttonEdges):t.left.equalTo(e.prev.right).offset(this.buttonEdges);else{let e=this.edges/2;this.align===UIKit.align.right?t.right.inset(e):t.left.inset(e)}}}}static creat({id:e,symbol:i,title:s,tapped:r,menu:n,events:a,color:o,align:l=UIKit.align.right}={}){let h=new t;return h.setEvents(Object.assign({tapped:r},a)).setAlign(l).setSymbol(i).setTitle(s).setColor(o).setMenu(n),e&&h.setProp(\"id\",e),h}},NavigationBar=class t extends View{static largeTitleDisplayModeAutomatic=0;static largeTitleDisplayModeAlways=1;static largeTitleDisplayModeNever=2;static pageSheetNavigationBarHeight=56;navigationBarItems;title=\"\";prefersLargeTitles=!0;largeTitleDisplayMode=t.largeTitleDisplayModeAutomatic;fontFamily=\"bold\";largeTitleFontSize=34;largeTitleFontHeight=$text.sizeThatFits({text:\"A\",width:100,font:$font(this.fontFamily,this.largeTitleFontSize)}).height;navigationBarTitleFontSize=17;topSafeArea=!0;contentViewHeightOffset=10;navigationBarNormalHeight=UIKit.NavigationBarNormalHeight;navigationBarLargeTitleHeight=UIKit.NavigationBarLargeTitleHeight;setTopSafeArea(){return this.topSafeArea=!0,this}removeTopSafeArea(){return this.topSafeArea=!1,this}setLargeTitleDisplayMode(t){return this.largeTitleDisplayMode=t,this}setBackgroundColor(t){return this.backgroundColor=t,this}setTitle(t){return this.title=t,this}setPrefersLargeTitles(t){return this.prefersLargeTitles=t,this}setContentViewHeightOffset(t){return this.contentViewHeightOffset=t,this}getLargeTitleView(){return this.prefersLargeTitles&&this.largeTitleDisplayMode!==t.largeTitleDisplayModeNever?{type:\"label\",props:{id:this.id+\"-large-title\",text:this.title,textColor:UIKit.textColor,align:$align.left,font:$font(this.fontFamily,this.largeTitleFontSize),line:1},layout:(t,e)=>{t.left.equalTo(e.super.safeArea).offset(15),t.height.equalTo(this.largeTitleFontHeight),t.top.equalTo(e.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}:{props:{id:this.id+\"-large-title\"},layout:(t,e)=>{t.left.top.right.inset(0),t.bottom.equalTo(e.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}}getNavigationBarView(){let e=(t,e)=>{let i=(t,i)=>{t.top.equalTo(i.super.safeAreaTop),t.bottom.equalTo(i.super.safeAreaTop).offset(this.navigationBarNormalHeight),e===UIKit.align.left?t.left.equalTo(i.super.safeArea):t.right.equalTo(i.super.safeArea)};if(t&&!Array.isArray(t))return{type:\"view\",views:[t],layout:i};let s=0,r=[];t.forEach((t=>{s+=t.width,r.push(t.definition)}));let n=t[0]?.edges??0;return s+=t.length>=2?2*n:n,t.length>0?{type:\"view\",views:r,info:{width:s},layout:(t,e)=>{i(t,e),t.width.equalTo(s)}}:{type:\"view\",layout:t=>t.size.equalTo(0)}},i=e(this.navigationBarItems.popButtonView??this.navigationBarItems.leftButtons,UIKit.align.left),s=e(this.navigationBarItems.rightButtons,UIKit.align.right),r=this.prefersLargeTitles,n=!this.prefersLargeTitles||this.largeTitleDisplayMode===t.largeTitleDisplayModeNever;return{type:\"view\",props:{id:this.id+\"-navigation\",bgcolor:$color(\"clear\")},layout:(t,e)=>{t.left.top.right.inset(0),t.bottom.equalTo(e.super.safeAreaTop).offset(this.navigationBarNormalHeight)},views:[this.backgroundColor?{type:\"view\",props:{hidden:r,bgcolor:this.backgroundColor,id:this.id+\"-background\"},layout:$layout.fill}:UIKit.blurBox({hidden:r,id:this.id+\"-background\"}),UIKit.separatorLine({id:this.id+\"-underline\",alpha:r?0:1}),{type:\"view\",props:{alpha:0,bgcolor:$color(\"clear\"),id:this.id+\"-large-title-mask\"},events:{ready:t=>{t.bgcolor=$(this.id+\"-large-title\")?.prev.bgcolor}},layout:$layout.fill},i,s,{type:\"view\",views:[{type:\"label\",props:{id:this.id+\"-small-title\",alpha:n?1:0,text:this.title,font:$font(this.fontFamily,this.navigationBarTitleFontSize),align:$align.center,bgcolor:$color(\"clear\"),textColor:UIKit.textColor},layout:(t,e)=>{t.edges.equalTo(e.super.safeArea);let r=UIKit.getContentSize($font(this.fontFamily,this.navigationBarTitleFontSize),e.text).width,n=Math.max(i.info?.width??0,s.info?.width??0);UIKit.windowSize.width-2*n>r&&t.centerX.equalTo(e.super.super)}}],layout:(t,e)=>{t.top.bottom.equalTo(e.super.safeArea),t.left.equalTo(e.prev.prev.right),t.right.equalTo(e.prev.left)}}]}}},NavigationBarController=class t extends Controller{static largeTitleViewSmallMode=0;static largeTitleViewLargeMode=1;navigationBar;updateSelector(){this.selector={navigation:$(this.navigationBar.id+\"-navigation\"),largeTitleView:$(this.navigationBar.id+\"-large-title\"),smallTitleView:$(this.navigationBar.id+\"-small-title\"),underlineView:this.navigationBar.navigationBarItems.isPinTitleView?$(this.navigationBar.id+\"-title-view-underline\"):$(this.navigationBar.id+\"-underline\"),largeTitleMaskView:$(this.navigationBar.id+\"-large-title-mask\"),backgroundView:$(this.navigationBar.id+\"-background\"),titleViewBackgroundView:$(this.navigationBar.id+\"-title-view-background\")}}toNormal(t=!0){this.updateSelector(),this.selector.backgroundView.hidden=!1,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=1,this.selector.smallTitleView.alpha=1,this.selector.largeTitleView.alpha=0}}),t&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=NavigationBar.largeTitleDisplayModeNever)}toLargeTitle(t=!0){this.updateSelector(),this.selector.backgroundView.hidden=!0,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=0,this.selector.smallTitleView.alpha=0,this.selector.largeTitleView.alpha=1}}),t&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=NavigationBar.largeTitleDisplayModeAlways)}#t(e){let i=e===t.largeTitleViewSmallMode;this.selector.largeTitleView.alpha=i?0:1,$ui.animate({duration:.2,animation:()=>{this.selector.smallTitleView.alpha=i?1:0}})}#e(e){if(this.selector.largeTitleView.updateLayout(((t,i)=>{this.navigationBar.navigationBarNormalHeight-e>0?t.top.equalTo(i.super.safeAreaTop).offset(this.navigationBar.navigationBarNormalHeight-e):t.top.equalTo(i.super.safeAreaTop).offset(0)})),e>0)e>=this.navigationBar.navigationBarNormalHeight?this.#t(t.largeTitleViewSmallMode):this.#t(t.largeTitleViewLargeMode);else{this.#t(t.largeTitleViewLargeMode);let i=this.navigationBar.largeTitleFontSize-.04*e;i>40&&(i=40),this.selector.largeTitleView.font=$font(this.navigationBar.fontFamily,i)}}#i(t){let e=this.navigationBar.largeTitleDisplayMode===NavigationBar.largeTitleDisplayModeNever?5:this.navigationBar.navigationBarNormalHeight,i=void 0!==this.selector.titleViewBackgroundView;if(t>e){this.selector.backgroundView.hidden=!1;let s=()=>{i&&this.navigationBar.navigationBarItems.isPinTitleView&&(this.selector.titleViewBackgroundView.alpha=1),this.selector.largeTitleMaskView.alpha=0,this.selector.underlineView.alpha=1};(t-e)/3>=1?s():$ui.animate({duration:.2,animation:()=>{s()}})}else this.selector.largeTitleMaskView.alpha=t>0?1:0,this.selector.underlineView.alpha=0,i&&(this.selector.titleViewBackgroundView.alpha=0),this.selector.backgroundView.hidden=!0}didScroll(t){if(!this.navigationBar.prefersLargeTitles)return;let e=this.navigationBar.largeTitleDisplayMode;if(e!==NavigationBar.largeTitleDisplayModeAlways)if(this.updateSelector(),e===NavigationBar.largeTitleDisplayModeAutomatic){if(!this.navigationBar.navigationBarItems?.isPinTitleView&&(this.navigationBar.navigationBarItems?.titleView?.controller.didScroll(t),t>0)){(t-=this.navigationBar.navigationBarItems?.titleView?.height??0)<0&&(t=0)}this.#e(t),this.#i(t)}else e===NavigationBar.largeTitleDisplayModeNever&&this.#i(t)}didEndDragging(t,e,i,s){if(!this.navigationBar.prefersLargeTitles)return;let r=this.navigationBar.largeTitleDisplayMode;if(r!==NavigationBar.largeTitleDisplayModeAlways&&(this.updateSelector(),r===NavigationBar.largeTitleDisplayModeAutomatic)){let r=0;this.navigationBar.navigationBarItems?.isPinTitleView||(this.navigationBar.navigationBarItems?.titleView?.controller.didEndDragging(t,e,i,s),r=this.navigationBar.navigationBarItems?.titleView?.height??0,t-=r),t>=0&&t<=this.navigationBar.largeTitleFontHeight&&i($point(0,t>=this.navigationBar.largeTitleFontHeight/2?this.navigationBar.navigationBarNormalHeight+r-s:r-s))}}},NavigationViewTypeError=class extends ValidationError{constructor(t,e){super(t,e),this.name=\"NavigationViewTypeError\"}},NavigationView=class extends Controller{page;navigationController=new NavigationBarController;navigationBar=new NavigationBar;navigationBarItems=new NavigationBarItems;constructor(){super(),this.navigationBar.navigationBarItems=this.navigationBarItems,this.navigationController.navigationBar=this.navigationBar}navigationBarTitle(t){return this.navigationBar.setTitle(t),this}setView(t){if(\"object\"!=typeof t)throw new NavigationViewTypeError(\"view\",\"object\");return this.view=View.create(t),this}#t(){if(!(this.view instanceof View))throw new NavigationViewTypeError(\"view\",\"View\");let t=this.view.scrollableView,e=$app.isDebugging||Kernel.isTaio?0:UIKit.topSafeAreaInsets,i=this.navigationBar.largeTitleDisplayMode===NavigationBar.largeTitleDisplayModeNever?this.navigationBar.navigationBarNormalHeight:this.navigationBar.navigationBarLargeTitleHeight,s=this.navigationBar.contentViewHeightOffset+i;if(this.navigationBarItems.titleView&&(s+=this.navigationBarItems.titleView.topOffset,s+=this.navigationBarItems.titleView.height,s+=this.navigationBarItems.titleView.bottomOffset),!this.view.scrollable||!1===t.props.associateWithNavigationBar)return void(this.view.layout=(t,i)=>{t.left.right.equalTo(i.super.safeArea),t.bottom.equalTo(i.super);let r=s-this.navigationBar.contentViewHeightOffset;(!UIKit.isHorizontal||UIKit.isLargeScreen)&&this.navigationBar.topSafeArea&&(r+=e),t.top.equalTo(r)});t.props.stickyHeader&&(s-=i,s+=this.navigationBar.largeTitleFontHeight),t.props.header?t.props.header={type:\"view\",props:{height:s+(t.props.header?.props?.height??0)},views:[{type:\"view\",props:{clipsToBounds:!0},views:[t.props.header],layout:(t,e)=>{t.top.equalTo(s),t.bottom.width.equalTo(e.super)}}]}:t.props.header={props:{height:s}},t.props.footer=Object.assign({props:{}},t.props.footer??{}),t.props.footer.props.height=(this.navigationBarItems.fixedFooterView?.height??0)+(t.props.footer.props?.height??0);let r=this.navigationBarItems.isPinTitleView?this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset+this.navigationBar.contentViewHeightOffset:0;if(t.props.indicatorInsets){let e=t.props.indicatorInsets;t.props.indicatorInsets=$insets(e.top+this.navigationBar.navigationBarNormalHeight+r,e.left,e.bottom+(this.navigationBarItems.fixedFooterView?.height??0),e.right)}else t.props.indicatorInsets=$insets(this.navigationBar.navigationBarNormalHeight+r,0,this.navigationBarItems.fixedFooterView?.height??0,0);t.layout=(e,i)=>{t.props.stickyHeader?e.top.equalTo(i.super.safeArea).offset(this.navigationBar.navigationBarNormalHeight):e.top.equalTo(i.super),e.left.right.equalTo(i.super.safeArea),e.bottom.equalTo(i.super)},t.assignEvent(\"didScroll\",(i=>{let s=i.contentOffset.y;(!UIKit.isHorizontal||UIKit.isLargeScreen)&&this.navigationBar.topSafeArea&&!t.props.stickyHeader&&(s+=e),this.navigationController.didScroll(s)})).assignEvent(\"didEndDragging\",((i,s)=>{let r=i.contentOffset.y,n=0;(!UIKit.isHorizontal||UIKit.isLargeScreen)&&this.navigationBar.topSafeArea&&!t.props.stickyHeader&&(r+=e,n=e),this.navigationController.didEndDragging(r,s,((...t)=>i.scrollToOffset(...t)),n)})).assignEvent(\"didEndDecelerating\",((...e)=>{e[0].tracking||t.events?.didEndDragging(...e)}))}#e(){if(this.navigationBar.prefersLargeTitles){this.#t();let t={};if(this.navigationBarItems.titleView){let e=this.navigationBar.largeTitleDisplayMode===NavigationBar.largeTitleDisplayModeNever?1:0;t=View.create({views:[this.navigationBar.backgroundColor?{type:\"view\",props:{alpha:e,bgcolor:this.navigationBar.backgroundColor,id:this.navigationBar.id+\"-title-view-background\"},layout:$layout.fill}:UIKit.blurBox({alpha:e,id:this.navigationBar.id+\"-title-view-background\"}),UIKit.separatorLine({id:this.navigationBar.id+\"-title-view-underline\",alpha:e}),this.navigationBarItems.titleView.definition],layout:(t,e)=>{t.top.equalTo(e.prev.bottom),t.width.equalTo(e.super),t.height.equalTo(this.navigationBarItems.titleView.topOffset+this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset)}})}this.page=PageView.createFromViews([this.view,this.navigationBar.getLargeTitleView(),t,this.navigationBar.getNavigationBarView(),this.navigationBarItems.fixedFooterView?.definition??{}])}else this.page=PageView.createFromViews([this.view]);this.view.props?.bgcolor?this.page.setProp(\"bgcolor\",this.view.props.bgcolor):this.page.setProp(\"bgcolor\",UIKit.defaultBackgroundColor(this.view.type))}getPage(){return this.page||this.#e(),this.page}},SearchBar=class extends BarTitleView{height=35;topOffset=15;bottomOffset=10;horizontalOffset=15;kbType=$kbType.search;placeholder=$l10n(\"SEARCH\");inputEvents={};keyboardView;accessoryView;cancelButtonFont=$font(16);constructor(t){super(t),this.setController(new SearchBarController),this.controller.setSearchBar(this)}get cancelButtonWidth(){return UIKit.getContentSize(this.cancelButtonFont,$l10n(\"CANCEL\")).width}setEvent(t,e){return this.inputEvents[t]=e,this}setPlaceholder(t){return this.placeholder=t,this}setKbType(t){return this.kbType=t,this}setKeyboardView(t){return this.keyboardView=t,this}setAccessoryView(t){return this.accessoryView=t,this}onBeginEditingAnimate(){$ui.animate({duration:.3,animation:()=>{let t=this.cancelButtonWidth;$(this.id+\"-cancel-button\").updateLayout(((e,i)=>{e.left.equalTo(i.super.right).offset(-t)})),$(this.id+\"-cancel-button\").alpha=1,$(this.id+\"-cancel-button\").relayout(),$(this.id+\"-input\").updateLayout((e=>{e.right.inset(t+this.horizontalOffset/2)})),$(this.id+\"-input\").relayout()}})}onEndEditingAnimate(){$ui.animate({duration:.3,animation:()=>{$(this.id+\"-cancel-button\").updateLayout(((t,e)=>{t.left.equalTo(e.super.right)})),$(this.id+\"-cancel-button\").alpha=0,$(this.id+\"-cancel-button\").relayout(),$(this.id+\"-input\").updateLayout($layout.fill),$(this.id+\"-input\").relayout()}})}cancel(){$(this.id+\"-input\").blur(),$(this.id+\"-input\").text=\"\",this.onEndEditingAnimate(),this.controller.callEvent(\"onCancel\")}getView(){return this.props={id:this.id,smoothCorners:!0,cornerRadius:6},this.views=[{type:\"input\",props:{id:this.id+\"-input\",type:this.kbType,bgcolor:$color(\"#EEF1F1\",\"#212121\"),placeholder:this.placeholder,keyboardView:this.keyboardView,accessoryView:this.accessoryView},layout:$layout.fill,events:Object.assign({didBeginEditing:t=>{this.onBeginEditingAnimate(),this.controller.callEvent(\"onBeginEditing\",t.text)},didEndEditing:t=>{this.controller.callEvent(\"onEndEditing\",t.text)},changed:t=>this.controller.callEvent(\"onChange\",t.text),returned:t=>this.controller.callEvent(\"onReturn\",t.text)},this.inputEvents)},{type:\"button\",props:{id:this.id+\"-cancel-button\",title:$l10n(\"CANCEL\"),font:this.cancelButtonFont,titleColor:$color(\"tintColor\"),bgcolor:$color(\"clear\"),alpha:0,hidden:!1},events:{tapped:()=>this.cancel()},layout:(t,e)=>{t.height.equalTo(e.super),t.width.equalTo(this.cancelButtonWidth),t.left.equalTo(e.super.right)}}],this.layout=(t,e)=>{t.height.equalTo(this.height),t.top.equalTo(e.super.safeArea).offset(this.topOffset),t.left.equalTo(e.super.safeArea).offset(this.horizontalOffset),t.right.equalTo(e.super.safeArea).offset(-this.horizontalOffset)},this}},SearchBarController=class extends Controller{setSearchBar(t){return this.searchBar=t,this}updateSelector(){this.selector={inputBox:$(this.searchBar.id),input:$(this.searchBar.id+\"-input\")}}hide(){this.updateSelector(),this.selector.inputBox.updateLayout((t=>{t.height.equalTo(0)}))}show(){this.updateSelector(),this.selector.inputBox.updateLayout((t=>{t.height.equalTo(this.searchBar.height)}))}didScroll(t){this.updateSelector();let e=this.searchBar.height-t;if(e=e>0?e>this.searchBar.height?this.searchBar.height:e:0,this.selector.inputBox.updateLayout((t=>{t.height.equalTo(e)})),t>0){let e=(this.searchBar.height/2-5-t)/10;this.selector.input.alpha=e}else this.selector.input.alpha=1}didEndDragging(t,e,i){this.updateSelector(),t>=0&&t<=this.searchBar.height&&i($point(0,t>=this.searchBar.height/2?this.searchBar.height:0))}},ViewController=class extends Controller{#t=[];#e(t){t.callEvent(\"onPop\"),this.callEvent(\"onPop\",t),this.#t.pop()}push(t){let e=this.#t[this.#t.length-1];t.navigationBarItems.addPopButton(e?.navigationBar.title),this.#t.push(t),$ui.push({props:{statusBarStyle:0,navBarHidden:!0},events:{dealloc:()=>{this.#e(t)}},views:[t.getPage().definition],layout:$layout.fill})}},SettingInfo=class extends SettingItem{getView(){let t=Array.isArray(this.default),e=t?this.default[0]:this.default,i=t?this.default[1]:this.default;return{type:\"view\",props:{selectable:!0},views:[this.createLineLabel(),{type:\"label\",props:{text:e,align:$align.right,textColor:$color(\"darkGray\")},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(SettingItem.edgeOffset),t.width.equalTo(180)}},{type:\"view\",events:{tapped:()=>{$ui.alert({title:this.title,message:i,actions:[{title:$l10n(\"COPY\"),handler:()=>{$clipboard.text=i,$ui.toast($l10n(\"COPIED\"))}},{title:$l10n(\"OK\")}]})}},layout:(t,e)=>{t.right.inset(0),t.size.equalTo(e.super)}}],layout:$layout.fill}}},SettingSwitch=class extends SettingItem{getView(){return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"switch\",props:{on:this.get(),onColor:$color(\"#00CC00\")},events:{changed:t=>{try{this.set(t.on)}catch(e){throw t.on=!t.on,e}}},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(SettingItem.edgeOffset)}}],layout:$layout.fill}}},SettingString=class extends SettingItem{getView(){return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"button\",props:{symbol:\"square.and.pencil\",bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\")},events:{tapped:t=>{let e=$ui.popover({sourceView:t,sourceRect:t.bounds,directions:$popoverDirection.down,size:$size(320,150),views:[{type:\"text\",props:{id:`${this.id}-string`,align:$align.left,text:this.get()},layout:t=>{t.left.right.inset(10),t.top.inset(20),t.height.equalTo(90)}},{type:\"button\",props:{symbol:\"checkmark\",bgcolor:$color(\"clear\"),titleEdgeInsets:10,contentEdgeInsets:0},layout:t=>{t.right.inset(10),t.bottom.inset(25),t.size.equalTo(30)},events:{tapped:()=>{this.set($(`${this.id}-string`).text),e.dismiss()}}}]})}},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(0),t.size.equalTo(50)}}],layout:$layout.fill}}},SettingStepper=class extends SettingItem{with({min:t,max:e}={}){return this.options={min:t,max:e},this}getView({min:t,max:e}={}){let i=`${this.id}-label`;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"label\",props:{id:i,text:this.get(),align:$align.left},layout:(t,e)=>{t.height.equalTo(e.super),t.right.inset(120)}},{type:\"stepper\",props:{min:t,max:e,value:this.get()},events:{changed:t=>{$(i).text=t.value;try{this.set(t.value)}catch(t){throw $(i).text=this.get(),t}}},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(SettingItem.edgeOffset)}}],layout:$layout.fill}}},SettingScript=class extends SettingItem{#h;#c(){$(this.id).bgcolor=$color(\"systemFill\")}#d(t=.3){0===t?$(this.id).bgcolor=$color(\"clear\"):$ui.animate({duration:t,animation:()=>{$(this.id).bgcolor=$color(\"clear\")}})}#p(t,e=!1,i=0){if(t=Object.assign(t,{touchesBegan:()=>{this.#c(),this.#h=$delay(1,(()=>this.#d(0)))},touchesMoved:()=>{this.#h?.cancel(),this.#d(0)}}),e){let e=t.tapped;t.tapped=()=>{this.#c(),$delay(i,(()=>this.#d())),\"function\"==typeof e&&e()}}return t}with({script:t}={}){return this.options={script:t},this}getView({script:script}={}){let buttonId=`${this.id}-button`,rightSymbol=\"chevron.right\",start=()=>{$(buttonId).alpha=0,$(`${buttonId}-spinner`).alpha=1,this.#c()},cancel=()=>{$(buttonId).alpha=1,$(`${buttonId}-spinner`).alpha=0,this.#d()},done=()=>{$(`${buttonId}-spinner`).alpha=0,this.#d();let t=$(buttonId);t.symbol=\"checkmark\",$ui.animate({duration:.6,animation:()=>t.alpha=1,completion:()=>{$ui.animate({duration:.4,animation:()=>t.alpha=0,completion:()=>{t.symbol=rightSymbol,$ui.animate({duration:.4,animation:()=>t.alpha=1})}})}}),$delay(.6,(()=>{}))};return{type:\"view\",props:{id:this.id},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"button\",props:{id:buttonId,symbol:rightSymbol,bgcolor:$color(\"clear\"),tintColor:$color(\"secondaryText\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.right.inset(0),t.height.equalTo(e.super)}},{type:\"spinner\",props:{id:`${buttonId}-spinner`,loading:!0,alpha:0},layout:(t,e)=>{t.size.equalTo(15),t.centerY.equalTo(e.super),t.right.equalTo(e.prev)}}],layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}},{type:\"view\",layout:$layout.fill}],events:this.#p({tapped:()=>{let animate={start:start,cancel:cancel,done:done,touchHighlightStart:()=>this.#c(),touchHighlightEnd:()=>this.#d()};\"function\"==typeof script?script(animate):script.startsWith(\"this.method\")?eval(`(()=>{return ${script}(animate)})()`):eval(script)}}),layout:$layout.fill}}},SettingTab=class extends SettingItem{with({items:t,values:e}={}){return Array.isArray(t)&&(t=t.map((t=>$l10n(t)))),this.options={items:t,values:e},this}getView({items:t,values:e}={}){t=this.evalValues(t),e=this.evalValues(e);let i=t?.length>0&&e?.length===t?.length;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"tab\",props:{items:t??[],index:i?e.indexOf(this.get()):this.get(),dynamicWidth:!0},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.prev)},events:{changed:t=>{i?this.set(e[t.index]):this.set(t.index)}}}],layout:$layout.fill}}},SettingMenu=class extends SettingItem{with({items:t,values:e,pullDown:i}={}){return Array.isArray(t)&&(t=t.map((t=>$l10n(t)))),this.options={items:t,values:e,pullDown:i},this}getView({items:t,values:e,pullDown:i}={}){let s=`${this.id}-label`,r=this.evalValues(t),n=this.evalValues(e),a=r?.length>0&&n?.length===r?.length,o=(t,i)=>{if(a){let t=this.evalValues(e);this.set(t[i])}else this.set(i);$(s).title=t},l=()=>{i||$ui.menu({items:this.evalValues(t),handler:o})};return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"button\",props:{menu:i?{pullDown:!0,asPrimary:!0,items:r.map(((t,e)=>({title:t,handler:()=>o(t,e)})))}:void 0,title:a?r[n.indexOf(this.get())]:r[this.get()],titleColor:$color(\"secondaryText\"),bgcolor:$color(\"clear\"),id:s},events:{tapped:l},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(e.super)}}],layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}}],events:{tapped:l},layout:$layout.fill}}},SettingColor=class extends SettingItem{get(t=null){let e=super.get(t);return e?\"string\"==typeof e?$color(e):$rgba(e.red,e.green,e.blue,e.alpha):t}getView(){let t=`${this.id}-color`;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"view\",props:{id:t,bgcolor:this.get(),circular:!0,borderWidth:1,borderColor:$color(\"#e3e3e3\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.right.inset(SettingItem.edgeOffset),t.size.equalTo(20)}},{type:\"view\",events:{tapped:async()=>{let e=await $picker.color({color:this.get()});this.set(e.components),$(t).bgcolor=$rgba(e.components.red,e.components.green,e.components.blue,e.components.alpha)}},layout:(t,e)=>{t.right.inset(0),t.height.width.equalTo(e.super.height)}}],layout:(t,e)=>{t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},SettingDate=class extends SettingItem{with({mode:t=2}={}){return this.options={mode:t},this}getView({mode:t=2}={}){let e=e=>{let i=\"\";switch(\"number\"==typeof e&&(e=new Date(e)),t){case 0:i=e.toLocaleTimeString();break;case 1:i=e.toLocaleDateString();break;case 2:i=e.toLocaleString()}return i};return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"label\",props:{id:`${this.id}-label`,color:$color(\"secondaryText\"),text:this.get()?e(this.get()):\"None\"},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(e.super)}}],events:{tapped:async()=>{let i=this.get(),s=await $picker.date({props:{mode:t,date:i||Date.now()}});this.set(s.getTime()),$(`${this.id}-label`).text=e(s)}},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},SettingInput=class extends SettingItem{with({secure:t=!1,kbType:e=$kbType.default,saveFunc:i}={}){return this.options={secure:t,kbType:e,saveFunc:i},this}getView({secure:t=!1,kbType:e=$kbType.default,saveFunc:i}={}){void 0===i&&(i=t=>this.set(t));let s=this.id+\"-input\";return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"input\",props:{id:s,type:e,align:$align.right,bgcolor:$color(\"clear\"),textColor:$color(\"secondaryText\"),text:this.get(),font:$font(16),secure:t,accessoryView:UIKit.blurBox({height:44},[UIKit.separatorLine({},UIKit.align.top),{type:\"button\",props:{title:$l10n(\"DONE\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.super)},events:{tapped:()=>{$(s).blur()}}},{type:\"button\",props:{title:$l10n(\"CANCEL\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(t,e)=>{t.left.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.super)},events:{tapped:()=>{let t=$(s),e=this.get(\"\");t.text!==e&&(t.text=e),t.blur()}}}])},layout:(t,e)=>{t.left.equalTo(e.prev.get(\"label\").right).offset(SettingItem.edgeOffset),t.right.inset(SettingItem.edgeOffset);let i=UIKit.getContentSize($font(16),this.get(\"\")).width;t.width.greaterThanOrEqualTo(i+30),t.height.equalTo(e.super)},events:{didBeginEditing:t=>{t.secure=!1,$app.autoKeyboardEnabled||($app.autoKeyboardEnabled=!0)},returned:t=>{t.blur()},didEndEditing:async e=>{let s=this.get(\"\");i(e.text)||(e.text=s),t&&(e.secure=t)}}}],layout:$layout.fill}}},SettingNumber=class extends SettingItem{getView(){return new SettingInput(this).getView({secure:!1,kbType:$kbType.decimal,saveFunc:t=>\"\"!==t&&/^[0-9]+.?[0-9]*$/.test(t)?this.set(Number(t)):($ui.toast($l10n(\"INVALID_VALUE\")),!1)})}},SettingIcon=class extends SettingItem{with({bgcolor:t=\"#000000\"}={}){return this.options={bgcolor:t},this}getView({bgcolor:t=\"#000000\"}={}){let e=`${this.id}-image`;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"image\",props:{cornerRadius:8,bgcolor:\"string\"==typeof t?$color(t):t,smoothCorners:!0},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.super),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:e,image:$image(this.get()),icon:$icon(this.get()?.slice(5,this.get().indexOf(\".\")),$color(\"#ffffff\")),tintColor:$color(\"#ffffff\")},layout:(t,e)=>{t.right.equalTo(e.prev).offset(-5),t.centerY.equalTo(e.super),t.size.equalTo($size(20,20))}}],events:{tapped:()=>{$ui.menu({items:[$l10n(\"JSBOX_ICON\"),$l10n(\"SF_SYMBOLS\"),$l10n(\"IMAGE_BASE64\")],handler:async(t,i)=>{if(0===i){let t=await $ui.selectIcon();this.set(t),$(e).icon=$icon(t.slice(5,t.indexOf(\".\")),$color(\"#ffffff\"))}else(1===i||2===i)&&$input.text({text:\"\",placeholder:t,handler:t=>{\"\"!==t?(this.set(t),1===i?$(e).symbol=t:$(e).image=$image(t)):$ui.toast($l10n(\"INVALID_VALUE\"))}})}})}},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},SettingPush=class extends SettingItem{with({view:t,tapped:e}={}){return this.options={view:t,tapped:e},this}getView({view:view,tapped:tapped}={}){return{type:\"view\",layout:$layout.fill,props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"button\",props:{symbol:\"chevron.right\",bgcolor:$color(\"clear\"),tintColor:$color(\"secondaryText\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.right.inset(SettingItem.edgeOffset),t.height.equalTo(e.super)}},{type:\"view\",layout:$layout.fill}],events:{tapped:()=>{let push=view=>{if(\"string\"==typeof view&&view.startsWith(\"this.method\")?view=eval(`(()=>{return ${view}()})()`):\"function\"==typeof view&&(view=view()),this.setting.isUseJsboxNav)UIKit.push({title:this.title,props:view.props??{},views:[view]});else{let t=new NavigationView;t.setView(view).navigationBarTitle(this.title),t.navigationBarItems.addPopButton(),t.navigationBar.setLargeTitleDisplayMode(NavigationBar.largeTitleDisplayModeNever),this.setting.hasSectionTitle(view)&&t.navigationBar.setContentViewHeightOffset(-10),this.setting.viewController.push(t)}};\"function\"==typeof tapped?tapped(push):push(view)}}}}},SettingChild=class extends SettingItem{with({children:t}={}){return this.options={children:t},this}getView({children:t}={}){return new SettingPush(this).getView({tapped:e=>{this.setting.events?.onChildPush?this.setting.callEvent(\"onChildPush\",this.setting.getListView(t,{}),this.title):e(this.setting.getListView(t,{}))}})}},SettingImage=class extends SettingItem{getImagePath(t=!1){let e=$text.MD5(this.key)+\".jpg\";return t&&(e=\"compress.\"+e),this.setting.imagePath+e}getImage(t=!1){try{return this.setting.fileStorage.readSync(this.getImagePath(t))}catch(t){if(t instanceof FileStorageFileNotFoundError)return null;throw t}}get(t=null){return this.getImage(!1)??null}getView(){let t=`${this.id}-image`,e=$image(\"questionmark.square.dashed\"),i=e=>async()=>{$(t).hidden=!0,$(`${t}-spinner`).hidden=!1,await $wait(.1);try{await e()}catch(t){$ui.alert({title:$l10n(\"ERROR\"),message:String(t)})}await $wait(.1),$(`${t}-spinner`).hidden=!0,$(t).hidden=!1},s=[{title:$l10n(\"PREVIEW\"),handler:i((()=>{let t=this.getImage(!1);t?Sheet.quickLookImage(t):$ui.toast($l10n(\"NO_IMAGE\"))}))},{inline:!0,items:[{title:$l10n(\"SELECT_IMAGE_PHOTO\"),handler:i((async()=>{let e=await $photo.pick({format:\"data\"});if(!e.status||!e.data){if(\"canceled\"!==e?.error?.description)throw new Error(e?.error?.description);return}let i=UIKit.compressImage(e.data.image);this.setting.fileStorage.write(this.getImagePath(!0),i.jpg(.8)),this.setting.fileStorage.write(this.getImagePath(),e.data),$(t).image=i,$ui.success($l10n(\"SUCCESS\"))}))},{title:$l10n(\"SELECT_IMAGE_ICLOUD\"),handler:i((async()=>{let e=await $drive.open();if(!e)return;let i=UIKit.compressImage(e.image);this.setting.fileStorage.write(this.getImagePath(!0),i.jpg(.8)),this.setting.fileStorage.write(this.getImagePath(),e),$(t).image=i,$ui.success($l10n(\"SUCCESS\"))}))}]},{title:$l10n(\"CLEAR_IMAGE\"),destructive:!0,handler:i((()=>{this.setting.fileStorage.delete(this.getImagePath(!0)),this.setting.fileStorage.delete(this.getImagePath()),$(t).image=e,$ui.success($l10n(\"SUCCESS\"))}))}];return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"image\",props:{id:t,image:this.getImage(!0)?.image??e},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.super),t.size.equalTo($size(30,30))}},{type:\"spinner\",props:{id:`${t}-spinner`,loading:!0,hidden:!0},layout:(t,e)=>{t.size.equalTo(e.prev),t.left.top.equalTo(e.prev)}},{type:\"button\",props:{menu:{pullDown:!0,asPrimary:!0,items:s},bgcolor:$color(\"clear\")},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.super),t.size.equalTo($size(30,30))}}],layout:(t,e)=>{t.right.inset(0),t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},Setting=class extends Controller{name;setting={};settingItems={};userData;fileStorage;imagePath;viewController=new ViewController;method={readme:()=>{let t=(()=>{let t=$device.info?.language?.startsWith(\"zh\")?\"README_CN.md\":\"README.md\";try{return __README__[t]??__README__[\"README.md\"]}catch{return $file.read(t)?.string??$file.read(\"README.md\")?.string}})();(new Sheet).setView({type:\"markdown\",props:{content:t},layout:(t,e)=>{t.size.equalTo(e.super)}}).init().present()}};#t=!1;#e=!1;#i;constructor(t={}){super(),\"function\"==typeof t.set&&\"function\"==typeof t.get?(this.set=t.set,this.getOriginal=t.get,this.setUserData(t.userData??{})):(this.fileStorage=t.fileStorage??new FileStorage,this.dataFile=t.dataFile??\"setting.json\"),t.structure?this.setStructure(t.structure):this.setStructurePath(t.structurePath??\"setting.json\"),this.isUseJsboxNav=t.isUseJsboxNav??!1,this.imagePath=(t.name??\"default\")+\".image/\",this.setName(t.name??$text.uuid)}useJsboxNav(){return this.isUseJsboxNav=!0,this}#s(){if(!this.#e)throw new SettingLoadConfigError}loader(t){t.setting=this;let e=null;switch(t.type){case\"info\":e=new SettingInfo(t);break;case\"switch\":e=new SettingSwitch(t);break;case\"string\":e=new SettingString(t);break;case\"stepper\":e=new SettingStepper(t).with({min:t.min??1,max:t.max??12});break;case\"script\":e=new SettingScript(t).with({script:t.script??t.value});break;case\"tab\":e=new SettingTab(t).with({items:t.items,values:t.values});break;case\"menu\":e=new SettingMenu(t).with({items:t.items,values:t.values,pullDown:t.pullDown??!1});break;case\"color\":e=new SettingColor(t);break;case\"date\":e=new SettingDate(t).with({mode:t.mode});break;case\"input\":e=new SettingInput(t).with({secure:t.secure});break;case\"number\":e=new SettingNumber(t);break;case\"icon\":e=new SettingIcon(t).with({bgcolor:t.bgcolor});break;case\"push\":e=new SettingPush(t).with({view:t.view});break;case\"child\":e=new SettingChild(t).with({children:t.children});break;case\"image\":e=new SettingImage(t)}return e}loadConfig(){this.#e=!1;let t=this.userData??this.fileStorage.readAsJSON(this.dataFile,{}),e=t=>t instanceof SettingItem?t instanceof SettingScript||t instanceof SettingInfo:[\"script\",\"info\"].includes(t.type),i=s=>{for(let r in s)for(let n in s[r].items){let a=s[r].items[n];a instanceof SettingItem||(s[r].items[n]=this.loader(a)),s[r].items[n].setting||(s[r].items[n].setting=this),s[r].items[n]instanceof SettingChild?i(s[r].items[n].options.children):e(a)||(a.key in t?this.setting[a.key]=t[a.key]:this.setting[a.key]=a.value??a.default,this.settingItems[a.key]=s[r].items[n])}};return i(this.structure),this.#e=!0,this}hasSectionTitle(t){return this.#s(),!!t[0]?.title}setUserData(t){return this.userData=t,this}setStructure(t){return this.structure=t,this.loadConfig()}setStructurePath(t){return this.structure||this.setStructure(FileStorage.readFromRootAsJSON(t)),this}setName(t){return this.name=t,this}setFooter(t){return this.#i=t,this}set footer(t){this.#i=t}get footer(){if(void 0===this.#i){let t=FileStorage.readFromRootAsJSON(\"config.json\",{}).info??{};if(!t.version||!t.author)try{t=__INFO__}catch{}this.#i={},t.version&&t.author&&(this.#i={type:\"view\",props:{height:70},views:[{type:\"label\",props:{font:$font(14),text:`${$l10n(\"VERSION\")} ${t.version} ♥ ${t.author}`,textColor:$color({light:\"#C0C0C0\",dark:\"#545454\"}),align:$align.center},layout:t=>{t.left.right.inset(0),t.top.inset(10)}}]})}return this.#i}setReadonly(){return this.#t=!0,this}set(t,e){if(this.#t)throw new SettingReadonlyError;return this.#s(),this.setting[t]=e,this.fileStorage.write(this.dataFile,$data({string:JSON.stringify(this.setting)})),this.callEvent(\"onSet\",t,e),!0}getOriginal(t,e=null){return this.#s(),Object.prototype.hasOwnProperty.call(this.setting,t)?this.setting[t]:e}getItem(t){return this.settingItems[t]}get(t,e=null){return this.#s(),this.getItem(t)?this.getItem(t).get(e):this.getOriginal(t,e)}#r(t){let e=[];for(let i of t){let t=[];for(let e of i.items)e instanceof SettingItem&&t.push(e.create());e.push({title:$l10n(i.title??\"\"),rows:t})}return e}getListView(t=this.structure,e=this.footer){return{type:\"list\",props:{id:this.name,style:2,separatorInset:$insets(0,SettingItem.iconSize+2*SettingItem.edgeOffset,0,SettingItem.edgeOffset),footer:e,data:this.#r(t)},layout:$layout.fill,events:{rowHeight:(t,e)=>(t.object(e)?.props?.info??{}).rowHeight??SettingItem.rowHeight}}}getNavigationView(){let t=new NavigationView;return t.setView(this.getListView(this.structure)).navigationBarTitle($l10n(\"SETTING\")),this.hasSectionTitle(this.structure)&&t.navigationBar.setContentViewHeightOffset(-10),t}getPage(){return this.getNavigationView().getPage()}},SheetViewTypeError=class extends ValidationError{constructor(t,e){super(t,e),this.name=\"SheetViewTypeError\"}},TabBarCellView=class extends View{constructor(t={}){super(t),this.setIcon(t.icon),this.setTitle(t.title),void 0!==t.activeStatus&&(this.activeStatus=t.activeStatus)}setIcon(t){return this.icon=t instanceof Array?t:[t,t],this}setTitle(t){return this.title=t,this}active(){$(`${this.props.id}-icon`).image=$image(this.icon[1]),$(`${this.props.id}-icon`).tintColor=$color(\"systemLink\"),$(`${this.props.id}-title`).textColor=$color(\"systemLink\"),this.activeStatus=!0}inactive(){$(`${this.props.id}-icon`).image=$image(this.icon[0]),$(`${this.props.id}-icon`).tintColor=$color(\"lightGray\"),$(`${this.props.id}-title`).textColor=$color(\"lightGray\"),this.activeStatus=!1}getView(){return this.views=[{type:\"image\",props:{id:`${this.props.id}-icon`,image:$image(this.activeStatus?this.icon[1]:this.icon[0]),bgcolor:$color(\"clear\"),tintColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(t,e)=>{t.centerX.equalTo(e.super);let i=TabBarController.tabBarHeight/2;t.size.equalTo(i),t.top.inset((TabBarController.tabBarHeight-i-13)/2)}},{type:\"label\",props:{id:`${this.props.id}-title`,text:this.title,font:$font(10),textColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(t,e)=>{t.centerX.equalTo(e.prev),t.top.equalTo(e.prev.bottom).offset(3)}}],this}},TabBarHeaderView=class extends View{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",this.props.bgcolor??UIKit.primaryViewBackgroundColor),this.layout=(t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.height-TabBarController.tabBarHeight)},this.views=[View.create({props:this.props,views:this.views,layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.height.equalTo(this.height)}})],this}},TabBarController=class t extends Controller{static tabBarHeight=50;#t={};#e={};#i;#s;#r=$text.uuid;#u=$text.uuid;bottomSafeAreaInsets=$app.isDebugging?0:UIKit.bottomSafeAreaInsets;get selected(){return this.#s}set selected(t){this.switchPageTo(t)}get contentOffset(){return t.tabBarHeight+(this.#i?.height??0)}setPages(t={}){return Object.keys(t).forEach((e=>this.setPage(e,t[e]))),this}setPage(t,e){return void 0===this.#s&&(this.#s=t),this.#t[t]=e instanceof PageView?e:PageView.create(e),this.#s!==t&&(this.#t[t].activeStatus=!1),this}switchPageTo(t){if(this.#t[t]){if(this.#s===t)return;$ui.animate({duration:.4,animation:()=>{this.#e[t].active()}}),this.#e[this.#s].inactive(),this.#t[this.#s].hide(),this.#t[t].show(),this.callEvent(\"onChange\",this.#s,t),this.#s=t,this.initBackground()}}hideBackground(t=!0){$(this.#u).hidden=!0,$ui.animate({duration:t?.2:1e-4,animation:()=>{$(this.#r).alpha=0}})}showBackground(t=!0){$(this.#u).hidden=!1,$ui.animate({duration:t?.2:1e-4,animation:()=>{$(this.#r).alpha=1}})}initBackground(){let t=this.#t[this.selected];t.scrollable&&$delay(0,(()=>{let e=$(t.id).get(t.scrollableView.id),i=e.contentOffset.y;e.contentSize.height+this.bottomSafeAreaInsets-e.frame.height-i<=0?this.hideBackground(!1):this.showBackground(!1)}))}setCells(t={}){return Object.keys(t).forEach((e=>this.setCell(e,t[e]))),this}setCell(t,e){return void 0===this.#s&&(this.#s=t),e instanceof TabBarCellView||(e=new TabBarCellView({props:{info:{key:t}},icon:e.icon,title:e.title,activeStatus:this.#s===t})),this.#e[t]=e,this}setHeader(t){return this.#i=t,this}#g(){let t=[];return Object.values(this.#e).forEach((e=>{e.setEvent(\"tapped\",(t=>{let e=t.info.key;this.switchPageTo(e)})),t.push(e.getView())})),t}#y(){return Object.values(this.#t).map((t=>{if(t.scrollable){let e=t.scrollableView;if(e.props.indicatorInsets){let t=e.props.indicatorInsets;e.props.indicatorInsets=$insets(t.top,t.left,t.bottom+this.contentOffset,t.right)}else e.props.indicatorInsets=$insets(0,0,this.contentOffset,0);e.props.footer=Object.assign({props:{}},e.props.footer??{}),e.props.footer.props.height?e.props.footer.props.height+=this.contentOffset:e.props.footer.props.height=this.contentOffset,\"function\"==typeof e.assignEvent&&e.assignEvent(\"didScroll\",(t=>{let e=t.contentOffset.y;t.contentSize.height+this.bottomSafeAreaInsets-t.frame.height-e<=1?this.hideBackground():this.showBackground()}))}return t.definition}))}generateView(){let e={type:\"view\",layout:(e,i)=>{e.centerX.equalTo(i.super),e.width.equalTo(i.super),e.top.equalTo(i.super.safeAreaBottom).offset(-t.tabBarHeight),e.bottom.equalTo(i.super)},views:[UIKit.blurBox({id:this.#r}),{type:\"stack\",layout:$layout.fillSafeArea,props:{axis:$stackViewAxis.horizontal,distribution:$stackViewDistribution.fillEqually,spacing:0,stack:{views:this.#g()}}},UIKit.separatorLine({id:this.#u},UIKit.align.top)],events:{ready:()=>this.initBackground()}};return View.createFromViews(this.#y().concat(this.#i?.definition??[],e))}},PageView=class extends View{constructor(t={}){super(t),this.activeStatus=!0}show(){$(this.props.id).hidden=!1,this.activeStatus=!0}hide(){$(this.props.id).hidden=!0,this.activeStatus=!1}setHorizontalSafeArea(t){return this.horizontalSafeArea=t,this}#t(t,e){t.top.bottom.equalTo(e.super),this.horizontalSafeArea?t.left.right.equalTo(e.super.safeArea):t.left.right.equalTo(e.super)}getView(){return this.layout=this.#t,this.props.clipsToBounds=!0,this.props.hidden=!this.activeStatus,super.getView()}},WebDAV=class extends Request{#t;user;password;#e;namespace=\"JSBox.WebDAV\";lockTokenCacheKey=this.namespace+\".lockToken\";get host(){return this.#t}set host(t){for(this.#t=t.trim();this.#t.endsWith(\"/\");)this.#t=this.#t.substring(0,this.#t.length-1);this.#t.startsWith(\"http\")||(this.#t=\"http://\"+this.#t)}get basepath(){return this.#e}set basepath(t){for(this.#e=t.trim();this.#e.endsWith(\"/\");)this.#e=this.#e.substring(0,this.#e.length-1);for(;this.#e.startsWith(\"/\");)this.#e=this.#e.substring(1);this.#e=\"/\"+this.#e}constructor({host:t,user:e,password:i,basepath:s=\"\"}={}){super((t=>console.log(t))),this.host=t,this.user=e,this.password=i,this.basepath=s}#i(t){return t=(t=t.trim()).startsWith(\"/\")?t:\"/\"+t,this.basepath+t}async request(t,e,i=null,s={}){return s=Object.assign({\"Content-Type\":\"text/xml; charset=UTF-8\",Authorization:\"Basic \"+$text.base64Encode(`${this.user}:${this.password}`)},s),await super.request(this.host+this.#i(t),e,i,s)}async allow(t){let e=await this.request(t,Request.method.options);return(e.response.headers?.allow??e.response.headers?.Allow)?.split(\",\").map((t=>t.trim().toUpperCase()))??[]}async propfind(t,e=[],i=0){Array.isArray(e)||(e=[e]);let s=`${e.map((t=>``)).join()}`,r=await this.request(t,\"PROPFIND\",s,{Depth:i});return $xml.parse({string:r.data})}async propfindAll(t,e=0){let i=await this.request(t,\"PROPFIND\",'',{Depth:e});return $xml.parse({string:i.data})}async ls(t,e=1){let i=await this.request(t,\"PROPFIND\",null,{Depth:e});return $xml.parse({string:i.data})}async exists(t){try{return(await this.allow(t)).includes(Request.method.get)?await this.request(t,Request.method.head):await this.ls(t,0),!0}catch(t){if(404===t?.code)return!1;throw t}}async mkdir(t){return await this.request(t,\"MKCOL\")}async get(t){return await this.request(t,Request.method.get,null)}async put(t,e,{withLock:i=!0,waitInterval:s=2,maxTry:r=3}={}){let n={};for(;await this.isLocked(t);){if(--r<=0)throw new Error(\"Resource Locked\");await $wait(s)}if(i)try{await this.lock(t),n.If=`(${this.#r(t)})`}catch(t){if(404!==t.code)throw t;i=!1}await this.request(t,Request.method.put,e,n),i&&await this.unlock(t)}async delete(t){if(!t)throw new Error(\"path empty\");return await this.request(t,Request.method.delete)}#s(t,e){let i=$cache.get(this.lockTokenCacheKey)??{};i[t]=e,$cache.set(this.lockTokenCacheKey,i)}#r(t){return($cache.get(this.lockTokenCacheKey)??{})[t]}async isSupportLock(t){try{return!!(await this.propfind(t,\"supportedlock\")).rootElement.firstChild({xPath:\"//D:response/D:propstat/D:prop/D:supportedlock/D:lockentry\"}).firstChild({xPath:\"//D:locktype/D:write\"})}catch(t){if(404!==t.code)return!1;throw t}}async lock(t,{infinity:e=!1,timeout:i=\"Second-10\"}={}){if(!await this.isSupportLock(t))throw new Error(\"Your WebDAV service does not support the `LOCK` method.\");let s=`${this.namespace}`,r=await this.request(t,\"LOCK\",s,{Timeout:i,Depth:e?\"infinity\":0}),n=r.response.headers[\"lock-token\"]??r.response.headers[\"Lock-Token\"];return this.#s(t,n),$xml.parse({string:r.data})}async isLocked(t){try{let e=(await this.propfind(t,\"lockdiscovery\")).rootElement;if(e.firstChild({xPath:\"//D:response/D:propstat/D:status\"}).string.includes(\"404\"))await this.lock(t,{timeout:\"Second-0\"});else{let i=e.firstChild({xPath:\"//D:response/D:propstat/D:prop/D:lockdiscovery\"}).children()??[];for(let e=0;e10240){const t=n.join(this.logPath,`caio.${Date.now()}.log`);this.fileStorage.move(this.logFilePath,t)}}t instanceof Error&&(t=`${t}\\n${t.stack}`),super.error(t),this.logger.error(t)}initComponents(){this.clips=new c(this),this.actionManager=new d(this),this.fileManager=new o}}t.exports={AppKernelBase:p}})),parcelRequire.register(\"2EAPF\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingInfo,r=i.SettingScript,n=i.SettingTab,a=parcelRequire(\"3dE3D\"),o=parcelRequire(\"2jPf3\"),l=parcelRequire(\"iN4Y6\"),h=parcelRequire(\"knZRr\"),c=parcelRequire(\"aziQd\"),d=parcelRequire(\"5xoIG\"),p=parcelRequire(\"fEWdA\");const u={items:[a,o,l,h,c,d]},g={items:[new n({icon:[\"rectangle.topthird.inset.filled\",\"#A569BD\"],title:\"DISPLAY_MODE\",key:\"mainUIDisplayMode\",value:0}).with({items:[\"CLASSIC\",\"MODERN\"]}),new r({icon:[\"folder.fill\",\"#FF9900\"],title:\"FILE_MANAGEMENT\"}).with({script:\"this.method.fileManager\"})]},y={items:[p]},m={items:[new s({icon:[\"/assets/icon/github.com.jpeg\",\"white\"],title:\"Github\",value:[\"ipuppet/CAIO\",\"https://github.com/ipuppet/CAIO\"]}),new s({icon:[\"/assets/icon/telegram.png\",\"white\"],title:\"Telegram\",value:[\"JSBoxTG\",\"https://t.me/JSBoxTG\"]}),new s({icon:[\"person.fill\",\"#FF9900\"],title:\"AUTHOR\",value:[\"ipuppet\",\"https://blog.ultagic.com\"]}),new r({icon:\"arrow.2.circlepath\",title:\"CHECK_UPDATE\"}).with({script:\"this.method.checkUpdate\"}),new r({icon:[\"book.fill\",\"#A569BD\"],title:\"README\"}).with({script:\"this.method.readme\"})]};t.exports=[u,g,y,m]})),parcelRequire.register(\"3dE3D\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingSwitch,r=i.SettingScript,n=i.SettingNumber,a=i.SettingPush,o=i.SettingChild;t.exports=new o({icon:[\"doc.on.clipboard\",\"#FFCC66\"],title:\"CLIPS\"}).with({children:[{items:[new s({icon:[\"link\",\"#FF6633\"],title:\"UNIVERSAL_CLIPBOARD\",key:\"clipboard.universal\",value:!0}),new r({icon:[\"cursorarrow.rays\",\"#FF6633\"],title:\"Tips\"}).with({script:\"$ui.alert({title:$l10n('UNIVERSAL_CLIPBOARD'),message:$l10n('UNIVERSAL_CLIPBOARD_TIPS')})\"})]},{items:[new a({icon:[\"trash\",\"red\"],title:\"RECYCLE_BIN\",key:\"clipboard.recycleBin\"}).with({view:\"this.method.recycleBin\"})]},{items:[new n({icon:[\"text.alignleft\",\"#FFCC66\"],title:\"MAX_ITEM_LENGTH\",key:\"clipboard.maxItemLength\",value:100}),new s({icon:[\"square.and.arrow.down.on.square\",\"#FF6633\"],title:\"AUTO_SAVE\",key:\"clipboard.autoSave\",value:!0})]},{items:[new r({icon:\"square.and.arrow.up\",title:\"EXPORT\"}).with({script:\"this.method.exportClipboard\"}),new r({icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\"}).with({script:\"this.method.importClipboard\"})]},{items:[new r({icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_DATABASE\"}).with({script:\"this.method.rebuildDatabase\"}),new r({icon:[\"trash\",\"red\"],title:\"DELETE_ALL_DATA\"}).with({script:\"this.method.deleteAllData\"})]}]})})),parcelRequire.register(\"2jPf3\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingScript,r=i.SettingChild;t.exports=new r({icon:[\"bolt.circle\",\"#FF6633\"],title:\"ACTIONS\"}).with({children:[{items:[new s({icon:[\"bolt.circle\",\"#FF6633\"],title:\"IMPORT_EXAMPLE_ACTIONS\",value:\"this.method.importExampleAction\"}).with({script:\"this.method.importExampleAction\"})]},{items:[new s({icon:\"square.and.arrow.up\",title:\"EXPORT\"}).with({script:\"this.method.exportAction\"}),new s({icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\"}).with({script:\"this.method.importAction\"})]},{items:[new s({icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_ACTION_DATABASE\"}).with({script:\"this.method.rebuildAction\"})]}]})})),parcelRequire.register(\"iN4Y6\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingSwitch,r=i.SettingInput,n=i.SettingNumber,a=i.SettingChild;t.exports=new a({icon:[\"pencil.circle\",\"#CC0099\"],title:\"EDITOR\"}).with({children:[{title:\"CLIPS\",items:[new n({icon:[\"wand.and.stars\",\"#FF6633\"],title:\"TEXT_INSETS\",key:\"editor.text.insets\",value:300})]},{title:\"CODE\",items:[new s({icon:[\"list.number\",\"#6699CC\"],title:\"SHOW_LINE_NUMBER\",key:\"editor.code.lineNumbers\",value:!1}),new r({icon:[\"wand.and.stars\",\"#FF6633\"],title:\"LIGHT_MODE_THEME\",key:\"editor.code.lightTheme\",value:\"atom-one-light\"}),new r({icon:[\"wand.and.stars\",\"#FF6633\"],title:\"DARK_MODE_THEME\",key:\"editor.code.darkTheme\",value:\"atom-one-dark\"})]}]})})),parcelRequire.register(\"knZRr\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingSwitch,r=i.SettingStepper,n=i.SettingScript,a=i.SettingTab,o=i.SettingNumber,l=i.SettingPush,h=i.SettingChild,c=i.SettingImage;t.exports=new h({icon:[\"keyboard\",\"#a2a5a6\"],title:\"KEYBOARD\"}).with({children:[{items:[new l({icon:\"rectangle.3.offgrid.fill\",title:\"PREVIEW\",key:\"keyboard.previewAndHeight\",value:267}).with({view:\"this.method.previewKeyboard\"})]},{items:[new a({icon:[\"rectangle.topthird.inset.filled\",\"#A569BD\"],title:\"DISPLAY_MODE\",key:\"keyboard.displayMode\",value:0}).with({items:[\"list\",\"matrix\"]}),new s({icon:[\"checkerboard.rectangle\",\"#1899c4\"],title:\"USE_BLUR\",key:\"keyboard.blur\",value:!1}),new c({icon:[\"photo\",\"#FFCC66\"],title:\"BACKGROUND_IMAGE\",key:\"keyboard.background.image\"})]},{items:[new s({icon:[\"globe\",\"#1899c4\"],title:\"SWITCH_AFTER_INSERT\",key:\"keyboard.switchAfterInsert\",value:!1}),new s({icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE\",key:\"keyboard.tapticEngine\",value:!0}),new r({icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE_LEVEL\",key:\"keyboard.tapticEngineLevel\",value:1}).with({min:0,max:2}),new n({icon:\"paperplane\",title:\"QUICK_START_SCRIPTS\"}).with({script:\"this.method.setKeyboardQuickStart\"})]},{items:[new o({icon:[\"rays\",\"#FFCC33\"],title:\"DELETE_DELAY\",key:\"keyboard.deleteDelay\",value:.05})]}]})})),parcelRequire.register(\"aziQd\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingScript,r=i.SettingMenu,n=i.SettingChild;t.exports=new n({icon:[\"rectangle.3.offgrid.fill\",\"#1899c4\"],title:\"WIDGET\"}).with({children:[{items:[new s({icon:\"rectangle.3.offgrid.fill\",title:\"PREVIEW\"}).with({script:\"this.method.previewWidget\"})]},{title:\"2x2\",items:[new r({icon:\"link\",title:\"CLICK_ACTION\",key:\"widget.2x2.widgetURL\",value:2}).with({pullDown:!0,items:[\"ADD\",\"ACTIONS\",\"CLIPS\"]})]}]})})),parcelRequire.register(\"5xoIG\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingScript,r=i.SettingChild;t.exports=new r({icon:[\"filemenu.and.selection\",\"#ebcc34\"],title:\"TODAY_WIDGET\"}).with({children:[{items:[new s({icon:\"rectangle.3.offgrid.fill\",title:\"PREVIEW\"}).with({script:\"this.method.previewTodayWidget\"})]},{items:[new s({icon:\"bolt.circle\",title:\"ACTIONS\"}).with({script:\"this.method.setTodayWidgetActions\"})]}]})})),parcelRequire.register(\"fEWdA\",(function(t,e){var i=parcelRequire(\"gxpqj\").SettingChild,s=parcelRequire(\"fiqsI\");t.exports=new i({icon:\"wrench.and.screwdriver\",title:\"EXPERIMENTAL\"}).with({children:[{items:[s]}]})})),parcelRequire.register(\"fiqsI\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.SettingSwitch,r=i.SettingInput,n=i.SettingChild;t.exports=new n({icon:[\"cloud\",\"#FF9900\"],title:\"WebDAV\"}).with({children:[{items:[new s({icon:[\"cloud\",\"#FF9900\"],title:\"WebDAV\",key:\"webdav.status\",value:!1})]},{items:[new r({icon:\"link\",title:\"HOST\",key:\"webdav.host\",value:\"\"}),new r({icon:\"person\",title:\"USER\",type:\"input\",key:\"webdav.user\",value:\"\"}),new r({icon:\"person.badge.key\",title:\"PASSWORD\",type:\"input\",key:\"webdav.password\",value:\"\"}),new r({icon:\"link\",title:\"BASEPATH\",type:\"input\",key:\"webdav.basepath\",value:\"\"})]}]})})),parcelRequire.register(\"jEwwi\",(function(t,e){var i=parcelRequire(\"gxpqj\").UIKit,s=parcelRequire(\"7GYtH\");class r{fileStorage;fsPath;imagePath;#f;static isImage(t=\"\"){return t?.startsWith(\"@image=\")}static pathToKey(t){return`@image=${t=JSON.stringify(t)}`}static keyToPath(t){if(r.isImage(t)){return JSON.parse(t.slice(7))}return!1}constructor({uuid:t,section:e,text:i=\"\",md5:s,tag:r=null,prev:n=null,next:a=null}={}){if(!t)throw new Error(\"Clip create faild: uuid undefined\");if(!e)throw new Error(\"Clip create faild: section undefined\");this.uuid=t,this.section=e,this.text=i,this.md5=s??$text.MD5(this.text),this.tag=r,this.prev=n,this.next=a}get text(){return this.#f}set text(t){this.#f=t,r.isImage(t)&&this.#w(r.keyToPath(t))}get hasTag(){return null!==this.tag}get image(){return r.isImage(this.text)}get imageOriginal(){return this.#b(\"original\")}get imagePreview(){return this.#b(\"preview\")}#b(t){if(this.image&&this.fileStorage.exists(this.fsPath[t]))return this.fileStorage.readSync(this.fsPath[t])}#w(t){this.fileStorage&&(this.fsPath=t,this.imagePath={original:this.fileStorage.filePath(t.original),preview:this.fileStorage.filePath(t.preview)})}}class n{sqlite;constructor(t){this.kernel=t,this.dbName=\"CAIO.db\",this.localDb=`/${this.dbName}`;const e=\"/image\";this.imagePath={base:e,original:`${e}/original`,preview:`${e}/preview`},this.tempPath=\"/temp\",this.tempDbFile=`${this.tempPath}/${this.dbName}`,this.tempImagePath=`${this.tempPath}/image`,this.exportFileName=\"CAIO.zip\",this.initWebdavSync(),this.init()}async initWebdavSync(){if(this.kernel.setting.get(\"webdav.status\"))try{this.webdavSync=new s({kernel:this.kernel,host:this.kernel.setting.get(\"webdav.host\"),user:this.kernel.setting.get(\"webdav.user\"),password:this.kernel.setting.get(\"webdav.password\"),basepath:this.kernel.setting.get(\"webdav.basepath\")}),await this.webdavSync.init()}catch(t){throw this.kernel.error(t),t}}needUpload(){this.kernel.setting.get(\"webdav.status\")&&this.webdavSync.needUpload()}sync(){this.kernel.setting.get(\"webdav.status\")&&this.webdavSync.sync()}init(){this.sqlite&&this.sqlite.close(),this.sqlite=$sqlite.open(this.kernel.fileStorage.filePath(this.localDb)),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS clips(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS favorite(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS tag(uuid TEXT PRIMARY KEY NOT NULL, tag TEXT)\"),this.kernel.print(\"init database\")}rebuild(){const t=this.tempPath+\"/rebuild.db\";this.kernel.fileStorage.delete(t);const e=new n(this.kernel);e.localDb=t,e.init();const i=(t,i)=>{const s=[];t.forEach((t=>{const n=new r({uuid:t.uuid,text:t.text,section:t.section,md5:t.md5,tag:t.tag,prev:null,next:s[0]?.uuid??null});e.beginTransaction();try{e.insert(n),n.next&&(s[0].prev=n.uuid,s[0].section=i,e.update(s[0])),e.commit(),s.unshift(n)}catch(t){throw e.rollback(),this.kernel.error(t),t}}))};[\"clips\",\"favorite\"].map((t=>{let e=this.all(t);try{const t=this.sort(e);if(t.length>e.length)throw new Error;e=t.reverse()}catch{}i(e,t)}));const s=this.sqlite.query(\"SELECT * FROM tag\");this.parseTag(s).forEach((t=>{e.beginTransaction();try{e.setTag(t.uuid,t.tag),e.commit()}catch(t){throw e.rollback(),this.kernel.error(t),t}})),this.kernel.fileStorage.copy(t,this.localDb),this.needUpload(),this.kernel.print(\"database rebuild\")}deleteAllData(){this.kernel.fileStorage.delete(this.imagePath.base),this.kernel.fileStorage.delete(this.localDb),this.needUpload(),this.kernel.print(\"delete all database\")}clearTemp(){this.kernel.fileStorage.delete(this.tempPath)}async export(t){this.clearTemp(),this.kernel.fileStorage.copy(this.localDb,this.tempDbFile),this.kernel.fileStorage.copy(this.imagePath.base,this.tempImagePath);const e=this.tempPath+\"/\"+this.exportFileName;await $archiver.zip({directory:this.kernel.fileStorage.filePath(this.tempPath),dest:this.kernel.fileStorage.filePath(e)}),$share.sheet({items:[{name:this.exportFileName,data:$data({path:this.kernel.fileStorage.filePath(e)})}],handler:i=>{this.kernel.fileStorage.delete(e),t(i)}})}async import(t){if(\"db\"===t.fileName.slice(-2)){if(!this.kernel.fileStorage.writeSync(this.localDb,t))throw new Error(\"WRITE_DB_FILE_FAILED\")}else if(\"zip\"===t.fileName.slice(-3)){if(!await $archiver.unzip({file:t,dest:this.kernel.fileStorage.filePath(this.tempPath)}))throw new Error(\"UNZIP_FAILED\");this.kernel.fileStorage.move(this.tempDbFile,this.localDb),this.kernel.fileStorage.move(this.tempImagePath,this.imagePath.base)}this.webdavSync&&this.webdavSync.updateLocalTimestamp()}sort(t,e=9e3){const i={};let s=0,r=null;t.forEach((t=>{i[t.uuid]=t,null===t.prev&&(r=t.uuid),s++}));const n=[];if(s>0)try{let t=i[r];for(;null!==t.next&&e>0;)e--,n.push(t),t=i[t.next];n.push(t)}catch(t){throw\"Unable to sort: \"+t}return n}replaceString(t){return[\"\\\\\",'\"',\"'\",\"%\",\"-\",\"_\",\";\"].forEach((e=>{t=t.replaceAll(e,`\\\\${e}`)})),t}parse(t){const e=t.result,i=t.error,s=[];try{if(null!==i)throw new Error(`Code [${i.code}] ${i.domain} ${i.localizedDescription}`);for(;e.next();){const t=e.get(\"text\"),i=new r({uuid:e.get(\"uuid\"),section:e.get(\"section\"),md5:e.get(\"md5\"),tag:e.get(\"tag\"),prev:e.get(\"prev\"),next:e.get(\"next\")});r.isImage(t)&&(i.fileStorage=this.kernel.fileStorage),i.text=t,s.push(i)}}catch(i){throw i}finally{e.close()}return s}parseTag(t){if(null!==t.error)throw t.error;const e=[];for(;t.result.next();)e.push({uuid:t.result.get(\"uuid\"),tag:t.result.get(\"tag\")});return t.result.close(),e}beginTransaction(){this.sqlite.beginTransaction()}commit(){this.sqlite.commit()}rollback(){this.sqlite.rollback()}getByUUID(t=\"\"){const e=this.sqlite.query({sql:\"\\n SELECT a.*, tag from\\n (SELECT *, 'clips' AS section FROM clips WHERE uuid = ?\\n UNION\\n SELECT *, 'favorite' AS section FROM favorite WHERE uuid = ?) a\\n LEFT JOIN tag ON a.uuid = tag.uuid\\n \",args:[t,t]});return this.parse(e)[0]}getByMD5(t=\"\"){const e=this.sqlite.query({sql:\"\\n SELECT a.*, tag from\\n (SELECT *, 'clips' AS section FROM clips WHERE md5 = ?\\n UNION\\n SELECT *, 'favorite' AS section FROM favorite WHERE md5 = ?) a\\n LEFT JOIN tag ON a.uuid = tag.uuid\\n \",args:[t,t]});return this.parse(e)[0]}async search(t){const e=(await $text.tokenize({text:t})).map((t=>this.replaceString(t))),i=`%${e.join(\"%\")}%`,s=this.sqlite.query({sql:`\\n SELECT a.*, tag from\\n (SELECT *, 'clips' AS section FROM clips WHERE text like \"${i}\"\\n UNION\\n SELECT *, 'favorite' AS section FROM favorite WHERE text like \"${i}\") a\\n LEFT JOIN tag ON a.uuid = tag.uuid\\n `});return{result:this.parse(s),keyword:e}}searchByTag(t){t.startsWith(\"#\")&&(t=t.substring(1));const e=this.sqlite.query({sql:`SELECT * FROM tag WHERE tag like \"%${this.replaceString(t)}%\"`}),i=this.parseTag(e),s=[];return i.forEach((t=>{s.push(this.getByUUID(t.uuid))})),{result:s,keyword:[t]}}deleteTable(t){const e=this.sqlite.update(`DELETE FROM ${t}`);if(!e.result)throw e.error;this.needUpload(),this.kernel.print(`delete table ${t}`)}all(t){const e=this.sqlite.query(`SELECT ${t}.*, tag, '${t}' AS section FROM ${t} LEFT JOIN tag ON ${t}.uuid = tag.uuid`);return this.parse(e)}saveImage(t){if(\"object\"==typeof t){const e=$text.uuid,s={original:`${this.imagePath.original}/${e}.png`,preview:`${this.imagePath.preview}/${e}.jpg`};return this.kernel.fileStorage.write(s.original,t.png),this.kernel.fileStorage.write(s.preview,i.compressImage(t).jpg(.8)),r.pathToKey(s)}throw new Error(\"saveImageError: image not an object\")}insert(t){const e=this.sqlite.update({sql:`INSERT INTO ${t.section} (uuid, text, md5, prev, next) values (?, ?, ?, ?, ?)`,args:[t.uuid,t.text,$text.MD5(t.text),t.prev,t.next]});if(!e.result)throw e.error;this.needUpload()}update(t){if(Object.keys(t).length<4||\"string\"!=typeof t.uuid)return;const e=this.sqlite.update({sql:`UPDATE ${t.section} SET text = ?, md5 = ?, prev = ?, next = ? WHERE uuid = ?`,args:[t.text,$text.MD5(t.text),t.prev,t.next,t.uuid]});if(!e.result)throw e.error;this.needUpload()}updateText(t,e,i){if(\"string\"!=typeof e)return;const s=this.sqlite.update({sql:`UPDATE ${t} SET text = ?, md5 = ? WHERE uuid = ?`,args:[i,$text.MD5(i),e]});if(!s.result)throw s.error;this.needUpload()}delete(t,e){this.getByUUID(e);const i=this.sqlite.update({sql:`DELETE FROM ${t} WHERE uuid = ?`,args:[e]});if(!i.result)throw i.error;this.needUpload()}isEmpty(){const t=this.sqlite.query(\"SELECT * FROM clips limit 1\").result,e=this.sqlite.query(\"SELECT * FROM favorite limit 1\").result;return t.next(),e.next(),t.isNull(0)&&e.isNull(0)}allImageFromDb(t=!0){const e=this.sqlite.query(\"\\n SELECT a.* from\\n (SELECT *, 'clips' AS section FROM clips WHERE text like \\\"@image=%\\\"\\n UNION\\n SELECT *, 'favorite' AS section FROM favorite WHERE text like \\\"@image=%\\\") a\\n LEFT JOIN tag ON a.uuid = tag.uuid\\n \"),i=this.parse(e)?.map((t=>{if(t.image){const e=t.fsPath;return e.preview=e.preview.replaceAll(this.imagePath.preview,\"\"),e.preview.startsWith(\"/\")&&(e.preview=e.preview.substring(1)),e.original=e.original.replaceAll(this.imagePath.original,\"\"),e.original.startsWith(\"/\")&&(e.original=e.original.substring(1)),e}})),s=[],r=[];return t||i.forEach((t=>{s.push(t.original),r.push(t.preview)})),t?i:{original:s,preview:r}}localImagesFromFile(){return{original:this.kernel.fileStorage.readSync(this.kernel.storage.imagePath.original),preview:this.kernel.fileStorage.readSync(this.kernel.storage.imagePath.preview)}}setTag(t,e){const i=this.sqlite.update({sql:\"INSERT OR REPLACE INTO tag (uuid, tag) values (?, ?)\",args:[t,e]});if(!i.result)throw i.error;this.needUpload()}deleteTag(t){const e=this.sqlite.update({sql:\"DELETE FROM tag WHERE uuid = ?\",args:[t]});if(!e.result)throw e.error;this.needUpload()}}t.exports={Clip:r,Storage:n}})),parcelRequire.register(\"7GYtH\",(function(t,e){var i=parcelRequire(\"gxpqj\").FileStorage,s=parcelRequire(\"2VUvw\");class r extends s{localSyncDataPath=\"/sync.json\";webdavSyncDataPath=\"/sync.json\";webdavDbPath=\"/CAIO.db\";webdavImagePath=\"/image\";get localDb(){return $data({path:this.kernel.fileStorage.filePath(this.kernel.storage.localDb)})}set localDb(t){this.kernel.fileStorage.writeSync(this.kernel.storage.localDb,t)}get localImagePath(){return this.kernel.fileStorage.filePath(\"/image\")}async init(){await super.init(),await this.initImagePath(),this.sync()}async initImagePath(){if(!await this.webdav.exists(this.webdavImagePath)){await this.webdav.mkdir(this.webdavImagePath);[\"/image/original\",\"/image/preview\"].map((async t=>{await this.webdav.exists(t)||await this.webdav.mkdir(t)}))}}isNew(){return this.kernel.storage.isEmpty()}async webdavImages(){const t=(await this.webdav.ls(this.webdavImagePath,\"infinity\")).rootElement,e=t.firstChild({xPath:\"//D:response/D:href\"}).string,i=[],s=[];return t.children().map((t=>{const r=t.firstChild({tag:\"href\"})?.string?.replaceAll(e,\"\");r.endsWith(\"/\")||(r.startsWith(\"original\")?i.push(r.substring(9)):r.startsWith(\"preview\")&&s.push(r.substring(8)))})),{original:i,preview:s}}async syncImages(){const t=await this.webdavImages(),e=this.kernel.storage.allImageFromDb(!1),s=this.kernel.storage.localImagesFromFile();Object.keys(s).map((t=>{s[t].forEach((async s=>{if(!e[t].includes(s)){const e=i.join(this.kernel.storage.imagePath[t],s);this.kernel.fileStorage.delete(e),this.kernel.print(`Local image deleted: ${e}`)}}))})),Object.keys(e).map((s=>{e[s].forEach((async e=>{const r=i.join(this.webdavImagePath,s,e),n=i.join(this.kernel.storage.imagePath[s],e);if(t[s].includes(e)&&!this.kernel.fileStorage.exists(n)){const t=await this.webdav.get(r);this.kernel.fileStorage.writeSync(n,t.rawData),this.kernel.print(`WebDAV image downloaded: ${n}`)}else if(!t[s].includes(e)){const t=this.kernel.fileStorage.readSync(n);await this.webdav.put(r,t),this.kernel.print(`WebDAV image uploaded: ${r}`)}}))})),Object.keys(t).map((s=>{t[s].forEach((async t=>{if(!e[s].includes(t)){const e=i.join(this.webdavImagePath,s,t);await this.webdav.delete(e),this.kernel.print(`WebDAV image deleted: ${e}`)}}))}))}async pull(){this.webdav.clearNSURLCache();let t=await this.webdav.get(this.webdavDbPath);this.localDb=t.rawData,await this.downloadSyncData(),this.kernel.storage.init(),await this.syncImages(),this.kernel.print(\"clip webdav sync: pulled\")}async push(){await this.webdav.put(this.webdavDbPath,this.localDb),await this.uploadSyncData(),await this.syncImages(),this.kernel.print(\"clip webdav sync: pushed\")}notify(t){$app.notify({name:\"clipSyncStatus\",object:t})}async#$(){let t=!1;try{const e=await this.nextSyncStep();if(this.kernel.print(`clip nextSyncStep: ${s.stepName[e]}`),e===s.step.needPush||e===s.step.init)await this.push();else if(e===s.step.needPull)await this.pull(),t=!0;else{if(e!==s.step.conflict)return void this.notify({status:s.status.nochange});await this.conflict($l10n(\"CLIPS\"))===r.conflictKeep.webdav&&(t=!0)}}catch(t){throw this.notify({status:s.status.fail,error:t}),this.kernel.error(\"clip sync error\"),this.kernel.error(t),t}finally{this.notify({status:s.status.success,updateList:t})}}sync(){this.notify({status:s.status.syncing,animate:!0}),this.syncTimer&&this.syncTimer.cancel(),this.syncTimer=$delay(.5,(()=>{this.#$()}))}needUpload(){this.notify({status:s.status.syncing}),this.uploadTimer&&this.uploadTimer.cancel(),this.uploadTimer=$delay(.5,(()=>{this.updateLocalTimestamp(),this.#$()}))}}t.exports=r})),parcelRequire.register(\"2VUvw\",(function(t,e){var i=parcelRequire(\"gxpqj\").WebDAV;class s{static step={init:-1,stay:0,needPush:2,needPull:3,conflict:4};static stepName=(()=>{const t={};return Object.keys(s.step).map((e=>{const i=s.step[e];t[i]=String(e)})),t})();static status={syncing:0,success:1,nochange:2,fail:3};static conflictKeep={local:0,webdav:1,cancel:2};static initLocalTimestamp=0;webdav;kernel;localSyncDataPath;webdavSyncDataPath;constructor({host:t,user:e,password:s,basepath:r,kernel:n}={}){this.kernel=n,this.webdav=new i({host:t,user:e,password:s,basepath:r}),this.webdav.namespace=\"JSBox.CAIO\"}get mustLocalSyncDataPath(){if(!this.localSyncDataPath)throw new Error(\"localSyncDataPath not set\");return this.localSyncDataPath}get mustWebdavSyncDataPath(){if(!this.webdavSyncDataPath)throw new Error(\"webdavSyncDataPath not set\");return this.webdavSyncDataPath}get localSyncData(){return this.kernel.fileStorage.exists(this.mustLocalSyncDataPath)||(this.localSyncData={timestamp:s.initLocalTimestamp}),this.kernel.fileStorage.readSync(this.mustLocalSyncDataPath)}set localSyncData(t){this.kernel.fileStorage.writeSync(this.mustLocalSyncDataPath,$data({string:JSON.stringify(t)}))}get localTimestamp(){return Number(JSON.parse(this.localSyncData.string).timestamp)}set localTimestamp(t){this.localSyncData=Object.assign(this.localSyncData,{timestamp:t})}async init(t=this.webdav.basepath){const e=new i({host:this.webdav.host,user:this.webdav.user,password:this.webdav.password,basepath:t});if(!await e.exists(\"/\"))try{await e.mkdir(\"/\")}catch(e){if(409===e.code)return await this.init(t.substring(0,t.lastIndexOf(\"/\"))),void await this.init(t);throw e}}isNew(){return!1}async webdavSyncData(){this.webdav.clearNSURLCache();let t=(await this.webdav.get(this.mustWebdavSyncDataPath)).data;return\"string\"==typeof t&&(t=JSON.parse(t)),t}async webdavTimestamp(){try{let t=await this.webdavSyncData();return Number(t.timestamp)}catch(t){if(404===t.code)return s.step.init;throw t}}updateLocalTimestamp(){this.localTimestamp!==s.initLocalTimestamp&&(this.localTimestamp=Date.now())}async uploadSyncData(){this.localTimestamp===s.initLocalTimestamp&&(this.localTimestamp=Date.now()),await this.webdav.put(this.mustWebdavSyncDataPath,this.localSyncData)}async downloadSyncData(){this.localSyncData=await this.webdavSyncData()}async nextSyncStep(){const t=this.localTimestamp,e=await this.webdavTimestamp();return e===s.step.init?s.step.init:e===s.initLocalTimestamp?(this.localTimestamp=Date.now(),await this.push(),s.step.stay):t>e?s.step.needPush:t===e?s.step.stay:t{this.updateList(!0),$delay(.5,(()=>{this.readClipboard()}))},clipSyncStatus:t=>{const e=$(this.listId);t.status===w.status.success?(t.updateList&&this.updateList(!0),e&&e.endRefreshing()):t.status===w.status.syncing&&t.animate&&e&&e.beginRefreshing()}})}listReady(){this.updateList(),r.isTaio||($delay(.5,(()=>{if($context.query.copy){const t=$context.query.copy;this.setCopied(t),$ui.success($l10n(\"COPIED\"))}else $context.query.add?this.getAddTextView():$context.query.actions&&(this.kernel.isUseJsboxNav?this.kernel.actionManager.present():this.kernel.tabBarController.switchPageTo(\"actions\"))})),$delay(.5,(()=>{this.readClipboard()})),this.appListen())}updateList(t=!1){t&&this.setNeedReload(),$(this.listId).data=this.clips.map((t=>this.lineData(t,this.copied.uuid===t.uuid))),this.updateListBackground()}updateListBackground(){const t=$(this.listId+\"-empty-background\");t&&(t.hidden=this.clips.length>0)}updateCopied(t=null){const e=this.copied?.uuid;$delay(.3,(()=>{try{const i=$(this.listId),s=i.cell($indexPath(0,this.getIndexByUUID(e)));s&&(s.get(\"copied\").hidden=!0),t&&(i.cell($indexPath(0,this.getIndexByUUID(t.uuid))).get(\"copied\").hidden=!1)}catch(t){this.kernel.error(\"set copied error\"),this.kernel.error(t)}})),t?Object.assign(this.copied,t):this.copied={},this.kernel.print(`this.copied: ${JSON.stringify(this.copied,null,2)}`),$cache.set(\"clips.copied\",this.copied)}setCopied(t){if(!t||t===this.copied.uuid&&this.tabIndex===this.copied?.tabIndex)return;let e={};this.copied.uuid!==t&&(e=this.getClip(t)??{}),e.tabIndex=this.tabIndex,this.updateCopied(e),this.setClipboardText(e.text)}clearCopied(){const t=$(this.listId).cell($indexPath(0,this.getIndexByUUID(this.copied.uuid)));t&&(t.get(\"copied\").hidden=!0),this.updateCopied(null)}async readClipboard(t=!1){if(t||this.kernel.setting.get(\"clipboard.autoSave\")){if(this.kernel.print(\"read clipboard\"),!t&&!this.isChanged)return;if($clipboard.images?.length>0)return t?(await $wait(.1),void $clipboard.images.forEach((t=>{this.add(t)}))):void 0;const e=$clipboard.text;if(!e||\"\"===e)return void this.clearCopied();if(this.getClip(this.copied?.uuid)?.text===e)return void(t&&$ui.toast($l10n(\"CLIPBOARD_NO_CHANGE\")));if(this.exists(e)){const t=this.kernel.storage.getByMD5($text.MD5(e));this.switchTab(this.tabItemsMap[t.section],!0),this.setCopied(t.uuid)}else{this.switchTab(1,!0);const t=this.add(e);this.setCopied(t.uuid)}}}add(t){try{const e=super.addItem(t);return this.updateListBackground(),$(this.listId).insert({indexPath:$indexPath(0,0),value:this.lineData(e)}),e}catch(t){$ui.alert(t)}}delete(t){try{super.deleteItem(t),this.copied.uuid===t&&(this.updateCopied(null),$clipboard.clear()),this.updateListBackground()}catch(t){$ui.alert(t)}}update(t,e){try{return super.updateItem(t,e),this.updateList(),e===this.copied.uuid&&this.setClipboardText(t),!0}catch(t){return $ui.alert(t),!1}}move(t,e,i=!0){if(t!==e)try{if(super.moveItem(t,e),!i)return;const s=$(this.listId);t{i.text?$share.sheet(i.text):$ui.warning($l10n(\"NONE\"))}}];if(this.kernel.isUseJsboxNav)i.uikitPush(t,(t=>e(t)),s);else{const r=i.getNavigationView(t,(t=>e(t)),s);this.viewController.push(r)}}getAddTextView(){this.edit(\"\",(t=>{\"\"!==t&&this.add(t)}))}menuItems(t=!1){const e=[{inline:!0,items:[{title:$l10n(\"TAG\"),symbol:\"tag\",handler:(t,e)=>{const i=this.getByIndex(e);$input.text({placeholder:$l10n(\"ADD_TAG\"),text:i.tag,handler:t=>{(t=t.trim()).length>0?this.kernel.storage.setTag(i.uuid,t):this.kernel.storage.deleteTag(i.uuid),this.updateList(!0)}})}}]},{inline:!0,items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:(t,e)=>{const i=this.getByIndex(e);$share.sheet(i.image?i.imageOriginal:i.text)}},{title:$l10n(\"COPY\"),symbol:\"square.on.square\",handler:(t,e)=>this.copy(this.getByIndex(e).uuid)},{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,items:[{title:$l10n(\"CONFIRM\"),destructive:!0,handler:(t,e)=>{t.delete(e),this.delete(this.getByIndex(e).uuid),$delay(.25,(()=>t.reload()))}}]}]}];if(t)return e;const i=t=>{const e=this.kernel.actionManager.getActionHandler(t.type,t.dir);return t.handler=(t,i)=>{const s=this.getByIndex(i),r=new m({env:f.clipboard,text:s.text,section:s.section,uuid:s.uuid});e(r)},t.title=t.name,t.symbol=t.icon,t},s=this.kernel.actionManager.getActions(\"clipboard\"),r={inline:!0,items:s.slice(0,this.menuItemActionMaxCount).map(i)};return s.length>this.menuItemActionMaxCount&&r.items.push({title:$l10n(\"MORE_ACTIONS\"),symbol:\"square.grid.2x2\",items:s.slice(this.menuItemActionMaxCount).map(i)}),[r,...e]}switchTab(t,e=!1){this.tabIndex=t,this.updateList(),e&&($(this.listId+\"-tab\").index=this.tabIndex)}tabView(){return{type:\"tab\",props:{id:this.listId+\"-tab\",items:this.tabItems,index:this.tabIndex,dynamicWidth:!0},events:{changed:t=>this.switchTab(t.index)},layout:(t,e)=>{t.centerY.equalTo(e.super),e.prev?t.left.equalTo(e.prev.right).offset(this.tabLeftMargin):t.left.inset(this.tabLeftMargin)}}}lineData(t,e=!1){const i={hidden:!0},s={text:\"\"},r={hidden:!t?.hasTag};return t.image?(i.src=t.imagePath.preview,i.hidden=!1):(t.textStyledText?s.styledText=t.textStyledText:s.text=t.text,t.tagStyledText?r.styledText=t.tagStyledText:r.text=t.tag),{copied:{hidden:!e},image:i,tag:r,content:s}}listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{type:\"view\",views:[{type:\"view\",props:{id:\"copied\",circular:this.copiedIndicatorSize,hidden:!0,bgcolor:$color(\"green\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.size.equalTo(this.copiedIndicatorSize),t.left.equalTo(e.super).inset(this.horizontalMargin/2-this.copiedIndicatorSize/2)}},{type:\"label\",props:{id:\"content\",lines:this.#v?1:2,font:$font(this.fontSize)},layout:(t,e)=>{t.left.right.equalTo(e.super).inset(this.horizontalMargin),t.top.equalTo(this.verticalMargin)}},{type:\"label\",props:{id:\"tag\",lines:1,color:this.tagColor,autoFontSize:!0,align:$align.leading},layout:(t,e)=>{t.bottom.equalTo(e.super),t.left.right.equalTo(e.prev),t.height.equalTo(this.tagHeight)}}],layout:$layout.fill},{type:\"image\",props:{id:\"image\",hidden:!0},layout:$layout.fill}]}}getEmptyBackground(t=this.listId){return{type:\"label\",props:{id:t+\"-empty-background\",color:$color(\"secondaryText\"),hidden:this.clips.length>0,text:$l10n(\"NONE\"),align:$align.center},layout:$layout.center}}getListView(t=this.listId,e=[]){const i={type:\"list\",props:{id:t,associateWithNavigationBar:!1,bgcolor:$color(\"clear\"),separatorInset:$insets(0,this.horizontalMargin,0,0),menu:{items:this.menuItems()},data:e,template:this.listTemplate(),actions:[{title:$l10n(\"COPY\"),color:$color(\"systemLink\"),handler:(t,e)=>this.copy(this.getByIndex(e).uuid)},{title:$l10n(\"FAVORITE\"),color:$color(\"orange\"),handler:(t,e)=>this.favorite(e.row)},{title:\"delete\",handler:(t,e)=>{this.delete(this.getByIndex(e).uuid),$delay(.25,(()=>t.reload()))}}]},layout:$layout.fill,events:{ready:()=>this.listReady(),rowHeight:(t,e)=>{const i=this.getByIndex(e),s=i?.hasTag?this.tagHeight:this.verticalMargin,r=i.image?this.imageContentHeight:this.getContentHeight(i.text);return this.verticalMargin+r+s},didSelect:(t,e)=>{const i=this.getByIndex(e);i.image?a.quickLookImage(i.imageOriginal):this.edit(i.text,(t=>{i.md5!==$text.MD5(t)&&this.update(t,i.uuid)}))},pulled:t=>{this.updateList(!0),this.kernel.storage.sync(),this.kernel.setting.get(\"webdav.status\")||$delay(.5,(()=>t.endRefreshing()))}}};return s.createFromViews([i,this.getEmptyBackground(t)])}getNavigationView(){const t=new a,e=e=>{const{keyword:i,result:s,isTagKeyword:r}=e,n=this.getListView(this.listId+\"-search-result\",s.map((t=>{const e=r?t.tag:t.text;let s=[];return i.forEach((t=>{let i=e.indexOf(t);for(;i>-1;)s.push({range:$range(i,t.length),color:$color(\"red\")}),i=e.indexOf(t,i+1)})),t.styledText={},r?t.tagStyledText={color:this.tagColor,text:e,styles:s}:t.textStyledText={text:e,styles:s},this.lineData(t,!1)})));return delete n.views[0].events.pulled,n.views[0].events.rowHeight=(t,e)=>{const i=s[e.row],r=i?.hasTag?this.tagHeight:this.verticalMargin,n=i.image?this.imageContentHeight:this.getContentHeight(i.text);return this.verticalMargin+n+r},n.views[0].events.didSelect=(e,i)=>{const r=s[i.row];r.image?a.quickLookImage(r.imageOriginal):(t.dismiss(),this.edit(r.text,(t=>{r.md5!==$text.MD5(t)&&this.update(t,r.uuid)})))},n},i=new u(this.kernel);i.setCallback((s=>{t.setView(e(s)).addNavBar({title:$l10n(\"SEARCH_RESULT\"),popButton:{title:$l10n(\"DONE\"),tapped:()=>i.dismiss()}}).init().present()}));const s=this.tabView();s.type=\"menu\",s.layout=(t,e)=>{t.top.left.right.equalTo(e.super),t.height.equalTo(this.tabHeight)};const r=this.getListView();r.views.unshift(s),r.views[1].layout=(t,e)=>{t.bottom.left.right.equalTo(e.super),t.top.equalTo(e.prev.bottom)},r.views.push(i.getSearchHistoryView());const o=(new l).navigationBarTitle($l10n(\"CLIPS\")).setView(r);return o.navigationBarItems.setTitleView(i.getSearchBarView()).pinTitleView().setRightButtons([{symbol:\"plus.circle\",tapped:()=>this.getAddTextView()}]).setLeftButtons([{title:$l10n(\"EDIT\"),tapped:()=>{new g(this).presentSheet()}},{symbol:\"square.and.arrow.down.on.square\",tapped:async t=>{t.start();try{await this.readClipboard(!0),t.done()}catch(e){t.cancel(),this.kernel.error(e)}}}]),o.navigationBar.setBackgroundColor(n.primaryViewBackgroundColor).setLargeTitleDisplayMode(h.largeTitleDisplayModeNever),this.kernel.isUseJsboxNav&&o.navigationBar.removeTopSafeArea(),o}}})),parcelRequire.register(\"f0nX9\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.UIKit,r=i.NavigationBar,n=i.NavigationView,a=i.Sheet,o=parcelRequire(\"eSp9Z\"),l=o.ActionEnv,h=o.ActionData;t.exports=class{#f=\"\";constructor(t){this.kernel=t,this.id=\"editor\",this.originalContent=void 0}set text(t=\"\"){void 0===this.originalContent&&(this.originalContent=t),this.#f=t}get text(){return this.#f}getActionButton(){return{symbol:\"bolt.circle\",tapped:(t,e)=>{e&&(t=e);const i=$(this.id).selectedRange,s=new h({env:l.editor,editor:{setContent:t=>this.setContent(t)},text:i.length>0?this.text.slice(i.location,i.location+i.length):this.text,selectedRange:i}),r=$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actionManager.getActionListView((t=>{r.dismiss(),$delay(.5,(()=>t(s)))}))]})}}}setContent(t){this.text=t,$(this.id).text=t}getView(t=\"text\"){return{type:t,layout:$layout.fill,props:{id:this.id,lineNumbers:this.kernel.setting.get(\"editor.code.lineNumbers\"),theme:this.kernel.setting.get($device.isDarkMode?\"editor.code.darkTheme\":\"editor.code.lightTheme\"),text:this.text,insets:$insets(15,15,\"text\"===t?this.kernel.setting.get(\"editor.text.insets\"):15,15)},events:{ready:t=>{\"\"===this.text&&$delay(.5,(()=>t.focus()))},didChange:t=>{this.text=t.text}}}}pageSheet(t=\"\",e,i,s=[],r=\"text\"){this.text=t,s.unshift(this.getActionButton());const n=new a;n.setView(this.getView(r)).addNavBar({title:i,popButton:{title:$l10n(\"DONE\"),tapped:()=>e(this.text)},rightButtons:s}).init(),n.navigationView.navigationBar.contentViewHeightOffset=0,n.present()}uikitPush(t=\"\",e,i=[],r=\"text\"){this.text=t,i.unshift(this.getActionButton()),s.push({title:\"\",navButtons:i.map((t=>(t.handler=t.tapped,t.tapped=void 0,t))),views:[this.getView(r)],disappeared:()=>e(this.text)})}getNavigationView(t=\"\",e,i=[],s=\"text\"){this.text=t,i.unshift(this.getActionButton());const a=new n;return a.navigationBar.contentViewHeightOffset=0,a.navigationBar.setLargeTitleDisplayMode(r.largeTitleDisplayModeNever),a.navigationBarItems.setRightButtons(i),a.setView(this.getView(s)).navigationBarTitle(\"\"),a.setEvent(\"onPop\",(()=>e(this.text))),a}}})),parcelRequire.register(\"eSp9Z\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.L10n,r=i.Sheet,n=parcelRequire(\"jVlss\").SecureFunction;class a{static build=-1;static today=0;static editor=1;static clipboard=2;static action=3;static keyboard=4}class o{env;args;text;originalContent;section;uuid;selectedRange;textBeforeInput;textAfterInput;editor;constructor({env:t,args:e,text:i,section:s=null,uuid:r=null,selectedRange:n=null,textBeforeInput:a=null,textAfterInput:o=null,editor:l=null}={}){this.env=t,this.args=e,this.text=i,this.originalContent=i,this.section=s,this.uuid=r,this.selectedRange=n,this.textBeforeInput=a,this.textAfterInput=o,this.editor=l}}t.exports={ActionEnv:a,ActionData:o,Action:class{#S;secureFunction;constructor(t,e,i){this.#S=t,this.config=e,this.secureFunction=new n(this.#S,this.config),i.env===a.build&&((i=this.preview()).env=a.build),Object.assign(this,i),this.originalContent=String(this.text);const r=this.l10n();Object.keys(r).forEach((t=>{s.add(t,r[t])}))}preview(){return new o({env:a.build})}l10n(){return{}}pageSheet({view:t,title:e=\"\",done:i,doneText:s=$l10n(\"DONE\"),rightButtons:n=[]}){(new r).setView(t).addNavBar({title:e,popButton:{title:s,tapped:()=>{i&&i()}},rightButtons:n}).init().present()}quickLookImage(t){r.quickLookImage(t)}getAllClips(){return{favorite:this.#S.storage.all(\"favorite\").map((t=>t.text)),clips:this.#S.storage.all(\"clips\").map((t=>t.text))}}async clearAllClips(){if(0!==(await $ui.alert({title:$l10n(\"DELETE_DATA\"),message:$l10n(\"DELETE_TABLE\").replaceAll(\"${table}\",$l10n(\"CLIPS\")),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index)return!1;try{return this.#S.storage.deleteTable(\"clips\"),!0}catch(t){throw this.#S.error(t),t}}setContent(t){this.text=t,this.env===a.editor?this.editor.setContent(t):this.env===a.clipboard&&(this.#S.storage.updateText(this.section,this.uuid,t),this.#S.clips.updateList(!0))}getAction(t,e,i){return this.#S.actionManager.getAction(t,e,i)}async runAction(t,e){const i=this.getAction(t,e);return await i.do()}async request(t,e,i,s){return this.secureFunction.http.request({url:t,method:e,body:i,header:s,timeout:3})}getUrls(){return(this.text??\"\").match(/(https?:\\/\\/)([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([:0-9])*([\\/\\w\\#\\.\\-\\?\\=\\&])*\\s?/gi)??[]}}}})),parcelRequire.register(\"jVlss\",(function(t,e){class i{#S;#A;notAllowed='\"The parameter or method is not allowed in Action.\"';constructor(t,e){if(this.#S=t,this.#A=JSON.parse(JSON.stringify(e)),!this.#A?.name||\"undefined\"===this.#A?.name)throw new Error(\"Cannot get Action name.\")}get name(){return this.#A.name}set name(t){const e=$l10n(\"ACTION_RESET_NAME_WARNING\").replaceAll(\"${name}\",this.name).replaceAll(\"${to_name}\",t);throw $ui.alert({title:$l10n(\"ACTION_SAFETY_WARNING\"),message:e}),new Error(e)}print(t){this.#S.print(t)}error(t){this.#S.error(t)}}class s extends i{rootPath=this.notAllowed;extensions=this.notAllowed;read(){throw new Error(this.notAllowed)}async download(){throw new Error(this.notAllowed)}write(){throw new Error(this.notAllowed)}delete(){throw new Error(this.notAllowed)}list(){throw new Error(this.notAllowed)}copy(){throw new Error(this.notAllowed)}move(){throw new Error(this.notAllowed)}mkdir(){throw new Error(this.notAllowed)}exists(){throw new Error(this.notAllowed)}isDirectory(){throw new Error(this.notAllowed)}merge(){throw new Error(this.notAllowed)}absolutePath(){throw new Error(this.notAllowed)}}class r extends i{#I=\"ActionHttpPermission\";get#C(){const t=$cache.get(this.#I);return t||(this.#C={},{})}set#C(t={}){return $cache.set(this.#I,t)}async#x(){if(0===(await $ui.alert({title:$l10n(\"ACTION_PERMISSION_REQUEST\"),message:$l10n(\"ACTION_NETWORK_PERMISSION_MESSAGE\").replaceAll(\"${name}\",this.name),actions:[{title:$l10n(\"OK\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index){const t=this.#C;return t[this.name]=!0,this.#C=t,!0}return!1}async#k(){const t=this.#C;return\"boolean\"==typeof t[this.name]?t[this.name]:!!await this.#x()}async request(t={}){try{if(!await this.#k())throw new Error(\"No network permission.\");this.print(`sending request [${t.method}]: ${t.url}`);const e=await $http.request(Object.assign({timeout:3},t));if(\"function\"==typeof t?.handler&&t?.handler(e),e.error)throw e.error;if(e?.response?.statusCode>=400){let t=e.data;throw\"object\"==typeof t&&(t=JSON.stringify(t)),new Error(\"http error: [\"+e.response.statusCode+\"] \"+t)}return e}catch(t){throw t.code&&(t=new Error(\"network error: [\"+t.code+\"] \"+t.localizedDescription)),this.error(`Action request error: ${this.name}`),this.error(t),t}}async get(t){return\"string\"==typeof t&&(t={url:t}),t.method=\"GET\",await this.request(t)}async post(t){return\"string\"==typeof t&&(t={url:t}),t.method=\"POST\",await this.request(t)}async download(){throw new Error(this.notAllowed)}async upload(){throw new Error(this.notAllowed)}async startServer(){throw new Error(this.notAllowed)}async stopServer(){throw new Error(this.notAllowed)}async shorten(t){return await $http.shorten(t)}async lengthen(t){return await $http.lengthen(t)}}t.exports={SecureFunction:class extends i{constructor(...t){super(...t),this.file=new s(...t),this.http=new r(...t)}addin(){throw new Error(this.notAllowed)}},SecureScript:class{script;sf=\"this.secureFunction\";constructor(t){this.script=t}#B(t,e){this.script=this.script.replaceAll(t,e)}replaceEval(){this.#B(/\\$addin\\.*[a-zA-Z0-9\\[\\]'\"`]+/gi,`${this.sf}.addin()`),this.#B(\"eval\",`${this.sf}.addin()`)}replaceFile(){this.#B(\"$file\",`${this.sf}.file`)}replaceHttp(){this.#B(\"$http\",`${this.sf}.http`)}secure(){return this.replaceEval(),this.replaceFile(),this.replaceHttp(),this.script}}}})),parcelRequire.register(\"ZnuTV\",(function(t,e){var i=parcelRequire(\"gxpqj\").UIKit,s=parcelRequire(\"jEwwi\").Clip;t.exports=class{kernel;pasteboard=$objc(\"UIPasteboard\").$generalPasteboard();#D=[];clipsUUIDMap={};clipsMD5Map={};tabItems=[$l10n(\"FAVORITE\"),$l10n(\"CLIPS\")];tabItemsIndex=[\"favorite\",\"clips\"];tabItemsMap=function(t){const e={};return t.forEach(((t,i)=>{e[t]=i})),e}(this.tabItemsIndex);constructor(t){this.kernel=t}get tabIndex(){return $cache.get(\"caio.main.tab.index\")??0}set tabIndex(t){$cache.set(\"caio.main.tab.index\",t)}get table(){return this.tabItemsIndex[this.tabIndex]}get tableL10n(){return this.tabItems[this.tabIndex]}get allClips(){return this.tabItemsIndex.forEach(((t,e)=>{this.#D[e]||(this.#D[e]=this.#L(t),this.kernel.print(`init clips: ${t}`))})),this.#D}get clips(){return this.#D[this.tabIndex]||(this.#D[this.tabIndex]=this.#L(this.table),this.kernel.print(`init clips: ${this.table}`)),this.#D[this.tabIndex]}get isChanged(){const t=this.pasteboard.$changeCount(),e=$cache.get(\"clipboard.changeCount\");return $cache.set(\"clipboard.changeCount\",t),e!==t}#L(t){try{const e=this.kernel.storage.all(t),i=this.kernel.storage.sort(e,this.kernel.setting.get(\"clipboard.maxItemLength\"));return i.forEach(((e,i)=>{this.clipsMD5Map[e.md5]=!0,this.clipsUUIDMap[e.uuid]={tab:t,index:i}})),this.#R(i)}catch(t){this.kernel.error(t),this.rebuildDatabase()}}#R(t){return new Proxy(t??[],{set:(t,e,i)=>Reflect.set(t,e,i),get:(t,e)=>Reflect.get(t,e)})}rebuildDatabase(){$ui.alert({title:$l10n(\"REBUILD_DATABASE\"),message:$l10n(\"CLIPS_STRUCTURE_ERROR\"),actions:[{title:$l10n(\"OK\"),handler:()=>{const t=i.loading();t.start(),this.kernel.storage.rebuild(),t.end(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\")}]})}setNeedReload(t){t?this.#D[this.tabItemsMap[t]]=null:this.#D=[],this.kernel.print(`set need reload: ${t??\"all\"}`)}getClipCopy(t,e={}){if(!t.uuid)return t;const i=new s(t);return i.fileStorage=t.fileStorage,Object.assign(i,e),i}getIndexByUUID(t){return this.clipsUUIDMap[t]?.index??-1}getClip(t){const e=this.clips[this.getIndexByUUID(t)];return e||this.kernel.storage.getByUUID(t)}exists(t){return Boolean(this.clipsMD5Map[$text.MD5(t)])}setClipboardText(t){this.kernel.setting.get(\"clipboard.universal\")?$clipboard.text=t:$clipboard.setTextLocalOnly(t)}addItem(t){const e=new s({uuid:$text.uuid,section:this.table,md5:null,prev:null,next:this.clips[0]?this.clips[0].uuid:null});if(\"string\"==typeof t){if(\"\"===t.trim())return;e.text=t}else{if(\"object\"!=typeof t)return;e.fileStorage=this.kernel.fileStorage,e.text=this.kernel.storage.saveImage(t)}try{return this.kernel.storage.beginTransaction(),this.kernel.storage.insert(e),e.next&&(this.clips[0].prev=e.uuid,this.kernel.storage.update(this.clips[0])),this.kernel.storage.commit(),this.setNeedReload(this.table),e}catch(t){throw this.kernel.storage.rollback(),this.kernel.error(t),t}}getRecycleBin(){return $cache.get(\"caio.recycleBin\")??[]}moveToRecycleBin(t){const e=this.getRecycleBin();e.push({text:t.text,tag:t.tag}),$cache.set(\"caio.recycleBin\",e)}removeFromRecycleBin(t){const e=this.getRecycleBin();e.splice(t,1),$cache.set(\"caio.recycleBin\",e)}deleteItem(t,e=!0){const i=this.getIndexByUUID(t),s=this.clips[i],r=this.clips[i-1],n=this.clips[i+1];try{this.kernel.storage.beginTransaction(),this.kernel.storage.delete(this.table,t),r&&(r.next=s.next,this.kernel.storage.update(r)),n&&(n.prev=s.prev,this.kernel.storage.update(n)),this.kernel.storage.commit(),e&&(this.kernel.storage.deleteTag(t),s?.image?(this.kernel.fileStorage.delete(s.fsPath.original),this.kernel.fileStorage.delete(s.fsPath.preview)):this.moveToRecycleBin(s)),this.setNeedReload(this.table)}catch(t){throw this.kernel.storage.rollback(),this.kernel.error(t),t}}updateItem(t,e){const i=$text.MD5(t),s=this.getClip(e);delete this.clipsMD5Map[s.md5],this.clipsMD5Map[i]=!0;const r=s.text;Object.assign(s,{text:t,md5:i});try{this.kernel.storage.updateText(this.table,s.uuid,t),this.kernel.print(`data changed at index [${this.getIndexByUUID(e)}]\\n${r}\\n↓\\n${t}`)}catch(t){throw this.kernel.error(t),t}}moveItem(t,e){if(t!==e){t{};onBegin=()=>{};onDismiss=()=>{};constructor(t){this.kernel=t,this.searchBar=new r,this.searchBarId=this.searchBar.id+\"-input\"}get searchHistoryView(){return{hide:()=>$(this.listId+\"-history\").hidden=!0,show:()=>$(this.listId+\"-history\").hidden=!1}}get searchHistory(){return[{title:$l10n(\"SEARCH_HISTORY\"),rows:$cache.get(\"caio.search.history\")?.reverse()??[]}]}getAccessoryView(){return s.blurBox({height:50},[{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"xmark.circle\"},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(e.super),t.width.equalTo(e.super.height)},events:{tapped:()=>this.dismiss()}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"keyboard.chevron.compact.down\"},layout:(t,e)=>{t.right.equalTo(e.prev.left),t.height.equalTo(e.super),t.width.equalTo(e.super.height)},events:{tapped:()=>$(this.searchBarId).blur()}}])}getSearchHistoryView(){return{type:\"list\",props:{id:this.listId+\"-history\",hidden:!0,stickyHeader:!0,data:this.searchHistory,separatorInset:$insets(0,13,0,0),actions:[{title:$l10n(\"DELETE\"),handler:(t,e)=>{const i=t.data;this.updateSearchHistory(i[0].rows.reverse())}}]},events:{didSelect:(t,e,i)=>{this.searchAction(i),$(this.searchBarId).text=i}},layout:$layout.fill}}setCallback(t){this.callback=t}setOnBegin(t){this.onBegin=t}setOnDismiss(t){this.onDismiss=t}begin(){this.searchHistoryView.show(),this.onBegin()}dismiss(){this.searchBar.cancel()}async searchAction(t){try{if(\"\"!==t){let e,i=t.startsWith(\"#\");e=i?this.kernel.storage.searchByTag(t.substring(1)):await this.kernel.storage.search(t);const{result:s,keyword:r}=e;s&&s.length>0?($(this.searchBarId).blur(),this.callback({keyword:r,result:s,isTagKeyword:i})):$ui.toast($l10n(\"NO_SEARCH_RESULT\")),this.pushSearchHistory(t)}}catch(t){throw t}}pushSearchHistory(t){let e=$cache.get(\"caio.search.history\")??[];-1===e.indexOf(t)&&(e.push(t),e.length>20&&(e=e.slice(-20)),$cache.set(\"caio.search.history\",e),$(this.listId+\"-history\").data=this.searchHistory)}updateSearchHistory(t=[]){$cache.set(\"caio.search.history\",t)}getSearchBarView(){return this.searchBar.controller.setEvent(\"onReturn\",(t=>{\"\"!==t?this.searchAction(t):this.searchHistoryView.show()})),this.searchBar.controller.setEvent(\"onChange\",(t=>{\"\"===t&&this.searchHistoryView.show()})),this.searchBar.controller.setEvent(\"onBeginEditing\",(t=>{\"\"===t&&this.begin()})),this.searchBar.controller.setEvent(\"onCancel\",(()=>{this.searchHistoryView.hide(),this.onDismiss()})),this.searchBar.setAccessoryView(this.getAccessoryView()),this.searchBar}}})),parcelRequire.register(\"9LqeL\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.View,r=i.UIKit,n=i.Sheet;class a{static symbol={selected:\"checkmark.circle.fill\",unselected:\"circle\"};#E={};listId=\"clips-list-editor\";reorder={};toolBarHeight=44;containerMargin=30;#N=void 0;#O={};constructor(t){this.clipsInstance=t,this.kernel=t.kernel}get editorSelectedIsEmpty(){let t=!0;const e=this.editorSelected;for(const i of Object.keys(e))if(e[i]){t=!1;break}return t}get editorSelectedIsFull(){let t=0,e=0;const i=this.editorSelected;for(const s of Object.keys(i))++e,i[s]&&++t;return e===t}get editorSelected(){return void 0===this.#N&&(Array(this.clipsInstance.clips.length).fill(0).map(((t,e)=>this.#O[e]=!1)),this.#N=new Proxy(this.#O,{set:(t,e,i,s)=>(Reflect.set(t,e,i,s),e=Number(e),this.updateToolBar(),$(this.listId).data=this.clipsInstance.clips.map(((e,i)=>{const s=this.lineData(e);return s.checkmark={symbol:t[i]?a.symbol.selected:a.symbol.unselected},s})),!0)})),this.#N}getTextHeight(t){return this.#E[t]||(this.#E[t]=Math.min($text.sizeThatFits({text:t,width:r.windowSize.width-2*(this.clipsInstance.horizontalMargin+this.containerMargin),font:$font(this.clipsInstance.fontSize)}).height,2*this.clipsInstance.singleLineContentHeight)),this.#E[t]}selectAll(){const t=this.editorSelectedIsFull;this.clipsInstance.clips.forEach(((e,i)=>{this.editorSelected[i]=!t}))}deleteSelected(){r.deleteConfirm($l10n(\"DELETE_CONFIRM_MSG\"),(()=>{const t=Object.keys(this.editorSelected);if(t.filter((t=>this.editorSelected[t])).length===this.clipsInstance.clips.length)return void this.deleteTable();const e=$(this.listId),i=$(this.clipsInstance.listId);t.reverse().forEach((t=>{if(this.editorSelected[t]){t=Number(t);const s=this.clipsInstance.clips[t];this.kernel.print(`delete selected: [${t}]\\n${s.text}`),this.clipsInstance.delete(s.uuid),i.delete(t),e.delete(t)}})),this.#N=void 0,this.updateToolBar()}))}deleteTable(){try{this.kernel.storage.deleteTable(this.clipsInstance.table),this.sheet.dismiss(),this.clipsInstance.updateList(!0)}catch(t){this.kernel.error(t),$ui.error(t)}}updateToolBar(){const t=this.editorSelectedIsEmpty,e=$(this.listId+\"-select-button\"),i=$(this.listId+\"-delete-button\");e.title=this.editorSelectedIsFull?$l10n(\"DESELECT_ALL\"):$l10n(\"SELECT_ALL\"),i.hidden=t,$(this.listId).reorder=t}getToolBarView(){return r.blurBox({},[r.separatorLine(),{type:\"view\",views:[{type:\"button\",props:{id:this.listId+\"-select-button\",title:$l10n(\"SELECT_ALL\"),titleColor:$color(\"tint\"),bgcolor:$color(\"clear\")},layout:(t,e)=>{t.left.inset(this.clipsInstance.horizontalMargin),t.centerY.equalTo(e.super)},events:{tapped:()=>this.selectAll()}},{type:\"button\",props:{id:this.listId+\"-delete-button\",symbol:\"trash\",hidden:!0,tintColor:$color(\"red\"),bgcolor:$color(\"clear\")},layout:(t,e)=>{t.height.equalTo(e.super),t.width.equalTo(2*this.clipsInstance.horizontalMargin),t.right.inset(this.clipsInstance.horizontalMargin/2),t.centerY.equalTo(e.super)},events:{tapped:()=>this.deleteSelected()}}],layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom)}}],((t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.toolBarHeight)}))}lineData(t){const e=this.clipsInstance.lineData(t);return e.checkmark={symbol:a.symbol.unselected},e}listTemplate(){const t=this.clipsInstance.listTemplate();return t.views[0].layout=(t,e)=>{t.height.right.equalTo(e.super),t.left.inset(this.containerMargin)},t.views.push({type:\"image\",props:{id:\"checkmark\",symbol:a.symbol.unselected,contentMode:$contentMode.scaleAspectFit},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(this.containerMargin/2),t.size.equalTo($size(25,25))}}),t}getListEditerView(){return{type:\"list\",props:{id:this.listId,bgcolor:r.primaryViewBackgroundColor,separatorInset:$insets(0,this.clipsInstance.horizontalMargin,0,0),indicatorInsets:$insets(0,0,this.toolBarHeight,0),data:this.clipsInstance.clips.map((t=>this.lineData(t))),template:this.listTemplate(),reorder:!0,footer:{height:this.toolBarHeight},crossSections:!1},events:{rowHeight:(t,e)=>{if(this.reorder.began){const t=e.row;t===this.reorder.to?e=this.reorder.from:this.reorder.tothis.reorder.to&&t<=this.reorder.from&&(e=t-1):this.reorder.to>this.reorder.from&&t=this.reorder.from&&(e=t+1)}const i=this.clipsInstance.getByIndex(e),s=i.hasTag?this.clipsInstance.tagHeight:this.clipsInstance.verticalMargin,r=i.image?this.clipsInstance.imageContentHeight:this.clipsInstance.getContentHeight(i.text);return this.clipsInstance.verticalMargin+r+s},reorderBegan:t=>{this.reorder.began=!0,this.reorder.from=t.row,this.reorder.to=t.row},reorderMoved:(t,e)=>{this.reorder.to=e.row},reorderFinished:()=>{this.reorder.began=!1,this.reorder.to!==this.reorder.from&&this.clipsInstance.move(this.reorder.from,this.reorder.to)},didSelect:(t,e,i)=>{this.editorSelected[e.row]=!this.editorSelected[e.row]}},layout:$layout.fill}}presentSheet(){this.sheet=new n,this.sheet.setView(s.createFromViews([this.getListEditerView(),this.getToolBarView()])).addNavBar({title:\"\",popButton:{title:$l10n(\"CLOSE\")},rightButtons:[{title:$l10n(\"CLEAR\"),color:$color(\"red\"),tapped:async()=>{0===(await $ui.alert({title:$l10n(\"DELETE_DATA\"),message:$l10n(\"DELETE_TABLE\").replaceAll(\"${table}\",this.clipsInstance.tableL10n),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index&&this.deleteTable()}}]}).init().present()}}t.exports=a})),parcelRequire.register(\"44eiF\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.Matrix,r=i.Setting,n=i.NavigationView,a=i.BarButtonItem,o=i.Sheet,l=i.UIKit,h=parcelRequire(\"f0nX9\"),c=parcelRequire(\"7TSVv\"),d=parcelRequire(\"eSp9Z\"),p=d.ActionEnv,u=d.ActionData,g=parcelRequire(\"2VUvw\");t.exports=class extends c{matrix;reorder={};addActionButtonId=\"action-manager-button-add\";sortActionButtonId=\"action-manager-button-sort\";syncButtonId=\"action-manager-button-sync\";syncLabelId=\"action-manager-sync-label\";get actionList(){return super.actions.map((t=>{const e=[];return t.items.forEach((t=>{e.push(this.actionToData(t))})),{title:t.title,items:e}}))}actionSyncStatus(){$app.listen({actionSyncStatus:t=>{if(t.status===g.status.syncing&&t.animate)this.updateNavButton(!0),this.updateSyncLabel($l10n(\"SYNCING\"));else if(t.status===g.status.success)try{this.matrix.data=this.actionList}catch(t){this.kernel.error(t),this.updateSyncLabel(t)}finally{this.updateSyncLabel(),this.updateNavButton(!1),$(this.matrix.id)?.endRefreshing()}}})}getColor(t,e=null){return t?\"string\"==typeof t?$color(t):$rgba(t.red,t.green,t.blue,t.alpha):e}editActionInfoPageSheet(t,e){const i=this.getActionTypes(),s=!Boolean(t);s?this.editingActionInfo={type:i[0],name:\"MyAction\",color:\"#CC00CC\",icon:\"icon_062.png\",readme:\"\"}:(this.editingActionInfo=t,this.editingActionInfo.readme=this.getActionReadme(t.type,t.dir));const n=new r({structure:[],set:(t,e)=>(this.editingActionInfo[t]=e,!0),get:(t,e=null)=>Object.prototype.hasOwnProperty.call(this.editingActionInfo,t)?this.editingActionInfo[t]:e}),a=n.loader({type:\"input\",key:\"name\",icon:[\"pencil.circle\",\"#FF3366\"],title:$l10n(\"NAME\")}).create(),l=n.loader({type:\"color\",key:\"color\",icon:[\"pencil.tip.crop.circle\",\"#0066CC\"],title:$l10n(\"COLOR\")}).create(),h=n.loader({type:\"icon\",key:\"icon\",icon:[\"star.circle\",\"#FF9933\"],title:$l10n(\"ICON\"),bgcolor:this.getColor(this.editingActionInfo.color)}).create(),c=n.loader({type:\"menu\",key:\"type\",icon:[\"tag.circle\",\"#33CC33\"],title:$l10n(\"TYPE\"),items:i,values:i,pullDown:!0}).create(),d={type:\"view\",views:[{type:\"text\",props:{id:\"action-text\",textColor:$color(\"#000000\",\"secondaryText\"),bgcolor:$color(\"systemBackground\"),text:this.editingActionInfo.readme,insets:$insets(10,10,10,10)},layout:$layout.fill,events:{tapped:t=>{$(\"actionInfoPageSheetList\").scrollToOffset($point(0,s?280:230)),$delay(.2,(()=>t.focus()))},didChange:t=>{this.editingActionInfo.readme=t.text}}}],layout:$layout.fill},p=[{title:$l10n(\"INFORMATION\"),rows:[a,l,h]},{title:$l10n(\"DESCRIPTION\"),rows:[d]}];s&&(p[0].rows=p[0].rows.concat(c));const u=new o,g=async()=>{if(s){if(this.editingActionInfo.dir=$text.MD5(this.editingActionInfo.name),this.exists(this.editingActionInfo)){if(1===(await $ui.alert({title:$l10n(\"UNABLE_CREATE_ACTION\"),message:$l10n(\"ACTION_NAME_ALREADY_EXISTS\").replaceAll(\"${name}\",this.editingActionInfo.name)})).index)return}const t=this.getActionOrder(this.editingActionInfo.type,!0);t.unshift(this.editingActionInfo.dir),this.saveOrder(this.editingActionInfo.type,t)}u.dismiss(),this.saveActionInfo(this.editingActionInfo),await $wait(.3),e&&e(this.editingActionInfo)};u.setView({type:\"list\",props:{id:\"actionInfoPageSheetList\",bgcolor:$color(\"insetGroupedBackground\"),style:2,separatorInset:$insets(0,50,0,10),data:p},layout:$layout.fill,events:{rowHeight:(t,e)=>1===e.section?120:50}}).addNavBar({title:\"\",popButton:{title:$l10n(\"CANCEL\")},rightButtons:[{title:$l10n(\"DONE\"),tapped:async()=>await g()}]}).init().present()}editActionMainJs(t=\"\",e){const i=new h(this.kernel);i.pageSheet(t,(t=>{this.saveMainJs(e,t)}),e.name,[{symbol:\"book.circle\",tapped:()=>{const t=$file.read(\"scripts/action/README.md\").string;(new o).setView({type:\"markdown\",props:{content:t},layout:(t,e)=>{t.size.equalTo(e.super)}}).init().present()}},{symbol:\"play.circle\",tapped:async()=>{this.saveMainJs(e,i.text);let t=await this.getActionHandler(e.type,e.dir)(new u({env:p.build}));if(void 0!==t){\"object\"==typeof t&&(t=JSON.stringify(t,null,2));(new o).setView({type:\"code\",props:{lineNumbers:!0,editable:!1,text:t},layout:$layout.fill}).addNavBar({title:\"\",popButton:{title:$l10n(\"DONE\")}}).init().present()}}}],\"code\")}move(t,e){if(t.section===e.section&&t.row===e.row)return;super.move(t,e);const i=this.matrix,s=this.actionToData(this.actions[e.section].items[e.row]);t.row{const i=t.cell(e),s=i.get(\"info\").info;this.editActionInfoPageSheet(s,(t=>{i.get(\"info\").info=t,i.get(\"color\").bgcolor=this.getColor(t.color),i.get(\"name\").text=t.name,\"icon_\"===t.icon.slice(0,5)?i.get(\"icon\").icon=$icon(t.icon.slice(5,t.icon.indexOf(\".\")),$color(\"#ffffff\")):i.get(\"icon\").image=$image(t.icon)}))}},{title:$l10n(\"EDIT_SCRIPT\"),symbol:\"square.and.pencil\",handler:(t,e,i)=>{const s=i.info.info;if(!s)return;const r=`${this.userActionPath}/${s.type}/${s.dir}/main.js`,n=$file.read(r).string;this.editActionMainJs(n,s)}},{inline:!0,items:[{title:\"README\",symbol:\"book\",handler:(t,e)=>{const i=t.cell(e).get(\"info\").info;let s;try{s=__ACTIONS__[i.type][i.dir][\"README.md\"]}catch{s=this.getActionReadme(i.type,i.dir)}(new o).setView({type:\"markdown\",props:{content:s},layout:(t,e)=>{t.size.equalTo(e.super)}}).init().present()}}]},{inline:!0,items:[{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,handler:(t,e,i)=>{l.deleteConfirm($l10n(\"DELETE_CONFIRM_MSG\"),(()=>{this.delete(i.info.info),t.delete(e)}))}}]}]}getNavButtons(){return[{symbol:\"plus.circle\",id:this.addActionButtonId,menu:{pullDown:!0,asPrimary:!0,items:[{title:$l10n(\"CREATE_NEW_ACTION\"),handler:()=>{this.editActionInfoPageSheet(null,(async t=>{this.matrix.insert({indexPath:$indexPath(this.getActionTypes().indexOf(t.type),0),value:this.actionToData(t)});const e=$file.read(`${this.actionPath}/template.js`).string;this.saveMainJs(t,e),await $wait(.3),this.editActionMainJs(e,t)}))}},{title:$l10n(\"CREATE_NEW_TYPE\"),handler:()=>{$input.text({text:\"\",placeholder:$l10n(\"CREATE_NEW_TYPE\"),handler:t=>{if(\"\"===(t=t.trim()))return void $ui.toast($l10n(\"INVALID_VALUE\"));const e=`${this.userActionPath}/${t}`;$file.isDirectory(e)?$ui.warning($l10n(\"TYPE_ALREADY_EXISTS\")):($file.mkdir(e),$ui.success($l10n(\"SUCCESS\")))}})}}]}},{symbol:\"arrow.up.arrow.down.circle\",id:this.sortActionButtonId,tapped:(t,e)=>{$ui.popover({sourceView:e,directions:$popoverDirection.up,size:$size(200,300),views:[this.getActionListView(void 0,{reorder:!0,actions:[{title:\"delete\",handler:(t,e)=>{const i=this.matrix,s=i.object(e,!1).info.info;this.delete(s),i.delete(e,!1)}}]},{reorderBegan:t=>{this.reorder.from=t,this.reorder.to=void 0},reorderMoved:(t,e)=>{this.reorder.to=e},reorderFinished:t=>{void 0!==this.reorder.to&&this.move(this.reorder.from,this.reorder.to,t)}})]})}}]}actionToData(t){return{name:{text:t.name},icon:\"icon_\"===t?.icon?.slice(0,5)?{icon:$icon(t.icon.slice(5,t.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(t?.icon)},color:{bgcolor:this.getColor(t.color)},info:{info:t}}}updateSyncLabel(t){t||(t=$l10n(\"MODIFIED\")+this.getLocalSyncData().toLocaleString()),$(this.syncLabelId)&&($(this.syncLabelId).text=t)}updateNavButton(t){const e=this.navigationView?.navigationBarItems?.getButton(this.addActionButtonId);e&&e.setLoading(t);const i=this.navigationView?.navigationBarItems?.getButton(this.sortActionButtonId);i&&i.setLoading(t);const s=this.navigationView?.navigationBarItems?.getButton(this.syncButtonId);s&&s.setLoading(t)}getActionListView(t,e={},i={}){return t&&(i.didSelect=(e,i,s)=>{const r=s.info.info,n=this.getActionHandler(r.type,r.dir);t(n)}),{type:\"list\",layout:(t,e)=>{t.top.width.equalTo(e.super.safeArea),t.bottom.inset(0)},events:i,props:Object.assign({reorder:!1,bgcolor:$color(\"clear\"),rowHeight:60,sectionTitleHeight:30,stickyHeader:!0,data:(()=>{const t=this.actionList;return t.map((t=>(t.rows=t.items,t))),t})(),template:{props:{bgcolor:$color(\"clear\")},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(15),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(20),t.size.equalTo($size(20,20))}},{type:\"label\",props:{id:\"name\",lines:1,font:$font(16)},layout:(t,e)=>{t.height.equalTo(30),t.centerY.equalTo(e.super),t.left.equalTo(e.prev.right).offset(15)}},{type:\"label\",props:{id:\"info\"}}]}},e)}}getActionMiniView(t,e){e||(e=[],super.actions.forEach((t=>{e=e.concat(t.items)})));return{type:\"matrix\",props:{bgcolor:$color(\"clear\"),columns:2,itemHeight:50,spacing:8,data:[],template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color($rgba(255,255,255,.3),$rgba(0,0,0,.3))},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:t=>{t.top.left.inset(10),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(t,e)=>{t.edges.equalTo(e.prev).insets(5)}},{type:\"label\",props:{id:\"name\",font:$font(14)},layout:(t,e)=>{t.bottom.top.inset(10),t.left.equalTo(e.prev.prev.right).offset(10),t.right.inset(10)}},{type:\"view\",props:{id:\"info\",hidden:!0}}]}},layout:$layout.fill,events:{ready:t=>{t.data=e.map((t=>this.actionToData(t)))},didSelect:async(e,i,s)=>{const r=s.info.info,n=await t(r);this.getActionHandler(r.type,r.dir)(n)}}}}getMatrixView({columns:t=2,spacing:e=15,itemHeight:i=100}={}){return this.matrix=s.create({type:\"matrix\",props:{columns:t,itemHeight:i,spacing:e,bgcolor:l.scrollViewBackgroundColor,menu:{items:this.menuItems()},data:this.actionList,template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color(\"#ffffff\",\"#242424\")},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:t=>{t.top.left.inset(10),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:t=>{t.top.left.inset(15),t.size.equalTo($size(20,20))}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:l.textColor,titleColor:l.textColor,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},views:[{type:\"image\",props:{symbol:\"ellipsis.circle\"},layout:(t,e)=>{t.center.equalTo(e.super),t.size.equalTo(a.style.iconSize)}}],events:{tapped:t=>{const e=t.next.info;if(!e)return;const i=`${this.userActionPath}/${e.type}/${e.dir}/main.js`,s=$file.read(i).string;this.editActionMainJs(s,e)}},layout:t=>{t.top.right.inset(0),t.size.equalTo(a.style.width)}},{type:\"view\",props:{id:\"info\",hidden:!0}},{type:\"label\",props:{id:\"name\",font:$font(16)},layout:(t,e)=>{t.bottom.left.inset(10),t.width.equalTo(e.super)}}]},footer:{type:\"view\",props:{hidden:!this.kernel.setting.get(\"webdav.status\"),height:this.kernel.setting.get(\"webdav.status\")?50:0},views:[{type:\"label\",props:{id:this.syncLabelId,color:$color(\"secondaryText\"),font:$font(12),text:$l10n(\"MODIFIED\")+this.getLocalSyncData().toLocaleString()},layout:(t,i)=>{t.size.equalTo(i.super),t.top.inset(-30),t.left.inset(e)}}]}},layout:$layout.fill,events:{didSelect:(t,e,i)=>{const s=i.info.info,r=new u({env:p.action,text:\"clipboard\"===s.type||\"uncategorized\"===s.type?$clipboard.text:null});this.getActionHandler(s.type,s.dir)(r)},pulled:async t=>{this.isEnableWebDavSync?this.syncWithWebDav():(this.updateNavButton(!0),await this.sync(),this.matrix.data=this.actionList,this.updateSyncLabel(),this.updateNavButton(!1),t.endRefreshing())}}}),this.actionSyncStatus(),this.matrix.definition}getPage(){return this.navigationView=new n,this.navigationView.navigationBarItems.setRightButtons(this.getNavButtons()),this.navigationView.setView(this.getMatrixView()).navigationBarTitle($l10n(\"ACTIONS\")),this.navigationView.getPage()}present(){const t=new o,e=this.getNavButtons();this.kernel.setting.get(\"webdav.status\")&&e.push({id:this.syncButtonId,symbol:\"arrow.triangle.2.circlepath.circle\",tapped:async(t,e)=>{this.isEnableWebDavSync?this.syncWithWebDav():(this.updateNavButton(!0),await this.sync(),this.matrix.data=this.actionList,this.updateSyncLabel(),this.updateNavButton(!1))}}),t.setView(this.getMatrixView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{symbol:\"xmark.circle\"},rightButtons:e}).init(),this.navigationView=t.navigationView,t.present()}}})),parcelRequire.register(\"7TSVv\",(function(t,e){var i=parcelRequire(\"gxpqj\").FileStorage,s=parcelRequire(\"eSp9Z\"),r=s.ActionEnv,n=s.ActionData,a=s.Action,o=parcelRequire(\"jVlss\").SecureScript,l=parcelRequire(\"7pN8M\");t.exports=class{#q;constructor(t){this.kernel=t,this.actionPath=\"scripts/action\",this.actionOrderFile=\"order.json\",this.tempPath=`${this.kernel.fileStorage.basePath}/temp`,this.userActionPath=`${this.kernel.fileStorage.basePath}/user_action`,this.localSyncFile=this.userActionPath+\"/sync.json\",this.typeNameMap={},this.checkUserAction(),this.sync()}get actions(){return this.#q||(this.#q=this.getActionTypes().map((t=>({title:this.getTypeName(t),items:this.getActions(t)}))),this.kernel.print(\"init actions\")),this.#q}get isNew(){return $cache.get(\"caio.action.isNew\")??!1}set isNew(t){$cache.get(\"caio.action.isNew\",t)}get isEnableWebDavSync(){return this.kernel.setting.get(\"webdav.status\")}setNeedReload(){this.#q=void 0,this.isEnableWebDavSync&&this.webdavSync.needUpload()}importExampleAction(){try{Object.keys(__ACTIONS__).forEach((t=>{const e=`${this.userActionPath}/${t}`;Object.keys(__ACTIONS__[t]).forEach((i=>{$file.exists(`${e}/${i}/main.js`)||($file.mkdir(e),$file.mkdir(`${e}/${i}`),$file.write({data:$data({string:__ACTIONS__[t][i][\"main.js\"]}),path:`${e}/${i}/main.js`}),$file.write({data:$data({string:__ACTIONS__[t][i][\"config.json\"]}),path:`${e}/${i}/config.json`}),$file.write({data:$data({string:__ACTIONS__[t][i][\"README.md\"]}),path:`${e}/${i}/README.md`}))}))}))}catch{$file.list(this.actionPath).forEach((t=>{const e=`${this.actionPath}/${t}`;if($file.isDirectory(e)){const i=`${this.userActionPath}/${t}`;$file.list(e).forEach((t=>{$file.exists(`${i}/${t}/main.js`)||($file.mkdir(i),$file.copy({src:`${e}/${t}`,dst:`${i}/${t}`}))}))}}))}this.setNeedReload()}getLocalSyncData(){const t=JSON.parse($file.read(this.localSyncFile)?.string??\"{}\");return new Date(t.timestamp)}async sync(){this.kernel.setting.get(\"webdav.status\")&&(this.webdavSync?await this.webdavSync.init():await this.initSyncWithWebDav())}async initSyncWithWebDav(){if(this.isEnableWebDavSync)try{this.webdavSync=new l({kernel:this.kernel,host:this.kernel.setting.get(\"webdav.host\"),user:this.kernel.setting.get(\"webdav.user\"),password:this.kernel.setting.get(\"webdav.password\"),basepath:this.kernel.setting.get(\"webdav.basepath\")}),await this.webdavSync.init()}catch(t){throw this.kernel.error(`${t}\\n${t.stack}`),t}}syncWithWebDav(){this.isEnableWebDavSync&&this.webdavSync.sync()}checkUserAction(){$file.exists(this.userActionPath)&&0!==$file.list(this.userActionPath).length||($file.mkdir(this.userActionPath),this.isNew=!1,this.importExampleAction())}getActionTypes(){const t=[\"clipboard\",\"editor\"];return t.concat($file.list(this.userActionPath).filter((e=>$file.isDirectory(`${this.userActionPath}/${e}`)&&t.indexOf(e)<0)))}getActionOrder(t,e=!1){const i=`${this.userActionPath}/${t}`,s=`${i}/${this.actionOrderFile}`;if($file.exists(s)){const e=JSON.parse($file.read(s).string),r=e.filter((t=>!!$file.exists(`${i}/${t}`)));return r.length!==e.length&&this.saveOrder(t,r),r}if(e){const t=[];return $file.list(i).forEach((e=>{t.push(e)})),t}return[]}getActionPath(t,e){return`${this.userActionPath}/${t}/${e}`}getActionConfig(t,e){return JSON.parse($file.read(`${this.getActionPath(t,e)}/config.json`).string)}getActionReadme(t,e){return $file.read(`${this.getActionPath(t,e)}/README.md`).string}getAction(t,e,i){$file.exists(this.getActionPath(t,e))||(e=$text.MD5(e));const s=this.getActionPath(t,e),l=this.getActionConfig(t,e);try{const t=$file.read(`${s}/main.js`).string,e=new o(t),h=new Function(\"Action\",\"ActionEnv\",\"ActionData\",`${e.secure()}\\n return MyAction`)(a,r,n);return new h(this.kernel,l,i)}catch(t){throw this.kernel.error(t),t}}getActionHandler(t,e){return async i=>{try{const s=this.getAction(t,e,i);return await s.do()}catch(t){throw this.kernel.error(t),t}}}getActions(t){const e=[],i=`${this.userActionPath}/${t}`;if(!$file.exists(i))return[];const s=s=>{const r=`${i}/${s}/`;if($file.isDirectory(r)){const i=this.getActionConfig(t,s);e.push(Object.assign(i,{dir:s,type:t,name:i.name??s,icon:i.icon,color:i.color}))}},r=this.getActionOrder(t);return r.forEach((t=>s(t))),$file.list(i).forEach((t=>{-1===r.indexOf(t)&&s(t)})),e}getTypeName(t){const e=t.toUpperCase(),i=$l10n(e),s=i===e?t:i;return this.typeNameMap[s]=t,s}getTypeDir(t){return this.typeNameMap[t]??t}#P(t,...e){\"string\"!=typeof t&&(t=JSON.stringify(t));const s=i.join(this.userActionPath,...e),r=s.substring(0,s.lastIndexOf(\"/\"));$file.exists(r)||$file.mkdir(r);const n=$file.read(s)?.string;let a;try{a=JSON.stringify(JSON.parse(n))}catch{a=n}t!==a&&($file.write({data:$data({string:t}),path:s}),this.setNeedReload())}saveActionInfo(t){this.#P({icon:t.icon,color:t.color,name:t.name},t.type,t.dir,\"config.json\"),this.#P(t.readme,t.type,t.dir,\"README.md\")}saveMainJs(t,e){this.#P(e,t.type,t.dir,\"main.js\")}saveOrder(t,e){this.#P(JSON.stringify(e),t,this.actionOrderFile)}move(t,e){if(t.section===e.section&&t.row===e.row)return;const i=this.actions[t.section];let s=i.items;const r=this.getTypeDir(i.title),n=t=>t.map((t=>t.dir));if(t.section===e.section){const i=t.rowe.row?t.row+1:t.row;s.splice(i,0,s[t.row]),s=s.filter(((t,e)=>e!==a)),this.saveOrder(r,n(s))}else{const i=this.actions[e.section],a=i.items,o=this.getTypeDir(i.title);a.splice(e.row,0,s[t.row]),s=s.filter(((e,i)=>i!==t.row)),$file.move({src:`${this.userActionPath}/${r}/${a[e.row].dir}`,dst:`${this.userActionPath}/${o}/${a[e.row].dir}`}),this.saveOrder(o,n(a)),this.saveOrder(r,n(s))}}delete(t){$file.delete(`${this.userActionPath}/${t.type}/${t.dir}`),this.setNeedReload()}exists(t){const e=`${this.userActionPath}/${t.type}/${t.dir}`;return!!$file.exists(e)}}})),parcelRequire.register(\"7pN8M\",(function(t,e){var i=parcelRequire(\"gxpqj\").FileStorage,s=parcelRequire(\"2VUvw\");class r extends s{localSyncDataPath=\"/user_action/sync.json\";webdavSyncDataPath=\"/sync.json\";tempPath=\"/temp\";webdavActionsPath=\"/actions.zip\";localActionsPath=\"/user_action\";constructor({host:t,user:e,password:s,basepath:r,kernel:n}={}){super({host:t,user:e,password:s,basepath:r=i.join(r,\"user_action\"),kernel:n})}async init(){await super.init(),this.sync()}isNew(){return this.kernel.actionManager.isNew}async pull(){const t=i.join(this.tempPath,\"user_action\"),e=this.kernel.fileStorage.filePath(t),s=await this.webdav.get(this.webdavActionsPath);if(!await $archiver.unzip({file:s.rawData,dest:e}))throw new Error(\"unzip failed\");await this.downloadSyncData(),this.kernel.fileStorage.move(t,this.localActionsPath),this.kernel.print(\"action webdav sync: pulled\")}async push(){const t=i.join(this.tempPath,\"actions.zip\");if(!$archiver.zip({directory:this.kernel.fileStorage.filePath(this.localActionsPath),dest:this.kernel.fileStorage.filePath(t)}))throw new Error(\"zip failed\");await $wait(.5),await this.webdav.put(this.webdavActionsPath,this.kernel.fileStorage.readSync(t)),await this.uploadSyncData(),this.kernel.fileStorage.delete(t),this.kernel.print(\"action webdav sync: pushed\")}notify(t){$app.notify({name:\"actionSyncStatus\",object:t})}async#$(){let t=!1;try{const e=await this.nextSyncStep();if(this.kernel.print(`action nextSyncStep: ${s.stepName[e]}`),e===s.step.needPush||e===s.step.init)await this.push();else if(e===s.step.needPull)await this.pull(),t=!0;else{if(e!==s.step.conflict)return void this.notify({status:s.status.nochange});await this.conflict($l10n(\"ACTIONS\"))===r.conflictKeep.webdav&&(t=!0)}}catch(t){throw this.notify({status:s.status.fail,error:t}),t}finally{this.notify({status:s.status.success,updateList:t})}}sync(){this.notify({status:s.status.syncing,animate:!0}),this.syncTimer&&this.syncTimer.cancel(),this.syncTimer=$delay(.5,(()=>{this.#$(!0)}))}needUpload(){this.notify({status:s.status.syncing}),this.uploadTimer&&this.uploadTimer.cancel(),this.uploadTimer=$delay(.5,(()=>{this.updateLocalTimestamp(),this.#$()}))}}t.exports=r})),parcelRequire.register(\"gYDdO\",(function(t,e){class i{files=[];databases=[];actions={};constructor(t){this.kernel=t}deleteFiles(t){t.forEach((t=>{this.files.includes(t)||this.files.push(t)}))}#_(){this.files.forEach((t=>{$file.exists(t)&&(this.kernel.print(`delete file: ${t}`),$file.delete(t))}))}rebuildDatabase(t,e){this.databases.push([t,e])}#V(){const t=(t,e)=>{const i=this.kernel.storage.sqlite.query(`SELECT count(*), name FROM sqlite_master WHERE type = \"table\" AND name = \"${t}\"`);if(null!==i.error)throw new Error(`Code [${i.error.code}] ${i.error.domain} ${i.error.localizedDescription}`);i.result.next();const s=i.result.get(0);i.result.close(),s>0&&(this.kernel.print(`copy data from old table: ${t}`),this.kernel.storage.sqlite.update(`INSERT INTO ${e} SELECT * FROM ${t}`),this.kernel.print(`drop table: ${t}`),this.kernel.storage.sqlite.update(`DROP TABLE ${t}`))};this.databases.forEach((e=>{t(e[0],e[1])}))}rebuildUserActions(t={}){for(let e of Object.keys(t))t[e].forEach((t=>{this.actions[e]||(this.actions[e]=[]),this.actions[e].includes(t)||this.actions[e].push(t)}))}async#M(){if(0===Object.keys(this.actions).length)return;const t=\"scripts/action\",e=`${this.kernel.fileStorage.basePath}/user_action`,i=[];for(let e of Object.keys(this.actions))this.actions[e].forEach((s=>{const r=JSON.parse($file.read(`${t}/${e}/${s}/config.json`).string);i.push(r.name)}));if(1!==(await $ui.alert({title:$l10n(\"compatibility.rebuildUserAction.alert.title\"),message:$l10n(\"compatibility.rebuildUserAction.alert.message\")+\"\\n\"+JSON.stringify(i,null,2)+\"\\n\"+$l10n(\"compatibility.rebuildUserAction.alert.message2\"),actions:[{title:$l10n(\"OK\")},{title:$l10n(\"CANCEL\")}]})).index){for(let i of Object.keys(this.actions))this.actions[i].forEach((s=>{$file.exists(`${e}/${i}/${s}`)&&(this.kernel.print(`rebuild user action: ${i}/${s}`),$file.copy({src:`${t}/${i}/${s}/main.js`,dst:`${e}/${i}/${s}/main.js`}))}));this.kernel.actionManager.setNeedReload()}}async do(){this.#_(),this.#V(),await this.#M()}}class s{version=7;userVersion=$cache.get(\"compatibility.version\")??0;constructor(t){this.kernel=t,this.compatibility=new i(this.kernel)}do(){this.userVersionthis.kernel.error(t))),$cache.set(\"compatibility.version\",this.version)}call(t){if(\"function\"!=typeof this[`ver${t}`])throw new ReferenceError(`version ${t} undefined`);this[`ver${t}`]()}ver1(){this.compatibility.deleteFiles([\"scripts/action/clipboard/ClearClipboard\",\"scripts/ui/clipboard.js\",\"scripts/ui/clipboard-data.js\",\"scripts/ui/clipboard-search.js\"]),this.compatibility.rebuildDatabase(\"clipboard\",\"clips\"),this.compatibility.rebuildUserActions({uncategorized:[\"ExportAllContent\",\"DisplayClipboard\"],clipboard:[\"B23Clean\"]}),$cache.get(\"caio.keyboard.height\")&&(this.kernel.setting.set(\"keyboard.previewAndHeight\",$cache.get(\"caio.keyboard.height\")),$cache.remove(\"caio.keyboard.height\"))}ver2(){this.compatibility.deleteFiles([\"scripts/storage.js\",\"scripts/ui/clips-data.js\",\"scripts/ui/components/action-manager-data.js\"]),this.compatibility.rebuildDatabase(\"pin\",\"favorite\"),this.compatibility.rebuildUserActions({uncategorized:[\"ExportAllContent\"]})}ver3(){this.compatibility.rebuildUserActions({clipboard:[\"SendToWin\"]})}ver4(){const t=\"/storage/user_action/data.json\";if($file.exists(t)){const e=JSON.parse($file.read(t).string).date;$file.write({data:$data({string:JSON.stringify({timestamp:e})}),path:\"/storage/user_action/sync.json\"}),$file.delete(t)}}ver5(){this.compatibility.rebuildUserActions({uncategorized:[\"DisplayClipboard\"]})}ver6(){this.compatibility.rebuildUserActions({clipboard:[\"GetFromWin\"]})}ver7(){this.compatibility.rebuildUserActions({uncategorized:[\"Replace\"]})}}t.exports=async function(t){if(t)try{new s(t).do()}catch(e){throw t.error(e),e}}})),parcelRequire.register(\"9RsVy\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.Kernel,r=i.UIKit,n=parcelRequire(\"2aNLD\"),a=parcelRequire(\"ilpYs\");let o;function l(){o.setting.method.exportClipboard=t=>{t.start(),o.storage.export((e=>{e?t.done():t.cancel()}))},o.setting.method.importClipboard=t=>{t.start(),$ui.alert({title:$l10n(\"ALERT_INFO\"),message:$l10n(\"OVERWRITE_ALERT\"),actions:[{title:$l10n(\"OK\"),handler:()=>{$drive.open({handler:e=>{void 0!==e?\"db\"===e.fileName.slice(-2)||\"zip\"===e.fileName.slice(-3)?o.storage.import(e).then((()=>{t.done(),$delay(.3,(()=>{$addin.restart()}))})).catch((e=>{$ui.error(e),o.error(e),t.cancel()})):($ui.warning($l10n(\"FILE_TYPE_ERROR\")),t.cancel()):t.cancel()}})}},{title:$l10n(\"CANCEL\"),handler:()=>t.cancel()}]})},o.setting.method.rebuildDatabase=t=>{t.start();$ui.alert({title:$l10n(\"REBUILD_DATABASE_ALERT\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{(()=>{try{o.storage.rebuild(),t.done(),$delay(.8,(()=>$addin.restart()))}catch(e){t.cancel(),$ui.alert(e)}})()}},{title:$l10n(\"CANCEL\"),handler:()=>{t.cancel()}}]})},o.setting.method.deleteAllData=t=>{t.start(),$ui.alert({title:$l10n(\"DELETE_ALL_DATA_ALERT\"),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{o.storage.deleteAllData(),t.done(),$delay(.5,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\"),handler:()=>{t.cancel()}}]})},o.setting.method.recycleBin=()=>({type:\"list\",props:{data:o.clips.getRecycleBin().map((t=>t?.text??\"None\")),actions:[{title:$l10n(\"DELETE\"),handler:(t,e)=>{o.clips.removeFromRecycleBin(e.row)}}]},events:{didSelect:(t,e)=>{const i=o.clips.getRecycleBin()[e.row]??{};if(i.text){const s=o.clips.addItem(i.text);i.tag&&o.storage.setTag(s.uuid,i.tag),o.clips.removeFromRecycleBin(e.row),o.clips.updateList(!0),t.delete(e)}}},layout:$layout.fill})}t.exports=function(t){o=t,o.setting.method.checkUpdate=async t=>{t.start();const e=\"scripts/libs/easy-jsbox.js\";if($file.exists(e))try{const t=await o.checkUpdate();t&&($file.write({data:$data({string:t}),path:e}),$ui.toast(\"The framework has been updated.\"))}catch{}$http.get({url:\"https://raw.githubusercontent.com/ipuppet/CAIO/master/config.json\",handler:e=>{const i=e.data?.info.version;let r;try{r=__INFO__}catch{r=JSON.parse($file.read(\"config.json\").string).info}s.versionCompare(i,r.version)>0?$ui.alert({title:\"New Version\",message:`New version found: ${i}\\nUpdate via Github or click the button to open Erots.`,actions:[{title:$l10n(\"CANCEL\")},{title:\"Erots\",handler:()=>{$addin.run({name:\"Erots\",query:{q:\"show\",objectId:\"603e6eaaca0dd64fcef93e2d\"}})}}]}):$ui.toast(\"No need to update\"),t.done()}})},o.setting.method.previewWidget=t=>{const{Widget:e}=parcelRequire(\"gD12U\"),i={};try{JSON.parse($file.read(\"widget-options.json\").string).forEach((t=>{i[t.name]=t.value}))}catch(t){return void $ui.error(t)}$ui.menu({items:Object.keys(i),handler:t=>{e.render(i[t])}})},o.setting.method.fileManager=()=>{o.fileManager.push(\"storage\")},l(),o.setting.method.exportAction=t=>{t.start();const e=\"actions.zip\",i=`/${e}`,s=o.fileStorage.filePath(i);$archiver.zip({directory:o.actionManager.userActionPath,dest:s,handler:()=>{$share.sheet({items:[{name:e,data:$data({path:s})}],handler:e=>{e?t.done():t.cancel(),o.fileStorage.delete(i)}})}})},o.setting.method.importAction=t=>{t.start(),$drive.open({handler:e=>{if(void 0!==e)if(\"zip\"===e.fileName.slice(-3)){const i=`${o.fileStorage.basePath}/action_import`;$archiver.unzip({file:e,dest:i,handler:()=>{$file.list(i).forEach((t=>{$file.isDirectory(`${i}/${t}`)&&$file.copy({src:`${i}/${t}`,dst:`${o.actionManager.userActionPath}/${t}`})})),$file.delete(i),t.done()}})}else $ui.warning($l10n(\"FILE_TYPE_ERROR\")),t.cancel();else t.cancel()}})},o.setting.method.importExampleAction=t=>{t.start(),o.actionManager.importExampleAction(),t.done()},o.setting.method.rebuildAction=t=>{t.start(),$ui.alert({title:$l10n(\"REBUILD_ACTION_DATABASE_ALERT_TITLE\"),message:$l10n(\"REBUILD_ACTION_DATABASE_ALERT_MESSAGE\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{$file.delete(o.actionManager.userActionPath),o.actionManager.setNeedReload(),t.done(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n(\"CANCEL\"),handler:()=>t.cancel()}]})},function(){const t=parcelRequire(\"7eNYp\"),e=200;o.setting.method.previewKeyboard=()=>{const i=new t(o),s=t=>{i.setKeyboardHeight(t),$(i.keyboardId).updateLayout((t=>{t.height.equalTo(i.keyboardHeight)})),1===i.keyboardDisplayMode&&$(i.keyboardId).get(i.listId).reload()},n=t=>(t-e)/200;return{views:[{type:\"label\",layout:(t,e)=>{t.top.inset(20),t.centerX.equalTo(e.super)},events:{ready:t=>t.text=i.keyboardHeight,tapped:t=>{$input.text({type:$kbType.number,text:i.keyboardHeight,handler:i=>{if(/^[0-9]+$/.test(i)){let r=Number(i);r=Math.min(r,400),r=Math.max(r,e),t.text=r,t.next.value=n(r),s(r)}else $ui.toast(\"Only integers can be entered.\")}})}}},{type:\"slider\",props:{max:1,min:0},layout:(t,e)=>{t.top.equalTo(e.prev.bottom),t.right.inset(20),t.width.equalTo(e.super).offset(-40)},events:{ready:t=>t.value=n(i.keyboardHeight),changed:t=>{const i=Math.floor(200*t.value+e);t.prev.text=i,s(i)}}},i.getView()],layout:(t,e)=>{t.left.right.bottom.equalTo(e.super.safeArea);let i=0;1===o.setting.get(\"mainUIDisplayMode\")&&(i=r.NavigationBarNormalHeight),t.top.equalTo(e.super.safeArea).inset(i)}}},o.setting.method.setKeyboardQuickStart=()=>n.sheet()}(),o.setting.method.previewTodayWidget=t=>{t.touchHighlightStart();const e=new(parcelRequire(\"49je6\"))(o).getView();r.push({views:[e],disappeared:()=>t.touchHighlightEnd()})},o.setting.method.setTodayWidgetActions=t=>{a.sheet(o)}}})),parcelRequire.register(\"2aNLD\",(function(t,e){var i=parcelRequire(\"gxpqj\").Sheet;class s{constructor(){this.listId=\"keyboard-script-list\"}static getAddins(){const t=$cache.get(\"keyboard.addins\");if(!t)return[];if($cache.get(\"keyboard.addins.all\")){const t=$addin.current.name;return $addin.list?.filter((e=>t!==e.displayName)).map((t=>t.displayName))}try{return JSON.parse(t)}catch(t){return[]}}static setAddins(t=[]){t.map(((e,i)=>{null===e&&t.splice(i,1)}));try{$cache.set(\"keyboard.addins\",JSON.stringify(t))}catch(t){$cache.set(\"keyboard.addins\",void 0)}}static setAllAddins(t){$cache.set(\"keyboard.addins.all\",t)}getUnsetAddins(){const t=$addin.current.name,e=s.getAddins();return $addin.list?.filter((i=>-1===e.indexOf(i.displayName)&&t!==i.displayName)).map((t=>t.displayName))}add(){const t={type:\"list\",props:{data:this.getUnsetAddins()},events:{didSelect:(t,e,i)=>{const r=s.getAddins();r.unshift(i),s.setAddins(r),$(this.listId).insert({indexPath:$indexPath(0,0),value:i}),t.delete(e)}},layout:$layout.fill};(new i).setView(t).addNavBar({title:$l10n(\"ADD\")}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListView(){return{type:\"list\",props:{id:this.listId,reorder:!0,data:s.getAddins(),actions:[{title:\"delete\",handler:(t,e)=>{s.setAddins(t.data)}}]},events:{reorderFinished:t=>{s.setAddins(t)}},layout:$layout.fill}}static async sheet(){if(0===(await $ui.menu({items:[$l10n(\"ALL_SCRIPTS\"),$l10n(\"SELECT_SCRIPTS\")]})).index)s.setAllAddins(!0);else{s.setAllAddins(!1);const t=new i,e=new s;t.setView(e.getListView()).addNavBar({title:$l10n(\"QUICK_START_SCRIPTS\"),popButton:{title:$l10n(\"DONE\")},rightButtons:e.getNavButtons()}),t.init().present()}}}t.exports=s})),parcelRequire.register(\"ilpYs\",(function(t,e){var i=parcelRequire(\"gxpqj\").Sheet;class s{constructor(t){this.listId=\"today-action-list\",this.kernel=t}getActions(){let t=$cache.get(\"today.actions\")??[];\"string\"==typeof t&&(t=JSON.parse(t),this.setActions(t));const e={};this.kernel.actionManager.getActionTypes().forEach((t=>{this.kernel.actionManager.getActions(t).forEach((t=>{e[t.type+t.dir]=t}))}));const i=[];let s=!1;return t.forEach((t=>{const r=e[t.type+t.dir];r?i.push(r):s=!0})),s&&this.setActions(i),i}setActions(t=[]){t.map(((e,i)=>{e||t.splice(i,1)})),$cache.set(\"today.actions\",t)}getAllActions(){let t=[];return this.kernel.actionManager.getActionTypes().forEach((e=>{t=t.concat(this.kernel.actionManager.getActions(e))})),t}getUnsetActions(){const t=this.getActions().map((t=>t.name)),e=[];return this.getAllActions().forEach((i=>{const s=i.name;-1===t.indexOf(s)&&e.push(i)})),e}getListData(t){return t.map((t=>({action:{text:t.name,info:t},icon:\"icon_\"===t.icon.slice(0,5)?{icon:$icon(t.icon.slice(5,t.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(t.icon)},color:{bgcolor:this.kernel.actionManager.getColor(t.color)}})))}getListTemplate(){return{views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:t=>{t.top.left.inset(10),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:t=>{t.top.left.inset(15),t.size.equalTo($size(20,20))}},{type:\"label\",props:{id:\"action\"},layout:(t,e)=>{t.bottom.top.inset(10),t.left.equalTo(e.prev.prev.right).offset(10),t.right.inset(10)}}]}}add(){const t={type:\"list\",props:{data:this.getListData(this.getUnsetActions()),template:this.getListTemplate(),rowHeight:50},events:{didSelect:(t,e,i)=>{const s=i.action.info,r=this.getActions();r.unshift(s),this.setActions(r),$(this.listId).insert({indexPath:$indexPath(0,0),value:this.getListData([s])[0]}),t.delete(e)}},layout:$layout.fill};(new i).setView(t).addNavBar({title:$l10n(\"ADD\"),popButton:{title:$l10n(\"CLOSE\")}}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListView(){return{type:\"list\",props:{id:this.listId,data:this.getListData(this.getActions()),template:this.getListTemplate(),rowHeight:50,reorder:!0,actions:[{title:\"delete\",handler:(t,e)=>{this.setActions(t.data.map((t=>t.action.info)))}}]},events:{reorderFinished:t=>{const e=[];t.forEach((t=>{e.push(t.action.info)})),this.setActions(e)}},layout:$layout.fill}}static sheet(t){const e=new i,r=new s(t);e.setView(r.getListView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{title:$l10n(\"CLOSE\")},rightButtons:r.getNavButtons()}),e.init().present()}}t.exports=s})),parcelRequire.register(\"7eNYp\",(function(t,e){var i=parcelRequire(\"eSp9Z\"),s=i.ActionData,r=i.ActionEnv,n=parcelRequire(\"gxpqj\"),a=n.View,o=n.UIKit,l=n.Sheet,h=n.BarButtonItem,c=parcelRequire(\"imdB1\"),d=parcelRequire(\"2aNLD\");t.exports=class extends c{#F;keyboardId=\"keyboard.main\";listId=\"keyboard-clips-list\";actionsId=\"keyboard-list-actions\";keyboardSwitchLockId=\"keyboard-switch-lock\";keyboardSwitchLockKey=\"caio.keyboard.switch.lock\";deleteTimer=void 0;continuousDeleteTimer=void 0;continuousDeleteTapticTimer=void 0;continuousDeleteDelay=.5;horizontalMargin=15;verticalMargin=12;copiedIndicatorSize=5;containerMargin=4;fontSize=14;tagHeight=this.verticalMargin+3;matrixBoxMargin=10;navHeight=50;bottomBarHeight=50;bottomButtonSize=$size(46,40);menuItemActionMaxCount=3;itemBackground=$color(\"#FFFFFF\",$rgba(151,151,151,.4));buttonBackground=$color($rgba(0,0,0,.15),$rgba(117,117,117,.4));constructor(t){super(t),this.keyboardDisplayMode=this.kernel.setting.get(\"keyboard.displayMode\"),this.backgroundImage=this.kernel.setting.get(\"keyboard.background.image\")?.image,this.useBlur=this.backgroundImage&&this.kernel.setting.get(\"keyboard.blur\"),this.deleteDelay=this.kernel.setting.get(\"keyboard.deleteDelay\"),\"boolean\"!=typeof $cache.get(this.keyboardSwitchLockKey)&&$cache.set(this.keyboardSwitchLockKey,!1)}get keyboardHeight(){return this.kernel.setting.get(\"keyboard.previewAndHeight\")}setKeyboardHeight(t){this.kernel.setting.set(\"keyboard.previewAndHeight\",t)}getKeyboardSwitchLock(){const t=$cache.get(this.keyboardSwitchLockKey);return\"boolean\"!=typeof t&&$cache.set(this.keyboardSwitchLockKey,!0),t}switchKeyboardSwitchLock(){const t=$cache.get(this.keyboardSwitchLockKey);$cache.set(this.keyboardSwitchLockKey,!t),$(this.keyboardSwitchLockId).symbol=t?\"lock.open\":\"lock\"}listReady(){this.updateList(),this.kernel.setting.get(\"clipboard.autoSave\")&&$app.env===$env.keyboard&&(this.#F=$timer.schedule({interval:1,handler:()=>{this.kernel.setting.get(\"clipboard.autoSave\")?this.readClipboard():this.#F.invalidate()}}))}keyboardTapped(t,e=!0){return async(...i)=>{if(e&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(this.kernel.setting.get(\"keyboard.tapticEngineLevel\")),\"function\"==typeof t)try{await t(...i)}catch(t){throw this.kernel.error(t),t}}}getTopButtons(){const t=[{symbol:\"keyboard.chevron.compact.down\",tapped:this.keyboardTapped((()=>$keyboard.dismiss()))},{symbol:\"square.and.arrow.down.on.square\",tapped:this.keyboardTapped((async t=>{t.start();try{await this.readClipboard(!0),t.done()}catch(e){throw t.cancel(),e}}))},{symbol:\"bolt.circle\",tapped:this.keyboardTapped((()=>{let t=!0===$(this.actionsId).hidden;$(this.listId+\"-container\").hidden=t,$(this.actionsId).hidden=!t}))}];return{type:\"view\",views:t.map(((t,e)=>{const i=new h;return i.buttonEdges=0,i.setAlign(o.align.right).setSymbol(t.symbol).setEvent(\"tapped\",t.tapped).definition})),layout:(e,i)=>{const s=new h;e.height.equalTo(i.super),e.right.inset(this.containerMargin-s.edges),e.width.equalTo(s.width*t.length+s.edges)}}}getTopBarView(){return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[{type:\"label\",props:{text:$l10n(\"CAIO\"),font:$font(\"bold\",20)},events:{tapped:()=>this.kernel.openInJsbox(),ready:t=>{$cache.get(\"tips.keyboard.title\")||($cache.set(\"tips.keyboard.title\",!0),$ui.popover({sourceView:t,size:$size(200,60),directions:$popoverDirection.up,views:[{type:\"label\",props:{lines:0,text:$l10n(\"CLICK_TO_OPEN_JSBOX\"),align:$align.center},layout:$layout.fillSafeArea}]}))}},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.equalTo(e.super).offset(this.containerMargin)}}].concat(this.tabView(),this.getTopButtons())}],layout:(t,e)=>{t.top.width.equalTo(e.super),t.height.equalTo(this.navHeight)}}}getBottomButtonView(t,e){const i=this.bottomButtonSize,s=this.containerMargin,r=(r,n)=>{if(t.title){const e=$text.sizeThatFits({text:t.title,width:o.windowSize.width,font:$font(16)}),n=Math.ceil(e.width)+2*(s+12);r.size.equalTo($size(n,i.height))}else r.size.equalTo(i);r.centerY.equalTo(n.super),n.prev&&n.prev.info.align===e?e===o.align.right?r.right.equalTo(n.prev.left).offset(1.5*-s):r.left.equalTo(n.prev.right).offset(1.5*s):e===o.align.right?r.right.inset(s):r.left.inset(s)},n={type:\"button\",props:Object.assign({smoothCorners:!1,cornerRadius:5,symbol:t.symbol,title:t.title,id:t.id??$text.uuid,font:$font(16),bgcolor:this.useBlur?$color(\"clear\"):this.buttonBackground,tintColor:o.textColor,titleColor:o.textColor,info:{align:e}},t.menu?{menu:t.menu}:{}),events:Object.assign({},t.tapped?{tapped:t.tapped}:{},t.events),layout:$layout.fill};return this.useBlur?o.blurBox({info:{align:e},style:$blurStyle.ultraThinMaterial,smoothCorners:!1,cornerRadius:5},[n],r):{type:\"view\",props:{info:{align:e}},views:[n],layout:r}}getBottomBarView(){const t=[],e=[];$device.hasFaceID&&!$device.isIpadPro||t.push({symbol:\"globe\",tapped:this.keyboardTapped((()=>$keyboard.next())),menu:{pullDown:!0,items:[{title:$l10n(\"SWITCH_KEYBOARD\"),handler:this.keyboardTapped((()=>$keyboard.next()))},{title:$l10n(\"OPEN_IN_JSBOX\"),handler:()=>this.kernel.openInJsbox()}]}}),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&t.push({symbol:this.getKeyboardSwitchLock()?\"lock\":\"lock.open\",id:this.keyboardSwitchLockId,tapped:this.keyboardTapped((()=>this.switchKeyboardSwitchLock()))}),t.push({symbol:\"paperplane\",menu:{pullDown:!0,asPrimary:!0,items:d.getAddins().reverse().map((t=>({title:t,handler:this.keyboardTapped((()=>$addin.run(t)))})))}}),e.push({title:$l10n(\"SEND\"),tapped:this.keyboardTapped((()=>$keyboard.send()))},{symbol:\"delete.left\",events:{touchesBegan:this.keyboardTapped((async()=>{$keyboard.delete(),this.continuousDeleteTapticTimer=$delay(this.continuousDeleteDelay,(()=>this.keyboardTapped()())),this.continuousDeleteTimer=$delay(this.continuousDeleteDelay,(()=>{this.deleteTimer=$timer.schedule({interval:this.deleteDelay,handler:()=>$keyboard.delete()})}))})),touchesEnded:()=>{this.deleteTimer?.invalidate(),this.continuousDeleteTimer?.cancel(),this.continuousDeleteTapticTimer?.cancel(),this.deleteTimer=void 0,this.continuousDeleteTimer=void 0}}});const i={type:\"button\",props:{smoothCorners:!1,cornerRadius:5,title:$l10n(\"SPACE\"),font:$font(16),bgcolor:this.itemBackground,titleColor:o.textColor},events:{tapped:this.keyboardTapped((()=>{$keyboard.insert(\" \")}))},layout:(t,i)=>{let s=i.prev;for(let t=0;tthis.getBottomButtonView(t,o.align.left))),...e.map((t=>this.getBottomButtonView(t,o.align.right))),i],layout:(t,e)=>{t.bottom.equalTo(e.super.safeArea).offset(-2),t.left.right.equalTo(e.super.safeArea),t.height.equalTo(this.bottomBarHeight)}}}menuItems(){const t=super.menuItems();return[t[0],t[2]]}itemContainer(t){return this.useBlur?o.blurBox({style:$blurStyle.ultraThinMaterial},t,$layout.fill):{type:\"view\",props:{bgcolor:this.itemBackground},views:t,layout:$layout.fill}}get matrixTemplate(){return{props:{smoothCorners:!0,cornerRadius:2*this.containerMargin},views:[this.itemContainer([{type:\"view\",props:{id:\"copied\",circular:this.copiedIndicatorSize,hidden:!0,bgcolor:$color(\"green\")},layout:(t,e)=>{t.size.equalTo(this.copiedIndicatorSize),t.left.top.inset(this.matrixBoxMargin/2)}},{type:\"label\",props:{id:\"content\",lines:0,font:$font(20)},layout:(t,e)=>{t.top.left.right.equalTo(e.super).inset(this.matrixBoxMargin),t.height.lessThanOrEqualTo(e.super).offset(2*-this.matrixBoxMargin-this.tagHeight)}},{type:\"label\",props:{id:\"tag\",lines:1,color:this.tagColor,autoFontSize:!0,align:$align.leading},layout:(t,e)=>{t.left.right.equalTo(e.prev),t.height.equalTo(this.tagHeight),t.bottom.equalTo(e.super).inset(this.matrixBoxMargin)}}]),{type:\"image\",props:{id:\"image\",hidden:!0},layout:$layout.fill}]}}get itemSelect(){return(t,e)=>{const i=this.clips[e.row];i.image?l.quickLookImage(i.imageOriginal):($keyboard.insert(i.text),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&!this.getKeyboardSwitchLock()&&$keyboard.next())}}getMatrixView(){const t={type:\"matrix\",props:{id:this.listId,bgcolor:$color(\"clear\"),menu:{items:this.menuItems()},direction:$scrollDirection.horizontal,square:!0,alwaysBounceVertical:!1,showsHorizontalIndicator:!1,alwaysBounceHorizontal:!0,columns:1,spacing:this.matrixBoxMargin,template:this.matrixTemplate},layout:(t,e)=>{t.top.inset(0),t.width.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom).offset(-1*(this.bottomBarHeight-this.navHeight))},events:{ready:()=>this.listReady(),didSelect:this.itemSelect,itemSize:(t,e)=>{let i=this.keyboardHeight-this.navHeight-this.bottomBarHeight;return i-=2*this.matrixBoxMargin,$size(i,i)}}},e=a.createFromViews([t,this.getEmptyBackground(this.listId)]);return e.setProp(\"id\",this.listId+\"-container\"),e}getListView(){const t=super.getListView();t.setProp(\"id\",this.listId+\"-container\"),t.layout=(t,e)=>{t.top.equalTo(this.navHeight-1),t.width.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom).offset(-this.bottomBarHeight-this.containerMargin)};const e=t.views[0];e.events.didSelect=this.itemSelect,e.props.separatorColor=$color(\"lightGray\"),e.props.separatorInset=$insets(0,this.horizontalMargin,0,this.horizontalMargin),delete e.events.pulled,e.props.header={props:{height:1}},e.props.style=2;const i=e.props.template.views[0].views;return e.props.template.views[0]=this.itemContainer(i),t}getDataView(){return 0===this.keyboardDisplayMode?this.getListView():this.getMatrixView()}getActionView(){return{type:\"view\",props:{id:this.actionsId,hidden:!0},views:[this.kernel.actionManager.getActionMiniView((async()=>new s({env:r.keyboard,textBeforeInput:$keyboard.textBeforeInput,textAfterInput:$keyboard.textAfterInput,text:$keyboard.selectedText??await $keyboard.getAllText()})))],layout:(t,e)=>{t.top.equalTo(this.navHeight),t.left.equalTo(this.containerMargin),t.right.equalTo(-this.containerMargin),t.bottom.equalTo(-this.bottomBarHeight)}}}getView(){const t={type:\"view\",views:[{type:\"image\",props:{image:this.backgroundImage},layout:$layout.fill},{type:\"view\",props:{bgcolor:$color(\"clear\",$rgba(0,0,0,.3))},layout:$layout.fill}],layout:$layout.fill};return{type:\"view\",props:{id:this.keyboardId},views:[this.backgroundImage?t:{},this.getDataView(),this.getTopBarView(),this.getBottomBarView(),this.getActionView()],layout:(t,e)=>{t.width.bottom.equalTo(e.super),t.height.equalTo(this.keyboardHeight)}}}}})),parcelRequire.register(\"49je6\",(function(t,e){var i=parcelRequire(\"eSp9Z\"),s=i.ActionData,r=i.ActionEnv,n=parcelRequire(\"gxpqj\"),a=n.View,o=n.UIKit,l=n.BarButtonItem,h=parcelRequire(\"imdB1\"),c=parcelRequire(\"ilpYs\");t.exports=class extends h{actionsId=\"today-list-actions\";listContainerId=\"today-list-container\";readClipboardButtonId=\"today-nav-readClipboard\";listId=\"today-list\";pageIndexId=\"today-list-page-index\";tabLeftMargin=8;horizontalMargin=15;verticalMargin=5;copiedIndicatorSize=5;fontSize=14;tagHeight=12;tagColor=$color(\"gray\",\"lightGray\");navHeight=34;taptic=1;inLauncher=$app.env===$env.today&&-1===$app.widgetIndex;launcherNavHeight=44;constructor(t){super(t),this.tabItems.push($l10n(\"ACTIONS\")),this.todayActions=new c(this.kernel),this.setClipboarPageSize($widget.mode),this.listPageNow=[0,0],this.listSection=Math.min(this.tabIndex,1),this.setSingleLine()}get isActionPage(){return 2===this.tabIndex}set tabIndex(t){$cache.set(\"caio.today.tab.index\",t)}get tabIndex(){return $cache.get(\"caio.today.tab.index\")??0}listReady(){$widget.modeChanged=t=>{this.setClipboarPageSize(t),this.isActionPage||this.updateList()},this.setClipboarPageSize($widget.mode),this.isActionPage||this.updateList(),this.appListen(),$delay(.5,(()=>this.readClipboard()))}async readClipboard(t=!1){this.isActionPage||$app.env!==$env.today||await super.readClipboard(t)}setClipboarPageSize(t){if(0===t)this.listPageSize=1;else{const t=(($app.env===$env.app?o.windowSize.height:$widget.height)-2*this.navHeight-(this.inLauncher?this.launcherNavHeight:0))/(this.singleLineContentHeight+this.verticalMargin+Math.max(this.tagHeight,this.verticalMargin)),e=Math.floor(t);this.listPageSize=e,t-e>=.6&&this.listPageSize++}}buttonTapped(t,e=!0){return async(...i)=>{e&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(this.taptic),await t(...i)}}switchTab(t){this.tabIndex=t,this.isActionPage?($(this.listContainerId).hidden=!0,$(this.actionsId).hidden=!1,$(this.readClipboardButtonId).hidden=!0):(this.listSection=t,$(this.actionsId).hidden=!0,$(this.listContainerId).hidden=!1,$(this.readClipboardButtonId).hidden=!1,this.updateList())}getNavBarView(){const t=[{symbol:\"square.and.arrow.down.on.square\",props:{id:this.readClipboardButtonId,hidden:this.isActionPage},tapped:this.buttonTapped((async t=>{t.start();try{await this.readClipboard(!0),t.done()}catch(e){throw t.cancel(),e}}))}].map((t=>{const e=new l;return e.setAlign(o.align.right).setSymbol(t.symbol).setEvent(\"tapped\",t.tapped).setProps(t.props??{}),e.definition}));return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[this.tabView(),...t]}],layout:(t,e)=>{t.top.width.equalTo(e.super),t.height.equalTo(this.navHeight)}}}getBottomBarView(){const t=t=>({type:\"button\",props:{symbol:t===o.align.left?\"chevron.backward.circle\":\"chevron.forward.circle\",bgcolor:$color(\"clear\"),tintColor:o.textColor},layout:i=>{t===o.align.left?i.left.inset(this.horizontalMargin):i.right.inset(this.horizontalMargin),i.centerY.equalTo(e.super)},events:{tapped:this.buttonTapped((()=>{t===o.align.left?this.clipboardPrevPage():this.clipboardNextPage()}))}}),e={type:\"view\",views:[t(o.align.left),t(o.align.right),{type:\"label\",props:{id:this.pageIndexId,align:$align.center,text:this.listPageNow[this.listSection]+1},layout:(t,e)=>{t.bottom.left.right.equalTo(e.super.safeArea),t.center.equalTo(e.super)}}],layout:(t,e)=>{t.bottom.left.right.equalTo(e.super.safeArea),t.height.equalTo(this.navHeight)}};return e}delete(...t){super.delete(...t),this.updateList()}updateList(t=!1){t&&this.setNeedReload();const e=this.listPageNow[this.listSection]*this.listPageSize,i=e+this.listPageSize,s=this.clips;$(this.listId).data=s.slice(e,i).map((t=>this.lineData(t,this.copied.uuid===t.uuid)));const r=this.listPageNow[this.listSection]+1,n=Math.ceil(s.length/this.listPageSize);$(this.pageIndexId).text=`${r}/${n}`}clipboardPrevPage(){this.listPageNow[this.listSection]>0&&(this.listPageNow[this.listSection]--,this.updateList())}clipboardNextPage(){const t=Math.ceil(this.clips.length/this.listPageSize);this.listPageNow[this.listSection]this.listReady(),rowHeight:(t,e)=>{const i=this.listPageSize*this.listPageNow[this.listSection],s=this.getByIndex(e.row+i),r=s.hasTag?this.tagHeight:this.verticalMargin,n=s.image?this.imageContentHeight:this.getContentHeight(s.text);return this.verticalMargin+n+r},didSelect:this.buttonTapped(((t,e)=>{const i=this.clips[e.row];i.image?$clipboard.image=i.imageOriginal:(this.setClipboardText(i.text),this.setCopied(i.uuid)),$ui.toast($l10n(\"COPIED\"))}))},layout:(t,e)=>{t.top.width.equalTo(e.super),t.bottom.equalTo(e.super).offset(-this.navHeight)}},this.getBottomBarView()],layout:(t,e)=>{t.top.equalTo(this.navHeight),t.bottom.left.right.equalTo(e.super.safeArea)}}}getActionView(){let t=this.todayActions.getActions();return 0===t.length&&(t=this.todayActions.getAllActions()),{type:\"view\",props:{id:this.actionsId,hidden:!this.isActionPage},views:[this.kernel.actionManager.getActionMiniView((t=>new s({env:r.today,text:\"clipboard\"===t.type||\"uncategorized\"===t.type?$clipboard.text:null})),t)],layout:(t,e)=>{t.top.equalTo(this.navHeight),t.left.right.bottom.equalTo(e.super.safeArea)}}}getView(){return a.create({props:{titleColor:o.textColor,barColor:o.primaryViewBackgroundColor},views:[{type:\"view\",views:[this.getNavBarView(),this.getActionView(),this.getListView()],layout:$layout.fill}],events:{appeared:async()=>{if($app.env!==$env.today)return;const t=$timer.schedule({interval:0,handler:()=>{$ui.animate({duration:.3,animation:()=>{$ui.vc.ocValue().$view().$setBackgroundColor($color(\"clear\"))},completion:()=>{t.invalidate()}})}})}}})}}})),parcelRequire.register(\"gD12U\",(function(t,e){var i=parcelRequire(\"gxpqj\"),s=i.Logger,r=i.Setting,n=i.FileStorage,a=parcelRequire(\"2EAPF\"),o=parcelRequire(\"jEwwi\").Storage;const l=new n;class h{static widgetInstance(t,...e){if($file.exists(`/scripts/widget/${t}.js`)){const{Widget:i}=require(`./widget/${t}.js`);return new i(...e)}return!1}static kernel(){const t=new s;t.printToFile(l,\"logs/widget.log\");const e={setting:new r({fileStorage:l,structure:a}),fileStorage:l,print:()=>{},error:e=>{t.error(e)}};e.setting.setReadonly();const i=new o(e);return e.storage=i,e}static renderError(){$widget.setTimeline({render:()=>({type:\"text\",props:{text:\"Invalid argument\"}})})}static renderClipboard(){(new r).setReadonly();h.widgetInstance(\"Clipboard\",h.kernel()).render()}static render(t=$widget.inputValue){\"Clipboard\"===(t=t??\"Clipboard\")?h.renderClipboard():h.renderError()}}t.exports={Widget:h,run:()=>{h.render()}}})),parcelRequire.register(\"ljE8b\",(function(t,e){var i=parcelRequire(\"34tpw\").AppKernelBase;class s extends i{constructor(){super(),this.setting.setReadonly()}addOpenInJsboxButton(){this.useJsboxNav(),this.setNavButtons([{image:$image(\"assets/icon.png\"),handler:()=>this.openInJsbox()}])}}class r{static kernel=$app.env!==$env.widget?new s:void 0;static renderKeyboardUI(){this.kernel.addOpenInJsboxButton();const t=new(parcelRequire(\"7eNYp\"))(this.kernel);this.kernel.KeyboardRender(t.getView())}static renderTodayUI(){this.kernel.addOpenInJsboxButton();const t=new(parcelRequire(\"49je6\"))(this.kernel);this.kernel.UIRender(t.getView())}}t.exports={run:()=>{$app.env===$env.today?r.renderTodayUI():$app.env===$env.keyboard&&r.renderKeyboardUI()}}})),$app.strings={en:{ALERT_INFO:\"Alert\",NONE:\"Nothing\",DONE:\"Done\",CLOSE:\"Close\",FAILED_TO_LOAD_VIEW:\"Faild to load view\",VIEW_NOT_PROVIDED:\"The view is not provided\",UNCATEGORIZED:\"Uncategorized\",SHARE:\"Share\",CLICK_TO_OPEN_JSBOX:\"Click the title to open the main app.\",CLIPS:\"Clips\",CLIPBOARD:\"Clipboard\",UNIVERSAL_CLIPBOARD:\"Universal Clipboard\",UNIVERSAL_CLIPBOARD_TIPS:\"Universal Clipboard allows you to copy something on your iPhone, and paste it on your Mac–or vice-versa–using iCloud.\",CLIPS_STRUCTURE_ERROR:\"Clips data structure is abnormal\",CLIPBOARD_NO_CHANGE:\"Clipboard no change\",RECYCLE_BIN:\"Recycle Bin\",ADD:\"Add\",TAG:\"Tag\",ADD_TAG:\"Add Tag\",EDIT:\"Edit\",SEARCH:\"Search\",SEARCH_HISTORY:\"Search History\",SEARCH_RESULT:\"Search Result\",NO_SEARCH_RESULT:\"No item found.\",FAVORITE:\"Favorite\",COPY:\"Copy\",COPIED:\"Copied\",SORT:\"Sort\",ACTIONS:\"Actions\",MORE_ACTIONS:\"More Actions\",PREVIEW:\"Preview\",MAX_ITEM_LENGTH:\"Line Limit\",TEXT_MAX_LENGTH:\"Display Character Length\",AUTO_SAVE:\"Auto Save\",AUTO_SYNC:\"Auto Sync\",SYNC_NOW:\"Sync Now\",UNZIP_FAILED:\"Unzip file failed\",REBUILD:\"Rebuild\",REBUILD_DATABASE:\"Rebuild Database\",REBUILD_DATABASE_ALERT:\"Rebuilding the database will lose the order information, do you want to confirm the rebuild?\",DELETE_ALL_DATA:\"Delete All Data\",DELETE_ALL_DATA_ALERT:\"Are you sure you want to delete all your data?\",DELETE_DATA:\"Delete Data\",DELETE_TABLE:\"Delete all data from `${table}`?\",SELECT_ALL:\"Select All\",DESELECT_ALL:\"Deselect All\",EDITOR:\"Editor\",CREATE_NEW:\"Create New\",CREATE_NEW_ACTION:\"New Action\",CREATE_NEW_TYPE:\"New Category\",TYPE_ALREADY_EXISTS:\"This category already exists\",EDIT_DETAILS:\"Edit Details\",EDIT_SCRIPT:\"Edit Script\",INFORMATION:\"Information\",NAME:\"Name\",ICON:\"Icon\",TYPE:\"Category\",DESCRIPTION:\"Description\",CODE:\"Code\",TEXT_INSETS:\"Text bottom margin\",SHOW_LINE_NUMBER:\"Show line number\",LIGHT_MODE_THEME:\"Light Mode Theme\",DARK_MODE_THEME:\"Dark Mode Theme\",SAVE:\"Save\",SAVE_SUCCESS:\"Save success\",SAVE_ERROR:\"Save failed\",DELETE:\"Delete\",CONFIRM:\"Confirm\",DELETE_CONFIRM_MSG:\"Are you sure you want to delete?\",DELETE_SUCCESS:\"Delete success\",DELETE_ERROR:\"Delete failed\",IMPORT_EXAMPLE_ACTIONS:\"Import example actions\",REBUILD_ACTION_DATABASE:\"Rebuild Action Database\",REBUILD_ACTION_DATABASE_ALERT_TITLE:\"Are you sure you want to rebuild?\",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:\"Rebuild also deletes the data saved in WebDAV Drive! (If enabled)\",EXPORT:\"Export\",IMPORT:\"Import\",FILE_TYPE_ERROR:\"File type does not match\",OVERWRITE_ALERT:\"This operation will overwrite the current data. Do you want to continue?\",UNABLE_CREATE_ACTION:\"Unable to create action\",ACTION_NAME_ALREADY_EXISTS:\"Action `${name}` already exists\",KEYBOARD:\"Keyboard\",KEYBOARD_HEIGHT:\"Keyboard Height\",USE_BLUR:\"Use Blur\",BACKGROUND_IMAGE:\"Background Image\",DELETE_DELAY:\"Delete Delay\",SWITCH_AFTER_INSERT:\"Switch After Insert\",JSBOX_TOOLBAR:\"JSBox Toolbar\",QUICK_START_SCRIPTS:\"Quick Start Scripts\",SEND:\"Send\",OPEN_IN_JSBOX:\"Open in JSBox\",SWITCH_KEYBOARD:\"Switch Keyboard\",TAPTIC_ENGINE:\"Taptic Engine\",TAPTIC_ENGINE_LEVEL:\"Taptic Engine Level\",TAPTIC_ENGINE_FOR_DELETE:\"Taptic Engine For Delete\",SPACE:\"Space\",ALL_SCRIPTS:\"All Scripts\",SELECT_SCRIPTS:\"Select Scripts\",CHECK_UPDATE:\"Check Update\",UPDATE:\"Update\",WIDGET:\"Widget\",RECENT:\"Recent\",CLICK_ACTION:\"Click Action\",TODAY_WIDGET:\"Today Widget\",PREV_PAGE:\"Prev\",NEXT_PAGE:\"Next\",DISPLAY_MODE:\"Display Mode\",CLASSIC:\"Classic\",MODERN:\"Modern\",FILE_MANAGEMENT:\"File Management\",\"compatibility.rebuildUserAction.alert.title\":\"We need to rebuild some of the action!\",\"compatibility.rebuildUserAction.alert.message\":\"If you tap the OK button, the following actions will be rebuilt:\",\"compatibility.rebuildUserAction.alert.message2\":\"Only the action logic will be changed, and the name and icon will remain as it is.\",EXPERIMENTAL:\"Experimental\",SYNC_ACTIONS:\"Sync Actions\",SYNCING:\"Syncing...\",LAST_SYNC_AT:\"Last sync at: \",MODIFIED:\"Modified: \",HOST:\"Host\",USER:\"User\",PASSWORD:\"Password\",BASEPATH:\"Base Path\",DATA_CONFLICT:\"A data synchronization conflict occurred\",DATA_CONFLICT_MESSAGE:\"Select the data you want to keep\",WEBDAV_DATA:\"WebDAV data\",LOCAL_DATA:\"Local data\",ACTION_SAFETY_WARNING:\"Action safety warning\",ACTION_PERMISSION_REQUEST:\"Action permission request\",ACTION_RESET_NAME_WARNING:\"Action `${name}` is attempting to change its name to `${to_name}`, which may result in it gaining all permissions associated with `${to_name}`.\",ACTION_NETWORK_PERMISSION_MESSAGE:\"Would you like to grant Action `${name}` network permissions?\"},\"zh-Hans\":{ALERT_INFO:\"提示\",NONE:\"什么都没有\",DONE:\"完成\",CLOSE:\"关闭\",FAILED_TO_LOAD_VIEW:\"加载视图失败\",VIEW_NOT_PROVIDED:\"未提供该视图\",UNCATEGORIZED:\"未分类\",SHARE:\"分享\",CLICK_TO_OPEN_JSBOX:\"点击标题打开主应用。\",CLIPS:\"剪切板\",CLIPBOARD:\"剪切板\",UNIVERSAL_CLIPBOARD:\"通用剪贴板\",UNIVERSAL_CLIPBOARD_TIPS:\"用剪贴板允许您在 iPhone 上复制某些内容,然后使用 iCloud 将其粘贴到 Mac 上(反之亦然)。\",CLIPS_STRUCTURE_ERROR:\"剪切板数据结构异常\",CLIPBOARD_NO_CHANGE:\"剪切板无变化\",RECYCLE_BIN:\"回收站\",ADD:\"添加\",TAG:\"标签\",ADD_TAG:\"添加标签\",EDIT:\"编辑\",SEARCH:\"搜索\",SEARCH_HISTORY:\"搜索历史\",SEARCH_RESULT:\"搜索结果\",NO_SEARCH_RESULT:\"搜索无结果\",FAVORITE:\"收藏\",COPY:\"复制\",COPIED:\"已复制\",SORT:\"排序\",ACTIONS:\"动作\",MORE_ACTIONS:\"更多动作\",PREVIEW:\"预览\",MAX_ITEM_LENGTH:\"行数限制\",TEXT_MAX_LENGTH:\"显示字符长度\",AUTO_SAVE:\"自动保存\",AUTO_SYNC:\"自动同步\",SYNC_NOW:\"立即同步\",UNZIP_FAILED:\"解压文件失败\",REBUILD:\"重建\",REBUILD_DATABASE:\"重建数据库\",REBUILD_DATABASE_ALERT:\"重建数据库将会丢失顺序信息,是否确认重建?\",DELETE_ALL_DATA:\"删除所有数据\",DELETE_ALL_DATA_ALERT:\"确定要删除所有数据吗?\",DELETE_DATA:\"删除数据\",DELETE_TABLE:\"删除 `${table}` 的所有数据?\",SELECT_ALL:\"全选\",DESELECT_ALL:\"取消全选\",EDITOR:\"编辑器\",CREATE_NEW:\"新建\",CREATE_NEW_ACTION:\"新建动作\",CREATE_NEW_TYPE:\"新建分类\",TYPE_ALREADY_EXISTS:\"该类别已经存在\",EDIT_DETAILS:\"编辑信息\",EDIT_SCRIPT:\"编辑脚本\",INFORMATION:\"信息\",NAME:\"名称\",ICON:\"图标\",TYPE:\"分类\",DESCRIPTION:\"描述\",CODE:\"代码\",TEXT_INSETS:\"文本下边距\",SHOW_LINE_NUMBER:\"显示行号\",LIGHT_MODE_THEME:\"浅色模式主题\",DARK_MODE_THEME:\"深色模式主题\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\",SAVE_ERROR:\"保存失败\",DELETE:\"删除\",CONFIRM:\"确认\",DELETE_CONFIRM_MSG:\"确认要删除吗?\",DELETE_SUCCESS:\"删除成功\",DELETE_ERROR:\"删除失败\",IMPORT_EXAMPLE_ACTIONS:\"导入示例动作\",REBUILD_ACTION_DATABASE:\"重建动作库\",REBUILD_ACTION_DATABASE_ALERT_TITLE:\"您确认要重建?\",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:\"重建会同时删除保存在 WebDAV 中的数据!(如果开启的话)\",EXPORT:\"导出\",IMPORT:\"导入\",FILE_TYPE_ERROR:\"文件类型不符\",OVERWRITE_ALERT:\"该操作将会覆盖当前数据,是否继续?\",UNABLE_CREATE_ACTION:\"无法创建动作\",ACTION_NAME_ALREADY_EXISTS:\"动作 `${name}` 已存在\",KEYBOARD:\"键盘\",KEYBOARD_HEIGHT:\"键盘高度\",USE_BLUR:\"使用模糊效果\",BACKGROUND_IMAGE:\"背景图片\",DELETE_DELAY:\"删除延时\",SWITCH_AFTER_INSERT:\"输入后切换\",JSBOX_TOOLBAR:\"JSBox 工具栏\",QUICK_START_SCRIPTS:\"快速启动脚本\",SEND:\"发送\",OPEN_IN_JSBOX:\"在 JSBox 中打开\",SWITCH_KEYBOARD:\"切换键盘\",TAPTIC_ENGINE:\"触感反馈\",TAPTIC_ENGINE_LEVEL:\"触感反馈强度\",TAPTIC_ENGINE_FOR_DELETE:\"删除按钮触感反馈\",SPACE:\"空格\",ALL_SCRIPTS:\"所有脚本\",SELECT_SCRIPTS:\"选择脚本\",CHECK_UPDATE:\"检查更新\",UPDATE:\"更新\",WIDGET:\"小组件\",RECENT:\"最近内容\",CLICK_ACTION:\"点击事件\",TODAY_WIDGET:\"通知中心小组件\",PREV_PAGE:\"上一页\",NEXT_PAGE:\"下一页\",DISPLAY_MODE:\"显示模式\",CLASSIC:\"经典\",MODERN:\"现代\",FILE_MANAGEMENT:\"文件管理\",\"compatibility.rebuildUserAction.alert.title\":\"我们需要重建部分动作!\",\"compatibility.rebuildUserAction.alert.message\":\"如果您点击 好,以下动作将会被重建:\",\"compatibility.rebuildUserAction.alert.message2\":\"只有动作逻辑会被更改,名称和图标将维持现状。\",EXPERIMENTAL:\"实验功能\",SYNC_ACTIONS:\"动作同步\",SYNCING:\"正在同步...\",LAST_SYNC_AT:\"最后同步:\",MODIFIED:\"最近修改:\",HOST:\"Host\",USER:\"User\",PASSWORD:\"Password\",BASEPATH:\"Base Path\",DATA_CONFLICT:\"数据同步发生冲突\",DATA_CONFLICT_MESSAGE:\"请选择想要保留的数据\",WEBDAV_DATA:\"WebDAV 数据\",LOCAL_DATA:\"本地数据\",ACTION_SAFETY_WARNING:\"动作安全警告\",ACTION_PERMISSION_REQUEST:\"动作权限申请\",ACTION_RESET_NAME_WARNING:\"动作 `${name}` 正在尝试将名称改为 `${to_name}`,这可能导致其获取 `${to_name}` 的所有权限\",ACTION_NETWORK_PERMISSION_MESSAGE:\"是否允许动作 `${name}` 获取网络权限?\"}},$app.theme=\"auto\",$app.minSDKVer=\"2.19.0\",$app.minOSVer=\"14.0.0\",$app.idleTimerDisabled=!1,$app.keyboardToolbarEnabled=!0,$app.rotateDisabled=!1,__INFO__={name:\"CAIO\",version:\"1.10.8\",author:\"ipuppet\",module:!1},__README__={\"README.md\":\"# CAIO\\r\\n\\r\\n> Clipboard all in one.\\r\\n> \\r\\n> A Clipboard tool based on JSBox.\\r\\n\\r\\nSupport for home widget and notification center widgets.\\r\\n\\r\\n## Build Taio Action\\r\\n\\r\\nBuild script depend on [Parcel](https://parceljs.org/).\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\nYou can also use the packaged files directly [dist/CAIO-en.json](./dist/CAIO-en.json).\\r\\n\\r\\n## Actions\\r\\n\\r\\n> For details on how to write, see `scripts/action/README.md` or the book button in the upper right corner of the `Action` edit page in the app.\\r\\n\\r\\n### `Action` data difference in different environments\\r\\n\\r\\n- The data processed by the `Action` button at the top of the home page is the currently copied content.\\r\\n- The data processed by the `Action` menu that pops up by long-pressing the list is the selected content.\\r\\n- The data processed by the `Action` button in the editor is whatever is being edited.\\r\\n\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> Click to copy, long press to trigger the action.\\r\\n\\r\\nPlease try to avoid using the Today Widget when JSBox is running CAIO.\\r\\n\\r\\n## WebDAV\\r\\n\\r\\n> Sync data with WebDAV.\\r\\n\\r\\nConfig Example: \\r\\nHost: https://example.com/dav \\r\\nUser: guest \\r\\nPassword: password123 \\r\\nBast Path: /path/to/save/appdata\\r\\n\",\"README_CN.md\":\"# CAIO\\r\\n\\r\\n> Clipboard all in one.\\r\\n> \\r\\n> A Clipboard tool based on JSBox.\\r\\n\\r\\n支持桌面小组件和通知中心小组件\\r\\n\\r\\n## 构建 Taio 动作\\r\\n\\r\\n构建脚本依赖 [Parcel](https://parceljs.org/)\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\n您也可以直接使用已打包好的文件 [dist/CAIO-zh-Hans.json](./dist/CAIO-zh-Hans.json)\\r\\n\\r\\n## Actions\\r\\n\\r\\n> 编写方式详见 `scripts/action/README.md` 或应用内 `Action` 编辑页面右上角图书按钮。\\r\\n\\r\\n### 不同环境中 `Action` 数据区别\\r\\n\\r\\n- 首页顶部 `Action` 按钮处理的数据为当前复制的内容\\r\\n- 长按列表弹出的 `Action` 菜单处理的数据为被选中的内容\\r\\n- 编辑器中顶部 `Action` 按钮(闪电图形按钮)处理的数据为正在编辑的所有内容\\r\\n\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> 点击复制,长按触发动作。\\r\\n\\r\\n请尽量避免在 JSBox 运行 CAIO 时使用 Today Widget\\r\\n\\r\\n## WebDAV\\r\\n\\r\\n> 通过 WebDAV 同步数据\\r\\n\\r\\n示例配置: \\r\\nHost: https://example.com/dav \\r\\nUser: guest \\r\\nPassword: password123 \\r\\nBast Path: /path/to/save/appdata\\r\\n\"},__ACTIONS__={clipboard:{B23Clean:{\"config.json\":'{\\n \"icon\": \"trash\",\\n \"color\": \"#FF0000\",\\n \"name\": \"b23 清除追踪\"\\n}',\"main.js\":'/**\\n * @typedef {import(\"../../action\").Action} Action\\n */\\nclass MyAction extends Action {\\n l10n() {\\n return {\\n \"zh-Hans\": {\\n \"b23clean.converting\": \"正在转换...\",\\n \"b23clean.noUrl\": \"未检测到链接\",\\n \"b23clean.noBiliUrl\": \"未检测到 bilibili 链接\",\\n \"b23clean.success\": \"已转换为 BV 视频链接\",\\n \"b23clean.noChange\": \"无变化\",\\n \"b23clean.multipleLinks\": \"多条链接仅在编辑模式下可用。\"\\n },\\n en: {\\n \"b23clean.converting\": \"Converting...\",\\n \"b23clean.noUrl\": \"No link detected\",\\n \"b23clean.noBiliUrl\": \"bilibili link not detected\",\\n \"b23clean.success\": \"Converted to BV video link\",\\n \"b23clean.noChange\": \"No change\",\\n \"b23clean.multipleLinks\": \"Multiple links are only available in edit mode.\"\\n }\\n }\\n }\\n\\n async cleanUrl(b23url) {\\n if (b23url.indexOf(\"bilibili.com\") === -1 && b23url.indexOf(\"b23.tv\") === -1) {\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\n }\\n\\n let url = b23url\\n if (b23url.indexOf(\"b23.tv\") >= 0) {\\n const resp = await $http.get(b23url)\\n url = resp.response.url\\n }\\n\\n const queryStart = url.indexOf(\"?\")\\n if (queryStart > -1) {\\n url = url.substring(0, queryStart - 1)\\n }\\n\\n return url\\n }\\n\\n /**\\n * 系统会调用 do() 方法\\n */\\n async do() {\\n $ui.toast($l10n(\"b23clean.converting\"), 1000)\\n\\n try {\\n const b23url = this.getUrls()\\n if (b23url.length === 0) {\\n throw new Error($l10n(\"b23clean.noUrl\"))\\n }\\n\\n if (b23url.length === 1) {\\n let url = await this.cleanUrl(b23url[0])\\n $ui.clearToast()\\n $ui.alert({\\n title: $l10n(\"b23clean.success\"),\\n message: url,\\n actions: [\\n { title: $l10n(\"OK\") },\\n {\\n title: $l10n(\"COPY\"),\\n handler: () => {\\n $clipboard.text = url\\n $ui.success($l10n(\"COPIED\"))\\n }\\n }\\n ]\\n })\\n } else {\\n if (this.env !== ActionEnv.editor) {\\n $ui.toast($l10n(\"b23clean.multipleLinks\"))\\n return\\n }\\n let flag = false\\n for (let i = 0; i < b23url.length; i++) {\\n try {\\n const url = b23url[i].trim()\\n const replacedUrl = await this.cleanUrl(url)\\n flag = true\\n\\n if (url !== replacedUrl) {\\n const newText = this.text.replace(url, replacedUrl)\\n this.setContent(newText)\\n }\\n } catch {}\\n }\\n if (!flag) {\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\n } else {\\n $ui.toast($l10n(\"b23clean.noChange\"))\\n }\\n }\\n } catch (error) {\\n $ui.clearToast()\\n $delay(0.5, () => $ui.error(error))\\n }\\n }\\n}\\n',\"README.md\":\"## B23Clean\\r\\n\\r\\n清除 b23.tv 分享链接中的追踪参数,转换为 BV 视频链接。\"},CleanClipboard:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"清除剪切板\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"clipboard.clean.success\": \"剪切板已清空\"\\r\\n },\\r\\n en: {\\r\\n \"clipboard.clean.success\": \"Clipboard is cleaned\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n do() {\\r\\n $clipboard.clear()\\r\\n $ui.success($l10n(\"clipboard.clean.success\"))\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## CleanClipboard\\r\\n\\r\\n清空当前剪切板内容。\"},DownloadFromUrl:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.down\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"从链接下载\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n async downloadContent(url) {\\r\\n const response = await $http.get({\\r\\n url,\\r\\n showsProgress: true\\r\\n })\\r\\n if (response.error) {\\r\\n $ui.alert(response.error.localizedDescription)\\r\\n } else {\\r\\n return response\\r\\n }\\r\\n }\\r\\n\\r\\n async do() {\\r\\n const url = this.getUrls()\\r\\n let response = undefined\\r\\n if (url.length > 1) {\\r\\n $ui.menu({\\r\\n items: url,\\r\\n handler: async (title, index) => {\\r\\n response = await this.downloadContent(url[index])\\r\\n }\\r\\n })\\r\\n } else if (url.length === 1) {\\r\\n response = await this.downloadContent(url[0])\\r\\n } else {\\r\\n $ui.warning(\"未检测到链接\")\\r\\n return\\r\\n }\\r\\n $share.sheet([\\r\\n {\\r\\n name: response.response.suggestedFilename,\\r\\n data: response.data\\r\\n }\\r\\n ])\\r\\n return response\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DownloadFromUrl\\r\\n\\r\\n从链接下载内容,如 js 文件内容等。\"},GetFromWin:{\"config.json\":'{\\n \"icon\": \"square.and.arrow.down\",\\n \"color\": \"#33CC33\",\\n \"name\": \"读取 clipsync\"\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"GET\")\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n $clipboard.text = resp.data.data\\r\\n if ($app.env === $env.keyboard) {\\r\\n $keyboard.insert(resp.data.data)\\r\\n }\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## GetFromWin\\r\\n\\r\\n通 clipsync 读取 PC 剪切板。\\r\\n\\r\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\r\\n\"},OpenUrl:{\"config.json\":'{\\r\\n \"icon\": \"link\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"打开链接\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"openLink.nourl\": \"未检测到链接\"\\r\\n },\\r\\n en: {\\r\\n \"openLink.nourl\": \"No link detected\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n openUrl(url) {\\r\\n $app.openURL(url.trim())\\r\\n }\\r\\n\\r\\n do() {\\r\\n const url = this.getUrls()\\r\\n if (url.length > 1) {\\r\\n $ui.menu({\\r\\n items: url,\\r\\n handler: (title, index) => {\\r\\n this.openUrl(url[index])\\r\\n }\\r\\n })\\r\\n } else if (url.length === 1) {\\r\\n this.openUrl(url[0])\\r\\n } else {\\r\\n $ui.warning($l10n(\"openLink.nourl\"))\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## OpenUrl\\r\\n\\r\\n提取文本中的URL并打开。\"},RawRepoConverter:{\"config.json\":'{\\r\\n \"icon\": \"link\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"RawRepoConverter\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n #component\\r\\n\\r\\n get component() {\\r\\n if (!this.#component) {\\r\\n const url = String(this.text)\\r\\n const path = url.substring(url.indexOf(\"/\", \"https://\".length) + 1)\\r\\n this.#component = path.split(\"/\")\\r\\n }\\r\\n return this.#component\\r\\n }\\r\\n\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"openLink.nourl\": \"未检测到链接\"\\r\\n },\\r\\n en: {\\r\\n \"openLink.nourl\": \"No link detected\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n githubusercontent() {\\r\\n const user = this.component[0],\\r\\n repository = this.component[1],\\r\\n branch = this.component[2],\\r\\n file = this.component.slice(3).join(\"/\")\\r\\n return `https://github.com/${user}/${repository}/blob/${branch}/${file}`\\r\\n }\\r\\n\\r\\n github() {\\r\\n const user = this.component[0],\\r\\n repository = this.component[1],\\r\\n blob = this.component[2],\\r\\n branch = this.component[3],\\r\\n file = this.component.slice(4).join(\"/\")\\r\\n return `https://raw.githubusercontent.com/${user}/${repository}/${branch}/${file}`\\r\\n }\\r\\n\\r\\n do() {\\r\\n let result\\r\\n const url = String(this.text)\\r\\n if (url.includes(\"raw.githubusercontent.com\")) {\\r\\n result = this.githubusercontent(url)\\r\\n } else if (url.includes(\"github.com\")) {\\r\\n if (url.includes(\"?raw=true\")) {\\r\\n result = url.replace(\"?raw=true\", \"\")\\r\\n } else {\\r\\n result = this.github()\\r\\n }\\r\\n } else {\\r\\n $ui.warning($l10n(\"openLink.nourl\"))\\r\\n return\\r\\n }\\r\\n\\r\\n $ui.success($l10n(\"COPIED\"))\\r\\n $clipboard.text = result\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## RawRepoConverter\\r\\n\\r\\nGithub Raw 链接和 Repository 链接转换器\\r\\n\"},SendToWin:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#33CC33\",\\r\\n \"name\": \"推送 clipsync\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"POST\", {\\r\\n data: this.text\\r\\n })\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## SendToWin\\r\\n\\r\\n通 clipsync 推送剪切板至 PC。\\r\\n\\r\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\r\\n\"},Tokenize:{\"config.json\":'{\\r\\n \"icon\": \"pencil.and.ellipsis.rectangle\",\\r\\n \"color\": \"#0099FF\",\\r\\n \"name\": \"分词复制\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n getView() {\\r\\n const color = {\\r\\n background: {\\r\\n normal: $color(\"#E7F2FF\", \"#E7F2FF\"),\\r\\n highlight: $color(\"##074FF\", \"#BBDAFF\")\\r\\n },\\r\\n text: {\\r\\n normal: $color(\"##074FF\", \"##074FF\"),\\r\\n highlight: $color(\"#FFFFFF\", \"#ADADAD\")\\r\\n }\\r\\n }\\r\\n const fontSize = 16\\r\\n const edges = 10\\r\\n return {\\r\\n type: \"matrix\",\\r\\n layout: $layout.fill,\\r\\n props: {\\r\\n spacing: edges,\\r\\n data: this.results.map(item => ({ label: { text: item } })),\\r\\n template: {\\r\\n views: [{\\r\\n type: \"label\",\\r\\n props: {\\r\\n id: \"label\",\\r\\n align: $align.center,\\r\\n cornerRadius: edges,\\r\\n bgcolor: color.background.normal,\\r\\n font: $font(fontSize),\\r\\n textColor: color.text.normal\\r\\n },\\r\\n layout: $layout.fill\\r\\n }]\\r\\n }\\r\\n },\\r\\n events: {\\r\\n highlighted: () => { },\\r\\n itemSize: (sender, indexPath) => {\\r\\n const width = fontSize * this.results[indexPath.item].length + 1\\r\\n if (this.maxtrixItemHeight === undefined)\\r\\n this.maxtrixItemHeight = fontSize + edges * 2\\r\\n return $size(width + edges * 2, this.maxtrixItemHeight)\\r\\n },\\r\\n didSelect: (sender, indexPath) => {\\r\\n const index = this.selected.indexOf(indexPath.item)\\r\\n const label = sender.cell(indexPath).get(\"label\")\\r\\n if (index === -1) {\\r\\n this.selected.push(indexPath.item)\\r\\n label.bgcolor = color.background.highlight\\r\\n label.textColor = color.text.highlight\\r\\n } else {\\r\\n this.selected.splice(index, 1)\\r\\n label.bgcolor = color.background.normal\\r\\n label.textColor = color.text.normal\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n }\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n */\\r\\n do() {\\r\\n this.selected = []\\r\\n this.results = []\\r\\n $text.tokenize({\\r\\n text: this.text,\\r\\n handler: results => {\\r\\n this.results = results\\r\\n this.pageSheet({\\r\\n view: this.getView(),\\r\\n done: () => {\\r\\n const result = []\\r\\n this.selected.sort().forEach(i => {\\r\\n result.push(this.results[i])\\r\\n })\\r\\n if (result.length > 0) {\\r\\n const text = result.join(\"\")\\r\\n $clipboard.text = text\\r\\n $ui.alert({\\r\\n title: \"完成\",\\r\\n message: `已复制内容:${text}`\\r\\n })\\r\\n }\\r\\n }\\r\\n })\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## Tokenize\\r\\n\\r\\n将文本分词处理后复制。\"}},editor:{PreviewMarkdown:{\"config.json\":'{\\r\\n \"icon\": \"book\",\\r\\n \"color\": \"#9900CC\",\\r\\n \"name\": \"预览Markdown\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n do() {\\r\\n this.pageSheet({\\r\\n view: {\\r\\n type: \"markdown\",\\r\\n props: { content: this.text },\\r\\n layout: $layout.fill\\r\\n }\\r\\n })\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## PreviewMarkdown\\r\\n\\r\\n预览Markdown。\"},SelectedText:{\"config.json\":'{\\r\\n \"icon\": \"crop\",\\r\\n \"color\": \"#6699CC\",\\r\\n \"name\": \"选中的文本\"\\r\\n}',\"main.js\":\"class MyAction extends Action {\\r\\n do() {\\r\\n if (this.selectedRange.length > 0) {\\r\\n const selectedText = this.text\\r\\n $ui.alert(selectedText)\\r\\n }\\r\\n }\\r\\n}\\r\\n\",\"README.md\":\"## SelectedText\\r\\n\\r\\n显示选中的文本。\"}},uncategorized:{ActionEditPreview:{\"config.json\":'{\\r\\n \"icon\": \"play\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"编辑动作即时预览示例\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n * @typedef {import(\"../../action\").ActionData} ActionData\\r\\n * @typedef {import(\"../../action\").ActionEnv} ActionEnv\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n preview() {\\r\\n return new ActionData({\\r\\n text: \"hello word\"\\r\\n })\\r\\n }\\r\\n\\r\\n async do() {\\r\\n try {\\r\\n if (this.env !== ActionEnv.build) {\\r\\n $ui.toast(\"action editor only\")\\r\\n return\\r\\n }\\r\\n return this.text\\r\\n } catch (error) {\\r\\n $ui.alert(error)\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## ActionEditPreview\\r\\n\\r\\n编辑动作即时预览示例。\"},DeleteClips:{\"config.json\":'{\\r\\n \"icon\": \"trash\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"删除所有剪切板\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n async do() {\\r\\n try {\\r\\n const action = await this.clearAllClips()\\r\\n if (action) {\\r\\n $ui.success($l10n(\"DONE\"))\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.error(error)\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DeleteClips\\r\\n\\r\\n删除所有已保存的剪切板(不包括收藏)。\"},DisplayClipboard:{\"config.json\":'{\\r\\n \"icon\": \"option\",\\r\\n \"color\": \"#FF6633\",\\r\\n \"name\": \"显示剪切板\"\\r\\n}',\"main.js\":'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n const image = $clipboard.image\\r\\n if (image) {\\r\\n this.quickLookImage(image)\\r\\n } else {\\r\\n this.pageSheet({\\r\\n view: {\\r\\n type: \"label\",\\r\\n props: {\\r\\n lines: 0,\\r\\n text: $clipboard.text,\\r\\n align: $align.center\\r\\n },\\r\\n layout: $layout.fill\\r\\n }\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## DisplayClipboard\\r\\n\\r\\n显示当前剪切板内的内容。\"},ExportAllContent:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#FF3300\",\\r\\n \"name\": \"导出数据\"\\r\\n}',\"main.js\":'class MyAction extends Action {\\r\\n do() {\\r\\n const data = this.getAllClips()\\r\\n if (data.clips.length > 0 || data.favorite.length > 0) {\\r\\n $share.sheet(JSON.stringify(data, null, 2))\\r\\n } else {\\r\\n $ui.alert(\"无数据\")\\r\\n }\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## ExportAllContent\\r\\n\\r\\n导出所有保存的数据。\"},Replace:{\"config.json\":'{\\r\\n \"icon\": \"square.and.arrow.up\",\\r\\n \"color\": \"#FF3300\",\\r\\n \"name\": \"查找替换\"\\r\\n}',\"main.js\":'function HtmlTemplate(html) {\\r\\n return `\\r\\n\\r\\n\\r\\n \\r\\n\\r\\n\\r\\n${html}\\r\\n\\r\\n\\r\\n`\\r\\n}\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n $ui.menu({\\r\\n items: [\"忽略大小写\", \"大小写敏感\", \"正则表达式\"],\\r\\n handler: async (title, idx) => {\\r\\n const patternText = await $input.text({\\r\\n placeholder: \"查找内容\"\\r\\n })\\r\\n const replaceString = await $input.text({\\r\\n placeholder: \"替换内容\"\\r\\n })\\r\\n let pattern = undefined\\r\\n if (idx === 0) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"gi\")\\r\\n } else if (idx === 1) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"g\")\\r\\n } else if (idx === 2) {\\r\\n pattern = new RegExp(patternText, \"g\")\\r\\n }\\r\\n\\r\\n const matchResultPreview = this.text.replaceAll(pattern, `${replaceString}`)\\r\\n const matchResult = this.text.replaceAll(pattern, replaceString)\\r\\n this.pageSheet({\\r\\n title: \"替换预览\",\\r\\n doneText: \"替换\",\\r\\n view: {\\r\\n type: \"web\",\\r\\n props: {\\r\\n html: HtmlTemplate(matchResultPreview)\\r\\n },\\r\\n layout: $layout.fill\\r\\n },\\r\\n done: () => {\\r\\n this.setContent(matchResult)\\r\\n }\\r\\n })\\r\\n }\\r\\n })\\r\\n // this.setContent(\"Hello world!\")\\r\\n }\\r\\n}\\r\\n',\"README.md\":\"## Replace\\r\\n\\r\\n查找替换\"}}},$app.env){case $env.app:case $env.action:$9ca6ee6eeae53f7f$var$AppInstance=parcelRequire(\"8Makm\");break;case $env.today:case $env.keyboard:$9ca6ee6eeae53f7f$var$AppInstance=parcelRequire(\"ljE8b\");break;case $env.widget:$9ca6ee6eeae53f7f$var$AppInstance=parcelRequire(\"gD12U\");break;default:$intents.finish(\"不支持在此环境中运行\"),$ui.render({views:[{type:\"label\",props:{text:\"不支持在此环境中运行\",align:$align.center},layout:$layout.fill}]})}$9ca6ee6eeae53f7f$var$AppInstance&&$9ca6ee6eeae53f7f$var$AppInstance.run()})();" + } + } + } + ], + "buildVersion": 1, + "clientMinVersion": 1, + "clientVersion": 592, + "icon": { + "glyph": "heart.text.square", + "color": "#FF6633" + }, + "summary": "A Clipboard tool based on JSBox.", + "name": "CAIO" +} \ No newline at end of file diff --git a/dist/CAIO.js b/dist/CAIO.js new file mode 100644 index 00000000..46457b3c --- /dev/null +++ b/dist/CAIO.js @@ -0,0 +1 @@ +(()=>{var $parcel$global="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequire94c2;let $9ca6ee6eeae53f7f$var$AppInstance;switch(null==parcelRequire&&(parcelRequire=function(t){if(t in $parcel$modules)return $parcel$modules[t].exports;if(t in $parcel$inits){var e=$parcel$inits[t];delete $parcel$inits[t];var i={id:t,exports:{}};return $parcel$modules[t]=i,e.call(i.exports,i,i.exports),i.exports}var s=new Error("Cannot find module '"+t+"'");throw s.code="MODULE_NOT_FOUND",s},parcelRequire.register=function(t,e){$parcel$inits[t]=e},$parcel$global.parcelRequire94c2=parcelRequire),parcelRequire.register("8Makm",(function(t,e){var i=parcelRequire("gxpqj"),s=i.UIKit,r=i.ViewController,n=i.TabBarController,a=parcelRequire("34tpw").AppKernelBase,o=parcelRequire("gYDdO"),l=parcelRequire("9RsVy");class h extends a{constructor(){super(),this.query=$context.query,l(this)}}class c{static kernel=$app.env!==$env.widget?new h:void 0;static renderMainUI(){const t={clips:{icon:"doc.on.clipboard",title:$l10n("CLIPS")},actions:{icon:"command",title:$l10n("ACTIONS")},setting:{icon:"gear",title:$l10n("SETTING")}};if(this.kernel.setting.setEvent("onSet",(t=>{"mainUIDisplayMode"===t&&$delay(.3,(()=>$addin.restart()))})),0===this.kernel.setting.get("mainUIDisplayMode"))this.kernel.useJsboxNav(),this.kernel.setting.useJsboxNav(),this.kernel.setNavButtons([{symbol:t.setting.icon,title:t.setting.title,handler:()=>{s.push({title:t.setting.title,views:[this.kernel.setting.getListView()]})}},{symbol:t.actions.icon,title:t.actions.title,handler:()=>{this.kernel.actionManager.present()}}]),this.kernel.UIRender(this.kernel.clips.getNavigationView().getPage());else{this.kernel.fileManager.setViewController(new r),this.kernel.tabBarController=new n;const e=this.kernel.clips.getNavigationView();this.kernel.tabBarController.setPages({clips:e.getPage(),actions:this.kernel.actionManager.getPage(),setting:this.kernel.setting.getPage()}).setCells({clips:t.clips,actions:t.actions,setting:t.setting}),this.kernel.UIRender(this.kernel.tabBarController.generateView().definition)}}}t.exports={run:()=>{o(c.kernel),c.renderMainUI()}}})),parcelRequire.register("gxpqj",(function(module,exports){var VERSION="1.4.3",AlertAction=class{title;handler;constructor({title:t=$l10n("OK"),disabled:e=!1,style:i=$alertActionType.default,handler:s=(()=>{})}={}){this.title=t,this.disabled=e,this.style=i,this.handler=s}},Alert=class t{id=$text.uuid;title;message;actions;titleFont=$font("bold",20);messageFont=$font(14);actionButtonFontSize=16;actionButtonHighlight=$color($rgba(0,0,0,.2),$rgba(255,255,255,.2));actionButtonHeight=35;actionButtonBoderWidth=.5;actionButtonBorderColor=$color("#C9C9C9","#383838");boxWidth=250;textVerticalMargin=20;textHorizontalMargin=50;constructor({title:t="",message:e="",actions:i=[]}={}){this.title=t,this.message=e,this.actions=i,0===this.actions.length&&this.actions.push(new AlertAction),this.titleSize=UIKit.getContentSize(this.titleFont,this.title,this.boxWidth-2*this.textHorizontalMargin),this.messageSize=UIKit.getContentSize(this.messageFont,this.message,this.boxWidth-2*this.textHorizontalMargin)}textView(){return{type:"view",views:[{type:"label",props:{lines:0,font:this.titleFont,text:this.title,color:$color("tint"),align:$align.center},layout:(t,e)=>{t.centerX.equalTo(e.super),t.width.equalTo(this.boxWidth-2*this.textHorizontalMargin),t.height.equalTo(this.titleSize.height),t.top.equalTo(this.textVerticalMargin)}},{type:"label",props:{lines:0,font:this.messageFont,text:this.message,align:$align.center},layout:(t,e)=>{t.centerX.equalTo(e.super),t.width.equalTo(this.boxWidth-2*this.textHorizontalMargin),t.height.equalTo(this.messageSize.height),t.top.equalTo(e.prev.bottom)}}],layout:(t,e)=>{t.top.width.equalTo(e.super),t.height.equalTo(this.titleSize.height+this.messageSize.height+2*this.textVerticalMargin)}}}actionView(){let t=(t,e)=>{let i=t=>2===this.actions.length?t.y>=0&&t.x>=0&&t.y<=this.actionButtonHeight&&t.x<=this.boxWidth/2:t.y>=0&&t.x>=0&&t.y<=this.actionButtonHeight&&t.x<=this.boxWidth,s=async(s,r,n)=>{t.disabled||(s.bgcolor=$color("clear"),i(r)&&("function"==typeof t.handler&&await t.handler({index:e,title:t.title}),this.dismiss()))},r=$color("tint"),n=$font(this.actionButtonFontSize);return t.disabled?r=$color("gray"):t.style===$alertActionType.destructive?r=$color("red"):t.style===$alertActionType.cancel&&(n=$font("bold",this.actionButtonFontSize)),{type:"label",props:{lines:1,text:t.title,align:$align.center,font:n,color:r,borderWidth:this.actionButtonBoderWidth,borderColor:this.actionButtonBorderColor,bgcolor:$color("clear")},events:{tapped:()=>{},touchesBegan:e=>{t.disabled||(e.bgcolor=this.actionButtonHighlight)},touchesEnded:s,touchesCancelled:s,touchesMoved:(e,s,r)=>{t.disabled||(i(s)?e.bgcolor=this.actionButtonHighlight:e.bgcolor=$color("clear"))}},layout:(t,e)=>{2===this.actions.length?e.prev?(t.left.equalTo(e.prev.right).offset(-this.actionButtonBoderWidth),t.width.equalTo(e.super).dividedBy(2).offset(this.actionButtonBoderWidth)):t.width.equalTo(e.super).dividedBy(2):(t.width.equalTo(e.super),e.prev&&t.top.equalTo(e.prev.bottom).offset(-this.actionButtonBoderWidth)),t.height.equalTo(this.actionButtonHeight)}}};return{type:"view",views:this.actions.map(((e,i)=>t(e,i))),layout:(t,e)=>{t.left.equalTo(e.super).offset(-this.actionButtonBoderWidth),t.width.equalTo(e.super).offset(2*this.actionButtonBoderWidth),t.bottom.equalTo(e.super),t.top.equalTo(e.prev.bottom)}}}getView(){let t={type:"view",props:{id:this.id+"-box",smoothCorners:!0,cornerRadius:20,bgcolor:$color("#FFFFFF","#000000")},views:[this.textView(),this.actionView()],layout:(t,e)=>{t.center.equalTo(e.super.safeArea);let i=this.titleSize.height+this.messageSize.height+2*this.textVerticalMargin,s=this.actions.length>2?this.actions.length:1;i+=this.actionButtonHeight*s,i-=this.actionButtonBoderWidth*s;let r=this.boxWidth-2*this.actionButtonBoderWidth;t.size.equalTo($size(r,i))}};return{type:"view",props:{id:this.id,alpha:0,bgcolor:$rgba(0,0,0,.6)},views:[t],layout:$layout.fill}}present(){let t=$ui.create(this.getView());$ui.controller.view.hidden?$ui.controller.view.super.insertAtIndex(t,0):$ui.controller.view.insertAtIndex(t,0);let e=$(this.id);e.layout($layout.fill),e.moveToFront(),$ui.animate({duration:.3,animation:()=>{e.alpha=1}})}dismiss(){let t=$(this.id);$ui.animate({duration:.3,animation:()=>{t.alpha=0},completion:()=>{t.remove()}})}static fromJsbox(e){return new Promise(((i,s)=>{new t({title:e.title,message:e.message,actions:e?.actions?.map((t=>(t.handler||(t.handler=t=>{i(t)}),new AlertAction(t))))}).present()}))}},Controller=class{events={};setEvents(t){return Object.keys(t).forEach((e=>this.setEvent(e,t[e]))),this}setEvent(t,e){return this.events[t]=e,this}appendEvent(t,e){let i=this.events[t];return"function"==typeof i?this.events[t]=(...t)=>{i(...t),e(...t)}:this.setEvent(t,e),this}callEvent(t,...e){"function"==typeof this.events[t]&&this.events[t](...e)}},FileManager=class{viewController;constructor(){this.listId="file-manager-list",this.edges=10,this.iconSize=25}setViewController(t){this.viewController=t}get menu(){return{items:[{title:$l10n("SHARE"),symbol:"square.and.arrow.up",handler:async(t,e)=>{let i=t.object(e).info.info;$share.sheet([$file.absolutePath(i.path)])}}]}}delete(t){$file.delete(t.path)}edit(t){let e=$file.read(t.path);if(e.info?.mimeType?.startsWith("image"))Sheet.quickLookImage(e,t.path.substring(t.path.lastIndexOf("/")+1));else{let i=new Sheet,s=$text.uuid;i.setView({type:"code",layout:$layout.fill,props:{id:s,lineNumbers:!0,theme:$device.isDarkMode?"atom-one-dark":"atom-one-light",text:e.string,insets:$insets(15,15,15,15)}}).addNavBar({title:t.file,popButton:{title:$l10n("CLOSE")},rightButtons:[{title:$l10n("SAVE"),tapped:()=>{$file.write({data:$data({string:$(s).text}),path:t.path}),$ui.success($l10n("SAVE_SUCCESS"))}}]}),i.init().present()}}getFiles(t=""){return $file.list(t).map((e=>{let i=t+"/"+e,s=$file.isDirectory(i);return{info:{info:{path:i,file:e,isDirectory:s}},icon:{symbol:s?"folder.fill":"doc"},name:{text:e},size:{text:s?"":"--"}}})).sort(((t,e)=>t.info.info.isDirectory!==e.info.info.isDirectory?t.info.info.isDirectory?-1:1:t.info.info.isDirectory===e.info.info.isDirectory?t.info.info.file.localeCompare(e.info.info.file):void 0))}async loadFileSize(t){return t.map(((e,i)=>{let s=e.info.info;if(!s.isDirectory)try{t[i].size.text=UIKit.bytesToSize($file.read(s.path).info.size)}catch(e){t[i].size.text=e}})),t}get listTemplate(){return{props:{bgcolor:$color("clear")},views:[{props:{id:"info"}},{type:"image",props:{id:"icon"},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(this.edges),t.size.equalTo(this.iconSize)}},{type:"view",views:[{type:"label",props:{id:"size",color:$color("secondaryText"),lines:1},layout:(t,e)=>{t.height.equalTo(e.super),t.right.inset(this.edges)}},{type:"label",props:{id:"name",lines:1},layout:(t,e)=>{t.height.left.equalTo(e.super),t.right.equalTo(e.prev.left).offset(-this.edges)}}],layout:(t,e)=>{t.height.right.equalTo(e.super),t.left.equalTo(e.prev.right).offset(this.edges)}}]}}#t(t,e){if(this.viewController){let i=new NavigationView;i.setView(e).navigationBarTitle(t),i.navigationBar.setLargeTitleDisplayMode(NavigationBar.largeTitleDisplayModeNever),this.viewController.push(i)}else UIKit.push({title:t,views:[e]})}getListView(t=""){return{type:"list",props:{id:this.listId,menu:this.menu,info:{basePath:t},bgcolor:UIKit.primaryViewBackgroundColor,separatorInset:$insets(0,this.edges,0,0),data:[],template:this.listTemplate,actions:[{title:" "+$l10n("DELETE")+" ",color:$color("red"),handler:(t,e)=>{let i=t.object(e).info.info;UIKit.deleteConfirm($l10n("FILE_MANAGER_DELETE_CONFIRM_MSG")+' "'+i.file+'" ?',(()=>{this.delete(i),t.delete(e)}))}}]},layout:$layout.fill,events:{ready:()=>{let e=this.getFiles(t);$(this.listId).data=e,this.loadFileSize(e).then((t=>{$(this.listId).data=t}))},pulled:async t=>{let e=this.getFiles($(this.listId).info.basePath);$(this.listId).data=e,$(this.listId).data=await this.loadFileSize(e),$delay(.5,(()=>{t.endRefreshing()}))},didSelect:(t,e,i)=>{let s=i.info.info;s.isDirectory?this.#t(s.file,this.getListView(s.path)):this.edit(s)}}}}push(t=""){let e=t.substring(t.lastIndexOf("/"));this.#t(e,this.getListView(t))}},FileStorage=class t{basePath;constructor({basePath:t="storage"}={}){this.basePath=t,this.#t(this.basePath)}static join(...t){let e=t.length,i=t[0];if(e<2)return i;for(let s=0;st&&(s=e.substring(t+1),e=e.substring(0,t+1))}return i&&this.#t(e),e+s}exists(t=""){return t=this.filePath(t,!1),!!$file.exists(t)}write(t="",e){return new Promise(((i,s)=>{try{let r=this.writeSync(t,e);r?i(r):s(r)}catch(t){s(t)}}))}writeSync(t="",e){if(!e)throw new FileStorageParameterError("data");return $file.write({data:e,path:this.filePath(t)})}read(t=""){return new Promise(((e,i)=>{try{let s=this.readSync(t);s?e(s):i()}catch(t){i(t)}}))}readSync(t=""){if(t=this.filePath(t),!$file.exists(t))throw new FileStorageFileNotFoundError(t);return $file.isDirectory(t)?$file.list(t):$file.read(t)}readAsJSON(t="",e=null){try{let e=this.readSync(t)?.string;return JSON.parse(e)}catch{return e}}static readFromRoot(e=""){return new Promise(((i,s)=>{try{let r=t.readFromRootSync(e);r?i(r):s()}catch(t){s(t)}}))}static readFromRootSync(t=""){if(!t)throw new FileStorageParameterError("path");if(!$file.exists(t))throw new FileStorageFileNotFoundError(t);return $file.isDirectory(t)?$file.list(t):$file.read(t)}static readFromRootAsJSON(e="",i=null){try{let i=t.readFromRootSync(e)?.string;return JSON.parse(i)}catch{return i}}delete(t=""){return $file.delete(this.filePath(t,!1))}copy(t,e){t=this.filePath(t),e=this.filePath(e),$file.copy({src:t,dst:e})}move(t,e){t=this.filePath(t),e=this.filePath(e),$file.move({src:t,dst:e})}},Kernel=class t{startTime=Date.now();isUseJsboxNav=!1;title=$addin?.current?.name;constructor(){$app.isDebugging&&this.debug(),L10n.init()}static isTaio=$app.info.bundleID.includes("taio");static objectEqual(e,i){let s=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(i);if(s.length!==r.length)return!1;for(let r=0;rt?i[t]:0,r=isNaN(Number(e))?e.charCodeAt():Number(e),a=s.length>t?s[t]:0,o=isNaN(Number(a))?a.charCodeAt():Number(a);if(ro){n=1;break}}return n}debug(t,e){this.debugMode=!0,$app.idleTimerDisabled=!0,"function"==typeof t&&(this.debugPrint=t),"function"==typeof e&&(this.debugError=e),this.print("You are running EasyJsBox in debug mode.")}print(t){this.debugMode&&("function"==typeof this.debugPrint?this.debugPrint(t):console.log(t))}error(t){this.debugMode&&("function"==typeof this.debugError?this.debugError(t):console.error(t))}useJsboxNav(){return this.isUseJsboxNav=!0,this}setTitle(t){this.isUseJsboxNav&&($ui.title=t),this.title=t}setNavButtons(t){this.navButtons=t}openInJsbox(){$app.openURL(`jsbox://run?name=${this.title}`)}UIRender(t={}){let e=$context.query;if("alertFromKeyboard"===e.type){let t=JSON.parse($text.URLDecode(e.value));return t.actions=[{title:$l10n("CANCEL")}],void $ui.alert(t)}try{t.props=Object.assign({title:this.title,navBarHidden:!this.isUseJsboxNav,navButtons:this.navButtons??[],statusBarStyle:0},t.props),t.events||(t.events={});let e=t.events.layoutSubviews;t.events.layoutSubviews=()=>{$app.notify({name:"interfaceOrientationEvent",object:{statusBarOrientation:UIKit.statusBarOrientation,isHorizontal:UIKit.isHorizontal}}),"function"==typeof e&&e()},$ui.render(t)}catch(t){this.print(t)}}KeyboardRender(t={}){t.id||(t.id=$text.uuid),$ui.render({events:t.events??{}}),$delay(0,(()=>{$ui.controller.view=$ui.create(t),$ui.controller.view.layout(t.layout)}))}async checkUpdate(){let e=await $http.get("https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/src/version.js");if(e.error)throw e.error;let i=e.data.match(/.*VERSION.+\"([0-9\.]+)\"/)[1];if(this.print(`easy-jsbox latest version: ${i}`),t.versionCompare(i,VERSION)>0){let t=await $http.get("https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/dist/easy-jsbox.js");if(t.error)throw t.error;return t.data}return!1}},L10n=class{static l10n(t,e,i){if("string"==typeof e){let t={};e.split(";").forEach((e=>{if(""!==(e=e.trim())){let i=e.split("=");t[i[0].trim().slice(1,-1)]=i[1].trim().slice(1,-1)}})),e=t}let s=$app.strings;if(i)Object.assign(s[t],e);else for(let i in e)s[t][i]||(s[t][i]=e[i]);$app.strings=s}static set(t,e){this.l10n(t,e,!0)}static add(t,e){this.l10n(t,e,!1)}static init(){this.add("zh-Hans",{OK:"好",DONE:"完成",CANCEL:"取消",CLEAR:"清除",BACK:"返回",ERROR:"发生错误",SUCCESS:"成功",INVALID_VALUE:"非法参数",CONFIRM_CHANGES:"数据已变化,确认修改?",SETTING:"设置",GENERAL:"一般",ADVANCED:"高级",TIPS:"小贴士",COLOR:"颜色",COPY:"复制",COPIED:"复制成功",JSBOX_ICON:"JSBox 内置图标",SF_SYMBOLS:"SF Symbols",IMAGE_BASE64:"图片 / base64",PREVIEW:"预览",SELECT_IMAGE_PHOTO:"从相册选择图片",SELECT_IMAGE_ICLOUD:"从 iCloud 选择图片",CLEAR_IMAGE:"清除图片",NO_IMAGE:"无图片",ABOUT:"关于",VERSION:"Version",AUTHOR:"作者",AT_BOTTOM:"已经到底啦~"}),this.add("en",{OK:"OK",DONE:"Done",CANCEL:"Cancel",CLEAR:"Clear",BACK:"Back",ERROR:"Error",SUCCESS:"Success",INVALID_VALUE:"Invalid value",CONFIRM_CHANGES:"The data has changed, confirm the modification?",SETTING:"Setting",GENERAL:"General",ADVANCED:"Advanced",TIPS:"Tips",COLOR:"Color",COPY:"Copy",COPIED:"Copide",JSBOX_ICON:"JSBox in app icon",SF_SYMBOLS:"SF Symbols",IMAGE_BASE64:"Image / base64",PREVIEW:"Preview",SELECT_IMAGE_PHOTO:"Select From Photo",SELECT_IMAGE_ICLOUD:"Select From iCloud",CLEAR_IMAGE:"Clear Image",NO_IMAGE:"No Image",ABOUT:"About",VERSION:"Version",AUTHOR:"Author",AT_BOTTOM:"It's the end~"}),this.add("zh-Hans",{DELETE_CONFIRM_TITLE:"删除前确认"}),this.add("en",{DELETE_CONFIRM_TITLE:"Delete Confirmation"}),this.add("zh-Hans",{FILE_MANAGER_DELETE_CONFIRM_MSG:"确认要删除吗",DELETE:"删除",CANCEL:"取消",CLOSE:"关闭",SHARE:"分享",SAVE:"保存",SAVE_SUCCESS:"保存成功"}),this.add("en",{FILE_MANAGER_DELETE_CONFIRM_MSG:"Are you sure you want to delete",DELETE:"Delete",CANCEL:"Cancel",CLOSE:"Close",SHARE:"Share",SAVE:"Save",SAVE_SUCCESS:"Save Success"})}},Logger=class{print;constructor(t){this.print=t??console.log}printToFile(t,e){this.print=i=>{t.exists(e)&&(i=(t.readSync(e)?.string??"")+i),t.writeSync(e,$data({string:i}))}}format(t,e){return`${(new Date).toUTCString()} [${e}] ${t}\n`}log(t,e){this.print(this.format(t,e))}info(t){this.log(t,"INFO")}error(t){this.log(t,"ERROR")}alert(t){this.log(t,"ALERT")}},NavigationBarItems=class{rightButtons=[];leftButtons=[];#t={};hasbutton=!1;isPinTitleView=!1;setTitleView(t){return this.titleView=t,this}pinTitleView(){return this.isPinTitleView=!0,this}setFixedFooterView(t){return this.fixedFooterView=t,this}setRightButtons(t){return t.forEach((t=>this.addRightButton(t))),this.hasbutton||(this.hasbutton=!0),this}setLeftButtons(t){return t.forEach((t=>this.addLeftButton(t))),this.hasbutton||(this.hasbutton=!0),this}addRightButton({id:t,symbol:e,title:i,tapped:s,menu:r,events:n,color:a}={}){let o=BarButtonItem.creat({id:t,symbol:e,title:i,tapped:s,menu:r,events:n,color:a,align:UIKit.align.right});return this.rightButtons.push(o),this.#t[t??o.id]=o,this.hasbutton||(this.hasbutton=!0),this}addLeftButton({id:t,symbol:e,title:i,tapped:s,menu:r,events:n,color:a}={}){let o=BarButtonItem.creat({id:t,symbol:e,title:i,tapped:s,menu:r,events:n,color:a,align:UIKit.align.left});return this.leftButtons.push(o),this.#t[t??o.id]=o,this.hasbutton||(this.hasbutton=!0),this}getButton(t){return this.#t[t]}addPopButton(t,e,i){return t||(t=$l10n("BACK")),this.popButtonView=e??{type:"button",props:{bgcolor:$color("clear"),symbol:"chevron.left",tintColor:UIKit.linkColor,title:` ${t}`,titleColor:UIKit.linkColor,font:$font("bold",16)},layout:(t,e)=>{t.left.equalTo(e.super.safeArea).offset(BarButtonItem.style.edges),t.centerY.equalTo(e.super.safeArea)},events:{tapped:()=>{$ui.pop(),"function"==typeof i&&i()}}},this}removePopButton(){return this.popButtonView=void 0,this}},Plist=class{constructor(t){this.content=t}valueToJs(t){switch(t.tag){case"dict":return this.dictToJs(t);case"true":case"false":return"true"===t.tag;case"integer":return t.number;case"key":case"string":return t.string;case"date":return new Date(t.string);case"array":return this.arrayToJs(t);default:return t.node}}arrayToJs(t){let e=[];return t.children().forEach((t=>{e.push(this.valueToJs(t))})),e}dictToJs(t){let e=[],i=[];return t.children().forEach((t=>{"key"===t.tag?e.push(this.valueToJs(t)):i.push(this.valueToJs(t))})),Object.fromEntries(e.map(((t,e)=>[t,i[e]])))}getObject(){if(!this.content)return!1;let t=$xml.parse({string:this.content,mode:"xml"});return this.valueToJs(t.rootElement.firstChild({xPath:"//plist/dict"}))}static get(t){return new this(t).getObject()}},Request=class t{static method={get:"GET",post:"POST",put:"PUT",delete:"DELETE",patch:"PATCH",head:"HEAD",options:"OPTIONS"};static errorType={http:0,network:1};cacheContainerKey=$addin?.current?.name+".request.cache";#t;#e=!1;#i=!1;cacheLife=2592e6;#s=!1;timeout=5;logger;constructor(t){"function"==typeof t&&(this.logger=t)}get cache(){return $cache.get(this.cacheContainerKey)??{}}#r(t){this.#s&&"function"==typeof this.logger&&this.logger(t)}logRequest(t){return this.#s=!0,"function"==typeof t&&(this.logger=t),this}disableLogRequest(){this.#s=!1}getCacheKey(t){return $text.MD5(t)}getCache(t,e=null){return this.cache[t]??e}setCache(t,e){if(!e)return;let i=this.cache;i[t]=e,$cache.set(this.cacheContainerKey,i)}removeCache(t){let e=this.cache;delete e[t],$cache.set(this.cacheContainerKey,e)}clearCache(){$cache.remove(this.cacheContainerKey)}clearNSURLCache(){this.#t||(this.#t=$objc("NSURLCache").$sharedURLCache()),this.#t.$removeAllCachedResponses()}enableCache(){return this.#e=!0,this}disableCache(){return this.#e=!1,this}ignoreCacheExp(){this.#i=!0}async request(e,i,s={},r={},n=this.cacheLife,a){let o,l=this.#e&&i===t.method.get;if(l){o=this.getCacheKey(e);let t=this.getCache(o);if(t&&(this.#i||t.exp>Date.now()))return this.#r("get data from cache: "+e),t.data}this.#r(`sending request [${i}]: ${e}`);let h=await $http.request(Object.assign({header:r,url:e,method:i,body:i===t.method.get?null:s,timeout:this.timeout},a));if(h.error)throw new RequestError({type:t.errorType.network,message:h.error.localizedDescription,code:h.error.code});if(h?.response?.statusCode>=400){let e=h.data;throw"object"==typeof e&&(e=JSON.stringify(e)),new RequestError({type:t.errorType.http,message:e,code:h.response.statusCode})}return l&&this.setCache(o,{exp:Date.now()+n,data:h}),h}},SettingItem=class _SettingItem{static rowHeight=50;static edgeOffset=10;static iconSize=30;static iconDefaultColor="#00CC00";setting;#n;#a;#o;title;#l={};constructor({setting:t,key:e,title:i,icon:s,value:r=null}={}){this.setting=t,this.key=e,this.title=$l10n(i),this.icon=s,this.default=r}get method(){return this.setting.method}set key(t){return this.#a=t??$text.uuid,this.#n=void 0,this}get key(){return this.#a}get id(){return this.#n||(this.#n=`setting-${this.setting.name}-${this.key}`),this.#n}set icon(t){return t?Array.isArray(t)||(t=[t,_SettingItem.iconDefaultColor]):t=["square.grid.2x2.fill",_SettingItem.iconDefaultColor],Array.isArray(t[0])||(t[0]=[t[0],t[0]]),t[1]?Array.isArray(t[1])||(t[1]=[t[1],t[1]]):t[1]=[_SettingItem.iconDefaultColor,_SettingItem.iconDefaultColor],this.#o=t,this}get icon(){return this.#o}get options(){return this.#l}set options(t){return this.#l=t??{},this}set(t){return this.setting.set(this.key,t)}get(t=this.default){return this.setting.getOriginal(this.key,t)}evalValues(object){let result;return result="string"==typeof object?object.startsWith("this.method")?eval(`(()=>{return ${object}()})()`):eval(`(()=>{return ${object}})()`):"function"==typeof object?object():object??[],result}createLineLabel(){return{type:"view",views:[{type:"view",props:{bgcolor:$color(this.icon[1][0],this.icon[1][1]),cornerRadius:5,smoothCorners:!0},views:[{type:"image",props:{tintColor:$color("white"),image:$image(this.icon[0][0],this.icon[0][1])},layout:(t,e)=>{t.center.equalTo(e.super),t.size.equalTo(20)}}],layout:(t,e)=>{t.centerY.equalTo(e.super),t.size.equalTo(_SettingItem.iconSize),t.left.inset(_SettingItem.edgeOffset)}},{type:"label",props:{text:this.title,lines:1,align:$align.left},layout:(t,e)=>{t.centerY.equalTo(e.super),t.height.equalTo(e.super),t.left.equalTo(e.prev.right).offset(_SettingItem.edgeOffset),t.width.greaterThanOrEqualTo(10)}}],layout:(t,e)=>{t.height.centerY.equalTo(e.super),t.left.inset(0)}}}getView(){}create(){return this.getView(this.options)}},Sheet=class t{#t=()=>{};#e=()=>{};style=t.UIModalPresentationStyle.PageSheet;#i=!1;#s;static UIModalPresentationStyle={Automatic:-2,FullScreen:0,PageSheet:1,FormSheet:2,CurrentContext:3,Custom:4,OverFullScreen:5,OverCurrentContext:6,Popover:7,BlurOverFullScreen:8};navigationView;init(){this.initNavBar();let{width:t,height:e}=$device.info.screen,i=$objc("UIView").invoke("initWithFrame",$rect(0,0,t,e)),s=$objc("UIViewController").invoke("alloc.init"),r=s.$view();return r.$addSubview(i),s.$setModalPresentationStyle(this.style),s.$setModalInPresentation(this.#i),this.#t=()=>{r.jsValue().add(this.navigationView?.getPage().definition??this.view),$ui.vc.ocValue().invoke("presentViewController:animated:completion:",s,!0,void 0)},this.#e=()=>s.invoke("dismissViewControllerAnimated:completion:",!0,void 0),this}initNavBar(){if(!this.#s)return;let{title:e="",popButton:i={title:$l10n("CLOSE")},rightButtons:s=[]}=this.#s;if(void 0===this.view)throw new SheetViewUndefinedError;this.navigationView=new NavigationView;let r=this.navigationView.navigationBar;r.setLargeTitleDisplayMode(NavigationBar.largeTitleDisplayModeNever),r.navigationBarLargeTitleHeight-=r.navigationBarNormalHeight,r.navigationBarNormalHeight=NavigationBar.pageSheetNavigationBarHeight,r.navigationBarLargeTitleHeight+=r.navigationBarNormalHeight,this.style===t.UIModalPresentationStyle.FullScreen||this.style===t.UIModalPresentationStyle.OverFullScreen||this.style===t.UIModalPresentationStyle.BlurOverFullScreen?r.setTopSafeArea():r.removeTopSafeArea(),i.events=Object.assign({tapped:()=>{this.dismiss(),"function"==typeof i.tapped&&i.tapped()}},i.events??{}),this.navigationView.navigationBarItems.addLeftButton(i).setRightButtons(s),this.navigationView.setView(this.view).navigationBarTitle(e),this.view.props?.bgcolor&&this.navigationView?.getPage().setProp("bgcolor",this.view.props?.bgcolor)}preventDismiss(){return this.#i=!0,this}setStyle(t){return this.style=t,this}setView(t={}){if("object"!=typeof t)throw new SheetViewTypeError("view","object");return this.view=t,this}addNavBar(t){return this.#s=t,this}present(){this.#t()}dismiss(){this.#e()}static quickLookImage(e,i=$l10n("PREVIEW")){(new t).setView({type:"view",views:[{type:"scroll",props:{zoomEnabled:!0,maxZoomScale:3},layout:$layout.fill,views:[{type:"image",props:{data:e},layout:$layout.fill}]}],layout:$layout.fill}).addNavBar({title:i,rightButtons:[{symbol:"square.and.arrow.up",tapped:()=>$share.sheet(e)}]}).init().present()}},Tasks=class{#t={};addTask(t,e=0){let i=$text.uuid;return this.#t[i]=$delay(e,(async()=>{await t(),delete this.#t[i]})),i}cancelTask(t){this.#t[t].cancel()}clearTasks(){Object.values(this.#t).forEach((t=>t.cancel()))}},Toast=class t{static type={info:void 0,success:"checkmark",warning:"exclamationmark.triangle",error:"xmark.circle"};static edges=40;static iconSize=100;static labelTopMargin=10;static defaultFont=$font("default",26);width=Math.min(.6*UIKit.windowSize.width,260);labelWidth=this.width-2*t.edges;id=$text.uuid;#t="";font=t.defaultFont;type=t.type.info;labelLines=2;constructor(e,i=t.type.info,s=2,r=t.defaultFont){this.type=i,this.message=e,this.labelLines=s,this.font=r}get message(){return this.#t}set message(e){this.#t=e,this.fontHeight=UIKit.getContentSize(this.font,this.message,this.labelWidth,this.labelLines).height,this.height=(this.hasIcon?t.labelTopMargin+t.iconSize:0)+this.fontHeight+2*t.edges}get hasIcon(){return void 0!==this.type}get blurBox(){let e=UIKit.blurBox({id:this.id,cornerRadius:15,alpha:0},[{type:"image",props:{symbol:this.type,hidden:!this.hasIcon,tintColor:$color("lightGray")},layout:(e,i)=>{e.top.inset(t.edges),e.size.equalTo(t.iconSize),e.centerX.equalTo(i.super)}},{type:"label",props:{font:this.font,text:this.message,align:$align.center,lines:this.labelLines,color:$color("lightGray")},layout:(e,i)=>{e.bottom.equalTo(i.supper).offset(-t.edges),e.width.equalTo(this.labelWidth),e.height.equalTo(this.fontHeight),e.centerX.equalTo(i.super)}}]);return e.events={tapped:()=>{this.remove()}},e}show(){let t=$ui.create(this.blurBox);$ui.controller.view.hidden?$ui.controller.view.super.insertAtIndex(t,0):$ui.controller.view.insertAtIndex(t,0);let e=$(this.id);e.layout(((t,e)=>{t.center.equalTo(e.super),t.size.equalTo($size(this.width,this.height))})),e.moveToFront(),$ui.animate({duration:.2,animation:()=>{e.alpha=1}})}remove(){let t=$(this.id);t&&$ui.animate({duration:.2,animation:()=>{t.alpha=0},completion:()=>{t.remove()}})}static toast({message:e,type:i=t.type.info,show:s=!0,displayTime:r=2,labelLines:n=2,font:a=t.defaultFont}){let o=new t(e,i,n,a);return s&&(o.show(),$delay(r,(()=>{o.remove()}))),o}static info(e,i={}){return t.toast(Object.assign({message:e,type:t.type.info},i))}static success(e,i={}){return t.toast(Object.assign({message:e,type:t.type.success},i))}static warning(e,i={}){return t.toast(Object.assign({message:e,type:t.type.warning},i))}static error(e,i={}){return t.toast(Object.assign({message:e,type:t.type.error},i))}},UIKit=class t{static#t=$objc("UIApplication").$sharedApplication();static#e=$objc("UINotificationFeedbackGenerator").$new();static feedbackSuccess(){t.#e.$notificationOccurred(0)}static feedbackError(){t.#e.$notificationOccurred(2)}static align={left:0,right:1,top:2,bottom:3};static textColor=$color("primaryText");static linkColor=$color("systemLink");static primaryViewBackgroundColor=$color("primarySurface");static scrollViewBackgroundColor=$color("insetGroupedBackground");static scrollViewList=["list","matrix"];static isLargeScreen=$device.isIpad||$device.isIpadPro;static get windowSize(){return $objc("UIWindow").$keyWindow().jsValue().size}static NavigationBarNormalHeight=$objc("UINavigationController").invoke("alloc.init").$navigationBar().jsValue().frame.height;static NavigationBarLargeTitleHeight=$objc("UITabBarController").invoke("alloc.init").$tabBar().jsValue().frame.height+t.NavigationBarNormalHeight;static get isSplitScreenMode(){return t.isLargeScreen&&$device.info.screen.width!==t.windowSize.width}static get topSafeAreaInsets(){return t.#t?.$keyWindow()?.$safeAreaInsets()?.top??0}static get bottomSafeAreaInsets(){return t.#t?.$keyWindow()?.$safeAreaInsets()?.bottom??0}static get statusBarOrientation(){return t.#t.$statusBarOrientation()}static get consoleBarHeight(){if($app.isDebugging){let e=t.#t.$statusBarFrame().height+26;return $device.isIphoneX&&(e+=30),e}return 0}static get isHorizontal(){return 3===t.statusBarOrientation||4===t.statusBarOrientation}static loading(){let e=$ui.create(t.blurBox({cornerRadius:15},[{type:"spinner",props:{loading:!0,style:0},layout:(t,e)=>{t.size.equalTo(e.prev),t.center.equalTo(e.super)}}]));return{start:()=>{$ui.controller.view.insertAtIndex(e,0),e.layout(((e,i)=>{e.center.equalTo(i.super);let s=Math.min(.6*Math.min(t.windowSize.width,t.windowSize.height),260);e.size.equalTo($size(s,s))})),e.moveToFront()},end:()=>{e.remove()}}}static defaultBackgroundColor(e){return t.scrollViewList.indexOf(e)>-1?t.scrollViewBackgroundColor:t.primaryViewBackgroundColor}static separatorLine(e={},i=t.align.bottom){return{type:"canvas",props:e,layout:(e,s)=>{void 0===s.prev?e.top.equalTo(s.super):i===t.align.bottom?e.top.equalTo(s.prev.bottom):e.top.equalTo(s.prev.top),e.height.equalTo(1/$device.info.screen.scale),e.left.right.inset(0)},events:{draw:(t,i)=>{i.strokeColor=e.bgcolor??$color("separatorColor"),i.setLineWidth(1),i.moveToPoint(0,0),i.addLineToPoint(t.frame.width,0),i.strokePath()}}}}static blurBox(t={},e=[],i=$layout.fill){return{type:"blur",props:Object.assign({style:$blurStyle.thinMaterial},t),views:e,layout:i}}static getContentSize(e,i="A",s=t.windowSize.width,r){let n={text:i,width:s,font:e};return void 0!==r&&(n.lineSpacing=r),$text.sizeThatFits(n)}static getSymbolSize(t,e){let i=(t="string"==typeof t?$image(t):t).size.width/t.size.height;return t.size.width>t.size.height?$size(e,e/i):$size(e*i,e)}static push({views:t,statusBarStyle:e=0,title:i="",navButtons:s=[{title:""}],bgcolor:r=t[0]?.props?.bgcolor??"primarySurface",titleView:n,disappeared:a}={}){let o={statusBarStyle:e,navButtons:s,title:i,bgcolor:"string"==typeof r?$color(r):r};n&&(o.titleView=n),$ui.push({props:o,events:{disappeared:()=>{void 0!==a&&a()}},views:[{type:"view",views:t,layout:(t,e)=>{t.top.equalTo(e.super.safeArea),t.bottom.equalTo(e.super),t.left.right.equalTo(e.super.safeArea)}}]})}static compressImage(t,e=921600){let i=$imagekit.info(t);if(i.height*i.width>e){let s=e/(i.height*i.width);t=$imagekit.scaleBy(t,s)}return t}static deleteConfirm(t,e){$ui.alert({title:$l10n("DELETE_CONFIRM_TITLE"),message:t,actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive,handler:()=>{e()}},{title:$l10n("CANCEL")}]})}static bytesToSize(t){if(0===t)return"0 B";let e=Math.floor(Math.log(t)/Math.log(1024));return(t/Math.pow(1024,e)).toPrecision(3)+" "+["B","KB","MB","GB","TB","PB","EB","ZB","YB"][e]}},UILoading=class{#t;text="";interval;fullScreen=!1;#e=()=>{};constructor(){this.#t=$text.uuid}updateText(t){$(this.#t).text=t}setLoop(t){if("function"!=typeof t)throw"loop must be a function";this.#e=t}done(){clearInterval(this.interval)}load(){$ui.render({props:{navBarHidden:this.fullScreen},views:[{type:"spinner",props:{loading:!0},layout:(t,e)=>{t.centerY.equalTo(e.super).offset(-15),t.width.equalTo(e.super)}},{type:"label",props:{id:this.#t,align:$align.center,text:""},layout:(t,e)=>{t.top.equalTo(e.prev.bottom).offset(10),t.left.right.equalTo(e.super)}}],layout:$layout.fill,events:{appeared:()=>{this.interval=setInterval((()=>{this.#e()}),100)}}})}},View=class t{id=$text.uuid;type;props;views;events;layout;#t=void 0;#e=null;constructor({type:t="view",props:e={},views:i=[],events:s={},layout:r=$layout.fill}={}){this.type=t,this.props=e,this.views=i,this.events=s,this.layout=r,this.props.id?this.id=this.props.id:this.props.id=this.id}static create(t){return new this(t)}static createFromViews(t){return new this({views:t})}get scrollableView(){return this.scrollable?this.#e:null}set scrollableView(t){this.#e=t}get scrollable(){if(void 0===this.#t)if(this.#t=!1,UIKit.scrollViewList.indexOf(this.type)>-1)this.scrollableView=this,this.#t=!0;else if(this.views.length>0){let e=i=>{if(!this.#t&&i?.length>0)for(let s=0;s-1)return typeof i[s]!==t&&(i[s]=t.create(i[s])),this.scrollableView=i[s],void(this.#t=!0);e(i[s].views)}};e(this.views)}return this.#t}set scrollable(t){throw new Error("[scrollable] is readonly prop.")}setProps(t){return Object.keys(t).forEach((e=>this.setProp(e,t[e]))),this}setProp(t,e){return"id"===t&&(this.id=e),this.props[t]=e,this}setViews(t){return this.views=t,this.#t=void 0,this}setEvents(t){return Object.keys(t).forEach((e=>this.setEvent(e,t[e]))),this}setEvent(t,e){return this.events[t]=e,this}eventMiddleware(t,e){let i=this.events[t];return this.events[t]=(...t)=>{"function"==typeof i&&e(i,...t)},this}assignEvent(t,e){let i=this.events[t];return this.events[t]=(...t)=>{"function"==typeof i&&i(...t),e(...t)},this}setLayout(t){return this.layout=t,this}getView(){return this}get definition(){return this.getView()}},FileStorageParameterError=class extends Error{constructor(t){super(`Parameter [${t}] is required.`),this.name="FileStorageParameterError"}},FileStorageFileNotFoundError=class extends Error{constructor(t){super(`File not found: ${t}`),this.name="FileStorageFileNotFoundError"}},RequestError=class extends Error{constructor({message:t,code:e,type:i}={}){super(t),this.name="RequestError",this.code=e,this.type=i}},SettingLoadConfigError=class extends Error{constructor(){super("Call loadConfig() first."),this.name="SettingLoadConfigError"}},SettingReadonlyError=class extends Error{constructor(){super("Attempted to assign to readonly property."),this.name="SettingReadonlyError"}},SheetViewUndefinedError=class extends Error{constructor(){super("Please call setView(view) first."),this.name="SheetViewUndefinedError"}},ValidationError=class extends Error{constructor(t,e){super(`The type of the parameter '${t}' must be '${e}'`),this.name="ValidationError"}},FixedFooterView=class extends View{height=60;getView(){return this.type="view",this.setProp("bgcolor",UIKit.primaryViewBackgroundColor),this.layout=(t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.height)},this.views=[View.create({props:this.props,views:this.views,layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.height.equalTo(this.height)}})],this}},Matrix=class extends View{titleStyle={font:$font("bold",21),height:30};#t;#e;templateIdByIndex(t){return void 0===this.props.template.views[t]?.props?.id&&(void 0===this.props.template.views[t].props&&(this.props.template.views[t].props={}),this.props.template.views[t].props.id=$text.uuid),this.props.template.views[t].props.id}get templateHiddenStatus(){if(!this.#e){this.#e={};for(let t=0;t{t.items=t.items.filter((t=>!0===t?.__title?.hidden)),e.push(t)})),e}set data(t){this.props.data=this.rebuildData(t),$(this.id).data=this.props.data}#i(t){let e={...this.hiddenViews};return Object.assign(e,{__templateProps:{hidden:!0},__title:{hidden:!1,text:t,info:{title:!0}}}),e}rebuildData(t=[]){return t.map((t=>(t.items=t.items.map((t=>(Object.keys(t).forEach((e=>{t[e].hidden=this.templateHiddenStatus[e]??!1})),Object.keys(this.templateHiddenStatus).forEach((e=>{t[e]||(t[e]={}),t[e].hidden=this.templateHiddenStatus[e]})),t.__templateProps={hidden:!1},t.__title={hidden:!0},t))),t.title&&t.items.unshift(this.#i(t.title)),t)))}rebuildTemplate(){let t={};void 0!==this.props.template.props&&(void 0!==this.props.template.props.cornerRadius&&(this.props.template.props.clipsToBounds=!1),t=Object.assign(this.props.template.props,{id:"__templateProps",hidden:!1}));let e=[{type:"view",props:t,layout:$layout.fill},{type:"label",props:{id:"__title",hidden:!0,font:this.titleStyle.font},layout:(t,e)=>{t.top.inset(-this.titleStyle.height/4*3),t.height.equalTo(this.titleStyle.height),t.width.equalTo(e.super.safeArea)}}].concat(this.props.template.views);this.props.template.views=e}insert(t,e=!0){return t.indexPath=this.indexPath(t.indexPath,e),$(this.id).insert(t)}delete(t,e=!0){return t=this.indexPath(t,e),$(this.id).delete(t)}object(t,e=!0){return t=this.indexPath(t,e),$(this.id).object(t)}cell(t,e=!0){return t=this.indexPath(t,e),$(this.id).cell(t)}indexPath(t,e){let i=e?1:0;return t="number"==typeof t?$indexPath(0,t+i):$indexPath(t.section,t.row+i)}getView(){return this.props.data=this.rebuildData(this.props.data),this.rebuildTemplate(),this.setEvent("itemSize",((t,e)=>{if(t.object(e)?.__title?.info?.title)return $size(Math.max($device.info.screen.width,$device.info.screen.height),0);let i=this.props.columns??2,s=this.props.spacing??15,r=this.props.itemWidth??this.props.itemSize?.width??(t.super.frame.width-s*(i+1))/i,n=this.props.itemHeight??this.props.itemSize?.height??100;return $size(r,n)})),this}},BarTitleView=class extends View{controller={};setController(t){return this.controller=t,this}},BarButtonItem=class t extends View{static#t;edges=15;buttonEdges=this.edges/2;iconSize=24;fontSize=17;color=UIKit.textColor;title;#e;align=UIKit.align.right;get symbol(){return this.#e}set symbol(t){this.#e="string"==typeof t?$image(t):t}get width(){if(this.title){let t=$text.sizeThatFits({text:this.title,width:UIKit.windowSize.width,font:$font(this.fontSize)});return Math.ceil(t.width)+this.edges}return this.iconSize+this.edges}static get style(){return void 0===this.#t&&(this.#t=new t),this.#t}setEdges(t){return this.edges=t,this}setFontSize(t){return this.fontSize=t,this}setColor(t=UIKit.textColor){return this.color=t,this}setTitle(t){return this.title=t,this}setSymbol(t){return this.symbol=t,this}setMenu(t){return this.menu=t,this}setAlign(t){return this.align=t,this}setLoading(t){t?($(this.id).hidden=!0,$("spinner-"+this.id).hidden=!1):($(this.id).hidden=!1,$("spinner-"+this.id).hidden=!0)}#i(){let t=$(`icon-button-${this.id}`),e=$(`icon-checkmark-${this.id}`);t.alpha=0,$(this.id).hidden=!1,$("spinner-"+this.id).hidden=!0,$ui.animate({duration:.6,animation:()=>{e.alpha=1},completion:()=>{$delay(.3,(()=>$ui.animate({duration:.6,animation:()=>{e.alpha=0},completion:()=>{$ui.animate({duration:.4,animation:()=>{t.alpha=1},completion:()=>{t.alpha=1}})}})))}})}getView(){let t=this.events.tapped;return this.events.tapped=e=>{t&&t({start:()=>this.setLoading(!0),done:()=>this.#i(),cancel:()=>this.setLoading(!1)},e)},{type:"view",props:{info:{align:this.align}},views:[{type:"button",props:Object.assign({id:this.id,bgcolor:$color("clear"),font:$font(this.fontSize),titleColor:this.color,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},this.menu?{menu:this.menu}:{},this.title?{title:this.title}:{},this.props),views:[{type:"image",props:Object.assign({id:`icon-button-${this.id}`,hidden:void 0===this.symbol,tintColor:this.color},this.symbol?{image:this.symbol}:{}),layout:(t,e)=>{this.symbol&&t.size.equalTo(UIKit.getSymbolSize(this.symbol,this.iconSize)),t.center.equalTo(e.super)}},{type:"image",props:{id:`icon-checkmark-${this.id}`,alpha:0,tintColor:this.color,symbol:"checkmark"},layout:(t,e)=>{t.center.equalTo(e.super),t.size.equalTo(UIKit.getSymbolSize("checkmark",this.iconSize))}}],events:this.events,layout:$layout.fill},{type:"spinner",props:{id:"spinner-"+this.id,loading:!0,hidden:!0},layout:$layout.fill}],layout:(t,e)=>{if(t.size.equalTo($size(this.width,UIKit.NavigationBarNormalHeight)),t.centerY.equalTo(e.super),e.prev&&e.prev?.info?.align===this.align)this.align===UIKit.align.right?t.right.equalTo(e.prev.left).offset(-this.buttonEdges):t.left.equalTo(e.prev.right).offset(this.buttonEdges);else{let e=this.edges/2;this.align===UIKit.align.right?t.right.inset(e):t.left.inset(e)}}}}static creat({id:e,symbol:i,title:s,tapped:r,menu:n,events:a,color:o,align:l=UIKit.align.right}={}){let h=new t;return h.setEvents(Object.assign({tapped:r},a)).setAlign(l).setSymbol(i).setTitle(s).setColor(o).setMenu(n),e&&h.setProp("id",e),h}},NavigationBar=class t extends View{static largeTitleDisplayModeAutomatic=0;static largeTitleDisplayModeAlways=1;static largeTitleDisplayModeNever=2;static pageSheetNavigationBarHeight=56;navigationBarItems;title="";prefersLargeTitles=!0;largeTitleDisplayMode=t.largeTitleDisplayModeAutomatic;fontFamily="bold";largeTitleFontSize=34;largeTitleFontHeight=$text.sizeThatFits({text:"A",width:100,font:$font(this.fontFamily,this.largeTitleFontSize)}).height;navigationBarTitleFontSize=17;topSafeArea=!0;contentViewHeightOffset=10;navigationBarNormalHeight=UIKit.NavigationBarNormalHeight;navigationBarLargeTitleHeight=UIKit.NavigationBarLargeTitleHeight;setTopSafeArea(){return this.topSafeArea=!0,this}removeTopSafeArea(){return this.topSafeArea=!1,this}setLargeTitleDisplayMode(t){return this.largeTitleDisplayMode=t,this}setBackgroundColor(t){return this.backgroundColor=t,this}setTitle(t){return this.title=t,this}setPrefersLargeTitles(t){return this.prefersLargeTitles=t,this}setContentViewHeightOffset(t){return this.contentViewHeightOffset=t,this}getLargeTitleView(){return this.prefersLargeTitles&&this.largeTitleDisplayMode!==t.largeTitleDisplayModeNever?{type:"label",props:{id:this.id+"-large-title",text:this.title,textColor:UIKit.textColor,align:$align.left,font:$font(this.fontFamily,this.largeTitleFontSize),line:1},layout:(t,e)=>{t.left.equalTo(e.super.safeArea).offset(15),t.height.equalTo(this.largeTitleFontHeight),t.top.equalTo(e.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}:{props:{id:this.id+"-large-title"},layout:(t,e)=>{t.left.top.right.inset(0),t.bottom.equalTo(e.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}}getNavigationBarView(){let e=(t,e)=>{let i=(t,i)=>{t.top.equalTo(i.super.safeAreaTop),t.bottom.equalTo(i.super.safeAreaTop).offset(this.navigationBarNormalHeight),e===UIKit.align.left?t.left.equalTo(i.super.safeArea):t.right.equalTo(i.super.safeArea)};if(t&&!Array.isArray(t))return{type:"view",views:[t],layout:i};let s=0,r=[];t.forEach((t=>{s+=t.width,r.push(t.definition)}));let n=t[0]?.edges??0;return s+=t.length>=2?2*n:n,t.length>0?{type:"view",views:r,info:{width:s},layout:(t,e)=>{i(t,e),t.width.equalTo(s)}}:{type:"view",layout:t=>t.size.equalTo(0)}},i=e(this.navigationBarItems.popButtonView??this.navigationBarItems.leftButtons,UIKit.align.left),s=e(this.navigationBarItems.rightButtons,UIKit.align.right),r=this.prefersLargeTitles,n=!this.prefersLargeTitles||this.largeTitleDisplayMode===t.largeTitleDisplayModeNever;return{type:"view",props:{id:this.id+"-navigation",bgcolor:$color("clear")},layout:(t,e)=>{t.left.top.right.inset(0),t.bottom.equalTo(e.super.safeAreaTop).offset(this.navigationBarNormalHeight)},views:[this.backgroundColor?{type:"view",props:{hidden:r,bgcolor:this.backgroundColor,id:this.id+"-background"},layout:$layout.fill}:UIKit.blurBox({hidden:r,id:this.id+"-background"}),UIKit.separatorLine({id:this.id+"-underline",alpha:r?0:1}),{type:"view",props:{alpha:0,bgcolor:$color("clear"),id:this.id+"-large-title-mask"},events:{ready:t=>{t.bgcolor=$(this.id+"-large-title")?.prev.bgcolor}},layout:$layout.fill},i,s,{type:"view",views:[{type:"label",props:{id:this.id+"-small-title",alpha:n?1:0,text:this.title,font:$font(this.fontFamily,this.navigationBarTitleFontSize),align:$align.center,bgcolor:$color("clear"),textColor:UIKit.textColor},layout:(t,e)=>{t.edges.equalTo(e.super.safeArea);let r=UIKit.getContentSize($font(this.fontFamily,this.navigationBarTitleFontSize),e.text).width,n=Math.max(i.info?.width??0,s.info?.width??0);UIKit.windowSize.width-2*n>r&&t.centerX.equalTo(e.super.super)}}],layout:(t,e)=>{t.top.bottom.equalTo(e.super.safeArea),t.left.equalTo(e.prev.prev.right),t.right.equalTo(e.prev.left)}}]}}},NavigationBarController=class t extends Controller{static largeTitleViewSmallMode=0;static largeTitleViewLargeMode=1;navigationBar;updateSelector(){this.selector={navigation:$(this.navigationBar.id+"-navigation"),largeTitleView:$(this.navigationBar.id+"-large-title"),smallTitleView:$(this.navigationBar.id+"-small-title"),underlineView:this.navigationBar.navigationBarItems.isPinTitleView?$(this.navigationBar.id+"-title-view-underline"):$(this.navigationBar.id+"-underline"),largeTitleMaskView:$(this.navigationBar.id+"-large-title-mask"),backgroundView:$(this.navigationBar.id+"-background"),titleViewBackgroundView:$(this.navigationBar.id+"-title-view-background")}}toNormal(t=!0){this.updateSelector(),this.selector.backgroundView.hidden=!1,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=1,this.selector.smallTitleView.alpha=1,this.selector.largeTitleView.alpha=0}}),t&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=NavigationBar.largeTitleDisplayModeNever)}toLargeTitle(t=!0){this.updateSelector(),this.selector.backgroundView.hidden=!0,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=0,this.selector.smallTitleView.alpha=0,this.selector.largeTitleView.alpha=1}}),t&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=NavigationBar.largeTitleDisplayModeAlways)}#t(e){let i=e===t.largeTitleViewSmallMode;this.selector.largeTitleView.alpha=i?0:1,$ui.animate({duration:.2,animation:()=>{this.selector.smallTitleView.alpha=i?1:0}})}#e(e){if(this.selector.largeTitleView.updateLayout(((t,i)=>{this.navigationBar.navigationBarNormalHeight-e>0?t.top.equalTo(i.super.safeAreaTop).offset(this.navigationBar.navigationBarNormalHeight-e):t.top.equalTo(i.super.safeAreaTop).offset(0)})),e>0)e>=this.navigationBar.navigationBarNormalHeight?this.#t(t.largeTitleViewSmallMode):this.#t(t.largeTitleViewLargeMode);else{this.#t(t.largeTitleViewLargeMode);let i=this.navigationBar.largeTitleFontSize-.04*e;i>40&&(i=40),this.selector.largeTitleView.font=$font(this.navigationBar.fontFamily,i)}}#i(t){let e=this.navigationBar.largeTitleDisplayMode===NavigationBar.largeTitleDisplayModeNever?5:this.navigationBar.navigationBarNormalHeight,i=void 0!==this.selector.titleViewBackgroundView;if(t>e){this.selector.backgroundView.hidden=!1;let s=()=>{i&&this.navigationBar.navigationBarItems.isPinTitleView&&(this.selector.titleViewBackgroundView.alpha=1),this.selector.largeTitleMaskView.alpha=0,this.selector.underlineView.alpha=1};(t-e)/3>=1?s():$ui.animate({duration:.2,animation:()=>{s()}})}else this.selector.largeTitleMaskView.alpha=t>0?1:0,this.selector.underlineView.alpha=0,i&&(this.selector.titleViewBackgroundView.alpha=0),this.selector.backgroundView.hidden=!0}didScroll(t){if(!this.navigationBar.prefersLargeTitles)return;let e=this.navigationBar.largeTitleDisplayMode;if(e!==NavigationBar.largeTitleDisplayModeAlways)if(this.updateSelector(),e===NavigationBar.largeTitleDisplayModeAutomatic){if(!this.navigationBar.navigationBarItems?.isPinTitleView&&(this.navigationBar.navigationBarItems?.titleView?.controller.didScroll(t),t>0)){(t-=this.navigationBar.navigationBarItems?.titleView?.height??0)<0&&(t=0)}this.#e(t),this.#i(t)}else e===NavigationBar.largeTitleDisplayModeNever&&this.#i(t)}didEndDragging(t,e,i,s){if(!this.navigationBar.prefersLargeTitles)return;let r=this.navigationBar.largeTitleDisplayMode;if(r!==NavigationBar.largeTitleDisplayModeAlways&&(this.updateSelector(),r===NavigationBar.largeTitleDisplayModeAutomatic)){let r=0;this.navigationBar.navigationBarItems?.isPinTitleView||(this.navigationBar.navigationBarItems?.titleView?.controller.didEndDragging(t,e,i,s),r=this.navigationBar.navigationBarItems?.titleView?.height??0,t-=r),t>=0&&t<=this.navigationBar.largeTitleFontHeight&&i($point(0,t>=this.navigationBar.largeTitleFontHeight/2?this.navigationBar.navigationBarNormalHeight+r-s:r-s))}}},NavigationViewTypeError=class extends ValidationError{constructor(t,e){super(t,e),this.name="NavigationViewTypeError"}},NavigationView=class extends Controller{page;navigationController=new NavigationBarController;navigationBar=new NavigationBar;navigationBarItems=new NavigationBarItems;constructor(){super(),this.navigationBar.navigationBarItems=this.navigationBarItems,this.navigationController.navigationBar=this.navigationBar}navigationBarTitle(t){return this.navigationBar.setTitle(t),this}setView(t){if("object"!=typeof t)throw new NavigationViewTypeError("view","object");return this.view=View.create(t),this}#t(){if(!(this.view instanceof View))throw new NavigationViewTypeError("view","View");let t=this.view.scrollableView,e=$app.isDebugging||Kernel.isTaio?0:UIKit.topSafeAreaInsets,i=this.navigationBar.largeTitleDisplayMode===NavigationBar.largeTitleDisplayModeNever?this.navigationBar.navigationBarNormalHeight:this.navigationBar.navigationBarLargeTitleHeight,s=this.navigationBar.contentViewHeightOffset+i;if(this.navigationBarItems.titleView&&(s+=this.navigationBarItems.titleView.topOffset,s+=this.navigationBarItems.titleView.height,s+=this.navigationBarItems.titleView.bottomOffset),!this.view.scrollable||!1===t.props.associateWithNavigationBar)return void(this.view.layout=(t,i)=>{t.left.right.equalTo(i.super.safeArea),t.bottom.equalTo(i.super);let r=s-this.navigationBar.contentViewHeightOffset;(!UIKit.isHorizontal||UIKit.isLargeScreen)&&this.navigationBar.topSafeArea&&(r+=e),t.top.equalTo(r)});t.props.stickyHeader&&(s-=i,s+=this.navigationBar.largeTitleFontHeight),t.props.header?t.props.header={type:"view",props:{height:s+(t.props.header?.props?.height??0)},views:[{type:"view",props:{clipsToBounds:!0},views:[t.props.header],layout:(t,e)=>{t.top.equalTo(s),t.bottom.width.equalTo(e.super)}}]}:t.props.header={props:{height:s}},t.props.footer=Object.assign({props:{}},t.props.footer??{}),t.props.footer.props.height=(this.navigationBarItems.fixedFooterView?.height??0)+(t.props.footer.props?.height??0);let r=this.navigationBarItems.isPinTitleView?this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset+this.navigationBar.contentViewHeightOffset:0;if(t.props.indicatorInsets){let e=t.props.indicatorInsets;t.props.indicatorInsets=$insets(e.top+this.navigationBar.navigationBarNormalHeight+r,e.left,e.bottom+(this.navigationBarItems.fixedFooterView?.height??0),e.right)}else t.props.indicatorInsets=$insets(this.navigationBar.navigationBarNormalHeight+r,0,this.navigationBarItems.fixedFooterView?.height??0,0);t.layout=(e,i)=>{t.props.stickyHeader?e.top.equalTo(i.super.safeArea).offset(this.navigationBar.navigationBarNormalHeight):e.top.equalTo(i.super),e.left.right.equalTo(i.super.safeArea),e.bottom.equalTo(i.super)},t.assignEvent("didScroll",(i=>{let s=i.contentOffset.y;(!UIKit.isHorizontal||UIKit.isLargeScreen)&&this.navigationBar.topSafeArea&&!t.props.stickyHeader&&(s+=e),this.navigationController.didScroll(s)})).assignEvent("didEndDragging",((i,s)=>{let r=i.contentOffset.y,n=0;(!UIKit.isHorizontal||UIKit.isLargeScreen)&&this.navigationBar.topSafeArea&&!t.props.stickyHeader&&(r+=e,n=e),this.navigationController.didEndDragging(r,s,((...t)=>i.scrollToOffset(...t)),n)})).assignEvent("didEndDecelerating",((...e)=>{e[0].tracking||t.events?.didEndDragging(...e)}))}#e(){if(this.navigationBar.prefersLargeTitles){this.#t();let t={};if(this.navigationBarItems.titleView){let e=this.navigationBar.largeTitleDisplayMode===NavigationBar.largeTitleDisplayModeNever?1:0;t=View.create({views:[this.navigationBar.backgroundColor?{type:"view",props:{alpha:e,bgcolor:this.navigationBar.backgroundColor,id:this.navigationBar.id+"-title-view-background"},layout:$layout.fill}:UIKit.blurBox({alpha:e,id:this.navigationBar.id+"-title-view-background"}),UIKit.separatorLine({id:this.navigationBar.id+"-title-view-underline",alpha:e}),this.navigationBarItems.titleView.definition],layout:(t,e)=>{t.top.equalTo(e.prev.bottom),t.width.equalTo(e.super),t.height.equalTo(this.navigationBarItems.titleView.topOffset+this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset)}})}this.page=PageView.createFromViews([this.view,this.navigationBar.getLargeTitleView(),t,this.navigationBar.getNavigationBarView(),this.navigationBarItems.fixedFooterView?.definition??{}])}else this.page=PageView.createFromViews([this.view]);this.view.props?.bgcolor?this.page.setProp("bgcolor",this.view.props.bgcolor):this.page.setProp("bgcolor",UIKit.defaultBackgroundColor(this.view.type))}getPage(){return this.page||this.#e(),this.page}},SearchBar=class extends BarTitleView{height=35;topOffset=15;bottomOffset=10;horizontalOffset=15;kbType=$kbType.search;placeholder=$l10n("SEARCH");inputEvents={};keyboardView;accessoryView;cancelButtonFont=$font(16);constructor(t){super(t),this.setController(new SearchBarController),this.controller.setSearchBar(this)}get cancelButtonWidth(){return UIKit.getContentSize(this.cancelButtonFont,$l10n("CANCEL")).width}setEvent(t,e){return this.inputEvents[t]=e,this}setPlaceholder(t){return this.placeholder=t,this}setKbType(t){return this.kbType=t,this}setKeyboardView(t){return this.keyboardView=t,this}setAccessoryView(t){return this.accessoryView=t,this}onBeginEditingAnimate(){$ui.animate({duration:.3,animation:()=>{let t=this.cancelButtonWidth;$(this.id+"-cancel-button").updateLayout(((e,i)=>{e.left.equalTo(i.super.right).offset(-t)})),$(this.id+"-cancel-button").alpha=1,$(this.id+"-cancel-button").relayout(),$(this.id+"-input").updateLayout((e=>{e.right.inset(t+this.horizontalOffset/2)})),$(this.id+"-input").relayout()}})}onEndEditingAnimate(){$ui.animate({duration:.3,animation:()=>{$(this.id+"-cancel-button").updateLayout(((t,e)=>{t.left.equalTo(e.super.right)})),$(this.id+"-cancel-button").alpha=0,$(this.id+"-cancel-button").relayout(),$(this.id+"-input").updateLayout($layout.fill),$(this.id+"-input").relayout()}})}cancel(){$(this.id+"-input").blur(),$(this.id+"-input").text="",this.onEndEditingAnimate(),this.controller.callEvent("onCancel")}getView(){return this.props={id:this.id,smoothCorners:!0,cornerRadius:6},this.views=[{type:"input",props:{id:this.id+"-input",type:this.kbType,bgcolor:$color("#EEF1F1","#212121"),placeholder:this.placeholder,keyboardView:this.keyboardView,accessoryView:this.accessoryView},layout:$layout.fill,events:Object.assign({didBeginEditing:t=>{this.onBeginEditingAnimate(),this.controller.callEvent("onBeginEditing",t.text)},didEndEditing:t=>{this.controller.callEvent("onEndEditing",t.text)},changed:t=>this.controller.callEvent("onChange",t.text),returned:t=>this.controller.callEvent("onReturn",t.text)},this.inputEvents)},{type:"button",props:{id:this.id+"-cancel-button",title:$l10n("CANCEL"),font:this.cancelButtonFont,titleColor:$color("tintColor"),bgcolor:$color("clear"),alpha:0,hidden:!1},events:{tapped:()=>this.cancel()},layout:(t,e)=>{t.height.equalTo(e.super),t.width.equalTo(this.cancelButtonWidth),t.left.equalTo(e.super.right)}}],this.layout=(t,e)=>{t.height.equalTo(this.height),t.top.equalTo(e.super.safeArea).offset(this.topOffset),t.left.equalTo(e.super.safeArea).offset(this.horizontalOffset),t.right.equalTo(e.super.safeArea).offset(-this.horizontalOffset)},this}},SearchBarController=class extends Controller{setSearchBar(t){return this.searchBar=t,this}updateSelector(){this.selector={inputBox:$(this.searchBar.id),input:$(this.searchBar.id+"-input")}}hide(){this.updateSelector(),this.selector.inputBox.updateLayout((t=>{t.height.equalTo(0)}))}show(){this.updateSelector(),this.selector.inputBox.updateLayout((t=>{t.height.equalTo(this.searchBar.height)}))}didScroll(t){this.updateSelector();let e=this.searchBar.height-t;if(e=e>0?e>this.searchBar.height?this.searchBar.height:e:0,this.selector.inputBox.updateLayout((t=>{t.height.equalTo(e)})),t>0){let e=(this.searchBar.height/2-5-t)/10;this.selector.input.alpha=e}else this.selector.input.alpha=1}didEndDragging(t,e,i){this.updateSelector(),t>=0&&t<=this.searchBar.height&&i($point(0,t>=this.searchBar.height/2?this.searchBar.height:0))}},ViewController=class extends Controller{#t=[];#e(t){t.callEvent("onPop"),this.callEvent("onPop",t),this.#t.pop()}push(t){let e=this.#t[this.#t.length-1];t.navigationBarItems.addPopButton(e?.navigationBar.title),this.#t.push(t),$ui.push({props:{statusBarStyle:0,navBarHidden:!0},events:{dealloc:()=>{this.#e(t)}},views:[t.getPage().definition],layout:$layout.fill})}},SettingInfo=class extends SettingItem{getView(){let t=Array.isArray(this.default),e=t?this.default[0]:this.default,i=t?this.default[1]:this.default;return{type:"view",props:{selectable:!0},views:[this.createLineLabel(),{type:"label",props:{text:e,align:$align.right,textColor:$color("darkGray")},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(SettingItem.edgeOffset),t.width.equalTo(180)}},{type:"view",events:{tapped:()=>{$ui.alert({title:this.title,message:i,actions:[{title:$l10n("COPY"),handler:()=>{$clipboard.text=i,$ui.toast($l10n("COPIED"))}},{title:$l10n("OK")}]})}},layout:(t,e)=>{t.right.inset(0),t.size.equalTo(e.super)}}],layout:$layout.fill}}},SettingSwitch=class extends SettingItem{getView(){return{type:"view",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:"switch",props:{on:this.get(),onColor:$color("#00CC00")},events:{changed:t=>{try{this.set(t.on)}catch(e){throw t.on=!t.on,e}}},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(SettingItem.edgeOffset)}}],layout:$layout.fill}}},SettingString=class extends SettingItem{getView(){return{type:"view",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:"button",props:{symbol:"square.and.pencil",bgcolor:$color("clear"),tintColor:$color("primaryText")},events:{tapped:t=>{let e=$ui.popover({sourceView:t,sourceRect:t.bounds,directions:$popoverDirection.down,size:$size(320,150),views:[{type:"text",props:{id:`${this.id}-string`,align:$align.left,text:this.get()},layout:t=>{t.left.right.inset(10),t.top.inset(20),t.height.equalTo(90)}},{type:"button",props:{symbol:"checkmark",bgcolor:$color("clear"),titleEdgeInsets:10,contentEdgeInsets:0},layout:t=>{t.right.inset(10),t.bottom.inset(25),t.size.equalTo(30)},events:{tapped:()=>{this.set($(`${this.id}-string`).text),e.dismiss()}}}]})}},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(0),t.size.equalTo(50)}}],layout:$layout.fill}}},SettingStepper=class extends SettingItem{with({min:t,max:e}={}){return this.options={min:t,max:e},this}getView({min:t,max:e}={}){let i=`${this.id}-label`;return{type:"view",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:"label",props:{id:i,text:this.get(),align:$align.left},layout:(t,e)=>{t.height.equalTo(e.super),t.right.inset(120)}},{type:"stepper",props:{min:t,max:e,value:this.get()},events:{changed:t=>{$(i).text=t.value;try{this.set(t.value)}catch(t){throw $(i).text=this.get(),t}}},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(SettingItem.edgeOffset)}}],layout:$layout.fill}}},SettingScript=class extends SettingItem{#h;#c(){$(this.id).bgcolor=$color("systemFill")}#d(t=.3){0===t?$(this.id).bgcolor=$color("clear"):$ui.animate({duration:t,animation:()=>{$(this.id).bgcolor=$color("clear")}})}#p(t,e=!1,i=0){if(t=Object.assign(t,{touchesBegan:()=>{this.#c(),this.#h=$delay(1,(()=>this.#d(0)))},touchesMoved:()=>{this.#h?.cancel(),this.#d(0)}}),e){let e=t.tapped;t.tapped=()=>{this.#c(),$delay(i,(()=>this.#d())),"function"==typeof e&&e()}}return t}with({script:t}={}){return this.options={script:t},this}getView({script:script}={}){let buttonId=`${this.id}-button`,rightSymbol="chevron.right",start=()=>{$(buttonId).alpha=0,$(`${buttonId}-spinner`).alpha=1,this.#c()},cancel=()=>{$(buttonId).alpha=1,$(`${buttonId}-spinner`).alpha=0,this.#d()},done=()=>{$(`${buttonId}-spinner`).alpha=0,this.#d();let t=$(buttonId);t.symbol="checkmark",$ui.animate({duration:.6,animation:()=>t.alpha=1,completion:()=>{$ui.animate({duration:.4,animation:()=>t.alpha=0,completion:()=>{t.symbol=rightSymbol,$ui.animate({duration:.4,animation:()=>t.alpha=1})}})}}),$delay(.6,(()=>{}))};return{type:"view",props:{id:this.id},views:[this.createLineLabel(),{type:"view",views:[{type:"button",props:{id:buttonId,symbol:rightSymbol,bgcolor:$color("clear"),tintColor:$color("secondaryText")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.right.inset(0),t.height.equalTo(e.super)}},{type:"spinner",props:{id:`${buttonId}-spinner`,loading:!0,alpha:0},layout:(t,e)=>{t.size.equalTo(15),t.centerY.equalTo(e.super),t.right.equalTo(e.prev)}}],layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}},{type:"view",layout:$layout.fill}],events:this.#p({tapped:()=>{let animate={start:start,cancel:cancel,done:done,touchHighlightStart:()=>this.#c(),touchHighlightEnd:()=>this.#d()};"function"==typeof script?script(animate):script.startsWith("this.method")?eval(`(()=>{return ${script}(animate)})()`):eval(script)}}),layout:$layout.fill}}},SettingTab=class extends SettingItem{with({items:t,values:e}={}){return Array.isArray(t)&&(t=t.map((t=>$l10n(t)))),this.options={items:t,values:e},this}getView({items:t,values:e}={}){t=this.evalValues(t),e=this.evalValues(e);let i=t?.length>0&&e?.length===t?.length;return{type:"view",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:"tab",props:{items:t??[],index:i?e.indexOf(this.get()):this.get(),dynamicWidth:!0},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.prev)},events:{changed:t=>{i?this.set(e[t.index]):this.set(t.index)}}}],layout:$layout.fill}}},SettingMenu=class extends SettingItem{with({items:t,values:e,pullDown:i}={}){return Array.isArray(t)&&(t=t.map((t=>$l10n(t)))),this.options={items:t,values:e,pullDown:i},this}getView({items:t,values:e,pullDown:i}={}){let s=`${this.id}-label`,r=this.evalValues(t),n=this.evalValues(e),a=r?.length>0&&n?.length===r?.length,o=(t,i)=>{if(a){let t=this.evalValues(e);this.set(t[i])}else this.set(i);$(s).title=t},l=()=>{i||$ui.menu({items:this.evalValues(t),handler:o})};return{type:"view",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:"view",views:[{type:"button",props:{menu:i?{pullDown:!0,asPrimary:!0,items:r.map(((t,e)=>({title:t,handler:()=>o(t,e)})))}:void 0,title:a?r[n.indexOf(this.get())]:r[this.get()],titleColor:$color("secondaryText"),bgcolor:$color("clear"),id:s},events:{tapped:l},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(e.super)}}],layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}}],events:{tapped:l},layout:$layout.fill}}},SettingColor=class extends SettingItem{get(t=null){let e=super.get(t);return e?"string"==typeof e?$color(e):$rgba(e.red,e.green,e.blue,e.alpha):t}getView(){let t=`${this.id}-color`;return{type:"view",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:"view",views:[{type:"view",props:{id:t,bgcolor:this.get(),circular:!0,borderWidth:1,borderColor:$color("#e3e3e3")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.right.inset(SettingItem.edgeOffset),t.size.equalTo(20)}},{type:"view",events:{tapped:async()=>{let e=await $picker.color({color:this.get()});this.set(e.components),$(t).bgcolor=$rgba(e.components.red,e.components.green,e.components.blue,e.components.alpha)}},layout:(t,e)=>{t.right.inset(0),t.height.width.equalTo(e.super.height)}}],layout:(t,e)=>{t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},SettingDate=class extends SettingItem{with({mode:t=2}={}){return this.options={mode:t},this}getView({mode:t=2}={}){let e=e=>{let i="";switch("number"==typeof e&&(e=new Date(e)),t){case 0:i=e.toLocaleTimeString();break;case 1:i=e.toLocaleDateString();break;case 2:i=e.toLocaleString()}return i};return{type:"view",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:"view",views:[{type:"label",props:{id:`${this.id}-label`,color:$color("secondaryText"),text:this.get()?e(this.get()):"None"},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(e.super)}}],events:{tapped:async()=>{let i=this.get(),s=await $picker.date({props:{mode:t,date:i||Date.now()}});this.set(s.getTime()),$(`${this.id}-label`).text=e(s)}},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},SettingInput=class extends SettingItem{with({secure:t=!1,kbType:e=$kbType.default,saveFunc:i}={}){return this.options={secure:t,kbType:e,saveFunc:i},this}getView({secure:t=!1,kbType:e=$kbType.default,saveFunc:i}={}){void 0===i&&(i=t=>this.set(t));let s=this.id+"-input";return{type:"view",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:"input",props:{id:s,type:e,align:$align.right,bgcolor:$color("clear"),textColor:$color("secondaryText"),text:this.get(),font:$font(16),secure:t,accessoryView:UIKit.blurBox({height:44},[UIKit.separatorLine({},UIKit.align.top),{type:"button",props:{title:$l10n("DONE"),bgcolor:$color("clear"),titleColor:$color("primaryText")},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.super)},events:{tapped:()=>{$(s).blur()}}},{type:"button",props:{title:$l10n("CANCEL"),bgcolor:$color("clear"),titleColor:$color("primaryText")},layout:(t,e)=>{t.left.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.super)},events:{tapped:()=>{let t=$(s),e=this.get("");t.text!==e&&(t.text=e),t.blur()}}}])},layout:(t,e)=>{t.left.equalTo(e.prev.get("label").right).offset(SettingItem.edgeOffset),t.right.inset(SettingItem.edgeOffset);let i=UIKit.getContentSize($font(16),this.get("")).width;t.width.greaterThanOrEqualTo(i+30),t.height.equalTo(e.super)},events:{didBeginEditing:t=>{t.secure=!1,$app.autoKeyboardEnabled||($app.autoKeyboardEnabled=!0)},returned:t=>{t.blur()},didEndEditing:async e=>{let s=this.get("");i(e.text)||(e.text=s),t&&(e.secure=t)}}}],layout:$layout.fill}}},SettingNumber=class extends SettingItem{getView(){return new SettingInput(this).getView({secure:!1,kbType:$kbType.decimal,saveFunc:t=>""!==t&&/^[0-9]+.?[0-9]*$/.test(t)?this.set(Number(t)):($ui.toast($l10n("INVALID_VALUE")),!1)})}},SettingIcon=class extends SettingItem{with({bgcolor:t="#000000"}={}){return this.options={bgcolor:t},this}getView({bgcolor:t="#000000"}={}){let e=`${this.id}-image`;return{type:"view",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:"view",views:[{type:"image",props:{cornerRadius:8,bgcolor:"string"==typeof t?$color(t):t,smoothCorners:!0},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.super),t.size.equalTo($size(30,30))}},{type:"image",props:{id:e,image:$image(this.get()),icon:$icon(this.get()?.slice(5,this.get().indexOf(".")),$color("#ffffff")),tintColor:$color("#ffffff")},layout:(t,e)=>{t.right.equalTo(e.prev).offset(-5),t.centerY.equalTo(e.super),t.size.equalTo($size(20,20))}}],events:{tapped:()=>{$ui.menu({items:[$l10n("JSBOX_ICON"),$l10n("SF_SYMBOLS"),$l10n("IMAGE_BASE64")],handler:async(t,i)=>{if(0===i){let t=await $ui.selectIcon();this.set(t),$(e).icon=$icon(t.slice(5,t.indexOf(".")),$color("#ffffff"))}else(1===i||2===i)&&$input.text({text:"",placeholder:t,handler:t=>{""!==t?(this.set(t),1===i?$(e).symbol=t:$(e).image=$image(t)):$ui.toast($l10n("INVALID_VALUE"))}})}})}},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},SettingPush=class extends SettingItem{with({view:t,tapped:e}={}){return this.options={view:t,tapped:e},this}getView({view:view,tapped:tapped}={}){return{type:"view",layout:$layout.fill,props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:"button",props:{symbol:"chevron.right",bgcolor:$color("clear"),tintColor:$color("secondaryText")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.right.inset(SettingItem.edgeOffset),t.height.equalTo(e.super)}},{type:"view",layout:$layout.fill}],events:{tapped:()=>{let push=view=>{if("string"==typeof view&&view.startsWith("this.method")?view=eval(`(()=>{return ${view}()})()`):"function"==typeof view&&(view=view()),this.setting.isUseJsboxNav)UIKit.push({title:this.title,props:view.props??{},views:[view]});else{let t=new NavigationView;t.setView(view).navigationBarTitle(this.title),t.navigationBarItems.addPopButton(),t.navigationBar.setLargeTitleDisplayMode(NavigationBar.largeTitleDisplayModeNever),this.setting.hasSectionTitle(view)&&t.navigationBar.setContentViewHeightOffset(-10),this.setting.viewController.push(t)}};"function"==typeof tapped?tapped(push):push(view)}}}}},SettingChild=class extends SettingItem{with({children:t}={}){return this.options={children:t},this}getView({children:t}={}){return new SettingPush(this).getView({tapped:e=>{this.setting.events?.onChildPush?this.setting.callEvent("onChildPush",this.setting.getListView(t,{}),this.title):e(this.setting.getListView(t,{}))}})}},SettingImage=class extends SettingItem{getImagePath(t=!1){let e=$text.MD5(this.key)+".jpg";return t&&(e="compress."+e),this.setting.imagePath+e}getImage(t=!1){try{return this.setting.fileStorage.readSync(this.getImagePath(t))}catch(t){if(t instanceof FileStorageFileNotFoundError)return null;throw t}}get(t=null){return this.getImage(!1)??null}getView(){let t=`${this.id}-image`,e=$image("questionmark.square.dashed"),i=e=>async()=>{$(t).hidden=!0,$(`${t}-spinner`).hidden=!1,await $wait(.1);try{await e()}catch(t){$ui.alert({title:$l10n("ERROR"),message:String(t)})}await $wait(.1),$(`${t}-spinner`).hidden=!0,$(t).hidden=!1},s=[{title:$l10n("PREVIEW"),handler:i((()=>{let t=this.getImage(!1);t?Sheet.quickLookImage(t):$ui.toast($l10n("NO_IMAGE"))}))},{inline:!0,items:[{title:$l10n("SELECT_IMAGE_PHOTO"),handler:i((async()=>{let e=await $photo.pick({format:"data"});if(!e.status||!e.data){if("canceled"!==e?.error?.description)throw new Error(e?.error?.description);return}let i=UIKit.compressImage(e.data.image);this.setting.fileStorage.write(this.getImagePath(!0),i.jpg(.8)),this.setting.fileStorage.write(this.getImagePath(),e.data),$(t).image=i,$ui.success($l10n("SUCCESS"))}))},{title:$l10n("SELECT_IMAGE_ICLOUD"),handler:i((async()=>{let e=await $drive.open();if(!e)return;let i=UIKit.compressImage(e.image);this.setting.fileStorage.write(this.getImagePath(!0),i.jpg(.8)),this.setting.fileStorage.write(this.getImagePath(),e),$(t).image=i,$ui.success($l10n("SUCCESS"))}))}]},{title:$l10n("CLEAR_IMAGE"),destructive:!0,handler:i((()=>{this.setting.fileStorage.delete(this.getImagePath(!0)),this.setting.fileStorage.delete(this.getImagePath()),$(t).image=e,$ui.success($l10n("SUCCESS"))}))}];return{type:"view",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:"view",views:[{type:"image",props:{id:t,image:this.getImage(!0)?.image??e},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.super),t.size.equalTo($size(30,30))}},{type:"spinner",props:{id:`${t}-spinner`,loading:!0,hidden:!0},layout:(t,e)=>{t.size.equalTo(e.prev),t.left.top.equalTo(e.prev)}},{type:"button",props:{menu:{pullDown:!0,asPrimary:!0,items:s},bgcolor:$color("clear")},layout:(t,e)=>{t.right.inset(SettingItem.edgeOffset),t.centerY.equalTo(e.super),t.size.equalTo($size(30,30))}}],layout:(t,e)=>{t.right.inset(0),t.height.equalTo(SettingItem.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},Setting=class extends Controller{name;setting={};settingItems={};userData;fileStorage;imagePath;viewController=new ViewController;method={readme:()=>{let t=(()=>{let t=$device.info?.language?.startsWith("zh")?"README_CN.md":"README.md";try{return __README__[t]??__README__["README.md"]}catch{return $file.read(t)?.string??$file.read("README.md")?.string}})();(new Sheet).setView({type:"markdown",props:{content:t},layout:(t,e)=>{t.size.equalTo(e.super)}}).init().present()}};#t=!1;#e=!1;#i;constructor(t={}){super(),"function"==typeof t.set&&"function"==typeof t.get?(this.set=t.set,this.getOriginal=t.get,this.setUserData(t.userData??{})):(this.fileStorage=t.fileStorage??new FileStorage,this.dataFile=t.dataFile??"setting.json"),t.structure?this.setStructure(t.structure):this.setStructurePath(t.structurePath??"setting.json"),this.isUseJsboxNav=t.isUseJsboxNav??!1,this.imagePath=(t.name??"default")+".image/",this.setName(t.name??$text.uuid)}useJsboxNav(){return this.isUseJsboxNav=!0,this}#s(){if(!this.#e)throw new SettingLoadConfigError}loader(t){t.setting=this;let e=null;switch(t.type){case"info":e=new SettingInfo(t);break;case"switch":e=new SettingSwitch(t);break;case"string":e=new SettingString(t);break;case"stepper":e=new SettingStepper(t).with({min:t.min??1,max:t.max??12});break;case"script":e=new SettingScript(t).with({script:t.script??t.value});break;case"tab":e=new SettingTab(t).with({items:t.items,values:t.values});break;case"menu":e=new SettingMenu(t).with({items:t.items,values:t.values,pullDown:t.pullDown??!1});break;case"color":e=new SettingColor(t);break;case"date":e=new SettingDate(t).with({mode:t.mode});break;case"input":e=new SettingInput(t).with({secure:t.secure});break;case"number":e=new SettingNumber(t);break;case"icon":e=new SettingIcon(t).with({bgcolor:t.bgcolor});break;case"push":e=new SettingPush(t).with({view:t.view});break;case"child":e=new SettingChild(t).with({children:t.children});break;case"image":e=new SettingImage(t)}return e}loadConfig(){this.#e=!1;let t=this.userData??this.fileStorage.readAsJSON(this.dataFile,{}),e=t=>t instanceof SettingItem?t instanceof SettingScript||t instanceof SettingInfo:["script","info"].includes(t.type),i=s=>{for(let r in s)for(let n in s[r].items){let a=s[r].items[n];a instanceof SettingItem||(s[r].items[n]=this.loader(a)),s[r].items[n].setting||(s[r].items[n].setting=this),s[r].items[n]instanceof SettingChild?i(s[r].items[n].options.children):e(a)||(a.key in t?this.setting[a.key]=t[a.key]:this.setting[a.key]=a.value??a.default,this.settingItems[a.key]=s[r].items[n])}};return i(this.structure),this.#e=!0,this}hasSectionTitle(t){return this.#s(),!!t[0]?.title}setUserData(t){return this.userData=t,this}setStructure(t){return this.structure=t,this.loadConfig()}setStructurePath(t){return this.structure||this.setStructure(FileStorage.readFromRootAsJSON(t)),this}setName(t){return this.name=t,this}setFooter(t){return this.#i=t,this}set footer(t){this.#i=t}get footer(){if(void 0===this.#i){let t=FileStorage.readFromRootAsJSON("config.json",{}).info??{};if(!t.version||!t.author)try{t=__INFO__}catch{}this.#i={},t.version&&t.author&&(this.#i={type:"view",props:{height:70},views:[{type:"label",props:{font:$font(14),text:`${$l10n("VERSION")} ${t.version} ♥ ${t.author}`,textColor:$color({light:"#C0C0C0",dark:"#545454"}),align:$align.center},layout:t=>{t.left.right.inset(0),t.top.inset(10)}}]})}return this.#i}setReadonly(){return this.#t=!0,this}set(t,e){if(this.#t)throw new SettingReadonlyError;return this.#s(),this.setting[t]=e,this.fileStorage.write(this.dataFile,$data({string:JSON.stringify(this.setting)})),this.callEvent("onSet",t,e),!0}getOriginal(t,e=null){return this.#s(),Object.prototype.hasOwnProperty.call(this.setting,t)?this.setting[t]:e}getItem(t){return this.settingItems[t]}get(t,e=null){return this.#s(),this.getItem(t)?this.getItem(t).get(e):this.getOriginal(t,e)}#r(t){let e=[];for(let i of t){let t=[];for(let e of i.items)e instanceof SettingItem&&t.push(e.create());e.push({title:$l10n(i.title??""),rows:t})}return e}getListView(t=this.structure,e=this.footer){return{type:"list",props:{id:this.name,style:2,separatorInset:$insets(0,SettingItem.iconSize+2*SettingItem.edgeOffset,0,SettingItem.edgeOffset),footer:e,data:this.#r(t)},layout:$layout.fill,events:{rowHeight:(t,e)=>(t.object(e)?.props?.info??{}).rowHeight??SettingItem.rowHeight}}}getNavigationView(){let t=new NavigationView;return t.setView(this.getListView(this.structure)).navigationBarTitle($l10n("SETTING")),this.hasSectionTitle(this.structure)&&t.navigationBar.setContentViewHeightOffset(-10),t}getPage(){return this.getNavigationView().getPage()}},SheetViewTypeError=class extends ValidationError{constructor(t,e){super(t,e),this.name="SheetViewTypeError"}},TabBarCellView=class extends View{constructor(t={}){super(t),this.setIcon(t.icon),this.setTitle(t.title),void 0!==t.activeStatus&&(this.activeStatus=t.activeStatus)}setIcon(t){return this.icon=t instanceof Array?t:[t,t],this}setTitle(t){return this.title=t,this}active(){$(`${this.props.id}-icon`).image=$image(this.icon[1]),$(`${this.props.id}-icon`).tintColor=$color("systemLink"),$(`${this.props.id}-title`).textColor=$color("systemLink"),this.activeStatus=!0}inactive(){$(`${this.props.id}-icon`).image=$image(this.icon[0]),$(`${this.props.id}-icon`).tintColor=$color("lightGray"),$(`${this.props.id}-title`).textColor=$color("lightGray"),this.activeStatus=!1}getView(){return this.views=[{type:"image",props:{id:`${this.props.id}-icon`,image:$image(this.activeStatus?this.icon[1]:this.icon[0]),bgcolor:$color("clear"),tintColor:$color(this.activeStatus?"systemLink":"lightGray")},layout:(t,e)=>{t.centerX.equalTo(e.super);let i=TabBarController.tabBarHeight/2;t.size.equalTo(i),t.top.inset((TabBarController.tabBarHeight-i-13)/2)}},{type:"label",props:{id:`${this.props.id}-title`,text:this.title,font:$font(10),textColor:$color(this.activeStatus?"systemLink":"lightGray")},layout:(t,e)=>{t.centerX.equalTo(e.prev),t.top.equalTo(e.prev.bottom).offset(3)}}],this}},TabBarHeaderView=class extends View{height=60;getView(){return this.type="view",this.setProp("bgcolor",this.props.bgcolor??UIKit.primaryViewBackgroundColor),this.layout=(t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.height-TabBarController.tabBarHeight)},this.views=[View.create({props:this.props,views:this.views,layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.height.equalTo(this.height)}})],this}},TabBarController=class t extends Controller{static tabBarHeight=50;#t={};#e={};#i;#s;#r=$text.uuid;#u=$text.uuid;bottomSafeAreaInsets=$app.isDebugging?0:UIKit.bottomSafeAreaInsets;get selected(){return this.#s}set selected(t){this.switchPageTo(t)}get contentOffset(){return t.tabBarHeight+(this.#i?.height??0)}setPages(t={}){return Object.keys(t).forEach((e=>this.setPage(e,t[e]))),this}setPage(t,e){return void 0===this.#s&&(this.#s=t),this.#t[t]=e instanceof PageView?e:PageView.create(e),this.#s!==t&&(this.#t[t].activeStatus=!1),this}switchPageTo(t){if(this.#t[t]){if(this.#s===t)return;$ui.animate({duration:.4,animation:()=>{this.#e[t].active()}}),this.#e[this.#s].inactive(),this.#t[this.#s].hide(),this.#t[t].show(),this.callEvent("onChange",this.#s,t),this.#s=t,this.initBackground()}}hideBackground(t=!0){$(this.#u).hidden=!0,$ui.animate({duration:t?.2:1e-4,animation:()=>{$(this.#r).alpha=0}})}showBackground(t=!0){$(this.#u).hidden=!1,$ui.animate({duration:t?.2:1e-4,animation:()=>{$(this.#r).alpha=1}})}initBackground(){let t=this.#t[this.selected];t.scrollable&&$delay(0,(()=>{let e=$(t.id).get(t.scrollableView.id),i=e.contentOffset.y;e.contentSize.height+this.bottomSafeAreaInsets-e.frame.height-i<=0?this.hideBackground(!1):this.showBackground(!1)}))}setCells(t={}){return Object.keys(t).forEach((e=>this.setCell(e,t[e]))),this}setCell(t,e){return void 0===this.#s&&(this.#s=t),e instanceof TabBarCellView||(e=new TabBarCellView({props:{info:{key:t}},icon:e.icon,title:e.title,activeStatus:this.#s===t})),this.#e[t]=e,this}setHeader(t){return this.#i=t,this}#g(){let t=[];return Object.values(this.#e).forEach((e=>{e.setEvent("tapped",(t=>{let e=t.info.key;this.switchPageTo(e)})),t.push(e.getView())})),t}#y(){return Object.values(this.#t).map((t=>{if(t.scrollable){let e=t.scrollableView;if(e.props.indicatorInsets){let t=e.props.indicatorInsets;e.props.indicatorInsets=$insets(t.top,t.left,t.bottom+this.contentOffset,t.right)}else e.props.indicatorInsets=$insets(0,0,this.contentOffset,0);e.props.footer=Object.assign({props:{}},e.props.footer??{}),e.props.footer.props.height?e.props.footer.props.height+=this.contentOffset:e.props.footer.props.height=this.contentOffset,"function"==typeof e.assignEvent&&e.assignEvent("didScroll",(t=>{let e=t.contentOffset.y;t.contentSize.height+this.bottomSafeAreaInsets-t.frame.height-e<=1?this.hideBackground():this.showBackground()}))}return t.definition}))}generateView(){let e={type:"view",layout:(e,i)=>{e.centerX.equalTo(i.super),e.width.equalTo(i.super),e.top.equalTo(i.super.safeAreaBottom).offset(-t.tabBarHeight),e.bottom.equalTo(i.super)},views:[UIKit.blurBox({id:this.#r}),{type:"stack",layout:$layout.fillSafeArea,props:{axis:$stackViewAxis.horizontal,distribution:$stackViewDistribution.fillEqually,spacing:0,stack:{views:this.#g()}}},UIKit.separatorLine({id:this.#u},UIKit.align.top)],events:{ready:()=>this.initBackground()}};return View.createFromViews(this.#y().concat(this.#i?.definition??[],e))}},PageView=class extends View{constructor(t={}){super(t),this.activeStatus=!0}show(){$(this.props.id).hidden=!1,this.activeStatus=!0}hide(){$(this.props.id).hidden=!0,this.activeStatus=!1}setHorizontalSafeArea(t){return this.horizontalSafeArea=t,this}#t(t,e){t.top.bottom.equalTo(e.super),this.horizontalSafeArea?t.left.right.equalTo(e.super.safeArea):t.left.right.equalTo(e.super)}getView(){return this.layout=this.#t,this.props.clipsToBounds=!0,this.props.hidden=!this.activeStatus,super.getView()}},WebDAV=class extends Request{#t;user;password;#e;namespace="JSBox.WebDAV";lockTokenCacheKey=this.namespace+".lockToken";get host(){return this.#t}set host(t){for(this.#t=t.trim();this.#t.endsWith("/");)this.#t=this.#t.substring(0,this.#t.length-1);this.#t.startsWith("http")||(this.#t="http://"+this.#t)}get basepath(){return this.#e}set basepath(t){for(this.#e=t.trim();this.#e.endsWith("/");)this.#e=this.#e.substring(0,this.#e.length-1);for(;this.#e.startsWith("/");)this.#e=this.#e.substring(1);this.#e="/"+this.#e}constructor({host:t,user:e,password:i,basepath:s=""}={}){super((t=>console.log(t))),this.host=t,this.user=e,this.password=i,this.basepath=s}#i(t){return t=(t=t.trim()).startsWith("/")?t:"/"+t,this.basepath+t}async request(t,e,i=null,s={}){return s=Object.assign({"Content-Type":"text/xml; charset=UTF-8",Authorization:"Basic "+$text.base64Encode(`${this.user}:${this.password}`)},s),await super.request(this.host+this.#i(t),e,i,s)}async allow(t){let e=await this.request(t,Request.method.options);return(e.response.headers?.allow??e.response.headers?.Allow)?.split(",").map((t=>t.trim().toUpperCase()))??[]}async propfind(t,e=[],i=0){Array.isArray(e)||(e=[e]);let s=`${e.map((t=>``)).join()}`,r=await this.request(t,"PROPFIND",s,{Depth:i});return $xml.parse({string:r.data})}async propfindAll(t,e=0){let i=await this.request(t,"PROPFIND",'',{Depth:e});return $xml.parse({string:i.data})}async ls(t,e=1){let i=await this.request(t,"PROPFIND",null,{Depth:e});return $xml.parse({string:i.data})}async exists(t){try{return(await this.allow(t)).includes(Request.method.get)?await this.request(t,Request.method.head):await this.ls(t,0),!0}catch(t){if(404===t?.code)return!1;throw t}}async mkdir(t){return await this.request(t,"MKCOL")}async get(t){return await this.request(t,Request.method.get,null)}async put(t,e,{withLock:i=!0,waitInterval:s=2,maxTry:r=3}={}){let n={};for(;await this.isLocked(t);){if(--r<=0)throw new Error("Resource Locked");await $wait(s)}if(i)try{await this.lock(t),n.If=`(${this.#r(t)})`}catch(t){if(404!==t.code)throw t;i=!1}await this.request(t,Request.method.put,e,n),i&&await this.unlock(t)}async delete(t){if(!t)throw new Error("path empty");return await this.request(t,Request.method.delete)}#s(t,e){let i=$cache.get(this.lockTokenCacheKey)??{};i[t]=e,$cache.set(this.lockTokenCacheKey,i)}#r(t){return($cache.get(this.lockTokenCacheKey)??{})[t]}async isSupportLock(t){try{return!!(await this.propfind(t,"supportedlock")).rootElement.firstChild({xPath:"//D:response/D:propstat/D:prop/D:supportedlock/D:lockentry"}).firstChild({xPath:"//D:locktype/D:write"})}catch(t){if(404!==t.code)return!1;throw t}}async lock(t,{infinity:e=!1,timeout:i="Second-10"}={}){if(!await this.isSupportLock(t))throw new Error("Your WebDAV service does not support the `LOCK` method.");let s=`${this.namespace}`,r=await this.request(t,"LOCK",s,{Timeout:i,Depth:e?"infinity":0}),n=r.response.headers["lock-token"]??r.response.headers["Lock-Token"];return this.#s(t,n),$xml.parse({string:r.data})}async isLocked(t){try{let e=(await this.propfind(t,"lockdiscovery")).rootElement;if(e.firstChild({xPath:"//D:response/D:propstat/D:status"}).string.includes("404"))await this.lock(t,{timeout:"Second-0"});else{let i=e.firstChild({xPath:"//D:response/D:propstat/D:prop/D:lockdiscovery"}).children()??[];for(let e=0;e10240){const t=n.join(this.logPath,`caio.${Date.now()}.log`);this.fileStorage.move(this.logFilePath,t)}}t instanceof Error&&(t=`${t}\n${t.stack}`),super.error(t),this.logger.error(t)}initComponents(){this.clips=new c(this),this.actionManager=new d(this),this.fileManager=new o}}t.exports={AppKernelBase:p}})),parcelRequire.register("2EAPF",(function(t,e){var i=parcelRequire("gxpqj"),s=i.SettingInfo,r=i.SettingScript,n=i.SettingTab,a=parcelRequire("3dE3D"),o=parcelRequire("2jPf3"),l=parcelRequire("iN4Y6"),h=parcelRequire("knZRr"),c=parcelRequire("aziQd"),d=parcelRequire("5xoIG"),p=parcelRequire("fEWdA");const u={items:[a,o,l,h,c,d]},g={items:[new n({icon:["rectangle.topthird.inset.filled","#A569BD"],title:"DISPLAY_MODE",key:"mainUIDisplayMode",value:0}).with({items:["CLASSIC","MODERN"]}),new r({icon:["folder.fill","#FF9900"],title:"FILE_MANAGEMENT"}).with({script:"this.method.fileManager"})]},y={items:[p]},m={items:[new s({icon:["/assets/icon/github.com.jpeg","white"],title:"Github",value:["ipuppet/CAIO","https://github.com/ipuppet/CAIO"]}),new s({icon:["/assets/icon/telegram.png","white"],title:"Telegram",value:["JSBoxTG","https://t.me/JSBoxTG"]}),new s({icon:["person.fill","#FF9900"],title:"AUTHOR",value:["ipuppet","https://blog.ultagic.com"]}),new r({icon:"arrow.2.circlepath",title:"CHECK_UPDATE"}).with({script:"this.method.checkUpdate"}),new r({icon:["book.fill","#A569BD"],title:"README"}).with({script:"this.method.readme"})]};t.exports=[u,g,y,m]})),parcelRequire.register("3dE3D",(function(t,e){var i=parcelRequire("gxpqj"),s=i.SettingSwitch,r=i.SettingScript,n=i.SettingNumber,a=i.SettingPush,o=i.SettingChild;t.exports=new o({icon:["doc.on.clipboard","#FFCC66"],title:"CLIPS"}).with({children:[{items:[new s({icon:["link","#FF6633"],title:"UNIVERSAL_CLIPBOARD",key:"clipboard.universal",value:!0}),new r({icon:["cursorarrow.rays","#FF6633"],title:"Tips"}).with({script:"$ui.alert({title:$l10n('UNIVERSAL_CLIPBOARD'),message:$l10n('UNIVERSAL_CLIPBOARD_TIPS')})"})]},{items:[new a({icon:["trash","red"],title:"RECYCLE_BIN",key:"clipboard.recycleBin"}).with({view:"this.method.recycleBin"})]},{items:[new n({icon:["text.alignleft","#FFCC66"],title:"MAX_ITEM_LENGTH",key:"clipboard.maxItemLength",value:100}),new s({icon:["square.and.arrow.down.on.square","#FF6633"],title:"AUTO_SAVE",key:"clipboard.autoSave",value:!0})]},{items:[new r({icon:"square.and.arrow.up",title:"EXPORT"}).with({script:"this.method.exportClipboard"}),new r({icon:["square.and.arrow.down","#FFCC33"],title:"IMPORT"}).with({script:"this.method.importClipboard"})]},{items:[new r({icon:["arrow.2.circlepath","red"],title:"REBUILD_DATABASE"}).with({script:"this.method.rebuildDatabase"}),new r({icon:["trash","red"],title:"DELETE_ALL_DATA"}).with({script:"this.method.deleteAllData"})]}]})})),parcelRequire.register("2jPf3",(function(t,e){var i=parcelRequire("gxpqj"),s=i.SettingScript,r=i.SettingChild;t.exports=new r({icon:["bolt.circle","#FF6633"],title:"ACTIONS"}).with({children:[{items:[new s({icon:["bolt.circle","#FF6633"],title:"IMPORT_EXAMPLE_ACTIONS",value:"this.method.importExampleAction"}).with({script:"this.method.importExampleAction"})]},{items:[new s({icon:"square.and.arrow.up",title:"EXPORT"}).with({script:"this.method.exportAction"}),new s({icon:["square.and.arrow.down","#FFCC33"],title:"IMPORT"}).with({script:"this.method.importAction"})]},{items:[new s({icon:["arrow.2.circlepath","red"],title:"REBUILD_ACTION_DATABASE"}).with({script:"this.method.rebuildAction"})]}]})})),parcelRequire.register("iN4Y6",(function(t,e){var i=parcelRequire("gxpqj"),s=i.SettingSwitch,r=i.SettingInput,n=i.SettingNumber,a=i.SettingChild;t.exports=new a({icon:["pencil.circle","#CC0099"],title:"EDITOR"}).with({children:[{title:"CLIPS",items:[new n({icon:["wand.and.stars","#FF6633"],title:"TEXT_INSETS",key:"editor.text.insets",value:300})]},{title:"CODE",items:[new s({icon:["list.number","#6699CC"],title:"SHOW_LINE_NUMBER",key:"editor.code.lineNumbers",value:!1}),new r({icon:["wand.and.stars","#FF6633"],title:"LIGHT_MODE_THEME",key:"editor.code.lightTheme",value:"atom-one-light"}),new r({icon:["wand.and.stars","#FF6633"],title:"DARK_MODE_THEME",key:"editor.code.darkTheme",value:"atom-one-dark"})]}]})})),parcelRequire.register("knZRr",(function(t,e){var i=parcelRequire("gxpqj"),s=i.SettingSwitch,r=i.SettingStepper,n=i.SettingScript,a=i.SettingTab,o=i.SettingNumber,l=i.SettingPush,h=i.SettingChild,c=i.SettingImage;t.exports=new h({icon:["keyboard","#a2a5a6"],title:"KEYBOARD"}).with({children:[{items:[new l({icon:"rectangle.3.offgrid.fill",title:"PREVIEW",key:"keyboard.previewAndHeight",value:267}).with({view:"this.method.previewKeyboard"})]},{items:[new a({icon:["rectangle.topthird.inset.filled","#A569BD"],title:"DISPLAY_MODE",key:"keyboard.displayMode",value:0}).with({items:["list","matrix"]}),new s({icon:["checkerboard.rectangle","#1899c4"],title:"USE_BLUR",key:"keyboard.blur",value:!1}),new c({icon:["photo","#FFCC66"],title:"BACKGROUND_IMAGE",key:"keyboard.background.image"})]},{items:[new s({icon:["globe","#1899c4"],title:"SWITCH_AFTER_INSERT",key:"keyboard.switchAfterInsert",value:!1}),new s({icon:["cursor.rays","#FF8C00"],title:"TAPTIC_ENGINE",key:"keyboard.tapticEngine",value:!0}),new r({icon:["cursor.rays","#FF8C00"],title:"TAPTIC_ENGINE_LEVEL",key:"keyboard.tapticEngineLevel",value:1}).with({min:0,max:2}),new n({icon:"paperplane",title:"QUICK_START_SCRIPTS"}).with({script:"this.method.setKeyboardQuickStart"})]},{items:[new o({icon:["rays","#FFCC33"],title:"DELETE_DELAY",key:"keyboard.deleteDelay",value:.05})]}]})})),parcelRequire.register("aziQd",(function(t,e){var i=parcelRequire("gxpqj"),s=i.SettingScript,r=i.SettingMenu,n=i.SettingChild;t.exports=new n({icon:["rectangle.3.offgrid.fill","#1899c4"],title:"WIDGET"}).with({children:[{items:[new s({icon:"rectangle.3.offgrid.fill",title:"PREVIEW"}).with({script:"this.method.previewWidget"})]},{title:"2x2",items:[new r({icon:"link",title:"CLICK_ACTION",key:"widget.2x2.widgetURL",value:2}).with({pullDown:!0,items:["ADD","ACTIONS","CLIPS"]})]}]})})),parcelRequire.register("5xoIG",(function(t,e){var i=parcelRequire("gxpqj"),s=i.SettingScript,r=i.SettingChild;t.exports=new r({icon:["filemenu.and.selection","#ebcc34"],title:"TODAY_WIDGET"}).with({children:[{items:[new s({icon:"rectangle.3.offgrid.fill",title:"PREVIEW"}).with({script:"this.method.previewTodayWidget"})]},{items:[new s({icon:"bolt.circle",title:"ACTIONS"}).with({script:"this.method.setTodayWidgetActions"})]}]})})),parcelRequire.register("fEWdA",(function(t,e){var i=parcelRequire("gxpqj").SettingChild,s=parcelRequire("fiqsI");t.exports=new i({icon:"wrench.and.screwdriver",title:"EXPERIMENTAL"}).with({children:[{items:[s]}]})})),parcelRequire.register("fiqsI",(function(t,e){var i=parcelRequire("gxpqj"),s=i.SettingSwitch,r=i.SettingInput,n=i.SettingChild;t.exports=new n({icon:["cloud","#FF9900"],title:"WebDAV"}).with({children:[{items:[new s({icon:["cloud","#FF9900"],title:"WebDAV",key:"webdav.status",value:!1})]},{items:[new r({icon:"link",title:"HOST",key:"webdav.host",value:""}),new r({icon:"person",title:"USER",type:"input",key:"webdav.user",value:""}),new r({icon:"person.badge.key",title:"PASSWORD",type:"input",key:"webdav.password",value:""}),new r({icon:"link",title:"BASEPATH",type:"input",key:"webdav.basepath",value:""})]}]})})),parcelRequire.register("jEwwi",(function(t,e){var i=parcelRequire("gxpqj").UIKit,s=parcelRequire("7GYtH");class r{fileStorage;fsPath;imagePath;#f;static isImage(t=""){return t?.startsWith("@image=")}static pathToKey(t){return`@image=${t=JSON.stringify(t)}`}static keyToPath(t){if(r.isImage(t)){return JSON.parse(t.slice(7))}return!1}constructor({uuid:t,section:e,text:i="",md5:s,tag:r=null,prev:n=null,next:a=null}={}){if(!t)throw new Error("Clip create faild: uuid undefined");if(!e)throw new Error("Clip create faild: section undefined");this.uuid=t,this.section=e,this.text=i,this.md5=s??$text.MD5(this.text),this.tag=r,this.prev=n,this.next=a}get text(){return this.#f}set text(t){this.#f=t,r.isImage(t)&&this.#w(r.keyToPath(t))}get hasTag(){return null!==this.tag}get image(){return r.isImage(this.text)}get imageOriginal(){return this.#b("original")}get imagePreview(){return this.#b("preview")}#b(t){if(this.image&&this.fileStorage.exists(this.fsPath[t]))return this.fileStorage.readSync(this.fsPath[t])}#w(t){this.fileStorage&&(this.fsPath=t,this.imagePath={original:this.fileStorage.filePath(t.original),preview:this.fileStorage.filePath(t.preview)})}}class n{sqlite;constructor(t){this.kernel=t,this.dbName="CAIO.db",this.localDb=`/${this.dbName}`;const e="/image";this.imagePath={base:e,original:`${e}/original`,preview:`${e}/preview`},this.tempPath="/temp",this.tempDbFile=`${this.tempPath}/${this.dbName}`,this.tempImagePath=`${this.tempPath}/image`,this.exportFileName="CAIO.zip",this.initWebdavSync(),this.init()}async initWebdavSync(){if(this.kernel.setting.get("webdav.status"))try{this.webdavSync=new s({kernel:this.kernel,host:this.kernel.setting.get("webdav.host"),user:this.kernel.setting.get("webdav.user"),password:this.kernel.setting.get("webdav.password"),basepath:this.kernel.setting.get("webdav.basepath")}),await this.webdavSync.init()}catch(t){throw this.kernel.error(t),t}}needUpload(){this.kernel.setting.get("webdav.status")&&this.webdavSync.needUpload()}sync(){this.kernel.setting.get("webdav.status")&&this.webdavSync.sync()}init(){this.sqlite&&this.sqlite.close(),this.sqlite=$sqlite.open(this.kernel.fileStorage.filePath(this.localDb)),this.sqlite.update("CREATE TABLE IF NOT EXISTS clips(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)"),this.sqlite.update("CREATE TABLE IF NOT EXISTS favorite(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, md5 TEXT, prev TEXT, next TEXT)"),this.sqlite.update("CREATE TABLE IF NOT EXISTS tag(uuid TEXT PRIMARY KEY NOT NULL, tag TEXT)"),this.kernel.print("init database")}rebuild(){const t=this.tempPath+"/rebuild.db";this.kernel.fileStorage.delete(t);const e=new n(this.kernel);e.localDb=t,e.init();const i=(t,i)=>{const s=[];t.forEach((t=>{const n=new r({uuid:t.uuid,text:t.text,section:t.section,md5:t.md5,tag:t.tag,prev:null,next:s[0]?.uuid??null});e.beginTransaction();try{e.insert(n),n.next&&(s[0].prev=n.uuid,s[0].section=i,e.update(s[0])),e.commit(),s.unshift(n)}catch(t){throw e.rollback(),this.kernel.error(t),t}}))};["clips","favorite"].map((t=>{let e=this.all(t);try{const t=this.sort(e);if(t.length>e.length)throw new Error;e=t.reverse()}catch{}i(e,t)}));const s=this.sqlite.query("SELECT * FROM tag");this.parseTag(s).forEach((t=>{e.beginTransaction();try{e.setTag(t.uuid,t.tag),e.commit()}catch(t){throw e.rollback(),this.kernel.error(t),t}})),this.kernel.fileStorage.copy(t,this.localDb),this.needUpload(),this.kernel.print("database rebuild")}deleteAllData(){this.kernel.fileStorage.delete(this.imagePath.base),this.kernel.fileStorage.delete(this.localDb),this.needUpload(),this.kernel.print("delete all database")}clearTemp(){this.kernel.fileStorage.delete(this.tempPath)}async export(t){this.clearTemp(),this.kernel.fileStorage.copy(this.localDb,this.tempDbFile),this.kernel.fileStorage.copy(this.imagePath.base,this.tempImagePath);const e=this.tempPath+"/"+this.exportFileName;await $archiver.zip({directory:this.kernel.fileStorage.filePath(this.tempPath),dest:this.kernel.fileStorage.filePath(e)}),$share.sheet({items:[{name:this.exportFileName,data:$data({path:this.kernel.fileStorage.filePath(e)})}],handler:i=>{this.kernel.fileStorage.delete(e),t(i)}})}async import(t){if("db"===t.fileName.slice(-2)){if(!this.kernel.fileStorage.writeSync(this.localDb,t))throw new Error("WRITE_DB_FILE_FAILED")}else if("zip"===t.fileName.slice(-3)){if(!await $archiver.unzip({file:t,dest:this.kernel.fileStorage.filePath(this.tempPath)}))throw new Error("UNZIP_FAILED");this.kernel.fileStorage.move(this.tempDbFile,this.localDb),this.kernel.fileStorage.move(this.tempImagePath,this.imagePath.base)}this.webdavSync&&this.webdavSync.updateLocalTimestamp()}sort(t,e=9e3){const i={};let s=0,r=null;t.forEach((t=>{i[t.uuid]=t,null===t.prev&&(r=t.uuid),s++}));const n=[];if(s>0)try{let t=i[r];for(;null!==t.next&&e>0;)e--,n.push(t),t=i[t.next];n.push(t)}catch(t){throw"Unable to sort: "+t}return n}replaceString(t){return["\\",'"',"'","%","-","_",";"].forEach((e=>{t=t.replaceAll(e,`\\${e}`)})),t}parse(t){const e=t.result,i=t.error,s=[];try{if(null!==i)throw new Error(`Code [${i.code}] ${i.domain} ${i.localizedDescription}`);for(;e.next();){const t=e.get("text"),i=new r({uuid:e.get("uuid"),section:e.get("section"),md5:e.get("md5"),tag:e.get("tag"),prev:e.get("prev"),next:e.get("next")});r.isImage(t)&&(i.fileStorage=this.kernel.fileStorage),i.text=t,s.push(i)}}catch(i){throw i}finally{e.close()}return s}parseTag(t){if(null!==t.error)throw t.error;const e=[];for(;t.result.next();)e.push({uuid:t.result.get("uuid"),tag:t.result.get("tag")});return t.result.close(),e}beginTransaction(){this.sqlite.beginTransaction()}commit(){this.sqlite.commit()}rollback(){this.sqlite.rollback()}getByUUID(t=""){const e=this.sqlite.query({sql:"\n SELECT a.*, tag from\n (SELECT *, 'clips' AS section FROM clips WHERE uuid = ?\n UNION\n SELECT *, 'favorite' AS section FROM favorite WHERE uuid = ?) a\n LEFT JOIN tag ON a.uuid = tag.uuid\n ",args:[t,t]});return this.parse(e)[0]}getByMD5(t=""){const e=this.sqlite.query({sql:"\n SELECT a.*, tag from\n (SELECT *, 'clips' AS section FROM clips WHERE md5 = ?\n UNION\n SELECT *, 'favorite' AS section FROM favorite WHERE md5 = ?) a\n LEFT JOIN tag ON a.uuid = tag.uuid\n ",args:[t,t]});return this.parse(e)[0]}async search(t){const e=(await $text.tokenize({text:t})).map((t=>this.replaceString(t))),i=`%${e.join("%")}%`,s=this.sqlite.query({sql:`\n SELECT a.*, tag from\n (SELECT *, 'clips' AS section FROM clips WHERE text like "${i}"\n UNION\n SELECT *, 'favorite' AS section FROM favorite WHERE text like "${i}") a\n LEFT JOIN tag ON a.uuid = tag.uuid\n `});return{result:this.parse(s),keyword:e}}searchByTag(t){t.startsWith("#")&&(t=t.substring(1));const e=this.sqlite.query({sql:`SELECT * FROM tag WHERE tag like "%${this.replaceString(t)}%"`}),i=this.parseTag(e),s=[];return i.forEach((t=>{s.push(this.getByUUID(t.uuid))})),{result:s,keyword:[t]}}deleteTable(t){const e=this.sqlite.update(`DELETE FROM ${t}`);if(!e.result)throw e.error;this.needUpload(),this.kernel.print(`delete table ${t}`)}all(t){const e=this.sqlite.query(`SELECT ${t}.*, tag, '${t}' AS section FROM ${t} LEFT JOIN tag ON ${t}.uuid = tag.uuid`);return this.parse(e)}saveImage(t){if("object"==typeof t){const e=$text.uuid,s={original:`${this.imagePath.original}/${e}.png`,preview:`${this.imagePath.preview}/${e}.jpg`};return this.kernel.fileStorage.write(s.original,t.png),this.kernel.fileStorage.write(s.preview,i.compressImage(t).jpg(.8)),r.pathToKey(s)}throw new Error("saveImageError: image not an object")}insert(t){const e=this.sqlite.update({sql:`INSERT INTO ${t.section} (uuid, text, md5, prev, next) values (?, ?, ?, ?, ?)`,args:[t.uuid,t.text,$text.MD5(t.text),t.prev,t.next]});if(!e.result)throw e.error;this.needUpload()}update(t){if(Object.keys(t).length<4||"string"!=typeof t.uuid)return;const e=this.sqlite.update({sql:`UPDATE ${t.section} SET text = ?, md5 = ?, prev = ?, next = ? WHERE uuid = ?`,args:[t.text,$text.MD5(t.text),t.prev,t.next,t.uuid]});if(!e.result)throw e.error;this.needUpload()}updateText(t,e,i){if("string"!=typeof e)return;const s=this.sqlite.update({sql:`UPDATE ${t} SET text = ?, md5 = ? WHERE uuid = ?`,args:[i,$text.MD5(i),e]});if(!s.result)throw s.error;this.needUpload()}delete(t,e){this.getByUUID(e);const i=this.sqlite.update({sql:`DELETE FROM ${t} WHERE uuid = ?`,args:[e]});if(!i.result)throw i.error;this.needUpload()}isEmpty(){const t=this.sqlite.query("SELECT * FROM clips limit 1").result,e=this.sqlite.query("SELECT * FROM favorite limit 1").result;return t.next(),e.next(),t.isNull(0)&&e.isNull(0)}allImageFromDb(t=!0){const e=this.sqlite.query("\n SELECT a.* from\n (SELECT *, 'clips' AS section FROM clips WHERE text like \"@image=%\"\n UNION\n SELECT *, 'favorite' AS section FROM favorite WHERE text like \"@image=%\") a\n LEFT JOIN tag ON a.uuid = tag.uuid\n "),i=this.parse(e)?.map((t=>{if(t.image){const e=t.fsPath;return e.preview=e.preview.replaceAll(this.imagePath.preview,""),e.preview.startsWith("/")&&(e.preview=e.preview.substring(1)),e.original=e.original.replaceAll(this.imagePath.original,""),e.original.startsWith("/")&&(e.original=e.original.substring(1)),e}})),s=[],r=[];return t||i.forEach((t=>{s.push(t.original),r.push(t.preview)})),t?i:{original:s,preview:r}}localImagesFromFile(){return{original:this.kernel.fileStorage.readSync(this.kernel.storage.imagePath.original),preview:this.kernel.fileStorage.readSync(this.kernel.storage.imagePath.preview)}}setTag(t,e){const i=this.sqlite.update({sql:"INSERT OR REPLACE INTO tag (uuid, tag) values (?, ?)",args:[t,e]});if(!i.result)throw i.error;this.needUpload()}deleteTag(t){const e=this.sqlite.update({sql:"DELETE FROM tag WHERE uuid = ?",args:[t]});if(!e.result)throw e.error;this.needUpload()}}t.exports={Clip:r,Storage:n}})),parcelRequire.register("7GYtH",(function(t,e){var i=parcelRequire("gxpqj").FileStorage,s=parcelRequire("2VUvw");class r extends s{localSyncDataPath="/sync.json";webdavSyncDataPath="/sync.json";webdavDbPath="/CAIO.db";webdavImagePath="/image";get localDb(){return $data({path:this.kernel.fileStorage.filePath(this.kernel.storage.localDb)})}set localDb(t){this.kernel.fileStorage.writeSync(this.kernel.storage.localDb,t)}get localImagePath(){return this.kernel.fileStorage.filePath("/image")}async init(){await super.init(),await this.initImagePath(),this.sync()}async initImagePath(){if(!await this.webdav.exists(this.webdavImagePath)){await this.webdav.mkdir(this.webdavImagePath);["/image/original","/image/preview"].map((async t=>{await this.webdav.exists(t)||await this.webdav.mkdir(t)}))}}isNew(){return this.kernel.storage.isEmpty()}async webdavImages(){const t=(await this.webdav.ls(this.webdavImagePath,"infinity")).rootElement,e=t.firstChild({xPath:"//D:response/D:href"}).string,i=[],s=[];return t.children().map((t=>{const r=t.firstChild({tag:"href"})?.string?.replaceAll(e,"");r.endsWith("/")||(r.startsWith("original")?i.push(r.substring(9)):r.startsWith("preview")&&s.push(r.substring(8)))})),{original:i,preview:s}}async syncImages(){const t=await this.webdavImages(),e=this.kernel.storage.allImageFromDb(!1),s=this.kernel.storage.localImagesFromFile();Object.keys(s).map((t=>{s[t].forEach((async s=>{if(!e[t].includes(s)){const e=i.join(this.kernel.storage.imagePath[t],s);this.kernel.fileStorage.delete(e),this.kernel.print(`Local image deleted: ${e}`)}}))})),Object.keys(e).map((s=>{e[s].forEach((async e=>{const r=i.join(this.webdavImagePath,s,e),n=i.join(this.kernel.storage.imagePath[s],e);if(t[s].includes(e)&&!this.kernel.fileStorage.exists(n)){const t=await this.webdav.get(r);this.kernel.fileStorage.writeSync(n,t.rawData),this.kernel.print(`WebDAV image downloaded: ${n}`)}else if(!t[s].includes(e)){const t=this.kernel.fileStorage.readSync(n);await this.webdav.put(r,t),this.kernel.print(`WebDAV image uploaded: ${r}`)}}))})),Object.keys(t).map((s=>{t[s].forEach((async t=>{if(!e[s].includes(t)){const e=i.join(this.webdavImagePath,s,t);await this.webdav.delete(e),this.kernel.print(`WebDAV image deleted: ${e}`)}}))}))}async pull(){this.webdav.clearNSURLCache();let t=await this.webdav.get(this.webdavDbPath);this.localDb=t.rawData,await this.downloadSyncData(),this.kernel.storage.init(),await this.syncImages(),this.kernel.print("clip webdav sync: pulled")}async push(){await this.webdav.put(this.webdavDbPath,this.localDb),await this.uploadSyncData(),await this.syncImages(),this.kernel.print("clip webdav sync: pushed")}notify(t){$app.notify({name:"clipSyncStatus",object:t})}async#$(){let t=!1;try{const e=await this.nextSyncStep();if(this.kernel.print(`clip nextSyncStep: ${s.stepName[e]}`),e===s.step.needPush||e===s.step.init)await this.push();else if(e===s.step.needPull)await this.pull(),t=!0;else{if(e!==s.step.conflict)return void this.notify({status:s.status.nochange});await this.conflict($l10n("CLIPS"))===r.conflictKeep.webdav&&(t=!0)}}catch(t){throw this.notify({status:s.status.fail,error:t}),this.kernel.error("clip sync error"),this.kernel.error(t),t}finally{this.notify({status:s.status.success,updateList:t})}}sync(){this.notify({status:s.status.syncing,animate:!0}),this.syncTimer&&this.syncTimer.cancel(),this.syncTimer=$delay(.5,(()=>{this.#$()}))}needUpload(){this.notify({status:s.status.syncing}),this.uploadTimer&&this.uploadTimer.cancel(),this.uploadTimer=$delay(.5,(()=>{this.updateLocalTimestamp(),this.#$()}))}}t.exports=r})),parcelRequire.register("2VUvw",(function(t,e){var i=parcelRequire("gxpqj").WebDAV;class s{static step={init:-1,stay:0,needPush:2,needPull:3,conflict:4};static stepName=(()=>{const t={};return Object.keys(s.step).map((e=>{const i=s.step[e];t[i]=String(e)})),t})();static status={syncing:0,success:1,nochange:2,fail:3};static conflictKeep={local:0,webdav:1,cancel:2};static initLocalTimestamp=0;webdav;kernel;localSyncDataPath;webdavSyncDataPath;constructor({host:t,user:e,password:s,basepath:r,kernel:n}={}){this.kernel=n,this.webdav=new i({host:t,user:e,password:s,basepath:r}),this.webdav.namespace="JSBox.CAIO"}get mustLocalSyncDataPath(){if(!this.localSyncDataPath)throw new Error("localSyncDataPath not set");return this.localSyncDataPath}get mustWebdavSyncDataPath(){if(!this.webdavSyncDataPath)throw new Error("webdavSyncDataPath not set");return this.webdavSyncDataPath}get localSyncData(){return this.kernel.fileStorage.exists(this.mustLocalSyncDataPath)||(this.localSyncData={timestamp:s.initLocalTimestamp}),this.kernel.fileStorage.readSync(this.mustLocalSyncDataPath)}set localSyncData(t){this.kernel.fileStorage.writeSync(this.mustLocalSyncDataPath,$data({string:JSON.stringify(t)}))}get localTimestamp(){return Number(JSON.parse(this.localSyncData.string).timestamp)}set localTimestamp(t){this.localSyncData=Object.assign(this.localSyncData,{timestamp:t})}async init(t=this.webdav.basepath){const e=new i({host:this.webdav.host,user:this.webdav.user,password:this.webdav.password,basepath:t});if(!await e.exists("/"))try{await e.mkdir("/")}catch(e){if(409===e.code)return await this.init(t.substring(0,t.lastIndexOf("/"))),void await this.init(t);throw e}}isNew(){return!1}async webdavSyncData(){this.webdav.clearNSURLCache();let t=(await this.webdav.get(this.mustWebdavSyncDataPath)).data;return"string"==typeof t&&(t=JSON.parse(t)),t}async webdavTimestamp(){try{let t=await this.webdavSyncData();return Number(t.timestamp)}catch(t){if(404===t.code)return s.step.init;throw t}}updateLocalTimestamp(){this.localTimestamp!==s.initLocalTimestamp&&(this.localTimestamp=Date.now())}async uploadSyncData(){this.localTimestamp===s.initLocalTimestamp&&(this.localTimestamp=Date.now()),await this.webdav.put(this.mustWebdavSyncDataPath,this.localSyncData)}async downloadSyncData(){this.localSyncData=await this.webdavSyncData()}async nextSyncStep(){const t=this.localTimestamp,e=await this.webdavTimestamp();return e===s.step.init?s.step.init:e===s.initLocalTimestamp?(this.localTimestamp=Date.now(),await this.push(),s.step.stay):t>e?s.step.needPush:t===e?s.step.stay:t{this.updateList(!0),$delay(.5,(()=>{this.readClipboard()}))},clipSyncStatus:t=>{const e=$(this.listId);t.status===w.status.success?(t.updateList&&this.updateList(!0),e&&e.endRefreshing()):t.status===w.status.syncing&&t.animate&&e&&e.beginRefreshing()}})}listReady(){this.updateList(),r.isTaio||($delay(.5,(()=>{if($context.query.copy){const t=$context.query.copy;this.setCopied(t),$ui.success($l10n("COPIED"))}else $context.query.add?this.getAddTextView():$context.query.actions&&(this.kernel.isUseJsboxNav?this.kernel.actionManager.present():this.kernel.tabBarController.switchPageTo("actions"))})),$delay(.5,(()=>{this.readClipboard()})),this.appListen())}updateList(t=!1){t&&this.setNeedReload(),$(this.listId).data=this.clips.map((t=>this.lineData(t,this.copied.uuid===t.uuid))),this.updateListBackground()}updateListBackground(){const t=$(this.listId+"-empty-background");t&&(t.hidden=this.clips.length>0)}updateCopied(t=null){const e=this.copied?.uuid;$delay(.3,(()=>{try{const i=$(this.listId),s=i.cell($indexPath(0,this.getIndexByUUID(e)));s&&(s.get("copied").hidden=!0),t&&(i.cell($indexPath(0,this.getIndexByUUID(t.uuid))).get("copied").hidden=!1)}catch(t){this.kernel.error("set copied error"),this.kernel.error(t)}})),t?Object.assign(this.copied,t):this.copied={},this.kernel.print(`this.copied: ${JSON.stringify(this.copied,null,2)}`),$cache.set("clips.copied",this.copied)}setCopied(t){if(!t||t===this.copied.uuid&&this.tabIndex===this.copied?.tabIndex)return;let e={};this.copied.uuid!==t&&(e=this.getClip(t)??{}),e.tabIndex=this.tabIndex,this.updateCopied(e),this.setClipboardText(e.text)}clearCopied(){const t=$(this.listId).cell($indexPath(0,this.getIndexByUUID(this.copied.uuid)));t&&(t.get("copied").hidden=!0),this.updateCopied(null)}async readClipboard(t=!1){if(t||this.kernel.setting.get("clipboard.autoSave")){if(this.kernel.print("read clipboard"),!t&&!this.isChanged)return;if($clipboard.images?.length>0)return t?(await $wait(.1),void $clipboard.images.forEach((t=>{this.add(t)}))):void 0;const e=$clipboard.text;if(!e||""===e)return void this.clearCopied();if(this.getClip(this.copied?.uuid)?.text===e)return void(t&&$ui.toast($l10n("CLIPBOARD_NO_CHANGE")));if(this.exists(e)){const t=this.kernel.storage.getByMD5($text.MD5(e));this.switchTab(this.tabItemsMap[t.section],!0),this.setCopied(t.uuid)}else{this.switchTab(1,!0);const t=this.add(e);this.setCopied(t.uuid)}}}add(t){try{const e=super.addItem(t);return this.updateListBackground(),$(this.listId).insert({indexPath:$indexPath(0,0),value:this.lineData(e)}),e}catch(t){$ui.alert(t)}}delete(t){try{super.deleteItem(t),this.copied.uuid===t&&(this.updateCopied(null),$clipboard.clear()),this.updateListBackground()}catch(t){$ui.alert(t)}}update(t,e){try{return super.updateItem(t,e),this.updateList(),e===this.copied.uuid&&this.setClipboardText(t),!0}catch(t){return $ui.alert(t),!1}}move(t,e,i=!0){if(t!==e)try{if(super.moveItem(t,e),!i)return;const s=$(this.listId);t{i.text?$share.sheet(i.text):$ui.warning($l10n("NONE"))}}];if(this.kernel.isUseJsboxNav)i.uikitPush(t,(t=>e(t)),s);else{const r=i.getNavigationView(t,(t=>e(t)),s);this.viewController.push(r)}}getAddTextView(){this.edit("",(t=>{""!==t&&this.add(t)}))}menuItems(t=!1){const e=[{inline:!0,items:[{title:$l10n("TAG"),symbol:"tag",handler:(t,e)=>{const i=this.getByIndex(e);$input.text({placeholder:$l10n("ADD_TAG"),text:i.tag,handler:t=>{(t=t.trim()).length>0?this.kernel.storage.setTag(i.uuid,t):this.kernel.storage.deleteTag(i.uuid),this.updateList(!0)}})}}]},{inline:!0,items:[{title:$l10n("SHARE"),symbol:"square.and.arrow.up",handler:(t,e)=>{const i=this.getByIndex(e);$share.sheet(i.image?i.imageOriginal:i.text)}},{title:$l10n("COPY"),symbol:"square.on.square",handler:(t,e)=>this.copy(this.getByIndex(e).uuid)},{title:$l10n("DELETE"),symbol:"trash",destructive:!0,items:[{title:$l10n("CONFIRM"),destructive:!0,handler:(t,e)=>{t.delete(e),this.delete(this.getByIndex(e).uuid),$delay(.25,(()=>t.reload()))}}]}]}];if(t)return e;const i=t=>{const e=this.kernel.actionManager.getActionHandler(t.type,t.dir);return t.handler=(t,i)=>{const s=this.getByIndex(i),r=new m({env:f.clipboard,text:s.text,section:s.section,uuid:s.uuid});e(r)},t.title=t.name,t.symbol=t.icon,t},s=this.kernel.actionManager.getActions("clipboard"),r={inline:!0,items:s.slice(0,this.menuItemActionMaxCount).map(i)};return s.length>this.menuItemActionMaxCount&&r.items.push({title:$l10n("MORE_ACTIONS"),symbol:"square.grid.2x2",items:s.slice(this.menuItemActionMaxCount).map(i)}),[r,...e]}switchTab(t,e=!1){this.tabIndex=t,this.updateList(),e&&($(this.listId+"-tab").index=this.tabIndex)}tabView(){return{type:"tab",props:{id:this.listId+"-tab",items:this.tabItems,index:this.tabIndex,dynamicWidth:!0},events:{changed:t=>this.switchTab(t.index)},layout:(t,e)=>{t.centerY.equalTo(e.super),e.prev?t.left.equalTo(e.prev.right).offset(this.tabLeftMargin):t.left.inset(this.tabLeftMargin)}}}lineData(t,e=!1){const i={hidden:!0},s={text:""},r={hidden:!t?.hasTag};return t.image?(i.src=t.imagePath.preview,i.hidden=!1):(t.textStyledText?s.styledText=t.textStyledText:s.text=t.text,t.tagStyledText?r.styledText=t.tagStyledText:r.text=t.tag),{copied:{hidden:!e},image:i,tag:r,content:s}}listTemplate(){return{props:{bgcolor:$color("clear")},views:[{type:"view",views:[{type:"view",props:{id:"copied",circular:this.copiedIndicatorSize,hidden:!0,bgcolor:$color("green")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.size.equalTo(this.copiedIndicatorSize),t.left.equalTo(e.super).inset(this.horizontalMargin/2-this.copiedIndicatorSize/2)}},{type:"label",props:{id:"content",lines:this.#v?1:2,font:$font(this.fontSize)},layout:(t,e)=>{t.left.right.equalTo(e.super).inset(this.horizontalMargin),t.top.equalTo(this.verticalMargin)}},{type:"label",props:{id:"tag",lines:1,color:this.tagColor,autoFontSize:!0,align:$align.leading},layout:(t,e)=>{t.bottom.equalTo(e.super),t.left.right.equalTo(e.prev),t.height.equalTo(this.tagHeight)}}],layout:$layout.fill},{type:"image",props:{id:"image",hidden:!0},layout:$layout.fill}]}}getEmptyBackground(t=this.listId){return{type:"label",props:{id:t+"-empty-background",color:$color("secondaryText"),hidden:this.clips.length>0,text:$l10n("NONE"),align:$align.center},layout:$layout.center}}getListView(t=this.listId,e=[]){const i={type:"list",props:{id:t,associateWithNavigationBar:!1,bgcolor:$color("clear"),separatorInset:$insets(0,this.horizontalMargin,0,0),menu:{items:this.menuItems()},data:e,template:this.listTemplate(),actions:[{title:$l10n("COPY"),color:$color("systemLink"),handler:(t,e)=>this.copy(this.getByIndex(e).uuid)},{title:$l10n("FAVORITE"),color:$color("orange"),handler:(t,e)=>this.favorite(e.row)},{title:"delete",handler:(t,e)=>{this.delete(this.getByIndex(e).uuid),$delay(.25,(()=>t.reload()))}}]},layout:$layout.fill,events:{ready:()=>this.listReady(),rowHeight:(t,e)=>{const i=this.getByIndex(e),s=i?.hasTag?this.tagHeight:this.verticalMargin,r=i.image?this.imageContentHeight:this.getContentHeight(i.text);return this.verticalMargin+r+s},didSelect:(t,e)=>{const i=this.getByIndex(e);i.image?a.quickLookImage(i.imageOriginal):this.edit(i.text,(t=>{i.md5!==$text.MD5(t)&&this.update(t,i.uuid)}))},pulled:t=>{this.updateList(!0),this.kernel.storage.sync(),this.kernel.setting.get("webdav.status")||$delay(.5,(()=>t.endRefreshing()))}}};return s.createFromViews([i,this.getEmptyBackground(t)])}getNavigationView(){const t=new a,e=e=>{const{keyword:i,result:s,isTagKeyword:r}=e,n=this.getListView(this.listId+"-search-result",s.map((t=>{const e=r?t.tag:t.text;let s=[];return i.forEach((t=>{let i=e.indexOf(t);for(;i>-1;)s.push({range:$range(i,t.length),color:$color("red")}),i=e.indexOf(t,i+1)})),t.styledText={},r?t.tagStyledText={color:this.tagColor,text:e,styles:s}:t.textStyledText={text:e,styles:s},this.lineData(t,!1)})));return delete n.views[0].events.pulled,n.views[0].events.rowHeight=(t,e)=>{const i=s[e.row],r=i?.hasTag?this.tagHeight:this.verticalMargin,n=i.image?this.imageContentHeight:this.getContentHeight(i.text);return this.verticalMargin+n+r},n.views[0].events.didSelect=(e,i)=>{const r=s[i.row];r.image?a.quickLookImage(r.imageOriginal):(t.dismiss(),this.edit(r.text,(t=>{r.md5!==$text.MD5(t)&&this.update(t,r.uuid)})))},n},i=new u(this.kernel);i.setCallback((s=>{t.setView(e(s)).addNavBar({title:$l10n("SEARCH_RESULT"),popButton:{title:$l10n("DONE"),tapped:()=>i.dismiss()}}).init().present()}));const s=this.tabView();s.type="menu",s.layout=(t,e)=>{t.top.left.right.equalTo(e.super),t.height.equalTo(this.tabHeight)};const r=this.getListView();r.views.unshift(s),r.views[1].layout=(t,e)=>{t.bottom.left.right.equalTo(e.super),t.top.equalTo(e.prev.bottom)},r.views.push(i.getSearchHistoryView());const o=(new l).navigationBarTitle($l10n("CLIPS")).setView(r);return o.navigationBarItems.setTitleView(i.getSearchBarView()).pinTitleView().setRightButtons([{symbol:"plus.circle",tapped:()=>this.getAddTextView()}]).setLeftButtons([{title:$l10n("EDIT"),tapped:()=>{new g(this).presentSheet()}},{symbol:"square.and.arrow.down.on.square",tapped:async t=>{t.start();try{await this.readClipboard(!0),t.done()}catch(e){t.cancel(),this.kernel.error(e)}}}]),o.navigationBar.setBackgroundColor(n.primaryViewBackgroundColor).setLargeTitleDisplayMode(h.largeTitleDisplayModeNever),this.kernel.isUseJsboxNav&&o.navigationBar.removeTopSafeArea(),o}}})),parcelRequire.register("f0nX9",(function(t,e){var i=parcelRequire("gxpqj"),s=i.UIKit,r=i.NavigationBar,n=i.NavigationView,a=i.Sheet,o=parcelRequire("eSp9Z"),l=o.ActionEnv,h=o.ActionData;t.exports=class{#f="";constructor(t){this.kernel=t,this.id="editor",this.originalContent=void 0}set text(t=""){void 0===this.originalContent&&(this.originalContent=t),this.#f=t}get text(){return this.#f}getActionButton(){return{symbol:"bolt.circle",tapped:(t,e)=>{e&&(t=e);const i=$(this.id).selectedRange,s=new h({env:l.editor,editor:{setContent:t=>this.setContent(t)},text:i.length>0?this.text.slice(i.location,i.location+i.length):this.text,selectedRange:i}),r=$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actionManager.getActionListView((t=>{r.dismiss(),$delay(.5,(()=>t(s)))}))]})}}}setContent(t){this.text=t,$(this.id).text=t}getView(t="text"){return{type:t,layout:$layout.fill,props:{id:this.id,lineNumbers:this.kernel.setting.get("editor.code.lineNumbers"),theme:this.kernel.setting.get($device.isDarkMode?"editor.code.darkTheme":"editor.code.lightTheme"),text:this.text,insets:$insets(15,15,"text"===t?this.kernel.setting.get("editor.text.insets"):15,15)},events:{ready:t=>{""===this.text&&$delay(.5,(()=>t.focus()))},didChange:t=>{this.text=t.text}}}}pageSheet(t="",e,i,s=[],r="text"){this.text=t,s.unshift(this.getActionButton());const n=new a;n.setView(this.getView(r)).addNavBar({title:i,popButton:{title:$l10n("DONE"),tapped:()=>e(this.text)},rightButtons:s}).init(),n.navigationView.navigationBar.contentViewHeightOffset=0,n.present()}uikitPush(t="",e,i=[],r="text"){this.text=t,i.unshift(this.getActionButton()),s.push({title:"",navButtons:i.map((t=>(t.handler=t.tapped,t.tapped=void 0,t))),views:[this.getView(r)],disappeared:()=>e(this.text)})}getNavigationView(t="",e,i=[],s="text"){this.text=t,i.unshift(this.getActionButton());const a=new n;return a.navigationBar.contentViewHeightOffset=0,a.navigationBar.setLargeTitleDisplayMode(r.largeTitleDisplayModeNever),a.navigationBarItems.setRightButtons(i),a.setView(this.getView(s)).navigationBarTitle(""),a.setEvent("onPop",(()=>e(this.text))),a}}})),parcelRequire.register("eSp9Z",(function(t,e){var i=parcelRequire("gxpqj"),s=i.L10n,r=i.Sheet,n=parcelRequire("jVlss").SecureFunction;class a{static build=-1;static today=0;static editor=1;static clipboard=2;static action=3;static keyboard=4}class o{env;args;text;originalContent;section;uuid;selectedRange;textBeforeInput;textAfterInput;editor;constructor({env:t,args:e,text:i,section:s=null,uuid:r=null,selectedRange:n=null,textBeforeInput:a=null,textAfterInput:o=null,editor:l=null}={}){this.env=t,this.args=e,this.text=i,this.originalContent=i,this.section=s,this.uuid=r,this.selectedRange=n,this.textBeforeInput=a,this.textAfterInput=o,this.editor=l}}t.exports={ActionEnv:a,ActionData:o,Action:class{#S;secureFunction;constructor(t,e,i){this.#S=t,this.config=e,this.secureFunction=new n(this.#S,this.config),i.env===a.build&&((i=this.preview()).env=a.build),Object.assign(this,i),this.originalContent=String(this.text);const r=this.l10n();Object.keys(r).forEach((t=>{s.add(t,r[t])}))}preview(){return new o({env:a.build})}l10n(){return{}}pageSheet({view:t,title:e="",done:i,doneText:s=$l10n("DONE"),rightButtons:n=[]}){(new r).setView(t).addNavBar({title:e,popButton:{title:s,tapped:()=>{i&&i()}},rightButtons:n}).init().present()}quickLookImage(t){r.quickLookImage(t)}getAllClips(){return{favorite:this.#S.storage.all("favorite").map((t=>t.text)),clips:this.#S.storage.all("clips").map((t=>t.text))}}async clearAllClips(){if(0!==(await $ui.alert({title:$l10n("DELETE_DATA"),message:$l10n("DELETE_TABLE").replaceAll("${table}",$l10n("CLIPS")),actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive},{title:$l10n("CANCEL")}]})).index)return!1;try{return this.#S.storage.deleteTable("clips"),!0}catch(t){throw this.#S.error(t),t}}setContent(t){this.text=t,this.env===a.editor?this.editor.setContent(t):this.env===a.clipboard&&(this.#S.storage.updateText(this.section,this.uuid,t),this.#S.clips.updateList(!0))}getAction(t,e,i){return this.#S.actionManager.getAction(t,e,i)}async runAction(t,e){const i=this.getAction(t,e);return await i.do()}async request(t,e,i,s){return this.secureFunction.http.request({url:t,method:e,body:i,header:s,timeout:3})}getUrls(){return(this.text??"").match(/(https?:\/\/)([\da-z\.-]+)\.([a-z\.]{2,6})([:0-9])*([\/\w\#\.\-\?\=\&])*\s?/gi)??[]}}}})),parcelRequire.register("jVlss",(function(t,e){class i{#S;#A;notAllowed='"The parameter or method is not allowed in Action."';constructor(t,e){if(this.#S=t,this.#A=JSON.parse(JSON.stringify(e)),!this.#A?.name||"undefined"===this.#A?.name)throw new Error("Cannot get Action name.")}get name(){return this.#A.name}set name(t){const e=$l10n("ACTION_RESET_NAME_WARNING").replaceAll("${name}",this.name).replaceAll("${to_name}",t);throw $ui.alert({title:$l10n("ACTION_SAFETY_WARNING"),message:e}),new Error(e)}print(t){this.#S.print(t)}error(t){this.#S.error(t)}}class s extends i{rootPath=this.notAllowed;extensions=this.notAllowed;read(){throw new Error(this.notAllowed)}async download(){throw new Error(this.notAllowed)}write(){throw new Error(this.notAllowed)}delete(){throw new Error(this.notAllowed)}list(){throw new Error(this.notAllowed)}copy(){throw new Error(this.notAllowed)}move(){throw new Error(this.notAllowed)}mkdir(){throw new Error(this.notAllowed)}exists(){throw new Error(this.notAllowed)}isDirectory(){throw new Error(this.notAllowed)}merge(){throw new Error(this.notAllowed)}absolutePath(){throw new Error(this.notAllowed)}}class r extends i{#I="ActionHttpPermission";get#C(){const t=$cache.get(this.#I);return t||(this.#C={},{})}set#C(t={}){return $cache.set(this.#I,t)}async#x(){if(0===(await $ui.alert({title:$l10n("ACTION_PERMISSION_REQUEST"),message:$l10n("ACTION_NETWORK_PERMISSION_MESSAGE").replaceAll("${name}",this.name),actions:[{title:$l10n("OK"),style:$alertActionType.destructive},{title:$l10n("CANCEL")}]})).index){const t=this.#C;return t[this.name]=!0,this.#C=t,!0}return!1}async#k(){const t=this.#C;return"boolean"==typeof t[this.name]?t[this.name]:!!await this.#x()}async request(t={}){try{if(!await this.#k())throw new Error("No network permission.");this.print(`sending request [${t.method}]: ${t.url}`);const e=await $http.request(Object.assign({timeout:3},t));if("function"==typeof t?.handler&&t?.handler(e),e.error)throw e.error;if(e?.response?.statusCode>=400){let t=e.data;throw"object"==typeof t&&(t=JSON.stringify(t)),new Error("http error: ["+e.response.statusCode+"] "+t)}return e}catch(t){throw t.code&&(t=new Error("network error: ["+t.code+"] "+t.localizedDescription)),this.error(`Action request error: ${this.name}`),this.error(t),t}}async get(t){return"string"==typeof t&&(t={url:t}),t.method="GET",await this.request(t)}async post(t){return"string"==typeof t&&(t={url:t}),t.method="POST",await this.request(t)}async download(){throw new Error(this.notAllowed)}async upload(){throw new Error(this.notAllowed)}async startServer(){throw new Error(this.notAllowed)}async stopServer(){throw new Error(this.notAllowed)}async shorten(t){return await $http.shorten(t)}async lengthen(t){return await $http.lengthen(t)}}t.exports={SecureFunction:class extends i{constructor(...t){super(...t),this.file=new s(...t),this.http=new r(...t)}addin(){throw new Error(this.notAllowed)}},SecureScript:class{script;sf="this.secureFunction";constructor(t){this.script=t}#B(t,e){this.script=this.script.replaceAll(t,e)}replaceEval(){this.#B(/\$addin\.*[a-zA-Z0-9\[\]'"`]+/gi,`${this.sf}.addin()`),this.#B("eval",`${this.sf}.addin()`)}replaceFile(){this.#B("$file",`${this.sf}.file`)}replaceHttp(){this.#B("$http",`${this.sf}.http`)}secure(){return this.replaceEval(),this.replaceFile(),this.replaceHttp(),this.script}}}})),parcelRequire.register("ZnuTV",(function(t,e){var i=parcelRequire("gxpqj").UIKit,s=parcelRequire("jEwwi").Clip;t.exports=class{kernel;pasteboard=$objc("UIPasteboard").$generalPasteboard();#D=[];clipsUUIDMap={};clipsMD5Map={};tabItems=[$l10n("FAVORITE"),$l10n("CLIPS")];tabItemsIndex=["favorite","clips"];tabItemsMap=function(t){const e={};return t.forEach(((t,i)=>{e[t]=i})),e}(this.tabItemsIndex);constructor(t){this.kernel=t}get tabIndex(){return $cache.get("caio.main.tab.index")??0}set tabIndex(t){$cache.set("caio.main.tab.index",t)}get table(){return this.tabItemsIndex[this.tabIndex]}get tableL10n(){return this.tabItems[this.tabIndex]}get allClips(){return this.tabItemsIndex.forEach(((t,e)=>{this.#D[e]||(this.#D[e]=this.#L(t),this.kernel.print(`init clips: ${t}`))})),this.#D}get clips(){return this.#D[this.tabIndex]||(this.#D[this.tabIndex]=this.#L(this.table),this.kernel.print(`init clips: ${this.table}`)),this.#D[this.tabIndex]}get isChanged(){const t=this.pasteboard.$changeCount(),e=$cache.get("clipboard.changeCount");return $cache.set("clipboard.changeCount",t),e!==t}#L(t){try{const e=this.kernel.storage.all(t),i=this.kernel.storage.sort(e,this.kernel.setting.get("clipboard.maxItemLength"));return i.forEach(((e,i)=>{this.clipsMD5Map[e.md5]=!0,this.clipsUUIDMap[e.uuid]={tab:t,index:i}})),this.#R(i)}catch(t){this.kernel.error(t),this.rebuildDatabase()}}#R(t){return new Proxy(t??[],{set:(t,e,i)=>Reflect.set(t,e,i),get:(t,e)=>Reflect.get(t,e)})}rebuildDatabase(){$ui.alert({title:$l10n("REBUILD_DATABASE"),message:$l10n("CLIPS_STRUCTURE_ERROR"),actions:[{title:$l10n("OK"),handler:()=>{const t=i.loading();t.start(),this.kernel.storage.rebuild(),t.end(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n("CANCEL")}]})}setNeedReload(t){t?this.#D[this.tabItemsMap[t]]=null:this.#D=[],this.kernel.print(`set need reload: ${t??"all"}`)}getClipCopy(t,e={}){if(!t.uuid)return t;const i=new s(t);return i.fileStorage=t.fileStorage,Object.assign(i,e),i}getIndexByUUID(t){return this.clipsUUIDMap[t]?.index??-1}getClip(t){const e=this.clips[this.getIndexByUUID(t)];return e||this.kernel.storage.getByUUID(t)}exists(t){return Boolean(this.clipsMD5Map[$text.MD5(t)])}setClipboardText(t){this.kernel.setting.get("clipboard.universal")?$clipboard.text=t:$clipboard.setTextLocalOnly(t)}addItem(t){const e=new s({uuid:$text.uuid,section:this.table,md5:null,prev:null,next:this.clips[0]?this.clips[0].uuid:null});if("string"==typeof t){if(""===t.trim())return;e.text=t}else{if("object"!=typeof t)return;e.fileStorage=this.kernel.fileStorage,e.text=this.kernel.storage.saveImage(t)}try{return this.kernel.storage.beginTransaction(),this.kernel.storage.insert(e),e.next&&(this.clips[0].prev=e.uuid,this.kernel.storage.update(this.clips[0])),this.kernel.storage.commit(),this.setNeedReload(this.table),e}catch(t){throw this.kernel.storage.rollback(),this.kernel.error(t),t}}getRecycleBin(){return $cache.get("caio.recycleBin")??[]}moveToRecycleBin(t){const e=this.getRecycleBin();e.push({text:t.text,tag:t.tag}),$cache.set("caio.recycleBin",e)}removeFromRecycleBin(t){const e=this.getRecycleBin();e.splice(t,1),$cache.set("caio.recycleBin",e)}deleteItem(t,e=!0){const i=this.getIndexByUUID(t),s=this.clips[i],r=this.clips[i-1],n=this.clips[i+1];try{this.kernel.storage.beginTransaction(),this.kernel.storage.delete(this.table,t),r&&(r.next=s.next,this.kernel.storage.update(r)),n&&(n.prev=s.prev,this.kernel.storage.update(n)),this.kernel.storage.commit(),e&&(this.kernel.storage.deleteTag(t),s?.image?(this.kernel.fileStorage.delete(s.fsPath.original),this.kernel.fileStorage.delete(s.fsPath.preview)):this.moveToRecycleBin(s)),this.setNeedReload(this.table)}catch(t){throw this.kernel.storage.rollback(),this.kernel.error(t),t}}updateItem(t,e){const i=$text.MD5(t),s=this.getClip(e);delete this.clipsMD5Map[s.md5],this.clipsMD5Map[i]=!0;const r=s.text;Object.assign(s,{text:t,md5:i});try{this.kernel.storage.updateText(this.table,s.uuid,t),this.kernel.print(`data changed at index [${this.getIndexByUUID(e)}]\n${r}\n↓\n${t}`)}catch(t){throw this.kernel.error(t),t}}moveItem(t,e){if(t!==e){t{};onBegin=()=>{};onDismiss=()=>{};constructor(t){this.kernel=t,this.searchBar=new r,this.searchBarId=this.searchBar.id+"-input"}get searchHistoryView(){return{hide:()=>$(this.listId+"-history").hidden=!0,show:()=>$(this.listId+"-history").hidden=!1}}get searchHistory(){return[{title:$l10n("SEARCH_HISTORY"),rows:$cache.get("caio.search.history")?.reverse()??[]}]}getAccessoryView(){return s.blurBox({height:50},[{type:"button",props:{bgcolor:$color("clear"),tintColor:$color("primaryText"),symbol:"xmark.circle"},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(e.super),t.width.equalTo(e.super.height)},events:{tapped:()=>this.dismiss()}},{type:"button",props:{bgcolor:$color("clear"),tintColor:$color("primaryText"),symbol:"keyboard.chevron.compact.down"},layout:(t,e)=>{t.right.equalTo(e.prev.left),t.height.equalTo(e.super),t.width.equalTo(e.super.height)},events:{tapped:()=>$(this.searchBarId).blur()}}])}getSearchHistoryView(){return{type:"list",props:{id:this.listId+"-history",hidden:!0,stickyHeader:!0,data:this.searchHistory,separatorInset:$insets(0,13,0,0),actions:[{title:$l10n("DELETE"),handler:(t,e)=>{const i=t.data;this.updateSearchHistory(i[0].rows.reverse())}}]},events:{didSelect:(t,e,i)=>{this.searchAction(i),$(this.searchBarId).text=i}},layout:$layout.fill}}setCallback(t){this.callback=t}setOnBegin(t){this.onBegin=t}setOnDismiss(t){this.onDismiss=t}begin(){this.searchHistoryView.show(),this.onBegin()}dismiss(){this.searchBar.cancel()}async searchAction(t){try{if(""!==t){let e,i=t.startsWith("#");e=i?this.kernel.storage.searchByTag(t.substring(1)):await this.kernel.storage.search(t);const{result:s,keyword:r}=e;s&&s.length>0?($(this.searchBarId).blur(),this.callback({keyword:r,result:s,isTagKeyword:i})):$ui.toast($l10n("NO_SEARCH_RESULT")),this.pushSearchHistory(t)}}catch(t){throw t}}pushSearchHistory(t){let e=$cache.get("caio.search.history")??[];-1===e.indexOf(t)&&(e.push(t),e.length>20&&(e=e.slice(-20)),$cache.set("caio.search.history",e),$(this.listId+"-history").data=this.searchHistory)}updateSearchHistory(t=[]){$cache.set("caio.search.history",t)}getSearchBarView(){return this.searchBar.controller.setEvent("onReturn",(t=>{""!==t?this.searchAction(t):this.searchHistoryView.show()})),this.searchBar.controller.setEvent("onChange",(t=>{""===t&&this.searchHistoryView.show()})),this.searchBar.controller.setEvent("onBeginEditing",(t=>{""===t&&this.begin()})),this.searchBar.controller.setEvent("onCancel",(()=>{this.searchHistoryView.hide(),this.onDismiss()})),this.searchBar.setAccessoryView(this.getAccessoryView()),this.searchBar}}})),parcelRequire.register("9LqeL",(function(t,e){var i=parcelRequire("gxpqj"),s=i.View,r=i.UIKit,n=i.Sheet;class a{static symbol={selected:"checkmark.circle.fill",unselected:"circle"};#E={};listId="clips-list-editor";reorder={};toolBarHeight=44;containerMargin=30;#N=void 0;#O={};constructor(t){this.clipsInstance=t,this.kernel=t.kernel}get editorSelectedIsEmpty(){let t=!0;const e=this.editorSelected;for(const i of Object.keys(e))if(e[i]){t=!1;break}return t}get editorSelectedIsFull(){let t=0,e=0;const i=this.editorSelected;for(const s of Object.keys(i))++e,i[s]&&++t;return e===t}get editorSelected(){return void 0===this.#N&&(Array(this.clipsInstance.clips.length).fill(0).map(((t,e)=>this.#O[e]=!1)),this.#N=new Proxy(this.#O,{set:(t,e,i,s)=>(Reflect.set(t,e,i,s),e=Number(e),this.updateToolBar(),$(this.listId).data=this.clipsInstance.clips.map(((e,i)=>{const s=this.lineData(e);return s.checkmark={symbol:t[i]?a.symbol.selected:a.symbol.unselected},s})),!0)})),this.#N}getTextHeight(t){return this.#E[t]||(this.#E[t]=Math.min($text.sizeThatFits({text:t,width:r.windowSize.width-2*(this.clipsInstance.horizontalMargin+this.containerMargin),font:$font(this.clipsInstance.fontSize)}).height,2*this.clipsInstance.singleLineContentHeight)),this.#E[t]}selectAll(){const t=this.editorSelectedIsFull;this.clipsInstance.clips.forEach(((e,i)=>{this.editorSelected[i]=!t}))}deleteSelected(){r.deleteConfirm($l10n("DELETE_CONFIRM_MSG"),(()=>{const t=Object.keys(this.editorSelected);if(t.filter((t=>this.editorSelected[t])).length===this.clipsInstance.clips.length)return void this.deleteTable();const e=$(this.listId),i=$(this.clipsInstance.listId);t.reverse().forEach((t=>{if(this.editorSelected[t]){t=Number(t);const s=this.clipsInstance.clips[t];this.kernel.print(`delete selected: [${t}]\n${s.text}`),this.clipsInstance.delete(s.uuid),i.delete(t),e.delete(t)}})),this.#N=void 0,this.updateToolBar()}))}deleteTable(){try{this.kernel.storage.deleteTable(this.clipsInstance.table),this.sheet.dismiss(),this.clipsInstance.updateList(!0)}catch(t){this.kernel.error(t),$ui.error(t)}}updateToolBar(){const t=this.editorSelectedIsEmpty,e=$(this.listId+"-select-button"),i=$(this.listId+"-delete-button");e.title=this.editorSelectedIsFull?$l10n("DESELECT_ALL"):$l10n("SELECT_ALL"),i.hidden=t,$(this.listId).reorder=t}getToolBarView(){return r.blurBox({},[r.separatorLine(),{type:"view",views:[{type:"button",props:{id:this.listId+"-select-button",title:$l10n("SELECT_ALL"),titleColor:$color("tint"),bgcolor:$color("clear")},layout:(t,e)=>{t.left.inset(this.clipsInstance.horizontalMargin),t.centerY.equalTo(e.super)},events:{tapped:()=>this.selectAll()}},{type:"button",props:{id:this.listId+"-delete-button",symbol:"trash",hidden:!0,tintColor:$color("red"),bgcolor:$color("clear")},layout:(t,e)=>{t.height.equalTo(e.super),t.width.equalTo(2*this.clipsInstance.horizontalMargin),t.right.inset(this.clipsInstance.horizontalMargin/2),t.centerY.equalTo(e.super)},events:{tapped:()=>this.deleteSelected()}}],layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom)}}],((t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.toolBarHeight)}))}lineData(t){const e=this.clipsInstance.lineData(t);return e.checkmark={symbol:a.symbol.unselected},e}listTemplate(){const t=this.clipsInstance.listTemplate();return t.views[0].layout=(t,e)=>{t.height.right.equalTo(e.super),t.left.inset(this.containerMargin)},t.views.push({type:"image",props:{id:"checkmark",symbol:a.symbol.unselected,contentMode:$contentMode.scaleAspectFit},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(this.containerMargin/2),t.size.equalTo($size(25,25))}}),t}getListEditerView(){return{type:"list",props:{id:this.listId,bgcolor:r.primaryViewBackgroundColor,separatorInset:$insets(0,this.clipsInstance.horizontalMargin,0,0),indicatorInsets:$insets(0,0,this.toolBarHeight,0),data:this.clipsInstance.clips.map((t=>this.lineData(t))),template:this.listTemplate(),reorder:!0,footer:{height:this.toolBarHeight},crossSections:!1},events:{rowHeight:(t,e)=>{if(this.reorder.began){const t=e.row;t===this.reorder.to?e=this.reorder.from:this.reorder.tothis.reorder.to&&t<=this.reorder.from&&(e=t-1):this.reorder.to>this.reorder.from&&t=this.reorder.from&&(e=t+1)}const i=this.clipsInstance.getByIndex(e),s=i.hasTag?this.clipsInstance.tagHeight:this.clipsInstance.verticalMargin,r=i.image?this.clipsInstance.imageContentHeight:this.clipsInstance.getContentHeight(i.text);return this.clipsInstance.verticalMargin+r+s},reorderBegan:t=>{this.reorder.began=!0,this.reorder.from=t.row,this.reorder.to=t.row},reorderMoved:(t,e)=>{this.reorder.to=e.row},reorderFinished:()=>{this.reorder.began=!1,this.reorder.to!==this.reorder.from&&this.clipsInstance.move(this.reorder.from,this.reorder.to)},didSelect:(t,e,i)=>{this.editorSelected[e.row]=!this.editorSelected[e.row]}},layout:$layout.fill}}presentSheet(){this.sheet=new n,this.sheet.setView(s.createFromViews([this.getListEditerView(),this.getToolBarView()])).addNavBar({title:"",popButton:{title:$l10n("CLOSE")},rightButtons:[{title:$l10n("CLEAR"),color:$color("red"),tapped:async()=>{0===(await $ui.alert({title:$l10n("DELETE_DATA"),message:$l10n("DELETE_TABLE").replaceAll("${table}",this.clipsInstance.tableL10n),actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive},{title:$l10n("CANCEL")}]})).index&&this.deleteTable()}}]}).init().present()}}t.exports=a})),parcelRequire.register("44eiF",(function(t,e){var i=parcelRequire("gxpqj"),s=i.Matrix,r=i.Setting,n=i.NavigationView,a=i.BarButtonItem,o=i.Sheet,l=i.UIKit,h=parcelRequire("f0nX9"),c=parcelRequire("7TSVv"),d=parcelRequire("eSp9Z"),p=d.ActionEnv,u=d.ActionData,g=parcelRequire("2VUvw");t.exports=class extends c{matrix;reorder={};addActionButtonId="action-manager-button-add";sortActionButtonId="action-manager-button-sort";syncButtonId="action-manager-button-sync";syncLabelId="action-manager-sync-label";get actionList(){return super.actions.map((t=>{const e=[];return t.items.forEach((t=>{e.push(this.actionToData(t))})),{title:t.title,items:e}}))}actionSyncStatus(){$app.listen({actionSyncStatus:t=>{if(t.status===g.status.syncing&&t.animate)this.updateNavButton(!0),this.updateSyncLabel($l10n("SYNCING"));else if(t.status===g.status.success)try{this.matrix.data=this.actionList}catch(t){this.kernel.error(t),this.updateSyncLabel(t)}finally{this.updateSyncLabel(),this.updateNavButton(!1),$(this.matrix.id)?.endRefreshing()}}})}getColor(t,e=null){return t?"string"==typeof t?$color(t):$rgba(t.red,t.green,t.blue,t.alpha):e}editActionInfoPageSheet(t,e){const i=this.getActionTypes(),s=!Boolean(t);s?this.editingActionInfo={type:i[0],name:"MyAction",color:"#CC00CC",icon:"icon_062.png",readme:""}:(this.editingActionInfo=t,this.editingActionInfo.readme=this.getActionReadme(t.type,t.dir));const n=new r({structure:[],set:(t,e)=>(this.editingActionInfo[t]=e,!0),get:(t,e=null)=>Object.prototype.hasOwnProperty.call(this.editingActionInfo,t)?this.editingActionInfo[t]:e}),a=n.loader({type:"input",key:"name",icon:["pencil.circle","#FF3366"],title:$l10n("NAME")}).create(),l=n.loader({type:"color",key:"color",icon:["pencil.tip.crop.circle","#0066CC"],title:$l10n("COLOR")}).create(),h=n.loader({type:"icon",key:"icon",icon:["star.circle","#FF9933"],title:$l10n("ICON"),bgcolor:this.getColor(this.editingActionInfo.color)}).create(),c=n.loader({type:"menu",key:"type",icon:["tag.circle","#33CC33"],title:$l10n("TYPE"),items:i,values:i,pullDown:!0}).create(),d={type:"view",views:[{type:"text",props:{id:"action-text",textColor:$color("#000000","secondaryText"),bgcolor:$color("systemBackground"),text:this.editingActionInfo.readme,insets:$insets(10,10,10,10)},layout:$layout.fill,events:{tapped:t=>{$("actionInfoPageSheetList").scrollToOffset($point(0,s?280:230)),$delay(.2,(()=>t.focus()))},didChange:t=>{this.editingActionInfo.readme=t.text}}}],layout:$layout.fill},p=[{title:$l10n("INFORMATION"),rows:[a,l,h]},{title:$l10n("DESCRIPTION"),rows:[d]}];s&&(p[0].rows=p[0].rows.concat(c));const u=new o,g=async()=>{if(s){if(this.editingActionInfo.dir=$text.MD5(this.editingActionInfo.name),this.exists(this.editingActionInfo)){if(1===(await $ui.alert({title:$l10n("UNABLE_CREATE_ACTION"),message:$l10n("ACTION_NAME_ALREADY_EXISTS").replaceAll("${name}",this.editingActionInfo.name)})).index)return}const t=this.getActionOrder(this.editingActionInfo.type,!0);t.unshift(this.editingActionInfo.dir),this.saveOrder(this.editingActionInfo.type,t)}u.dismiss(),this.saveActionInfo(this.editingActionInfo),await $wait(.3),e&&e(this.editingActionInfo)};u.setView({type:"list",props:{id:"actionInfoPageSheetList",bgcolor:$color("insetGroupedBackground"),style:2,separatorInset:$insets(0,50,0,10),data:p},layout:$layout.fill,events:{rowHeight:(t,e)=>1===e.section?120:50}}).addNavBar({title:"",popButton:{title:$l10n("CANCEL")},rightButtons:[{title:$l10n("DONE"),tapped:async()=>await g()}]}).init().present()}editActionMainJs(t="",e){const i=new h(this.kernel);i.pageSheet(t,(t=>{this.saveMainJs(e,t)}),e.name,[{symbol:"book.circle",tapped:()=>{const t=$file.read("scripts/action/README.md").string;(new o).setView({type:"markdown",props:{content:t},layout:(t,e)=>{t.size.equalTo(e.super)}}).init().present()}},{symbol:"play.circle",tapped:async()=>{this.saveMainJs(e,i.text);let t=await this.getActionHandler(e.type,e.dir)(new u({env:p.build}));if(void 0!==t){"object"==typeof t&&(t=JSON.stringify(t,null,2));(new o).setView({type:"code",props:{lineNumbers:!0,editable:!1,text:t},layout:$layout.fill}).addNavBar({title:"",popButton:{title:$l10n("DONE")}}).init().present()}}}],"code")}move(t,e){if(t.section===e.section&&t.row===e.row)return;super.move(t,e);const i=this.matrix,s=this.actionToData(this.actions[e.section].items[e.row]);t.row{const i=t.cell(e),s=i.get("info").info;this.editActionInfoPageSheet(s,(t=>{i.get("info").info=t,i.get("color").bgcolor=this.getColor(t.color),i.get("name").text=t.name,"icon_"===t.icon.slice(0,5)?i.get("icon").icon=$icon(t.icon.slice(5,t.icon.indexOf(".")),$color("#ffffff")):i.get("icon").image=$image(t.icon)}))}},{title:$l10n("EDIT_SCRIPT"),symbol:"square.and.pencil",handler:(t,e,i)=>{const s=i.info.info;if(!s)return;const r=`${this.userActionPath}/${s.type}/${s.dir}/main.js`,n=$file.read(r).string;this.editActionMainJs(n,s)}},{inline:!0,items:[{title:"README",symbol:"book",handler:(t,e)=>{const i=t.cell(e).get("info").info;let s;try{s=__ACTIONS__[i.type][i.dir]["README.md"]}catch{s=this.getActionReadme(i.type,i.dir)}(new o).setView({type:"markdown",props:{content:s},layout:(t,e)=>{t.size.equalTo(e.super)}}).init().present()}}]},{inline:!0,items:[{title:$l10n("DELETE"),symbol:"trash",destructive:!0,handler:(t,e,i)=>{l.deleteConfirm($l10n("DELETE_CONFIRM_MSG"),(()=>{this.delete(i.info.info),t.delete(e)}))}}]}]}getNavButtons(){return[{symbol:"plus.circle",id:this.addActionButtonId,menu:{pullDown:!0,asPrimary:!0,items:[{title:$l10n("CREATE_NEW_ACTION"),handler:()=>{this.editActionInfoPageSheet(null,(async t=>{this.matrix.insert({indexPath:$indexPath(this.getActionTypes().indexOf(t.type),0),value:this.actionToData(t)});const e=$file.read(`${this.actionPath}/template.js`).string;this.saveMainJs(t,e),await $wait(.3),this.editActionMainJs(e,t)}))}},{title:$l10n("CREATE_NEW_TYPE"),handler:()=>{$input.text({text:"",placeholder:$l10n("CREATE_NEW_TYPE"),handler:t=>{if(""===(t=t.trim()))return void $ui.toast($l10n("INVALID_VALUE"));const e=`${this.userActionPath}/${t}`;$file.isDirectory(e)?$ui.warning($l10n("TYPE_ALREADY_EXISTS")):($file.mkdir(e),$ui.success($l10n("SUCCESS")))}})}}]}},{symbol:"arrow.up.arrow.down.circle",id:this.sortActionButtonId,tapped:(t,e)=>{$ui.popover({sourceView:e,directions:$popoverDirection.up,size:$size(200,300),views:[this.getActionListView(void 0,{reorder:!0,actions:[{title:"delete",handler:(t,e)=>{const i=this.matrix,s=i.object(e,!1).info.info;this.delete(s),i.delete(e,!1)}}]},{reorderBegan:t=>{this.reorder.from=t,this.reorder.to=void 0},reorderMoved:(t,e)=>{this.reorder.to=e},reorderFinished:t=>{void 0!==this.reorder.to&&this.move(this.reorder.from,this.reorder.to,t)}})]})}}]}actionToData(t){return{name:{text:t.name},icon:"icon_"===t?.icon?.slice(0,5)?{icon:$icon(t.icon.slice(5,t.icon.indexOf(".")),$color("#ffffff"))}:{image:$image(t?.icon)},color:{bgcolor:this.getColor(t.color)},info:{info:t}}}updateSyncLabel(t){t||(t=$l10n("MODIFIED")+this.getLocalSyncData().toLocaleString()),$(this.syncLabelId)&&($(this.syncLabelId).text=t)}updateNavButton(t){const e=this.navigationView?.navigationBarItems?.getButton(this.addActionButtonId);e&&e.setLoading(t);const i=this.navigationView?.navigationBarItems?.getButton(this.sortActionButtonId);i&&i.setLoading(t);const s=this.navigationView?.navigationBarItems?.getButton(this.syncButtonId);s&&s.setLoading(t)}getActionListView(t,e={},i={}){return t&&(i.didSelect=(e,i,s)=>{const r=s.info.info,n=this.getActionHandler(r.type,r.dir);t(n)}),{type:"list",layout:(t,e)=>{t.top.width.equalTo(e.super.safeArea),t.bottom.inset(0)},events:i,props:Object.assign({reorder:!1,bgcolor:$color("clear"),rowHeight:60,sectionTitleHeight:30,stickyHeader:!0,data:(()=>{const t=this.actionList;return t.map((t=>(t.rows=t.items,t))),t})(),template:{props:{bgcolor:$color("clear")},views:[{type:"image",props:{id:"color",cornerRadius:8,smoothCorners:!0},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(15),t.size.equalTo($size(30,30))}},{type:"image",props:{id:"icon",tintColor:$color("#ffffff")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(20),t.size.equalTo($size(20,20))}},{type:"label",props:{id:"name",lines:1,font:$font(16)},layout:(t,e)=>{t.height.equalTo(30),t.centerY.equalTo(e.super),t.left.equalTo(e.prev.right).offset(15)}},{type:"label",props:{id:"info"}}]}},e)}}getActionMiniView(t,e){e||(e=[],super.actions.forEach((t=>{e=e.concat(t.items)})));return{type:"matrix",props:{bgcolor:$color("clear"),columns:2,itemHeight:50,spacing:8,data:[],template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color($rgba(255,255,255,.3),$rgba(0,0,0,.3))},views:[{type:"image",props:{id:"color",cornerRadius:8,smoothCorners:!0},layout:t=>{t.top.left.inset(10),t.size.equalTo($size(30,30))}},{type:"image",props:{id:"icon",tintColor:$color("#ffffff")},layout:(t,e)=>{t.edges.equalTo(e.prev).insets(5)}},{type:"label",props:{id:"name",font:$font(14)},layout:(t,e)=>{t.bottom.top.inset(10),t.left.equalTo(e.prev.prev.right).offset(10),t.right.inset(10)}},{type:"view",props:{id:"info",hidden:!0}}]}},layout:$layout.fill,events:{ready:t=>{t.data=e.map((t=>this.actionToData(t)))},didSelect:async(e,i,s)=>{const r=s.info.info,n=await t(r);this.getActionHandler(r.type,r.dir)(n)}}}}getMatrixView({columns:t=2,spacing:e=15,itemHeight:i=100}={}){return this.matrix=s.create({type:"matrix",props:{columns:t,itemHeight:i,spacing:e,bgcolor:l.scrollViewBackgroundColor,menu:{items:this.menuItems()},data:this.actionList,template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color("#ffffff","#242424")},views:[{type:"image",props:{id:"color",cornerRadius:8,smoothCorners:!0},layout:t=>{t.top.left.inset(10),t.size.equalTo($size(30,30))}},{type:"image",props:{id:"icon",tintColor:$color("#ffffff")},layout:t=>{t.top.left.inset(15),t.size.equalTo($size(20,20))}},{type:"button",props:{bgcolor:$color("clear"),tintColor:l.textColor,titleColor:l.textColor,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},views:[{type:"image",props:{symbol:"ellipsis.circle"},layout:(t,e)=>{t.center.equalTo(e.super),t.size.equalTo(a.style.iconSize)}}],events:{tapped:t=>{const e=t.next.info;if(!e)return;const i=`${this.userActionPath}/${e.type}/${e.dir}/main.js`,s=$file.read(i).string;this.editActionMainJs(s,e)}},layout:t=>{t.top.right.inset(0),t.size.equalTo(a.style.width)}},{type:"view",props:{id:"info",hidden:!0}},{type:"label",props:{id:"name",font:$font(16)},layout:(t,e)=>{t.bottom.left.inset(10),t.width.equalTo(e.super)}}]},footer:{type:"view",props:{hidden:!this.kernel.setting.get("webdav.status"),height:this.kernel.setting.get("webdav.status")?50:0},views:[{type:"label",props:{id:this.syncLabelId,color:$color("secondaryText"),font:$font(12),text:$l10n("MODIFIED")+this.getLocalSyncData().toLocaleString()},layout:(t,i)=>{t.size.equalTo(i.super),t.top.inset(-30),t.left.inset(e)}}]}},layout:$layout.fill,events:{didSelect:(t,e,i)=>{const s=i.info.info,r=new u({env:p.action,text:"clipboard"===s.type||"uncategorized"===s.type?$clipboard.text:null});this.getActionHandler(s.type,s.dir)(r)},pulled:async t=>{this.isEnableWebDavSync?this.syncWithWebDav():(this.updateNavButton(!0),await this.sync(),this.matrix.data=this.actionList,this.updateSyncLabel(),this.updateNavButton(!1),t.endRefreshing())}}}),this.actionSyncStatus(),this.matrix.definition}getPage(){return this.navigationView=new n,this.navigationView.navigationBarItems.setRightButtons(this.getNavButtons()),this.navigationView.setView(this.getMatrixView()).navigationBarTitle($l10n("ACTIONS")),this.navigationView.getPage()}present(){const t=new o,e=this.getNavButtons();this.kernel.setting.get("webdav.status")&&e.push({id:this.syncButtonId,symbol:"arrow.triangle.2.circlepath.circle",tapped:async(t,e)=>{this.isEnableWebDavSync?this.syncWithWebDav():(this.updateNavButton(!0),await this.sync(),this.matrix.data=this.actionList,this.updateSyncLabel(),this.updateNavButton(!1))}}),t.setView(this.getMatrixView()).addNavBar({title:$l10n("ACTIONS"),popButton:{symbol:"xmark.circle"},rightButtons:e}).init(),this.navigationView=t.navigationView,t.present()}}})),parcelRequire.register("7TSVv",(function(t,e){var i=parcelRequire("gxpqj").FileStorage,s=parcelRequire("eSp9Z"),r=s.ActionEnv,n=s.ActionData,a=s.Action,o=parcelRequire("jVlss").SecureScript,l=parcelRequire("7pN8M");t.exports=class{#q;constructor(t){this.kernel=t,this.actionPath="scripts/action",this.actionOrderFile="order.json",this.tempPath=`${this.kernel.fileStorage.basePath}/temp`,this.userActionPath=`${this.kernel.fileStorage.basePath}/user_action`,this.localSyncFile=this.userActionPath+"/sync.json",this.typeNameMap={},this.checkUserAction(),this.sync()}get actions(){return this.#q||(this.#q=this.getActionTypes().map((t=>({title:this.getTypeName(t),items:this.getActions(t)}))),this.kernel.print("init actions")),this.#q}get isNew(){return $cache.get("caio.action.isNew")??!1}set isNew(t){$cache.get("caio.action.isNew",t)}get isEnableWebDavSync(){return this.kernel.setting.get("webdav.status")}setNeedReload(){this.#q=void 0,this.isEnableWebDavSync&&this.webdavSync.needUpload()}importExampleAction(){try{Object.keys(__ACTIONS__).forEach((t=>{const e=`${this.userActionPath}/${t}`;Object.keys(__ACTIONS__[t]).forEach((i=>{$file.exists(`${e}/${i}/main.js`)||($file.mkdir(e),$file.mkdir(`${e}/${i}`),$file.write({data:$data({string:__ACTIONS__[t][i]["main.js"]}),path:`${e}/${i}/main.js`}),$file.write({data:$data({string:__ACTIONS__[t][i]["config.json"]}),path:`${e}/${i}/config.json`}),$file.write({data:$data({string:__ACTIONS__[t][i]["README.md"]}),path:`${e}/${i}/README.md`}))}))}))}catch{$file.list(this.actionPath).forEach((t=>{const e=`${this.actionPath}/${t}`;if($file.isDirectory(e)){const i=`${this.userActionPath}/${t}`;$file.list(e).forEach((t=>{$file.exists(`${i}/${t}/main.js`)||($file.mkdir(i),$file.copy({src:`${e}/${t}`,dst:`${i}/${t}`}))}))}}))}this.setNeedReload()}getLocalSyncData(){const t=JSON.parse($file.read(this.localSyncFile)?.string??"{}");return new Date(t.timestamp)}async sync(){this.kernel.setting.get("webdav.status")&&(this.webdavSync?await this.webdavSync.init():await this.initSyncWithWebDav())}async initSyncWithWebDav(){if(this.isEnableWebDavSync)try{this.webdavSync=new l({kernel:this.kernel,host:this.kernel.setting.get("webdav.host"),user:this.kernel.setting.get("webdav.user"),password:this.kernel.setting.get("webdav.password"),basepath:this.kernel.setting.get("webdav.basepath")}),await this.webdavSync.init()}catch(t){throw this.kernel.error(`${t}\n${t.stack}`),t}}syncWithWebDav(){this.isEnableWebDavSync&&this.webdavSync.sync()}checkUserAction(){$file.exists(this.userActionPath)&&0!==$file.list(this.userActionPath).length||($file.mkdir(this.userActionPath),this.isNew=!1,this.importExampleAction())}getActionTypes(){const t=["clipboard","editor"];return t.concat($file.list(this.userActionPath).filter((e=>$file.isDirectory(`${this.userActionPath}/${e}`)&&t.indexOf(e)<0)))}getActionOrder(t,e=!1){const i=`${this.userActionPath}/${t}`,s=`${i}/${this.actionOrderFile}`;if($file.exists(s)){const e=JSON.parse($file.read(s).string),r=e.filter((t=>!!$file.exists(`${i}/${t}`)));return r.length!==e.length&&this.saveOrder(t,r),r}if(e){const t=[];return $file.list(i).forEach((e=>{t.push(e)})),t}return[]}getActionPath(t,e){return`${this.userActionPath}/${t}/${e}`}getActionConfig(t,e){return JSON.parse($file.read(`${this.getActionPath(t,e)}/config.json`).string)}getActionReadme(t,e){return $file.read(`${this.getActionPath(t,e)}/README.md`).string}getAction(t,e,i){$file.exists(this.getActionPath(t,e))||(e=$text.MD5(e));const s=this.getActionPath(t,e),l=this.getActionConfig(t,e);try{const t=$file.read(`${s}/main.js`).string,e=new o(t),h=new Function("Action","ActionEnv","ActionData",`${e.secure()}\n return MyAction`)(a,r,n);return new h(this.kernel,l,i)}catch(t){throw this.kernel.error(t),t}}getActionHandler(t,e){return async i=>{try{const s=this.getAction(t,e,i);return await s.do()}catch(t){throw this.kernel.error(t),t}}}getActions(t){const e=[],i=`${this.userActionPath}/${t}`;if(!$file.exists(i))return[];const s=s=>{const r=`${i}/${s}/`;if($file.isDirectory(r)){const i=this.getActionConfig(t,s);e.push(Object.assign(i,{dir:s,type:t,name:i.name??s,icon:i.icon,color:i.color}))}},r=this.getActionOrder(t);return r.forEach((t=>s(t))),$file.list(i).forEach((t=>{-1===r.indexOf(t)&&s(t)})),e}getTypeName(t){const e=t.toUpperCase(),i=$l10n(e),s=i===e?t:i;return this.typeNameMap[s]=t,s}getTypeDir(t){return this.typeNameMap[t]??t}#P(t,...e){"string"!=typeof t&&(t=JSON.stringify(t));const s=i.join(this.userActionPath,...e),r=s.substring(0,s.lastIndexOf("/"));$file.exists(r)||$file.mkdir(r);const n=$file.read(s)?.string;let a;try{a=JSON.stringify(JSON.parse(n))}catch{a=n}t!==a&&($file.write({data:$data({string:t}),path:s}),this.setNeedReload())}saveActionInfo(t){this.#P({icon:t.icon,color:t.color,name:t.name},t.type,t.dir,"config.json"),this.#P(t.readme,t.type,t.dir,"README.md")}saveMainJs(t,e){this.#P(e,t.type,t.dir,"main.js")}saveOrder(t,e){this.#P(JSON.stringify(e),t,this.actionOrderFile)}move(t,e){if(t.section===e.section&&t.row===e.row)return;const i=this.actions[t.section];let s=i.items;const r=this.getTypeDir(i.title),n=t=>t.map((t=>t.dir));if(t.section===e.section){const i=t.rowe.row?t.row+1:t.row;s.splice(i,0,s[t.row]),s=s.filter(((t,e)=>e!==a)),this.saveOrder(r,n(s))}else{const i=this.actions[e.section],a=i.items,o=this.getTypeDir(i.title);a.splice(e.row,0,s[t.row]),s=s.filter(((e,i)=>i!==t.row)),$file.move({src:`${this.userActionPath}/${r}/${a[e.row].dir}`,dst:`${this.userActionPath}/${o}/${a[e.row].dir}`}),this.saveOrder(o,n(a)),this.saveOrder(r,n(s))}}delete(t){$file.delete(`${this.userActionPath}/${t.type}/${t.dir}`),this.setNeedReload()}exists(t){const e=`${this.userActionPath}/${t.type}/${t.dir}`;return!!$file.exists(e)}}})),parcelRequire.register("7pN8M",(function(t,e){var i=parcelRequire("gxpqj").FileStorage,s=parcelRequire("2VUvw");class r extends s{localSyncDataPath="/user_action/sync.json";webdavSyncDataPath="/sync.json";tempPath="/temp";webdavActionsPath="/actions.zip";localActionsPath="/user_action";constructor({host:t,user:e,password:s,basepath:r,kernel:n}={}){super({host:t,user:e,password:s,basepath:r=i.join(r,"user_action"),kernel:n})}async init(){await super.init(),this.sync()}isNew(){return this.kernel.actionManager.isNew}async pull(){const t=i.join(this.tempPath,"user_action"),e=this.kernel.fileStorage.filePath(t),s=await this.webdav.get(this.webdavActionsPath);if(!await $archiver.unzip({file:s.rawData,dest:e}))throw new Error("unzip failed");await this.downloadSyncData(),this.kernel.fileStorage.move(t,this.localActionsPath),this.kernel.print("action webdav sync: pulled")}async push(){const t=i.join(this.tempPath,"actions.zip");if(!$archiver.zip({directory:this.kernel.fileStorage.filePath(this.localActionsPath),dest:this.kernel.fileStorage.filePath(t)}))throw new Error("zip failed");await $wait(.5),await this.webdav.put(this.webdavActionsPath,this.kernel.fileStorage.readSync(t)),await this.uploadSyncData(),this.kernel.fileStorage.delete(t),this.kernel.print("action webdav sync: pushed")}notify(t){$app.notify({name:"actionSyncStatus",object:t})}async#$(){let t=!1;try{const e=await this.nextSyncStep();if(this.kernel.print(`action nextSyncStep: ${s.stepName[e]}`),e===s.step.needPush||e===s.step.init)await this.push();else if(e===s.step.needPull)await this.pull(),t=!0;else{if(e!==s.step.conflict)return void this.notify({status:s.status.nochange});await this.conflict($l10n("ACTIONS"))===r.conflictKeep.webdav&&(t=!0)}}catch(t){throw this.notify({status:s.status.fail,error:t}),t}finally{this.notify({status:s.status.success,updateList:t})}}sync(){this.notify({status:s.status.syncing,animate:!0}),this.syncTimer&&this.syncTimer.cancel(),this.syncTimer=$delay(.5,(()=>{this.#$(!0)}))}needUpload(){this.notify({status:s.status.syncing}),this.uploadTimer&&this.uploadTimer.cancel(),this.uploadTimer=$delay(.5,(()=>{this.updateLocalTimestamp(),this.#$()}))}}t.exports=r})),parcelRequire.register("gYDdO",(function(t,e){class i{files=[];databases=[];actions={};constructor(t){this.kernel=t}deleteFiles(t){t.forEach((t=>{this.files.includes(t)||this.files.push(t)}))}#_(){this.files.forEach((t=>{$file.exists(t)&&(this.kernel.print(`delete file: ${t}`),$file.delete(t))}))}rebuildDatabase(t,e){this.databases.push([t,e])}#V(){const t=(t,e)=>{const i=this.kernel.storage.sqlite.query(`SELECT count(*), name FROM sqlite_master WHERE type = "table" AND name = "${t}"`);if(null!==i.error)throw new Error(`Code [${i.error.code}] ${i.error.domain} ${i.error.localizedDescription}`);i.result.next();const s=i.result.get(0);i.result.close(),s>0&&(this.kernel.print(`copy data from old table: ${t}`),this.kernel.storage.sqlite.update(`INSERT INTO ${e} SELECT * FROM ${t}`),this.kernel.print(`drop table: ${t}`),this.kernel.storage.sqlite.update(`DROP TABLE ${t}`))};this.databases.forEach((e=>{t(e[0],e[1])}))}rebuildUserActions(t={}){for(let e of Object.keys(t))t[e].forEach((t=>{this.actions[e]||(this.actions[e]=[]),this.actions[e].includes(t)||this.actions[e].push(t)}))}async#M(){if(0===Object.keys(this.actions).length)return;const t="scripts/action",e=`${this.kernel.fileStorage.basePath}/user_action`,i=[];for(let e of Object.keys(this.actions))this.actions[e].forEach((s=>{const r=JSON.parse($file.read(`${t}/${e}/${s}/config.json`).string);i.push(r.name)}));if(1!==(await $ui.alert({title:$l10n("compatibility.rebuildUserAction.alert.title"),message:$l10n("compatibility.rebuildUserAction.alert.message")+"\n"+JSON.stringify(i,null,2)+"\n"+$l10n("compatibility.rebuildUserAction.alert.message2"),actions:[{title:$l10n("OK")},{title:$l10n("CANCEL")}]})).index){for(let i of Object.keys(this.actions))this.actions[i].forEach((s=>{$file.exists(`${e}/${i}/${s}`)&&(this.kernel.print(`rebuild user action: ${i}/${s}`),$file.copy({src:`${t}/${i}/${s}/main.js`,dst:`${e}/${i}/${s}/main.js`}))}));this.kernel.actionManager.setNeedReload()}}async do(){this.#_(),this.#V(),await this.#M()}}class s{version=7;userVersion=$cache.get("compatibility.version")??0;constructor(t){this.kernel=t,this.compatibility=new i(this.kernel)}do(){this.userVersionthis.kernel.error(t))),$cache.set("compatibility.version",this.version)}call(t){if("function"!=typeof this[`ver${t}`])throw new ReferenceError(`version ${t} undefined`);this[`ver${t}`]()}ver1(){this.compatibility.deleteFiles(["scripts/action/clipboard/ClearClipboard","scripts/ui/clipboard.js","scripts/ui/clipboard-data.js","scripts/ui/clipboard-search.js"]),this.compatibility.rebuildDatabase("clipboard","clips"),this.compatibility.rebuildUserActions({uncategorized:["ExportAllContent","DisplayClipboard"],clipboard:["B23Clean"]}),$cache.get("caio.keyboard.height")&&(this.kernel.setting.set("keyboard.previewAndHeight",$cache.get("caio.keyboard.height")),$cache.remove("caio.keyboard.height"))}ver2(){this.compatibility.deleteFiles(["scripts/storage.js","scripts/ui/clips-data.js","scripts/ui/components/action-manager-data.js"]),this.compatibility.rebuildDatabase("pin","favorite"),this.compatibility.rebuildUserActions({uncategorized:["ExportAllContent"]})}ver3(){this.compatibility.rebuildUserActions({clipboard:["SendToWin"]})}ver4(){const t="/storage/user_action/data.json";if($file.exists(t)){const e=JSON.parse($file.read(t).string).date;$file.write({data:$data({string:JSON.stringify({timestamp:e})}),path:"/storage/user_action/sync.json"}),$file.delete(t)}}ver5(){this.compatibility.rebuildUserActions({uncategorized:["DisplayClipboard"]})}ver6(){this.compatibility.rebuildUserActions({clipboard:["GetFromWin"]})}ver7(){this.compatibility.rebuildUserActions({uncategorized:["Replace"]})}}t.exports=async function(t){if(t)try{new s(t).do()}catch(e){throw t.error(e),e}}})),parcelRequire.register("9RsVy",(function(t,e){var i=parcelRequire("gxpqj"),s=i.Kernel,r=i.UIKit,n=parcelRequire("2aNLD"),a=parcelRequire("ilpYs");let o;function l(){o.setting.method.exportClipboard=t=>{t.start(),o.storage.export((e=>{e?t.done():t.cancel()}))},o.setting.method.importClipboard=t=>{t.start(),$ui.alert({title:$l10n("ALERT_INFO"),message:$l10n("OVERWRITE_ALERT"),actions:[{title:$l10n("OK"),handler:()=>{$drive.open({handler:e=>{void 0!==e?"db"===e.fileName.slice(-2)||"zip"===e.fileName.slice(-3)?o.storage.import(e).then((()=>{t.done(),$delay(.3,(()=>{$addin.restart()}))})).catch((e=>{$ui.error(e),o.error(e),t.cancel()})):($ui.warning($l10n("FILE_TYPE_ERROR")),t.cancel()):t.cancel()}})}},{title:$l10n("CANCEL"),handler:()=>t.cancel()}]})},o.setting.method.rebuildDatabase=t=>{t.start();$ui.alert({title:$l10n("REBUILD_DATABASE_ALERT"),actions:[{title:$l10n("REBUILD"),style:$alertActionType.destructive,handler:()=>{(()=>{try{o.storage.rebuild(),t.done(),$delay(.8,(()=>$addin.restart()))}catch(e){t.cancel(),$ui.alert(e)}})()}},{title:$l10n("CANCEL"),handler:()=>{t.cancel()}}]})},o.setting.method.deleteAllData=t=>{t.start(),$ui.alert({title:$l10n("DELETE_ALL_DATA_ALERT"),actions:[{title:$l10n("DELETE"),style:$alertActionType.destructive,handler:()=>{o.storage.deleteAllData(),t.done(),$delay(.5,(()=>$addin.restart()))}},{title:$l10n("CANCEL"),handler:()=>{t.cancel()}}]})},o.setting.method.recycleBin=()=>({type:"list",props:{data:o.clips.getRecycleBin().map((t=>t?.text??"None")),actions:[{title:$l10n("DELETE"),handler:(t,e)=>{o.clips.removeFromRecycleBin(e.row)}}]},events:{didSelect:(t,e)=>{const i=o.clips.getRecycleBin()[e.row]??{};if(i.text){const s=o.clips.addItem(i.text);i.tag&&o.storage.setTag(s.uuid,i.tag),o.clips.removeFromRecycleBin(e.row),o.clips.updateList(!0),t.delete(e)}}},layout:$layout.fill})}t.exports=function(t){o=t,o.setting.method.checkUpdate=async t=>{t.start();const e="scripts/libs/easy-jsbox.js";if($file.exists(e))try{const t=await o.checkUpdate();t&&($file.write({data:$data({string:t}),path:e}),$ui.toast("The framework has been updated."))}catch{}$http.get({url:"https://raw.githubusercontent.com/ipuppet/CAIO/master/config.json",handler:e=>{const i=e.data?.info.version;let r;try{r=__INFO__}catch{r=JSON.parse($file.read("config.json").string).info}s.versionCompare(i,r.version)>0?$ui.alert({title:"New Version",message:`New version found: ${i}\nUpdate via Github or click the button to open Erots.`,actions:[{title:$l10n("CANCEL")},{title:"Erots",handler:()=>{$addin.run({name:"Erots",query:{q:"show",objectId:"603e6eaaca0dd64fcef93e2d"}})}}]}):$ui.toast("No need to update"),t.done()}})},o.setting.method.previewWidget=t=>{const{Widget:e}=parcelRequire("gD12U"),i={};try{JSON.parse($file.read("widget-options.json").string).forEach((t=>{i[t.name]=t.value}))}catch(t){return void $ui.error(t)}$ui.menu({items:Object.keys(i),handler:t=>{e.render(i[t])}})},o.setting.method.fileManager=()=>{o.fileManager.push("storage")},l(),o.setting.method.exportAction=t=>{t.start();const e="actions.zip",i=`/${e}`,s=o.fileStorage.filePath(i);$archiver.zip({directory:o.actionManager.userActionPath,dest:s,handler:()=>{$share.sheet({items:[{name:e,data:$data({path:s})}],handler:e=>{e?t.done():t.cancel(),o.fileStorage.delete(i)}})}})},o.setting.method.importAction=t=>{t.start(),$drive.open({handler:e=>{if(void 0!==e)if("zip"===e.fileName.slice(-3)){const i=`${o.fileStorage.basePath}/action_import`;$archiver.unzip({file:e,dest:i,handler:()=>{$file.list(i).forEach((t=>{$file.isDirectory(`${i}/${t}`)&&$file.copy({src:`${i}/${t}`,dst:`${o.actionManager.userActionPath}/${t}`})})),$file.delete(i),t.done()}})}else $ui.warning($l10n("FILE_TYPE_ERROR")),t.cancel();else t.cancel()}})},o.setting.method.importExampleAction=t=>{t.start(),o.actionManager.importExampleAction(),t.done()},o.setting.method.rebuildAction=t=>{t.start(),$ui.alert({title:$l10n("REBUILD_ACTION_DATABASE_ALERT_TITLE"),message:$l10n("REBUILD_ACTION_DATABASE_ALERT_MESSAGE"),actions:[{title:$l10n("REBUILD"),style:$alertActionType.destructive,handler:()=>{$file.delete(o.actionManager.userActionPath),o.actionManager.setNeedReload(),t.done(),$delay(.8,(()=>$addin.restart()))}},{title:$l10n("CANCEL"),handler:()=>t.cancel()}]})},function(){const t=parcelRequire("7eNYp"),e=200;o.setting.method.previewKeyboard=()=>{const i=new t(o),s=t=>{i.setKeyboardHeight(t),$(i.keyboardId).updateLayout((t=>{t.height.equalTo(i.keyboardHeight)})),1===i.keyboardDisplayMode&&$(i.keyboardId).get(i.listId).reload()},n=t=>(t-e)/200;return{views:[{type:"label",layout:(t,e)=>{t.top.inset(20),t.centerX.equalTo(e.super)},events:{ready:t=>t.text=i.keyboardHeight,tapped:t=>{$input.text({type:$kbType.number,text:i.keyboardHeight,handler:i=>{if(/^[0-9]+$/.test(i)){let r=Number(i);r=Math.min(r,400),r=Math.max(r,e),t.text=r,t.next.value=n(r),s(r)}else $ui.toast("Only integers can be entered.")}})}}},{type:"slider",props:{max:1,min:0},layout:(t,e)=>{t.top.equalTo(e.prev.bottom),t.right.inset(20),t.width.equalTo(e.super).offset(-40)},events:{ready:t=>t.value=n(i.keyboardHeight),changed:t=>{const i=Math.floor(200*t.value+e);t.prev.text=i,s(i)}}},i.getView()],layout:(t,e)=>{t.left.right.bottom.equalTo(e.super.safeArea);let i=0;1===o.setting.get("mainUIDisplayMode")&&(i=r.NavigationBarNormalHeight),t.top.equalTo(e.super.safeArea).inset(i)}}},o.setting.method.setKeyboardQuickStart=()=>n.sheet()}(),o.setting.method.previewTodayWidget=t=>{t.touchHighlightStart();const e=new(parcelRequire("49je6"))(o).getView();r.push({views:[e],disappeared:()=>t.touchHighlightEnd()})},o.setting.method.setTodayWidgetActions=t=>{a.sheet(o)}}})),parcelRequire.register("2aNLD",(function(t,e){var i=parcelRequire("gxpqj").Sheet;class s{constructor(){this.listId="keyboard-script-list"}static getAddins(){const t=$cache.get("keyboard.addins");if(!t)return[];if($cache.get("keyboard.addins.all")){const t=$addin.current.name;return $addin.list?.filter((e=>t!==e.displayName)).map((t=>t.displayName))}try{return JSON.parse(t)}catch(t){return[]}}static setAddins(t=[]){t.map(((e,i)=>{null===e&&t.splice(i,1)}));try{$cache.set("keyboard.addins",JSON.stringify(t))}catch(t){$cache.set("keyboard.addins",void 0)}}static setAllAddins(t){$cache.set("keyboard.addins.all",t)}getUnsetAddins(){const t=$addin.current.name,e=s.getAddins();return $addin.list?.filter((i=>-1===e.indexOf(i.displayName)&&t!==i.displayName)).map((t=>t.displayName))}add(){const t={type:"list",props:{data:this.getUnsetAddins()},events:{didSelect:(t,e,i)=>{const r=s.getAddins();r.unshift(i),s.setAddins(r),$(this.listId).insert({indexPath:$indexPath(0,0),value:i}),t.delete(e)}},layout:$layout.fill};(new i).setView(t).addNavBar({title:$l10n("ADD")}).init().present()}getNavButtons(){return[{symbol:"plus",tapped:()=>this.add()}]}getListView(){return{type:"list",props:{id:this.listId,reorder:!0,data:s.getAddins(),actions:[{title:"delete",handler:(t,e)=>{s.setAddins(t.data)}}]},events:{reorderFinished:t=>{s.setAddins(t)}},layout:$layout.fill}}static async sheet(){if(0===(await $ui.menu({items:[$l10n("ALL_SCRIPTS"),$l10n("SELECT_SCRIPTS")]})).index)s.setAllAddins(!0);else{s.setAllAddins(!1);const t=new i,e=new s;t.setView(e.getListView()).addNavBar({title:$l10n("QUICK_START_SCRIPTS"),popButton:{title:$l10n("DONE")},rightButtons:e.getNavButtons()}),t.init().present()}}}t.exports=s})),parcelRequire.register("ilpYs",(function(t,e){var i=parcelRequire("gxpqj").Sheet;class s{constructor(t){this.listId="today-action-list",this.kernel=t}getActions(){let t=$cache.get("today.actions")??[];"string"==typeof t&&(t=JSON.parse(t),this.setActions(t));const e={};this.kernel.actionManager.getActionTypes().forEach((t=>{this.kernel.actionManager.getActions(t).forEach((t=>{e[t.type+t.dir]=t}))}));const i=[];let s=!1;return t.forEach((t=>{const r=e[t.type+t.dir];r?i.push(r):s=!0})),s&&this.setActions(i),i}setActions(t=[]){t.map(((e,i)=>{e||t.splice(i,1)})),$cache.set("today.actions",t)}getAllActions(){let t=[];return this.kernel.actionManager.getActionTypes().forEach((e=>{t=t.concat(this.kernel.actionManager.getActions(e))})),t}getUnsetActions(){const t=this.getActions().map((t=>t.name)),e=[];return this.getAllActions().forEach((i=>{const s=i.name;-1===t.indexOf(s)&&e.push(i)})),e}getListData(t){return t.map((t=>({action:{text:t.name,info:t},icon:"icon_"===t.icon.slice(0,5)?{icon:$icon(t.icon.slice(5,t.icon.indexOf(".")),$color("#ffffff"))}:{image:$image(t.icon)},color:{bgcolor:this.kernel.actionManager.getColor(t.color)}})))}getListTemplate(){return{views:[{type:"image",props:{id:"color",cornerRadius:8,smoothCorners:!0},layout:t=>{t.top.left.inset(10),t.size.equalTo($size(30,30))}},{type:"image",props:{id:"icon",tintColor:$color("#ffffff")},layout:t=>{t.top.left.inset(15),t.size.equalTo($size(20,20))}},{type:"label",props:{id:"action"},layout:(t,e)=>{t.bottom.top.inset(10),t.left.equalTo(e.prev.prev.right).offset(10),t.right.inset(10)}}]}}add(){const t={type:"list",props:{data:this.getListData(this.getUnsetActions()),template:this.getListTemplate(),rowHeight:50},events:{didSelect:(t,e,i)=>{const s=i.action.info,r=this.getActions();r.unshift(s),this.setActions(r),$(this.listId).insert({indexPath:$indexPath(0,0),value:this.getListData([s])[0]}),t.delete(e)}},layout:$layout.fill};(new i).setView(t).addNavBar({title:$l10n("ADD"),popButton:{title:$l10n("CLOSE")}}).init().present()}getNavButtons(){return[{symbol:"plus",tapped:()=>this.add()}]}getListView(){return{type:"list",props:{id:this.listId,data:this.getListData(this.getActions()),template:this.getListTemplate(),rowHeight:50,reorder:!0,actions:[{title:"delete",handler:(t,e)=>{this.setActions(t.data.map((t=>t.action.info)))}}]},events:{reorderFinished:t=>{const e=[];t.forEach((t=>{e.push(t.action.info)})),this.setActions(e)}},layout:$layout.fill}}static sheet(t){const e=new i,r=new s(t);e.setView(r.getListView()).addNavBar({title:$l10n("ACTIONS"),popButton:{title:$l10n("CLOSE")},rightButtons:r.getNavButtons()}),e.init().present()}}t.exports=s})),parcelRequire.register("7eNYp",(function(t,e){var i=parcelRequire("eSp9Z"),s=i.ActionData,r=i.ActionEnv,n=parcelRequire("gxpqj"),a=n.View,o=n.UIKit,l=n.Sheet,h=n.BarButtonItem,c=parcelRequire("imdB1"),d=parcelRequire("2aNLD");t.exports=class extends c{#F;keyboardId="keyboard.main";listId="keyboard-clips-list";actionsId="keyboard-list-actions";keyboardSwitchLockId="keyboard-switch-lock";keyboardSwitchLockKey="caio.keyboard.switch.lock";deleteTimer=void 0;continuousDeleteTimer=void 0;continuousDeleteTapticTimer=void 0;continuousDeleteDelay=.5;horizontalMargin=15;verticalMargin=12;copiedIndicatorSize=5;containerMargin=4;fontSize=14;tagHeight=this.verticalMargin+3;matrixBoxMargin=10;navHeight=50;bottomBarHeight=50;bottomButtonSize=$size(46,40);menuItemActionMaxCount=3;itemBackground=$color("#FFFFFF",$rgba(151,151,151,.4));buttonBackground=$color($rgba(0,0,0,.15),$rgba(117,117,117,.4));constructor(t){super(t),this.keyboardDisplayMode=this.kernel.setting.get("keyboard.displayMode"),this.backgroundImage=this.kernel.setting.get("keyboard.background.image")?.image,this.useBlur=this.backgroundImage&&this.kernel.setting.get("keyboard.blur"),this.deleteDelay=this.kernel.setting.get("keyboard.deleteDelay"),"boolean"!=typeof $cache.get(this.keyboardSwitchLockKey)&&$cache.set(this.keyboardSwitchLockKey,!1)}get keyboardHeight(){return this.kernel.setting.get("keyboard.previewAndHeight")}setKeyboardHeight(t){this.kernel.setting.set("keyboard.previewAndHeight",t)}getKeyboardSwitchLock(){const t=$cache.get(this.keyboardSwitchLockKey);return"boolean"!=typeof t&&$cache.set(this.keyboardSwitchLockKey,!0),t}switchKeyboardSwitchLock(){const t=$cache.get(this.keyboardSwitchLockKey);$cache.set(this.keyboardSwitchLockKey,!t),$(this.keyboardSwitchLockId).symbol=t?"lock.open":"lock"}listReady(){this.updateList(),this.kernel.setting.get("clipboard.autoSave")&&$app.env===$env.keyboard&&(this.#F=$timer.schedule({interval:1,handler:()=>{this.kernel.setting.get("clipboard.autoSave")?this.readClipboard():this.#F.invalidate()}}))}keyboardTapped(t,e=!0){return async(...i)=>{if(e&&this.kernel.setting.get("keyboard.tapticEngine")&&$device.taptic(this.kernel.setting.get("keyboard.tapticEngineLevel")),"function"==typeof t)try{await t(...i)}catch(t){throw this.kernel.error(t),t}}}getTopButtons(){const t=[{symbol:"keyboard.chevron.compact.down",tapped:this.keyboardTapped((()=>$keyboard.dismiss()))},{symbol:"square.and.arrow.down.on.square",tapped:this.keyboardTapped((async t=>{t.start();try{await this.readClipboard(!0),t.done()}catch(e){throw t.cancel(),e}}))},{symbol:"bolt.circle",tapped:this.keyboardTapped((()=>{let t=!0===$(this.actionsId).hidden;$(this.listId+"-container").hidden=t,$(this.actionsId).hidden=!t}))}];return{type:"view",views:t.map(((t,e)=>{const i=new h;return i.buttonEdges=0,i.setAlign(o.align.right).setSymbol(t.symbol).setEvent("tapped",t.tapped).definition})),layout:(e,i)=>{const s=new h;e.height.equalTo(i.super),e.right.inset(this.containerMargin-s.edges),e.width.equalTo(s.width*t.length+s.edges)}}}getTopBarView(){return{type:"view",views:[{type:"view",layout:$layout.fill,views:[{type:"label",props:{text:$l10n("CAIO"),font:$font("bold",20)},events:{tapped:()=>this.kernel.openInJsbox(),ready:t=>{$cache.get("tips.keyboard.title")||($cache.set("tips.keyboard.title",!0),$ui.popover({sourceView:t,size:$size(200,60),directions:$popoverDirection.up,views:[{type:"label",props:{lines:0,text:$l10n("CLICK_TO_OPEN_JSBOX"),align:$align.center},layout:$layout.fillSafeArea}]}))}},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.equalTo(e.super).offset(this.containerMargin)}}].concat(this.tabView(),this.getTopButtons())}],layout:(t,e)=>{t.top.width.equalTo(e.super),t.height.equalTo(this.navHeight)}}}getBottomButtonView(t,e){const i=this.bottomButtonSize,s=this.containerMargin,r=(r,n)=>{if(t.title){const e=$text.sizeThatFits({text:t.title,width:o.windowSize.width,font:$font(16)}),n=Math.ceil(e.width)+2*(s+12);r.size.equalTo($size(n,i.height))}else r.size.equalTo(i);r.centerY.equalTo(n.super),n.prev&&n.prev.info.align===e?e===o.align.right?r.right.equalTo(n.prev.left).offset(1.5*-s):r.left.equalTo(n.prev.right).offset(1.5*s):e===o.align.right?r.right.inset(s):r.left.inset(s)},n={type:"button",props:Object.assign({smoothCorners:!1,cornerRadius:5,symbol:t.symbol,title:t.title,id:t.id??$text.uuid,font:$font(16),bgcolor:this.useBlur?$color("clear"):this.buttonBackground,tintColor:o.textColor,titleColor:o.textColor,info:{align:e}},t.menu?{menu:t.menu}:{}),events:Object.assign({},t.tapped?{tapped:t.tapped}:{},t.events),layout:$layout.fill};return this.useBlur?o.blurBox({info:{align:e},style:$blurStyle.ultraThinMaterial,smoothCorners:!1,cornerRadius:5},[n],r):{type:"view",props:{info:{align:e}},views:[n],layout:r}}getBottomBarView(){const t=[],e=[];$device.hasFaceID&&!$device.isIpadPro||t.push({symbol:"globe",tapped:this.keyboardTapped((()=>$keyboard.next())),menu:{pullDown:!0,items:[{title:$l10n("SWITCH_KEYBOARD"),handler:this.keyboardTapped((()=>$keyboard.next()))},{title:$l10n("OPEN_IN_JSBOX"),handler:()=>this.kernel.openInJsbox()}]}}),this.kernel.setting.get("keyboard.switchAfterInsert")&&t.push({symbol:this.getKeyboardSwitchLock()?"lock":"lock.open",id:this.keyboardSwitchLockId,tapped:this.keyboardTapped((()=>this.switchKeyboardSwitchLock()))}),t.push({symbol:"paperplane",menu:{pullDown:!0,asPrimary:!0,items:d.getAddins().reverse().map((t=>({title:t,handler:this.keyboardTapped((()=>$addin.run(t)))})))}}),e.push({title:$l10n("SEND"),tapped:this.keyboardTapped((()=>$keyboard.send()))},{symbol:"delete.left",events:{touchesBegan:this.keyboardTapped((async()=>{$keyboard.delete(),this.continuousDeleteTapticTimer=$delay(this.continuousDeleteDelay,(()=>this.keyboardTapped()())),this.continuousDeleteTimer=$delay(this.continuousDeleteDelay,(()=>{this.deleteTimer=$timer.schedule({interval:this.deleteDelay,handler:()=>$keyboard.delete()})}))})),touchesEnded:()=>{this.deleteTimer?.invalidate(),this.continuousDeleteTimer?.cancel(),this.continuousDeleteTapticTimer?.cancel(),this.deleteTimer=void 0,this.continuousDeleteTimer=void 0}}});const i={type:"button",props:{smoothCorners:!1,cornerRadius:5,title:$l10n("SPACE"),font:$font(16),bgcolor:this.itemBackground,titleColor:o.textColor},events:{tapped:this.keyboardTapped((()=>{$keyboard.insert(" ")}))},layout:(t,i)=>{let s=i.prev;for(let t=0;tthis.getBottomButtonView(t,o.align.left))),...e.map((t=>this.getBottomButtonView(t,o.align.right))),i],layout:(t,e)=>{t.bottom.equalTo(e.super.safeArea).offset(-2),t.left.right.equalTo(e.super.safeArea),t.height.equalTo(this.bottomBarHeight)}}}menuItems(){const t=super.menuItems();return[t[0],t[2]]}itemContainer(t){return this.useBlur?o.blurBox({style:$blurStyle.ultraThinMaterial},t,$layout.fill):{type:"view",props:{bgcolor:this.itemBackground},views:t,layout:$layout.fill}}get matrixTemplate(){return{props:{smoothCorners:!0,cornerRadius:2*this.containerMargin},views:[this.itemContainer([{type:"view",props:{id:"copied",circular:this.copiedIndicatorSize,hidden:!0,bgcolor:$color("green")},layout:(t,e)=>{t.size.equalTo(this.copiedIndicatorSize),t.left.top.inset(this.matrixBoxMargin/2)}},{type:"label",props:{id:"content",lines:0,font:$font(20)},layout:(t,e)=>{t.top.left.right.equalTo(e.super).inset(this.matrixBoxMargin),t.height.lessThanOrEqualTo(e.super).offset(2*-this.matrixBoxMargin-this.tagHeight)}},{type:"label",props:{id:"tag",lines:1,color:this.tagColor,autoFontSize:!0,align:$align.leading},layout:(t,e)=>{t.left.right.equalTo(e.prev),t.height.equalTo(this.tagHeight),t.bottom.equalTo(e.super).inset(this.matrixBoxMargin)}}]),{type:"image",props:{id:"image",hidden:!0},layout:$layout.fill}]}}get itemSelect(){return(t,e)=>{const i=this.clips[e.row];i.image?l.quickLookImage(i.imageOriginal):($keyboard.insert(i.text),this.kernel.setting.get("keyboard.switchAfterInsert")&&!this.getKeyboardSwitchLock()&&$keyboard.next())}}getMatrixView(){const t={type:"matrix",props:{id:this.listId,bgcolor:$color("clear"),menu:{items:this.menuItems()},direction:$scrollDirection.horizontal,square:!0,alwaysBounceVertical:!1,showsHorizontalIndicator:!1,alwaysBounceHorizontal:!0,columns:1,spacing:this.matrixBoxMargin,template:this.matrixTemplate},layout:(t,e)=>{t.top.inset(0),t.width.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom).offset(-1*(this.bottomBarHeight-this.navHeight))},events:{ready:()=>this.listReady(),didSelect:this.itemSelect,itemSize:(t,e)=>{let i=this.keyboardHeight-this.navHeight-this.bottomBarHeight;return i-=2*this.matrixBoxMargin,$size(i,i)}}},e=a.createFromViews([t,this.getEmptyBackground(this.listId)]);return e.setProp("id",this.listId+"-container"),e}getListView(){const t=super.getListView();t.setProp("id",this.listId+"-container"),t.layout=(t,e)=>{t.top.equalTo(this.navHeight-1),t.width.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom).offset(-this.bottomBarHeight-this.containerMargin)};const e=t.views[0];e.events.didSelect=this.itemSelect,e.props.separatorColor=$color("lightGray"),e.props.separatorInset=$insets(0,this.horizontalMargin,0,this.horizontalMargin),delete e.events.pulled,e.props.header={props:{height:1}},e.props.style=2;const i=e.props.template.views[0].views;return e.props.template.views[0]=this.itemContainer(i),t}getDataView(){return 0===this.keyboardDisplayMode?this.getListView():this.getMatrixView()}getActionView(){return{type:"view",props:{id:this.actionsId,hidden:!0},views:[this.kernel.actionManager.getActionMiniView((async()=>new s({env:r.keyboard,textBeforeInput:$keyboard.textBeforeInput,textAfterInput:$keyboard.textAfterInput,text:$keyboard.selectedText??await $keyboard.getAllText()})))],layout:(t,e)=>{t.top.equalTo(this.navHeight),t.left.equalTo(this.containerMargin),t.right.equalTo(-this.containerMargin),t.bottom.equalTo(-this.bottomBarHeight)}}}getView(){const t={type:"view",views:[{type:"image",props:{image:this.backgroundImage},layout:$layout.fill},{type:"view",props:{bgcolor:$color("clear",$rgba(0,0,0,.3))},layout:$layout.fill}],layout:$layout.fill};return{type:"view",props:{id:this.keyboardId},views:[this.backgroundImage?t:{},this.getDataView(),this.getTopBarView(),this.getBottomBarView(),this.getActionView()],layout:(t,e)=>{t.width.bottom.equalTo(e.super),t.height.equalTo(this.keyboardHeight)}}}}})),parcelRequire.register("49je6",(function(t,e){var i=parcelRequire("eSp9Z"),s=i.ActionData,r=i.ActionEnv,n=parcelRequire("gxpqj"),a=n.View,o=n.UIKit,l=n.BarButtonItem,h=parcelRequire("imdB1"),c=parcelRequire("ilpYs");t.exports=class extends h{actionsId="today-list-actions";listContainerId="today-list-container";readClipboardButtonId="today-nav-readClipboard";listId="today-list";pageIndexId="today-list-page-index";tabLeftMargin=8;horizontalMargin=15;verticalMargin=5;copiedIndicatorSize=5;fontSize=14;tagHeight=12;tagColor=$color("gray","lightGray");navHeight=34;taptic=1;inLauncher=$app.env===$env.today&&-1===$app.widgetIndex;launcherNavHeight=44;constructor(t){super(t),this.tabItems.push($l10n("ACTIONS")),this.todayActions=new c(this.kernel),this.setClipboarPageSize($widget.mode),this.listPageNow=[0,0],this.listSection=Math.min(this.tabIndex,1),this.setSingleLine()}get isActionPage(){return 2===this.tabIndex}set tabIndex(t){$cache.set("caio.today.tab.index",t)}get tabIndex(){return $cache.get("caio.today.tab.index")??0}listReady(){$widget.modeChanged=t=>{this.setClipboarPageSize(t),this.isActionPage||this.updateList()},this.setClipboarPageSize($widget.mode),this.isActionPage||this.updateList(),this.appListen(),$delay(.5,(()=>this.readClipboard()))}async readClipboard(t=!1){this.isActionPage||$app.env!==$env.today||await super.readClipboard(t)}setClipboarPageSize(t){if(0===t)this.listPageSize=1;else{const t=(($app.env===$env.app?o.windowSize.height:$widget.height)-2*this.navHeight-(this.inLauncher?this.launcherNavHeight:0))/(this.singleLineContentHeight+this.verticalMargin+Math.max(this.tagHeight,this.verticalMargin)),e=Math.floor(t);this.listPageSize=e,t-e>=.6&&this.listPageSize++}}buttonTapped(t,e=!0){return async(...i)=>{e&&this.kernel.setting.get("keyboard.tapticEngine")&&$device.taptic(this.taptic),await t(...i)}}switchTab(t){this.tabIndex=t,this.isActionPage?($(this.listContainerId).hidden=!0,$(this.actionsId).hidden=!1,$(this.readClipboardButtonId).hidden=!0):(this.listSection=t,$(this.actionsId).hidden=!0,$(this.listContainerId).hidden=!1,$(this.readClipboardButtonId).hidden=!1,this.updateList())}getNavBarView(){const t=[{symbol:"square.and.arrow.down.on.square",props:{id:this.readClipboardButtonId,hidden:this.isActionPage},tapped:this.buttonTapped((async t=>{t.start();try{await this.readClipboard(!0),t.done()}catch(e){throw t.cancel(),e}}))}].map((t=>{const e=new l;return e.setAlign(o.align.right).setSymbol(t.symbol).setEvent("tapped",t.tapped).setProps(t.props??{}),e.definition}));return{type:"view",views:[{type:"view",layout:$layout.fill,views:[this.tabView(),...t]}],layout:(t,e)=>{t.top.width.equalTo(e.super),t.height.equalTo(this.navHeight)}}}getBottomBarView(){const t=t=>({type:"button",props:{symbol:t===o.align.left?"chevron.backward.circle":"chevron.forward.circle",bgcolor:$color("clear"),tintColor:o.textColor},layout:i=>{t===o.align.left?i.left.inset(this.horizontalMargin):i.right.inset(this.horizontalMargin),i.centerY.equalTo(e.super)},events:{tapped:this.buttonTapped((()=>{t===o.align.left?this.clipboardPrevPage():this.clipboardNextPage()}))}}),e={type:"view",views:[t(o.align.left),t(o.align.right),{type:"label",props:{id:this.pageIndexId,align:$align.center,text:this.listPageNow[this.listSection]+1},layout:(t,e)=>{t.bottom.left.right.equalTo(e.super.safeArea),t.center.equalTo(e.super)}}],layout:(t,e)=>{t.bottom.left.right.equalTo(e.super.safeArea),t.height.equalTo(this.navHeight)}};return e}delete(...t){super.delete(...t),this.updateList()}updateList(t=!1){t&&this.setNeedReload();const e=this.listPageNow[this.listSection]*this.listPageSize,i=e+this.listPageSize,s=this.clips;$(this.listId).data=s.slice(e,i).map((t=>this.lineData(t,this.copied.uuid===t.uuid)));const r=this.listPageNow[this.listSection]+1,n=Math.ceil(s.length/this.listPageSize);$(this.pageIndexId).text=`${r}/${n}`}clipboardPrevPage(){this.listPageNow[this.listSection]>0&&(this.listPageNow[this.listSection]--,this.updateList())}clipboardNextPage(){const t=Math.ceil(this.clips.length/this.listPageSize);this.listPageNow[this.listSection]this.listReady(),rowHeight:(t,e)=>{const i=this.listPageSize*this.listPageNow[this.listSection],s=this.getByIndex(e.row+i),r=s.hasTag?this.tagHeight:this.verticalMargin,n=s.image?this.imageContentHeight:this.getContentHeight(s.text);return this.verticalMargin+n+r},didSelect:this.buttonTapped(((t,e)=>{const i=this.clips[e.row];i.image?$clipboard.image=i.imageOriginal:(this.setClipboardText(i.text),this.setCopied(i.uuid)),$ui.toast($l10n("COPIED"))}))},layout:(t,e)=>{t.top.width.equalTo(e.super),t.bottom.equalTo(e.super).offset(-this.navHeight)}},this.getBottomBarView()],layout:(t,e)=>{t.top.equalTo(this.navHeight),t.bottom.left.right.equalTo(e.super.safeArea)}}}getActionView(){let t=this.todayActions.getActions();return 0===t.length&&(t=this.todayActions.getAllActions()),{type:"view",props:{id:this.actionsId,hidden:!this.isActionPage},views:[this.kernel.actionManager.getActionMiniView((t=>new s({env:r.today,text:"clipboard"===t.type||"uncategorized"===t.type?$clipboard.text:null})),t)],layout:(t,e)=>{t.top.equalTo(this.navHeight),t.left.right.bottom.equalTo(e.super.safeArea)}}}getView(){return a.create({props:{titleColor:o.textColor,barColor:o.primaryViewBackgroundColor},views:[{type:"view",views:[this.getNavBarView(),this.getActionView(),this.getListView()],layout:$layout.fill}],events:{appeared:async()=>{if($app.env!==$env.today)return;const t=$timer.schedule({interval:0,handler:()=>{$ui.animate({duration:.3,animation:()=>{$ui.vc.ocValue().$view().$setBackgroundColor($color("clear"))},completion:()=>{t.invalidate()}})}})}}})}}})),parcelRequire.register("gD12U",(function(t,e){var i=parcelRequire("gxpqj"),s=i.Logger,r=i.Setting,n=i.FileStorage,a=parcelRequire("2EAPF"),o=parcelRequire("jEwwi").Storage;const l=new n;class h{static widgetInstance(t,...e){if($file.exists(`/scripts/widget/${t}.js`)){const{Widget:i}=require(`./widget/${t}.js`);return new i(...e)}return!1}static kernel(){const t=new s;t.printToFile(l,"logs/widget.log");const e={setting:new r({fileStorage:l,structure:a}),fileStorage:l,print:()=>{},error:e=>{t.error(e)}};e.setting.setReadonly();const i=new o(e);return e.storage=i,e}static renderError(){$widget.setTimeline({render:()=>({type:"text",props:{text:"Invalid argument"}})})}static renderClipboard(){(new r).setReadonly();h.widgetInstance("Clipboard",h.kernel()).render()}static render(t=$widget.inputValue){"Clipboard"===(t=t??"Clipboard")?h.renderClipboard():h.renderError()}}t.exports={Widget:h,run:()=>{h.render()}}})),parcelRequire.register("ljE8b",(function(t,e){var i=parcelRequire("34tpw").AppKernelBase;class s extends i{constructor(){super(),this.setting.setReadonly()}addOpenInJsboxButton(){this.useJsboxNav(),this.setNavButtons([{image:$image("assets/icon.png"),handler:()=>this.openInJsbox()}])}}class r{static kernel=$app.env!==$env.widget?new s:void 0;static renderKeyboardUI(){this.kernel.addOpenInJsboxButton();const t=new(parcelRequire("7eNYp"))(this.kernel);this.kernel.KeyboardRender(t.getView())}static renderTodayUI(){this.kernel.addOpenInJsboxButton();const t=new(parcelRequire("49je6"))(this.kernel);this.kernel.UIRender(t.getView())}}t.exports={run:()=>{$app.env===$env.today?r.renderTodayUI():$app.env===$env.keyboard&&r.renderKeyboardUI()}}})),$app.strings={en:{ALERT_INFO:"Alert",NONE:"Nothing",DONE:"Done",CLOSE:"Close",FAILED_TO_LOAD_VIEW:"Faild to load view",VIEW_NOT_PROVIDED:"The view is not provided",UNCATEGORIZED:"Uncategorized",SHARE:"Share",CLICK_TO_OPEN_JSBOX:"Click the title to open the main app.",CLIPS:"Clips",CLIPBOARD:"Clipboard",UNIVERSAL_CLIPBOARD:"Universal Clipboard",UNIVERSAL_CLIPBOARD_TIPS:"Universal Clipboard allows you to copy something on your iPhone, and paste it on your Mac–or vice-versa–using iCloud.",CLIPS_STRUCTURE_ERROR:"Clips data structure is abnormal",CLIPBOARD_NO_CHANGE:"Clipboard no change",RECYCLE_BIN:"Recycle Bin",ADD:"Add",TAG:"Tag",ADD_TAG:"Add Tag",EDIT:"Edit",SEARCH:"Search",SEARCH_HISTORY:"Search History",SEARCH_RESULT:"Search Result",NO_SEARCH_RESULT:"No item found.",FAVORITE:"Favorite",COPY:"Copy",COPIED:"Copied",SORT:"Sort",ACTIONS:"Actions",MORE_ACTIONS:"More Actions",PREVIEW:"Preview",MAX_ITEM_LENGTH:"Line Limit",TEXT_MAX_LENGTH:"Display Character Length",AUTO_SAVE:"Auto Save",AUTO_SYNC:"Auto Sync",SYNC_NOW:"Sync Now",UNZIP_FAILED:"Unzip file failed",REBUILD:"Rebuild",REBUILD_DATABASE:"Rebuild Database",REBUILD_DATABASE_ALERT:"Rebuilding the database will lose the order information, do you want to confirm the rebuild?",DELETE_ALL_DATA:"Delete All Data",DELETE_ALL_DATA_ALERT:"Are you sure you want to delete all your data?",DELETE_DATA:"Delete Data",DELETE_TABLE:"Delete all data from `${table}`?",SELECT_ALL:"Select All",DESELECT_ALL:"Deselect All",EDITOR:"Editor",CREATE_NEW:"Create New",CREATE_NEW_ACTION:"New Action",CREATE_NEW_TYPE:"New Category",TYPE_ALREADY_EXISTS:"This category already exists",EDIT_DETAILS:"Edit Details",EDIT_SCRIPT:"Edit Script",INFORMATION:"Information",NAME:"Name",ICON:"Icon",TYPE:"Category",DESCRIPTION:"Description",CODE:"Code",TEXT_INSETS:"Text bottom margin",SHOW_LINE_NUMBER:"Show line number",LIGHT_MODE_THEME:"Light Mode Theme",DARK_MODE_THEME:"Dark Mode Theme",SAVE:"Save",SAVE_SUCCESS:"Save success",SAVE_ERROR:"Save failed",DELETE:"Delete",CONFIRM:"Confirm",DELETE_CONFIRM_MSG:"Are you sure you want to delete?",DELETE_SUCCESS:"Delete success",DELETE_ERROR:"Delete failed",IMPORT_EXAMPLE_ACTIONS:"Import example actions",REBUILD_ACTION_DATABASE:"Rebuild Action Database",REBUILD_ACTION_DATABASE_ALERT_TITLE:"Are you sure you want to rebuild?",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:"Rebuild also deletes the data saved in WebDAV Drive! (If enabled)",EXPORT:"Export",IMPORT:"Import",FILE_TYPE_ERROR:"File type does not match",OVERWRITE_ALERT:"This operation will overwrite the current data. Do you want to continue?",UNABLE_CREATE_ACTION:"Unable to create action",ACTION_NAME_ALREADY_EXISTS:"Action `${name}` already exists",KEYBOARD:"Keyboard",KEYBOARD_HEIGHT:"Keyboard Height",USE_BLUR:"Use Blur",BACKGROUND_IMAGE:"Background Image",DELETE_DELAY:"Delete Delay",SWITCH_AFTER_INSERT:"Switch After Insert",JSBOX_TOOLBAR:"JSBox Toolbar",QUICK_START_SCRIPTS:"Quick Start Scripts",SEND:"Send",OPEN_IN_JSBOX:"Open in JSBox",SWITCH_KEYBOARD:"Switch Keyboard",TAPTIC_ENGINE:"Taptic Engine",TAPTIC_ENGINE_LEVEL:"Taptic Engine Level",TAPTIC_ENGINE_FOR_DELETE:"Taptic Engine For Delete",SPACE:"Space",ALL_SCRIPTS:"All Scripts",SELECT_SCRIPTS:"Select Scripts",CHECK_UPDATE:"Check Update",UPDATE:"Update",WIDGET:"Widget",RECENT:"Recent",CLICK_ACTION:"Click Action",TODAY_WIDGET:"Today Widget",PREV_PAGE:"Prev",NEXT_PAGE:"Next",DISPLAY_MODE:"Display Mode",CLASSIC:"Classic",MODERN:"Modern",FILE_MANAGEMENT:"File Management","compatibility.rebuildUserAction.alert.title":"We need to rebuild some of the action!","compatibility.rebuildUserAction.alert.message":"If you tap the OK button, the following actions will be rebuilt:","compatibility.rebuildUserAction.alert.message2":"Only the action logic will be changed, and the name and icon will remain as it is.",EXPERIMENTAL:"Experimental",SYNC_ACTIONS:"Sync Actions",SYNCING:"Syncing...",LAST_SYNC_AT:"Last sync at: ",MODIFIED:"Modified: ",HOST:"Host",USER:"User",PASSWORD:"Password",BASEPATH:"Base Path",DATA_CONFLICT:"A data synchronization conflict occurred",DATA_CONFLICT_MESSAGE:"Select the data you want to keep",WEBDAV_DATA:"WebDAV data",LOCAL_DATA:"Local data",ACTION_SAFETY_WARNING:"Action safety warning",ACTION_PERMISSION_REQUEST:"Action permission request",ACTION_RESET_NAME_WARNING:"Action `${name}` is attempting to change its name to `${to_name}`, which may result in it gaining all permissions associated with `${to_name}`.",ACTION_NETWORK_PERMISSION_MESSAGE:"Would you like to grant Action `${name}` network permissions?"},"zh-Hans":{ALERT_INFO:"提示",NONE:"什么都没有",DONE:"完成",CLOSE:"关闭",FAILED_TO_LOAD_VIEW:"加载视图失败",VIEW_NOT_PROVIDED:"未提供该视图",UNCATEGORIZED:"未分类",SHARE:"分享",CLICK_TO_OPEN_JSBOX:"点击标题打开主应用。",CLIPS:"剪切板",CLIPBOARD:"剪切板",UNIVERSAL_CLIPBOARD:"通用剪贴板",UNIVERSAL_CLIPBOARD_TIPS:"用剪贴板允许您在 iPhone 上复制某些内容,然后使用 iCloud 将其粘贴到 Mac 上(反之亦然)。",CLIPS_STRUCTURE_ERROR:"剪切板数据结构异常",CLIPBOARD_NO_CHANGE:"剪切板无变化",RECYCLE_BIN:"回收站",ADD:"添加",TAG:"标签",ADD_TAG:"添加标签",EDIT:"编辑",SEARCH:"搜索",SEARCH_HISTORY:"搜索历史",SEARCH_RESULT:"搜索结果",NO_SEARCH_RESULT:"搜索无结果",FAVORITE:"收藏",COPY:"复制",COPIED:"已复制",SORT:"排序",ACTIONS:"动作",MORE_ACTIONS:"更多动作",PREVIEW:"预览",MAX_ITEM_LENGTH:"行数限制",TEXT_MAX_LENGTH:"显示字符长度",AUTO_SAVE:"自动保存",AUTO_SYNC:"自动同步",SYNC_NOW:"立即同步",UNZIP_FAILED:"解压文件失败",REBUILD:"重建",REBUILD_DATABASE:"重建数据库",REBUILD_DATABASE_ALERT:"重建数据库将会丢失顺序信息,是否确认重建?",DELETE_ALL_DATA:"删除所有数据",DELETE_ALL_DATA_ALERT:"确定要删除所有数据吗?",DELETE_DATA:"删除数据",DELETE_TABLE:"删除 `${table}` 的所有数据?",SELECT_ALL:"全选",DESELECT_ALL:"取消全选",EDITOR:"编辑器",CREATE_NEW:"新建",CREATE_NEW_ACTION:"新建动作",CREATE_NEW_TYPE:"新建分类",TYPE_ALREADY_EXISTS:"该类别已经存在",EDIT_DETAILS:"编辑信息",EDIT_SCRIPT:"编辑脚本",INFORMATION:"信息",NAME:"名称",ICON:"图标",TYPE:"分类",DESCRIPTION:"描述",CODE:"代码",TEXT_INSETS:"文本下边距",SHOW_LINE_NUMBER:"显示行号",LIGHT_MODE_THEME:"浅色模式主题",DARK_MODE_THEME:"深色模式主题",SAVE:"保存",SAVE_SUCCESS:"保存成功",SAVE_ERROR:"保存失败",DELETE:"删除",CONFIRM:"确认",DELETE_CONFIRM_MSG:"确认要删除吗?",DELETE_SUCCESS:"删除成功",DELETE_ERROR:"删除失败",IMPORT_EXAMPLE_ACTIONS:"导入示例动作",REBUILD_ACTION_DATABASE:"重建动作库",REBUILD_ACTION_DATABASE_ALERT_TITLE:"您确认要重建?",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:"重建会同时删除保存在 WebDAV 中的数据!(如果开启的话)",EXPORT:"导出",IMPORT:"导入",FILE_TYPE_ERROR:"文件类型不符",OVERWRITE_ALERT:"该操作将会覆盖当前数据,是否继续?",UNABLE_CREATE_ACTION:"无法创建动作",ACTION_NAME_ALREADY_EXISTS:"动作 `${name}` 已存在",KEYBOARD:"键盘",KEYBOARD_HEIGHT:"键盘高度",USE_BLUR:"使用模糊效果",BACKGROUND_IMAGE:"背景图片",DELETE_DELAY:"删除延时",SWITCH_AFTER_INSERT:"输入后切换",JSBOX_TOOLBAR:"JSBox 工具栏",QUICK_START_SCRIPTS:"快速启动脚本",SEND:"发送",OPEN_IN_JSBOX:"在 JSBox 中打开",SWITCH_KEYBOARD:"切换键盘",TAPTIC_ENGINE:"触感反馈",TAPTIC_ENGINE_LEVEL:"触感反馈强度",TAPTIC_ENGINE_FOR_DELETE:"删除按钮触感反馈",SPACE:"空格",ALL_SCRIPTS:"所有脚本",SELECT_SCRIPTS:"选择脚本",CHECK_UPDATE:"检查更新",UPDATE:"更新",WIDGET:"小组件",RECENT:"最近内容",CLICK_ACTION:"点击事件",TODAY_WIDGET:"通知中心小组件",PREV_PAGE:"上一页",NEXT_PAGE:"下一页",DISPLAY_MODE:"显示模式",CLASSIC:"经典",MODERN:"现代",FILE_MANAGEMENT:"文件管理","compatibility.rebuildUserAction.alert.title":"我们需要重建部分动作!","compatibility.rebuildUserAction.alert.message":"如果您点击 好,以下动作将会被重建:","compatibility.rebuildUserAction.alert.message2":"只有动作逻辑会被更改,名称和图标将维持现状。",EXPERIMENTAL:"实验功能",SYNC_ACTIONS:"动作同步",SYNCING:"正在同步...",LAST_SYNC_AT:"最后同步:",MODIFIED:"最近修改:",HOST:"Host",USER:"User",PASSWORD:"Password",BASEPATH:"Base Path",DATA_CONFLICT:"数据同步发生冲突",DATA_CONFLICT_MESSAGE:"请选择想要保留的数据",WEBDAV_DATA:"WebDAV 数据",LOCAL_DATA:"本地数据",ACTION_SAFETY_WARNING:"动作安全警告",ACTION_PERMISSION_REQUEST:"动作权限申请",ACTION_RESET_NAME_WARNING:"动作 `${name}` 正在尝试将名称改为 `${to_name}`,这可能导致其获取 `${to_name}` 的所有权限",ACTION_NETWORK_PERMISSION_MESSAGE:"是否允许动作 `${name}` 获取网络权限?"}},$app.theme="auto",$app.minSDKVer="2.19.0",$app.minOSVer="14.0.0",$app.idleTimerDisabled=!1,$app.keyboardToolbarEnabled=!0,$app.rotateDisabled=!1,__INFO__={name:"CAIO",version:"1.10.8",author:"ipuppet",module:!1},__README__={"README.md":"# CAIO\r\n\r\n> Clipboard all in one.\r\n> \r\n> A Clipboard tool based on JSBox.\r\n\r\nSupport for home widget and notification center widgets.\r\n\r\n## Build Taio Action\r\n\r\nBuild script depend on [Parcel](https://parceljs.org/).\r\n\r\n```shell\r\nnpm i -g parcel\r\nnpm run build\r\n```\r\n\r\nYou can also use the packaged files directly [dist/CAIO-en.json](./dist/CAIO-en.json).\r\n\r\n## Actions\r\n\r\n> For details on how to write, see `scripts/action/README.md` or the book button in the upper right corner of the `Action` edit page in the app.\r\n\r\n### `Action` data difference in different environments\r\n\r\n- The data processed by the `Action` button at the top of the home page is the currently copied content.\r\n- The data processed by the `Action` menu that pops up by long-pressing the list is the selected content.\r\n- The data processed by the `Action` button in the editor is whatever is being edited.\r\n\r\n\r\n## Today Widget\r\n\r\n> Click to copy, long press to trigger the action.\r\n\r\nPlease try to avoid using the Today Widget when JSBox is running CAIO.\r\n\r\n## WebDAV\r\n\r\n> Sync data with WebDAV.\r\n\r\nConfig Example: \r\nHost: https://example.com/dav \r\nUser: guest \r\nPassword: password123 \r\nBast Path: /path/to/save/appdata\r\n","README_CN.md":"# CAIO\r\n\r\n> Clipboard all in one.\r\n> \r\n> A Clipboard tool based on JSBox.\r\n\r\n支持桌面小组件和通知中心小组件\r\n\r\n## 构建 Taio 动作\r\n\r\n构建脚本依赖 [Parcel](https://parceljs.org/)\r\n\r\n```shell\r\nnpm i -g parcel\r\nnpm run build\r\n```\r\n\r\n您也可以直接使用已打包好的文件 [dist/CAIO-zh-Hans.json](./dist/CAIO-zh-Hans.json)\r\n\r\n## Actions\r\n\r\n> 编写方式详见 `scripts/action/README.md` 或应用内 `Action` 编辑页面右上角图书按钮。\r\n\r\n### 不同环境中 `Action` 数据区别\r\n\r\n- 首页顶部 `Action` 按钮处理的数据为当前复制的内容\r\n- 长按列表弹出的 `Action` 菜单处理的数据为被选中的内容\r\n- 编辑器中顶部 `Action` 按钮(闪电图形按钮)处理的数据为正在编辑的所有内容\r\n\r\n\r\n## Today Widget\r\n\r\n> 点击复制,长按触发动作。\r\n\r\n请尽量避免在 JSBox 运行 CAIO 时使用 Today Widget\r\n\r\n## WebDAV\r\n\r\n> 通过 WebDAV 同步数据\r\n\r\n示例配置: \r\nHost: https://example.com/dav \r\nUser: guest \r\nPassword: password123 \r\nBast Path: /path/to/save/appdata\r\n"},__ACTIONS__={clipboard:{B23Clean:{"config.json":'{\n "icon": "trash",\n "color": "#FF0000",\n "name": "b23 清除追踪"\n}',"main.js":'/**\n * @typedef {import("../../action").Action} Action\n */\nclass MyAction extends Action {\n l10n() {\n return {\n "zh-Hans": {\n "b23clean.converting": "正在转换...",\n "b23clean.noUrl": "未检测到链接",\n "b23clean.noBiliUrl": "未检测到 bilibili 链接",\n "b23clean.success": "已转换为 BV 视频链接",\n "b23clean.noChange": "无变化",\n "b23clean.multipleLinks": "多条链接仅在编辑模式下可用。"\n },\n en: {\n "b23clean.converting": "Converting...",\n "b23clean.noUrl": "No link detected",\n "b23clean.noBiliUrl": "bilibili link not detected",\n "b23clean.success": "Converted to BV video link",\n "b23clean.noChange": "No change",\n "b23clean.multipleLinks": "Multiple links are only available in edit mode."\n }\n }\n }\n\n async cleanUrl(b23url) {\n if (b23url.indexOf("bilibili.com") === -1 && b23url.indexOf("b23.tv") === -1) {\n throw new Error($l10n("b23clean.noBiliUrl"))\n }\n\n let url = b23url\n if (b23url.indexOf("b23.tv") >= 0) {\n const resp = await $http.get(b23url)\n url = resp.response.url\n }\n\n const queryStart = url.indexOf("?")\n if (queryStart > -1) {\n url = url.substring(0, queryStart - 1)\n }\n\n return url\n }\n\n /**\n * 系统会调用 do() 方法\n */\n async do() {\n $ui.toast($l10n("b23clean.converting"), 1000)\n\n try {\n const b23url = this.getUrls()\n if (b23url.length === 0) {\n throw new Error($l10n("b23clean.noUrl"))\n }\n\n if (b23url.length === 1) {\n let url = await this.cleanUrl(b23url[0])\n $ui.clearToast()\n $ui.alert({\n title: $l10n("b23clean.success"),\n message: url,\n actions: [\n { title: $l10n("OK") },\n {\n title: $l10n("COPY"),\n handler: () => {\n $clipboard.text = url\n $ui.success($l10n("COPIED"))\n }\n }\n ]\n })\n } else {\n if (this.env !== ActionEnv.editor) {\n $ui.toast($l10n("b23clean.multipleLinks"))\n return\n }\n let flag = false\n for (let i = 0; i < b23url.length; i++) {\n try {\n const url = b23url[i].trim()\n const replacedUrl = await this.cleanUrl(url)\n flag = true\n\n if (url !== replacedUrl) {\n const newText = this.text.replace(url, replacedUrl)\n this.setContent(newText)\n }\n } catch {}\n }\n if (!flag) {\n throw new Error($l10n("b23clean.noBiliUrl"))\n } else {\n $ui.toast($l10n("b23clean.noChange"))\n }\n }\n } catch (error) {\n $ui.clearToast()\n $delay(0.5, () => $ui.error(error))\n }\n }\n}\n',"README.md":"## B23Clean\r\n\r\n清除 b23.tv 分享链接中的追踪参数,转换为 BV 视频链接。"},CleanClipboard:{"config.json":'{\r\n "icon": "trash",\r\n "color": "#FF0000",\r\n "name": "清除剪切板"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\nclass MyAction extends Action {\r\n l10n() {\r\n return {\r\n "zh-Hans": {\r\n "clipboard.clean.success": "剪切板已清空"\r\n },\r\n en: {\r\n "clipboard.clean.success": "Clipboard is cleaned"\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * 系统会调用 do() 方法\r\n */\r\n do() {\r\n $clipboard.clear()\r\n $ui.success($l10n("clipboard.clean.success"))\r\n }\r\n}\r\n',"README.md":"## CleanClipboard\r\n\r\n清空当前剪切板内容。"},DownloadFromUrl:{"config.json":'{\r\n "icon": "square.and.arrow.down",\r\n "color": "#FF0099",\r\n "name": "从链接下载"\r\n}',"main.js":'class MyAction extends Action {\r\n async downloadContent(url) {\r\n const response = await $http.get({\r\n url,\r\n showsProgress: true\r\n })\r\n if (response.error) {\r\n $ui.alert(response.error.localizedDescription)\r\n } else {\r\n return response\r\n }\r\n }\r\n\r\n async do() {\r\n const url = this.getUrls()\r\n let response = undefined\r\n if (url.length > 1) {\r\n $ui.menu({\r\n items: url,\r\n handler: async (title, index) => {\r\n response = await this.downloadContent(url[index])\r\n }\r\n })\r\n } else if (url.length === 1) {\r\n response = await this.downloadContent(url[0])\r\n } else {\r\n $ui.warning("未检测到链接")\r\n return\r\n }\r\n $share.sheet([\r\n {\r\n name: response.response.suggestedFilename,\r\n data: response.data\r\n }\r\n ])\r\n return response\r\n }\r\n}\r\n',"README.md":"## DownloadFromUrl\r\n\r\n从链接下载内容,如 js 文件内容等。"},GetFromWin:{"config.json":'{\n "icon": "square.and.arrow.down",\n "color": "#33CC33",\n "name": "读取 clipsync"\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\nclass MyAction extends Action {\r\n async getIp(refresh = false) {\r\n let address = $cache.get("caio.action.clipsync.address")\r\n if (refresh || !address) {\r\n address = await $input.text({\r\n placeholder: "Address",\r\n text: $cache.get("caio.action.clipsync.address")\r\n })\r\n }\r\n\r\n $cache.set("caio.action.clipsync.address", address)\r\n\r\n if (!address.startsWith("http")) {\r\n address = "http://" + address\r\n }\r\n\r\n return address\r\n }\r\n\r\n async do() {\r\n let address = await this.getIp()\r\n\r\n $ui.toast("Loading...", 5)\r\n try {\r\n const resp = await this.request(address + "/api/clip", "GET")\r\n if (resp.data.status) {\r\n $ui.success("success")\r\n $clipboard.text = resp.data.data\r\n if ($app.env === $env.keyboard) {\r\n $keyboard.insert(resp.data.data)\r\n }\r\n }\r\n } catch (error) {\r\n $ui.clearToast()\r\n $ui.alert({\r\n title: "Error",\r\n message: String(error),\r\n actions: [\r\n { title: "OK" },\r\n {\r\n title: "Reset Adress",\r\n handler: () => this.getIp(true)\r\n }\r\n ]\r\n })\r\n }\r\n }\r\n}\r\n',"README.md":"## GetFromWin\r\n\r\n通 clipsync 读取 PC 剪切板。\r\n\r\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\r\n"},OpenUrl:{"config.json":'{\r\n "icon": "link",\r\n "color": "#FF0099",\r\n "name": "打开链接"\r\n}',"main.js":'class MyAction extends Action {\r\n l10n() {\r\n return {\r\n "zh-Hans": {\r\n "openLink.nourl": "未检测到链接"\r\n },\r\n en: {\r\n "openLink.nourl": "No link detected"\r\n }\r\n }\r\n }\r\n\r\n openUrl(url) {\r\n $app.openURL(url.trim())\r\n }\r\n\r\n do() {\r\n const url = this.getUrls()\r\n if (url.length > 1) {\r\n $ui.menu({\r\n items: url,\r\n handler: (title, index) => {\r\n this.openUrl(url[index])\r\n }\r\n })\r\n } else if (url.length === 1) {\r\n this.openUrl(url[0])\r\n } else {\r\n $ui.warning($l10n("openLink.nourl"))\r\n }\r\n }\r\n}\r\n',"README.md":"## OpenUrl\r\n\r\n提取文本中的URL并打开。"},RawRepoConverter:{"config.json":'{\r\n "icon": "link",\r\n "color": "#FF0099",\r\n "name": "RawRepoConverter"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\nclass MyAction extends Action {\r\n #component\r\n\r\n get component() {\r\n if (!this.#component) {\r\n const url = String(this.text)\r\n const path = url.substring(url.indexOf("/", "https://".length) + 1)\r\n this.#component = path.split("/")\r\n }\r\n return this.#component\r\n }\r\n\r\n l10n() {\r\n return {\r\n "zh-Hans": {\r\n "openLink.nourl": "未检测到链接"\r\n },\r\n en: {\r\n "openLink.nourl": "No link detected"\r\n }\r\n }\r\n }\r\n\r\n githubusercontent() {\r\n const user = this.component[0],\r\n repository = this.component[1],\r\n branch = this.component[2],\r\n file = this.component.slice(3).join("/")\r\n return `https://github.com/${user}/${repository}/blob/${branch}/${file}`\r\n }\r\n\r\n github() {\r\n const user = this.component[0],\r\n repository = this.component[1],\r\n blob = this.component[2],\r\n branch = this.component[3],\r\n file = this.component.slice(4).join("/")\r\n return `https://raw.githubusercontent.com/${user}/${repository}/${branch}/${file}`\r\n }\r\n\r\n do() {\r\n let result\r\n const url = String(this.text)\r\n if (url.includes("raw.githubusercontent.com")) {\r\n result = this.githubusercontent(url)\r\n } else if (url.includes("github.com")) {\r\n if (url.includes("?raw=true")) {\r\n result = url.replace("?raw=true", "")\r\n } else {\r\n result = this.github()\r\n }\r\n } else {\r\n $ui.warning($l10n("openLink.nourl"))\r\n return\r\n }\r\n\r\n $ui.success($l10n("COPIED"))\r\n $clipboard.text = result\r\n }\r\n}\r\n',"README.md":"## RawRepoConverter\r\n\r\nGithub Raw 链接和 Repository 链接转换器\r\n"},SendToWin:{"config.json":'{\r\n "icon": "square.and.arrow.up",\r\n "color": "#33CC33",\r\n "name": "推送 clipsync"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\nclass MyAction extends Action {\r\n async getIp(refresh = false) {\r\n let address = $cache.get("caio.action.clipsync.address")\r\n if (refresh || !address) {\r\n address = await $input.text({\r\n placeholder: "Address",\r\n text: $cache.get("caio.action.clipsync.address")\r\n })\r\n }\r\n\r\n $cache.set("caio.action.clipsync.address", address)\r\n\r\n if (!address.startsWith("http")) {\r\n address = "http://" + address\r\n }\r\n\r\n return address\r\n }\r\n\r\n async do() {\r\n let address = await this.getIp()\r\n\r\n $ui.toast("Loading...", 5)\r\n try {\r\n const resp = await this.request(address + "/api/clip", "POST", {\r\n data: this.text\r\n })\r\n if (resp.data.status) {\r\n $ui.success("success")\r\n }\r\n } catch (error) {\r\n $ui.clearToast()\r\n $ui.alert({\r\n title: "Error",\r\n message: String(error),\r\n actions: [\r\n { title: "OK" },\r\n {\r\n title: "Reset Adress",\r\n handler: () => this.getIp(true)\r\n }\r\n ]\r\n })\r\n }\r\n }\r\n}\r\n',"README.md":"## SendToWin\r\n\r\n通 clipsync 推送剪切板至 PC。\r\n\r\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\r\n"},Tokenize:{"config.json":'{\r\n "icon": "pencil.and.ellipsis.rectangle",\r\n "color": "#0099FF",\r\n "name": "分词复制"\r\n}',"main.js":'class MyAction extends Action {\r\n getView() {\r\n const color = {\r\n background: {\r\n normal: $color("#E7F2FF", "#E7F2FF"),\r\n highlight: $color("##074FF", "#BBDAFF")\r\n },\r\n text: {\r\n normal: $color("##074FF", "##074FF"),\r\n highlight: $color("#FFFFFF", "#ADADAD")\r\n }\r\n }\r\n const fontSize = 16\r\n const edges = 10\r\n return {\r\n type: "matrix",\r\n layout: $layout.fill,\r\n props: {\r\n spacing: edges,\r\n data: this.results.map(item => ({ label: { text: item } })),\r\n template: {\r\n views: [{\r\n type: "label",\r\n props: {\r\n id: "label",\r\n align: $align.center,\r\n cornerRadius: edges,\r\n bgcolor: color.background.normal,\r\n font: $font(fontSize),\r\n textColor: color.text.normal\r\n },\r\n layout: $layout.fill\r\n }]\r\n }\r\n },\r\n events: {\r\n highlighted: () => { },\r\n itemSize: (sender, indexPath) => {\r\n const width = fontSize * this.results[indexPath.item].length + 1\r\n if (this.maxtrixItemHeight === undefined)\r\n this.maxtrixItemHeight = fontSize + edges * 2\r\n return $size(width + edges * 2, this.maxtrixItemHeight)\r\n },\r\n didSelect: (sender, indexPath) => {\r\n const index = this.selected.indexOf(indexPath.item)\r\n const label = sender.cell(indexPath).get("label")\r\n if (index === -1) {\r\n this.selected.push(indexPath.item)\r\n label.bgcolor = color.background.highlight\r\n label.textColor = color.text.highlight\r\n } else {\r\n this.selected.splice(index, 1)\r\n label.bgcolor = color.background.normal\r\n label.textColor = color.text.normal\r\n }\r\n }\r\n }\r\n }\r\n }\r\n /**\r\n * 系统会调用 do() 方法\r\n */\r\n do() {\r\n this.selected = []\r\n this.results = []\r\n $text.tokenize({\r\n text: this.text,\r\n handler: results => {\r\n this.results = results\r\n this.pageSheet({\r\n view: this.getView(),\r\n done: () => {\r\n const result = []\r\n this.selected.sort().forEach(i => {\r\n result.push(this.results[i])\r\n })\r\n if (result.length > 0) {\r\n const text = result.join("")\r\n $clipboard.text = text\r\n $ui.alert({\r\n title: "完成",\r\n message: `已复制内容:${text}`\r\n })\r\n }\r\n }\r\n })\r\n }\r\n })\r\n }\r\n}\r\n',"README.md":"## Tokenize\r\n\r\n将文本分词处理后复制。"}},editor:{PreviewMarkdown:{"config.json":'{\r\n "icon": "book",\r\n "color": "#9900CC",\r\n "name": "预览Markdown"\r\n}',"main.js":'class MyAction extends Action {\r\n do() {\r\n this.pageSheet({\r\n view: {\r\n type: "markdown",\r\n props: { content: this.text },\r\n layout: $layout.fill\r\n }\r\n })\r\n }\r\n}\r\n',"README.md":"## PreviewMarkdown\r\n\r\n预览Markdown。"},SelectedText:{"config.json":'{\r\n "icon": "crop",\r\n "color": "#6699CC",\r\n "name": "选中的文本"\r\n}',"main.js":"class MyAction extends Action {\r\n do() {\r\n if (this.selectedRange.length > 0) {\r\n const selectedText = this.text\r\n $ui.alert(selectedText)\r\n }\r\n }\r\n}\r\n","README.md":"## SelectedText\r\n\r\n显示选中的文本。"}},uncategorized:{ActionEditPreview:{"config.json":'{\r\n "icon": "play",\r\n "color": "#FF0000",\r\n "name": "编辑动作即时预览示例"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n * @typedef {import("../../action").ActionData} ActionData\r\n * @typedef {import("../../action").ActionEnv} ActionEnv\r\n */\r\n\r\nclass MyAction extends Action {\r\n preview() {\r\n return new ActionData({\r\n text: "hello word"\r\n })\r\n }\r\n\r\n async do() {\r\n try {\r\n if (this.env !== ActionEnv.build) {\r\n $ui.toast("action editor only")\r\n return\r\n }\r\n return this.text\r\n } catch (error) {\r\n $ui.alert(error)\r\n }\r\n }\r\n}\r\n',"README.md":"## ActionEditPreview\r\n\r\n编辑动作即时预览示例。"},DeleteClips:{"config.json":'{\r\n "icon": "trash",\r\n "color": "#FF0000",\r\n "name": "删除所有剪切板"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\n\r\nclass MyAction extends Action {\r\n async do() {\r\n try {\r\n const action = await this.clearAllClips()\r\n if (action) {\r\n $ui.success($l10n("DONE"))\r\n }\r\n } catch (error) {\r\n $ui.error(error)\r\n }\r\n }\r\n}\r\n',"README.md":"## DeleteClips\r\n\r\n删除所有已保存的剪切板(不包括收藏)。"},DisplayClipboard:{"config.json":'{\r\n "icon": "option",\r\n "color": "#FF6633",\r\n "name": "显示剪切板"\r\n}',"main.js":'/**\r\n * @typedef {import("../../action").Action} Action\r\n */\r\n\r\nclass MyAction extends Action {\r\n do() {\r\n const image = $clipboard.image\r\n if (image) {\r\n this.quickLookImage(image)\r\n } else {\r\n this.pageSheet({\r\n view: {\r\n type: "label",\r\n props: {\r\n lines: 0,\r\n text: $clipboard.text,\r\n align: $align.center\r\n },\r\n layout: $layout.fill\r\n }\r\n })\r\n }\r\n }\r\n}\r\n',"README.md":"## DisplayClipboard\r\n\r\n显示当前剪切板内的内容。"},ExportAllContent:{"config.json":'{\r\n "icon": "square.and.arrow.up",\r\n "color": "#FF3300",\r\n "name": "导出数据"\r\n}',"main.js":'class MyAction extends Action {\r\n do() {\r\n const data = this.getAllClips()\r\n if (data.clips.length > 0 || data.favorite.length > 0) {\r\n $share.sheet(JSON.stringify(data, null, 2))\r\n } else {\r\n $ui.alert("无数据")\r\n }\r\n }\r\n}\r\n',"README.md":"## ExportAllContent\r\n\r\n导出所有保存的数据。"},Replace:{"config.json":'{\r\n "icon": "square.and.arrow.up",\r\n "color": "#FF3300",\r\n "name": "查找替换"\r\n}',"main.js":'function HtmlTemplate(html) {\r\n return `\r\n\r\n\r\n \r\n\r\n\r\n${html}\r\n\r\n\r\n`\r\n}\r\n\r\nclass MyAction extends Action {\r\n do() {\r\n $ui.menu({\r\n items: ["忽略大小写", "大小写敏感", "正则表达式"],\r\n handler: async (title, idx) => {\r\n const patternText = await $input.text({\r\n placeholder: "查找内容"\r\n })\r\n const replaceString = await $input.text({\r\n placeholder: "替换内容"\r\n })\r\n let pattern = undefined\r\n if (idx === 0) {\r\n pattern = new RegExp(`(${patternText})+`, "gi")\r\n } else if (idx === 1) {\r\n pattern = new RegExp(`(${patternText})+`, "g")\r\n } else if (idx === 2) {\r\n pattern = new RegExp(patternText, "g")\r\n }\r\n\r\n const matchResultPreview = this.text.replaceAll(pattern, `${replaceString}`)\r\n const matchResult = this.text.replaceAll(pattern, replaceString)\r\n this.pageSheet({\r\n title: "替换预览",\r\n doneText: "替换",\r\n view: {\r\n type: "web",\r\n props: {\r\n html: HtmlTemplate(matchResultPreview)\r\n },\r\n layout: $layout.fill\r\n },\r\n done: () => {\r\n this.setContent(matchResult)\r\n }\r\n })\r\n }\r\n })\r\n // this.setContent("Hello world!")\r\n }\r\n}\r\n',"README.md":"## Replace\r\n\r\n查找替换"}}},$app.env){case $env.app:case $env.action:$9ca6ee6eeae53f7f$var$AppInstance=parcelRequire("8Makm");break;case $env.today:case $env.keyboard:$9ca6ee6eeae53f7f$var$AppInstance=parcelRequire("ljE8b");break;case $env.widget:$9ca6ee6eeae53f7f$var$AppInstance=parcelRequire("gD12U");break;default:$intents.finish("不支持在此环境中运行"),$ui.render({views:[{type:"label",props:{text:"不支持在此环境中运行",align:$align.center},layout:$layout.fill}]})}$9ca6ee6eeae53f7f$var$AppInstance&&$9ca6ee6eeae53f7f$var$AppInstance.run()})(); \ No newline at end of file diff --git a/main.js b/main.js index effdf1fc..44e3f86e 100644 --- a/main.js +++ b/main.js @@ -1,3 +1,35 @@ -// run app -const app = require("./scripts/app") -app.run() +let AppInstance + +switch ($app.env) { + case $env.app: + case $env.action: + AppInstance = require("./scripts/app") + break + case $env.today: + case $env.keyboard: + AppInstance = require("./scripts/app-lite") + break + case $env.widget: + AppInstance = require("./scripts/widget") + break + + default: + $intents.finish("不支持在此环境中运行") + $ui.render({ + views: [ + { + type: "label", + props: { + text: "不支持在此环境中运行", + align: $align.center + }, + layout: $layout.fill + } + ] + }) + break +} + +if (AppInstance) { + AppInstance.run() +} diff --git a/package.json b/package.json index 9197a239..2599a8f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ -{ - "license": "MIT", - "scripts": { - "build": "node build.js" - } +{ + "license": "MIT", + "scripts": { + "build": "node build.js" + } } \ No newline at end of file diff --git a/scripts/app-base.js b/scripts/app-base.js new file mode 100644 index 00000000..cf7f6601 --- /dev/null +++ b/scripts/app-base.js @@ -0,0 +1,71 @@ +const { Kernel, Logger, FileStorage, Setting, FileManager } = require("./libs/easy-jsbox") +const SettingStructure = require("./setting/setting") +const { Storage } = require("./dao/storage") +const Clips = require("./ui/clips") +const ActionManager = require("./ui/components/action-manager") + +/** + * @typedef {AppKernelBase} AppKernelBase + */ +class AppKernelBase extends Kernel { + static fileStorage = new FileStorage() + + logPath = "logs" + logFile = "caio.log" + logFilePath = FileStorage.join(this.logPath, this.logFile) + + #storage + + constructor() { + super() + // FileStorage + this.fileStorage = AppKernelBase.fileStorage + // Logger + this.logger = new Logger() + this.logger.printToFile(this.fileStorage, this.logFilePath) + // Setting + this.setting = new Setting({ + fileStorage: this.fileStorage, + structure: SettingStructure + }) + this.setting.setReadonly() + this.initComponents() + } + + get storage() { + if (!this.#storage) { + this.print("init storage") + this.#storage = new Storage(this) + } + return this.#storage + } + + error(message) { + if (this.fileStorage.exists(this.logFilePath)) { + const logFileSize = this.fileStorage.readSync(this.logFilePath)?.info?.size ?? 0 + if (logFileSize > 1024 * 10) { + const dist = FileStorage.join(this.logPath, `caio.${Date.now()}.log`) + this.fileStorage.move(this.logFilePath, dist) + } + } + + if (message instanceof Error) { + message = `${message}\n${message.stack}` + } + super.error(message) + this.logger.error(message) + } + + initComponents() { + // Clips + this.clips = new Clips(this) + // ActionManager + this.actionManager = new ActionManager(this) + // FileManager + this.fileManager = new FileManager() + } +} + +module.exports = { + AppKernelBase +} diff --git a/scripts/app-lite.js b/scripts/app-lite.js new file mode 100644 index 00000000..d652b6c0 --- /dev/null +++ b/scripts/app-lite.js @@ -0,0 +1,58 @@ +const { AppKernelBase } = require("./app-base") + +/** + * @typedef {AppKernel} AppKernel + */ +class AppKernel extends AppKernelBase { + constructor() { + super() + + this.setting.setReadonly() + } + + addOpenInJsboxButton() { + this.useJsboxNav() + this.setNavButtons([ + { + image: $image("assets/icon.png"), + handler: () => this.openInJsbox() + } + ]) + } +} + +class AppUI { + // 小组件模式下不初始化 AppKernel + static kernel = $app.env !== $env.widget ? new AppKernel() : undefined + + static renderKeyboardUI() { + this.kernel.addOpenInJsboxButton() + + const Keyboard = require("./ui/keyboard") + const keyboard = new Keyboard(this.kernel) + + this.kernel.KeyboardRender(keyboard.getView()) + } + + static renderTodayUI() { + this.kernel.addOpenInJsboxButton() + + const Today = require("./ui/today") + const today = new Today(this.kernel) + + this.kernel.UIRender(today.getView()) + } +} + +module.exports = { + run: () => { + //AppUI.renderKeyboardUI();return + //AppUI.renderTodayUI();return + + if ($app.env === $env.today) { + AppUI.renderTodayUI() + } else if ($app.env === $env.keyboard) { + AppUI.renderKeyboardUI() + } + } +} diff --git a/scripts/app.js b/scripts/app.js index 3fc90b94..5f69780c 100644 --- a/scripts/app.js +++ b/scripts/app.js @@ -1,85 +1,19 @@ -const { - UIKit, - ViewController, - TabBarController, - Kernel, - Logger, - FileStorage, - Setting, - FileManager -} = require("./libs/easy-jsbox") -const { Storage } = require("./dao/storage") -const SettingStructure = require("./setting/setting") -const Clips = require("./ui/clips") -const ActionManager = require("./ui/components/action-manager") +const { UIKit, ViewController, TabBarController } = require("./libs/easy-jsbox") +const { AppKernelBase } = require("./app-base") const compatibility = require("./compatibility") const settingMethods = require("./setting-methods") -const fileStorage = new FileStorage() - /** * @typedef {AppKernel} AppKernel */ -class AppKernel extends Kernel { - logPath = "logs" - logFile = "caio.log" - logFilePath = FileStorage.join(this.logPath, this.logFile) - +class AppKernel extends AppKernelBase { constructor() { super() this.query = $context.query - // FileStorage - this.fileStorage = fileStorage - // Logger - this.logger = new Logger() - this.logger.printToFile(fileStorage, this.logFilePath) - // Setting - this.setting = new Setting({ - fileStorage: this.fileStorage, - structure: SettingStructure - }) - // Storage - this.storage = new Storage(this) - this.initComponents() settingMethods(this) } - - error(message) { - if (this.fileStorage.exists(this.logFilePath)) { - const logFileSize = this.fileStorage.readSync(this.logFilePath)?.info?.size ?? 0 - if (logFileSize > 1024 * 10) { - const dist = FileStorage.join(this.logPath, `caio.${Date.now()}.log`) - this.fileStorage.move(this.logFilePath, dist) - } - } - - if (message instanceof Error) { - message = `${message}\n${message.stack}` - } - super.error(message) - this.logger.error(message) - } - - addOpenInJsboxButton() { - this.useJsboxNav() - this.setNavButtons([ - { - image: $image("assets/icon.png"), - handler: () => this.openInJsbox() - } - ]) - } - - initComponents() { - // Clips - this.clips = new Clips(this) - // ActionManager - this.actionManager = new ActionManager(this) - // FileManager - this.fileManager = new FileManager() - } } class AppUI { @@ -143,121 +77,13 @@ class AppUI { this.kernel.UIRender(this.kernel.tabBarController.generateView().definition) } } - - static renderKeyboardUI() { - this.kernel.addOpenInJsboxButton() - - const Keyboard = require("./ui/keyboard") - const keyboard = new Keyboard(this.kernel) - - this.kernel.KeyboardRender(keyboard.getView()) - } - - static renderTodayUI() { - this.kernel.addOpenInJsboxButton() - - const Today = require("./ui/today") - const today = new Today(this.kernel) - - this.kernel.UIRender(today.getView()) - } - - static renderUnsupported() { - $intents.finish("不支持在此环境中运行") - $ui.render({ - views: [ - { - type: "label", - props: { - text: "不支持在此环境中运行", - align: $align.center - }, - layout: $layout.fill - } - ] - }) - } -} - -class Widget { - static widgetInstance(widget, ...data) { - if ($file.exists(`/scripts/widget/${widget}.js`)) { - const { Widget } = require(`./widget/${widget}.js`) - return new Widget(...data) - } else { - return false - } - } - - static kernel() { - const logger = new Logger() - logger.printToFile(fileStorage, "logs/widget.log") - const kernel = { - setting: new Setting(), - fileStorage, - print: () => {}, - error: msg => { - logger.error(msg) - } - } - kernel.setting.setReadonly() - - const storage = new Storage(kernel) - kernel.storage = storage - - return kernel - } - - static renderError() { - $widget.setTimeline({ - render: () => ({ - type: "text", - props: { - text: "Invalid argument" - } - }) - }) - } - - static renderClipboard() { - const setting = new Setting() - setting.setReadonly() - - const widget = Widget.widgetInstance("Clipboard", Widget.kernel()) - - widget.render() - } - - static render(widgetName = $widget.inputValue) { - widgetName = widgetName ?? "Clipboard" - if (widgetName === "Clipboard") { - Widget.renderClipboard() - } else { - Widget.renderError() - } - } } module.exports = { - Widget, run: () => { - //AppUI.renderTodayUI(); return - //AppUI.renderKeyboardUI(); return - //Widget.render(); return - // 兼容性操作 compatibility(AppUI.kernel) - if ($app.env === $env.app || $app.env === $env.action) { - AppUI.renderMainUI() - } else if ($app.env === $env.keyboard) { - AppUI.renderKeyboardUI() - } else if ($app.env === $env.widget) { - Widget.render() - } else if ($app.env === $env.today) { - AppUI.renderTodayUI() - } else { - AppUI.renderUnsupported() - } + AppUI.renderMainUI() } } diff --git a/scripts/dao/clips-data.js b/scripts/dao/clips-data.js index b419f88d..ed7afd1d 100644 --- a/scripts/dao/clips-data.js +++ b/scripts/dao/clips-data.js @@ -3,6 +3,7 @@ const { Clip } = require("./storage") /** * @typedef {import("../app").AppKernel} AppKernel + * @typedef {import("../app-lite").AppKernel} AppKernelLite * @typedef {import("./storage").Clip} Clip */ @@ -16,7 +17,7 @@ function array2object(array) { class ClipsData { /** - * @type {AppKernel} + * @type {AppKernel|AppKernelLite} */ kernel diff --git a/scripts/setting-methods.js b/scripts/setting-methods.js index 84e13750..375c9196 100644 --- a/scripts/setting-methods.js +++ b/scripts/setting-methods.js @@ -419,7 +419,7 @@ function settingMethods(appKernel) { } kernel.setting.method.previewWidget = animate => { - const { Widget } = require("./app") + const { Widget } = require("./widget") const widgets = {} try { JSON.parse($file.read("widget-options.json").string).forEach(item => { diff --git a/scripts/ui/keyboard.js b/scripts/ui/keyboard.js index 0070602b..35ddb579 100644 --- a/scripts/ui/keyboard.js +++ b/scripts/ui/keyboard.js @@ -4,7 +4,7 @@ const Clips = require("./clips") const KeyboardScripts = require("./components/keyboard-scripts") /** - * @typedef {import("../app").AppKernel} AppKernel + * @typedef {import("../app-lite").AppKernel} AppKernel */ class Keyboard extends Clips { diff --git a/scripts/ui/today.js b/scripts/ui/today.js index 37ac865e..c151cbea 100644 --- a/scripts/ui/today.js +++ b/scripts/ui/today.js @@ -4,7 +4,7 @@ const Clips = require("./clips") const TodayActions = require("./components/today-actions") /** - * @typedef {import("../app").AppKernel} AppKernel + * @typedef {import("../app-lite").AppKernel} AppKernel */ class Today extends Clips { diff --git a/scripts/widget.js b/scripts/widget.js new file mode 100644 index 00000000..56ff6a50 --- /dev/null +++ b/scripts/widget.js @@ -0,0 +1,74 @@ +const { Logger, Setting, FileStorage } = require("./libs/easy-jsbox") +const SettingStructure = require("./setting/setting") +const { Storage } = require("./dao/storage") + +const fileStorage = new FileStorage() + +class Widget { + static widgetInstance(widget, ...data) { + if ($file.exists(`/scripts/widget/${widget}.js`)) { + const { Widget } = require(`./widget/${widget}.js`) + return new Widget(...data) + } else { + return false + } + } + + static kernel() { + const logger = new Logger() + logger.printToFile(fileStorage, "logs/widget.log") + const kernel = { + setting: new Setting({ + fileStorage, + structure: SettingStructure + }), + fileStorage, + print: () => {}, + error: msg => { + logger.error(msg) + } + } + kernel.setting.setReadonly() + + const storage = new Storage(kernel) + kernel.storage = storage + + return kernel + } + + static renderError() { + $widget.setTimeline({ + render: () => ({ + type: "text", + props: { + text: "Invalid argument" + } + }) + }) + } + + static renderClipboard() { + const setting = new Setting() + setting.setReadonly() + + const widget = Widget.widgetInstance("Clipboard", Widget.kernel()) + + widget.render() + } + + static render(widgetName = $widget.inputValue) { + widgetName = widgetName ?? "Clipboard" + if (widgetName === "Clipboard") { + Widget.renderClipboard() + } else { + Widget.renderError() + } + } +} + +module.exports = { + Widget, + run: () => { + Widget.render() + } +}