(globalThis.webpackChunk_affine_web=globalThis.webpackChunk_affine_web||[]).push([[3524],{77966:(e,t,a)=>{"use strict";a.d(t,{os:()=>r,hG:()=>o,sx:()=>i,z6:()=>s,$J:()=>n,tU:()=>l,du:()=>c,IG:()=>d,c8:()=>m,RQ:()=>p,NW:()=>u});var r="_14hl6bl2",o="_14hl6bl0",i="_14hl6bl1",s="_14hl6bl3",n="_14hl6bl5",l="_14hl6bla",c="_14hl6bl7",d="_14hl6bl4",m="_14hl6bl9",p="_14hl6bl8",u="_14hl6bld"},10609:(e,t,a)=>{"use strict";a.d(t,{ff:()=>r,h7:()=>o,lK:()=>i,zS:()=>s,zy:()=>n,vJ:()=>l,Er:()=>c,tq:()=>d,E2:()=>m,k$:()=>p,UJ:()=>u,D0:()=>h,b:()=>f,qb:()=>g,fF:()=>y,r:()=>b,py:()=>v,IB:()=>k,y3:()=>w,h$:()=>x,_N:()=>C,eI:()=>S,fw:()=>F,zr:()=>A,nB:()=>E,aK:()=>N,rM:()=>_,LI:()=>I,HW:()=>j,qd:()=>D,AU:()=>M,KW:()=>T,T6:()=>P,yj:()=>L,IJ:()=>$,su:()=>W,dR:()=>z});var r="rmastff",o="rmastfa",i="rmastf13",s="rmastfg",n="rmastfx",l="rmastf10",c="rmastfy",d="rmastfz",m="rmastf7",p="rmastfh",u="rmastfp",h="rmastfr",f="rmastfn rmastfl",g="rmastfq",y="rmastf14",b="rmastf18",v="rmastfs rmastfl rmastfm",k="rmastfw rmastft rmastfs rmastfl rmastfm",w="rmastft rmastfs rmastfl rmastfm",x="rmastfu rmastfs rmastfl rmastfm",C="rmastfv rmastfs rmastfl rmastfm",S="rmastf15 rmastfk rmastfj",F="rmastf19",A="rmastf1",E="rmastf2",N="rmastf17",_="rmastfn rmastfl rmastfj rmastfm",I="rmastfd",j="rmastfe",D="rmastf3",M="rmastf9",T="rmastf6",P="rmastfc",L="rmastf4",$="rmastf5",W="rmastfb",z="rmastfi rmastfh"},69109:(e,t,a)=>{"use strict";a.d(t,{op:()=>r,sY:()=>o,VP:()=>i,Fc:()=>s,lo:()=>n,tj:()=>l,cD:()=>c,C8:()=>d,As:()=>m,hf:()=>p,ES:()=>u,W5:()=>h});var r="vjs73ab",o="vjs73ac",i="vjs73a0",s="vjs73a6",n="vjs73a5",l="vjs73aa",c="vjs73a9",d="vjs73a7",m="vjs73a1",p="vjs73a4",u="vjs73a8",h="vjs73a2"},60920:(e,t,a)=>{"use strict";a.d(t,{a8:()=>r,G5:()=>o,fy:()=>i,M2:()=>s,N4:()=>n,_s:()=>l,R_:()=>c,R:()=>d,_w:()=>m,gc:()=>p,zr:()=>u}),a(90419),a(84022),a(30803);var r="_1a7mq8x5",o="_1a7mq8xb",i="_1a7mq8xc",s="_1a7mq8xa",n="_1a7mq8x8",l="_1a7mq8x3",c="_1a7mq8x4",d="_1a7mq8x7",m="_1a7mq8x6",p="_1a7mq8x1",u="_1a7mq8x2"},65449:(e,t,a)=>{"use strict";a.d(t,{hP:()=>r,RV:()=>o,Ml:()=>i,gO:()=>s,yK:()=>n,Vq:()=>l,fh:()=>c,iV:()=>d,dR:()=>m,RZ:()=>p,SV:()=>u,E_:()=>h,rE:()=>f,Km:()=>g,W2:()=>y,Uv:()=>b,fw:()=>v,$W:()=>k,yZ:()=>w,bc:()=>x,bX:()=>C,x4:()=>S,dj:()=>F,OF:()=>A,ux:()=>E});var r="_12l52tqq",o="_12l52tq4",i="_12l52tqi",s="_12l52tq0",n="_12l52tqb",l="_12l52tqa",c="_12l52tq9",d="_12l52tq8",m="_12l52tq6",p="_12l52tqc",u="_12l52tql",h="_12l52tq2",f="_12l52tq1",g="_12l52tqn",y="_12l52tqm",b="_12l52tqk",v="_12l52tq5",k="_12l52tqh",w="_12l52tqg",x="_12l52tqe",C="_12l52tqd",S="_12l52tqf",F="_12l52tq7",A="_12l52tqs",E="_12l52tqo"},90419:()=>{},84022:()=>{},30803:()=>{},36466:()=>{},52490:(e,t,a)=>{"use strict";a.d(t,{k:()=>s});var r=a(56503),o=a.n(r);let i="affine:debug";"undefined"!=typeof window&&(window.location.search.includes("debug")&&sessionStorage.setItem(i,"true"),"true"===sessionStorage.getItem(i)&&(o().enable("*"),console.warn("Debug logs enabled")));class s{constructor(e){this._debug=o()(e)}set enabled(e){this._debug.enabled=e}get enabled(){return this._debug.enabled}debug(e,...t){this.log("debug",e,...t)}info(e,...t){this.log("info",e,...t)}warn(e,...t){this.log("warn",e,...t)}error(e,...t){this.log("error",e,...t)}log(e,t,...a){this._debug.log=console[e].bind(console),this._debug(`[${e.toUpperCase()}] ${t}`,...a)}namespace(e){let t=this._debug.namespace;return new s(`${t}:${e}`)}}},52428:(e,t,a)=>{"use strict";a.d(t,{Bd:()=>r,EZ:()=>n,I:()=>s,LL:()=>d,P0:()=>l,S$:()=>o,c9:()=>m,xl:()=>i});let r="undefined"!=typeof window,o=!r&&"undefined"==typeof navigator,i=r&&!!window.appInfo?.electron,s="ARMS",n="Untitled",l="updatedDate",c={loginError:0,noPermission:1,loadListFailed:2,getDetailFailed:3,createWorkspaceFailed:4,getMembersFailed:5,updateWorkspaceFailed:6,deleteWorkspaceFailed:7,inviteMemberFailed:8,removeMemberFailed:9,acceptInvitingFailed:10,getBlobFailed:11,leaveWorkspaceFailed:12,downloadWorkspaceFailed:13,refreshTokenError:14,blobTooLarge:15};c.loginError,c.noPermission,c.loadListFailed,c.getDetailFailed,c.createWorkspaceFailed,c.getMembersFailed,c.updateWorkspaceFailed,c.deleteWorkspaceFailed,c.inviteMemberFailed,c.removeMemberFailed,c.acceptInvitingFailed,c.getBlobFailed,c.leaveWorkspaceFailed,c.downloadWorkspaceFailed,c.refreshTokenError,c.blobTooLarge;class d extends TypeError{constructor(e,t){super(),this.docCollection=e,this.pageId=t}}class m extends Error{constructor(e){super(e)}}},55863:(e,t,a)=>{"use strict";a.d(t,{J:()=>c});var r=a(71006),o=a(67448),i=a(52428);class s{constructor(e){this.navigator=e,this.isLinux=!1,this.isMacOs=!1,this.isSafari=!1,this.isWindows=!1,this.isFireFox=!1,this.isMobile=!1,this.isChrome=!1,this.isIOS=!1,this.getChromeVersion=()=>{let e=this.navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);return(e||(e=this.navigator.userAgent.match(/(CriOS)\/([0-9]+)/)),e)?parseInt(e[2],10):(console.error("Cannot get chrome version"),0)},this.uaMap=n(e),this.initUaFlags()}checkUseragent(e){return!!this.uaMap[e]}initUaFlags(){this.isLinux=this.checkUseragent("linux"),this.isMacOs=this.checkUseragent("mac"),this.isSafari=this.checkUseragent("safari"),this.isWindows=this.checkUseragent("win"),this.isFireFox=this.checkUseragent("firefox"),this.isMobile=this.checkUseragent("mobile"),this.isChrome=this.checkUseragent("chrome"),this.isIOS=this.checkUseragent("ios")}}let n=e=>{let t=e.userAgent,a=t.toLowerCase(),r=/iPhone|iPad|iPod|Android/i.test(t),o=r&&(a.indexOf("android")>-1||a.indexOf("linux")>-1)||a.indexOf("adr")>-1,i=r&&!o&&/Mac OS/i.test(t),s=!r&&/Mac OS/i.test(t),n=i&&a.indexOf("iphone")>-1,l=/MicroMessenger/i.test(t),c=/CriOS/i.test(t)||/Chrome/i.test(t),d=r&&/aweme/i.test(t),m=r&&/Weibo/i.test(t),p=i&&!c&&!l&&!m&&!d&&/Safari|Macintosh/i.test(t),u=/Firefox/.test(t);return{ua:t,mobile:r,android:o,ios:i,mac:s,wx:l,chrome:c,iphone:n,ipad:i&&!n,safari:p,tiktok:d,weibo:m,win:/windows|win32|win64|wow32|wow64/.test(a),linux:/linux/.test(a),firefox:u}},l=o.z.object({serverUrlPrefix:o.z.string(),appVersion:o.z.string(),editorVersion:o.z.string(),appBuildType:o.z.union([o.z.literal("stable"),o.z.literal("beta"),o.z.literal("internal"),o.z.literal("canary")]),isSelfHosted:o.z.boolean().optional(),githubUrl:o.z.string(),changelogUrl:o.z.string(),downloadUrl:o.z.string(),imageProxyUrl:o.z.string(),linkPreviewUrl:o.z.string(),allowLocalWorkspace:o.z.boolean(),enablePreloading:o.z.boolean(),enableNewSettingUnstableApi:o.z.boolean(),enableCaptcha:o.z.boolean(),enableEnhanceShareMode:o.z.boolean(),enableExperimentalFeature:o.z.boolean(),enableInfoModal:o.z.boolean(),enableOrganize:o.z.boolean(),enableThemeEditor:o.z.boolean()});function c(){let e;if(!globalThis.$AFFINE_SETUP){if(l.parse({isSelfHosted:!1,appBuildType:"internal",serverUrlPrefix:"https://insider.affine.pro",appVersion:"0.16.0",editorVersion:"0.17.0-canary-202408121434-8bc42f0",githubUrl:"https://github.com/toeverything/AFFiNE",changelogUrl:"https://github.com/toeverything/AFFiNE/releases",downloadUrl:"https://affine.pro/download",imageProxyUrl:"/api/worker/image-proxy",linkPreviewUrl:"/api/worker/link-preview",enablePreloading:!0,enableCaptcha:!0,enableExperimentalFeature:!0,allowLocalWorkspace:!1,enableOrganize:!0,enableInfoModal:!0,enableNewSettingUnstableApi:!1,enableEnhanceShareMode:!1,enableThemeEditor:!1}),i.S$)e={isDesktop:!1,isBrowser:!1,isServer:!0,isDebug:!1};else{let t=new s(navigator);(e={origin:window.location.origin,isDesktop:i.xl,isBrowser:!0,isServer:!1,isDebug:!1,isLinux:t.isLinux,isMacOs:t.isMacOs,isSafari:t.isSafari,isWindows:t.isWindows,isFireFox:t.isFireFox,isMobile:t.isMobile,isChrome:t.isChrome,isIOS:t.isIOS}).isChrome&&!e.isIOS&&((0,r.U2)(e.isSafari,!1),(0,r.U2)(e.isFireFox,!1),e={...e,isSafari:!1,isFireFox:!1,isChrome:!0,chromeVersion:t.getChromeVersion()})}globalThis.environment=e,globalThis.$AFFINE_SETUP=!0}}},21823:(e,t,a)=>{"use strict";var r;a.d(t,{j:()=>r}),function(e){e.AFFINE_CLOUD="affine-cloud",e.LOCAL="local"}(r||(r={}))},26165:(e,t,a)=>{"use strict";a.d(t,{Z:()=>o});let r=(0,a(49791).y$)();function o(){return r}},51520:(e,t,a)=>{"use strict";a.d(t,{r1:()=>p,r2:()=>d,wJ:()=>m,wM:()=>h,z$:()=>g});var r=a(52490),o=a(55863),i=a(49791),s=a(17597),n=a(75968),l=a(26165);(0,o.J)();let c=new r.k("affine:settings"),d=["frameless","NativeTitleBar"],m=["MM/dd/YYYY","dd/MM/YYYY","YYYY-MM-dd","YYYY.MM.dd","YYYY/MM/dd","dd-MMM-YYYY","dd MMMM YYYY"],p=[{key:"Sans",value:"var(--affine-font-sans-family)"},{key:"Serif",value:"var(--affine-font-serif-family)"},{key:"Mono",value:"var(--affine-font-mono-family)"}],u=(0,s.tG)("affine-settings",{clientBorder:environment.isDesktop&&!environment.isWindows,fullWidthLayout:!1,windowFrameStyle:"frameless",fontStyle:"Sans",dateFormat:m[0],startWeekOnMonday:!1,enableBlurBackground:!0,enableNoisyBackground:!0,autoCheckUpdate:!0,autoDownloadUpdate:!0,enableTelemetry:!0,enableMultiView:!1,editorFlags:{}});function h(e){let t=(0,l.Z)(),a=()=>{try{let t=(0,l.Z)().get(u).editorFlags;Object.entries(t??{}).forEach(([t,a])=>{e.awarenessStore.setFlag(t,a)}),Object.entries(v).forEach(([t,a])=>{void 0!==a.defaultState&&e.awarenessStore.setFlag(t,a.defaultState)})}catch(e){c.error("syncEditorFlags",e)}};t.sub(u,a),a()}let f=(0,n.$)(e=>{let t=e(u);environment.isDesktop&&(c.debug("sync settings to electron",t),window.apis?.updater.setConfig({autoCheckUpdate:t.autoCheckUpdate,autoDownloadUpdate:t.autoDownloadUpdate}).catch(e=>{console.error(e)}))}),g=(0,i.eU)(e=>(e(f),e(u)),(e,t,a)=>{t(u,e=>{let t="function"==typeof a?a(e):a;return{...e,...t}})}),y=()=>!0,b=()=>!1,v={enable_database_attachment_note:{displayName:"Database Attachment Note",description:"Allows adding notes to database attachments.",precondition:y},enable_database_statistics:{displayName:"Database Block Statistics",description:"Shows statistics for database blocks.",precondition:y},enable_block_query:{displayName:"Todo Block Query",description:"Enables querying of todo blocks.",precondition:y},enable_synced_doc_block:{displayName:"Synced Doc Block",description:"Enables syncing of doc blocks.",precondition:b,defaultState:!0},enable_edgeless_text:{displayName:"Edgeless Text",description:"Enables edgeless text blocks.",precondition:b,defaultState:!0},enable_color_picker:{displayName:"Color Picker",description:"Enables color picker blocks.",precondition:b,defaultState:!0},enable_ai_chat_block:{displayName:"AI Chat Block",description:"Enables AI chat blocks.",precondition:b,defaultState:!0},enable_ai_onboarding:{displayName:"AI Onboarding",description:"Enables AI onboarding.",precondition:b,defaultState:!0},enable_expand_database_block:{displayName:"Expand Database Block",description:"Enables expanding of database blocks.",precondition:b,defaultState:!0}}},63932:(e,t,a)=>{"use strict";a.d(t,{u:()=>i});var r,o=a(56044);r=Symbol.dispose;class i{get eventBus(){return this.framework.eventBus}constructor(){if(!o.v.current.provider)throw Error("Component must be created in the context of a provider");this.framework=o.v.current.provider,this.props=o.v.current.props,o.v.current={}}dispose(){}[r](){this.dispose()}}},29820:(e,t,a)=>{"use strict";a.d(t,{w:()=>o});var r=a(63932);class o extends r.u{constructor(...e){super(...e),this.__isEntity=!0}}},66683:(e,t,a)=>{"use strict";a.d(t,{H:()=>o});var r=a(63932);class o extends r.u{get collection(){return this.framework.collection}get scope(){return this.framework.scope}get get(){return this.framework.get}get getAll(){return this.framework.getAll}get getOptional(){return this.framework.getOptional}get createEntity(){return this.framework.createEntity}get createScope(){return this.framework.createScope}get emitEvent(){return this.framework.emitEvent}dispose(){super.dispose(),this.framework.dispose()}constructor(...e){super(...e),this.__injectable=!0}}},95284:(e,t,a)=>{"use strict";a.d(t,{k:()=>o});var r=a(63932);class o extends r.u{constructor(...e){super(...e),this.__isService=!0,this.__injectable=!0}}},48990:(e,t,a)=>{"use strict";a.d(t,{i:()=>o});var r=a(63932);class o extends r.u{constructor(...e){super(...e),this.__isStore=!0,this.__injectable=!0}}},56044:(e,t,a)=>{"use strict";a.d(t,{e:()=>o,v:()=>r});let r={current:{}};function o(e,t){let a=r.current;try{return r.current=t,e()}finally{r.current=a}}},86448:(e,t,a)=>{"use strict";a.d(t,{Yk:()=>o,kU:()=>i,um:()=>r});let r="default",o=[],i=Symbol("subComponents")},13116:(e,t,a)=>{"use strict";a.d(t,{Dq:()=>l,MX:()=>o,U9:()=>n,j5:()=>i,vU:()=>s});var r=a(86448);class o extends Error{constructor(){super("Dynamic resolve recursion limit reached")}}class i extends Error{constructor(e){super(`A circular dependency was detected. `+d(e)),this.dependencyStack=e}}class s extends Error{constructor(e){super(`Component ${c(e)} not found in container`),this.identifier=e}}class n extends Error{constructor(e,t,a){super(`Missing dependency ${c(t)} in creating ${c(e)}. ${d(a)}`),this.from=e,this.target=t,this.dependencyStack=a}}class l extends Error{constructor(e){super(`${c(e)} already exists`),this.identifier=e}}function c(e){return`[${e.identifierName}]${e.variant!==r.um?`(${e.variant})`:""}`}function d(e){return e.map(e=>`${c(e)}`).join(" -> ")}},34354:(e,t,a)=>{"use strict";a.d(t,{e_:()=>m,l7:()=>c,lh:()=>n});var r=a(52490),o=a(2139),i=a(86448),s=a(34819);function n(e){return{id:e,_type:{}}}let l=new r.k("affine:event-bus");class c{constructor(e,t){for(let a of(this.parent=t,this.listeners={},e.getAll(d,{sameScope:!0}).values()))this.on(a.event.id,a.handler)}get root(){return this.parent?.root??this}on(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t);let a=this.parent?.on(e,t);return()=>{this.off(e,t),a?.()}}off(e,t){this.listeners[e]&&(this.listeners[e]=this.listeners[e].filter(e=>e!==t))}emit(e,t){l.debug("Emitting event",e.id,t);let a=this.listeners[e.id];a&&a.forEach(e=>{try{e(t)}catch(e){console.error(e)}})}}let d=(0,s.Qm)("EventHandler"),m=(e,t)=>a=>{let r=a[i.kU]??[];return a[i.kU]=[...r,{identifier:d(a.name+(0,o.c)(e)+(0,o.c)(t)),factory:r=>({event:e,handler:e=>{let o=r.get(a);t(o).apply(o,[e])}})}],a}},66714:(e,t,a)=>{"use strict";a.d(t,{d:()=>f});var r,o,i=a(86448),s=a(13116),n=a(34819),l=a(56044),c=a(34354);r=Symbol.dispose;class d{[r](){this.dispose()}constructor(){this.get=(e,t)=>this.getRaw((0,n.fu)(e),{...t,optional:!1}),this.getAll=(e,t)=>this.getAllRaw((0,n.fu)(e),{...t}),this.getOptional=(e,t)=>this.getRaw((0,n.fu)(e),{...t,optional:!0}),this.createEntity=(e,...[t])=>this.getRaw((0,n.fu)(e),{noCache:!0,sameScope:!0,props:t}),this.createScope=(e,...[t])=>this.collection.provider([...this.scope,(0,n.fu)(e).identifierName],this).getRaw((0,n.fu)(e),{sameScope:!0,props:t}),this.emitEvent=(e,t)=>{this.eventBus.emit(e,t)}}}o=Symbol.dispose;class m{getOrInsert(e,t){let a=this.cache.get(e.identifierName)??new Map;a.has(e.variant)||a.set(e.variant,t());let r=a.get(e.variant);return this.cache.set(e.identifierName,a),r}dispose(){for(let e of this.cache.values())for(let t of e.values())if("object"==typeof t&&"function"==typeof t[Symbol.dispose])try{t[Symbol.dispose]()}catch(e){setImmediate(()=>{throw e})}}[o](){this.dispose()}constructor(){this.cache=new Map}}class p extends d{constructor(e,t=0,a=[]){super(),this.provider=e,this.depth=t,this.stack=a,this.scope=this.provider.scope,this.collection=this.provider.collection,this.eventBus=this.provider.eventBus}getRaw(e,{sameScope:t=!1,optional:a=!1,noCache:r=!1,props:o}={}){let i=this.provider.collection.getFactory(e,this.provider.scope);if(!i){if(this.provider.parent&&!t)return this.provider.parent.getRaw(e,{sameScope:t,optional:a,noCache:r,props:o});if(a)return;throw new s.vU(e)}let n=()=>{let t=this.track(e);try{return(0,l.e)(()=>i(t),{provider:this.provider,props:o})}catch(t){if(t instanceof s.vU)throw new s.U9(e,t.identifier,this.stack);throw t}};return r?n():this.provider.cache.getOrInsert(e,n)}getAllRaw(e,{sameScope:t=!1,noCache:a,props:r}={}){let o=this.provider.collection.getFactoryAll(e,this.provider.scope);if(void 0===o)return this.provider.parent&&!t?this.provider.parent.getAllRaw(e):new Map;let i=new Map;for(let[t,n]of o){let o;let c=()=>{let t=this.track(e);try{return(0,l.e)(()=>n(t),{provider:this.provider,props:r})}catch(t){if(t instanceof s.vU)throw new s.U9(e,t.identifier,this.stack);throw t}};o=a?c():this.provider.cache.getOrInsert({identifierName:e.identifierName,variant:t},c),i.set(t,o)}return i}track(e){let t=this.depth+1;if(t>=100)throw new s.MX;if(this.stack.find(t=>t.identifierName===e.identifierName&&t.variant===e.variant))throw new s.j5([...this.stack,e]);return new p(this.provider,t,[...this.stack,e])}dispose(){}}class u extends d{constructor(e,t,a){super(),this.scope=t,this.parent=a,this.cache=new m,this.disposed=!1,this.collection=e,this.eventBus=new c.l7(this,this.parent?.eventBus)}getRaw(e,t){return new p(this).getRaw(e,t)}getAllRaw(e,t){return new p(this).getAllRaw(e,t)}dispose(){this.disposed||(this.disposed=!0,this.cache.dispose())}}function h(e){return e.join("/")}class f{static get EMPTY(){return new f}get componentCount(){let e=0;for(let[,t]of this.components)for(let[,a]of t)e+=a.size;return e}get service(){return new g(this).service}get impl(){return new g(this).impl}get entity(){return new g(this).entity}get scope(){return new g(this).scope}get override(){return new g(this).override}get store(){return new g(this).store}addValue(e,t,{scope:a,override:r}={}){this.addFactory((0,n.fu)(e),()=>t,{scope:a,override:r})}addFactory(e,t,{scope:a,override:r}={}){let o=h(a??i.Yk),l=(0,n.fu)(e),c=l.variant??i.um,d=this.components.get(o)??new Map,m=d.get(l.identifierName)??new Map;if(m.has(c)&&!r)throw new s.Dq(l);m.set(c,t),d.set(l.identifierName,m),this.components.set(o,d)}remove(e,t=i.Yk){let a=h(t),r=(0,n.fu)(e),o=r.variant??i.um,s=this.components.get(a);if(!s)return;let l=s.get(r.identifierName);l&&l.delete(o)}provider(e=i.Yk,t=null){return new u(this,e,t)}getFactory(e,t=i.Yk){return this.components.get(h(t))?.get(e.identifierName)?.get(e.variant??i.um)}getFactoryAll(e,t=i.Yk){return new Map(this.components.get(h(t))?.get(e.identifierName))}clone(){let e=new f;for(let[t,a]of this.components){let r=new Map;for(let[e,t]of a)r.set(e,new Map(t));e.components.set(t,r)}return e}constructor(){this.components=new Map}}class g{constructor(e){this.collection=e,this.currentScopeStack=i.Yk,this.service=(e,...[t])=>{if(t instanceof Function?this.collection.addFactory(e,t,{scope:this.currentScopeStack}):t instanceof Array||void 0===t?this.collection.addFactory(e,y(e,t),{scope:this.currentScopeStack}):this.collection.addValue(e,t,{scope:this.currentScopeStack}),i.kU in e)for(let{identifier:t,factory:a}of e[i.kU])this.collection.addFactory(t,a,{scope:this.currentScopeStack});return this},this.store=(e,...[t])=>{if(t instanceof Function?this.collection.addFactory(e,t,{scope:this.currentScopeStack}):t instanceof Array||void 0===t?this.collection.addFactory(e,y(e,t),{scope:this.currentScopeStack}):this.collection.addValue(e,t,{scope:this.currentScopeStack}),i.kU in e)for(let{identifier:t,factory:a}of e[i.kU])this.collection.addFactory(t,a,{scope:this.currentScopeStack});return this},this.entity=(e,...[t])=>(t instanceof Function?this.collection.addFactory(e,t,{scope:this.currentScopeStack}):this.collection.addFactory(e,y(e,t),{scope:this.currentScopeStack}),this),this.impl=(e,t,...[a])=>(t instanceof Function?this.collection.addFactory(e,y(t,a),{scope:this.currentScopeStack}):this.collection.addValue(e,t,{scope:this.currentScopeStack}),this),this.override=(e,t,...[a])=>(null===t?this.collection.remove((0,n.fu)(e),this.currentScopeStack):t instanceof Function?this.collection.addFactory(e,y(t,a),{scope:this.currentScopeStack,override:!0}):this.collection.addValue(e,t,{scope:this.currentScopeStack,override:!0}),this),this.scope=e=>(this.currentScopeStack=[...this.currentScopeStack,(0,n.fu)(e).identifierName],this.collection.addFactory(e,y(e,[]),{scope:this.currentScopeStack,override:!0}),this)}}function y(e,t=[]){return a=>{let r=[];for(let e of t){let t,o;if(Array.isArray(e)){if(1!==e.length)throw Error("Invalid dependency");t=!0,o=e[0]}else t=!1,o=e;t?r.push(Array.from(a.getAll(o).values())):r.push(a.get(o))}return!function(e){try{return Reflect.construct(function(){},[],e),!0}catch(e){return!1}}(e)?e(...r,a):new e(...r,a)}}},34819:(e,t,a)=>{"use strict";a.d(t,{Qm:()=>i,fu:()=>s});var r=a(2139),o=a(86448);function i(e,t=o.um){return Object.assign(t=>i(e,t),{identifierName:e,variant:t})}function s(e){if(e.identifierName)return e;if("function"==typeof e&&e.name)return i(`${e.name}${(0,r.c)(e)}`);throw Error("Input is not a service identifier.")}},10980:(e,t,a)=>{"use strict";a.d(t,{A$:()=>p,Dq:()=>u,V5:()=>h,h1:()=>m,u:()=>d,xc:()=>f});var r=a(36870),o=a(86326),i=a(66714),s=a(13116),n=a(34819),l=a(32742);let c=o.createContext([i.d.EMPTY.provider()]);function d(){let e=(0,o.useContext)(c);return e[e.length-1]}function m(e){let t=(0,o.useContext)(c),a=null;for(let r=t.length-1;r>=0&&!(a=t[r].getOptional(e,{sameScope:!0}));r--);if(!a)throw new s.vU((0,n.fu)(e));return a}function p(e){let t=(0,o.useContext)(c),a={};for(let[r,o]of Object.entries(e)){let e;for(let a=t.length-1;a>=0&&!(e=t[a].getOptional(o,{sameScope:!0}));a--);if(!e)throw new s.vU((0,n.fu)(o));a[r.charAt(0).toLowerCase()+r.slice(1)]=e}return a}function u(e){let t=(0,o.useContext)(c),a=null;for(let r=t.length-1;r>=0&&!(a=t[r].getOptional(e,{sameScope:!0}));r--);return a}let h=({framework:e,children:t})=>(0,r.jsx)(c.Provider,{value:[e],children:t}),f=({scope:e,children:t})=>{let a=(0,o.useContext)(c),i=(0,o.useMemo)(()=>e?[...a,e.framework]:a,[a,e]);return(0,r.jsx)(c.Provider,{value:i,children:(0,r.jsx)(l.M,{children:t})})}},32742:(e,t,a)=>{"use strict";a.d(t,{J:()=>n,M:()=>l});var r=a(36870),o=a(86326);let i=o.createContext({nodes:new Map,setNodes:()=>{}}),s=0,n=e=>{let[t]=o.useState(s++),{setNodes:a}=o.useContext(i),r=o.useCallback(()=>{a(e=>{if(!e.has(t))return e;let a=new Map(e);return a.delete(t),a})},[t,a]),n=o.useCallback(o=>(a(a=>new Map(a).set(t,{node:o,debugKey:e})),r),[a,t,e,r]);return o.useMemo(()=>({mount:n}),[n])},l=({children:e})=>{let[t,a]=o.useState(new Map);return(0,r.jsxs)(i.Provider,{value:{nodes:t,setNodes:a},children:[e,Array.from(t.entries()).map(([e,{node:t,debugKey:a}])=>(0,r.jsx)("div",{"data-testid":a,style:{display:"contents"},children:t},e))]})}},56964:(e,t,a)=>{"use strict";function r(e,t){e.load(()=>{let a=e.addBlock("affine:page",{title:new e.Text(t??"")});e.addBlock("affine:surface",{},a);let r=e.addBlock("affine:note",{},a);e.addBlock("affine:paragraph",{},r),e.history.clear()})}a.d(t,{h:()=>r})},91218:(e,t,a)=>{"use strict";a.d(t,{Q:()=>n});var r=a(52490),o=a(52428),i=a(50049);let s=new r.k("effect");function n(...e){let t=new i.B,a=environment.isDebug?`(${Error().stack?.split("\n")[2].trim()})`:"";class r extends o.c9{constructor(e,t){s.error(`effect ${a} ${e}`,t),super(`effect ${a} ${e} ${t?t instanceof Error?t.stack??t.message:t+"":""}`)}}let l=t.pipe.apply(t,e).subscribe({next(e){let t=new r("should not emit value",e);setImmediate(()=>{throw t})},complete(){let e=new r("effect unexpected complete");setImmediate(()=>{throw e})},error(e){let t=new r("effect uncaught error",e);setImmediate(()=>{throw t})}}),c=e=>{t.next(e)};return c.unsubscribe=()=>l.unsubscribe(),c}},34802:(e,t,a)=>{"use strict";a.d(t,{D:()=>k});var r,o,i=a(52490),s=a(82377),n=a(82834),l=a(56607),c=a(75841),d=a(77909),m=a(28138),p=a(15654),u=a(84190),h=a(50049),f=a(35690),g=a(97156),y=a(30315),b=a(8790);let v=new i.k("livedata");r=Symbol.observable||"@@observable",o=Symbol.observable;class k extends s.c{static from(e,t){return new k(t,"function"==typeof e?e:t=>t.pipe((0,n.Z)(e=>"set"===e?l.w:"get"===e?(0,c.of)("watch","unwatch"):(0,c.of)(e)),(0,d.S)((e,t)=>"watch"===t?e+1:"unwatch"===t?e-1:e,0),(0,m.T)(e=>e>0?"watch":"unwatch"),(0,p.F)(),(0,u.n)(t=>"watch"===t?e:l.w)))}static{this.GLOBAL_COMPUTED_RECURSIVE_COUNT=0}static computed(e){return k.from(new s.c(t=>{let a=a=>{let r=[];k.GLOBAL_COMPUTED_RECURSIVE_COUNT++;try{k.GLOBAL_COMPUTED_RECURSIVE_COUNT>10?t.error(Error("computed recursive limit exceeded")):t.next(e(e=>{let o=null,i=!0;return r.push(e.subscribe({error(e){t.error(e)},next(e){o=e,i||a(),i=!1}})),o}))}catch(e){t.error(e)}finally{k.GLOBAL_COMPUTED_RECURSIVE_COUNT--}return()=>{r.forEach(e=>e.unsubscribe())}},r=()=>{},o=()=>{let e=a(o);r(),r=e};return o(),()=>{r()}}),null)}constructor(e,t){super(),this.ops$=new h.B,this.isPoisoned=!1,this.poisonedError=null,this.getValue=()=>{if(this.isPoisoned)throw this.poisonedError;return this.ops$.next("get"),this.raw$.value},this.setValue=e=>{if(this.isPoisoned)throw this.poisonedError;this.raw$.next(e),this.ops$.next("set")},this.next=e=>{if(this.isPoisoned)throw this.poisonedError;return this.setValue(e)},this.reactSubscribe=e=>{if(this.isPoisoned)throw this.poisonedError;this.ops$.next("watch");let t=this.raw$.pipe((0,p.F)(),(0,f.i)(1)).subscribe(e);return t.add(()=>{this.ops$.next("unwatch")}),()=>t.unsubscribe()},this.reactGetSnapshot=()=>{if(this.isPoisoned)throw this.poisonedError;return this.ops$.next("watch"),Promise.resolve().then(()=>{this.ops$.next("unwatch")}),this.raw$.value},this.raw$=new g.t(e),t&&(this.upstreamSubscription=t(this.ops$).subscribe({next:e=>{this.raw$.next(e)},complete:()=>{this.raw$.closed||v.error("livedata upstream unexpected complete")},error:e=>{v.error("uncatched error in livedata",e),this.isPoisoned=!0,this.poisonedError=new w(e),this.raw$.error(this.poisonedError)}}))}get value(){return this.getValue()}set value(e){this.next(e)}subscribe(e,t,a){this.ops$.next("watch");let r=this.raw$.subscribe(e,t,a);return r.add(()=>{this.ops$.next("unwatch")}),r}map(e){let t=k.from(new s.c(a=>this.subscribe({next:t=>{a.next(e(t))},complete:()=>{t.complete()}})),void 0);return t}distinctUntilChanged(e){return k.from(this.pipe((0,p.F)(e)),null)}throttleTime(e,{trailing:t=!0,leading:a=!0}={}){return k.from(this.pipe((0,y.c)(e,void 0,{trailing:t,leading:a})),null)}asObservable(){return new s.c(e=>this.subscribe(e))}pipe(...e){return new s.c(t=>{this.ops$.next("watch");let a=this.raw$.pipe.apply(this.raw$,e).subscribe(t);return a.add(()=>{this.ops$.next("unwatch")}),a})}complete(){this.ops$.complete(),this.raw$.complete(),this.upstreamSubscription?.unsubscribe()}flat(){return k.from(this.pipe((0,u.n)(e=>e instanceof k?e.flat():Array.isArray(e)?0===e.length?(0,c.of)([]):(0,b.z)(e.map(e=>e instanceof k?e.flat():(0,c.of)(e))):(0,c.of)(e))),null)}static flat(e){return new k(e).flat()}waitFor(e,t){return new Promise((a,r)=>{let o=this.subscribe(t=>{e(t)&&(a(t),setImmediate(()=>{o.unsubscribe()}))});t?.addEventListener("abort",e=>{o.unsubscribe(),r(e)})})}waitForNonNull(e){return this.waitFor(e=>null!=e,e)}_subscribe(){throw Error("Method not implemented.")}[r](){return this}[o](){return this}}class w extends Error{constructor(e){super("The livedata is poisoned, original error: "+(e instanceof Error?e.stack:e))}}},72254:(e,t,a)=>{"use strict";a.d(t,{DW:()=>C,Rp:()=>w,Sx:()=>x,ao:()=>k,lp:()=>b,um:()=>v,vN:()=>S});var r=a(22571),o=a(82834),i=a(56607),s=a(2773),n=a(82377),l=a(36090),c=a(26274),d=a(56823),m=a(50394),p=a(15654),u=a(84190),h=a(32982),f=a(75841),g=a(67130),y=a(28563);function b(e){return(0,r.F)((0,o.Z)(t=>(e.next(t),i.w)))}function v(e,t){return(0,r.F)(w(()=>e.next(null)),(0,s.W)(a=>(e.next(a),t?.(a),i.w)))}function k(e){return t=>new n.c(a=>(e(),t.subscribe(a)))}function w(e){return t=>new n.c(a=>t.subscribe({complete(){e(),a.complete()},error(e){a.error(e)},next(e){a.next(e)}}))}function x(e){return new n.c(t=>{let a=new AbortController;return(e instanceof Function?e(a.signal):e).then(e=>{t.next(e),t.complete()}).catch(e=>{t.error(e)}),()=>a.abort(y.f)})}function C({when:e,count:t=3,delay:a=200,maxDelay:r=15e3}={}){return o=>o.pipe((0,l.L)({count:t,delay:(t,o)=>{if(e&&!e(t))return(0,c.$)(()=>t);let i=Math.pow(2,o-1)*a;return(0,d.O)(Math.min(i,r))}}))}function S(e,t,a){return(0,r.F)((0,m.N)(r=>r.pipe((0,p.F)(e),(0,u.n)(e=>(a?.(e),(0,h.h)((0,f.of)(e),r).pipe((0,g.p)((e,a)=>t(e,a))))))))}},61569:(e,t,a)=>{"use strict";a.d(t,{M:()=>c,S:()=>l});var r=a(81314),o=a(86326);function i(){return()=>{}}function s(){return null}function n(){}function l(e){return(0,o.useSyncExternalStore)(e?e.reactSubscribe:i,e?e.reactGetSnapshot:void 0===e?n:s)}function c(e){let t=l(e);return null==t?(0,r.Y)(new Promise((t,a)=>{let r=e.subscribe({next(e){null==e&&(t(e),r.unsubscribe())},error(e){a(e)},complete(){a(Error("Unexpected completion"))}})})):t}},99866:(e,t,a)=>{"use strict";a.d(t,{DB:()=>i});var r=a(29820),o=a(2134);class i extends r.w{constructor(){super(),this.db=this.props.db,Object.entries(this.props.schema).forEach(([e])=>{let t=this.framework.createEntity(o.X,{table:this.db[e],storageDocId:this.props.storageDocId(e)});Object.defineProperty(this,e,{get:()=>t})})}}},2134:(e,t,a)=>{"use strict";a.d(t,{X:()=>o});var r=a(29820);class o extends r.w{constructor(e){super(),this.workspaceService=e,this.table=this.props.table,this.isSyncing$=this.workspaceService.workspace.engine.doc.docState$(this.props.storageDocId).map(e=>e.syncing),this.isLoading$=this.workspaceService.workspace.engine.doc.docState$(this.props.storageDocId).map(e=>e.loading),this.create=this.table.create.bind(this.table),this.update=this.table.update.bind(this.table),this.get=this.table.get.bind(this.table),this.get$=this.table.get$.bind(this.table),this.find=this.table.find.bind(this.table),this.find$=this.table.find$.bind(this.table),this.keys=this.table.keys.bind(this.table),this.delete=this.table.delete.bind(this.table)}}},5704:(e,t,a)=>{"use strict";let r;a.d(t,{r:()=>$,D:()=>W});var o,i,s=a(16820),n=a(95284),l=a(9613),c=a(11156),d=a(82377),m=a(86513),p=a(52847);function u(e){return null===e||Array.isArray(e)||"Object"===e.constructor||!e.constructor?"json":typeof e}function h(e,t){if("json"===e)switch(t){case"bigint":case"function":case"object":case"symbol":case"undefined":return!1}return e===t}let f={PrimaryKeyShouldExist:{validate(e,t){if(null==t[e.keyField])throw Error(`[Table(${e.name})]: Primary key field '${e.keyField}' is required but not set.`)}},PrimaryKeyShouldNotBeUpdated:{validate(e,t){if(void 0!==t[e.keyField])throw Error(`[Table(${e.name})]: Primary key field '${e.keyField}' can't be updated.`)}},DataTypeShouldMatch:{validate(e,t){for(let a in t){let r=e.schema[a];if(!r)throw Error(`[Table(${e.name})]: Field '${a}' is not defined but set in entity.`);let o=t[a];if(void 0===o){delete t[a];continue}if(null===o){if(!r.optional)throw Error(`[Table(${e.name})]: Field '${a}' is required but not set.`);continue}let i=u(o);if(!h(r.type,i))throw Error(`[Table(${e.name})]: Field '${a}' type mismatch. Expected ${r.type} got ${i}.`)}}},DataTypeShouldExactlyMatch:{validate(e,t){let a=new Set;for(let r in t){let o=e.schema[r];if(!o)throw Error(`[Table(${e.name})]: Field '${r}' is not defined but set in entity.`);let i=t[r];if(null==i){if(!o.optional)throw Error(`[Table(${e.name})]: Field '${r}' is required but not set.`);continue}let s=u(i);if(!h(o.type,s))throw Error(`[Table(${e.name})]: Field '${r}' type mismatch. Expected type '${o.type}' but got '${s}'.`);a.add(r)}for(let t in e.schema)if(!a.has(t)&&!1===e.schema[t].optional)throw Error(`[Table(${e.name})]: Field '${t}' is required but not set.`)}}},g=p.A,y=g(f,"PrimaryKeyShouldExist","DataTypeShouldExactlyMatch"),b=g(f,"PrimaryKeyShouldNotBeUpdated","DataTypeShouldMatch"),v=["$$DELETED"];function k(e){return(...t)=>(function(e,...t){let a=[];for(let[r,o]of Object.entries(e))try{o.validate(...t)}catch(e){a.push({code:r,error:e})}!function(e){if(e.length)throw Error("Validation Failed Error\n"+e.map(({code:e,error:t})=>`${e}: ${t.stack??t.message}`).join("\n"))}(a)})(e,...t)}let w={validateTableSchema:k({PrimaryKeyShouldExist:{validate(e,t){if(!Object.values(t).some(e=>e.schema.isPrimaryKey))throw Error(`[Table(${e})]: There should be at least one field marked as primary key.`)}},OnlyOnePrimaryKey:{validate(e,t){let a=[];for(let e in t)t[e].schema.isPrimaryKey&&a.push(e);if(a.length>1)throw Error(`[Table(${e})]: There should be only one field marked as primary key. Found [${a.join(", ")}].`)}},PrimaryKeyShouldNotBeOptional:{validate(e,t){for(let a in t){let r=t[a].schema;if(r.isPrimaryKey&&r.optional&&!r.default)throw Error(`[Table(${e})]: Field '${a}' can't be marked primary key and optional with no default value provider at the same time.`)}}}}),validateCreateEntityData:k(y),validateUpdateEntityData:k(b),validateYjsTableSchema:k({UsePreservedFields:{validate(e,t){for(let a in t)if(v.includes(a))throw Error(`[Table(${e})]: Field '${a}' is reserved keyword and can't be used.`)}}}),validateYjsEntityData:k({SetPreservedFields:{validate(e,t){for(let a of v)if(void 0!==t[a])throw Error(`[Table(${e})]: Field '${a}' is reserved keyword and can't be set.`)}}})};class x{constructor(e,t,a){this.name=t,this.opts=a,this.keyField="",this.subscribedKeys=new Map,this.adapter=e.table(t),this.schema=Object.entries(this.opts.schema).reduce((e,[t,a])=>(e[t]=a.schema,a.schema.isPrimaryKey&&(this.keyField=t),e),{}),this.adapter.setup({...a,keyField:this.keyField})}create(e){let t=Object.entries(this.schema).reduce((e,[t,a])=>(void 0===e[t]&&(a.optional&&(e[t]=null),a.default&&(e[t]=a.default()??null)),e),(0,l.A)(e,c.A));return w.validateCreateEntityData(this,t),this.adapter.insert({data:t})}update(e,t){w.validateUpdateEntityData(this,t);let[a]=this.adapter.update({where:{byKey:e},data:t});return a||null}get(e){let[t]=this.adapter.find({where:{byKey:e}});return t||null}get$(e){let t=this.subscribedKeys.get(e);return t||(t=new d.c(t=>{let a=this.adapter.observe({where:{byKey:e},callback:([e])=>{t.next(e||null)}});return()=>{a(),this.subscribedKeys.delete(e)}}).pipe((0,m.t)({refCount:!0,bufferSize:1})),this.subscribedKeys.set(e,t)),t}find(e){return this.adapter.find({where:e?Object.entries(e).map(([e,t])=>({field:e,value:t})).filter(({value:e})=>void 0!==e):void 0})}find$(e){return new d.c(t=>this.adapter.observe({where:e?Object.entries(e).map(([e,t])=>({field:e,value:t})).filter(({value:e})=>void 0!==e):void 0,callback:e=>{t.next(e)}}))}keys(){return this.adapter.find({select:"key"})}keys$(){let e=this.subscribedKeys.get("$$KEYS");return e||(e=new d.c(e=>{let t=this.adapter.observe({select:"key",callback:t=>{e.next(t)}});return()=>{t(),this.subscribedKeys.delete("$$KEYS")}}).pipe((0,m.t)({refCount:!0,bufferSize:1})),this.subscribedKeys.set("$$KEYS",e)),e}delete(e){this.adapter.delete({where:{byKey:e}})}}class C{static{this.hooksMap=new Map}constructor(e,t){this.db=e,this.adapter=t,this.tables=new Map,Object.entries(e).forEach(([e,t])=>{Object.defineProperty(this,e,{get:()=>{let a=this.tables.get(e);return a||(a=new x(this.adapter,e,{schema:t,hooks:C.hooksMap.get(e)}),this.tables.set(e,a)),a}})})}static defineHook(e,t,a){let r=this.hooksMap.get(e);r||(r=[],this.hooksMap.set(e,r)),r.push(a)}}function S(e){return Object.entries(e).forEach(([e,t])=>{w.validateTableSchema(e,t)}),class extends C{constructor(t){super(e,t)}}}function F(e,t,a,r){return(F=function(){function e(e,t){return function(r){(function(e,t){if(e.v)throw Error("attempted to call "+t+" after decoration was finished")})(t,"addInitializer"),a(r,"An initializer"),e.push(r)}}function t(t,a,r,o,i,s,n,l,c){switch(i){case 1:d="accessor";break;case 2:d="method";break;case 3:d="getter";break;case 4:d="setter";break;default:d="field"}var d,m,p,u={kind:d,name:n?"#"+a:a,static:s,private:n,metadata:l},h={v:!1};u.addInitializer=e(o,h),0===i?n?(m=r.get,p=r.set):(m=function(){return this[a]},p=function(e){this[a]=e}):2===i?m=function(){return r.value}:((1===i||3===i)&&(m=function(){return r.get.call(this)}),(1===i||4===i)&&(p=function(e){r.set.call(this,e)})),u.access=m&&p?{get:m,set:p}:m?{get:m}:{set:p};try{return t(c,u)}finally{h.v=!0}}function a(e,t){if("function"!=typeof e)throw TypeError(t+" must be a function")}function r(e,t){var r=typeof t;if(1===e){if("object"!==r||null===t)throw TypeError("accessor decorators must return an object with get, set, or init properties or void 0");void 0!==t.get&&a(t.get,"accessor.get"),void 0!==t.set&&a(t.set,"accessor.set"),void 0!==t.init&&a(t.init,"accessor.init")}else if("function"!==r)throw TypeError((0===e?"field":10===e?"class":"method")+" decorators must return a function or void 0")}function o(e,t){t&&e.push(function(e){for(var a=0;a3,b=f>=5;if(b?(p=e,f-=5,u=m=m||[]):(p=e.prototype,u=d=d||[]),0!==f&&!y){var v=b?l:n,k=v.get(g)||0;if(!0===k||3===k&&4!==f||4===k&&3!==f)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+g);!k&&f>2?v.set(g,f):v.set(g,!0)}!function(e,a,o,i,s,n,l,c,d){var m,p,u,h,f,g,y=o[0];if(l?m=0===s||1===s?{get:o[3],set:o[4]}:3===s?{get:o[3]}:4===s?{set:o[3]}:{value:o[3]}:0!==s&&(m=Object.getOwnPropertyDescriptor(a,i)),1===s?u={get:m.get,set:m.set}:2===s?u=m.value:3===s?u=m.get:4===s&&(u=m.set),"function"==typeof y)void 0!==(h=t(y,i,m,c,s,n,l,d,u))&&(r(s,h),0===s?p=h:1===s?(p=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h);else for(var b=y.length-1;b>=0;b--)void 0!==(h=t(y[b],i,m,c,s,n,l,d,u))&&(r(s,h),0===s?g=h:1===s?(g=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h,void 0!==g&&(void 0===p?p=g:"function"==typeof p?p=[p,g]:p.push(g)));if(0===s||1===s){if(void 0===p)p=function(e,t){return t};else if("function"!=typeof p){var v=p;p=function(e,t){for(var a=t,r=0;r0){for(var s=[],n=t,l=t.name,c=a.length-1;c>=0;c--){var d={v:!1};try{var m=a[c](n,{kind:"class",name:l,addInitializer:e(s,d),metadata:o})}finally{d.v=!0}void 0!==m&&(r(10,m),n=m)}return[i(n,o),function(){for(var e=0;eclass extends e{setup(e){super.setup(e),this.hooks=e.hooks??[]}deserialize(e){return this.hooks.length?this.hooks.reduce((e,t)=>t.deserialize(e),Object.assign({},e)):e}toObject(e){return this.deserialize(super.toObject(e))}constructor(...e){super(...e),this.hooks=[]}};class A{static{({c:[r,i]}=F(this,[],[o]))}constructor(e,t){this.tableName=e,this.doc=t,this.deleteFlagKey="$$DELETED",this.keyField="key",this.fields=[],this.origin="YjsTableAdapter"}setup(e){this.keyField=e.keyField,this.fields=Object.keys(e.schema)}dispose(){this.doc.destroy()}insert(e){let{data:t,select:a}=e;w.validateYjsEntityData(this.tableName,t);let r=t[this.keyField],o=this.doc.getMap(r.toString());return this.doc.transact(()=>{for(let e in t)o.set(e,t[e]);o.delete(this.deleteFlagKey)},this.origin),this.value(o,a)}update(e){let{data:t,select:a,where:r}=e;w.validateYjsEntityData(this.tableName,t);let o=[];return this.doc.transact(()=>{for(let e of this.iterate(r))for(let r in o.push(this.value(e,a)),t)this.setField(e,r,t[r])},this.origin),o}find(e){let{where:t,select:a}=e,r=[];for(let e of this.iterate(t))r.push(this.value(e,a));return r}observe(e){let{where:t,select:a,callback:r}=e,o=!1,i=new Map;for(let e of(t||(o=!0),this.iterate(t)))i.set(this.keyof(e),this.value(e,a));r(Array.from(i.values()));let s=e=>{let s=!1;for(let[r]of e.changed){let e=this.keyof(r),n=(o||t&&this.match(r,t))&&!this.isDeleted(r),l=i.get(e),c=i.has(e);if(n&&c){let t=this.value(r,a);l!==t&&(i.set(e,t),s=!0)}else n&&!c?(i.set(this.keyof(r),this.value(r,a)),s=!0):!n&&c&&(i.delete(e),s=!0)}s&&r(Array.from(i.values()))};return this.doc.on("afterTransaction",s),()=>{this.doc.off("afterTransaction",s)}}delete(e){let{where:t}=e;this.doc.transact(()=>{for(let e of this.iterate(t))this.deleteTy(e)},this.origin)}toObject(e){return s.Map.prototype.toJSON.call(e)}recordByKey(e){return this.doc.share.has(e)?this.doc.getMap(e):null}*iterate(e){if(e){if("byKey"in e){let t=this.recordByKey(e.byKey.toString());t&&(yield t)}else if(Array.isArray(e))for(let t of this.doc.share.values())this.match(t,e)&&(yield t)}else for(let e of this.doc.share.values())this.isDeleted(e)||(yield e)}value(e,t="*"){let a;return this.isDeleted(e)||this.isEmpty(e)?null:"key"===t?this.keyof(e):(a="*"===t?this.fields:t,(0,p.A)(this.toObject(e),a))}match(e,t){return!this.isDeleted(e)&&(Array.isArray(t)?0!==t.length&&t.every(t=>this.field(e,t.field)===t.value):t.byKey===this.keyof(e))}isDeleted(e){return!0===this.field(e,this.deleteFlagKey)||this.isEmpty(e)}keyof(e){return this.field(e,this.keyField)}field(e,t){return s.Map.prototype.get.call(e,t)}setField(e,t,a){s.Map.prototype.set.call(e,t,a)}isEmpty(e){return 0===e._map.size}deleteTy(e){this.fields.forEach(t=>{t!==this.keyField&&s.Map.prototype.delete.call(e,t)}),s.Map.prototype.set.call(e,this.deleteFlagKey,!0)}static{i()}}class E{constructor(e,t){for(let[a,o]of(this.provider=t,this.tables=new Map,Object.entries(e))){w.validateYjsTableSchema(a,o);let e=this.provider.getDoc(a);this.tables.set(a,new r(a,e))}}table(e){let t=this.tables.get(e);if(!t)throw Error("Table not found");return t}}var N=a(34177),_=a(99866),I=a(30397);class j{constructor(e){this.schema={type:"string",optional:!1,isPrimaryKey:!1,default:void 0},this.schema.type=e}optional(){return this.schema.optional=!0,this}default(e){return this.schema.default=e,this.schema.optional=!0,this}primaryKey(){return this.schema.isPrimaryKey=!0,this}}let D={string:()=>new j("string")},M={folders:{id:D.string().primaryKey().optional().default(I.Ak),parentId:D.string().optional(),data:D.string(),type:D.string(),index:D.string()}},T={favorite:{key:D.string().primaryKey(),index:D.string()}},P=S(M),L=S(T);class $ extends n.k{constructor(e){super(),this.workspaceService=e,this.userdataDBPool=new N.i({onDangling:()=>!1}),this.db=this.framework.createEntity(_.DB,{db:new P(new E(M,{getDoc:e=>{let t=new s.Doc({guid:`db$${this.workspaceService.workspace.id}$${e}`});return this.workspaceService.workspace.engine.doc.addDoc(t,!1),this.workspaceService.workspace.engine.doc.setPriority(t.guid,50),t}})),schema:M,storageDocId:e=>`db$${this.workspaceService.workspace.id}$${e}`})}userdataDB(e){let t=this.userdataDBPool.get(e);if(t)return t.obj;let a=this.framework.createEntity(_.DB,{db:new L(new E(T,{getDoc:t=>{let a=new s.Doc({guid:`userdata$${e}$${this.workspaceService.workspace.id}$${t}`});return this.workspaceService.workspace.engine.doc.addDoc(a,!1),this.workspaceService.workspace.engine.doc.setPriority(a.guid,50),a}})),schema:T,storageDocId:t=>`userdata$${e}$${this.workspaceService.workspace.id}$${t}`});return this.userdataDBPool.put(e,a),a}static isDBDocId(e){return e.startsWith("db$")||e.startsWith("userdata$")}}async function W(e,t,a,r,o){for(let o of Object.keys(M)){let i=`db$${e}$${o}`,s=await a.doc.get(i);if(s){let e=`db$${t}$${o}`;await r.doc.set(e,s)}}for(let i of Object.keys(T)){let s=`userdata$__local__$${e}$${i}`,n=await a.doc.get(s);if(n){let e=`userdata$${o}$${t}$${i}`;await r.doc.set(e,n)}}}},71504:(e,t,a)=>{"use strict";a.d(t,{J:()=>o});var r=a(29820);class o extends r.w{constructor(e,t){super(),this.scope=e,this.store=t,this.blockSuiteDoc=this.scope.props.blockSuiteDoc,this.record=this.scope.props.record,this.meta$=this.record.meta$,this.mode$=this.record.mode$,this.title$=this.record.title$,this.trash$=this.record.trash$}get id(){return this.scope.props.docId}setMode(e){return this.record.setMode(e)}getMode(){return this.record.getMode()}toggleMode(){return this.record.toggleMode()}observeMode(){return this.record.observeMode()}moveToTrash(){return this.record.moveToTrash()}restoreFromTrash(){return this.record.restoreFromTrash()}waitForSyncReady(){return this.store.waitForDocLoadReady(this.id)}setPriorityLoad(e){return this.store.setPriorityLoad(this.id,e)}}},91958:(e,t,a)=>{"use strict";a.d(t,{q:()=>n});var r=a(28138),o=a(29820),i=a(34802),s=a(33745);class n extends o.w{constructor(e){super(),this.store=e,this.pool=new Map,this.docs$=i.D.from(this.store.watchDocIds().pipe((0,r.T)(e=>e.map(e=>{let t=this.pool.get(e);if(t)return t;let a=this.framework.createEntity(s.s,{id:e});return this.pool.set(e,a),a}))),[]),this.trashDocs$=i.D.from(this.store.watchTrashDocIds().pipe((0,r.T)(e=>e.map(e=>{let t=this.pool.get(e);if(t)return t;let a=this.framework.createEntity(s.s,{id:e});return this.pool.set(e,a),a}))),[]),this.isReady$=i.D.from(this.store.watchDocListReady(),!1)}doc$(e){return this.docs$.map(t=>t.find(t=>t.id===e))}setMode(e,t){return this.store.setDocModeSetting(e,t)}getMode(e){return this.store.getDocModeSetting(e)}toggleMode(e){let t="edgeless"===this.getMode(e)?"page":"edgeless";return this.setMode(e,t),this.getMode(e)}observeMode(e){return this.store.watchDocModeSetting(e)}}},33745:(e,t,a)=>{"use strict";a.d(t,{s:()=>i});var r=a(29820),o=a(34802);class i extends r.w{constructor(e){super(),this.docsStore=e,this.id=this.props.id,this.meta$=o.D.from(this.docsStore.watchDocMeta(this.id),{}),this.mode$=o.D.from(this.docsStore.watchDocModeSetting(this.id),"page").map(e=>"edgeless"===e?"edgeless":"page"),this.title$=this.meta$.map(e=>e.title??""),this.trash$=this.meta$.map(e=>e.trash??!1)}setMeta(e){this.docsStore.setDocMeta(this.id,e)}setMode(e){return this.docsStore.setDocModeSetting(this.id,e)}getMode(){return this.docsStore.getDocModeSetting(this.id)}toggleMode(){let e="edgeless"===this.getMode()?"page":"edgeless";return this.setMode(e),this.getMode()}observeMode(){return this.docsStore.watchDocModeSetting(this.id)}moveToTrash(){return this.setMeta({trash:!0})}restoreFromTrash(){return this.setMeta({trash:!1})}}},79930:(e,t,a)=>{"use strict";a.d(t,{B:()=>o});var r=a(66683);class o extends r.H{}},58507:(e,t,a)=>{"use strict";a.d(t,{s:()=>i});var r=a(95284),o=a(71504);class i extends r.k{constructor(...e){super(...e),this.doc=this.framework.createEntity(o.J)}}},70154:(e,t,a)=>{"use strict";a.d(t,{F:()=>d});var r=a(52428),o=a(95284),i=a(56964),s=a(34177),n=a(91958),l=a(79930),c=a(58507);class d extends o.k{constructor(e){super(),this.store=e,this.list=this.framework.createEntity(n.q),this.pool=new s.i({onDelete(e){e.scope.dispose()}})}open(e){let t=this.list.doc$(e).value;if(!t)throw Error("Doc record not found");let a=this.store.getBlockSuiteDoc(e);if(!a)throw Error("Doc not found");let r=this.pool.get(e);if(r)return{doc:r.obj,release:r.release};let o=this.framework.createScope(l.B,{docId:e,blockSuiteDoc:a,record:t}).get(c.s).doc,{obj:i,release:s}=this.pool.put(e,o);return{doc:i,release:s}}createDoc(e={}){let t=this.store.createBlockSuiteDoc();(0,i.h)(t,e.title),this.store.markDocSyncStateAsReady(t.id);let a=this.list.doc$(t.id).value;if(!a)throw new r.c9;return e.mode&&a.setMode(e.mode),a}async addLinkedDoc(e,t){let{doc:a,release:r}=this.open(e);a.setPriorityLoad(10),await a.waitForSyncReady();let o=a.blockSuiteDoc.Text.fromDelta([{insert:" ",attributes:{reference:{type:"LinkedPage",pageId:t}}}]),[i]=a.blockSuiteDoc.getBlocksByFlavour("affine:note");i&&a.blockSuiteDoc.addBlock("affine:paragraph",{text:o},i.id),r()}async changeDocTitle(e,t){let{doc:a,release:r}=this.open(e);a.setPriorityLoad(10),await a.waitForSyncReady();let o=a.blockSuiteDoc.getBlocksByFlavour("affine:page").at(0)?.model;o&&(a.blockSuiteDoc.transact(()=>{o.title.delete(0,o.title.length),o.title.insert(t,0)}),a.record.setMeta({title:t})),r()}}},71218:(e,t,a)=>{"use strict";a.d(t,{F:()=>s});var r=a(29820),o=a(34802),i=a(1598);class s extends r.w{define(e){return this.memento.set(e,null),{get:()=>this.memento.get(e),set:t=>this.memento.set(e,t),$:o.D.from(this.memento.watch(e),null)}}constructor(...e){super(...e),this.memento=new i.n,this.workspaceId=this.define("workspaceId"),this.isDoc=this.define("isDoc"),this.isTrashDoc=this.define("isTrashDoc"),this.docId=this.define("docId"),this.docMode=this.define("docMode"),this.isCollection=this.define("isCollection"),this.collectionId=this.define("collectionId"),this.isTrash=this.define("isTrash"),this.isTag=this.define("isTag"),this.tagId=this.define("tagId"),this.isAllDocs=this.define("isAllDocs")}}},33907:(e,t,a)=>{"use strict";a.d(t,{q:()=>i});var r=a(95284),o=a(71218);class i extends r.k{constructor(...e){super(...e),this.globalContext=this.framework.createEntity(o.F)}}},28066:(e,t,a)=>{"use strict";a.d(t,{IS:()=>i,oK:()=>n,qb:()=>s});var r=a(34354),o=a(95284);let i=(0,r.lh)("ApplicationStartup"),s=(0,r.lh)("ApplicationFocused");class n extends o.k{constructor(){super()}applicationStart(){this.eventBus.emit(i,!0)}applicationFocus(){this.eventBus.emit(s,!0)}}},72071:(e,t,a)=>{"use strict";a.d(t,{R:()=>o,m:()=>i});var r=a(34819);let o=(0,r.Qm)("GlobalState"),i=(0,r.Qm)("GlobalCache")},66861:(e,t,a)=>{"use strict";a.d(t,{D:()=>i,U:()=>o});var r=a(95284);class o extends r.k{constructor(e){super(),this.globalState=e}}class i extends r.k{constructor(e){super(),this.globalCache=e}}},13446:(e,t,a)=>{"use strict";a.d(t,{Q:()=>D});var r=a(29820),o=a(52490),i=a(30397),s=a(28138),n=a(34802),l=a(28563),c=a(52428),d=a(58830),m=a(82377),p=a(50049),u=a(16820),h=a(11766);class f{push(e,t=0){let a=this.priorityMap.get(e);a!==t&&(void 0!==a&&this.remove(e),this.tree.insert({id:e,priority:t}),this.priorityMap.set(e,t))}pop(){let e=this.tree.max();if(!e)return null;this.tree.removeNode(e);let{id:t}=e.getValue();return this.priorityMap.delete(t),t}remove(e,t){if(void 0===(t??=this.priorityMap.get(e)))return!1;let a=this.tree.remove({id:e,priority:t});return a&&this.priorityMap.delete(e),a}clear(){this.tree.clear(),this.priorityMap.clear()}updatePriority(e,t){this.remove(e)&&this.push(e,t)}get length(){return this.tree.count}constructor(){this.tree=new h.BinarySearchTree((e,t)=>e.priority===t.priority?e.id===t.id?0:e.id>t.id?1:-1:e.priority-t.priority),this.priorityMap=new Map}}class g extends f{async asyncPop(e){return this.pop()||(this._waitForUpdate||(this._waitForUpdate=new Promise(e=>{this._resolveUpdate=e})),await Promise.race([this._waitForUpdate,new Promise((t,a)=>{e?.aborted&&a(e?.reason),e?.addEventListener("abort",()=>{a(e.reason)})})]),this.asyncPop(e))}push(e,t=0){if(super.push(e,t),this._resolveUpdate){let e=this._resolveUpdate;this._resolveUpdate=null,this._waitForUpdate=null,e()}}constructor(...e){super(...e),this._resolveUpdate=null,this._waitForUpdate=null}}var y=a(68535);let b="doc-engine",v=new o.k("doc-engine:local");class k{docState$(e){return n.D.from(new m.c(t=>{let a=()=>{t.next({ready:this.status.readyDocs.has(e)??!1,loading:this.status.connectedDocs.has(e),syncing:(this.status.jobMap.get(e)?.length??0)>0||this.status.currentJob?.docId===e})};return a(),this.statusUpdatedSubject$.subscribe(t=>{t===e&&a()})}),{ready:!1,loading:!1,syncing:!1})}constructor(e,t){this.clientId=e,this.storage=t,this.prioritySettings=new Map,this.statusUpdatedSubject$=new p.B,this.status={docs:new Map,connectedDocs:new Set,readyDocs:new Set,jobDocQueue:new g,jobMap:new Map,currentJob:null},this.engineState$=n.D.from(new m.c(e=>{let t=()=>{e.next({total:this.status.docs.size,syncing:this.status.jobMap.size+(this.status.currentJob?1:0)})};return t(),this.statusUpdatedSubject$.subscribe(()=>{t()})}),{syncing:0,total:0}),this.actions={addDoc:e=>{this.schedule({type:"load",docId:e.guid}),this.status.docs.set(e.guid,e),this.statusUpdatedSubject$.next(e.guid)},markAsReady:e=>{this.status.readyDocs.add(e),this.statusUpdatedSubject$.next(e)}},this.jobs={load:async(e,t)=>{let a=this.status.docs.get(e.docId);if(!a)throw new c.c9("doc not found");let r=(0,u.encodeStateAsUpdate)(a);(0,y.f)(r)||this.schedule({type:"save",docId:a.guid,update:r}),a.emit("sync",[!0,a]),a.on("update",this.handleDocUpdate),this.status.connectedDocs.add(e.docId),this.statusUpdatedSubject$.next(e.docId);let o=await this.storage.loadDocFromLocal(e.docId,t);!o||(0,y.f)(o)||(this.applyUpdate(e.docId,o),this.status.readyDocs.add(e.docId),this.statusUpdatedSubject$.next(e.docId))},save:async(e,t,a)=>{if(this.status.connectedDocs.has(e)){let r=(0,u.mergeUpdates)(t.map(e=>e.update).filter(e=>!(0,y.f)(e))),o=await this.storage.commitDocAsClientUpdate(e,r,a);this.storage.eventBus.emit({type:"ClientUpdateCommitted",seqNum:o,docId:e,clientId:this.clientId,update:r})}},apply:async(e,t)=>{(0,l.T)(t),this.status.connectedDocs.has(e.docId)&&this.applyUpdate(e.docId,e.update),e.isInitialize&&!(0,y.f)(e.update)&&(this.status.readyDocs.add(e.docId),this.statusUpdatedSubject$.next(e.docId))}},this.events={ServerUpdateCommitted:({docId:e,update:t,clientId:a})=>{this.schedule({type:"apply",docId:e,update:t,isInitialize:a===this.clientId})},ClientUpdateCommitted:({docId:e,update:t,clientId:a})=>{a!==this.clientId&&this.schedule({type:"apply",docId:e,update:t,isInitialize:!1})}},this.handleDocUpdate=(e,t,a)=>{t!==b&&this.schedule({type:"save",docId:a.guid,update:e})}}async mainLoop(e){let t=this.storage.eventBus.on(e=>{let t=this.events[e.type];t&&t(e)});try{for(;;){(0,l.T)(e);let t=await this.status.jobDocQueue.asyncPop(e),a=this.status.jobMap.get(t);if(this.status.jobMap.delete(t),!a)continue;this.status.currentJob={docId:t,jobs:a},this.statusUpdatedSubject$.next(t);let{apply:r,load:o,save:i}=(0,d.A)(a,e=>e.type);for(let t of(o?.length&&await this.jobs.load(o[0],e),r??[]))await this.jobs.apply(t,e);i?.length&&await this.jobs.save(t,i,e),this.status.currentJob=null,this.statusUpdatedSubject$.next(t)}}finally{for(let e of(t(),this.status.connectedDocs)){let t=this.status.docs.get(e);t&&t.off("update",this.handleDocUpdate)}}}applyUpdate(e,t){let a=this.status.docs.get(e);if(a&&!(0,y.f)(t))try{(0,u.applyUpdate)(a,t,b)}catch(e){v.error("failed to apply update yjs doc",e)}}schedule(e){let t=this.prioritySettings.get(e.docId)??0;this.status.jobDocQueue.push(e.docId,t);let a=this.status.jobMap.get(e.docId)??[];a.push(e),this.status.jobMap.set(e.docId,a),this.statusUpdatedSubject$.next(e.docId)}setPriority(e,t){this.prioritySettings.set(e,t),this.status.jobDocQueue.updatePriority(e,t)}}var w=a(43891);class x{constructor(e){for(let t of(this.map=e,this.max=0,e.values()))t>this.max&&(this.max=t)}get(e){return this.map.get(e)??0}set(e,t){this.map.set(e,t),t>this.max&&(this.max=t)}setIfBigger(e,t){t>this.get(e)&&this.set(e,t)}clear(){this.map.clear(),this.max=0}}let C=new o.k("doc-engine:remote");class S{constructor(e,t,a){this.clientId=e,this.storage=t,this.server=a,this.prioritySettings=new Map,this.status={docs:new Set,connectedDocs:new Set,jobDocQueue:new g,jobMap:new Map,serverClocks:new x(new Map),syncing:!1,retrying:!1,errorMessage:null},this.statusUpdatedSubject$=new p.B,this.engineState$=n.D.from(new m.c(e=>{let t=()=>{if(this.status.syncing){let t=this.status.jobMap.size;e.next({total:this.status.docs.size,syncing:t,retrying:this.status.retrying,errorMessage:this.status.errorMessage})}else e.next({total:this.status.docs.size,syncing:this.status.docs.size,retrying:this.status.retrying,errorMessage:this.status.errorMessage})};return t(),this.statusUpdatedSubject$.subscribe(()=>{t()})}),{syncing:0,total:0,retrying:!1,errorMessage:null}),this.jobs={connect:async(e,t)=>{let a=await this.storage.loadDocSeqNumPushed(e,t),r=await this.storage.loadDocSeqNum(e,t);if(null===a||a!==r)await this.jobs.pullAndPush(e,t);else{let a=await this.storage.loadDocServerClockPulled(e);(null===a||a!==this.status.serverClocks.get(F(e)))&&await this.jobs.pull(e,t)}this.status.connectedDocs.add(e),this.statusUpdatedSubject$.next(e)},push:async(e,t,a)=>{if(this.status.connectedDocs.has(e)){if(Math.max(...t.map(e=>e.seqNum))-(await this.storage.loadDocSeqNumPushed(e,a)??0)===t.length){let r=(0,u.mergeUpdates)(t.map(e=>e.update).filter(e=>!(0,y.f)(e)));if(!(0,y.f)(r)){let{serverClock:t}=await this.server.pushDoc(e,r);this.schedule({type:"save",docId:e,serverClock:t})}await this.storage.saveDocPushedSeqNum(e,{add:t.length},a)}else await this.jobs.pullAndPush(e,a)}},pullAndPush:async(e,t)=>{let a=await this.storage.loadDocSeqNum(e,t),r=await this.storage.loadDocFromLocal(e,t),o=r&&!(0,y.f)(r)?(0,u.encodeStateVectorFromUpdate)(r):new Uint8Array,i=await this.server.pullDoc(e,o);if(i){let{data:o,stateVector:s,serverClock:n}=i;await this.storage.saveServerClock(new Map([[F(e),n]]),t),this.actions.updateServerClock(F(e),n),await this.storage.commitDocAsServerUpdate(e,o,n,t),this.storage.eventBus.emit({type:"ServerUpdateCommitted",docId:e,clientId:this.clientId,update:o});let l=r&&s&&s.length>0?(0,u.diffUpdate)(r,s):r;if(l&&!(0,y.f)(l)){let{serverClock:t}=await this.server.pushDoc(e,l);this.schedule({type:"save",docId:e,serverClock:t})}await this.storage.saveDocPushedSeqNum(e,a,t)}else{if(r&&!(0,y.f)(r)){let{serverClock:a}=await this.server.pushDoc(e,r);await this.storage.saveDocServerClockPulled(e,a,t),await this.storage.saveServerClock(new Map([[F(e),a]]),t),this.actions.updateServerClock(F(e),a)}await this.storage.saveDocPushedSeqNum(e,a,t)}},pull:async(e,t)=>{let a=await this.storage.loadDocFromLocal(e,t),r=a&&!(0,y.f)(a)?(0,u.encodeStateVectorFromUpdate)(a):new Uint8Array,o=await this.server.pullDoc(e,r);if(!o)return;let{data:i,serverClock:s}=o;await this.storage.commitDocAsServerUpdate(e,i,s,t),this.storage.eventBus.emit({type:"ServerUpdateCommitted",docId:e,clientId:this.clientId,update:i}),await this.storage.saveServerClock(new Map([[F(e),s]]),t),this.actions.updateServerClock(F(e),s)},save:async(e,t,a)=>{let r=t.reduce((e,t)=>Math.max(e,t.serverClock),0);if(await this.storage.saveServerClock(new Map([[F(e),r]]),a),this.actions.updateServerClock(F(e),r),this.status.connectedDocs.has(e)){let o=t.map(e=>e.update).filter(e=>!!e&&!(0,y.f)(e)),i=o.length>0?(0,u.mergeUpdates)(o):new Uint8Array;await this.storage.commitDocAsServerUpdate(e,i,r,a),this.storage.eventBus.emit({type:"ServerUpdateCommitted",docId:e,clientId:this.clientId,update:i})}}},this.actions={updateServerClock:(e,t)=>{this.status.serverClocks.setIfBigger(e,t),this.statusUpdatedSubject$.next(e)},addDoc:e=>{this.status.docs.has(e)||(this.status.docs.add(e),this.statusUpdatedSubject$.next(e),this.schedule({type:"connect",docId:e}))}},this.events={ClientUpdateCommitted:({clientId:e,docId:t,seqNum:a,update:r})=>{e===this.clientId&&this.schedule({type:"push",docId:t,update:r,seqNum:a})}}}docState$(e){return n.D.from(new m.c(t=>{let a=()=>{t.next({syncing:!this.status.connectedDocs.has(e)||this.status.jobMap.has(e),serverClock:this.status.serverClocks.get(e),retrying:this.status.retrying,errorMessage:this.status.errorMessage})};return a(),this.statusUpdatedSubject$.subscribe(t=>{(!0===t||t===e)&&a()})}),{syncing:!1,retrying:!1,errorMessage:null,serverClock:null})}async mainLoop(e){for(;;){try{await this.retryLoop(e)}catch(t){if(e?.aborted)return;C.error("Remote sync error, retry in 5s",t),this.status.errorMessage=t instanceof Error?t.message:`${t}`,this.statusUpdatedSubject$.next(!0)}finally{this.status={docs:this.status.docs,connectedDocs:new Set,jobDocQueue:new g,jobMap:new Map,serverClocks:new x(new Map),syncing:!1,retrying:!0,errorMessage:this.status.errorMessage},this.statusUpdatedSubject$.next(!0)}await Promise.race([new Promise(e=>{setTimeout(e,5e3)}),new Promise((t,a)=>{e?.aborted&&a(e.reason),e?.addEventListener("abort",()=>{a(e.reason)})})])}}async retryLoop(e){(0,l.T)(e);let t=new AbortController;e?.addEventListener("abort",e=>{t.abort(e)}),e=t.signal;let a=[];try{for(let t of(a.push(this.storage.eventBus.on(e=>{let t=this.events[e.type];t?.(e)})),(0,l.T)(e),this.status.docs))this.schedule({type:"connect",docId:t});for(let[r,o]of(C.info("Remote sync started"),this.status.syncing=!0,this.statusUpdatedSubject$.next(!0),this.server.onInterrupted(e=>{t.abort(e)}),await Promise.race([this.server.waitForConnectingServer(e),new Promise((e,t)=>{setTimeout(()=>{t(Error("Connect to server timeout"))},3e4)}),new Promise((t,a)=>{e?.addEventListener("abort",e=>{a(e)})})]),this.status.retrying=!1,this.statusUpdatedSubject$.next(!0),(0,l.T)(e),a.push(await this.server.subscribeAllDocs(({docId:e,data:t,serverClock:a})=>{this.schedule({type:"save",docId:e,serverClock:a,update:t})})),await this.storage.loadServerClock(e)))this.actions.updateServerClock(r,o);let r=this.status.serverClocks.max,o=await this.server.loadServerClock(r);for(let[e,t]of o)this.actions.updateServerClock(e,t);for(await this.storage.saveServerClock(o,e);;){(0,l.T)(e);let t=await this.status.jobDocQueue.asyncPop(e);for(;;){let a=this.status.jobMap.get(t);if(!a||0===a.length){this.status.jobMap.delete(t),this.statusUpdatedSubject$.next(t);break}let r=(0,w.A)(a,e=>"connect"===e.type);if(r&&r.length>0){await this.jobs.connect(t,e);continue}let o=(0,w.A)(a,e=>"pullAndPush"===e.type);if(o&&o.length>0){await this.jobs.pullAndPush(t,e);continue}let i=(0,w.A)(a,e=>"pull"===e.type);if(i&&i.length>0){await this.jobs.pull(t,e);continue}let s=(0,w.A)(a,e=>"push"===e.type);if(s&&s.length>0){await this.jobs.push(t,s,e);continue}let n=(0,w.A)(a,e=>"save"===e.type);if(n&&n.length>0){await this.jobs.save(t,n,e);continue}}}}finally{for(let e of a)e();try{this.server.disconnectServer()}catch(e){C.error("Error on disconnect server",e)}this.status.syncing=!1,C.info("Remote sync ended")}}schedule(e){let t=this.prioritySettings.get(e.docId)??0;this.status.jobDocQueue.push(e.docId,t);let a=this.status.jobMap.get(e.docId)??[];a.push(e),this.status.jobMap.set(e.docId,a),this.statusUpdatedSubject$.next(e.docId)}setPriority(e,t){this.prioritySettings.set(e,t),this.status.jobDocQueue.updatePriority(e,t)}}function F(e){var t;let a;(t=a||(a={})).Workspace="workspace",t.Page="page",t.Space="space",t.Settings="settings",t.Unknown="unknown";try{if(!e.length)throw Error("Invalid Empty Doc ID");let t=e.split(":");if(t.length>3){if("space"===t[1]&&"page"===t[2])t=[t[0],"space",t[3]];else throw Error(`Invalid format of Doc ID: ${e}`)}else if(2===t.length)throw Error("not supported");else 1===t.length&&(t=["","unknown",t[0]]);let a=t.at(2);if(!a)throw Error("ID is required");return a}catch(t){return C.error("Error on normalize docId "+e,t),e}}var A=a(88082);let E=new o.k("doc-engine");class N{docState$(e){let t=this.localPart.docState$(e),a=this.remotePart?.docState$(e);return n.D.computed(e=>{let r=e(t),o=a?e(a):null;return o?{syncing:o.syncing,saving:r.syncing,loading:r.syncing,retrying:o.retrying,ready:r.ready,errorMessage:o.errorMessage,serverClock:o.serverClock}:{syncing:r.syncing,saving:r.syncing,loading:r.syncing,ready:r.ready,retrying:!1,errorMessage:null,serverClock:null}})}markAsReady(e){this.localPart.actions.markAsReady(e)}constructor(e,t){this.server=t,this.engineState$=n.D.computed(e=>{let t=e(this.localPart.engineState$);if(this.remotePart){let a=e(this.remotePart?.engineState$);return{total:a.total,syncing:a.syncing,saving:t.syncing,retrying:a.retrying,errorMessage:a.errorMessage}}return{total:t.total,syncing:t.syncing,saving:t.syncing,retrying:!1,errorMessage:null}}),this.abort=new AbortController,this.clientId=(0,i.Ak)(),this.storage=new A.ws(e),this.localPart=new k(this.clientId,this.storage),this.remotePart=this.server?new S(this.clientId,this.storage,this.server):null}start(){return this.abort.abort(l.f),this.abort=new AbortController,Promise.all([this.localPart.mainLoop(this.abort.signal),this.remotePart?.mainLoop(this.abort.signal)]).catch(e=>{e!==l.f&&E.error("Doc engine error",e)}),this}stop(){this.abort.abort(l.f)}async resetSyncStatus(){this.stop(),await this.storage.clearSyncMetadata(),await this.storage.clearServerClock()}addDoc(e,t=!0){if(this.localPart.actions.addDoc(e),this.remotePart?.actions.addDoc(e.guid),t){for(let t of e.getSubdocs())this.addDoc(t,!1);e.on("subdocs",({added:e})=>{for(let t of e)this.addDoc(t,!1)})}}setPriority(e,t){this.localPart.setPriority(e,t),this.remotePart?.setPriority(e,t)}waitForSaved(){return new Promise(e=>{this.engineState$.pipe((0,s.T)(e=>0===e.saving)).subscribe(t=>{t&&e()})})}waitForSynced(){return new Promise(e=>{this.engineState$.pipe((0,s.T)(e=>0===e.syncing&&0===e.saving)).subscribe(t=>{t&&e()})})}waitForReady(e){return new Promise(t=>{this.docState$(e).pipe((0,s.T)(e=>e.ready)).subscribe(e=>{e&&t()})})}}var _=a(7684);class I{constructor(e){this.connections=e}connect(e){this.connections.forEach(t=>t.connect(e))}disconnect(){this.connections.forEach(e=>e.disconnect())}}var j=a(69461);class D extends r.w{constructor(e){super(),this.workspaceService=e,this.doc=new N(this.props.engineProvider.getDocStorage(),this.props.engineProvider.getDocServer()),this.blob=new _.kb(this.props.engineProvider.getLocalBlobStorage(),this.props.engineProvider.getRemoteBlobStorages()),this.awareness=new I(this.props.engineProvider.getAwarenessConnections()),this.docEngineState$=this.doc.engineState$,this.rootDocState$=this.doc.docState$(this.workspaceService.workspace.id)}setRootDoc(e){this.doc.setPriority(e.guid,100),this.doc.addDoc(e)}start(){this.eventBus.emit(j.v,this),this.doc.start(),this.awareness.connect(this.workspaceService.workspace.awareness),this.blob.start()}canGracefulStop(){return 0===this.doc.engineState$.value.saving}async waitForGracefulStop(e){await this.doc.waitForSaved(),(0,l.T)(e),this.forceStop()}forceStop(){this.doc.stop(),this.awareness.disconnect(),this.blob.stop()}waitForDocSynced(){return this.doc.waitForSynced()}waitForRootDocReady(){return this.doc.waitForReady(this.workspaceService.workspace.id)}dispose(){this.forceStop()}}},52617:(e,t,a)=>{"use strict";a.d(t,{G:()=>g});var r,o=a(52428),i=a(21823),s=a(16820);function n(e,t){let a=e.doc.share.get("space:meta"),r=Array.from(e.doc.share.keys()),o=!!a&&a.size>0,i=r.some(e=>e.startsWith("space:"));if(!t&&(o||i))return 1;if(!e.meta.docs?.length)return null;for(let t of e.doc.getMap("meta").get("pages")){let e=t.get("id");if(e?.includes(":"))return 2}for(let[t,a]of e.doc.getMap("spaces"))if(t.includes(":"))return 2;if(!e.meta.hasVersion)return 3;if((e.meta.docs?.length??0)<=1)try{e.meta.validateVersion(e)}catch(e){return console.info("validateVersion error",e),3}for(let[t,a]of Object.entries(e.meta.blockVersions??{})){let r=e.schema.flavourSchemaMap.get(t);if(r?.version!==a)return 3}return null}!function(e){e[e.SubDoc=1]="SubDoc",e[e.GuidFix=2]="GuidFix",e[e.BlockVersion=3]="BlockVersion"}(r||(r={}));var l=a(30397);let c="affine-migration",d=async(e,t)=>{let a=function(e){if(!(Array.from(e.getMap("space:meta").keys()).length>0))return e;let t=new s.Doc,a={};return!function(e,t,a){let r=e.getMap("space:meta"),o=r.get("versions"),i=r.get("pages"),n=t.getMap("meta"),c=new s.Array,d=o.clone();n.set("workspaceVersion",1),n.set("blockVersions",d),n.set("pages",c),n.set("name",r.get("name")),function(e){let t=e.get("affine:frame");void 0!==t&&(e.set("affine:note",t),e.delete("affine:frame"));let a=e.get("affine:embed");void 0!==a&&(e.set("affine:image",a),e.delete("affine:embed"));let r=e.get("affine:database");void 0!==r&&r<2&&e.set("affine:database",2)}(d);let m=i.map(e=>{let t=new s.Map;return Array.from(e.entries()).filter(([e])=>"subpageIds"!==e).forEach(([e,r])=>{"id"===e?(a[r]=(0,l.Ak)(),t.set(e,a[r])):t.set(e,r)}),t});c.push(m)}(e,t,a),!function(e,t,a){let r=t.getMap("spaces"),o=e.getMap("space:meta"),i=o.get("versions");o.get("pages").forEach(t=>{let o=t.get("id"),n=a[o],l=o.startsWith("space:")?o:`space:${o}`,c=e.getMap(l),d=new s.Doc;r.set(n,d),d.guid=o;let m=d.getMap("blocks");Array.from(c.entries()).forEach(([e,t])=>{let a=t.clone();m.set(e,a);let r=a.get("sys:flavour"),o=i.get(r);void 0!==o&&function(e,t,a){if("affine:frame"===e){t.set("sys:flavour","affine:note");return}if("affine:surface"===e&&a<=3){if(t.has("elements")){let e=t.get("elements");(function(e){for(let[,t]of e.entries())"connector"===t.get("type")&&function(e){let t=e.get("startElement")?.id,a=e.get("controllers"),r=a.length,o=JSON.parse(e.get("xywh"));t?e.set("source",{id:t}):e.set("source",{position:[a[0].x+o[0],a[0].y+o[1]]}),(t=e.get("endElement")?.id)?e.set("target",{id:t}):e.set("target",{position:[a[r-1].x+o[0],a[r-1].y+o[1]]});let i=e.get("lineWidth")??4;e.set("strokeWidth",i);let s=e.get("color");e.set("stroke",s),e.delete("startElement"),e.delete("endElement"),e.delete("controllers"),e.delete("lineWidth"),e.delete("color"),e.delete("xywh")}(t)})(e),t.set("prop:elements",e.clone()),t.delete("elements")}else t.set("prop:elements",new s.Map)}"affine:embed"===e&&(t.set("sys:flavour","affine:image"),t.delete("prop:type")),"affine:database"===e&&a<2&&function(e){e.delete("prop:mode"),e.set("prop:views",new s.Array);let t=e.get("prop:columns").toJSON(),a=[{id:"default",name:"Table",columns:t.map(e=>({id:e.id,width:e.width,hide:e.hide})),filter:{type:"group",op:"and",conditions:[]},mode:"table"}],r=e.get("prop:cells").toJSON(),o=(e,t)=>{Object.values(r).forEach(a=>{null!==a[e]&&void 0!==a[e]&&t(a[e])})},i=t.map(e=>{let t={};return("select"===e.type||"multi-select"===e.type)&&(t={options:e.selection},"select"===e.type?o(e.id,e=>{Array.isArray(e.value)&&(e.value=e.value[0]?.id)}):o(e.id,e=>{Array.isArray(e.value)&&(e.value=e.value.map(e=>e.id))})),"number"===e.type&&o(e.id,e=>{"string"==typeof e.value&&(e.value=Number.parseFloat(e.value.toString()))}),{id:e.id,type:e.type,name:e.name,data:t}});e.set("prop:columns",i),e.set("prop:views",a),e.set("prop:cells",r)}(t)}(r,a,o)})})}(e,t,a),t}(e);(0,s.applyUpdate)(t,(0,s.encodeStateAsUpdate)(a),c),a.getSubdocs().forEach(e=>{t.getSubdocs().forEach(t=>{e.guid===t.guid&&(0,s.applyUpdate)(t,(0,s.encodeStateAsUpdate)(e),c)})})},m=e=>[...e.flavourSchemaMap.entries()].reduce((e,[t,a])=>(e[t]=a.version,e),{});async function p(e,t){let a=e.getMap("spaces"),r=e.getMap("meta"),o=r.get("blockVersions"),i=o?.toJSON()??{};return a.forEach(e=>{try{t.upgradeDoc(0,i,e)}catch(e){console.error(e)}}),t.upgradeCollection(e),(0,s.transact)(e,()=>{let e=r.get("pageVersion");("number"!=typeof e||e<2)&&r.set("pageVersion",2);let a=m(t);return r.set("blockVersions",new s.Map(Object.entries(a))),Object.entries(i).some(([e,t])=>a[e]!==t)},"migratePages",!1)}function u(e){let t=e.getMap("meta").get("pages");t?.forEach(e=>{let t=e.get("id");t?.includes(":")&&e.set("id",t.split(":").at(-1))});let a=e.getMap("spaces");a?.forEach((e,t)=>{if(t.includes(":")){let r=t.split(":").at(-1)??t,o=new s.Doc;s.applyUpdate(o,s.encodeStateAsUpdate(e)),o.guid=e.guid,a.set(r,o),a.delete(t),console.debug(`fixed space id ${t} -> ${r}, doc id: ${e.guid}`)}})}var h=a(29820),f=a(34802);class g extends h.w{constructor(e,t,a){super(),this.workspaceService=e,this.workspaceFactory=t,this.workspaceDestroy=a,this.needUpgrade$=new f.D(!1),this.upgrading$=new f.D(!1),this.checkIfNeedUpgrade(),e.workspace.docCollection.doc.on("update",()=>{this.checkIfNeedUpgrade()})}checkIfNeedUpgrade(){let e=!!n(this.workspaceService.workspace.docCollection,this.workspaceService.workspace.flavour===i.j.AFFINE_CLOUD);return this.needUpgrade$.next(e),e}async upgrade(){if(this.upgrading$.value)return null;this.upgrading$.next(!0);try{await this.workspaceService.workspace.engine.waitForDocSynced();let e=n(this.workspaceService.workspace.docCollection,this.workspaceService.workspace.flavour===i.j.AFFINE_CLOUD);if(!e)return null;let t=new s.Doc({guid:this.workspaceService.workspace.docCollection.doc.guid});if(y(t,this.workspaceService.workspace.docCollection.doc),e===r.SubDoc){let e=await this.workspaceFactory.create(i.j.LOCAL,async(e,a)=>{for(let r of(await d(t,e.doc),u(t),await p(e.doc,this.workspaceService.workspace.docCollection.schema),await this.workspaceService.workspace.docCollection.blobSync.list())){let e=await this.workspaceService.workspace.docCollection.blobSync.get(r);e&&await a.set(r,e)}});return await this.workspaceDestroy.deleteWorkspace(this.workspaceService.workspace.meta),e}if(e===r.GuidFix)return u(t),await p(t,this.workspaceService.workspace.docCollection.schema),y(this.workspaceService.workspace.docCollection.doc,t),await this.workspaceService.workspace.engine.waitForDocSynced(),null;if(e===r.BlockVersion)return await p(t,this.workspaceService.workspace.docCollection.schema),y(this.workspaceService.workspace.docCollection.doc,t),await this.workspaceService.workspace.engine.waitForDocSynced(),null;throw new o.c9}finally{this.upgrading$.next(!1)}}}function y(e,t){for(let a of((0,s.applyUpdate)(e,(0,s.encodeStateAsUpdate)(t)),e.subdocs.values())){let e=Array.from(t.subdocs.values()).find(e=>e.guid===a.guid);e&&y(a,e)}}},82942:(e,t,a)=>{"use strict";a.d(t,{a:()=>m});var r=a(73711),o=a(30397),i=a(82377),s=a(29820),n=a(34802),l=a(16146),c=a(68292),d=a(78128);class m extends s.w{constructor(e){super(),this.scope=e,this.id=this.scope.props.openOptions.metadata.id,this.openOptions=this.scope.props.openOptions,this.meta=this.scope.props.openOptions.metadata,this.flavour=this.meta.flavour,this._docCollection=null,this.name$=n.D.from(new i.c(e=>(e.next(this.docCollection.meta.name),this.docCollection.meta.commonFieldsUpdated.on(()=>{e.next(this.docCollection.meta.name)}).dispose)),void 0),this.avatar$=n.D.from(new i.c(e=>(e.next(this.docCollection.meta.avatar),this.docCollection.meta.commonFieldsUpdated.on(()=>{e.next(this.docCollection.meta.avatar)}).dispose)),void 0)}get docCollection(){return this._docCollection||(this._docCollection=new r.rl({id:this.openOptions.metadata.id,blobSources:{main:this.engine.blob},idGenerator:()=>(0,o.Ak)(),schema:l.G,disableBacklinkIndex:!0,disableSearchIndex:!0})),this._docCollection}get awareness(){return this.docCollection.awarenessStore.awareness}get rootYDoc(){return this.docCollection.doc}get canGracefulStop(){return!0}get engine(){return this.framework.get(c.r).engine}get upgrade(){return this.framework.get(d.N).upgrade}get flavourProvider(){return this.scope.props.flavourProvider}}},69461:(e,t,a)=>{"use strict";a.d(t,{v:()=>r});let r=(0,a(34354).lh)("WorkspaceEngineBeforeStart")},16146:(e,t,a)=>{"use strict";a.d(t,{G:()=>i});var r=a(77955),o=a(52153);let i=new(a(73711)).Sj,s=[...r.g,o.Jy];i.register(s)},27887:(e,t,a)=>{"use strict";a.d(t,{k:()=>r});let r=(0,a(34819).Qm)("WorkspaceFlavourProvider")},50211:(e,t,a)=>{"use strict";a.d(t,{K:()=>o,V:()=>i});var r=a(34819);let o=(0,r.Qm)("WorkspaceLocalState"),i=(0,r.Qm)("WorkspaceLocalCache")},36548:(e,t,a)=>{"use strict";a.d(t,{u:()=>o});var r=a(66683);class o extends r.H{}},68292:(e,t,a)=>{"use strict";a.d(t,{r:()=>i});var r=a(95284),o=a(13446);class i extends r.k{get engine(){return this._engine||(this._engine=this.framework.createEntity(o.Q,{engineProvider:this.workspaceScope.props.flavourProvider.getEngineProvider(this.workspaceScope.props.openOptions.metadata.id)})),this._engine}constructor(e){super(),this.workspaceScope=e,this._engine=null}}},78128:(e,t,a)=>{"use strict";a.d(t,{N:()=>i});var r=a(95284),o=a(52617);class i extends r.k{constructor(...e){super(...e),this.upgrade=this.framework.createEntity(o.G)}}},17049:(e,t,a)=>{"use strict";a.d(t,{j:()=>i});var r=a(95284),o=a(82942);class i extends r.k{get workspace(){return this._workspace||(this._workspace=this.framework.createEntity(o.a)),this._workspace}constructor(...e){super(...e),this._workspace=null}}},98504:(e,t,a)=>{"use strict";a.d(t,{q:()=>o});var r=a(95284);class o extends r.k{get list(){return this.listService.list}constructor(e,t,a,r,o,i,s){super(),this.providers=e,this.listService=t,this.profileRepo=a,this.transform=r,this.workspaceRepo=o,this.workspaceFactory=i,this.destroy=s}get deleteWorkspace(){return this.destroy.deleteWorkspace}get getProfile(){return this.profileRepo.getProfile}get transformLocalToCloud(){return this.transform.transformLocalToCloud}get open(){return this.workspaceRepo.open}get create(){return this.workspaceFactory.create}async getWorkspaceBlob(e,t){return await this.providers.find(t=>t.flavour===e.flavour)?.getWorkspaceBlob(e.id,t)}}},1598:(e,t,a)=>{"use strict";a.d(t,{n:()=>o,u:()=>i});var r=a(34802);class o{setAll(e){for(let[t,a]of Object.entries(e))this.set(t,a)}getLiveData(e){let t=this.data.get(e);return t||(t=new r.D(void 0),this.data.set(e,t)),t}get(e){return this.getLiveData(e).value}watch(e){return this.getLiveData(e).asObservable()}set(e,t){this.getLiveData(e).next(t)}keys(){return Array.from(this.data).filter(([e,t])=>void 0!==t.value).map(([e])=>e)}clear(){this.data.clear()}del(e){this.data.delete(e)}constructor(){this.data=new Map}}function i(e,t){return{get:a=>e.get(t+a),watch:a=>e.watch(t+a),set(a,r){e.set(t+a,r)},keys:()=>e.keys().filter(e=>e.startsWith(t)).map(e=>e.slice(t.length)),clear(){e.keys().forEach(a=>{a.startsWith(t)&&e.del(a)})},del(a){e.del(t+a)}}}},7684:(e,t,a)=>{"use strict";a.d(t,{kb:()=>d,km:()=>m});var r=a(52490),o=a(50620),i=a(20593),s=a(34802),n=a(28563),l=a(3681);let c=new r.k("affine:blob-engine");class d{constructor(e,t){this.local=e,this.remotes=t,this.name="blob-engine",this.readonly=this.local.readonly,this.abort=null,this.isStorageOverCapacity$=new s.D(!1),this.singleBlobSizeLimit=104857600,this.onAbortLargeBlob=new o.D}start(){if(this.abort||this.isStorageOverCapacity$.value)return;this.abort=new AbortController;let e=this.abort.signal,t=()=>{e.aborted||this.sync().catch(e=>{c.error("sync blob error",e)}).finally(()=>{setTimeout(t,6e4)})};t()}stop(){this.abort?.abort(n.f),this.abort=null}get storages(){return[this.local,...this.remotes]}async sync(){if(!this.local.readonly){for(let e of(c.debug("start syncing blob..."),this.remotes)){let t=[],a=[];if(!e.readonly){try{t=await this.local.list(),a=await e.list()}catch(e){c.error("error when sync",e);continue}for(let r of(0,i.A)(t,a))try{let t=await this.local.get(r);t&&await e.set(r,t)}catch(t){c.error(`error when sync ${r} from [${this.local.name}] to [${e.name}]`,t)}}for(let r of(0,i.A)(a,t))try{let t=await e.get(r);t&&await this.local.set(r,t)}catch(t){t instanceof l.x&&(this.isStorageOverCapacity$.value=!0),c.error(`error when sync ${r} from [${e.name}] to [${this.local.name}]`,t)}}c.debug("finish syncing blob")}}async get(e){for(let t of(c.debug("get blob",e),this.storages)){let a=await t.get(e);if(a)return a}return null}async set(e,t){if(this.local.readonly)throw Error("local peer is readonly");return t.size>this.singleBlobSizeLimit?(this.onAbortLargeBlob.emit(t),c.error("blob over limit, abort set")):(await this.local.set(e,t),Promise.allSettled(this.remotes.filter(e=>!e.readonly).map(a=>a.set(e,t).catch(e=>{c.error("Error when uploading to peer",e)}))).then(t=>{t.some(({status:e})=>"rejected"===e)?c.error(`blob ${e} update finish, but some peers failed to update`):c.debug(`blob ${e} update finish`)}).catch(()=>{})),e}async delete(e){}async list(){let e=new Set;for(let t of this.storages){let a=await t.list();if(a)for(let t of a)e.add(t)}return Array.from(e)}}let m={name:"empty",readonly:!0,get:async e=>null,async set(e,t){throw Error("not supported")},async delete(e){throw Error("not supported")},list:async()=>[]}},3681:(e,t,a)=>{"use strict";a.d(t,{x:()=>r});class r extends Error{constructor(e){super("Blob storage over capacity."),this.originError=e}}},88082:(e,t,a)=>{"use strict";a.d(t,{ws:()=>u,WM:()=>h});var r=a(16820);class o{async acquire(){let e=null,t=new Promise(t=>{e=t});return await this._lock,this._lock=t,{release:e,[Symbol.dispose]:()=>{e()}}}constructor(){this._lock=Promise.resolve()}}class i{constructor(e=new Map){this.db=e,this.lock=new o}async transaction(e){try{var t=function(){var e="function"==typeof SuppressedError?SuppressedError:function(e,t){var a=Error();return a.name="SuppressedError",a.suppressed=t,a.error=e,a},t={},a=[];function r(e,t){if(null!=t){if(Object(t)!==t)throw TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(e)var r=t[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(null==r&&(r=t[Symbol.dispose||Symbol.for("Symbol.dispose")]),"function"!=typeof r)throw TypeError("Property [Symbol.dispose] is not a function.");a.push({v:t,d:r,a:e})}else e&&a.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r=this.e;function o(){for(;e=a.pop();)try{var e,s=e.d&&e.d.call(e.v);if(e.a)return Promise.resolve(s).then(o,i)}catch(e){return i(e)}if(r!==t)throw r}function i(a){return r=r!==t?new e(r,a):a,o()}return o()}}}();return t.u(await this.lock.acquire()),await e({get:async e=>this.db.get(e)??null,set:async(e,t)=>{this.db.set(e,t)},keys:async()=>Array.from(this.db.keys()),del:async e=>{this.db.delete(e)},clear:async()=>{this.db.clear()}})}catch(e){t.e=e}finally{t.d()}}get(e){return this.transaction(async t=>t.get(e))}set(e,t){return this.transaction(async a=>a.set(e,t))}keys(){return this.transaction(async e=>e.keys())}clear(){return this.transaction(async e=>e.clear())}del(e){return this.transaction(async t=>t.del(e))}}class s extends i{transaction(e){return super.transaction(t=>e({...t,set:()=>Promise.resolve(),del:()=>Promise.resolve(),clear:()=>Promise.resolve()}))}set(e,t){return Promise.resolve()}del(e){return Promise.resolve()}clear(){return Promise.resolve()}}var n=a(28563);class l{emit(e){for(let t of this.listeners)try{t(e)}catch(e){console.error(e)}}on(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}constructor(){this.listeners=new Set}}class c{constructor(e){this.eventBusBehavior=e}emit(e){this.eventBusBehavior.emit(e)}on(e){return this.eventBusBehavior.on(e)}}var d=a(68535);let m={SeqNum:e=>`${e}:seqNum`,SeqNumPushed:e=>`${e}:seqNumPushed`,ServerClockPulled:e=>`${e}:serverClockPulled`},p={UInt64:{parse:e=>Number(new DataView(e.buffer).getBigUint64(0,!1)),serialize:e=>{let t=new ArrayBuffer(8);return new DataView(t).setBigUint64(0,BigInt(e),!1),new Uint8Array(t)}}};class u{constructor(e){this.behavior=e,this.eventBus=new c(this.behavior.eventBus)}async loadServerClock(e){(0,n.T)(e);let t=await this.behavior.serverClock.keys(),a=new Map;for(let e of t){let t=await this.behavior.serverClock.get(e);t&&a.set(e,p.UInt64.parse(t))}return a}async saveServerClock(e,t){(0,n.T)(t),await this.behavior.serverClock.transaction(async t=>{for(let[a,r]of e){let e=await t.get(a);(e?p.UInt64.parse(e):0){let r=m.SeqNum(e),o=await a.get(r),i=o?p.UInt64.parse(o):0;return!0===t?(await a.set(r,p.UInt64.serialize(i+1)),i+1):i{let r=m.SeqNumPushed(e),o=await a.get(r),i=o?p.UInt64.parse(o):null;return"object"==typeof t?a.set(r,p.UInt64.serialize((i??0)+t.add)):null===i||i{let r=await a.get(m.ServerClockPulled(e)),o=r?p.UInt64.parse(r):null;(null===o||o{let o=await a.get(e);await a.set(e,o&&!(0,d.f)(o)?(0,d.f)(t)?o:(0,r.mergeUpdates)([o,t]):t)}),await this.saveDocServerClockPulled(e,a)}async commitDocAsClientUpdate(e,t,a){return(0,n.T)(a),await this.behavior.doc.transaction(async a=>{let o=await a.get(e);await a.set(e,o&&!(0,d.f)(o)?(0,d.f)(t)?o:(0,r.mergeUpdates)([o,t]):t)}),await this.saveDocSeqNum(e,!0)}clearSyncMetadata(){return this.behavior.syncMetadata.clear()}async clearServerClock(){return this.behavior.serverClock.clear()}}class h{constructor(e){this.map=e,this.eventBus=new l,this.doc=new s(new Map(Object.entries(this.map))),this.serverClock=new s,this.syncMetadata=new s}}},68535:(e,t,a)=>{"use strict";function r(e){return 0===e.byteLength||2===e.byteLength&&0===e[0]&&0===e[1]}a.d(t,{f:()=>r})},34177:(e,t,a)=>{"use strict";a.d(t,{i:()=>o});var r=a(52428);class o{constructor(e={}){this.options=e,this.objects=new Map,this.timeoutToGc=null}get(e){let t=this.objects.get(e);if(t){t.rc++;let e=!1;return{obj:t.obj,release:()=>{e||(e=!0,t.rc--,this.requestGc())}}}return null}put(e,t){this.objects.set(e,{obj:t,rc:0});let a=this.get(e);if(!a)throw new r.c9;return a}requestGc(){this.timeoutToGc&&clearInterval(this.timeoutToGc),this.timeoutToGc=setInterval(()=>{this.gc()},1e3)}gc(){for(let[e,{obj:t,rc:a}]of new Map(this.objects))0===a&&(!this.options.onDangling||this.options.onDangling(t))&&(this.options.onDelete?.(t),this.objects.delete(e));for(let[e,{rc:t}]of this.objects)if(0===t)return;this.timeoutToGc&&clearInterval(this.timeoutToGc)}clear(){for(let{obj:e}of this.objects.values())this.options.onDelete?.(e);this.objects.clear()}}},2139:(e,t,a)=>{"use strict";a.d(t,{c:()=>function e(t){let a=typeof t,i=t&&t.constructor,s=i===Date;if(Object(t)===t&&!s&&i!==RegExp){let a,s=r.get(t);if(s)return s;if(s=++o+"~",r.set(t,s),i===Array){for(a=0,s="@";a{"use strict";function r(e){if(e?.aborted)throw Error(e.reason);return!0}a.d(t,{T:()=>r,f:()=>o});let o="manually-stop"},3213:(e,t,a)=>{"use strict";a.d(t,{j:()=>p});var r=a(36870),o=a(55683),i=a(24312),s=a(45483),n=a(86326);let l=()=>{let e=(0,i.s9)();return(0,n.useMemo)(()=>[{title:e["com.arms.other-page.nav.official-website"](),path:"https://affine.pro"},{title:e["com.arms.other-page.nav.affine-community"](),path:"https://community.affine.pro/home"},{title:e["com.arms.other-page.nav.blog"](),path:"https://affine.pro/blog"},{title:e["com.arms.other-page.nav.contact-us"](),path:"https://affine.pro/about-us"}],[e])},c=()=>{let e=l();return(0,r.jsx)("div",{className:"_1c2xj2s3",children:e.map(e=>(0,r.jsx)("a",{href:e.path,target:"_blank",rel:"noreferrer",className:"_1c2xj2s4",children:e.title},e.title))})};var d=a(14277);let m=()=>{let[e,t]=(0,n.useState)(!1),a=l(),i=(0,r.jsx)(r.Fragment,{children:a.map(e=>(0,r.jsx)(d.Dr,{onClick:()=>{open(e.path,"_blank")},className:"_1c2xj2s9",children:e.title},e.title))});return(0,r.jsx)("div",{className:"_1c2xj2s6",children:(0,r.jsx)(d.W1,{items:i,contentOptions:{className:"_1c2xj2s8",sideOffset:20},rootOptions:{open:e,onOpenChange:t},children:(0,r.jsx)(o.K0,{variant:"plain",size:"24",className:"_1c2xj2s5",children:e?(0,r.jsx)(s.CloseIcon,{}):(0,r.jsx)(s.PropertyIcon,{})})})})},p=({children:e})=>{let t=(0,i.s9)(),a=(0,n.useCallback)(()=>{open("https://affine.pro/download","_blank")},[]);return(0,r.jsxs)("div",{className:"_1c2xj2s0",children:[environment.isDesktop?null:(0,r.jsxs)("div",{className:"_1c2xj2s2",children:[(0,r.jsx)("a",{href:"/",rel:"noreferrer",className:"_1c2xj2s1",children:(0,r.jsx)(s.Logo1Icon,{width:24,height:24})}),(0,r.jsx)(c,{}),(0,r.jsx)(o.$n,{onClick:a,className:"_1c2xj2s7",children:t["com.arms.auth.open.affine.download-app"]()}),(0,r.jsx)(m,{})]}),e]})}},94225:(e,t,a)=>{"use strict";a.d(t,{K_:()=>s,F0:()=>l,Ux:()=>L,r:()=>m,oq:()=>g,io:()=>v,b:()=>j,zd:()=>D,cn:()=>T,rQ:()=>$,PW:()=>H,TT:()=>Z,lx:()=>K,rr:()=>Y,Cl:()=>J});var r=a(36870),o=a(37064),i="_17xkjwrc";let s=({children:e,className:t,...a})=>(0,r.jsx)("div",{className:(0,o.A)("_17xkjwr5",t),...a,children:e});var n=a(18859);let l=({label:e,error:t,errorHint:a,withoutHint:i=!1,onEnter:s,className:l,...c})=>(0,r.jsxs)("div",{className:(0,o.A)("_17xkjwr1",{"without-hint":i}),children:[e?(0,r.jsx)("label",{children:e}):null,(0,r.jsx)(n.p,{className:(0,o.A)(l),size:"extraLarge",status:t?"error":"default",onKeyDown:e=>{"Enter"===e.key&&s?.()},...c}),t&&a&&!i?(0,r.jsx)("div",{className:(0,o.A)("_17xkjwr2",{error:t}),children:a}):null]});var c=a(74468),d=a(3213);let m=({children:e,title:t,subtitle:a})=>(0,r.jsx)(d.j,{children:(0,r.jsx)("div",{className:"_17xkjwra",children:(0,r.jsxs)("div",{className:"wrapper",children:[(0,r.jsxs)("div",{className:"content",children:[(0,r.jsx)("p",{className:"title",children:t}),(0,r.jsx)("p",{className:"subtitle",children:a}),e]}),(0,r.jsx)("div",{className:"_17xkjwrd",children:(0,r.jsx)(c.S,{})})]})})});var p=a(24312),u=a(45483),h=a(99971),f=a(55683);let g=e=>{let t=(0,p.s9)();return(0,r.jsx)(f.$n,{variant:"plain",style:{marginTop:12,marginLeft:-5,paddingLeft:0,paddingRight:5,color:(0,h.Vg)("textSecondaryColor")},prefix:(0,r.jsx)(u.ArrowLeftSmallIcon,{}),...e,children:t["com.arms.backButton"]()})};var y=a(86326),b=a(51629);let v=({onChangeEmail:e})=>{let t=(0,p.s9)(),[a,o]=(0,y.useState)(!1),[s,n]=(0,y.useState)(""),[c,d]=(0,y.useState)(!0),[u,h]=(0,y.useState)(!1),g=(0,y.useCallback)(()=>void(async()=>{if(!b.U.test(s)){d(!1);return}d(!0),h(!0);let t=await e(s);h(!1),o(t)})(),[s,e]),v=(0,y.useCallback)(e=>{n(e)},[]);return(0,r.jsx)(m,{title:t["com.arms.auth.change.email.page.title"](),subtitle:t["com.arms.auth.change.email.page.subtitle"](),children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l,{className:i,label:t["com.arms.settings.email"](),placeholder:t["com.arms.auth.sign.email.placeholder"](),value:s,onChange:v,error:!c,errorHint:c?"":t["com.arms.auth.sign.email.error"](),onEnter:g,disabled:a}),(0,r.jsx)(f.$n,{variant:"primary",size:"large",onClick:g,loading:u,disabled:a,children:t["com.arms.auth.set.email.save"]()})]})})};var k=a(67156),w=a(23675),x=a(68672),C=a(67448);let S=()=>(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)("g",{id:"InformationFill_Duotone",children:(0,r.jsxs)("g",{id:"Icon (Stroke)",children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1.33398 8.00065C1.33398 4.31875 4.31875 1.33398 8.00065 1.33398C11.6826 1.33398 14.6673 4.31875 14.6673 8.00065C14.6673 11.6826 11.6826 14.6673 8.00065 14.6673C4.31875 14.6673 1.33398 11.6826 1.33398 8.00065ZM7.33398 5.33398C7.33398 4.96579 7.63246 4.66732 8.00065 4.66732H8.00732C8.37551 4.66732 8.67398 4.96579 8.67398 5.33398C8.67398 5.70217 8.37551 6.00065 8.00732 6.00065H8.00065C7.63246 6.00065 7.33398 5.70217 7.33398 5.33398ZM8.00065 6.66732C8.36884 6.66732 8.66732 6.96579 8.66732 7.33398V10.6673C8.66732 11.0355 8.36884 11.334 8.00065 11.334C7.63246 11.334 7.33398 11.0355 7.33398 10.6673V7.33398C7.33398 6.96579 7.63246 6.66732 8.00065 6.66732Z",fill:"#EB4335"}),(0,r.jsx)("path",{d:"M8.66732 7.33398C8.66732 6.96579 8.36884 6.66732 8.00065 6.66732C7.63246 6.66732 7.33398 6.96579 7.33398 7.33398V10.6673C7.33398 11.0355 7.63246 11.334 8.00065 11.334C8.36884 11.334 8.66732 11.0355 8.66732 10.6673V7.33398Z",fill:"white"}),(0,r.jsx)("path",{d:"M8.00065 4.66732C7.63246 4.66732 7.33398 4.96579 7.33398 5.33398C7.33398 5.70217 7.63246 6.00065 8.00065 6.00065H8.00732C8.37551 6.00065 8.67398 5.70217 8.67398 5.33398C8.67398 4.96579 8.37551 4.66732 8.00732 4.66732H8.00065Z",fill:"white"})]})})});var F="_1dmesnq0";let A=()=>(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsxs)("g",{id:"SingleSelect",children:[(0,r.jsx)("path",{id:"Ellipse 2102 (Stroke)",fillRule:"evenodd",clipRule:"evenodd",d:"M1.5 8C1.5 4.41015 4.41015 1.5 8 1.5C11.5899 1.5 14.5 4.41015 14.5 8C14.5 11.5899 11.5899 14.5 8 14.5C4.41015 14.5 1.5 11.5899 1.5 8Z",fill:"#10CB86"}),(0,r.jsx)("path",{id:"Icon (Stroke)",fillRule:"evenodd",clipRule:"evenodd",d:"M11.0052 5.63143C11.2087 5.81802 11.2225 6.13431 11.0359 6.33787L7.36923 10.3379C7.27708 10.4384 7.14786 10.4969 7.01151 10.4999C6.87517 10.5028 6.74353 10.45 6.6471 10.3536L4.98043 8.68689C4.78517 8.49163 4.78517 8.17505 4.98043 7.97978C5.17569 7.78452 5.49228 7.78452 5.68754 7.97978L6.98495 9.27719L10.2987 5.66214C10.4853 5.45858 10.8016 5.44483 11.0052 5.63143Z",fill:"white"})]})}),E=({status:e,minimum:t,maximum:a})=>{let i=(0,y.useMemo)(()=>({weak:"Weak",medium:"Medium",strong:"Strong",minimum:t,maximum:a}),[t,a]);return(0,r.jsx)("div",{className:(0,o.A)("_1dmesnq1",{weak:"weak"===e,medium:"medium"===e,strong:"strong"===e,minimum:"minimum"===e,maximum:"maximum"===e}),children:i[e]})},N=[{id:0,value:"weak",minDiversity:0,minLength:0},{id:1,value:"medium",minDiversity:4,minLength:8},{id:2,value:"strong",minDiversity:4,minLength:10}],_=({passwordLimits:e,onPass:t,onPrevent:a,...o})=>{let s=(0,p.s9)(),[l,c]=(0,y.useState)(null),[d,m]=(0,y.useState)(null),[u,h]=(0,y.useState)(!1),[f,g]=(0,y.useState)(""),[b,v]=(0,y.useState)(""),k=(0,y.useMemo)(()=>{let{minLength:t,maxLength:a}=e;return C.z.string().superRefine((e,r)=>{e.lengtha&&r.addIssue({code:C.eq.custom,params:{status:"maximum"}});let{value:o}=(0,x.Bi)(e,N);r.addIssue({code:C.eq.custom,message:"password strength",path:["strength"],params:{status:o}})})},[e]),w=(0,y.useCallback)((e,t)=>{let a=k.safeParse(e),r=!1;if(!a.success){let e=a.error.issues[0];c(e.params?.status||null),e.path.includes("strength")&&(r=!0)}if(t){let a=e===t;a?m("success"):m("error"),r&&=a}else r&&=!1,m(null);h(r)},[k]),_=(0,y.useCallback)(e=>{let t=e.trim();g(t),w(t,b)},[w,b]),I=(0,y.useCallback)(e=>{let t=e.trim();v(t),w(f,t)},[w,f]);return(0,y.useEffect)(()=>{u?t(f):a()},[u,f,t,a]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.p,{name:"password",className:i,type:"password",size:"extraLarge",style:{marginBottom:20},placeholder:s["com.arms.auth.set.password.placeholder"]({min:String(e.minLength)}),onChange:_,endFix:(0,r.jsx)("div",{className:F,children:l?(0,r.jsx)(E,{status:l,minimum:s["com.arms.auth.set.password.message.minlength"]({min:String(e.minLength)}),maximum:s["com.arms.auth.set.password.message.maxlength"]({max:String(e.maxLength)})}):null}),...o}),(0,r.jsx)(n.p,{name:"confirmPassword",className:i,type:"password",size:"extraLarge",placeholder:s["com.arms.auth.set.password.placeholder.confirm"](),onChange:I,endFix:(0,r.jsx)("div",{className:F,children:d?"success"===d?(0,r.jsx)(A,{}):(0,r.jsx)(S,{}):null}),...o})]})},I=({passwordLimits:e,onLater:t,onSetPassword:a,showLater:o=!1})=>{let i=(0,p.s9)(),[s,n]=(0,y.useState)(!1),l=(0,y.useRef)("");return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w.mO,{marginTop:30,marginBottom:42,children:(0,r.jsx)(_,{passwordLimits:e,onPass:(0,y.useCallback)(e=>{n(!0),l.current=e},[]),onPrevent:(0,y.useCallback)(()=>{n(!1)},[])})}),(0,r.jsx)(f.$n,{variant:"primary",size:"large",disabled:!s,style:{marginRight:20},onClick:(0,y.useCallback)(()=>{a(l.current)},[a]),children:i["com.arms.auth.set.password.save"]()}),o?(0,r.jsx)(f.$n,{variant:"plain",size:"large",onClick:t,children:i["com.arms.auth.later"]()}):null]})},j=({passwordLimits:e,onSetPassword:t,onOpenAffine:a})=>{let o=(0,p.s9)(),[i,s]=(0,y.useState)(!1),n=(0,y.useCallback)(e=>{t(e).then(()=>s(!0)).catch(e=>k.m.error({title:o["com.arms.auth.password.set-failed"](),message:String(e)}))},[t,o]);return(0,r.jsx)(m,{title:i?o["com.arms.auth.reset.password.page.success"]():o["com.arms.auth.reset.password.page.title"](),subtitle:i?o["com.arms.auth.sent.reset.password.success.message"]():o["com.arms.auth.page.sent.email.subtitle"]({min:String(e.minLength),max:String(e.maxLength)}),children:i?(0,r.jsx)(f.$n,{variant:"primary",size:"large",onClick:a,children:o["com.arms.auth.open.affine"]()}):(0,r.jsx)(I,{passwordLimits:e,onSetPassword:n})})},D=({onOpenAffine:e})=>{let t=(0,p.s9)();return(0,r.jsx)(m,{title:t["com.arms.auth.change.email.page.success.title"](),subtitle:t["com.arms.auth.change.email.page.success.subtitle"](),children:(0,r.jsx)(f.$n,{variant:"primary",size:"large",onClick:e,children:t["com.arms.auth.open.affine"]()})})},M=e=>{let t=Math.floor(e/60).toString().padStart(2,"0"),a=(e%60).toString().padStart(2,"0");return`${t}:${a}`},T=(0,y.forwardRef)(({timeLeft:e,...t},a)=>(0,r.jsx)("div",{...t,ref:a,children:M(e)}));T.displayName="CountDownRender";var P=a(34310);let L=({children:e,open:t,setOpen:a})=>(0,r.jsx)(P.aF,{open:t,onOpenChange:a,width:400,minHeight:500,contentOptions:{"data-testid":"auth-modal",style:{padding:"44px 40px 0"}},children:e}),$=({title:e,subTitle:t})=>(0,r.jsxs)("div",{className:"_17xkjwr0",children:[(0,r.jsxs)("p",{children:[(0,r.jsx)(u.Logo1Icon,{className:"logo"}),e]}),(0,r.jsx)("p",{children:t})]});var W=a(42277),z=a(47488),O=a(15767),B=a(63035),R=a(66889),U="_1vgu04fc",q="_1vgu04fe",V="_1vgu04fk";let G=({headerItems:e,children:t,isMacosDesktop:a,isWindowsDesktop:o})=>(0,r.jsxs)("div",{className:"_1vgu04f0","data-is-macos-electron":a,children:[(0,r.jsx)("header",{className:"_1vgu04f1","data-is-windows-electron":o,children:e}),(0,r.jsx)(R.Np,{className:"_1vgu04f3",children:(0,r.jsx)("div",{className:"_1vgu04f4",children:t})}),(0,r.jsx)("footer",{className:"_1vgu04f2",children:(0,r.jsxs)("div",{className:"_1vgu04fj",children:[(0,r.jsx)("a",{className:V,href:"https://affine.pro/terms",target:"_blank",rel:"noreferrer",children:"Terms of Conditions"}),(0,r.jsx)(B.c,{orientation:"vertical"}),(0,r.jsx)("a",{className:V,href:"https://affine.pro/privacy",target:"_blank",rel:"noreferrer",children:"Privacy Policy"})]})})]}),H=({user:e,onOpenAffine:t})=>{let a=(0,W.zy)(),i=(0,W.Zp)(),[s,l]=(0,y.useState)(0),{data:c}=(0,z.Ay)("/api/worker/questionnaire",e=>fetch(e).then(e=>e.json()),{suspense:!0,revalidateOnFocus:!1}),[d,m]=(0,y.useState)(new Set),[p,h]=(0,y.useState)({}),g=(0,y.useMemo)(()=>(function(e){try{let t=e.state?.callbackURL||new URLSearchParams(e.search).get("redirect_uri");if("string"==typeof t&&t){if(!t.startsWith("http:")&&!t.startsWith("https:"))return t;let e=new URL(t);return e.pathname+e.search}}catch(e){}return null})(a),[a]),b=(0,y.useMemo)(()=>c?.[s],[s,c]),v=environment.isDesktop&&environment.isMacOs,k=environment.isDesktop&&environment.isWindows;if(!c)return null;if(g?.startsWith("/open-app/signin-redirect")){let e=new URL(g,window.location.origin);return e.searchParams.set("next","onboarding"),console.log("redirect to",e.toString()),window.location.assign(e.toString()),null}return b?(0,r.jsx)(G,{headerItems:(0,r.jsx)(f.$n,{className:(0,o.A)(U,{[q]:0===s,_1vgu04ff:k}),size:"extraLarge",onClick:()=>l(c.length),children:"Skip"}),isMacosDesktop:v,isWindowsDesktop:k,children:(0,r.jsxs)("div",{className:"_1vgu04f5",children:[(0,r.jsx)("h1",{className:"_1vgu04f6",children:b.question}),(0,r.jsx)("div",{className:"_1vgu04f7",children:b.options&&b.options.length>0&&b.options.map((e,t)=>"checkbox"===e.type?(0,r.jsx)(O.S,{name:e.value,className:"_1vgu04f9",labelClassName:"_1vgu04fa",checked:d.has(e.value),onChange:t=>{m(a=>(t.target.checked?a.add(e.value):a.delete(e.value),new Set(a)))},label:e.label},t):"input"===e.type?(0,r.jsx)(n.A,{className:"_1vgu04fb",type:"text",size:"large",placeholder:e.label,value:p[e.value]||"",onChange:t=>h(a=>({...a,[e.value]:t}))},t):null)}),(0,r.jsxs)("div",{className:"_1vgu04f8",children:[(0,r.jsx)(f.$n,{className:(0,o.A)(U,{[q]:0!==s}),size:"extraLarge",onClick:()=>l(c.length),children:"Skip"}),(0,r.jsx)(f.$n,{className:U,variant:"primary",size:"extraLarge",itemType:"submit",onClick:()=>{b.id&&e?.id?fetch("/api/worker/questionnaire",{method:"POST",body:JSON.stringify({form:e.id,ask:b.id,answer:[...Array.from(d),...Object.entries(p).map(([e,t])=>`${e}:${t}`)]})}).finally(()=>{m(new Set),h({}),l(s+1)}):l(s+1)},suffix:(0,r.jsx)(u.ArrowRightSmallIcon,{}),children:0===s?"start":"Next"})]})]})}):(0,r.jsx)(G,{isMacosDesktop:v,isWindowsDesktop:k,children:(0,r.jsxs)("div",{className:"_1vgu04fg",children:[(0,r.jsx)("h1",{className:"_1vgu04fh",children:"Thank you!"}),(0,r.jsx)("p",{className:"_1vgu04fi",children:"We will continue to enhance our products based on your feedback. Thank you once again for your supports."}),(0,r.jsx)(f.$n,{className:(0,o.A)(U,"_1vgu04fd"),variant:"primary",size:"extraLarge",onClick:()=>{g?i(g):t()},suffix:(0,r.jsx)(u.ArrowRightSmallIcon,{}),children:"Get Started"})]})})},Z=({passwordLimits:e,onSetPassword:t,onOpenAffine:a})=>{let o=(0,p.s9)(),[i,s]=(0,y.useState)(!1),n=(0,y.useCallback)(e=>{t(e).then(()=>s(!0)).catch(e=>k.m.error({title:o["com.arms.auth.password.set-failed"](),message:String(e)}))},[t,o]);return(0,r.jsx)(m,{title:i?o["com.arms.auth.set.password.page.success"]():o["com.arms.auth.set.password.page.title"](),subtitle:i?o["com.arms.auth.sent.set.password.success.message"]():o["com.arms.auth.page.sent.email.subtitle"]({min:String(e.minLength),max:String(e.maxLength)}),children:i?(0,r.jsx)(f.$n,{variant:"primary",size:"large",onClick:a,children:o["com.arms.auth.open.affine"]()}):(0,r.jsx)(I,{passwordLimits:e,onSetPassword:n})})},K=({children:e})=>(0,r.jsx)("div",{className:"_17xkjwrb",children:e}),Y=({onOpenAffine:e})=>{let t=(0,p.s9)();return(0,r.jsx)(m,{title:t["com.arms.auth.signed.success.title"](),subtitle:t["com.arms.auth.signed.success.subtitle"](),children:(0,r.jsx)(f.$n,{variant:"primary",size:"large",onClick:e,children:t["com.arms.auth.open.affine"]()})})},J=({passwordLimits:e,user:{email:t},onSetPassword:a,onOpenAffine:o,openButtonText:i})=>{let s=(0,p.s9)(),[n,l]=(0,y.useState)(!1),c=(0,y.useCallback)(e=>{a(e).then(()=>l(!0)).catch(e=>k.m.error({title:s["com.arms.auth.password.set-failed"](),message:String(e)}))},[a,s]),d=(0,y.useCallback)(()=>{l(!0)},[]);return(0,r.jsx)(m,{title:n?s["com.arms.auth.sign.up.success.title"]():s["com.arms.auth.page.sent.email.title"](),subtitle:n?s["com.arms.auth.sign.up.success.subtitle"]():(0,r.jsxs)(r.Fragment,{children:[s["com.arms.auth.page.sent.email.subtitle"]({min:String(e.minLength),max:String(e.maxLength)}),(0,r.jsx)("a",{href:`mailto:${t}`,children:t})]}),children:n?(0,r.jsx)(f.$n,{variant:"primary",size:"large",onClick:o,children:i??s["com.arms.auth.open.affine"]()}):(0,r.jsx)(I,{passwordLimits:e,onSetPassword:c,onLater:d,showLater:!0})})}},51629:(e,t,a)=>{"use strict";a.d(t,{U:()=>r});let r=/^(?:(?:[^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@(?:(?:\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|((?:[a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/},20464:(e,t,a)=>{"use strict";a.d(t,{r:()=>s});var r=a(36870),o=a(24312),i=a(34310);let s=e=>{let t=(0,o.s9)();return(0,r.jsx)(i.uo,{title:t["com.arms.publicLinkDisableModal.title"](),description:t["com.arms.publicLinkDisableModal.description"](),cancelText:t["com.arms.publicLinkDisableModal.button.cancel"](),confirmText:t["com.arms.publicLinkDisableModal.button.disable"](),confirmButtonOptions:{variant:"error","data-testid":"confirm-enable-affine-cloud-button"},...e})}},37272:(e,t,a)=>{"use strict";a.d(t,{K7:()=>u,$A:()=>p,p0:()=>m});var r=a(36870),o=a(5863),i=a(86326),s=a(73896),n=a(49791),l=a(30397);let c=(0,n.eU)([]),d=(0,n.eU)(e=>e(c)),m=(0,n.eU)(null,(e,t,a)=>{t(c,e=>e.filter(e=>e.key!==a))}),p=(0,n.eU)(null,(e,t,a)=>{a.key=a.key||(0,l.Ak)(),t(c,e=>[{...a},...e])});function u(){let e=(0,o.md)(d),[t,a]=(0,i.useState)(!1);return((0,i.useEffect)(()=>{e.length?a(!0):a(!1)},[e]),e.length)?(0,r.jsx)("div",{className:"_1xhi3cl0","data-loading":t,children:(0,r.jsx)(s.R,{size:20})}):null}},89716:(e,t,a)=>{"use strict";a.d(t,{a:()=>i,g:()=>s});var r=a(36870),o=a(59097);let i=()=>(0,r.jsxs)("div",{className:"_1t9mgss2",children:[(0,r.jsx)(o.E,{className:"_1t9mgss3",animation:"wave",height:50}),(0,r.jsx)(o.E,{animation:"wave",height:30,width:"40%"})]}),s=()=>(0,r.jsxs)("div",{className:"_1t9mgss0",children:[(0,r.jsx)("div",{className:"_1t9mgss1"}),(0,r.jsx)(i,{})]})},80100:(e,t,a)=>{"use strict";a.d(t,{T:()=>d});var r=a(36870),o=a(71006),i=a(50822),s=a(37064),n=a(86326),l=a(85651);let c=({className:e,resizing:t,minWidth:a,maxWidth:l,resizeHandlePos:c,resizeHandleOffset:d,resizeHandleVerticalPadding:m,open:p,onOpen:u,onResizing:h,onWidthChange:f,...g})=>{let y=(0,n.useRef)(null),b=(0,n.useCallback)(()=>{let e=!1,t=y.current?.parentElement;(0,o.Z1)(t,"parent element not found for resize indicator");let{left:r,right:i}=t.getBoundingClientRect();function s(o){o.preventDefault(),t&&(f(Math.min(l,Math.max("right"===c?o.clientX-r:i-o.clientX,a))),h(!0),e=!0)}document.addEventListener("mousemove",s),document.addEventListener("mouseup",()=>{e||u(!1),h(!1),document.removeEventListener("mousemove",s)},{once:!0})},[l,c,a,f,h,u]);return(0,r.jsx)("div",{...g,"data-testid":"resize-handle",ref:y,style:(0,i.D)({"var(--zc9op91)":`${d??0}px`,"var(--zc9op92)":`${m??0}px`}),className:(0,s.A)("zc9op96",e),"data-handle-position":c,"data-resizing":t,"data-open":p,onMouseDown:b,children:(0,r.jsx)("div",{className:"zc9op97"})})},d=(0,n.forwardRef)(function({children:e,className:t,resizing:a,minWidth:o,maxWidth:d,width:m,floating:p,enableAnimation:u=!0,open:h,unmountOnExit:f,onOpen:g,onResizing:y,onWidthChange:b,resizeHandlePos:v,resizeHandleOffset:k,resizeHandleVerticalPadding:w,...x},C){let S=function(){let[e,t]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{window.setTimeout(()=>{t(!0)},500)},[]),e}()&&u,F=Math.min(d,Math.max(o,m)),[{status:A},E]=(0,l.p)({timeout:300});return(0,n.useLayoutEffect)(()=>{E(h)},[h]),(0,r.jsxs)("div",{...x,ref:C,style:(0,i.D)({"var(--zc9op90)":`${F}px`,"var(--zc9op93)":"300ms"}),className:(0,s.A)(t,"zc9op94"),"data-open":h,"data-transition-state":A,"data-is-floating":p,"data-handle-position":v,"data-enable-animation":S&&!a,children:[!("exited"===A&&!1!==f)&&e,(0,r.jsx)(c,{resizeHandlePos:v,resizeHandleOffset:k,resizeHandleVerticalPadding:w,maxWidth:d,minWidth:o,onOpen:g,onResizing:y,onWidthChange:b,open:h,resizing:a})]})})},48834:(e,t,a)=>{"use strict";a.d(t,{z:()=>d});var r=a(36870),o=a(10980),i=a(98504),s=a(61569),n=a(86326),l=a(80198);let c=new Map,d=({meta:e,...t})=>{let a=(0,o.h1)(i.q),d=a.getProfile(e);(0,n.useEffect)(()=>{d.revalidate()},[e,d]);let m=(0,s.S)(d.profile$.map(e=>e?.avatar)),[p,u]=(0,n.useState)(c.get(e.id));return(0,n.useLayoutEffect)(()=>{if(!m||!e){u(void 0);return}let t=!1;return a.getWorkspaceBlob(e,m).then(async a=>{if(a&&!t){let t=document.createElement("img"),r=URL.createObjectURL(a);t.src=r,await t.decode();let o=Math.min(128/t.naturalWidth,128/t.naturalHeight),i=await createImageBitmap(t,{resizeWidth:t.naturalWidth*o,resizeHeight:t.naturalHeight*o});URL.revokeObjectURL(r),u(e=>e?.key===m?e:{imageBitmap:i,key:m}),c.set(e.id,{imageBitmap:i,key:m})}}).catch(e=>{console.error("get workspace blob error: "+e)}),()=>{t=!0}},[e,a,m]),(0,r.jsx)(l.e,{image:p?.imageBitmap,...t})}},91119:(e,t,a)=>{"use strict";a.d(t,{f:()=>o,p:()=>i});var r=a(86326);let o=e=>{let t=(0,r.useRef)(null);return(0,r.useLayoutEffect)(()=>{t.current&&e&&setTimeout(()=>{t.current?.focus()},0)},[e]),t},i=e=>{let t=o(e);return(0,r.useLayoutEffect)(()=>{t.current&&e&&t.current?.select()},[e,t]),t}},63234:(e,t,a)=>{"use strict";let r,o;a.d(t,{Ih:()=>eZ,Q8:()=>eY,Lj:()=>eQ,eu:()=>I.e,$n:()=>j.$n,Sc:()=>D.S,uo:()=>e0.uo,lr:()=>eo,cG:()=>eh.c,X1:()=>ej,gf:()=>j.gf,Sv:()=>ez.S,Kw:()=>eB,Z6:()=>eR.Z6,K0:()=>j.K0,SE:()=>e$,pd:()=>eL.p,Rh:()=>eU.R,W1:()=>eX.W1,ZB:()=>eX.ZB,Dr:()=>eX.Dr,bX:()=>eX.bX,aC:()=>eX.aC,aF:()=>e0.aF,bG:()=>e1.b,of:()=>e0.of,AM:()=>e3,z6:()=>e4.z,yE:()=>e6.yE,Np:()=>e6.Np,EA:()=>e5.E,dO:()=>e7,m_:()=>ti.m,bC:()=>ep,mO:()=>eR.mO,i6:()=>c,me:()=>e1.m,vy:()=>ec,fI:()=>N,oR:()=>to,fl:()=>e0.fl,PM:()=>ex,Al:()=>eP,IF:()=>e6.IF,XM:()=>S});let i=new Set(["children","localName","ref","style","className"]),s=new WeakMap,n=(e,t,a)=>{let r=s.get(e);void 0===r&&s.set(e,r=new Map);let o=r.get(t);void 0!==a?void 0===o?(r.set(t,o={handleEvent:a}),e.addEventListener(t,o)):o.handleEvent=a:void 0!==o&&(r.delete(t),e.removeEventListener(t,o))},l=(e,t,a,r,o)=>{let i=o?.[t];if(void 0!==i&&a!==r){n(e,i,a);return}e[t]=a,null==a&&t in HTMLElement.prototype&&e.removeAttribute(t)},c=({react:e,tagName:t="div",elementClass:a,events:r,displayName:o})=>{let s=new Set(Object.keys(r??{})),n=e.forwardRef((o,n)=>{let c=e.useRef(null),d=e.useRef(null),m=e.useRef(null),p={"data-lit-react-wrapper":a.name},u={};if(null===m.current){let e=new a;m.current=e,"function"==typeof n?n(m.current):n&&(n.current=e)}let h=m.current;for(let[e,t]of Object.entries(o)){if(i.has(e)){p[e]=t;continue}if(s.has(e)||e in a.prototype){u[e]=t;continue}p[e]=t}return e.useLayoutEffect(()=>{if(null!==m.current){for(let e in u)l(m.current,e,o[e],d.current?d.current[e]:void 0,r);d.current=o}}),e.useLayoutEffect(()=>{let e=c.current;if(e)return e.append(h),()=>{h.remove()}},[h]),e.createElement(t,{...p,ref:e.useCallback(e=>{c.current=e},[c])})});return n.displayName=o??a.name,n};var d,m,p,u,h,f,g=a(91449),y=a(4564),b=a(30397),v=a(86326),k=a(35623);function w(e,t,a,r){return(w=function(){function e(e,t){return function(r){(function(e,t){if(e.v)throw Error("attempted to call "+t+" after decoration was finished")})(t,"addInitializer"),a(r,"An initializer"),e.push(r)}}function t(t,a,r,o,i,s,n,l,c){switch(i){case 1:d="accessor";break;case 2:d="method";break;case 3:d="getter";break;case 4:d="setter";break;default:d="field"}var d,m,p,u={kind:d,name:n?"#"+a:a,static:s,private:n,metadata:l},h={v:!1};u.addInitializer=e(o,h),0===i?n?(m=r.get,p=r.set):(m=function(){return this[a]},p=function(e){this[a]=e}):2===i?m=function(){return r.value}:((1===i||3===i)&&(m=function(){return r.get.call(this)}),(1===i||4===i)&&(p=function(e){r.set.call(this,e)})),u.access=m&&p?{get:m,set:p}:m?{get:m}:{set:p};try{return t(c,u)}finally{h.v=!0}}function a(e,t){if("function"!=typeof e)throw TypeError(t+" must be a function")}function r(e,t){var r=typeof t;if(1===e){if("object"!==r||null===t)throw TypeError("accessor decorators must return an object with get, set, or init properties or void 0");void 0!==t.get&&a(t.get,"accessor.get"),void 0!==t.set&&a(t.set,"accessor.set"),void 0!==t.init&&a(t.init,"accessor.init")}else if("function"!==r)throw TypeError((0===e?"field":10===e?"class":"method")+" decorators must return a function or void 0")}function o(e,t){t&&e.push(function(e){for(var a=0;a3,b=f>=5;if(b?(p=e,f-=5,u=m=m||[]):(p=e.prototype,u=d=d||[]),0!==f&&!y){var v=b?l:n,k=v.get(g)||0;if(!0===k||3===k&&4!==f||4===k&&3!==f)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+g);!k&&f>2?v.set(g,f):v.set(g,!0)}!function(e,a,o,i,s,n,l,c,d){var m,p,u,h,f,g,y=o[0];if(l?m=0===s||1===s?{get:o[3],set:o[4]}:3===s?{get:o[3]}:4===s?{set:o[3]}:{value:o[3]}:0!==s&&(m=Object.getOwnPropertyDescriptor(a,i)),1===s?u={get:m.get,set:m.set}:2===s?u=m.value:3===s?u=m.get:4===s&&(u=m.set),"function"==typeof y)void 0!==(h=t(y,i,m,c,s,n,l,d,u))&&(r(s,h),0===s?p=h:1===s?(p=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h);else for(var b=y.length-1;b>=0;b--)void 0!==(h=t(y[b],i,m,c,s,n,l,d,u))&&(r(s,h),0===s?g=h:1===s?(g=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h,void 0!==g&&(void 0===p?p=g:"function"==typeof p?p=[p,g]:p.push(g)));if(0===s||1===s){if(void 0===p)p=function(e,t){return t};else if("function"!=typeof p){var v=p;p=function(e,t){for(var a=t,r=0;r0){for(var s=[],n=t,l=t.name,c=a.length-1;c>=0;c--){var d={v:!1};try{var m=a[c](n,{kind:"class",name:l,addInitializer:e(s,d),metadata:o})}finally{d.v=!0}void 0!==m&&(r(10,m),n=m)}return[i(n,o),function(){for(var e=0;ee({name:"connectedCallback",target:this}))}disconnectedCallback(){super.disconnectedCallback(),C.forEach(e=>e({name:"disconnectedCallback",target:this}))}willUpdate(e){super.willUpdate(e),C.forEach(t=>t({name:"willUpdate",target:this,previousPortalId:e.get("portalId")}))}constructor(...e){super(...e),this.portalId=""}}}};let S=()=>{let[e,t]=(0,v.useState)([]);return[(0,v.useCallback)(e=>{let a="function"==typeof e?e():e;return function(e){let t=(0,b.Ak)();return C.add(a=>{a.target.portalId===t&&e(a)}),(0,g.qy)``}(e=>{let r=e.target.portalId;t(t=>{let o=t.filter(t=>t.id!==e.previousPortalId&&t.id!==r);return"disconnectedCallback"!==e.name&&o.push({id:r,portal:k.createPortal(a,e.target)}),o})})},[t]),e]};function F(e,t,a,r){return(F=function(){function e(e,t){return function(r){(function(e,t){if(e.v)throw Error("attempted to call "+t+" after decoration was finished")})(t,"addInitializer"),a(r,"An initializer"),e.push(r)}}function t(t,a,r,o,i,s,n,l,c){switch(i){case 1:d="accessor";break;case 2:d="method";break;case 3:d="getter";break;case 4:d="setter";break;default:d="field"}var d,m,p,u={kind:d,name:n?"#"+a:a,static:s,private:n,metadata:l},h={v:!1};u.addInitializer=e(o,h),0===i?n?(m=r.get,p=r.set):(m=function(){return this[a]},p=function(e){this[a]=e}):2===i?m=function(){return r.value}:((1===i||3===i)&&(m=function(){return r.get.call(this)}),(1===i||4===i)&&(p=function(e){r.set.call(this,e)})),u.access=m&&p?{get:m,set:p}:m?{get:m}:{set:p};try{return t(c,u)}finally{h.v=!0}}function a(e,t){if("function"!=typeof e)throw TypeError(t+" must be a function")}function r(e,t){var r=typeof t;if(1===e){if("object"!==r||null===t)throw TypeError("accessor decorators must return an object with get, set, or init properties or void 0");void 0!==t.get&&a(t.get,"accessor.get"),void 0!==t.set&&a(t.set,"accessor.set"),void 0!==t.init&&a(t.init,"accessor.init")}else if("function"!==r)throw TypeError((0===e?"field":10===e?"class":"method")+" decorators must return a function or void 0")}function o(e,t){t&&e.push(function(e){for(var a=0;a3,b=f>=5;if(b?(p=e,f-=5,u=m=m||[]):(p=e.prototype,u=d=d||[]),0!==f&&!y){var v=b?l:n,k=v.get(g)||0;if(!0===k||3===k&&4!==f||4===k&&3!==f)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+g);!k&&f>2?v.set(g,f):v.set(g,!0)}!function(e,a,o,i,s,n,l,c,d){var m,p,u,h,f,g,y=o[0];if(l?m=0===s||1===s?{get:o[3],set:o[4]}:3===s?{get:o[3]}:4===s?{set:o[3]}:{value:o[3]}:0!==s&&(m=Object.getOwnPropertyDescriptor(a,i)),1===s?u={get:m.get,set:m.set}:2===s?u=m.value:3===s?u=m.get:4===s&&(u=m.set),"function"==typeof y)void 0!==(h=t(y,i,m,c,s,n,l,d,u))&&(r(s,h),0===s?p=h:1===s?(p=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h);else for(var b=y.length-1;b>=0;b--)void 0!==(h=t(y[b],i,m,c,s,n,l,d,u))&&(r(s,h),0===s?g=h:1===s?(g=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h,void 0!==g&&(void 0===p?p=g:"function"==typeof p?p=[p,g]:p.push(g)));if(0===s||1===s){if(void 0===p)p=function(e,t){return t};else if("function"!=typeof p){var v=p;p=function(e,t){for(var a=t,r=0;r0){for(var s=[],n=t,l=t.name,c=a.length-1;c>=0;c--){var d={v:!1};try{var m=a[c](n,{kind:"class",name:l,addInitializer:e(s,d),metadata:o})}finally{d.v=!0}void 0!==m&&(r(10,m),n=m)}return[i(n,o),function(){for(var e=0;ee?"string"==typeof e?e:(0,v.createElement)(E,{template:e}):null;var _=a(88713),I=a(80198),j=a(55683),D=a(15767),M=a(36870),T=a(50822),P=a(94343),L=a.n(P),$="_8en2eef _8en2ee6 _8en2ee4 _8en2ee5 _8en2ee7",W="_8en2eeu _8en2eeq _8en2eem _8en2ee9",z="_8en2eem _8en2ee9",O="_8en2eek",B={gapX:"var(--_8en2ee0)",gapY:"var(--_8en2ee1)"},R="_8en2eeq _8en2eem _8en2ee9";let U="1970-01-01",q="2099-12-31",V=L()(U).year(),G=L()(q).year();var H=a(45483),Z=a(37064);let K={height:"auto"},Y=(0,v.memo)(function({length:e,left:t,right:a,className:r,style:o,mode:i,...s}){let n={...(0,T.D)({"--len":`${e}`}),...o};return(0,M.jsx)("div",{className:(0,Z.A)(O,r),style:n,...s,children:Array.from({length:e}).fill(0).map((r,o)=>{let s=0===o,n=o===e-1;return(0,M.jsx)("div",{"data-length":e,"data-is-left":s,"data-is-right":n,className:(0,Z.A)({[z]:"day"===i,[R]:"month"===i,[W]:"year"===i}),style:K,children:(0,M.jsx)("div",{className:"_8en2eee",children:s?t:n?a:null})},o)})})}),J=(0,v.forwardRef)(({headerLeft:e,headerRight:t,body:a,length:r,mode:o},i)=>(0,M.jsxs)("div",{className:"_8en2eeb",ref:i,"data-mode":o,children:[(0,M.jsx)(Y,{mode:o,length:r,left:e,right:t,className:"_8en2eec"}),a]}));J.displayName="CalendarLayout";let Q=({label:e,date:t,isToday:a,notCurrentMonth:r,selected:o,focused:i})=>(0,M.jsx)("button",{"data-is-date-cell":!0,"data-value":t.format("YYYY-MM-DD"),"data-is-today":a,"data-not-current-month":r,"data-selected":o,tabIndex:i?0:-1,className:"_8en2een _8en2ee6 _8en2ee4 _8en2ee5 _8en2ee7",children:e}),X=(0,v.memo)(function({children:e,prevDisabled:t,nextDisabled:a,onPrev:r,onNext:o}){return(0,M.jsxs)("div",{className:"_8en2eeg",children:[(0,M.jsx)(j.K0,{size:"16",disabled:t,"data-testid":"date-picker-nav-prev",onClick:r,children:(0,M.jsx)(H.ArrowLeftSmallIcon,{})},"nav-btn-prev"),e??(0,M.jsx)("div",{className:"_8en2eeh"}),(0,M.jsx)(j.K0,{size:"16",disabled:a,"data-testid":"date-picker-nav-next",onClick:o,children:(0,M.jsx)(H.ArrowRightSmallIcon,{})},"nav-btn-next")]},"nav-btn-group")}),ee=(0,v.memo)(function(e){let t=(0,v.useRef)(null),a=(0,v.useRef)(null),{value:r,cursor:o,weekDays:i,monthNames:s,format:n,todayLabel:l,customDayRenderer:c,onChange:d,onCursorChange:m,onModeChange:p}=e,u=(0,v.useMemo)(()=>{let e=o.startOf("month").startOf("week"),t=o.endOf("month").endOf("week"),a=[],i=e;for(;i.isBefore(t);){let e=[];for(let t=0;t<7;t++)e.push({date:i,label:i.date().toString(),isToday:i.isSame(L()(),"day"),notCurrentMonth:!i.isSame(o,"month"),selected:!!r&&i.isSame(r,"day"),focused:i.isSame(o,"day")}),i=i.add(1,"day");a.push(e)}return a},[o,r]),h=(0,v.useMemo)(()=>o.startOf("month").isSame(U,"day"),[o]),f=(0,v.useMemo)(()=>o.endOf("month").isSame(q,"day"),[o]),g=(0,v.useCallback)(()=>{m?.(o.add(1,"month").set("date",1))},[o,m]),y=(0,v.useCallback)(()=>{m?.(o.add(-1,"month").set("date",1))},[o,m]),b=(0,v.useCallback)(()=>{let e=t.current;if(!e)return;let a=e.querySelector('[data-is-date-cell][tabindex="0"]');a&&a.focus()},[]),k=(0,v.useCallback)(()=>p?.("month"),[p]),w=(0,v.useCallback)(()=>p?.("year"),[p]);(0,v.useEffect)(()=>{let e=t.current;if(!e)return;let a=e=>{if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key))return;let t=document.activeElement;t?.hasAttribute("data-is-date-cell")&&(e.shiftKey||(e.preventDefault(),e.stopPropagation(),"ArrowUp"===e.key&&m?.(o.add(-7,"day")),"ArrowDown"===e.key&&m?.(o.add(7,"day")),"ArrowLeft"===e.key&&m?.(o.add(-1,"day")),"ArrowRight"===e.key&&m?.(o.add(1,"day")),setTimeout(b)))};return e.addEventListener("keydown",a),()=>{e?.removeEventListener("keydown",a)}},[o,b,m]);let x=(0,v.useMemo)(()=>(0,M.jsxs)("div",{style:{whiteSpace:"nowrap"},children:[(0,M.jsx)("button",{onClick:k,ref:a,className:$,"data-testid":"month-picker-button","data-month":o.month(),"data-year":o.year(),children:s.split(",")[o.month()]}),(0,M.jsx)("button",{className:$,onClick:w,"data-testid":"year-picker-button","data-year":o.year(),children:o.year()})]}),[o,s,k,w]),C=(0,v.useMemo)(()=>(0,M.jsx)(X,{onNext:g,onPrev:y,prevDisabled:h,nextDisabled:f,children:(0,M.jsx)("button",{className:"_8en2eei _8en2ee6 _8en2ee4 _8en2ee5 _8en2ee7",onClick:()=>d?.(L()().format(n)),children:l})},"nav-buttons"),[n,f,d,g,y,h,l]),S=(0,v.useMemo)(()=>(0,M.jsxs)("main",{className:"_8en2eej",children:[(0,M.jsx)("div",{className:O,children:i.split(",").map(e=>(0,M.jsx)("div",{className:"_8en2eel _8en2ee9",children:e},e))}),u.map((e,t)=>(0,M.jsx)("div",{className:O,children:e.map((e,t)=>(0,M.jsx)("div",{className:z,onClick:()=>d?.(e.date.format(n)),children:c?c(e):(0,M.jsx)(Q,{...e},t)},t))},t))]}),[c,n,u,d,i]);return(0,M.jsx)(J,{mode:"day",ref:t,length:7,headerLeft:x,headerRight:C,body:S})}),et=(0,v.memo)(function(e){let{cursor:t,value:a,monthNames:r,onModeChange:o,onCursorChange:i}=e,s=(0,v.useRef)(null),[n,l]=(0,v.useState)(t.startOf("month")),c=(0,v.useCallback)(()=>o?.("day"),[o]),d=(0,v.useCallback)(e=>{o?.("day"),i?.(e)},[i,o]),m=(0,v.useCallback)(()=>l(e=>e.add(1,"year").startOf("year")),[]),p=(0,v.useCallback)(()=>l(e=>e.subtract(1,"year").startOf("year")),[]),u=(0,v.useMemo)(()=>n.isSame(q,"year"),[n]),h=(0,v.useMemo)(()=>n.isSame(U,"year"),[n]),f=(0,v.useMemo)(()=>{let e=[],t=n.startOf("year");for(;t.isBefore(n.endOf("year"));){let a=[];for(let e=0;e<3;e++)a.push(t.clone()),t=t.add(1,"month");e.push(a)}return e},[n]),g=(0,v.useCallback)(()=>{let e=s.current;if(!e)return;let t=e.querySelector('[data-is-month-cell][tabindex="0"]');t&&t.focus()},[]);(0,v.useEffect)(()=>{let e=s.current;if(!e)return;let t=e=>{if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),c();return}["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key)&&(e.preventDefault(),e.stopPropagation(),"ArrowUp"===e.key&&l(e=>e.subtract(3,"month")),"ArrowDown"===e.key&&l(e=>e.add(3,"month")),"ArrowLeft"===e.key&&l(e=>e.subtract(1,"month")),"ArrowRight"===e.key&&l(e=>e.add(1,"month")),setTimeout(g))};return e.addEventListener("keydown",t),()=>{e.removeEventListener("keydown",t)}},[c,g]);let y=(0,v.useMemo)(()=>(0,M.jsx)("button",{"data-testid":"month-picker-current-year",onClick:c,className:$,children:n.format("YYYY")}),[c,n]),b=(0,v.useMemo)(()=>(0,M.jsx)(X,{onNext:m,onPrev:p,prevDisabled:h,nextDisabled:u}),[m,u,p,h]),k=(0,v.useMemo)(()=>(0,M.jsx)("div",{className:"_8en2eeo _8en2eej",children:f.map((e,t)=>(0,M.jsx)("div",{className:"_8en2eek",children:e.map((e,t)=>(0,M.jsx)("div",{className:R,children:(0,M.jsx)("button",{"data-value":e.format("YYYY-MM"),"data-is-month-cell":!0,className:"_8en2eer _8en2een _8en2ee6 _8en2ee4 _8en2ee5 _8en2ee7","data-selected":a&&e.isSame(a,"month"),"data-current-month":e.isSame(L()(),"month"),onClick:()=>d(e),tabIndex:e.isSame(n,"month")?0:-1,"aria-label":e.format("YYYY-MM"),children:r.split(",")[e.month()]})},t))},t))}),[f,n,r,d,a]);return(0,M.jsx)(J,{mode:"month",ref:s,length:3,headerLeft:y,headerRight:b,body:k})}),ea={format:"YYYY-MM-DD",gapX:8,gapY:8,weekDays:"Su,Mo,Tu,We,Th,Fr,Sa",monthNames:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec",todayLabel:"Today"},er=(0,v.memo)(function(e){let{value:t,cursor:a,onModeChange:r,onCursorChange:o}=e,i=(0,v.useRef)(null),[s,n]=(0,v.useState)(L()(a).startOf("year")),l=(0,v.useCallback)(()=>r?.("day"),[r]),c=(0,v.useCallback)(e=>{l(),o?.(e)},[l,o]),d=(0,v.useCallback)(()=>{n(e=>e.add(12,"year").startOf("year"))},[]),m=(0,v.useCallback)(()=>{n(e=>e.subtract(12,"year").startOf("year"))},[]),p=(0,v.useMemo)(()=>Math.floor((s.year()-V)/12),[s]),u=(0,v.useMemo)(()=>L()(U).add(12*p,"year"),[p]),h=(0,v.useMemo)(()=>u.add(11,"year"),[u]),f=(0,v.useMemo)(()=>s.add(12,"year").isAfter(`${G}-01-01`),[s]),g=(0,v.useMemo)(()=>p<=0,[p]),y=(0,v.useMemo)(()=>{let e=[],t=u.clone();for(;t.isBefore(h.add(1,"year"));){let a=[];for(let e=0;e<3;e++)a.push(t.clone().startOf("year")),t=t.add(1,"year");e.push(a)}return e},[h,u]),b=(0,v.useCallback)(()=>{let e=i.current;if(!e)return;let t=e.querySelector('[data-is-year-cell][tabindex="0"]');t&&t.focus()},[]);(0,v.useEffect)(()=>{let e=i.current;if(!e)return;let t=e=>{if("Escape"===e.key){e.preventDefault(),e.stopPropagation(),l();return}["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key)&&(e.preventDefault(),e.stopPropagation(),"ArrowUp"===e.key&&n(e=>e.subtract(3,"year")),"ArrowDown"===e.key&&n(e=>e.add(3,"year")),"ArrowLeft"===e.key&&n(e=>e.subtract(1,"year")),"ArrowRight"===e.key&&n(e=>e.add(1,"year")),setTimeout(b))};return e.addEventListener("keydown",t),()=>{e.removeEventListener("keydown",t)}},[l,b]);let k=(0,v.useMemo)(()=>(0,M.jsxs)("button",{onClick:l,className:$,children:[u.year(),"-",h.year()]}),[l,h,u]),w=(0,v.useMemo)(()=>(0,M.jsx)(X,{onNext:d,onPrev:m,nextDisabled:f,prevDisabled:g}),[d,f,m,g]),x=(0,v.useMemo)(()=>(0,M.jsx)("div",{className:"_8en2eeo _8en2eej",children:y.map((e,a)=>(0,M.jsx)("div",{className:"_8en2eek",children:e.map((e,a)=>{let r=e.isAfter(q)||e.isBefore(U);return(0,M.jsx)("div",{className:W,children:(0,M.jsx)("button",{"aria-disabled":r,"data-value":e.format("YYYY"),"data-is-year-cell":!0,className:"_8en2eer _8en2een _8en2ee6 _8en2ee4 _8en2ee5 _8en2ee7","data-selected":t&&e.isSame(t,"year"),"data-current-year":e.isSame(L()(),"year"),tabIndex:e.isSame(s,"year")?0:-1,onClick:r?void 0:()=>c(e),children:e.year()})},a)})},a))}),[y,c,t,s]);return(0,M.jsx)(J,{mode:"year",ref:i,length:3,headerLeft:k,headerRight:w,body:x})}),eo=e=>{let t={...ea,...e},{value:a,gapX:r,gapY:o,onChange:i}=t,[s,n]=(0,v.useState)("day"),[l,c]=(0,v.useState)(L()(a)),d=(0,T.D)({[B.gapX]:`${r}px`,[B.gapY]:`${o}px`}),m=(0,v.useCallback)(e=>{n("day"),c(L()(e)),i?.(e)},[i]),p=(0,v.useCallback)(e=>{e.isBefore(U)?e=L()(U):e.isAfter(q)&&(e=L()(q)),c(e)},[]);return(0,M.jsx)("div",{className:"_8en2eea",style:d,children:(0,M.jsx)("day"===s?ee:"month"===s?et:er,{cursor:l,...t,onChange:m,onCursorChange:p,onModeChange:n})})},ei=null,es=new WeakMap;window._resizeObserverElementsMap=es;let en=()=>ei??=new ResizeObserver(e=>{e.forEach(e=>{(es.get(e.target)??[]).forEach(({callback:t})=>t(e))})}),el=(e,t)=>{if(!e)return;let a=es.get(e)??[],r=en();a.includes(t)&&es.set(e,a.filter(e=>e!==t)),es.get(e)?.length===0&&(r.unobserve(e),es.delete(e))},ec=(e,t)=>{let a=en();es.has(e)||a.observe(e);let r=es.get(e)??[],o={callback:t,dispose:()=>{}};return o.dispose=()=>el(e,o),es.set(e,[...r,o]),o.dispose},ed=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],em="YYYY-MM-DD",ep=(0,v.memo)(function({value:e,onChange:t,className:a,handleRef:r,...o}){let i=(0,v.useRef)(null),[s,n]=(0,v.useState)(L()(e)),[l,c]=(0,v.useState)(!1),[d,m]=(0,v.useState)(7);(0,v.useImperativeHandle)(r,()=>({setCursor:n}));let p=(0,v.useMemo)(()=>{if(7===d)return[0,7];let e=Math.max(0,s.day()-Math.floor(d/2)),t=Math.min(7,e+d);return 7===t&&(e=7-d),[e,t]},[s,d]),u=(0,v.useMemo)(()=>Array.from({length:7}).map((e,t)=>s.startOf("week").add(t,"day").startOf("day")),[s]),h=(0,v.useMemo)(()=>u.slice(...p),[u,p]),f=(0,v.useCallback)(()=>{let e=h.length;7===e?n(e=>e.add(1,"week")):n(t=>{if(h[h.length-1].isSame(t.endOf("week"),"day"))return t.add(1,"week").startOf("week").add(Math.floor(e/2),"day");let a=t.add(e,"day");return a.isSame(t,"week")||(a=t.endOf("week")),a})},[h]),g=(0,v.useCallback)(()=>{let e=h.length;7===e?n(e=>e.add(-1,"week")):n(t=>{if(h[0].isSame(t.startOf("week"),"day"))return t.subtract(1,"week").endOf("week").subtract(Math.floor(e/2)-1,"day");let a=t.add(-e,"day");return a.isSame(t,"week")||(a=t.startOf("week")),a})},[h]),y=(0,v.useCallback)(e=>{t?.(e.format(em))},[t]);(0,v.useEffect)(()=>{let e=i.current;if(e)return ec(e,({contentRect:e})=>{let t=e.width;t&&(m(Math.max(1,Math.min(Math.floor(t/34),7))),c(t<300))})},[]),(0,v.useEffect)(()=>{e&&n(L()(e))},[e]);let b=(0,v.useCallback)(()=>{if(!i.current)return;let e=i.current.querySelector('button[tabIndex="0"]');e?.focus()},[]);return(0,v.useLayoutEffect)(()=>{if(!i.current)return;let e=i.current,t=e=>{("ArrowLeft"===e.key||"ArrowRight"===e.key)&&(e.preventDefault(),e.stopPropagation(),n(t=>t.add("ArrowLeft"===e.key?-1:1,"day")),setTimeout(b))};return e.addEventListener("keydown",t),()=>{e.removeEventListener("keydown",t)}},[b,f,g]),(0,M.jsxs)("div",{className:(0,Z.A)("vgwt9w0",a),...o,children:[(0,M.jsx)(j.K0,{onClick:g,children:(0,M.jsx)(H.ArrowLeftSmallIcon,{})}),(0,M.jsx)("div",{ref:i,className:"vgwt9w1",children:h.map(t=>(0,M.jsx)(eu,{dense:l,value:e,day:t,cursor:s,onClick:y},t.toISOString()))}),(0,M.jsx)(j.K0,{onClick:f,children:(0,M.jsx)(H.ArrowRightSmallIcon,{})})]})}),eu=({day:e,dense:t,value:a,cursor:r,onClick:o})=>{let i=e.format(em)===a,s=e.month()===r.month(),n=e.isSame(L()(),"day"),l=ed[e.day()];return(0,M.jsxs)("button",{tabIndex:r.isSame(e,"day")?0:-1,"aria-label":e.format(em),"data-active":i,"data-curr-month":s,"data-today":n,"data-value":e.format(em),className:"vgwt9w2",onClick:()=>o(e),children:[(0,M.jsx)("div",{className:"vgwt9w3",children:t?l.slice(0,1):l}),(0,M.jsx)("div",{className:"vgwt9w4",children:e.format("D")})]},e.toISOString())};var eh=a(63035),ef=a(70439),eg=a(93752),ey=a(74540),eb=a(83066),ev=a(99267),ek=a(80719);function ew(e){if(void 0!==e)return t=>"function"==typeof e?e(t):e}let ex=(e=()=>({}),t=[])=>{let[a,r]=(0,v.useState)(!1),[o,i]=(0,v.useState)({offsetX:0,offsetY:0,clientX:0,clientY:0,outWindow:!1}),[s,n]=(0,v.useState)([]),[l,c]=(0,v.useState)(()=>()=>null),d=(0,v.useRef)(null),m=(0,v.useRef)(null),p=(0,v.useRef)(!1),u=(0,v.useRef)(!1),h=(0,v.useRef)(!1),f=(0,v.useRef)(!1),g=(0,v.useMemo)(e,t);return(0,v.useEffect)(()=>{if(!d.current)return;let e={dragleave:()=>{i(e=>!0===e.outWindow?e:{...e,outWindow:!0})},dragover:()=>{i(e=>!0===e.outWindow?{...e,outWindow:!1}:e)}},t=(0,ef.kZ)({element:d.current,dragHandle:m.current??void 0,canDrag:ew(g.canDrag),getInitialData:ew(g.data),getInitialDataForExternal:ew(g.dataForExternal),onDragStart:t=>{f.current&&r(!0),u.current&&(document.body.addEventListener("dragleave",e.dragleave),document.body.addEventListener("dragover",e.dragover),i({offsetX:0,offsetY:0,clientX:t.location.initial.input.clientX,clientY:t.location.initial.input.clientY,outWindow:!1})),h.current&&n([]),d.current&&(d.current.dataset.dragging="true")},onDrop:()=>{f.current&&r(!1),u.current&&(document.body.removeEventListener("dragleave",e.dragleave),document.body.removeEventListener("dragover",e.dragover),i({offsetX:0,offsetY:0,clientX:0,clientY:0,outWindow:!1})),h.current&&n([]),d.current&&delete d.current.dataset.dragging},onDrag:e=>{u.current&&i(t=>({offsetX:e.location.current.input.clientX-e.location.initial.input.clientX,offsetY:e.location.current.input.clientY-e.location.initial.input.clientY,clientX:e.location.current.input.clientX,clientY:e.location.current.input.clientY,outWindow:t.outWindow}))},onDropTargetChange(e){h.current&&n(e.location.current.dropTargets)},onGenerateDragPreview({nativeSetDragImage:e,source:t,location:a}){if(g.disableDragPreview){(0,ey.Y)({nativeSetDragImage:e});return}let r=g.dragPreviewPosition??"native";p.current?(0,ek.t)({getOffset:(...e)=>"pointer-center"===r?(0,eg.l)(...e):"pointer-outside"===r?(0,eb.I)({x:"8px",y:"4px"})(...e):(0,ev.C)({element:t.element,input:a.current.input})(...e),render:({container:e})=>((0,k.flushSync)(()=>{c(()=>({children:t,position:a})=>(r=a||r,k.createPortal(t,e)))}),()=>c(()=>()=>null)),nativeSetDragImage:e}):"native"!==r&&(0,ek.t)({getOffset:(...e)=>"pointer-center"===r?(0,eg.l)(...e):"pointer-outside"===r?(0,eb.I)({x:"8px",y:"4px"})(...e):(0,ev.C)({element:t.element,input:a.current.input})(...e),render({container:e}){e.append(t.element.cloneNode(!0))},nativeSetDragImage:e})}});return()=>{window.removeEventListener("dragleave",e.dragleave),window.removeEventListener("dragover",e.dragover),t()}},[g]),{get dragging(){return f.current=!0,a},get draggingPosition(){return u.current=!0,o},get CustomDragPreview(){return p.current=!0,l},get dropTarget(){return h.current=!0,s},dragRef:d,dragHandleRef:m}};var eC=a(99971),eS="var(--_1h3z4641)",eF="_1h3z4645",eA="_1h3z4643";function eE({instruction:e,isBlocked:t}){let a={[eS]:`${e.currentLevel*e.indentPerLevel}px`,"var(--_1h3z4642)":t?(0,eC.Vg)("--affine-warning-color"):(0,eC.Vg)("--affine-primary-color")};return"reorder-above"===e.type?(0,M.jsx)("div",{className:(0,Z.A)(eA,"_1h3z4644"),style:(0,T.D)(a)}):"reorder-below"===e.type?(0,M.jsx)("div",{className:(0,Z.A)(eA,eF),style:(0,T.D)(a)}):"make-child"===e.type?(0,M.jsx)("div",{className:(0,Z.A)("_1h3z4646"),style:(0,T.D)(a)}):"reparent"===e.type?(a[eS]=`${e.desiredLevel*e.indentPerLevel}px`,(0,M.jsx)("div",{className:(0,Z.A)(eA,eF),style:(0,T.D)(a)})):null}let eN={top:"horizontal",bottom:"horizontal",left:"vertical",right:"vertical"},e_={horizontal:"_1h3z4647",vertical:"_1h3z4648"},eI={top:"_1h3z464a",bottom:"_1h3z464c",left:"_1h3z464d",right:"_1h3z464b"};function ej({instruction:e,edge:t}){return t?function(e,t=0){let a=`calc(-0.5 * (${t}px + 2px))`,r=eN[e];return(0,M.jsx)("div",{className:(0,Z.A)(["_1h3z464e",e_[r],eI[e]]),style:(0,T.D)({"var(--_1h3z4649)":a})})}(t,0):e?"instruction-blocked"===e.type?eE({instruction:e.desired,isBlocked:!0}):eE({instruction:e,isBlocked:!1}):void 0}var eD=a(23993),eM=a(61870);function eT(e,t){if(void 0!==e)return a=>"function"==typeof e?e({...a,get treeInstruction(){return t.treeInstruction?(0,eM.Q)((0,eM.G)({},{input:a.input,element:a.element,currentLevel:t.treeInstruction.currentLevel,indentPerLevel:t.treeInstruction.indentPerLevel,mode:t.treeInstruction.mode,block:t.treeInstruction.block})):null},get closestEdge(){return t.closestEdge?(0,eD.S)((0,eD.E)({},{input:a.input,element:a.element,allowedEdges:t.closestEdge.allowedEdges})):null}}):e}let eP=(e=()=>({}),t=[])=>{let a=(0,v.useRef)(null),[r,o]=(0,v.useState)(!1),[i,s]=(0,v.useState)(null),[n,l]=(0,v.useState)(null),[c,d]=(0,v.useState)(null),[m,p]=(0,v.useState)(null),[u,h]=(0,v.useState)({relativeX:0,relativeY:0,clientX:0,clientY:0}),f=(0,v.useRef)(!1),g=(0,v.useRef)(!1),y=(0,v.useRef)(!1),b=(0,v.useRef)(!1),k=(0,v.useMemo)(e,t);return(0,v.useEffect)(()=>{if(a.current)return(0,ef.tO)({element:a.current,canDrop:eT(k.canDrop,k),getDropEffect:eT(k.dropEffect,k),getIsSticky:eT(k.isSticky,k),onDrop:e=>{f.current&&o(!1),g.current&&p(null),y.current&&h({relativeX:0,relativeY:0,clientX:0,clientY:0}),k.treeInstruction&&(s(null),a.current&&delete a.current.dataset.treeInstruction),k.closestEdge&&l(null),b.current&&d(null),a.current&&delete a.current.dataset.draggedOver,e.location.current.dropTargets[0]?.element===a.current&&k.onDrop?.({...e,treeInstruction:eM.Q(e.self.data),closestEdge:eD.S(e.self.data)})},getData:e=>{let t=eT(k.data??{},k)(e),{input:a,element:r}=e,o=k.treeInstruction?(0,eM.G)(t,{input:a,element:r,currentLevel:k.treeInstruction.currentLevel,indentPerLevel:k.treeInstruction.indentPerLevel,mode:k.treeInstruction.mode,block:k.treeInstruction.block}):t;return k.closestEdge?(0,eD.E)(o,{element:r,input:a,allowedEdges:k.closestEdge.allowedEdges}):o},onDrag:e=>{if(e.location.current.dropTargets[0]?.element===a.current){g.current&&p({data:e.source.data});let t=null,r=null;if(k.treeInstruction&&(s(t=(0,eM.Q)(e.self.data)),a.current&&(a.current.dataset.treeInstruction=t?.type)),k.closestEdge&&l(r=(0,eD.S)(e.self.data)),b.current&&d(e.self.dropEffect),y.current){let t=e.self.element.getBoundingClientRect(),{clientX:a,clientY:r}=e.location.current.input;h({relativeX:a-t.x,relativeY:r-t.y,clientX:a,clientY:r})}k.onDrag?.({...e,treeInstruction:t,closestEdge:r})}},onDropTargetChange:e=>{if(e.location.current.dropTargets[0]?.element===a.current){if(f.current&&o(!0),k.treeInstruction){let t=(0,eM.Q)(e.self.data);s(t),a.current&&(a.current.dataset.treeInstruction=t?.type)}if(k.closestEdge&&l((0,eD.S)(e.self.data)),b.current&&d(e.self.dropEffect),g.current&&p({data:e.source.data}),y.current){let t=e.self.element.getBoundingClientRect();h({relativeX:e.location.current.input.clientX-t.x,relativeY:e.location.current.input.clientY-t.y,clientX:e.location.current.input.clientX,clientY:e.location.current.input.clientY})}a.current&&(a.current.dataset.draggedOver="true")}else f.current&&o(!1),g.current&&p(null),k.treeInstruction&&(s(null),a.current&&delete a.current.dataset.treeInstruction),b.current&&d(e.self.dropEffect),y.current&&h({relativeX:0,relativeY:0,clientX:0,clientY:0}),k.closestEdge&&l(null),a.current&&delete a.current.dataset.draggedOver}})},[k]),{dropTargetRef:a,get draggedOver(){return f.current=!0,r},get draggedOverDraggable(){return g.current=!0,m},get draggedOverPosition(){return y.current=!0,u},get dropEffect(){return b.current=!0,c},treeInstruction:i,closestEdge:n}};var eL=a(18859);let e$=({value:e,editable:t,exitible:a,className:r,style:o,trigger:i="doubleClick",autoSelect:s,onInput:n,onChange:l,placeholder:c,placeholderClassName:d,placeholderStyle:m,handleRef:p,inputAttrs:u,...h})=>{let[f,g]=(0,v.useState)(!1),[y,b]=(0,v.useState)(e),k=(0,v.useRef)(null);(0,v.useImperativeHandle)(p,()=>({triggerEdit:w}));let w=(0,v.useCallback)(()=>{t&&(g(!0),setTimeout(()=>{k.current?.focus(),s&&k.current?.select()},0))},[s,t]),x=(0,v.useCallback)(()=>{"doubleClick"===i&&w()},[w,i]),C=(0,v.useCallback)(()=>{"click"===i&&w()},[w,i]),S=(0,v.useCallback)(()=>{l?.(y||"")},[y,l]),F=(0,v.useCallback)(()=>{k.current?.blur()},[]),A=(0,v.useCallback)(()=>{g(!1),S(),k.current?.scrollTo(0,0)},[S]),E=(0,v.useCallback)(e=>{e.stopPropagation(),a&&"Escape"===e.key&&k.current?.blur()},[a]),N=(0,v.useCallback)(e=>{b(e),n?.(e)},[n]);(0,v.useEffect)(()=>{b(e)},[e]);let _=(0,v.useMemo)(()=>y?y.replace(/\n/g,""):"",[y]),I={margin:"inherit",padding:"inherit",borderRadius:"inherit",fontSize:"inherit",fontFamily:"inherit",lineHeight:"inherit",fontWeight:"inherit",letterSpacing:"inherit",textAlign:"inherit",color:"inherit",backgroundColor:"inherit"},j={...I,padding:0,margin:0};return(0,M.jsxs)("div",{"data-editing":f,className:(0,Z.A)("_1ejglp90",r),style:{...o},...h,children:[(0,M.jsxs)("div",{onClick:C,onDoubleClick:x,className:(0,Z.A)("_1ejglp91"),children:[_,!_&&(0,M.jsx)(eW,{className:d,label:c,style:m})]}),(0,M.jsx)(eL.A,{ref:k,className:"_1ejglp92",value:y,placeholder:c,onEnter:F,onKeyDown:E,onChange:N,style:I,inputStyle:j,onBlur:A,...u})]})},eW=({label:e,children:t,className:a,style:r,...o})=>(0,M.jsx)("div",{className:(0,Z.A)("_1ejglp93",a),style:r,...o,children:t??e});var ez=a(74468),eO="_1emdcdb0";let eB=({children:e,inline:t,style:a,className:r})=>t?(0,M.jsx)("span",{style:a,className:(0,Z.A)(r,eO),children:e}):(0,M.jsx)("div",{style:a,className:(0,Z.A)(r,eO),children:e});var eR=a(23675),eU=a(73896),eq=a(81241),eV=a.n(eq);let eG=JSON.parse('{"v":"5.12.1","fr":120,"ip":0,"op":76,"w":300,"h":300,"nm":"合成 1","ddd":0,"assets":[{"id":"comp_0","nm":"预合成 1","fr":120,"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.7,"y":1},"o":{"x":0.3,"y":0},"t":0,"s":[154,140,0],"to":[0,-1.667,0],"ti":[0,-15.5,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.3,"y":0},"t":14.57,"s":[154,130,0],"to":[0,15.5,0],"ti":[0,-17.167,0]},{"i":{"x":0.5,"y":0.5},"o":{"x":0.167,"y":0.167},"t":30,"s":[154,233,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.5,"y":0},"t":171,"s":[154,233,0],"to":[0,-15.5,0],"ti":[0,15.5,0]},{"t":193,"s":[154,140,0]}],"ix":2,"l":2,"x":"var $bm_rt;\\nvar enable, amp, freq, decay, n, t, v;\\ntry {\\n $bm_rt = enable = effect(\'Excite - 位置\')(\'Pseudo/BNCA2506f0b33-0001\');\\n if (enable == 0) {\\n $bm_rt = value;\\n } else {\\n amp = $bm_div(effect(\'Excite - 位置\')(\'Pseudo/BNCA2506f0b33-0003\'), 5);\\n freq = $bm_div(effect(\'Excite - 位置\')(\'Pseudo/BNCA2506f0b33-0004\'), 10);\\n decay = $bm_div(effect(\'Excite - 位置\')(\'Pseudo/BNCA2506f0b33-0005\'), 3);\\n n = 0, 0 < numKeys && (n = nearestKey(time).index, key(n).time > time && n--), t = 0 === n ? 0 : $bm_sub(time, key(n).time), $bm_rt = 0 < n ? (v = velocityAtTime($bm_sub(key(n).time, $bm_div(thisComp.frameDuration, 10))), $bm_sum(value, $bm_div($bm_mul($bm_mul($bm_div(v, 100), amp), Math.sin($bm_mul($bm_mul($bm_mul(freq, t), 2), Math.PI))), Math.exp($bm_mul(decay, t))))) : value;\\n }\\n} catch (err) {\\n $bm_rt = value = value;\\n}"},"a":{"a":0,"k":[12,12,0],"ix":1,"l":2},"s":{"a":0,"k":[1246,1246,100],"ix":6,"l":2}},"ao":0,"ef":[{"ty":5,"nm":"Excite - 位置","np":8,"mn":"Pseudo/BNCA2506f0b33","ix":1,"en":1,"ef":[{"ty":7,"nm":"Enable","mn":"Pseudo/BNCA2506f0b33-0001","ix":1,"v":{"a":0,"k":1,"ix":1}},{"ty":6,"nm":"Properties","mn":"Pseudo/BNCA2506f0b33-0002","ix":2,"v":0},{"ty":0,"nm":"Overshoot","mn":"Pseudo/BNCA2506f0b33-0003","ix":3,"v":{"a":0,"k":20,"ix":3,"x":"var $bm_rt;\\n$bm_rt = clamp(value, 0, 100);"}},{"ty":0,"nm":"Bounce","mn":"Pseudo/BNCA2506f0b33-0004","ix":4,"v":{"a":0,"k":40,"ix":4,"x":"var $bm_rt;\\n$bm_rt = clamp(value, 0, 100);"}},{"ty":0,"nm":"Friction","mn":"Pseudo/BNCA2506f0b33-0005","ix":5,"v":{"a":0,"k":40,"ix":5,"x":"var $bm_rt;\\n$bm_rt = clamp(value, 0, 100);"}},{"ty":6,"nm":"","mn":"Pseudo/BNCA2506f0b33-0006","ix":6,"v":0}]}],"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[7,8],[17,8]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.466666696586,0.458823559331,0.490196108351,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1200,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.7,"y":1},"o":{"x":0.3,"y":0},"t":4,"s":[154,140,0],"to":[0,-1.667,0],"ti":[0,-15.5,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.3,"y":0},"t":18.57,"s":[154,130,0],"to":[0,15.5,0],"ti":[0,-17.167,0]},{"i":{"x":0.5,"y":0.5},"o":{"x":0.167,"y":0.167},"t":34,"s":[154,233,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.5,"y":0},"t":168,"s":[154,233,0],"to":[0,-15.5,0],"ti":[0,15.5,0]},{"t":190,"s":[154,140,0]}],"ix":2,"l":2,"x":"var $bm_rt;\\nvar enable, amp, freq, decay, n, t, v;\\ntry {\\n $bm_rt = enable = effect(\'Excite - 位置\')(\'Pseudo/BNCA2506f0b33-0001\');\\n if (enable == 0) {\\n $bm_rt = value;\\n } else {\\n amp = $bm_div(effect(\'Excite - 位置\')(\'Pseudo/BNCA2506f0b33-0003\'), 5);\\n freq = $bm_div(effect(\'Excite - 位置\')(\'Pseudo/BNCA2506f0b33-0004\'), 10);\\n decay = $bm_div(effect(\'Excite - 位置\')(\'Pseudo/BNCA2506f0b33-0005\'), 3);\\n n = 0, 0 < numKeys && (n = nearestKey(time).index, key(n).time > time && n--), t = 0 === n ? 0 : $bm_sub(time, key(n).time), $bm_rt = 0 < n ? (v = velocityAtTime($bm_sub(key(n).time, $bm_div(thisComp.frameDuration, 10))), $bm_sum(value, $bm_div($bm_mul($bm_mul($bm_div(v, 100), amp), Math.sin($bm_mul($bm_mul($bm_mul(freq, t), 2), Math.PI))), Math.exp($bm_mul(decay, t))))) : value;\\n }\\n} catch (err) {\\n $bm_rt = value = value;\\n}"},"a":{"a":0,"k":[12,12,0],"ix":1,"l":2},"s":{"a":0,"k":[1246,1246,100],"ix":6,"l":2}},"ao":0,"ef":[{"ty":5,"nm":"Excite - 位置","np":8,"mn":"Pseudo/BNCA2506f0b33","ix":1,"en":1,"ef":[{"ty":7,"nm":"Enable","mn":"Pseudo/BNCA2506f0b33-0001","ix":1,"v":{"a":0,"k":1,"ix":1}},{"ty":6,"nm":"Properties","mn":"Pseudo/BNCA2506f0b33-0002","ix":2,"v":0},{"ty":0,"nm":"Overshoot","mn":"Pseudo/BNCA2506f0b33-0003","ix":3,"v":{"a":0,"k":20,"ix":3,"x":"var $bm_rt;\\n$bm_rt = clamp(value, 0, 100);"}},{"ty":0,"nm":"Bounce","mn":"Pseudo/BNCA2506f0b33-0004","ix":4,"v":{"a":0,"k":40,"ix":4,"x":"var $bm_rt;\\n$bm_rt = clamp(value, 0, 100);"}},{"ty":0,"nm":"Friction","mn":"Pseudo/BNCA2506f0b33-0005","ix":5,"v":{"a":0,"k":40,"ix":5,"x":"var $bm_rt;\\n$bm_rt = clamp(value, 0, 100);"}},{"ty":6,"nm":"","mn":"Pseudo/BNCA2506f0b33-0006","ix":6,"v":0}]}],"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[9,5],[15,5]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.466666696586,0.458823559331,0.490196108351,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1200,"st":0,"ct":1,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"“图层 4”轮廓","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[154,140,0],"ix":2,"l":2},"a":{"a":0,"k":[12,12,0],"ix":1,"l":2},"s":{"a":0,"k":[1246,1246,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-1.105,0],[0,0],[0,-1.105],[0,0],[1.105,0],[0,0],[0,1.105],[0,0]],"o":[[0,0],[1.105,0],[0,0],[0,1.105],[0,0],[-1.105,0],[0,0],[0,-1.105]],"v":[[-5,-4.5],[5,-4.5],[7,-2.5],[7,2.5],[5,4.5],[-5,4.5],[-7,2.5],[-7,-2.5]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.466666696586,0.458823559331,0.490196108351,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":1,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[12,15.5],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1200,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":0,"nm":"预合成 1","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[150,150,0],"ix":2,"l":2},"a":{"a":0,"k":[150,150,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"hasMask":true,"masksProperties":[{"inv":false,"mode":"a","pt":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[291.703,10],[14,10],[14,128.273],[291.703,128.273]],"c":true},"ix":1},"o":{"a":0,"k":100,"ix":3},"x":{"a":0,"k":0,"ix":4},"nm":"蒙版 1"}],"w":300,"h":300,"ip":0,"op":1200,"st":0,"bm":0}],"markers":[],"props":{}}');var eH="ko45ds0";let eZ=({closed:e,className:t})=>{let a=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(a.current){let t=a.current;e?t.setDirection(1):t.setDirection(-1),t.play()}},[e]),(0,M.jsx)(eV(),{className:(0,Z.A)(eH,t),autoPlay:!1,loop:!1,lottieRef:a,animationData:eG})},eK=JSON.parse('{"v":"5.12.1","fr":120,"ip":0,"op":72,"w":240,"h":240,"nm":"Delete","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"head","parent":2,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[12,5,0],"ix":2,"l":2},"a":{"a":0,"k":[12,5,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-1.105,0],[0,0],[0,-1.105],[0,0],[0,0]],"o":[[0,-1.105],[0,0],[1.105,0],[0,0],[0,0],[0,0]],"v":[[-3,0],[-1,-2],[1,-2],[3,0],[3,2],[-3,2]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.466666696586,0.458823559331,0.490196108351,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[12,5],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1200,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"headline","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.62],"y":[1]},"o":{"x":[0.001],"y":[0]},"t":15.906,"s":[0]},{"t":23,"s":[-23]}],"ix":10},"p":{"a":1,"k":[{"i":{"x":0.62,"y":1},"o":{"x":0.001,"y":0},"t":9,"s":[119,67,0],"to":[-2.167,-0.583,0],"ti":[5.25,2.583,0]},{"i":{"x":0.62,"y":1},"o":{"x":0.001,"y":0},"t":15.906,"s":[106,63.5,0],"to":[-5.25,-2.583,0],"ti":[3.083,2,0]},{"t":22.80859375,"s":[87.5,51.5,0]}],"ix":2,"l":2},"a":{"a":0,"k":[12,7,0],"ix":1,"l":2},"s":{"a":0,"k":[1000,1000,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[4,7],[20,7]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.466666696586,0.458823559331,0.490196108351,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1200,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"line2","parent":5,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[14,14,0],"ix":2,"l":2},"a":{"a":0,"k":[14,14,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[14,11],[14,17]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.466666696586,0.458823559331,0.490196108351,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1200,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"line1","parent":5,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[10,14,0],"ix":2,"l":2},"a":{"a":0,"k":[10,14,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[10,11],[10,17]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.466666696586,0.458823559331,0.490196108351,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1200,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"body","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.62],"y":[1]},"o":{"x":[0.001],"y":[0]},"t":9,"s":[0]},{"t":21.08203125,"s":[-9]}],"ix":10},"p":{"a":0,"k":[49,207,0],"ix":2,"l":2},"a":{"a":0,"k":[5,21,0],"ix":1,"l":2},"s":{"a":0,"k":[1000,1000,100],"ix":6,"l":2}},"ao":0,"ef":[{"ty":5,"nm":"Excite - 位置","np":8,"mn":"Pseudo/BNCA2506f0b33","ix":1,"en":1,"ef":[{"ty":7,"nm":"Enable","mn":"Pseudo/BNCA2506f0b33-0001","ix":1,"v":{"a":0,"k":1,"ix":1}},{"ty":6,"nm":"Properties","mn":"Pseudo/BNCA2506f0b33-0002","ix":2,"v":0},{"ty":0,"nm":"Overshoot","mn":"Pseudo/BNCA2506f0b33-0003","ix":3,"v":{"a":0,"k":20,"ix":3,"x":"var $bm_rt;\\n$bm_rt = clamp(value, 0, 100);"}},{"ty":0,"nm":"Bounce","mn":"Pseudo/BNCA2506f0b33-0004","ix":4,"v":{"a":0,"k":40,"ix":4,"x":"var $bm_rt;\\n$bm_rt = clamp(value, 0, 100);"}},{"ty":0,"nm":"Friction","mn":"Pseudo/BNCA2506f0b33-0005","ix":5,"v":{"a":0,"k":40,"ix":5,"x":"var $bm_rt;\\n$bm_rt = clamp(value, 0, 100);"}},{"ty":6,"nm":"","mn":"Pseudo/BNCA2506f0b33-0006","ix":6,"v":0}]},{"ty":5,"nm":"Excite - 旋转","np":8,"mn":"Pseudo/BNCA2506f0b33","ix":2,"en":1,"ef":[{"ty":7,"nm":"Enable","mn":"Pseudo/BNCA2506f0b33-0001","ix":1,"v":{"a":0,"k":1,"ix":1}},{"ty":6,"nm":"Properties","mn":"Pseudo/BNCA2506f0b33-0002","ix":2,"v":0},{"ty":0,"nm":"Overshoot","mn":"Pseudo/BNCA2506f0b33-0003","ix":3,"v":{"a":0,"k":20,"ix":3,"x":"var $bm_rt;\\n$bm_rt = clamp(value, 0, 100);"}},{"ty":0,"nm":"Bounce","mn":"Pseudo/BNCA2506f0b33-0004","ix":4,"v":{"a":0,"k":40,"ix":4,"x":"var $bm_rt;\\n$bm_rt = clamp(value, 0, 100);"}},{"ty":0,"nm":"Friction","mn":"Pseudo/BNCA2506f0b33-0005","ix":5,"v":{"a":0,"k":40,"ix":5,"x":"var $bm_rt;\\n$bm_rt = clamp(value, 0, 100);"}},{"ty":6,"nm":"","mn":"Pseudo/BNCA2506f0b33-0006","ix":6,"v":0}]}],"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[-1.049,0],[0,0],[-0.075,1.046],[0,0]],"o":[[0,0],[0.075,1.046],[0,0],[1.049,0],[0,0],[0,0]],"v":[[-7,-7],[-6.133,5.143],[-4.138,7],[4.138,7],[6.133,5.143],[7,-7]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.466666696586,0.458823559331,0.490196108351,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":1,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[12,14],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1200,"st":0,"ct":1,"bm":0}],"markers":[],"props":{}}'),eY=({closed:e,className:t})=>{let a=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(a.current){let t=a.current;e?t.setDirection(1):t.setDirection(-1),t.play()}},[e]),(0,M.jsx)(eV(),{className:(0,Z.A)(eH,t),autoPlay:!1,loop:!1,lottieRef:a,animationData:eK})},eJ=JSON.parse('{"v":"5.12.1","fr":60,"ip":0,"op":6,"w":240,"h":240,"nm":"folder","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"“图层 2”轮廓 3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[120,120,0],"ix":2,"l":2},"a":{"a":0,"k":[12,12,0],"ix":1,"l":2},"s":{"a":0,"k":[1000,1000,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":0,"s":[{"i":[[0,0],[-1.105,0],[0,0],[0,0],[0,0],[-0.366,-0.46],[0,0],[1.105,0],[0,0],[0,1.105]],"o":[[0,-1.105],[0,0],[0.53,0],[0,0],[0.634,0],[0.272,0.342],[0,1.105],[0,0],[-1.105,0],[0,0]],"v":[[-9,-5.25],[-7,-7.25],[-2.328,-7.25],[0.5,-5.25],[7,-5.25],[8.565,-4.495],[9,5.25],[7,7.25],[-7,7.25],[-9,5.25]],"c":true}]},{"t":5,"s":[{"i":[[0,0],[-1.105,0],[0,0],[0,0],[0,0],[-0.002,-0.756],[0,0],[1.105,0],[0,0],[0,1.105]],"o":[[0.225,-0.675],[0,0],[0.53,0],[0,0],[2.525,-0.05],[-0.002,0.982],[-0.375,1.05],[0,0],[-1.105,0],[0,0]],"v":[[-7.5,0.35],[-5.5,-1.65],[-0.828,-1.65],[2,-1.637],[7.825,-1.612],[10.577,0.344],[9.075,5.25],[7.075,7.25],[-7,7.25],[-9,5.25]],"c":true}]}],"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.466666666667,0.458823529412,0.490196078431,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":1,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[12,11.75],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":1,"op":18060,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"形状图层 1","td":1,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[120,120,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":0,"s":[{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[77.675,-57.65],[77.675,39.75],[-74.425,39.801],[-74.425,-57.6]],"c":true}]},{"t":5,"s":[{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[107.675,-32.825],[84.175,45.15],[-80.425,45.075],[-80.425,-34.825]],"c":true}]}],"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-1.575,18.575],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"矩形 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":18060,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"“图层 2”轮廓","tt":2,"tp":2,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[120,120,0],"ix":2,"l":2},"a":{"a":0,"k":[12,12,0],"ix":1,"l":2},"s":{"a":0,"k":[1000,1000,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-1.105,0],[0,0],[-0.375,-0.375],[0,0],[0,0],[0,-1.105],[0,0],[1.105,0],[0,0],[0,1.105]],"o":[[0,-1.105],[0,0],[0.53,0],[0,0],[0,0],[1.105,0],[0,0],[0,1.105],[0,0],[-1.105,0],[0,0]],"v":[[-9,-5.25],[-7,-7.25],[-2.328,-7.25],[-0.914,-6.664],[0.5,-5.25],[7,-5.25],[9,-3.25],[9,5.25],[7,7.25],[-7,7.25],[-9,5.25]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.466666666667,0.458823529412,0.490196078431,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":1,"lj":2,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[12,11.75],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":18060,"st":0,"ct":1,"bm":0}],"markers":[],"props":{}}'),eQ=({open:e,className:t,speed:a=.5})=>{let r=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(r.current){let t=r.current;t.setSpeed(a),e?t.setDirection(1):t.setDirection(-1),t.play()}},[e,a]),(0,M.jsx)(eV(),{className:(0,Z.A)(eH,t),autoPlay:!1,loop:!1,lottieRef:r,animationData:eJ})};var eX=a(14277),e0=a(34310),e1=a(67156),e2=a(45891);let e3=({content:e,children:t,portalOptions:a,contentOptions:{className:r,style:o,...i}={},...s})=>(0,M.jsxs)(e2.bL,{...s,children:[(0,M.jsx)(e2.l9,{asChild:!0,children:t}),(0,M.jsx)(e2.ZL,{...a,children:(0,M.jsx)(e2.UC,{className:(0,v.useMemo)(()=>(0,Z.A)("fhfoir0",r),[r]),sideOffset:5,align:"start",style:{zIndex:"var(--affine-z-index-popover)",...o},...i,children:e})})]});e3.displayName="Popover";var e4=a(21633),e6=a(66889),e5=a(59097);let e7=({checked:e=!1,onChange:t,children:a,className:r,disabled:o,...i})=>{let[s,n]=(0,v.useState)(e),l=t?e:s,c=(0,v.useCallback)(e=>{if(o)return;let a=e.target.checked;t?t(a):n(a)},[o,t]);return(0,M.jsxs)("label",{className:(0,Z.A)("_1lq49df0",r),...i,children:[a,(0,M.jsx)("input",{className:(0,Z.A)("_1lq49df1"),type:"checkbox",value:l?"on":"off",checked:l,onChange:c}),(0,M.jsx)("span",{className:(0,Z.A)("_1lq49df2",{_1lq49df3:l,_1lq49df4:o})})]})};(0,_.I4)("table")(({showBorder:e})=>({fontSize:"var(--affine-font-base)",color:"var(--affine-text-primary-color)",tableLayout:"fixed",width:"100%",borderCollapse:"collapse",borderSpacing:"0",..."boolean"==typeof e?{thead:{"::after":{display:"block",position:"absolute",content:'""',width:"100%",height:"1px",left:0,background:"var(--affine-border-color)",transition:"opacity .15s",opacity:e?1:0}}}:{}})),(0,_.I4)("tbody")(()=>({fontWeight:400})),(0,_.I4)("td")(({align:e="left",ellipsis:t=!1,proportion:a,active:r=!1,onClick:o})=>({width:a?`${100*a}%`:"auto",height:"52px",paddingLeft:"16px",boxSizing:"border-box",textAlign:e,verticalAlign:"middle",whiteSpace:"nowrap",userSelect:"none",fontSize:"var(--affine-font-sm)",...r?{color:"var(--affine-text-primary-color)"}:{},...t?(0,_.L9)(1):{},...o?{cursor:"pointer"}:{}})),(0,_.I4)("thead")(()=>({fontWeight:500,color:"var(--affine-text-secondary-color)"})),(0,_.I4)("tr")({td:{whiteSpace:"nowrap",position:"sticky",top:0,background:"var(--affine-background-primary-color)"}}),(0,_.I4)("tr")(()=>({td:{transition:"background .15s"},"td:first-of-type":{borderTopLeftRadius:"10px",borderBottomLeftRadius:"10px"},"td:last-of-type":{borderTopRightRadius:"10px",borderBottomRightRadius:"10px"},":hover":{td:{background:"var(--affine-hover-color)"}}}));let e8=new(a(52490)).k("toast"),e9=null,te=e=>{let t=document.createElement("template");if("string"==typeof e)e=e.trim(),t.innerHTML=e;else{let{strings:a,values:r}=e,o=[...r,""];t.innerHTML=a.reduce((e,t,a)=>e+t+o[a],"")}return t.content.firstChild},tt=e=>{e=e||document.body;let t=(0,g.AH)` width: 100%; position: fixed; z-index: 9999; bottom: 78px; left: 50%; transform: translateX(-50%); pointer-events: none; display: flex; flex-direction: column; align-items: center; `,a=te((0,g.qy)`
`);return e.append(a),a},ta=e=>{e.style.opacity="0",setTimeout(()=>e.remove(),300)},tr=(e,t,a)=>{e9&&(!a||a.contains(e9))||(e9=tt(a));let r=(0,g.AH)` position: absolute; bottom: 0; max-width: 480px; text-align: center; font-family: var(--affine-font-family); font-size: var(--affine-font-sm); padding: 10px 16px; margin: 0; color: var(--affine-white); background: var(--affine-tooltip); box-shadow: var(--affine-float-button-shadow); border-radius: 8px; opacity: 0; transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1), opacity 0.3s ease; `,o=te((0,g.qy)`
${e}
`);o.textContent=e,e9.append(o),e8.debug(`toast with message: "${e}"`),window.dispatchEvent(new CustomEvent("affine-toast:emit",{detail:e})),setTimeout(()=>{o.style.opacity="1",o.style.transform="translateY(0)"},100),setTimeout(()=>{ta(o)},t)},to=(e,{duration:t=3e3,portal:a}={})=>{e9&&e9.children.length>=2&&e9.children[0].remove(),e9&&1===e9.children.length&&ta(e9.children[0]),tr(e,t,a)};var ti=a(39958)},88713:(e,t,a)=>{"use strict";a.d(t,{I4:()=>o.A,L9:()=>r});let r=(e=1)=>e>1?{display:"-webkit-box",wordBreak:"break-all",WebkitBoxOrient:"vertical",WebkitLineClamp:`${e}`,overflow:"hidden",textOverflow:"ellipsis"}:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};var o=a(39405)},80198:(e,t,a)=>{"use strict";a.d(t,{e:()=>f});var r=a(36870),o=a(45483),i=a(94307),s=a(50822),n=a(37064),l=a(86326),c=a(24766),d=a(55683),m=a(39958),p="_1012frsc";let u=[["#FF0000","#FF00E5","#FFAE73"],["#FF5C00","#FFC700","#FFE073"],["#FFDA16","#FFFBA6","#FFBE73"],["#8CD317","#FCFF5C","#67CAE9"],["#28E19F","#89FFC6","#39A880"],["#35B7E0","#77FFCE","#5076FF"],["#3D39FF","#77BEFF","#3502FF"],["#BD08EB","#755FFF","#6967E4"]],h=({char:e})=>{let t=(0,l.useMemo)(()=>u[e.toUpperCase().charCodeAt(0)%u.length],[e]),a=(0,l.useRef)(),[o,i,s]=t,[c,d]=(0,l.useState)(!1);return(0,r.jsxs)("div",{className:"_1012frs4",onMouseEnter:()=>{a.current=setTimeout(()=>{d(!0)},300)},onMouseLeave:()=>{clearTimeout(a.current),d(!1)},children:[(0,r.jsx)("div",{className:"_1012frs9",style:{background:s}}),(0,r.jsx)("div",{className:(0,n.A)("_1012frs5",{_1012frs6:c}),style:{background:i}}),(0,r.jsx)("div",{className:(0,n.A)("_1012frs7",{_1012frs8:c}),style:{background:o}})]})},f=(0,l.forwardRef)(({size:e=20,style:t={},url:a,image:u,name:f,className:g,colorfulFallback:y=!1,hoverIcon:b,fallbackProps:{className:v,...k}={},imageProps:w,avatarProps:x,rounded:C="50%",onRemove:S,hoverWrapperProps:{className:F,...A}={},avatarTooltipOptions:E,removeTooltipOptions:N,removeButtonProps:{className:_,...I}={},...j},D)=>{let M=(0,l.useMemo)(()=>f?.slice(0,1)||"A",[f]),[T,P]=(0,l.useState)(null),[L,$]=(0,l.useState)(null),[W,z]=(0,l.useState)(null);(0,l.useLayoutEffect)(()=>{if(W&&u){let t=W?.getContext("2d");t&&function(e,t,a){let r=Math.max(a/e.width,a/e.height),o=(a-e.width*r)/2,i=(a-e.height*r)/2;t.drawImage(e,0,0,e.width,e.height,o,i,e.width*r,e.height*r)}(u,t,e*window.devicePixelRatio)}},[W,u,e]);let O=(0,l.useCallback)(e=>{z(e)},[]);return(0,r.jsxs)(i.bL,{className:"_1012frsa",...x,ref:D,children:[(0,r.jsx)(m.m,{portalOptions:{container:T},...E,children:(0,r.jsxs)("div",{ref:P,className:(0,n.A)("_1012frsb",g),style:{...(0,s.D)({"var(--_1012frs0)":e?`${e}px`:"20px","var(--_1012frs1)":`${.3*e}px`,borderRadius:(0,c.$)(C,"px")}),...t},...j,children:[u?(0,r.jsx)("canvas",{className:p,ref:O,width:e*window.devicePixelRatio,height:e*window.devicePixelRatio,...w}):(0,r.jsx)(i._V,{className:p,src:a||"",alt:f,...w}),!u&&(0,r.jsx)(i.H4,{className:(0,n.A)("_1012frsd",v),delayMs:a?600:void 0,...k,children:y?(0,r.jsx)(h,{char:M}):M.toUpperCase()}),b?(0,r.jsx)("div",{className:(0,n.A)("_1012frse",F),...A,children:b}):null]})}),S?(0,r.jsx)(d.K0,{tooltipOptions:{portalOptions:{container:L},...N},variant:"solid",size:"12",className:(0,n.A)("_1012frsf",_),onClick:S,ref:$,...I,children:(0,r.jsx)(o.CloseIcon,{})}):null]})});f.displayName="Avatar"},55683:(e,t,a)=>{"use strict";a.d(t,{$n:()=>d,gf:()=>p,K0:()=>h});var r=a(36870),o=a(37064),i=a(86326),s=a(91119),n=a(73896),l=a(39958);let c=({icon:e,loading:t,className:a,...s})=>e||t?(0,r.jsxs)("div",{className:(0,o.A)("_158e9log",a),...s,children:[void 0!==t&&t?(0,r.jsx)(n.R,{size:"100%"}):null,e&&!t?(0,i.cloneElement)(e,{width:"100%",height:"100%",...e.props}):null]}):null,d=(0,i.forwardRef)(({variant:e="secondary",size:t="default",children:a,disabled:n,block:d,loading:m,className:p,withoutHover:u,prefix:h,prefixClassName:f,prefixStyle:g,suffix:y,suffixClassName:b,suffixStyle:v,contentClassName:k,contentStyle:w,tooltip:x,tooltipShortcut:C,tooltipOptions:S,autoFocus:F,onClick:A,...E},N)=>{let _=(0,s.f)(F),I=(0,i.useCallback)(e=>{m||n||A?.(e)},[n,m,A]);return(0,r.jsx)(l.m,{content:x,shortcut:C,...S,children:(0,r.jsxs)("button",{...E,ref:e=>{_.current=e,N&&("function"==typeof N?N(e):N.current=e)},className:(0,o.A)("_158e9loe",p),"data-loading":m||void 0,"data-block":d||void 0,disabled:n,"data-disabled":n||void 0,"data-size":t,"data-variant":e,"data-no-hover":u||void 0,onClick:I,children:[(0,r.jsx)(c,{icon:h,loading:m,className:f,style:g}),a?(0,r.jsx)("span",{className:(0,o.A)("_158e9lof",k),style:w,children:a}):null,(0,r.jsx)(c,{icon:y,className:b,style:v})]})})});d.displayName="Button";var m=a(45483);let p=(0,i.forwardRef)(({onClickDropDown:e,children:t,size:a="default",...o},i)=>(0,r.jsxs)("button",{ref:i,"data-size":a,className:"_1ml45c00",...o,children:[(0,r.jsx)("span",{children:t}),(0,r.jsx)("span",{className:"_1ml45c01"}),(0,r.jsx)("span",{className:"_1ml45c02",onClick:t=>{t.stopPropagation(),e?.(t)},children:(0,r.jsx)(m.ArrowDownSmallIcon,{className:"_1ml45c03",width:16,height:16})})]}));p.displayName="DropdownButton";var u=a(50822);let h=(0,i.forwardRef)(({variant:e="plain",size:t="20",style:a,className:i,children:s,icon:n,iconClassName:l,iconStyle:c,...m},p)=>{let h=isNaN(parseInt(t,10))?16:t;return(0,r.jsx)(d,{ref:p,style:{...a,...(0,u.D)({"var(--_158e9lo2)":`${h}px`})},"data-icon-variant":e,"data-icon-size":h,className:(0,o.A)("_158e9loh",i),size:"custom",variant:"custom",prefix:s??n,prefixClassName:l,prefixStyle:c,...m})});h.displayName="IconButton";var f=a(84837);a(21633).z,(0,i.forwardRef)(({children:e,className:t,spanStyle:a,...i},s)=>(0,r.jsxs)(f.q7,{ref:s,...i,className:(0,o.A)("_1ml45c04",t),children:[(0,r.jsx)("span",{className:(0,o.A)("_1ml45c06 _1ml45c05",a),children:e}),(0,r.jsx)(f.C1,{className:(0,o.A)("_1ml45c05",a),children:e})]})).displayName="RadioButton",(0,i.forwardRef)(({className:e,style:t,width:a,...i},s)=>(0,r.jsx)(f.bL,{ref:s,className:(0,o.A)("_1ml45c07",e),style:{width:a,...t},...i})).displayName="RadioButtonGroup"},15767:(e,t,a)=>{"use strict";a.d(t,{S:()=>c});var r=a(36870),o=a(37064),i=a(86326);let s=(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 3.25C4.48122 3.25 3.25 4.48122 3.25 6V18C3.25 19.5188 4.48122 20.75 6 20.75H18C19.5188 20.75 20.75 19.5188 20.75 18V6C20.75 4.48122 19.5188 3.25 18 3.25H6ZM4.75 6C4.75 5.30964 5.30964 4.75 6 4.75H18C18.6904 4.75 19.25 5.30964 19.25 6V18C19.25 18.6904 18.6904 19.25 18 19.25H6C5.30964 19.25 4.75 18.6904 4.75 18V6Z",fill:"currentColor"})}),n=(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.25 6C3.25 4.48122 4.48122 3.25 6 3.25H18C19.5188 3.25 20.75 4.48122 20.75 6V18C20.75 19.5188 19.5188 20.75 18 20.75H6C4.48122 20.75 3.25 19.5188 3.25 18V6ZM16.5303 9.53033C16.8232 9.23744 16.8232 8.76256 16.5303 8.46967C16.2374 8.17678 15.7626 8.17678 15.4697 8.46967L10.5 13.4393L9.03033 11.9697C8.73744 11.6768 8.26256 11.6768 7.96967 11.9697C7.67678 12.2626 7.67678 12.7374 7.96967 13.0303L9.96967 15.0303C10.2626 15.3232 10.7374 15.3232 11.0303 15.0303L16.5303 9.53033Z",fill:"var(--affine-blue-600)"})}),l=(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 3.25C4.48122 3.25 3.25 4.48122 3.25 6V18C3.25 19.5188 4.48122 20.75 6 20.75H18C19.5188 20.75 20.75 19.5188 20.75 18V6C20.75 4.48122 19.5188 3.25 18 3.25H6ZM8.54 11.25C8.12579 11.25 7.79 11.5858 7.79 12C7.79 12.4142 8.12579 12.75 8.54 12.75H15.54C15.9542 12.75 16.29 12.4142 16.29 12C16.29 11.5858 15.9542 11.25 15.54 11.25H8.54Z",fill:"currentColor"})}),c=({checked:e,onChange:t,indeterminate:a,disabled:c,animation:m,name:p,label:u,inputClassName:h,labelClassName:f,className:g,...y})=>{let b=(0,i.useRef)(null),v=(0,i.useCallback)(e=>{let a=e.target.checked;t(e,a);let r=b.current;a&&r&&m&&d(r.parentElement).catch(console.error)},[t,m]);return(0,i.useEffect)(()=>{b.current&&(b.current.indeterminate=!!a)},[a]),(0,r.jsxs)("div",{className:(0,o.A)("yjadpy0",g,c&&"yjadpy1"),role:"checkbox",...y,children:[a?l:e?n:s,(0,r.jsx)("input",{ref:b,"data-testid":"affine-checkbox",className:(0,o.A)("yjadpy2",h),type:"checkbox",value:e?"on":"off",id:p,name:p,checked:e,onChange:v}),u?(0,r.jsx)("label",{htmlFor:p,className:(0,o.A)(f),children:u}):null]})},d=async e=>{let t=document.createElement("div");t.classList.add("affine-check-animation"),t.style.cssText=` position: absolute; width: 1em; height: 1em; border-radius: 50%; font-size: inherit; `,e.append(t),await t.animate([{boxShadow:"0 -18px 0 -8px #1e96eb, 16px -8px 0 -8px #1e96eb, 16px 8px 0 -8px #1e96eb, 0 18px 0 -8px #1e96eb, -16px 8px 0 -8px #1e96eb, -16px -8px 0 -8px #1e96eb"}],{duration:240,easing:"ease",fill:"forwards"}).finished,await t.animate([{boxShadow:"0 -36px 0 -10px transparent, 32px -16px 0 -10px transparent, 32px 16px 0 -10px transparent, 0 36px 0 -10px transparent, -32px 16px 0 -10px transparent, -32px -16px 0 -10px transparent"}],{duration:360,easing:"ease",fill:"forwards"}).finished,t.remove()}},63035:(e,t,a)=>{"use strict";a.d(t,{c:()=>i});var r=a(36870),o=a(37064);let i=(0,a(86326).forwardRef)(({orientation:e="horizontal",size:t="default",dividerColor:a="var(--affine-border-color)",style:i,className:s,...n},l)=>(0,r.jsx)("div",{"data-divider":!0,ref:l,className:(0,o.A)("_1tgwjy20",{_1tgwjy22:"vertical"===e,_1tgwjy21:"thinner"===t&&"horizontal"===e,_1tgwjy23:"thinner"===t&&"vertical"===e},s),style:{backgroundColor:a||void 0,...i},...n}));i.displayName="Divider"},74468:(e,t,a)=>{"use strict";a.d(t,{S:()=>s});var r=a(36870),o=a(50822);let i=(0,a(86326).memo)(function({style:e,className:t}){return(0,r.jsxs)("svg",{className:t,style:e,width:"248",height:"216",viewBox:"0 0 248 216",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M124.321 4.45459L5.2627 210.669H243.379L124.321 4.45459ZM239.666 207.565L182.825 109.114L125.984 141.931L239.666 207.565ZM125.153 140.49L181.993 107.673L125.153 9.22248L125.153 140.49ZM123.489 9.22248L123.489 140.49L66.6484 107.673L123.489 9.22248ZM65.8166 109.114L8.97592 207.565L122.657 141.931L65.8166 109.114ZM123.489 143.372L9.80773 209.006H123.489V143.372ZM125.153 209.006H238.834L125.153 143.372L125.153 209.006Z",fillOpacity:"0.3"}),(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M124.283 208.367C161.062 208.367 190.89 178.415 190.89 141.452C190.89 104.489 161.062 74.5371 124.283 74.5371C87.5044 74.5371 57.6765 104.489 57.6765 141.452C57.6765 178.415 87.5044 208.367 124.283 208.367ZM124.283 210.031C161.988 210.031 192.553 179.327 192.553 141.452C192.553 103.577 161.988 72.8735 124.283 72.8735C86.5785 72.8735 56.0129 103.577 56.0129 141.452C56.0129 179.327 86.5785 210.031 124.283 210.031Z",fillOpacity:"0.3"}),(0,r.jsx)("circle",{cx:"65.7267",cy:"107.881",r:"4.93369",fillOpacity:"0.8"}),(0,r.jsx)("circle",{cx:"5.26255",cy:"210.014",r:"4.93369",fillOpacity:"0.8"}),(0,r.jsx)("circle",{cx:"124.359",cy:"210.014",r:"4.93369",fillOpacity:"0.8"}),(0,r.jsx)("circle",{cx:"243.06",cy:"210.014",r:"4.93369",fillOpacity:"0.8"}),(0,r.jsx)("circle",{cx:"183.499",cy:"107.881",r:"4.93369",fillOpacity:"0.8"}),(0,r.jsx)("circle",{cx:"124.396",cy:"141.83",r:"4.93369",fillOpacity:"0.8"}),(0,r.jsx)("circle",{cx:"124.344",cy:"5.00449",r:"4.93369",fillOpacity:"0.8"})]})}),s=({containerStyle:e,title:t,description:a,descriptionStyle:s})=>{let n=(0,o.D)({"var(--g2c0ac0)":e?.width,"var(--g2c0ac1)":e?.height,"var(--g2c0ac2)":e?.fontSize});return(0,r.jsxs)("div",{className:"g2c0ac3",children:[(0,r.jsx)("div",{style:{color:"var(--affine-black)"},children:(0,r.jsx)(i,{className:"g2c0ac4",style:n})}),t&&(0,r.jsx)("p",{style:{marginTop:"30px",color:"var(--affine-text-primary-color)",fontWeight:700},children:t}),a&&(0,r.jsx)("p",{style:{marginTop:t?"8px":"30px",...s},children:a})]})}},18859:(e,t,a)=>{"use strict";a.d(t,{p:()=>n,A:()=>l});var r=a(36870),o=a(37064),i=a(86326),s=a(91119);let n=(0,i.forwardRef)(function({disabled:e,onChange:t,noBorder:a=!1,className:n,status:l="default",style:c={},inputStyle:d={},size:m="default",preFix:p,endFix:u,onEnter:h,onKeyDown:f,onBlur:g,autoFocus:y,autoSelect:b,...v},k){let w=(0,s.f)(y),x=(0,s.p)(b);return(0,i.useEffect)(()=>{if(g)return x.current?.addEventListener("blur",g),()=>{x.current?.removeEventListener("blur",g)}},[g,x]),(0,r.jsxs)("div",{className:(0,o.A)("p3ks4p0",n,{disabled:e,"no-border":a,error:"error"===l,success:"success"===l,warning:"warning"===l,default:"default"===l,large:"large"===m,"extra-large":"extraLarge"===m}),style:{...c},children:[p,(0,r.jsx)("input",{className:(0,o.A)("p3ks4p1",{large:"large"===m,"extra-large":"extraLarge"===m}),ref:e=>{w.current=e,x.current=e,k&&("function"==typeof k?k(e):k.current=e)},disabled:e,style:d,onChange:(0,i.useCallback)(e=>{t?.(e.target.value)},[t]),onKeyDown:(0,i.useCallback)(e=>{"Enter"===e.key&&h?.(),f?.(e)},[f,h]),...v}),u]})}),l=n},23675:(e,t,a)=>{"use strict";a.d(t,{Z6:()=>i,mO:()=>o});var r=a(88713);(0,r.I4)("div",{shouldForwardProp:e=>!["color","fontSize","weight","lineHeight","ellipsis","lineNum","width","maxWidth","align"].includes(e)})(({color:e,fontSize:t,weight:a,lineHeight:o,ellipsis:i,lineNum:s,width:n,maxWidth:l,align:c})=>({width:n,maxWidth:l,textAlign:c,display:"inline-block",color:e??"var(--affine-text-primary-color)",fontSize:t??"var(--affine-font-base)",fontWeight:a??400,lineHeight:o??1.5,...i?(0,r.L9)(s):{}}));let o=(0,r.I4)("div",{shouldForwardProp:e=>!["display","width","height","padding","margin","paddingTop","paddingRight","paddingLeft","paddingBottom","marginTop","marginLeft","marginRight","marginBottom"].includes(e)})(({display:e,width:t,height:a,padding:r,margin:o,paddingTop:i,paddingRight:s,paddingLeft:n,paddingBottom:l,marginTop:c,marginLeft:d,marginRight:m,marginBottom:p})=>({display:e,width:t,height:a,padding:r,margin:o,paddingTop:i,paddingRight:s,paddingLeft:n,paddingBottom:l,marginTop:c,marginLeft:d,marginRight:m,marginBottom:p})),i=(0,r.I4)(o,{shouldForwardProp:e=>!["justifyContent","alignItems","wrap","flexDirection","flexShrink","flexGrow","gap"].includes(e)})(({justifyContent:e,alignItems:t,wrap:a=!1,flexDirection:r,flexShrink:o,flexGrow:i,gap:s})=>({display:"flex",justifyContent:e,alignItems:t,flexWrap:a?"wrap":"nowrap",flexDirection:r,flexShrink:o,flexGrow:i,gap:s}))},73896:(e,t,a)=>{"use strict";a.d(t,{R:()=>s});var r=a(36870),o=a(50822),i=a(24766);let s=({size:e,speed:t=1.2,progress:a=.2})=>{let s=e?(0,i.$)(e,"px"):"16px";return(0,r.jsxs)("svg",{className:"_1hoh1ej2",width:s,height:s,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{...(0,o.D)({"var(--_1hoh1ej0)":`${t}s`})},children:[(0,r.jsx)("circle",{cx:12,cy:12,r:8,strokeWidth:4,stroke:"var(--affine-black-10)"}),(0,r.jsx)("circle",{cx:12,cy:12,r:8,strokeWidth:4,stroke:"var(--affine-primary-color)",strokeDasharray:`${2*Math.PI*8*a} ${2*Math.PI*8*(1-a)}`})]})}},14277:(e,t,a)=>{"use strict";a.d(t,{W1:()=>n,ZB:()=>c,Dr:()=>p,bX:()=>u,aC:()=>h,cQ:()=>g});var r=a(36870),o=a(43151),i=a(37064),s="njwon21";let n=({children:e,items:t,portalOptions:a,rootOptions:n,noPortal:l,contentOptions:{className:c="",style:d={},...m}={}})=>(0,r.jsxs)(o.bL,{...n,children:[(0,r.jsx)(o.l9,{asChild:!0,children:e}),l?(0,r.jsx)(o.UC,{className:(0,i.A)(s,c),sideOffset:5,align:"start",style:{zIndex:"var(--affine-z-index-popover)",...d},...m,children:t}):(0,r.jsx)(o.ZL,{...a,children:(0,r.jsx)(o.UC,{className:(0,i.A)(s,c),sideOffset:5,align:"start",style:{zIndex:"var(--affine-z-index-popover)",...d},...m,children:t})})]});var l=a(86326);let c=(0,l.forwardRef)(({children:e,icon:t,position:a="start",className:o,...s},n)=>(0,r.jsx)("div",{ref:n,className:(0,l.useMemo)(()=>(0,i.A)("njwon24",{end:"end"===a,start:"start"===a},o),[o,a]),...s,children:t||e}));c.displayName="MenuIcon";var d=a(45483);let m=({children:e,type:t="default",className:a,preFix:o,endFix:s,checked:n,selected:m,block:p})=>{let u=(0,l.useMemo)(()=>(0,i.A)("njwon22",{danger:"danger"===t,warning:"warning"===t,checked:n,selected:m,block:p},a),[p,n,a,m,t]);return{children:(0,l.useMemo)(()=>(0,r.jsxs)(r.Fragment,{children:[o,(0,r.jsx)("span",{className:"njwon23",children:e}),s,n||m?(0,r.jsx)(c,{position:"end",className:(0,i.A)({selected:m,checked:n}),children:(0,r.jsx)(d.DoneIcon,{})}):null]}),[n,s,o,e,m]),className:u}},p=({children:e,type:t="default",className:a,preFix:i,endFix:s,checked:n,selected:l,block:c,...d})=>{let{className:p,children:u}=m({children:e,className:a,type:t,preFix:i,endFix:s,checked:n,selected:l,block:c});return(0,r.jsx)(o.q7,{className:p,...d,children:u})},u=({className:e,...t})=>(0,r.jsx)(o.wv,{className:(0,l.useMemo)(()=>(0,i.A)("njwon25",e),[e]),...t}),h=({children:e,items:t,portalOptions:a,subOptions:n,triggerOptions:{className:p,preFix:u,endFix:h,type:f,...g}={},subContentOptions:{className:y="",...b}={}})=>{let{className:v,children:k}=m({children:e,className:p,type:f,preFix:u,endFix:h});return(0,r.jsxs)(o.Pb,{...n,children:[(0,r.jsxs)(o.ZP,{className:v,...g,children:[k,(0,r.jsx)(c,{position:"end",children:(0,r.jsx)(d.ArrowRightSmallIcon,{})})]}),(0,r.jsx)(o.ZL,{...a,children:(0,r.jsx)(o.G5,{sideOffset:10,className:(0,l.useMemo)(()=>(0,i.A)(s,y),[y]),...b,children:t})})]})};var f=a(50822);let g=(0,l.forwardRef)(({disabled:e,noBorder:t=!1,className:a,status:o="default",size:s="default",preFix:n,endFix:l,block:m=!1,children:p,width:u,style:h={},...g},y)=>(0,r.jsxs)("button",{ref:y,style:{...(0,f.D)({"var(--njwon20)":u?"number"==typeof u?`${u}px`:u:"auto"}),...h},className:(0,i.A)("njwon26",a,{block:m,disabled:e,"no-border":t,error:"error"===o,success:"success"===o,warning:"warning"===o,default:"default"===o,large:"large"===s,"extra-large":"extraLarge"===s}),...g,children:[n,p,l,(0,r.jsx)(c,{position:"end",children:(0,r.jsx)(d.ArrowDownSmallIcon,{})})]}));g.displayName="MenuTrigger"},34310:(e,t,a)=>{"use strict";a.d(t,{uo:()=>g,V:()=>b,aF:()=>f,of:()=>S,fl:()=>v});var r=a(36870),o=a(53978),i=a(37064),s=a(86326),n=a(55683),l=a(45483),c=a(59248),d=a(50822);let m=(e="",t="")=>e?"number"==typeof e?`${e}px`:e:t;class p extends HTMLElement{removeChild(e){return"function"==typeof document.startViewTransition?(this.pendingTransitionNodes.push(e),this.requestTransition(),e):super.removeChild(e)}requestTransition(){this.animationFrame&&cancelAnimationFrame(this.animationFrame),this.animationFrame=requestAnimationFrame(()=>{if("function"==typeof document.startViewTransition){let e=this.pendingTransitionNodes;document.startViewTransition(()=>{e.forEach(e=>{super.removeChild(e)})}),this.pendingTransitionNodes=[]}})}constructor(...e){super(...e),this.pendingTransitionNodes=[],this.animationFrame=null}}let u=!1,h=(0,s.forwardRef)((e,t)=>{let{modal:a,portalOptions:h,open:f,onOpenChange:g,width:y,height:b,minHeight:v=194,title:k,description:w,withoutCloseButton:x=!1,persistent:C,contentOptions:{style:S,className:F,onPointerDownOutside:A,onEscapeKeyDown:E,...N}={},overlayOptions:{className:_,style:I,...j}={},closeButtonOptions:D,children:M,...T}=e,{className:P,...L}=D||{},[$,W]=(0,s.useState)(null);(0,s.useEffect)(()=>{let e=function(){u||(customElements.define("modal-transition-container",p),u=!0);let e=new p;return document.body.append(e),e}();return W(e),()=>{setTimeout(()=>{e.remove()},1e3)}},[]);let z=(0,s.useCallback)(e=>{A?.(e),C&&e.preventDefault()},[A,C]),O=(0,s.useCallback)(e=>{E?.(e),C&&e.preventDefault()},[E,C]);if($)return(0,r.jsx)(o.bL,{modal:a,open:f,onOpenChange:g,...T,children:(0,r.jsxs)(o.ZL,{container:$,...h,children:[(0,r.jsx)(o.hJ,{className:(0,i.A)("_1ukx6mx6",_),style:{...I},...j}),(0,r.jsx)("div",{"data-modal":a,className:(0,i.A)("_1ukx6mx8"),children:(0,r.jsxs)(o.UC,{onPointerDownOutside:z,onEscapeKeyDown:O,className:(0,i.A)("_1ukx6mx9",F),style:{...(0,d.D)({"var(--_1ukx6mx0)":m(y,"50vw"),"var(--_1ukx6mx1)":m(b,"unset"),"var(--_1ukx6mx2)":m(v,"26px")}),...S},...w?{}:{"aria-describedby":void 0},...N,ref:t,children:[x?null:(0,r.jsx)(o.bm,{asChild:!0,children:(0,r.jsx)(n.K0,{size:"20",className:(0,i.A)("_1ukx6mxa",P),"aria-label":"Close","data-testid":"modal-close-button",...L,children:(0,r.jsx)(l.CloseIcon,{})})}),k?(0,r.jsx)(o.hE,{className:"_1ukx6mxb",children:k}):(0,r.jsx)(c.b,{asChild:!0,children:(0,r.jsx)(o.hE,{})}),w?(0,r.jsx)(o.VY,{className:"_1ukx6mxc",children:w}):null,M]})})]})})});h.displayName="ModalInner";let f=(0,s.forwardRef)((e,t)=>{if(e.open)return(0,r.jsx)(h,{...e,ref:t})});f.displayName="Modal";let g=({children:e,confirmButtonOptions:t,confirmText:a="Confirm",cancelText:l="Cancel",cancelButtonOptions:c,reverseFooter:d,onConfirm:m,onCancel:p,width:u=480,autoFocusConfirm:h=!0,...g})=>{let y=(0,s.useCallback)(()=>{Promise.resolve(m?.()).catch(e=>{console.error(e)})},[m]);return(0,r.jsxs)(f,{contentOptions:{className:"_1ukx6mxf",onPointerDownOutside:e=>{e.stopPropagation(),p?.()}},width:u,closeButtonOptions:{onClick:p},...g,children:[e?(0,r.jsx)("div",{className:"_1ukx6mxe",children:e}):null,(0,r.jsxs)("div",{className:(0,i.A)("_1ukx6mxd",{modalFooterWithChildren:!!e,reverse:d}),children:[(0,r.jsx)(o.zM,{asChild:!0,children:(0,r.jsx)(n.$n,{onClick:p,"data-testid":"confirm-modal-cancel",...c,children:l})}),(0,r.jsx)(n.$n,{onClick:y,"data-testid":"confirm-modal-confirm",autoFocus:h,...t,children:a})]})]})},y=(0,s.createContext)({modalProps:{open:!1},openConfirmModal:()=>{},closeConfirmModal:()=>{}}),b=({children:e})=>{let[t,a]=(0,s.useState)({open:!1}),o=(0,s.useCallback)(e=>{a(t=>({...t,confirmButtonOptions:{...t.confirmButtonOptions,loading:e}}))},[]),i=(0,s.useCallback)(()=>{a({open:!1})},[]),n=(0,s.useCallback)((e,t)=>{let{autoClose:r=!0,onSuccess:s}=t??{};if(!e){a({open:!0});return}let{onConfirm:n,...l}=e;a({...l,onConfirm:()=>(o(!0),Promise.resolve(n?.()).then(()=>s?.()).catch(console.error).finally(()=>o(!1)).finally(()=>r&&i())),open:!0})},[i,o]),l=(0,s.useCallback)(e=>{t.onOpenChange?.(e),a(t=>({...t,open:e}))},[t]);return(0,r.jsxs)(y.Provider,{value:{openConfirmModal:n,closeConfirmModal:i,modalProps:t},children:[e,(0,r.jsx)(g,{...t,onOpenChange:l})]})},v=()=>{let e=(0,s.useContext)(y);if(!e)throw Error("useConfirmModal must be used within a ConfirmModalProvider");return{openConfirmModal:e.openConfirmModal,closeConfirmModal:e.closeConfirmModal}};var k=a(99971),w=a(4194);let x={style:{padding:0,overflow:"hidden",boxShadow:(0,k.Vg)("menuShadow")}},C={style:{background:(0,k.Vg)("white80"),backdropFilter:"blur(2px)"}},S=(0,s.memo)(function({open:e,topImage:t,onOpenChange:a,title:i,description:l,onConfirm:c,to:d,external:m,confirmButtonOptions:p,cancelButtonOptions:u,withoutCancelButton:h,contentOptions:g=x,overlayOptions:y=C,cancelText:b="Cancel",confirmText:v="Confirm",width:k=400}){let S=(0,s.useCallback)(()=>{a?.(!1),c?.()},[a,c]);return(0,r.jsxs)(f,{contentOptions:g,overlayOptions:y,open:e,width:k,onOpenChange:a,withoutCloseButton:!0,children:[t,(0,r.jsx)("div",{className:"_1300qvw0",children:i}),(0,r.jsx)("div",{className:"_1300qvw1",children:l}),(0,r.jsxs)("div",{className:"_1300qvw2",children:[h?null:(0,r.jsx)(o.zM,{asChild:!0,children:(0,r.jsx)(n.$n,{...u,children:b})}),d?m?(0,r.jsx)("a",{href:d,target:"_blank",rel:"noreferrer",children:(0,r.jsx)(n.$n,{onClick:S,...p,children:v})}):(0,r.jsx)(w.N_,{to:d,children:(0,r.jsx)(n.$n,{onClick:S,...p,children:v})}):(0,r.jsx)(n.$n,{onClick:S,...p,children:v})]})]})})},67156:(e,t,a)=>{"use strict";a.d(t,{b:()=>v,m:()=>k});var r=a(36870),o=a(45483),i=a(50822),s=a(86326),n=a(3957),l=a(37064),c=a(55683),d="_1jxbkdg9",m=a(99971);let p=(e,t)=>"information"===e?({error:(0,m.Vg)("backgroundErrorColor"),info:(0,m.Vg)("backgroundProcessingColor"),success:(0,m.Vg)("backgroundSuccessColor"),warning:(0,m.Vg)("backgroundWarningColor")})[t]:"alert"===e?({error:(0,m.Vg)("errorColor"),info:(0,m.Vg)("processingColor"),success:(0,m.Vg)("successColor"),warning:(0,m.Vg)("warningColor")})[t]:(0,m.Vg)("white"),u=(e,t)=>"information"===e?({error:(0,m.Vg)("errorColor"),info:(0,m.Vg)("processingColor"),success:(0,m.Vg)("successColor"),warning:(0,m.Vg)("warningColor")})[t]:f(e),h=e=>"normal"===e?(0,m.Vg)("borderColor"):(0,m.Vg)("black10"),f=e=>"alert"===e?(0,m.Vg)("pureWhite"):(0,m.Vg)("textPrimaryColor"),g=(e,t,a)=>{if("alert"!==e){let e={error:(0,m.Vg)("errorColor"),info:(0,m.Vg)("processingColor"),success:(0,m.Vg)("successColor"),warning:(0,m.Vg)("warningColor")};return a||e[t]}return a||(0,m.Vg)("pureWhite")},y=e=>"alert"===e?f(e):(0,m.Vg)("iconColor"),b=({notification:e})=>{let{theme:t="info",style:a="normal",icon:n=(0,r.jsx)(o.InformationFillDuotoneIcon,{}),iconColor:m,thumb:b,action:v,title:k,footer:w,alignMessage:x="title",onDismiss:C,rootAttrs:S}=e,F=(0,s.useCallback)(()=>{v?.onClick()?.catch(console.error),v?.autoClose!==!1&&C?.()},[v,C]);return(0,r.jsxs)("div",{style:(0,i.D)({"var(--_1jxbkdg0)":p(a,t),"var(--_1jxbkdg2)":h(a),"var(--_1jxbkdg1)":f(a),"var(--_1jxbkdg3)":u(a,t),"var(--_1jxbkdg4)":g(a,t,m),"var(--_1jxbkdg5)":y(a)}),"data-with-icon":n?"":void 0,...S,className:(0,l.A)("_1jxbkdg6",S?.className),children:[b,(0,r.jsxs)("div",{className:"_1jxbkdg7",children:[(0,r.jsxs)("header",{className:"_1jxbkdg8",children:[n?(0,r.jsx)("div",{className:(0,l.A)("_1jxbkdga",d),children:n}):null,(0,r.jsx)("div",{className:"_1jxbkdgb",children:k}),v?(0,r.jsx)("div",{className:(0,l.A)(d,"_1jxbkdgc"),children:(0,r.jsx)(c.$n,{className:"_1jxbkdgd",onClick:F,...v.buttonProps,children:v.label})}):null,(0,r.jsx)("div",{"data-float":!!b,className:(0,l.A)(d,"_1jxbkdge"),children:(0,r.jsx)(c.K0,{"data-testid":"notification-close-button",onClick:C,children:(0,r.jsx)(o.CloseIcon,{className:"_1jxbkdgf",width:16,height:16})})})]}),(0,r.jsx)("main",{"data-align":x,className:"_1jxbkdgg",children:e.message}),(0,r.jsx)("footer",{children:w})]})]})};function v({width:e=380}){let t=(0,s.useMemo)(()=>({...(0,i.D)({"--width":`${e}px`}),pointerEvents:"auto"}),[e]),a=(0,s.useMemo)(()=>({style:{width:"100%"}}),[]);return(0,r.jsx)(n.l$,{className:"affine-notification-center",style:t,toastOptions:a})}function k(e,t){return n.oR.custom(t=>(0,r.jsx)(b,{notification:{...e,onDismiss:()=>{e.onDismiss?.(),n.oR.dismiss(t)}}}),t)}k.error=(e,t)=>k({icon:(0,r.jsx)(o.InformationFillDuotoneIcon,{}),style:"normal",theme:"error",...e},t),k.success=(e,t)=>k({icon:(0,r.jsx)(o.SingleSelectSelectSolidIcon,{}),style:"normal",theme:"success",...e},t),k.warning=(e,t)=>k({icon:(0,r.jsx)(o.InformationFillDuotoneIcon,{}),style:"normal",theme:"warning",...e},t),k.custom=(e,t)=>n.oR.custom(t=>(0,r.jsx)(e,{onDismiss:()=>n.oR.dismiss(t)}),t),k.dismiss=n.oR.dismiss},21633:(e,t,a)=>{"use strict";a.d(t,{z:()=>c});var r=a(36870),o=a(84837),i=a(50822),s=a(37064),n=a(86326),l=a(24766);let c=(0,n.memo)(function({items:e,value:t,width:a,style:c,padding:d=2,gap:m=4,borderRadius:p=10,itemHeight:u=28,animationDuration:h=250,animationEasing:f="cubic-bezier(.18,.22,0,1)",activeItemClassName:g,activeItemStyle:y,iconMode:b,onChange:v}){let k=(0,n.useRef)(null),w=(0,n.useMemo)(()=>e.map(e=>"string"==typeof e?{value:e}:e).map(e=>({...e,ref:(0,n.createRef)(),indicatorRef:(0,n.createRef)()})),[e]),x=(0,n.useMemo)(()=>({width:a,...c,...(0,i.D)({"var(--d0pnwl0)":(0,l.$)(d,"px"),"var(--d0pnwl1)":(0,l.$)(p,"px"),"var(--d0pnwl2)":(0,l.$)(m,"px"),"var(--d0pnwl3)":(0,l.$)(u,"px")})}),[a,c,d,p,m,u]),C=(0,n.useCallback)((e,t)=>{if(!e||!t)return;let a=w.find(t=>t.value===e),r=w.find(e=>e.value===t);if(!a||!r)return;let o=a.ref.current?.getBoundingClientRect(),i=r.ref.current?.getBoundingClientRect();if(!o||!i)return;let s=r.indicatorRef.current;if(!s)return;s.style.transform=`translate3d(${o.left-i.left}px,0,0)`,s.style.transition="none",s.style.width=`${o.width}px`;let n=`${(0,l.$)(h,"ms")} ${f}`;k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{k.current=null,s.style.transition=`transform ${n}, width ${n}`,s.style.transform="none",s.style.width=""},50)},[h,f,w]),S=(0,n.useRef)(t);return(0,n.useEffect)(()=>{let e=S.current;t!==e&&(C(e,t),S.current=t)},[C,t]),(0,r.jsx)(o.bL,{value:t,onValueChange:v,className:"d0pnwl6",style:x,"data-icon-mode":b,children:w.map(({customRender:e,...a},i)=>{let n=a.testId?{"data-testid":a.testId}:{},l=a.value===t,c={d0pnwl4:!0};g&&(c[g]=l),a.className&&(c[a.className]=!0);let d={...a.style};return y&&l&&Object.assign(d,y),(0,r.jsxs)(o.q7,{ref:a.ref,value:a.value,className:(0,s.A)(c),style:d,...n,...a.attrs,children:[(0,r.jsx)(o.C1,{forceMount:!0,className:"d0pnwl7",ref:a.indicatorRef}),(0,r.jsx)("span",{className:"d0pnwl5",children:e?.(a,i)??a.label??a.value})]},a.value)})})})},66889:(e,t,a)=>{"use strict";a.d(t,{yE:()=>h,Np:()=>y,IF:()=>g});var r=a(36870),o=a(59142),i=a(37064),s=a(86326),n="_1wjuzxw0",l="_1wjuzxw2",c="_1wjuzxw4",d="_1wjuzxw6";let m=(0,s.forwardRef)(({children:e,className:t,...a},s)=>(0,r.jsx)(o.bL,{...a,ref:s,className:(0,i.A)(t,n),children:e}));m.displayName="ScrollableRoot";let p=(0,s.forwardRef)(({children:e,className:t,...a},s)=>(0,r.jsx)(o.LM,{...a,ref:s,className:(0,i.A)(t,l),children:e}));p.displayName="ScrollableViewport";let u=(0,s.forwardRef)(({children:e,className:t,...a},s)=>(0,r.jsxs)(o.Ze,{orientation:"vertical",...a,ref:s,className:(0,i.A)(t,c),children:[(0,r.jsx)(o.zi,{className:d}),e]}));u.displayName="ScrollableScrollbar";let h={Root:m,Viewport:p,Scrollbar:u};var f=a(55161);function g(){let[e,t]=(0,s.useState)(!1);return[(0,s.useMemo)(()=>{let e=null;return a=>{e?.();let r=(0,f.A)(()=>{a&&setTimeout(()=>{t(a.scrollTop>0)})},50);a?.addEventListener("scroll",r),r(),e=()=>{a?.removeEventListener("scroll",r)}}},[]),e]}let y=({children:e,showScrollTopBorder:t=!1,inTableView:a=!1,className:s,styles:m,viewPortClassName:p,scrollBarClassName:u})=>{let[h,f]=g();return(0,r.jsxs)(o.bL,{style:m,className:(0,i.A)(n,s),children:[(0,r.jsx)("div",{"data-has-scroll-top":f,className:(0,i.A)({_1wjuzxw1:t})}),(0,r.jsx)(o.LM,{className:(0,i.A)([l,p]),ref:h,children:(0,r.jsx)("div",{className:"_1wjuzxw3",children:e})}),(0,r.jsx)(o.Ze,{orientation:"vertical",className:(0,i.A)(c,u,{_1wjuzxw5:a}),children:(0,r.jsx)(o.zi,{className:d})})]})}},59097:(e,t,a)=>{"use strict";a.d(t,{E:()=>l});var r=a(36870),o=a(37064),i={pulse:"_17vik8w7",wave:"_17vik8w8"},s={circular:"_17vik8w3",rectangular:"_17vik8w4",rounded:"_17vik8w5",text:"_17vik8w6"};function n(e){return"number"==typeof e||/^\d+$/.test(e)?`${e}px`:e}let l=({animation:e="pulse",variant:t="text",children:a,width:l,height:c,style:d,className:m,...p})=>{let u={width:void 0!==l?n(l):void 0,height:void 0!==c?n(c):void 0,...d};return(0,r.jsx)("div",{className:(0,o.A)(m,"_17vik8w2",s[t],e&&i[e]),style:u,...p,children:a})}},39958:(e,t,a)=>{"use strict";a.d(t,{m:()=>m});var r=a(36870),o=a(16405),i=a(99971),s=a(99264),n=a(37064);let l="undefined"!=typeof navigator&&-1!==navigator.userAgent.indexOf("Mac"),c=e=>"$mod"===e?l?"⌘":"Ctrl":"$alt"===e?l?"⌥":"Alt":"$shift"===e?l?"⇧":"Shift":e,d=({shortcut:e})=>{let t=(Array.isArray(e)?e:[e]).map(e=>e.trim()).map(e=>c(e));return(0,r.jsx)("div",{className:"_1egqhv93",children:t.map((e,t)=>(0,r.jsx)("div",{className:"_1egqhv94","data-length":e.length,children:e},`${t}-${e}`))})},m=({children:e,content:t,side:a="top",align:l="center",shortcut:c,options:m,rootOptions:p,portalOptions:u})=>{if(!t)return e;let{className:h,...f}=m||{},{style:g,...y}=f;return(0,r.jsx)(o.Kq,{children:(0,r.jsxs)(o.bL,{delayDuration:500,...p,children:[(0,r.jsx)(o.l9,{asChild:!0,children:e}),(0,r.jsx)(o.ZL,{...u,children:(0,r.jsxs)(o.UC,{className:(0,n.A)("_1egqhv90",h),side:a,align:l,sideOffset:5,style:{zIndex:(0,i.Vg)("zIndexPopover"),...g},...y,children:[c?(0,r.jsxs)("div",{className:"_1egqhv91",children:[(0,r.jsx)("div",{className:"_1egqhv92",children:t}),(0,r.jsx)(d,{shortcut:c})]}):t,(0,r.jsx)(o.i3,{asChild:!0,children:(0,r.jsx)("svg",{width:"10",height:"6",viewBox:"0 0 10 6",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)("path",{d:"M4.11111 5.55C4.55556 6.15 5.44445 6.15 5.88889 5.55L10 0H0L4.11111 5.55Z",fill:(0,s.h0)("tooltips/background")})})})]})})]})})}},24766:(e,t,a)=>{"use strict";a.d(t,{$:()=>r});let r=(e,t)=>"number"==typeof e||/^\d+(\.\d+)?$/.test(e)?`${e}${t}`:e},77846:(e,t,a)=>{"use strict";a.d(t,{Eb:()=>h,G4:()=>i,JO:()=>p,Jr:()=>c,SH:()=>n,Tb:()=>s,W7:()=>u,gP:()=>m,hX:()=>d,iZ:()=>f,qj:()=>o,tc:()=>l});var r=a(49791);(0,r.eU)(!1);let o=(0,r.eU)(!1),i=(0,r.eU)(!1),s=(0,r.eU)(!1),n=(0,r.eU)(!1),l=(0,r.eU)(!1),c=(0,r.eU)(!1),d=(0,r.eU)(!1),m=(0,r.eU)(320),p=(0,r.eU)({activeTab:"appearance",open:!1}),u=(0,r.eU)({openModal:!1,state:"signIn",email:"",emailType:"changeEmail"}),h=(0,r.eU)("docs"),f=(0,r.eU)(!1)},22943:(e,t,a)=>{"use strict";let r,o,i,s,n,l,c,d,m,p,u,h,f,g,y,b,v,k,w,x,C,S,F,A;a.d(t,{M6:()=>lX,pB:()=>nV,A0:()=>nH,y$:()=>nq,JZ:()=>nG,uj:()=>i0});var E,N,_,I,j,D,M,T,P,L,$,W,z,O,B,R,U,q,V,G,H,Z,K,Y,J,Q,X,ee,et,ea,er,eo,ei,es,en,el,ec,ed,em,ep,eu,eh,ef,eg,ey,eb,ev,ek,ew,ex,eC,eS,eF,eA,eE,eN,e_,eI,ej,eD,eM,eT,eP,eL,e$,eW,ez,eO,eB,eR,eU,eq,eV,eG,eH,eZ,eK,eY,eJ,eQ,eX,e0,e1,e2,e3,e4,e6,e5,e7,e8,e9,te,tt,ta,tr,to,ti,ts,tn,tl,tc,td,tm,tp,tu,th,tf,tg,ty,tb,tv,tk,tw,tx,tC,tS,tF,tA,tE,tN,t_,tI,tj,tD,tM,tT,tP,tL,t$,tW,tz,tO,tB,tR,tU,tq,tV,tG,tH,tZ,tK,tY,tJ,tQ,tX,t0,t1,t2,t3,t4,t6,t5,t7,t8,t9,ae,at,aa,ar,ao,ai,as,an,al,ac,ad,am,ap,au,ah,af,ag,ay,ab,av,ak,aw,ax,aC,aS,aF,aA,aE,aN,a_,aI,aj,aD,aM,aT,aP,aL,a$,aW,az,aO,aB,aR,aU,aq,aV,aG,aH,aZ,aK,aY,aJ,aQ,aX,a0,a1,a2,a3,a4,a6,a5,a7,a8,a9,re,rt,ra,rr,ro,ri,rs,rn,rl,rc,rd,rm,rp,ru,rh,rf,rg,ry,rb,rv,rk,rw,rx,rC,rS,rF,rA,rE,rN,r_,rI,rj,rD,rM,rT,rP,rL,r$,rW,rz,rO,rB,rR,rU,rq,rV,rG,rH,rZ,rK,rY,rJ,rQ,rX,r0,r1,r2,r3,r4,r6,r5,r7,r8,r9,oe,ot,oa,or,oo,oi,os,on,ol,oc,od,om,op,ou,oh,of,og,oy,ob,ov,ok,ow,ox,oC,oS,oF,oA=a(71006),oE=a(21167),oN=a(94098);a(14801);var o_=a(91449);(0,o_.qy)` `;let oI=(0,o_.qy)``,oj=(0,o_.qy)` `,oD=(0,o_.qy)` `,oM=e=>(0,o_.qy)` `,oT=(0,o_.qy)` `,oP=(0,o_.qy)` `,oL=(0,o_.qy)` `,o$=(0,o_.qy)` `,oW=(0,o_.qy)` `,oz=(0,o_.qy)` `,oO=(0,o_.qy)` `,oB=(0,o_.qy)` `,oR=(0,o_.qy)` `,oU=(0,o_.qy)` `,oq=(0,o_.qy)` `,oV=(0,o_.qy)` `;(0,o_.qy)` `;let oG=(0,o_.qy)` `,oH=(0,o_.qy)` `,oZ=(0,o_.qy)` `,oK=(0,o_.qy)` `,oY=(0,o_.qy)` `,oJ=(0,o_.qy)` `,oQ=(0,o_.qy)` `,oX=(0,o_.qy)` `,o0=(0,o_.qy)` `,o1=(0,o_.qy)` `,o2=(0,o_.qy)` `,o3=(0,o_.qy)` `,o4=(0,o_.qy)` `,o6=(0,o_.qy)` `,o5=(0,o_.qy)` `,o7=(0,o_.qy)` `,o8=(0,o_.qy)` `,o9=(0,o_.qy)` `,ie=(0,o_.qy)` `,it=(0,o_.qy)` `,ia=(0,o_.qy)``,ir=(0,o_.qy)` `,io=(0,o_.qy)``,ii=(0,o_.qy)` `,is=(0,o_.qy)``,il=(0,o_.qy)` `,ic=(0,o_.qy)` `,id=(0,o_.qy)` `,im=(0,o_.qy)``,ip=(0,o_.qy)` `,iu=(0,o_.qy)` `,ih=(0,o_.qy)``,ig=(0,o_.qy)` `,iy=(0,o_.qy)` `,ib=(0,o_.qy)` `,iv=(0,o_.qy)` `,ik=(0,o_.qy)` `,iw=(0,o_.qy)` `,ix=(0,o_.qy)` `,iC=(0,o_.qy)` `,iS=(0,o_.qy)` `,iF=(0,o_.qy)` `,iA=(0,o_.qy)` `,iE=(0,o_.qy)` `,iN=(0,o_.qy)` `,i_=(0,o_.qy)` `,iI=["brainstormMindmap","expandMindmap","makeItReal","createSlides","createImage","findActions","filterImage","processImage"],ij=["generateCaption"],iD=["createImage","processImage","filterImage"],iM=["Generating image","Rendering image"],iT={makeItReal:["Coding for you","Rendering the code"],brainstormMindmap:["Thinking about this topic","Rendering mindmap"],createSlides:["Thinking about this topic","Rendering slides"],createImage:iM,processImage:iM,filterImage:iM},iP=["createHeadings"];var iL=a(7595),i$=a(73711),iW=a(4564),iz=a(83951),iO=a(71323),iB=a(3874);class iR extends oE.rFg{loadFonts(){}}let iU=oE.kbk.map(e=>"affine:page"===e.schema.model.flavour?{...e,service:iR,view:{component:(0,iB.eu)`affine-page-root`}}:e),iq=(e,t,a)=>{let{index:r,length:o}=e;t.props.text&&0!==o&&(t.props.text.delta=a.text?.sliceToDelta(r,o+r))};async function iV(e,t,a="markdown"){let r=new i$._O({collection:e.std.doc.collection,middlewares:[oE.tO3,(0,oE.afe)("content")]}),o=await r.sliceToSnapshot(t);if(!o)return"";!function(e,t){let{content:a}=e,r=t.selection.find("text");a.length&&r&&a.forEach(e=>(function e(t,a,r){let o=r.doc.getBlockById(t.id);(0,oA.Z1)(o);let i=o.id;a.from.blockId===i&&iq(a.from,t,o),a.to&&a.to.blockId===i&&iq(a.to,t,o),t.children.forEach(t=>e(t,a,r))})(e,r,t))}(o,e);let i="markdown"===a?new oE.FNZ(r):new oE.JBs(r);return(await i.fromSliceSnapshot({snapshot:o,assets:r.assetsManager})).file}let iG=async(e,t)=>{let a=new i$._O({collection:t.std.doc.collection,middlewares:[oE.HzZ,(0,oE.O40)(t.std)]}),r=new oE.xAB(a),{blockVersions:o,workspaceVersion:i,pageVersion:s}=t.std.doc.collection.meta;if(!o||!i||!s)throw Error("Need blockVersions, workspaceVersion, pageVersion meta information to get slice");let n={file:e,assets:a.assetsManager,blockVersions:o,pageVersion:s,workspaceVersion:i,workspaceId:t.std.doc.collection.id,pageId:t.std.doc.id},l=await r.toSliceSnapshot(n);return(0,oA.Z1)(l,"import markdown failed, expected to get a snapshot"),{snapshot:l,job:a}};async function iH(e,t,a,r,o){let{snapshot:i,job:s}=await iG(t,e),n=i.content.flatMap(e=>e.children),l=[];for(let e=0;e3,b=f>=5;if(b?(p=e,f-=5,u=m=m||[]):(p=e.prototype,u=d=d||[]),0!==f&&!y){var v=b?l:n,k=v.get(g)||0;if(!0===k||3===k&&4!==f||4===k&&3!==f)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+g);!k&&f>2?v.set(g,f):v.set(g,!0)}!function(e,a,o,i,s,n,l,c,d){var m,p,u,h,f,g,y=o[0];if(l?m=0===s||1===s?{get:o[3],set:o[4]}:3===s?{get:o[3]}:4===s?{set:o[3]}:{value:o[3]}:0!==s&&(m=Object.getOwnPropertyDescriptor(a,i)),1===s?u={get:m.get,set:m.set}:2===s?u=m.value:3===s?u=m.get:4===s&&(u=m.set),"function"==typeof y)void 0!==(h=t(y,i,m,c,s,n,l,d,u))&&(r(s,h),0===s?p=h:1===s?(p=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h);else for(var b=y.length-1;b>=0;b--)void 0!==(h=t(y[b],i,m,c,s,n,l,d,u))&&(r(s,h),0===s?g=h:1===s?(g=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h,void 0!==g&&(void 0===p?p=g:"function"==typeof p?p=[p,g]:p.push(g)));if(0===s||1===s){if(void 0===p)p=function(e,t){return t};else if("function"!=typeof p){var v=p;p=function(e,t){for(var a=t,r=0;r0){for(var s=[],n=t,l=t.name,c=a.length-1;c>=0;c--){var d={v:!1};try{var m=a[c](n,{kind:"class",name:l,addInitializer:e(s,d),metadata:o})}finally{d.v=!0}void 0!==m&&(r(10,m),n=m)}return[i(n,o),function(){for(var e=0;e .affine-block-children-container { > :first-child, > :first-child * { margin-top: 0 !important; } > :last-child, > :last-child * { margin-bottom: 0 !important; } } } } .ai-answer-text-container { overflow-y: auto; overflow-x: hidden; padding: 0; overscroll-behavior-y: none; } .ai-answer-text-container.show-scrollbar::-webkit-scrollbar { width: 5px; height: 100px; } .ai-answer-text-container.show-scrollbar::-webkit-scrollbar-thumb { border-radius: 20px; } .ai-answer-text-container.show-scrollbar:hover::-webkit-scrollbar-thumb { background-color: var(--affine-black-30); } .ai-answer-text-container.show-scrollbar::-webkit-scrollbar-corner { display: none; } .ai-answer-text-container { rich-text .nowrap-lines v-text span, rich-text .nowrap-lines v-element span { white-space: pre; } editor-host:focus-visible { outline: none; } editor-host * { box-sizing: border-box; } editor-host { isolation: isolate; } } ${iJ} ${iQ} `}#e;get _container(){return this.#e}set _container(e){this.#e=e}#t;get host(){return this.#t}set host(e){this.#t=e}#a;get answer(){return this.#a}set answer(e){this.#a=e}#r;get options(){return this.#r}set options(e){this.#r=e}#o;get state(){return this.#o}set state(e){this.#o=e}_onWheel(e){e.stopPropagation(),"generating"===this.state&&e.preventDefault()}shouldUpdate(e){return!e.has("answer")||(this._answers.push(this.answer),!1)}connectedCallback(){super.connectedCallback(),this._answers.push(this.answer),this._updateDoc(),"generating"===this.state&&(this._timer=setInterval(this._updateDoc,600))}disconnectedCallback(){super.disconnectedCallback(),this._clearTimer()}updated(e){super.updated(e),requestAnimationFrame(()=>{this._container&&(this._container.scrollTop=this._container.scrollHeight)})}render(){let{maxHeight:e,customHeading:t}=this.options,a=(0,iz.H)({"ai-answer-text-container":!0,"show-scrollbar":!!e,"custom-heading":!!t});return(0,o_.qy)`
${(0,iO.D)(this._doc,(0,o_.qy)`
${this.host.renderSpecPortal(this._doc,iU)}
`)}
`}constructor(...e){super(...e),this.#e=(O(this),P(this)),this._answers=[],this._timer=null,this.#t=L(this),this.#a=$(this),this.#r=W(this),this.#o=z(this,void 0),this._clearTimer=()=>{this._timer&&(clearInterval(this._timer),this._timer=null)},this._query={mode:"strict",match:["affine:page","affine:note","affine:surface","affine:paragraph","affine:code","affine:list","affine:divider"].map(e=>({flavour:e,viewType:i$.lv.Display}))},this._updateDoc=()=>{if(this._answers.length>0){let e=this._answers.pop();this._answers=[],e&&iZ(this.host,e).then(e=>{this._doc=e.blockCollection.getDoc({query:this._query}),this.disposables.add(()=>{e.blockCollection.clearQuery(this._query)}),this._doc.awarenessStore.setReadonly(this._doc.blockCollection,!0),this.requestUpdate(),"generating"!==this.state&&this._clearTimer()}).catch(console.error)}}}}}};let iX=(e,t)=>(a,r)=>(0,o_.qy)``;class i0{static get slots(){return i0.instance.slots}static get actions(){return i0.instance.actions}static get userInfo(){return i0.instance.userInfoFn()}static get photoEngine(){return i0.instance.photoEngine}static get histories(){return i0.instance.histories}static get actionHistory(){return i0.instance.actionHistory}static get toggleGeneralAIOnboarding(){return i0.instance.toggleGeneralAIOnboarding}static get forkChat(){return i0.instance.forkChat}static{this.instance=new i0}static{this.LAST_ACTION_SESSIONID=""}static{this.LAST_ROOT_SESSION_ID=""}static{this.MAX_LOCAL_HISTORY=10}provideAction(e,t){this.actions[e]&&console.warn(`AI action ${e} is already provided`),this.actions[e]=(...a)=>{let r=a[0],o=this.slots;o.actions.emit({action:e,options:r,event:"started"}),this.actionHistory.push({action:e,options:r}),this.actionHistory.length>i0.MAX_LOCAL_HISTORY&&this.actionHistory.shift();let i=t(...a);return Reflect.has(i,Symbol.asyncIterator)?{[Symbol.asyncIterator]:async function*(){try{yield*i,o.actions.emit({action:e,options:r,event:"finished"})}catch(t){throw o.actions.emit({action:e,options:r,event:"error"}),t instanceof oE.yPR?o.actions.emit({action:e,options:r,event:"aborted:paywall"}):t instanceof oE.D_h?o.actions.emit({action:e,options:r,event:"aborted:login-required"}):o.actions.emit({action:e,options:r,event:"aborted:server-error"}),t}}}:i.then(t=>(o.actions.emit({action:e,options:r,event:"finished"}),t)).catch(t=>{throw o.actions.emit({action:e,options:r,event:"error"}),t instanceof oE.yPR&&o.actions.emit({action:e,options:r,event:"aborted:paywall"}),t})}}static provide(e,t){"userInfo"===e?i0.instance.userInfoFn=t:"histories"===e?i0.instance.histories=t:"photoEngine"===e?i0.instance.photoEngine=t:"onboarding"===e?i0.instance.toggleGeneralAIOnboarding=t:"forkChat"===e?i0.instance.forkChat=t:i0.instance.provideAction(e,t)}constructor(){this.actions={},this.photoEngine=null,this.histories=null,this.toggleGeneralAIOnboarding=null,this.forkChat=null,this.slots={requestOpenWithChat:new i$.DX,requestInsertTemplate:new i$.DX,requestLogin:new i$.DX,requestUpgradePlan:new i$.DX,requestRunInEdgeless:new i$.DX,actions:new i$.DX,userInfo:new i$.DX,toggleChatCards:new i$.DX},this.actionHistory=[],this.userInfoFn=()=>null}}function i1(e){let t=i0.actionHistory.at(-1);t&&i0.slots.actions.emit({action:t.action,options:t.options,event:e})}function i2(e){let t=e?.group;return t instanceof oE.ARu&&t.tree.element===e}function i3(e){return e?.group instanceof oE.ARu&&!i2(e)}function i4(e){return e.spec.getService("affine:page")}function i6(e){let t=e.doc.root?.id;return e.view.getWidget(oE.VCv,t)}let i5=e=>{let t=e;for(;"affine:note"!==t.flavour;)t=t.parentBlock;return t.model.id},i7=(e,t,a)=>{let r=a.map(e=>e.id).map(t=>e.selection.create("block",{blockId:t}));if((0,oE.Arh)(e)){let a=i5(t),o=e.selection.create("surface",r[0].blockId,[a],!0);r.push(o),e.selection.set(r)}else e.selection.setGroup("note",r)},i8=async(e,t,a,r=!0)=>{let o=a.parentBlock,i=o.model.children.findIndex(e=>e.id===a.model.id),{doc:s}=e,n=await iH(e,t,s,o.model.id,r?i+1:i);await e.updateComplete,requestAnimationFrame(()=>i7(e,o,n))},i9=async(e,t,a)=>{await i8(e,t,a,!0)},se=async(e,t,a)=>{await i8(e,t,a,!1)},st=async(e,t,a,r,o)=>{let i=a.parentBlock,s=i.model.children.findIndex(e=>e.id===a.model.id);if(o){let{snapshot:a,job:r}=await iG(t,e);await r.snapshotToSlice(a,e.doc,i.model.id,s+1)}else{r.forEach(t=>{e.doc.deleteBlock(t)});let{doc:a}=e,o=await iH(e,t,a,i.model.id,s);await e.updateComplete,requestAnimationFrame(()=>i7(e,i,o))}},sa=async e=>{let t=e.host;return!!e.answer&&sr(t,e.answer)},sr=async(e,t)=>{let a=await iZ(e,t),r=a.getBlocksByFlavour("affine:note").map(e=>e.model).flatMap(e=>e.children),o=i$.Ji.fromModels(a,r);return await e.std.clipboard.copySlice(o),!0},so=e=>e.std.spec.getService("affine:page");function si(e){let t=e.getElementsByTagName("affine-edgeless-root")[0];if(!t)throw alert("Please switch to edgeless mode"),Error("Please open switch to edgeless mode");return t}function ss(e){let t=e.std.spec.getService("affine:page");if(t instanceof oE.U1$)return t;throw alert("Please switch to edgeless mode"),Error("Please open switch to edgeless mode")}async function sn(e){let t=si(e),{notes:a,frames:r,shapes:o,images:i}=oE.yYJ.splitElements(t.service.selection.selectedElements);if(a.length+r.length+i.length+o.length===0)return;let s=await t.clipboardController.toCanvas([...a,...r,...i],o);if(s)return s}function sl(e){let[t,a]=e.std.command.chain().getSelectedModels({types:["block","text"]}).run(),{selectedModels:r}=a;return r}async function sc(e,t,a="markdown"){let r=t.filter(e=>!oE.yYJ.matchFlavours(e,["affine:image","affine:database"])).map(i$.uS);r.forEach(e=>(function e(t,a){let r="affine:database"===t.flavour?t.children:t.children.filter(e=>a.findIndex(t=>t.id===e.id)>=0);r.forEach(t=>{let r=a.findIndex(e=>e.id===t.id);r>=0&&a.splice(r,1),e(t,a)}),t.children=r})(e,r));let o=i$.Ji.fromModels(e.std.doc,r);return iV(e,o,a)}async function sd(e,t="markdown"){let a=sl(e);return(0,oA.Z1)(a),sc(e,a,t)}async function sm(e,t=10){let a=sl(e);(0,oA.Z1)(a);let r=a[a.length-1],o=r,i=null;for(;o&&"affine:note"!==o.flavour;)i=o,o=e.doc.getParent(o);(0,oA.Z1)(o),(0,oA.Z1)(i);let s=o.children.indexOf(i)+1,n=Math.max(0,s-t),l=o.children[n];a=[];let c=!1,d=e=>{if(!c){if(a.push(e),e===r){c=!0;return}e.children.forEach(e=>d(e))}};o.children.slice(n,s).forEach(d);let{selection:m}=e;return m.set([m.create("text",{from:{blockId:l.id,index:0,length:l.text?.length??0},to:{blockId:r.id,index:0,length:m.find("text")?.from.index??0}})]),sc(e,a)}let sp=(e,t="flat")=>{let[a,r]=e.command.chain().tryAll(e=>[e.getTextSelection(),e.getBlockSelections(),e.getImageSelections()]).getSelectedBlocks({types:["text","block","image"],mode:t}).run();return r},su=async e=>{let[t,a]=e.command.chain().tryAll(e=>[e.getTextSelection(),e.getBlockSelections(),e.getImageSelections()]).getSelectedBlocks({types:["block","image"]}).run();return(await Promise.all(a.selectedBlocks?.map(async t=>{let a=t.model.sourceId;if(!a)return null;let r=await e.doc.blobSync.get(a);return r?new File([r],a):null})??[])).filter(e=>!!e)},sh=(e,t)=>e.querySelector(`[data-portal-block-id="${t}"] .note-background`);function sf(e){let t=i4(e);return i6(e).visible?t.tool.controllers.copilot.selectedElements:t.selection.selectedElements}let sg=async e=>{let t=sf(e);if(1!==t.length)return;let a=t[0];if(!(a instanceof oE.mK9)||!a.sourceId)return;let r=await e.doc.blobSync.get(a.sourceId);if(r)return{attachments:[r]}};function sy(e){let t=e.selection.find("text"),{selectedBlocks:a}=sp(e,t?"flat":"highest");(0,oA.Z1)(a);let r=a.length,o=a[0],i=a[r-1];return{textSelection:t,selectedModels:a.map(e=>e.model),firstBlock:o,lastBlock:i}}function sb(e,t){return{name:"Use as caption",icon:it,showWhen:()=>{let a=sC(e);return"generateCaption"===t&&!!a.answer},handler:()=>{i1("result:use-as-caption");let t=sC(e),a=t.answer;if(!a)return;let{selectedBlocks:r}=sp(e);if(!r||1!==r.length)return;let o=r[0].model;o instanceof oE.mK9&&(e.doc.updateBlock(o,{caption:a}),t.hide())}}}function sv(e){return{name:"Create new note",icon:oG,showWhen:()=>!!sC(e).answer&&(0,oE.Arh)(e),handler:()=>{i1("result:add-note");let{selectedBlocks:t}=sp(e);if(!t||!t.length)return;let a=function(e){let t=e;for(;t;){if((0,oE.op$)(t.model,["affine:note"]))return t.model;if((0,oE.op$)(t.model,["affine:page","affine:surface"]))break;t=t.parentBlock}return null}(t[0]);if(!a)return;let r=oN.z.deserialize(a.xywh),o=new oN.z(r.x-r.w-20,r.y,r.w,72),i=e.doc,s=sC(e),n=i4(e);i.transact(()=>{(0,oA.Z1)(i.root);let t=i.addBlock("affine:note",{xywh:o.serialize(),displayMode:oE.ko3.EdgelessOnly,index:n.generateIndex("affine:note")},i.root.id);(0,oA.Z1)(s.answer),iH(e,s.answer,i,t).then(()=>{n.selection.set({elements:[t],editing:!1});let e=i.getBlock(t)?.model;if(!e||!(0,oE.op$)(e,["affine:note"]))return;let a=[r,oN.z.deserialize(e.xywh)],{zoom:o,centerX:s,centerY:l}=n.getFitToScreenData([20,20,20,20],a);n.viewport.setViewport(o,[s,l])}).catch(e=>{console.error(e)})}),s.hide()}}}async function sk(e){let{host:t}=e,a=sy(t);if(!a||!e.answer)return;let{textSelection:r,firstBlock:o,selectedModels:i}=a;await st(t,e.answer,o,i,r),e.hide()}async function sw(e){let{host:t}=e,a=sy(t);if(!a||!e.answer)return;let{lastBlock:r}=a;await i9(t,e.answer,r),e.hide()}async function sx(e){let{host:t}=e,a=sy(t);if(!a||!e.answer)return;let{firstBlock:r}=a;await se(t,e.answer,r),e.hide()}let sC=e=>{let t=e.doc.root?.id;(0,oA.Z1)(t);let a=e.view.getWidget(oE.v1U,t);if((0,oA.Z1)(a),!(a instanceof oE.wER))throw Error("AI panel not found");return a};function sS(e,{update:t,finish:a,signal:r}){(async()=>{let o="";for await(let i of(r?.addEventListener("abort",()=>{a("aborted"),i1("aborted:stop")}),e)){if(r?.aborted)return;t(o+=i)}a("success")})().catch(e=>{r?.aborted||("AbortError"===e.name?a("aborted"):a("error",e))})}function sF(e,t,a,r){return o=>{let i=sC(o);!function(e,t,a,r,o){var i;let{config:s,host:n}=e;(0,oA.Z1)(s),s.generateAnswer=({signal:e,update:a,finish:i})=>{let{selectedBlocks:s}=sp(n);if(!s||0===s.length)return;let l=(function(e,t,a,r){let o=i0.actions[e];if(o&&"function"==typeof o)return e=>{let i;return{async *[Symbol.asyncIterator](){let s;let{currentTextSelection:n,selectedBlocks:l}=sp(e),c=[];n?.isCollapsed()?s=await sm(e):[s,c]=await Promise.all([sd(e),su(e)]);let d=l?.length===1&&c.length>0,m=l?.map(e=>e.model),p=r?.control??"format-bar",u=r?.where??"ai-panel";(i=o({...a,attachments:d?c:void 0,input:d?"":s,stream:!0,host:e,models:m,signal:t,control:p,where:u,docId:e.doc.id,workspaceId:e.doc.collection.id}))&&(yield*i)}}}})(t,e,r,o)?.(n);l&&sS(l,{update:a,finish:i,signal:e})},s.answerRenderer=iX(n,{maxHeight:320}),s.finishStateConfig={responses:function(e,t){let a=e.host;return[{name:"Response",items:[{name:"Insert below",icon:oq,showWhen:()=>!!e.answer&&(!t||!iP.includes(t)),handler:()=>{i1("result:insert"),sw(e).catch(console.error)}},{name:"Insert above",icon:oV,showWhen:()=>!!e.answer&&!!t&&iP.includes(t),handler:()=>{i1("result:insert"),sx(e).catch(console.error)}},sb(a,t),{name:"Replace selection",icon:oU,showWhen:()=>!!e.answer,handler:()=>{i1("result:replace"),sk(e).catch(console.error)}},sv(a)]},{name:"",items:[{name:"Continue in chat",icon:ip,handler:()=>{i1("result:continue-in-chat"),i0.slots.requestOpenWithChat.emit({host:a}),e.hide()}},{name:"Regenerate",icon:iw,handler:()=>{i1("result:retry"),e.generate()}},{name:"Discard",icon:ib,handler:()=>{e.discard()}}]}]}(e,t),actions:[]},s.generatingStateConfig={generatingIcon:a??oI},s.errorStateConfig={upgrade:()=>{i0.slots.requestUpgradePlan.emit({host:i.host}),i.hide()},login:()=>{i0.slots.requestLogin.emit({host:i.host}),i.hide()},cancel:()=>{i.hide()},responses:function(e,t){let a=e.host;return[{name:"Response",items:[{name:"Replace selection",icon:oU,showWhen:()=>!!e.answer,handler:()=>{sk(e).catch(console.error)}},{name:"Insert below",icon:oq,showWhen:()=>!!e.answer&&(!t||!iP.includes(t)),handler:()=>{sw(e).catch(console.error)}},{name:"Insert above",icon:oV,showWhen:()=>!!e.answer&&!!t&&iP.includes(t),handler:()=>{i1("result:insert"),sx(e).catch(console.error)}},sb(a,t),sv(a)]},{name:"",items:[{name:"Retry",icon:iw,showWhen:()=>!0,handler:()=>{i1("result:retry"),e.generate()}},{name:"Discard",icon:ib,showWhen:()=>!!e.answer,handler:()=>{e.discard()}}]}]}(i=e,void 0)},s.copy={allowed:!0,onCopy:()=>sa(e)},s.discardCallback=()=>{i1("result:discard")}}(i,e,t,a,r);let{selectedBlocks:s}=sp(i.host);if(!s||0===s.length)return;let n=s.at(-1);(0,oA.Z1)(n),i.toggle(n,"placeholder")}}var sA=a(64816),sE=a(52153);(0,sA.lQ)(oE.i6S);let sN=(e,t,a)=>(r,o)=>{if("generating"===o){let t=sC(e);t.generatingElement?.updateLoadingProgress(2)}return"finished"!==o&&"error"!==o?o_.s6:(0,o_.qy)``},s_=(e,t,a)=>(r,o)=>{if("finished"!==o){let t=sC(e);return t.generatingElement?.updateLoadingProgress(2),o_.s6}return t.set({node:(0,oE.fp4)(r,e.doc)}),a(t),o_.s6};var sI=a(77955),sj=a(45601);let sD=async(e,t)=>{let a=new i$._O({collection:t.std.doc.collection}),r=new oE.FNZ(a),{blockVersions:o,workspaceVersion:i,pageVersion:s}=t.std.doc.collection.meta;if(!o||!i||!s)throw Error("Need blockVersions, workspaceVersion, pageVersion meta information to get slice");let n={file:e,assets:a.assetsManager,blockVersions:o,pageVersion:s,workspaceVersion:i,workspaceId:t.std.doc.collection.id,pageId:t.std.doc.id},l=await r.toSliceSnapshot(n);return(0,oA.Z1)(l,"import markdown failed, expected to get a snapshot"),{snapshot:l,job:a}};async function sM(e,t,a,r){let{snapshot:o,job:i}=await sD(t,e),s=o.content[0].children,n=[];for(let t=0;t{if(null!=t&&"object"==typeof t){if(Array.isArray(t)){t.forEach(t=>sP(e,t));return}"string"==typeof t.insert&&(t.insert=e[t.insert]??t.insert),Object.values(t).forEach(t=>sP(e,t));return}},sL=e=>async(t,a)=>{let r=await i0.photoEngine?.searchImages({query:e,width:t,height:a});return null==r||0===r.length?"":r[Math.floor((1664525*function(e){let t=0;for(let a=0;a{let a={},r=e=>{if(null!=e&&"object"==typeof e){if(Array.isArray(e)){e.forEach(e=>r(e));return}if("string"==typeof e.caption){let t=oN.z.deserialize(e.xywh),r=(0,i$.Ak)();e.sourceId=r,a[e.caption]={id:r,width:t.w,height:t.h},delete e.caption}Object.values(e).forEach(e=>r(e));return}};return r(t),(await Promise.all(Object.entries(a).map(async([t,a])=>{let r=e[t];if(!r)return;let o=await r(a.width,a.height);return{id:a.id,url:o}}))).filter(e=>null!=e)},sW=async(e,t)=>{let r=sz((await a.e(6215).then(a.t.bind(a,76215,19))).default);return sP({title:e,"section1.title":t.title,"section1.content":t.content},r),{images:await s$({"section1.image":sL(t.keywords)},r),content:r}};function sz(e){return JSON.parse(JSON.stringify(e[Math.floor(Math.random()*e.length)]))}let sO=async(e,t)=>{let r=sz((await a.e(7592).then(a.t.bind(a,27592,19))).default);return sP({title:e,"section1.title":t.title,"section1.content":t.content},r),{images:await s$({"section1.image":sL(t.keywords),"section1.image2":sL(t.keywords),"section1.image3":sL(t.keywords)},r),content:r}},sB=async(e,t,r)=>{let o=sz((await a.e(5226).then(a.t.bind(a,65226,19))).default);return sP({title:e,"section1.title":t.title,"section1.content":t.content,"section2.title":r.title,"section2.content":r.content},o),{images:await s$({"section1.image":sL(t.keywords),"section2.image":sL(r.keywords),background:()=>"https://cdn.affine.pro/ppt-images/background/basic_2_selection_background.png"},o),content:o}},sR=async(e,t,r,o)=>{let i=sz((await a.e(52).then(a.t.bind(a,40052,19))).default);return sP({title:e,"section1.title":t.title,"section1.content":t.content,"section2.title":r.title,"section2.content":r.content,"section3.title":o.title,"section3.content":o.content},i),{images:await s$({"section1.image":sL(t.keywords),"section2.image":sL(r.keywords),"section3.image":sL(o.keywords),background:()=>"https://cdn.affine.pro/ppt-images/background/basic_3_selection_background.png"},i),content:i}},sU=async(e,t,r,o,i)=>{let s=sz((await a.e(944).then(a.t.bind(a,60944,19))).default);return sP({title:e,"section1.title":t.title,"section1.content":t.content,"section2.title":r.title,"section2.content":r.content,"section3.title":o.title,"section3.content":o.content,"section4.title":i.title,"section4.content":i.content},s),{images:await s$({"section1.image":sL(t.keywords),"section2.image":sL(r.keywords),"section3.image":sL(o.keywords),"section4.image":sL(i.keywords),background:()=>"https://cdn.affine.pro/ppt-images/background/basic_4_selection_background.png"},s),content:s}},sq=e=>e.isCover?sW(e.title,e.sections[0]):1===e.sections.length?sO(e.title,e.sections[0]):2===e.sections.length?sB(e.title,e.sections[0],e.sections[1]):3===e.sections.length?sR(e.title,e.sections[0],e.sections[1],e.sections[2]):sU(e.title,e.sections[0],e.sections[1],e.sections[2],e.sections[3]),sV=e=>{let t=e.spec.getService("affine:page"),a=[],r=[],o=[],i=async i=>{let s=i.children.map(e=>({title:sG(e),keywords:sG(e.children[0]),content:sG(e.children[1])})),n={isCover:0===a.length,title:sG(i),sections:s};if(a.push(n),n.isCover)return;let l=t.createTemplateJob("template"),{images:c,content:d}=await sq(n);r.push(d),o.push(c),c.length&&await Promise.all(c.map(({id:e,url:t})=>fetch(t).then(e=>e.blob()).then(t=>l.job.assets.set(e,t)))),await l.insertTemplate(d),sT(e).refresh()};return{process:async a=>{try{for(let r of(await sD(a,e)).snapshot.content[0].children){await i(r);let{centerX:e,centerY:a,zoom:o}=t.getFitToScreenData();t.viewport.setViewport(o,[e,a])}}catch(e){console.error(e)}return{contents:r,images:o}},done:async t=>{let a=(await sD(t,e)).snapshot.content[0];await i(a.children[a.children.length-1])}}},sG=e=>e.props.text?.delta?.[0]?.insert??"";function sH(e,t,a,r){return(sH=function(){function e(e,t){return function(r){(function(e,t){if(e.v)throw Error("attempted to call "+t+" after decoration was finished")})(t,"addInitializer"),a(r,"An initializer"),e.push(r)}}function t(t,a,r,o,i,s,n,l,c){switch(i){case 1:d="accessor";break;case 2:d="method";break;case 3:d="getter";break;case 4:d="setter";break;default:d="field"}var d,m,p,u={kind:d,name:n?"#"+a:a,static:s,private:n,metadata:l},h={v:!1};u.addInitializer=e(o,h),0===i?n?(m=r.get,p=r.set):(m=function(){return this[a]},p=function(e){this[a]=e}):2===i?m=function(){return r.value}:((1===i||3===i)&&(m=function(){return r.get.call(this)}),(1===i||4===i)&&(p=function(e){r.set.call(this,e)})),u.access=m&&p?{get:m,set:p}:m?{get:m}:{set:p};try{return t(c,u)}finally{h.v=!0}}function a(e,t){if("function"!=typeof e)throw TypeError(t+" must be a function")}function r(e,t){var r=typeof t;if(1===e){if("object"!==r||null===t)throw TypeError("accessor decorators must return an object with get, set, or init properties or void 0");void 0!==t.get&&a(t.get,"accessor.get"),void 0!==t.set&&a(t.set,"accessor.set"),void 0!==t.init&&a(t.init,"accessor.init")}else if("function"!==r)throw TypeError((0===e?"field":10===e?"class":"method")+" decorators must return a function or void 0")}function o(e,t){t&&e.push(function(e){for(var a=0;a3,b=f>=5;if(b?(p=e,f-=5,u=m=m||[]):(p=e.prototype,u=d=d||[]),0!==f&&!y){var v=b?l:n,k=v.get(g)||0;if(!0===k||3===k&&4!==f||4===k&&3!==f)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+g);!k&&f>2?v.set(g,f):v.set(g,!0)}!function(e,a,o,i,s,n,l,c,d){var m,p,u,h,f,g,y=o[0];if(l?m=0===s||1===s?{get:o[3],set:o[4]}:3===s?{get:o[3]}:4===s?{set:o[3]}:{value:o[3]}:0!==s&&(m=Object.getOwnPropertyDescriptor(a,i)),1===s?u={get:m.get,set:m.set}:2===s?u=m.value:3===s?u=m.get:4===s&&(u=m.set),"function"==typeof y)void 0!==(h=t(y,i,m,c,s,n,l,d,u))&&(r(s,h),0===s?p=h:1===s?(p=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h);else for(var b=y.length-1;b>=0;b--)void 0!==(h=t(y[b],i,m,c,s,n,l,d,u))&&(r(s,h),0===s?g=h:1===s?(g=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h,void 0!==g&&(void 0===p?p=g:"function"==typeof p?p=[p,g]:p.push(g)));if(0===s||1===s){if(void 0===p)p=function(e,t){return t};else if("function"!=typeof p){var v=p;p=function(e,t){for(var a=t,r=0;r0){for(var s=[],n=t,l=t.name,c=a.length-1;c>=0;c--){var d={v:!1};try{var m=a[c](n,{kind:"class",name:l,addInitializer:e(s,d),metadata:o})}finally{d.v=!0}void 0!==m&&(r(10,m),n=m)}return[i(n,o),function(){for(var e=0;e(a,r)=>{if("generating"===r){let t=sC(e);return t.generatingElement?.updateLoadingProgress(2),o_.s6}return"finished"!==r&&"error"!==r?o_.s6:(0,o_.qy)`
`};function sY(e){let t=e.indexOf(""),a=e.indexOf("");return e.slice(t,a+7)}function sJ(e,t,a,r){return(sJ=function(){function e(e,t){return function(r){(function(e,t){if(e.v)throw Error("attempted to call "+t+" after decoration was finished")})(t,"addInitializer"),a(r,"An initializer"),e.push(r)}}function t(t,a,r,o,i,s,n,l,c){switch(i){case 1:d="accessor";break;case 2:d="method";break;case 3:d="getter";break;case 4:d="setter";break;default:d="field"}var d,m,p,u={kind:d,name:n?"#"+a:a,static:s,private:n,metadata:l},h={v:!1};u.addInitializer=e(o,h),0===i?n?(m=r.get,p=r.set):(m=function(){return this[a]},p=function(e){this[a]=e}):2===i?m=function(){return r.value}:((1===i||3===i)&&(m=function(){return r.get.call(this)}),(1===i||4===i)&&(p=function(e){r.set.call(this,e)})),u.access=m&&p?{get:m,set:p}:m?{get:m}:{set:p};try{return t(c,u)}finally{h.v=!0}}function a(e,t){if("function"!=typeof e)throw TypeError(t+" must be a function")}function r(e,t){var r=typeof t;if(1===e){if("object"!==r||null===t)throw TypeError("accessor decorators must return an object with get, set, or init properties or void 0");void 0!==t.get&&a(t.get,"accessor.get"),void 0!==t.set&&a(t.set,"accessor.set"),void 0!==t.init&&a(t.init,"accessor.init")}else if("function"!==r)throw TypeError((0===e?"field":10===e?"class":"method")+" decorators must return a function or void 0")}function o(e,t){t&&e.push(function(e){for(var a=0;a3,b=f>=5;if(b?(p=e,f-=5,u=m=m||[]):(p=e.prototype,u=d=d||[]),0!==f&&!y){var v=b?l:n,k=v.get(g)||0;if(!0===k||3===k&&4!==f||4===k&&3!==f)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+g);!k&&f>2?v.set(g,f):v.set(g,!0)}!function(e,a,o,i,s,n,l,c,d){var m,p,u,h,f,g,y=o[0];if(l?m=0===s||1===s?{get:o[3],set:o[4]}:3===s?{get:o[3]}:4===s?{set:o[3]}:{value:o[3]}:0!==s&&(m=Object.getOwnPropertyDescriptor(a,i)),1===s?u={get:m.get,set:m.set}:2===s?u=m.value:3===s?u=m.get:4===s&&(u=m.set),"function"==typeof y)void 0!==(h=t(y,i,m,c,s,n,l,d,u))&&(r(s,h),0===s?p=h:1===s?(p=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h);else for(var b=y.length-1;b>=0;b--)void 0!==(h=t(y[b],i,m,c,s,n,l,d,u))&&(r(s,h),0===s?g=h:1===s?(g=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h,void 0!==g&&(void 0===p?p=g:"function"==typeof p?p=[p,g]:p.push(g)));if(0===s||1===s){if(void 0===p)p=function(e,t){return t};else if("function"!=typeof p){var v=p;p=function(e,t){for(var a=t,r=0;r0){for(var s=[],n=t,l=t.name,c=a.length-1;c>=0;c--){var d={v:!1};try{var m=a[c](n,{kind:"class",name:l,addInitializer:e(s,d),metadata:o})}finally{d.v=!0}void 0!==m&&(r(10,m),n=m)}return[i(n,o),function(){for(var e=0;e{this._editorHost&&sV(this._editorHost).process(this.text).then(e=>{this.ctx&&this.ctx.set({contents:e.contents,images:e.images})}).catch(console.error)})}render(){return(0,o_.qy)`
${this.host.renderSpecPortal(this._doc,oE.BH6)}
`}connectedCallback(){super.connectedCallback();let e=new i$.Sj().register(sI.g),t=new i$.rl({schema:e,id:"SLIDES_PREVIEW",disableBacklinkIndex:!0,disableSearchIndex:!0});t.meta.initialize(),t.start();let a=t.createDoc();a.load(()=>{let e=a.addBlock("affine:page",{});a.addBlock("affine:surface",{},e)}),a.resetHistory(),this._doc=a}constructor(...e){super(...e),this._editorContainer=(0,sj._)(),this.#i=(Q(this),Z(this)),this.#s=K(this),this.#n=Y(this),this.#l=J(this,void 0)}}}},X=(0,iW.EM)("ai-answer-wrapper"),ea=(0,iW.MZ)({attribute:!1}),new class extends sQ{constructor(){super(i),ee()}static{class e extends(et=o_.WF){static{({e:[er,eo],c:[i,ee]}=sJ(this,[[ea,1,"options"]],[X],et))}static{this.styles=(0,o_.AH)` :host { display: block; width: 100%; box-sizing: border-box; border-radius: 4px; border: 1px solid var(--affine-border-color); box-shadow: var(--affine-shadow-1); background: var(--affine-background-secondary-color); overflow: hidden; } ::slotted(.ai-answer-iframe) { width: 100%; height: 100%; border: none; } ::slotted(.ai-answer-image) { width: 100%; height: 100%; } `}#c;get options(){return this.#c}set options(e){this.#c=e}render(){return(0,o_.qy)` `}constructor(...e){super(...e),this.#c=(eo(this),er(this,void 0))}}}};let sX=(e,t)=>(a,r)=>{if("generating"===r){let t=sC(e);return t.generatingElement?.updateLoadingProgress(2),o_.s6}if("finished"!==r&&"error"!==r)return o_.s6;let o=(0,o_.qy)``;return(0,o_.qy)`${o}`},s0=(e,t)=>(a,r)=>{if("generating"===r){let t=sC(e);return t.generatingElement?.updateLoadingProgress(2),o_.s6}if("finished"!==r&&"error"!==r)return o_.s6;let o=(0,o_.qy)`
`;return(0,o_.qy)`${o}`};async function s1(e,t,a){var r;try{let o=await (0,oE.aKu)(e,void 0,a);if(o&&o.ok){let e=await o.blob();return e.type&&e.type.startsWith("image/")||(e=await (r=e,new Promise(e=>{let t=new FileReader;t.addEventListener("load",a=>{let r=new Image;r.onload=()=>{let t=document.createElement("canvas");t.width=r.width,t.height=r.height;let a=t.getContext("2d");(0,oA.Z1)(a),a.imageSmoothingEnabled=!0,a.imageSmoothingQuality="high",a.drawImage(r,0,0),t.toBlob(e,"image/png")},r.onerror=()=>e(null),r.src=t.result}),t.addEventListener("error",()=>e(null)),t.readAsDataURL(r)})).then(t=>t||e)),new File([e],t,{type:e.type||"image/png"})}}catch(e){console.error(e)}return new Promise(a=>{let r=new Image;r.onload=()=>{let e=document.createElement("canvas");e.width=r.width,e.height=r.height;let o=e.getContext("2d");(0,oA.Z1)(o),o.imageSmoothingEnabled=!0,o.imageSmoothingQuality="high",o.drawImage(r,0,0),e.toBlob(e=>{if(e)return a(new File([e],t,{type:e.type}));a()},"image/png")},r.onerror=()=>a(),r.crossOrigin="anonymous",r.src=e})}function s2(e){return new Promise((t,a)=>{let r=new FileReader;r.onload=e=>{"string"==typeof e.target?.result?t(e.target.result):a()},r.onerror=a,r.readAsDataURL(e)})}function s3(e,t="image/png",a){return new Promise(r=>e.toBlob(r,t,a))}function s4(e){let t=e.doc.root?.id;return e.view.getWidget(oE.FrX,t)}function s6(e,t){return{name:"Discard",icon:oE.d7y,showWhen:()=>!!e.answer,handler:()=>{e.discard()}}}function s5(e){return{name:"Retry",icon:oE.NAP,handler:()=>{i1("result:retry"),e.generate()}}}function s7(e,t,a,r=0){sM(e,t,a,r).then(()=>{i4(e).selection.set({elements:[a],editing:!1})}).catch(e=>{console.error(e)})}function s8(e,t,a){let r=e.doc,o=i6(e);r.transact(()=>{(0,oA.Z1)(r.root);let i="",s=o.determineInsertionBounds(oE.rYV,oE.MyE),n=r.getBlocksByFlavour("affine:surface")[0];if("edgelessText"===a)i=r.addBlock("affine:edgeless-text",{xywh:s.serialize()},n.id);else{let e=o.determineInsertionBounds(800,95);i=r.addBlock("affine:note",{xywh:e.serialize(),displayMode:oE.ko3.EdgelessOnly},r.root.id)}s7(e,t,i)})}let s9=e=>{let t=sC(e),a=sf(e);if((0,oA.Z1)(t.answer),1===a.length&&a[0]instanceof oE.QLR){let r=a[0].id,o=a[0].children.length;s7(e,t.answer,r,o)}else a.length>1&&a.every(e=>e instanceof oE.QLR)?s8(e,t.answer,"edgelessText"):s8(e,t.answer,"note")},ne=e=>{let t=sC(e),a=t.answer;if(!a)return;let r=i6(e),o=r.determineInsertionBounds(),i=sf(e).find(e=>e instanceof oE.mK9),s=i?oN.z.deserialize(i.xywh):null;r.hideCopilotPanel(),t.hide(),s1(a,"image",e.std.clipboard.configs.get("imageProxy")).then(t=>{if(!t)return;let a=si(e),{minX:r,minY:i}=o,[n,l]=a.service.viewport.toViewCoord(r,i);e.doc.transact(()=>{a.addImages([t],[n,l],!0).then(t=>{let a=t[0],r=e.doc.getBlock(a);if(!r||!s)return;let o=r.model,i=oN.z.deserialize(o.xywh),n=new oN.z(i.x,i.y,s.w,s.h);e.doc.updateBlock(o,{xywh:n.serialize()})}).catch(console.error)})}).catch(console.error)},nt={expandMindmap:(e,t)=>{let[a]=e.doc.getBlockByFlavour("affine:surface"),r=t.get().selectedElements,o=t.get();queueMicrotask(()=>{sC(e).hide()});let i=r[0].group;if(o?.node&&o.node.children){o.node.children.forEach(e=>{i.addTree(r[0].id,e)});let t=i.getNode(r[0].id);if(!t)return;a.doc.transact(()=>{let e=t=>{(0,oE.hw5)(t.element),t.children.forEach(t=>{e(t)})};e(t)}),setTimeout(()=>{ss(e).selection.set({elements:[t.element.id],editing:!1})})}},brainstormMindmap:(e,t)=>{let a=sC(e),r=ss(e),o=i6(e),i=o.selectionModelRect,[s]=e.doc.getBlockByFlavour("affine:surface"),n=t.get().selectedElements,l=t.get(),c=!0;if(i2(n[0])){let e=n[0].group,t=e.tree.element.xywh;s.removeElement(e.id),l.node&&(l.node.xywh=t,c=!1)}o.hideCopilotPanel(),a.hide();let d=s.addElement({type:"mindmap",children:l.node,style:l.style}),m=s.getElementById(d);e.doc.transact(()=>{m.childElements.forEach(e=>{(0,oE.hw5)(e)})}),r.telemetryService?.track("CanvasElementAdded",{control:"ai",page:"whiteboard editor",module:"toolbar",segment:"toolbar",type:"mindmap"}),queueMicrotask(()=>{c&&i&&m.moveTo([i.x,i.y,i.width,i.height])}),setTimeout(()=>{r.viewport.setViewportByBound(m.elementBound,[20,20,20,20],!0),r.selection.set({elements:[m.tree.element.id],editing:!1})})},makeItReal:(e,t)=>{let a=sC(e),r=a.answer;if(!r)return;r=sY(r);let o=i6(e),[i]=e.doc.getBlockByFlavour("affine:surface"),s=t.get(),n=o.determineInsertionBounds(s.width||800,s.height||600);o.hideCopilotPanel(),a.hide();let l=si(e);e.doc.transact(()=>{l.doc.addBlock("affine:embed-html",{html:r,design:"ai:makeItReal",xywh:n.serialize()},i.id)})},createSlides:(e,t)=>{let a=t.get(),r=a.contents;if(!r)return;let o=a.images,i=e.spec.getService("affine:page");(async function(){for(let t=0;tfetch(t).then(e=>e.blob()).then(t=>n.job.assets.set(e,t)))),await n.insertTemplate(s),sT(e).refresh()}})().catch(console.error)},createImage:ne,processImage:ne,filterImage:ne},na={brainstormMindmap:e=>e?.regenerate?"Replace":void 0};function nr(e,t,a,r){let o=nt[e]??s9,i=na[e]?.(r)??void 0;return function(e,t,a,r,o="Insert below"){return{name:o,icon:oE.amD,showWhen:()=>{let t=sC(a);return!ij.includes(e)&&!!t.answer},handler:()=>{i1("result:insert"),t(a,r),sC(a).hide()}}}(e,o,t,a,i)}async function no(e,t){let a=i$.Ji.fromModels(e.doc,t);return(await iV(e,a)).trim()}async function ni(e,t){return(await Promise.all(t.map(t=>{let a=i$.Ji.fromModels(e.doc,t.children);return iV(e,a)}))).map(e=>e.trim()).filter(e=>e.length)}async function ns(e,t){let{notes:a,texts:r,shapes:o,images:i,edgelessTexts:s,embedSyncedDocs:n}=t.reduce((e,t)=>{if(t instanceof oE.NTi)e.notes.push(t);else if(t instanceof oE.n6X)e.texts.push(t);else{var a,r;t instanceof oE.B5W&&void 0!==(a=t).text&&0!==a.text.length?e.shapes.push(t):t instanceof oE.mK9&&void 0!==(r=t).caption&&0!==r.caption.length?e.images.push(t):t instanceof oE.QLR?e.edgelessTexts.push(t):t instanceof oE.Frf&&e.embedSyncedDocs.push(t)}return e},{notes:[],texts:[],shapes:[],images:[],edgelessTexts:[],embedSyncedDocs:[]}),l=await ni(e,a),c=await ni(e,s),d=await no(e,n);return`${l.join("\n")} ${c.join("\n")} ${d} ${r.map(e=>e.text.toString()).join("\n")} ${o.map(e=>e.text.toString()).join("\n")} ${i.map(e=>e.caption.toString()).join("\n")} `.trim()}function nn(e,t,a,r,o){return i=>{let s=sC(i),n=i6(i),l={},c=sf(i),{selectedBlocks:d}=sp(i),m={get:()=>({...l,selectedElements:c}),set(e){l=e}};n.hideCopilotPanel(),n.lockToolbar(!0),function(e,t,a,r,o,i,s,n){var l,c;let d=e.host,{config:m}=e;(0,oA.Z1)(m),m.answerRenderer=function(e,t,a){if("brainstormMindmap"===e){let e=a.get().selectedElements;return i2(e[0]||i3(e[0]))?sN(t,a,e[0].group.style):sN(t,a)}return"expandMindmap"===e?s_(t,a,e=>{nt.expandMindmap?.(t,e)}):"createSlides"===e?sK(t,a):"makeItReal"===e?sX(t,{height:300}):iD.includes(e)?s0(t,{height:300}):iX(t,{maxHeight:320})}(a,d,o),m.generateAnswer=({signal:e,update:t,finish:r})=>{if(!s&&0===sf(d).length)return;let l=(function(e,t,a,r,o){let i=i0.actions[e];if(i&&"function"==typeof i)return r&&"function"==typeof r?(e,s)=>{let n;let l=o?.control||"format-bar",c=o?.where||"ai-panel";return{async *[Symbol.asyncIterator](){let o=sf(e),d={...a,signal:t,input:"",stream:!0,control:l,where:c,models:o,host:e,docId:e.doc.id,workspaceId:e.doc.collection.id},m=await r(e,s);m&&Object.assign(d,m),(n=i(d))&&(yield*n)}}}:e=>{let r;return{async *[Symbol.asyncIterator](){let o=sC(e),s=sf(e),n=await function(e){let t=sf(e);return ns(e,t)}(o.host);(r=i({...a,signal:t,input:n,stream:!0,where:"ai-panel",models:s,control:"format-bar",host:e,docId:e.doc.id,workspaceId:e.doc.collection.id}))&&(yield*r)}}}})(a,e,i,s,n)?.(d,o);l&&sS(l,{update:t,finish:r,signal:e})},m.finishStateConfig={responses:[{name:"Response",items:[{name:"Continue in chat",icon:ip,handler:()=>{i1("result:continue-in-chat");let e=sC(l);i0.slots.requestOpenWithChat.emit({host:l}),e.hide()}},nr(a,l=d,o,i),(c=l,{name:"Use as caption",icon:it,showWhen:()=>{let e=sC(c);return"generateCaption"===a&&!!e.answer},handler:()=>{i1("result:use-as-caption");let e=sC(c),t=e.answer;if(!t)return;let a=sf(c);if(1!==a.length)return;let r=a[0];r instanceof oE.mK9&&(c.doc.updateBlock(r,{caption:t}),e.hide())}}),s5(sC(l)),s6(sC(l),i6(l))]}],actions:[]},m.generatingStateConfig={generatingIcon:r,stages:iT[a]},m.errorStateConfig={upgrade:()=>{i0.slots.requestUpgradePlan.emit({host:e.host}),e.hide()},login:()=>{i0.slots.requestLogin.emit({host:e.host}),e.hide()},cancel:()=>{e.hide()},responses:[{name:"Response",items:[nr(a,d,o,i)]},{name:"",items:[s5(sC(d)),s6(sC(d),i6(d))]}]},m.copy={allowed:!iI.includes(a),onCopy:()=>sa(e)},m.discardCallback=()=>{i1("result:discard")},m.hideCallback=()=>{e.updateComplete.finally(()=>{t.edgeless.service.tool.switchToDefaultMode({elements:[],editing:!1}),d.selection.clear(),t.lockToolbar(!1)}).catch(console.error)}}(s,n,e,t,m,a,r,o);let p=s4(i),u=0===c.length,h="createImage"===e,f=!h&&"makeItReal"===e,g=null,y=()=>Promise.resolve(u);if(d&&0!==d.length)g=d.at(-1);else if(n.visible&&n.selectionElem)g=n.selectionElem;else if(p.toolbarVisible)g=s4(i);else if(!u){let e=c.at(-1)?.id;(0,oA.Z1)(e),g=sh(i,e)}g&&((h||f)&&(y=async()=>{if(u)return!0;let{notes:e,shapes:t,images:a,edgelessTexts:r,embedSyncedDocs:o}=oE.yYJ.splitElements(c),s=[...e,...t,...a,...r,...o];if(0===s.length)return!0;let n=await ns(i,s);return m.set({content:n}),0===n.length}),y().then(e=>{s.toggle(g,e?void 0:"placeholder")}).catch(console.error))}}function nl(e,t,a){return sf(a).some(e=>e instanceof oE.NTi||e instanceof oE.n6X||e instanceof oE.QLR)}function nc(e,t,a){let r=sf(a);return!!r.length&&r[0]instanceof oE.NTi&&1===r[0].children.length&&oE.yYJ.matchFlavours(r[0].children[0],["affine:code"])}function nd(e,t,a){let r=sf(a);return 1===r.length&&r[0]instanceof oE.mK9}function nm(e,t,a){let r=sf(a);return 0===r.length||!r.every(e=>e instanceof sE.hJ)}let np=["English","Spanish","German","French","Italian","Simplified Chinese","Traditional Chinese","Japanese","Russian","Korean"],nu=["Professional","Informal","Friendly","Critical","Humorous"],nh=["Clay style","Sketch style","Anime style","Pixel style"],nf=["Clearer","Remove background","Convert to sticker"],ng=np.map(e=>({type:e,handler:nn("translate",oE.orQ,{lang:e})})),ny=nu.map(e=>({type:e,handler:nn("changeTone",oE.orQ,{tone:e})})),nb=nh.map(e=>({type:e,handler:nn("filterImage",im,{style:e},sg)})),nv=nf.map(e=>({type:e,handler:nn("processImage",im,{type:e},sg)})),nk={name:"edit with ai",items:[{name:"Translate to",icon:oK,showWhen:nl,subItem:ng},{name:"Change tone to",icon:o4,showWhen:nl,subItem:ny},{name:"Improve writing",icon:oY,showWhen:nl,handler:nn("improveWriting",oE.orQ)},{name:"Make it longer",icon:oX,showWhen:nl,handler:nn("makeLonger",oE.orQ)},{name:"Make it shorter",icon:oQ,showWhen:nl,handler:nn("makeShorter",oE.orQ)},{name:"Continue writing",icon:it,showWhen:nl,handler:nn("continueWriting",ia)}]},nw={name:"draft with ai",items:[{name:"Write an article about this",icon:it,showWhen:nl,handler:nn("writeArticle",ia)},{name:"Write a tweet about this",icon:it,showWhen:nl,handler:nn("writeTwitterPost",ia)},{name:"Write a poem about this",icon:it,showWhen:nl,handler:nn("writePoem",ia)},{name:"Write a blog post about this",icon:it,showWhen:nl,handler:nn("writeBlogPost",ia)},{name:"Brainstorm ideas about this",icon:it,showWhen:nl,handler:nn("brainstorm",ia)}]},nx=[{name:"review with ai",items:[{name:"Fix spelling",icon:it,showWhen:nl,handler:nn("fixSpelling",oE.orQ)},{name:"Fix grammar",icon:it,showWhen:nl,handler:nn("improveGrammar",oE.orQ)},{name:"Explain this image",icon:it,showWhen:nd,handler:nn("explainImage",oE.orQ,void 0,sg)},{name:"Explain this code",icon:o0,showWhen:nc,handler:nn("explainCode",oE.orQ)},{name:"Check code error",icon:o0,showWhen:nc,handler:nn("checkCodeErrors",oE.orQ)},{name:"Explain selection",icon:o2,showWhen:nl,handler:nn("explain",oE.orQ)}]},nk,{name:"generate with ai",items:[{name:"Summarize",icon:it,showWhen:nl,handler:nn("summary",ia)},{name:"Generate headings",icon:it,handler:nn("createHeadings",ia),showWhen:nl,beta:!0},{name:"Generate an image",icon:id,showWhen:nm,handler:nn("createImage",im,void 0,async(e,t)=>{let a=sf(e),r=a.length,o=sC(e);if(0===r){let e=o.inputText?.trim();if(!e)return;return{content:e}}let i=t.get().content||"";0===i.length&&(i=o.inputText?.trim()||"");let{images:s,shapes:n,notes:l,frames:c}=oE.yYJ.splitElements(a),d=n.filter(e=>!(e instanceof oE.n6X||e instanceof oE.B5W&&e.text?.length));if(i.length&&s.length+d.length===0)return{content:i};let m=si(e),p=await m.clipboardController.toCanvas(s,d,{dpr:1,padding:0,background:"white"});if(!p)return;let u=await s3(p);if(u)return{content:i,attachments:[u],seed:String(function(e=0,t=Date.now()){return Math.round(Math.random()*(t-e))+e}())}})},{name:"Generate outline",icon:it,showWhen:nl,handler:nn("writeOutline",ia)},{name:"Expand from this mind map node",icon:il,showWhen:function(e,t,a){let r=sf(a);return 1===r.length&&i3(r[0])},handler:nn("expandMindmap",is,void 0,function(e){let t=sf(e)[0],a=t?.group;return a instanceof oE.ARu?Promise.resolve({input:t.text?.toString()??"",mindmap:function(e){let t="",a=(e,r=0)=>{let o=e.element.text?.toString()??"";t+=`${" ".repeat(r)}- ${o} `,e.children&&e.children.forEach(e=>a(e,r+2))};return a(e.tree,0),t}(a)}):Promise.resolve({})}),beta:!0},{name:"Brainstorm ideas with mind map",icon:ii,showWhen:nl,handler:nn("brainstormMindmap",is)},{name:"Regenerate mind map",icon:ii,showWhen:function(e,t,a){let r=sf(a);return 1===r.length&&i2(r[0])},handler:nn("brainstormMindmap",is,{regenerate:!0})},{name:"Generate presentation",icon:ir,showWhen:nl,handler:nn("createSlides",io),beta:!0},{name:"Make it real",icon:iu,beta:!0,showWhen:nm,handler:nn("makeItReal",ih,void 0,async(e,t)=>{let a=sf(e);if(0===a.length){let t=sC(e),a=t.inputText?.trim();if(!a)return;return{content:a}}let{notes:r,frames:o,shapes:i,images:s,edgelessTexts:n}=oE.yYJ.splitElements(a),l=o.length,c=s.length,d=r.length,m=i.length,p=n.length;if(l+c+d+m+p===0)return;let u=t.get().content||"";if(0===c&&d+m+p===1&&(1===d||1===p||1===m&&i[0]instanceof oE.n6X))return{content:u};if(0===u.length){let t=sC(e);u=t.inputText?.trim()||""}let h=si(e),f=await h.clipboardController.toCanvas([...r,...o,...s],i,{dpr:1,background:"white"});if(!f)return;let g=await s3(f);if(g)return t.set({width:f.width,height:f.height}),{content:u,attachments:[g]}})},{name:"AI image filter",icon:oY,showWhen:nd,subItem:nb,subItemOffset:[12,-4],beta:!0},{name:"Image processing",icon:id,showWhen:nd,subItem:nv,subItemOffset:[12,-6],beta:!0},{name:"Generate a caption",icon:it,showWhen:nd,beta:!0,handler:nn("generateCaption",oE.orQ,void 0,sg)},{name:"Find actions",icon:o5,showWhen:nl,handler:nn("findActions",oE.orQ),beta:!0}]},nw,{name:"others",items:[{name:"Continue with AI",icon:iN,showWhen:()=>!0,handler:e=>{let t=sC(e);i0.slots.requestOpenWithChat.emit({host:e,mode:"edgeless",autoSelect:!0}),t.hide()}},{name:"Open AI Chat",icon:ip,showWhen:()=>!0,handler:e=>{let t=sC(e);i0.slots.requestOpenWithChat.emit({host:e,mode:"edgeless"}),t.hide()}}]}];(0,sA.lQ)(oE.exN);var nC=a(62055),nS=a(41295),nF=a(47590),nA=a(74351);let nE=(0,o_.qy)``;function nN(e){console.log("=======call=========="),function(e){e.clearConfig().addParagraphDropdown().addDivider().addTextStyleToggle({key:"bold",action:e=>e.toggleBold().run(),icon:oE.$oz}).addTextStyleToggle({key:"italic",action:e=>e.toggleItalic().run(),icon:oE.yOR}).addTextStyleToggle({key:"underline",action:e=>e.toggleUnderline().run(),icon:oE.qpS}).addTextStyleToggle({key:"strike",action:e=>e.toggleStrike().run(),icon:oE.t64}).addTextStyleToggle({key:"code",action:e=>e.toggleCode().run(),icon:oE.loI}).addTextStyleToggle({key:"link",action:e=>e.toggleLink().run(),icon:oE.qYV}).addDivider().addHighlighterDropdown().addDivider().addInlineAction({id:"convert-to-database",name:"Create Data Table & Kanban Board",icon:oE.yni,isActive:()=>!1,action:()=>{(0,nS.p0)({template:(0,o_.qy)``})},showWhen:e=>{let t=(e=0)=>(t,a)=>{let{selectedBlocks:r}=t;r&&r.length!==e&&r.every(e=>nF.Z.includes(e.flavour))&&a()},[a]=e.getTextSelection().getSelectedBlocks({types:["text"]}).inline(t(1)).run();return!!a||([a]=e.tryAll(e=>[e.getBlockSelections(),e.getImageSelections()]).getSelectedBlocks({types:["block","image"]}).inline(t(0)).run(),a)}}).addDivider().addInlineAction({id:"convert-to-linked-doc",name:"드래그 한 내용을 A-RMS에 요구사항으로 등록 + 하위 요구사항 페이지 생성",icon:nE,isActive:()=>!1,action:(e,t)=>{let[a,r]=e.getSelectedModels({types:["block","text"],mode:"highest"}).run(),{selectedModels:o}=r;if((0,oA.Z1)(o),!o.length)return;let i=t.host;i.selection.clear();let s=i.doc;(function(e,t){console.log("promptDocTitle");let a=e.std.spec.getService("affine:page").notificationService;if(!a)return Promise.resolve(void 0);let r=document.getSelection();if(!r||0===r.rangeCount)return!1;let o=r.getRangeAt(0);console.log(o.startContainer.data),console.log(o.endContainer.data);var i="";return i=o.startContainer.data.toString()==o.endContainer.data.toString()?o.startContainer.data.toString():o.startContainer.data.toString()+" "+o.endContainer.data.toString(),a.prompt({title:"A-RMS 요구사항 생성",message:"드래그한 부분을 A-RMS에 요구사항을 생성합니다. \n또한 요구사항 하위 페이지를 구성합니다.",inputTitle:"요구사항 제목",placeholder:t,autofill:"[ADOC-REQ] "+i,confirmText:"Confirm",cancelText:"Cancel",versionSelect:!0})})(i,(0,nA.G6)(o)).then(e=>{if(null===e)return;let t=(0,nA.B$)(s,o,e);console.log("========================"),console.log(o),console.log(e),console.log("========================"),i.spec.getService("affine:embed-linked-doc").slots.linkedDocCreated.emit({docId:t.id}),(0,nA.eD)(i,s),i.spec.getService("affine:page").telemetryService?.track("DocCreated",{control:"create linked doc",page:"doc editor",module:"format toolbar",type:"embed-linked-doc"}),i.spec.getService("affine:page").telemetryService?.track("LinkedDocCreated",{control:"create linked doc",page:"doc editor",module:"format toolbar",type:"embed-linked-doc"}),console.log("여기에서 ARMS 연동"),console.log(t.Text),console.log(t.id),n_(e,i)})},showWhen:e=>{let[t,a]=e.getSelectedModels({types:["block","text"],mode:"highest"}).run(),{selectedModels:r}=a;return!!r&&r.length>0}}).addBlockTypeSwitch({flavour:"affine:paragraph",type:"text",name:"Text",icon:oE.N$i}).addBlockTypeSwitch({flavour:"affine:paragraph",type:"h1",name:"Heading 1",icon:oE.BQZ}).addBlockTypeSwitch({flavour:"affine:paragraph",type:"h2",name:"Heading 2",icon:oE.SoJ}).addBlockTypeSwitch({flavour:"affine:paragraph",type:"h3",name:"Heading 3",icon:oE.Nrq}).addBlockTypeSwitch({flavour:"affine:paragraph",type:"h4",name:"Heading 4",icon:oE.WXD}).addBlockTypeSwitch({flavour:"affine:paragraph",type:"h5",name:"Heading 5",icon:oE.TXg}).addBlockTypeSwitch({flavour:"affine:paragraph",type:"h6",name:"Heading 6",icon:oE.ma5}).addBlockTypeSwitch({flavour:"affine:list",type:"bulleted",name:"Bulleted List",icon:oE.RyS}).addBlockTypeSwitch({flavour:"affine:list",type:"numbered",name:"Numbered List",icon:oE.gZg}).addBlockTypeSwitch({flavour:"affine:list",type:"todo",name:"To-do List",icon:oE.lOw}).addBlockTypeSwitch({flavour:"affine:code",name:"Code Block",icon:oE.loI}).addBlockTypeSwitch({flavour:"affine:paragraph",type:"quote",name:"Quote",icon:oE.cyi})}(e)}async function n_(e,t){await (0,nC.A)({method:"get",url:"/api/auth/arms",params:{c_title:e,c_req_pdservice_link:11,c_req_pdservice_versionset_link:'["37"]',c_req_contents:"제품(*서비스) 이름 : A\n제품(*서비스) 버전 : B\n제품(*서비스) 내용 : Adoc 문서 제목 : "+t.std.range.host.ownerDocument.title,c_req_desc:"설명",c_req_etc:"비고"},headers:{"Access-Control-Allow-Origin":"*"},crossDomain:!0}).then(e=>{console.log(e.data)}).catch(e=>{console.error(e)})}var nI=a(54719);function nj(e,t,a,r){return(nj=function(){function e(e,t){return function(r){(function(e,t){if(e.v)throw Error("attempted to call "+t+" after decoration was finished")})(t,"addInitializer"),a(r,"An initializer"),e.push(r)}}function t(t,a,r,o,i,s,n,l,c){switch(i){case 1:d="accessor";break;case 2:d="method";break;case 3:d="getter";break;case 4:d="setter";break;default:d="field"}var d,m,p,u={kind:d,name:n?"#"+a:a,static:s,private:n,metadata:l},h={v:!1};u.addInitializer=e(o,h),0===i?n?(m=r.get,p=r.set):(m=function(){return this[a]},p=function(e){this[a]=e}):2===i?m=function(){return r.value}:((1===i||3===i)&&(m=function(){return r.get.call(this)}),(1===i||4===i)&&(p=function(e){r.set.call(this,e)})),u.access=m&&p?{get:m,set:p}:m?{get:m}:{set:p};try{return t(c,u)}finally{h.v=!0}}function a(e,t){if("function"!=typeof e)throw TypeError(t+" must be a function")}function r(e,t){var r=typeof t;if(1===e){if("object"!==r||null===t)throw TypeError("accessor decorators must return an object with get, set, or init properties or void 0");void 0!==t.get&&a(t.get,"accessor.get"),void 0!==t.set&&a(t.set,"accessor.set"),void 0!==t.init&&a(t.init,"accessor.init")}else if("function"!==r)throw TypeError((0===e?"field":10===e?"class":"method")+" decorators must return a function or void 0")}function o(e,t){t&&e.push(function(e){for(var a=0;a3,b=f>=5;if(b?(p=e,f-=5,u=m=m||[]):(p=e.prototype,u=d=d||[]),0!==f&&!y){var v=b?l:n,k=v.get(g)||0;if(!0===k||3===k&&4!==f||4===k&&3!==f)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+g);!k&&f>2?v.set(g,f):v.set(g,!0)}!function(e,a,o,i,s,n,l,c,d){var m,p,u,h,f,g,y=o[0];if(l?m=0===s||1===s?{get:o[3],set:o[4]}:3===s?{get:o[3]}:4===s?{set:o[3]}:{value:o[3]}:0!==s&&(m=Object.getOwnPropertyDescriptor(a,i)),1===s?u={get:m.get,set:m.set}:2===s?u=m.value:3===s?u=m.get:4===s&&(u=m.set),"function"==typeof y)void 0!==(h=t(y,i,m,c,s,n,l,d,u))&&(r(s,h),0===s?p=h:1===s?(p=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h);else for(var b=y.length-1;b>=0;b--)void 0!==(h=t(y[b],i,m,c,s,n,l,d,u))&&(r(s,h),0===s?g=h:1===s?(g=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h,void 0!==g&&(void 0===p?p=g:"function"==typeof p?p=[p,g]:p.push(g)));if(0===s||1===s){if(void 0===p)p=function(e,t){return t};else if("function"!=typeof p){var v=p;p=function(e,t){for(var a=t,r=0;r0){for(var s=[],n=t,l=t.name,c=a.length-1;c>=0;c--){var d={v:!1};try{var m=a[c](n,{kind:"class",name:l,addInitializer:e(s,d),metadata:o})}finally{d.v=!0}void 0!==m&&(r(10,m),n=m)}return[i(n,o),function(){for(var e=0;e({...e,items:e.items.filter(e=>!e.showWhen||e.showWhen(this.host.command.chain(),this._edgeless?"edgeless":"page",this.host))})).filter(e=>e.items.length>0)}render(){let e=(0,nI.W)({minWidth:`${this.minWidth}px`});return(0,o_.qy)`
`}constructor(...e){super(...e),this.#d=(eg(this),ep(this)),this.#m=eu(this),this.#p=eh(this,null),this.#u=ef(this,330)}}}};var nM=a(41507);function nT(e,t,a,r){return(nT=function(){function e(e,t){return function(r){(function(e,t){if(e.v)throw Error("attempted to call "+t+" after decoration was finished")})(t,"addInitializer"),a(r,"An initializer"),e.push(r)}}function t(t,a,r,o,i,s,n,l,c){switch(i){case 1:d="accessor";break;case 2:d="method";break;case 3:d="getter";break;case 4:d="setter";break;default:d="field"}var d,m,p,u={kind:d,name:n?"#"+a:a,static:s,private:n,metadata:l},h={v:!1};u.addInitializer=e(o,h),0===i?n?(m=r.get,p=r.set):(m=function(){return this[a]},p=function(e){this[a]=e}):2===i?m=function(){return r.value}:((1===i||3===i)&&(m=function(){return r.get.call(this)}),(1===i||4===i)&&(p=function(e){r.set.call(this,e)})),u.access=m&&p?{get:m,set:p}:m?{get:m}:{set:p};try{return t(c,u)}finally{h.v=!0}}function a(e,t){if("function"!=typeof e)throw TypeError(t+" must be a function")}function r(e,t){var r=typeof t;if(1===e){if("object"!==r||null===t)throw TypeError("accessor decorators must return an object with get, set, or init properties or void 0");void 0!==t.get&&a(t.get,"accessor.get"),void 0!==t.set&&a(t.set,"accessor.set"),void 0!==t.init&&a(t.init,"accessor.init")}else if("function"!==r)throw TypeError((0===e?"field":10===e?"class":"method")+" decorators must return a function or void 0")}function o(e,t){t&&e.push(function(e){for(var a=0;a3,b=f>=5;if(b?(p=e,f-=5,u=m=m||[]):(p=e.prototype,u=d=d||[]),0!==f&&!y){var v=b?l:n,k=v.get(g)||0;if(!0===k||3===k&&4!==f||4===k&&3!==f)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+g);!k&&f>2?v.set(g,f):v.set(g,!0)}!function(e,a,o,i,s,n,l,c,d){var m,p,u,h,f,g,y=o[0];if(l?m=0===s||1===s?{get:o[3],set:o[4]}:3===s?{get:o[3]}:4===s?{set:o[3]}:{value:o[3]}:0!==s&&(m=Object.getOwnPropertyDescriptor(a,i)),1===s?u={get:m.get,set:m.set}:2===s?u=m.value:3===s?u=m.get:4===s&&(u=m.set),"function"==typeof y)void 0!==(h=t(y,i,m,c,s,n,l,d,u))&&(r(s,h),0===s?p=h:1===s?(p=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h);else for(var b=y.length-1;b>=0;b--)void 0!==(h=t(y[b],i,m,c,s,n,l,d,u))&&(r(s,h),0===s?g=h:1===s?(g=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h,void 0!==g&&(void 0===p?p=g:"function"==typeof p?p=[p,g]:p.push(g)));if(0===s||1===s){if(void 0===p)p=function(e,t){return t};else if("function"!=typeof p){var v=p;p=function(e,t){for(var a=t,r=0;r0){for(var s=[],n=t,l=t.name,c=a.length-1;c>=0;c--){var d={v:!1};try{var m=a[c](n,{kind:"class",name:l,addInitializer:e(s,d),metadata:o})}finally{d.v=!0}void 0!==m&&(r(10,m),n=m)}return[i(n,o),function(){for(var e=0;e ${oE.O1o} Ask AI `}constructor(...e){super(...e),this.#h=(eI(this),eF(this)),this._abortController=null,this._whenHover=new oE.n9L(this,({abortController:e})=>({template:(0,o_.qy)``,computePosition:{referenceElement:this,placement:"bottom-start",middleware:[(0,nM.UU)(),(0,nM.cY)({mainAxis:8,crossAxis:-6})],autoUpdate:!0}}),{allowMultiple:!0}),this.#t=eA(this),this.#f=eE(this),this.#g=eN(this,"hover"),this.#y=e_(this,{size:"middle",backgroundColor:void 0,boxShadow:void 0,panelWidth:330}),this._clearAbortController=()=>{this._abortController&&(this._abortController.abort(),this._abortController=null)},this._toggleAIPanel=()=>{if("click"!==this.toggleType)return;if(this._abortController){this._clearAbortController();return}this._abortController=new AbortController,(0,oA.Z1)(this._askAIButton);let e=this.options.panelWidth||330;(0,oE.clE)({template:(0,o_.qy)``,container:this._askAIButton,computePosition:{referenceElement:this._askAIButton,placement:"bottom-start",middleware:[(0,nM.UU)(),(0,nM.cY)({mainAxis:8,crossAxis:-6})],autoUpdate:!0},abortController:this._abortController,closeOnClickAway:!0})}}}}},np.map(e=>({type:e,handler:sF("translate",oI,{lang:e})})),nu.map(e=>({type:e,handler:sF("changeTone",oI,{tone:e})}));let nW={control:"block-action-bar",where:"ai-panel"};function nz(e,t,a,r){return o=>{if(o.doc.root?.id===void 0)return;let i=o.view.getWidget(oE.FrX,o.doc.root.id)?.edgeless;if(i){i.tools.setEdgelessTool({type:"copilot"});let s=i.tools.controllers.copilot,n=i.service.selection.selectedElements;return s.updateDragPointsWith(n,10),s.draggingAreaUpdated.emit(!1),nn(e,t,a,async()=>{let e=sp(o),[t,a]=await Promise.all([sd(o),su(o)]),r=e?.selectedBlocks?.length===1&&a.length>0;return{attachments:r?a:void 0,content:r?"":t}},r)(o)}i0.slots.requestRunInEdgeless.emit({host:o})}}sF("improveWriting",oI),sF("makeLonger",oI),sF("makeShorter",oI),sF("continueWriting",ia),sF("writeArticle",ia),sF("writeTwitterPost",ia),sF("writePoem",ia),sF("writeBlogPost",ia),sF("brainstorm",ia),sF("fixSpelling",oI),sF("improveGrammar",oI),sF("explainImage",oI),sF("explainCode",oI),sF("checkCodeErrors",oI),sF("explain",oI),sF("summary",ia),sF("createHeadings",ia),nz("createImage",im),sF("writeOutline",ia),nz("brainstormMindmap",ia),nz("createSlides",io),nz("makeItReal",ih),sF("findActions",oI);let nO={name:"Others",items:[{name:"Continue with AI",icon:iN,handler:e=>{let t=sC(e);i0.slots.requestOpenWithChat.emit({host:e,autoSelect:!0}),t.hide()}},{name:"Open AI Chat",icon:ip,handler:e=>{let t=sC(e);i0.slots.requestOpenWithChat.emit({host:e}),t.hide()}}]},nB=[{name:"edit with ai",items:[{name:"Explain this image",icon:id,showWhen:()=>!0,handler:sF("explainImage",oI,void 0,nW)}]},{name:"generate with ai",items:[{name:"Generate an image",icon:id,showWhen:()=>!0,handler:nz("createImage",im,void 0,nW)},{name:"Image processing",icon:id,showWhen:()=>!0,subItem:nf.map(e=>({type:e,handler:nz("processImage",im,{type:e},nW)})),subItemOffset:[12,-6],beta:!0},{name:"AI image filter",icon:oY,showWhen:()=>!0,subItem:nh.map(e=>({type:e,handler:nz("filterImage",im,{style:e},nW)})),subItemOffset:[12,-4],beta:!0},{name:"Generate a caption",icon:it,showWhen:()=>!0,beta:!0,handler:sF("generateCaption",oI,void 0,nW)}]},nO],nR={size:"small",backgroundColor:"var(--affine-white)",panelWidth:300};function nU(e){let t=e.config.items.slice();t.unshift({name:"DrawIO",icon:oE.O1o,showWhen:({rootComponent:e})=>null!==e.host.view.getWidget(oE.v1U,e.model.id)&&(e.host.command.chain(),e.service.docModeService.getMode(e.doc.id),(void 0)??!0),action:()=>{window.open("https://www.a-rms.net/reference/drawio/","_blank")}}),e.config={...oE.IfI.DEFAULT_CONFIG,items:t}}let nq={...oE.MNr,view:{...oE.MNr.view,widgets:{...oE.MNr.view.widgets,[oE.v1U]:(0,iB.eu)`${(0,iB.Bk)(oE.v1U)}`}},setup:(e,t)=>{oE.MNr.setup?.(e,t),t.add(e.widgetConnected.on(e=>{e.component instanceof oE.wYV&&nN(e.component),e.component instanceof oE.IfI&&nU(e.component)}))}},nV={...oE.fFq,view:{...oE.fFq.view,widgets:{...oE.fFq.view.widgets,[oE.VCv]:(0,iB.eu)`${(0,iB.Bk)(oE.VCv)}`,[oE.v1U]:(0,iB.eu)`${(0,iB.Bk)(oE.v1U)}`}},setup(e,t){oE.fFq.setup?.(e,t),e.widgetConnected.on(e=>{e.component instanceof oE.tX8&&(e.component.groups=nx),e.component instanceof oE.gWp&&function(e){e.registerEntry({when:()=>!0,render:e=>{let t=e.service.std.command.chain();return nx.reduce((a,r)=>{let o=r.items.filter(a=>a.showWhen?.(t,"edgeless",e.host));return o.length>0&&a.push({...r,items:o}),a},[]).every(e=>0===e.items.length)?null:(0,o_.qy)``}})}(e.component),e.component instanceof oE.wYV&&nN(e.component),e.component instanceof oE.IfI&&nU(e.component)})}},nG={...oE.jlj,setup(e,t){oE.jlj.setup?.(e,t),e.mounted.on(({service:e})=>{(0,oA.nn)(e,oE.b16),e.placeholderGenerator=e=>"text"===e.type?"Type '/' for commands":({h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",quote:""})[e.type]})}},nH={...oE.YXb,setup(e,t){oE.YXb.setup?.(e,t),e.widgetConnected.on(e=>{e.component instanceof oE.sq2&&function(e){let t=()=>{let{host:t}=e,{selection:a}=t,r=e.block;a.setGroup("note",[a.create("image",{blockId:r.blockId})])};e.buildDefaultConfig(),e.addConfigItems([{type:"custom",render:(e,a)=>(0,o_.qy)`{e.stopPropagation(),t(),a?.()}} >`,showWhen:e=>!e.doc.readonly}],0)}(e.component)})}};var nZ=a(22805);function nK(e,t,a,r){return(nK=function(){function e(e,t){return function(r){(function(e,t){if(e.v)throw Error("attempted to call "+t+" after decoration was finished")})(t,"addInitializer"),a(r,"An initializer"),e.push(r)}}function t(t,a,r,o,i,s,n,l,c){switch(i){case 1:d="accessor";break;case 2:d="method";break;case 3:d="getter";break;case 4:d="setter";break;default:d="field"}var d,m,p,u={kind:d,name:n?"#"+a:a,static:s,private:n,metadata:l},h={v:!1};u.addInitializer=e(o,h),0===i?n?(m=r.get,p=r.set):(m=function(){return this[a]},p=function(e){this[a]=e}):2===i?m=function(){return r.value}:((1===i||3===i)&&(m=function(){return r.get.call(this)}),(1===i||4===i)&&(p=function(e){r.set.call(this,e)})),u.access=m&&p?{get:m,set:p}:m?{get:m}:{set:p};try{return t(c,u)}finally{h.v=!0}}function a(e,t){if("function"!=typeof e)throw TypeError(t+" must be a function")}function r(e,t){var r=typeof t;if(1===e){if("object"!==r||null===t)throw TypeError("accessor decorators must return an object with get, set, or init properties or void 0");void 0!==t.get&&a(t.get,"accessor.get"),void 0!==t.set&&a(t.set,"accessor.set"),void 0!==t.init&&a(t.init,"accessor.init")}else if("function"!==r)throw TypeError((0===e?"field":10===e?"class":"method")+" decorators must return a function or void 0")}function o(e,t){t&&e.push(function(e){for(var a=0;a3,b=f>=5;if(b?(p=e,f-=5,u=m=m||[]):(p=e.prototype,u=d=d||[]),0!==f&&!y){var v=b?l:n,k=v.get(g)||0;if(!0===k||3===k&&4!==f||4===k&&3!==f)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+g);!k&&f>2?v.set(g,f):v.set(g,!0)}!function(e,a,o,i,s,n,l,c,d){var m,p,u,h,f,g,y=o[0];if(l?m=0===s||1===s?{get:o[3],set:o[4]}:3===s?{get:o[3]}:4===s?{set:o[3]}:{value:o[3]}:0!==s&&(m=Object.getOwnPropertyDescriptor(a,i)),1===s?u={get:m.get,set:m.set}:2===s?u=m.value:3===s?u=m.get:4===s&&(u=m.set),"function"==typeof y)void 0!==(h=t(y,i,m,c,s,n,l,d,u))&&(r(s,h),0===s?p=h:1===s?(p=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h);else for(var b=y.length-1;b>=0;b--)void 0!==(h=t(y[b],i,m,c,s,n,l,d,u))&&(r(s,h),0===s?g=h:1===s?(g=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h,void 0!==g&&(void 0===p?p=g:"function"==typeof p?p=[p,g]:p.push(g)));if(0===s||1===s){if(void 0===p)p=function(e,t){return t};else if("function"!=typeof p){var v=p;p=function(e,t){for(var a=t,r=0;r0){for(var s=[],n=t,l=t.name,c=a.length-1;c>=0;c--){var d={v:!1};try{var m=a[c](n,{kind:"class",name:l,addInitializer:e(s,d),metadata:o})}finally{d.v=!0}void 0!==m&&(r(10,m),n=m)}return[i(n,o),function(){for(var e=0;e3,b=f>=5;if(b?(p=e,f-=5,u=m=m||[]):(p=e.prototype,u=d=d||[]),0!==f&&!y){var v=b?l:n,k=v.get(g)||0;if(!0===k||3===k&&4!==f||4===k&&3!==f)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+g);!k&&f>2?v.set(g,f):v.set(g,!0)}!function(e,a,o,i,s,n,l,c,d){var m,p,u,h,f,g,y=o[0];if(l?m=0===s||1===s?{get:o[3],set:o[4]}:3===s?{get:o[3]}:4===s?{set:o[3]}:{value:o[3]}:0!==s&&(m=Object.getOwnPropertyDescriptor(a,i)),1===s?u={get:m.get,set:m.set}:2===s?u=m.value:3===s?u=m.get:4===s&&(u=m.set),"function"==typeof y)void 0!==(h=t(y,i,m,c,s,n,l,d,u))&&(r(s,h),0===s?p=h:1===s?(p=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h);else for(var b=y.length-1;b>=0;b--)void 0!==(h=t(y[b],i,m,c,s,n,l,d,u))&&(r(s,h),0===s?g=h:1===s?(g=h.init,u={get:h.get||u.get,set:h.set||u.set}):u=h,void 0!==g&&(void 0===p?p=g:"function"==typeof p?p=[p,g]:p.push(g)));if(0===s||1===s){if(void 0===p)p=function(e,t){return t};else if("function"!=typeof p){var v=p;p=function(e,t){for(var a=t,r=0;r0){for(var s=[],n=t,l=t.name,c=a.length-1;c>=0;c--){var d={v:!1};try{var m=a[c](n,{kind:"class",name:l,addInitializer:e(s,d),metadata:o})}finally{d.v=!0}void 0!==m&&(r(10,m),n=m)}return[i(n,o),function(){for(var e=0;e