1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6305],{417251:(e,t,r)=>{r.d(t,{N:()=>a});var n=r(920985);let l=[{name:"Marketing",templates:{Storyboard:()=>r.e(4861).then(r.bind(r,404861)).then(e=>e.default),"4P Marketing Matrix":()=>r.e(61003).then(r.bind(r,661003)).then(e=>e.default),"User Journey Map":()=>r.e(22840).then(r.bind(r,222840)).then(e=>e.default)}},{name:"Project management",templates:{Gantt:()=>r.e(91017).then(r.bind(r,691017)).then(e=>e.default),Kanban:()=>r.e(88089).then(r.bind(r,288089)).then(e=>e.default),"Monthly Calendar":()=>r.e(48540).then(r.bind(r,148540)).then(e=>e.default),Fishbone:()=>r.e(99262).then(r.bind(r,899262)).then(e=>e.default),"Project Planning":()=>r.e(61207).then(r.bind(r,861207)).then(e=>e.default)}},{name:"Brainstorming",templates:{SWOT:()=>r.e(97775).then(r.bind(r,97775)).then(e=>e.default),"5W2H":()=>r.e(71316).then(r.bind(r,871316)).then(e=>e.default),"Flow Chart":()=>r.e(1327).then(r.bind(r,301327)).then(e=>e.default),"Concept Map":()=>r.e(397).then(r.bind(r,100397)).then(e=>e.default),"SMART Principles":()=>r.e(73639).then(r.bind(r,173639)).then(e=>e.default)}},{name:"Presentation",templates:{"Data Analysis":()=>r.e(49175).then(r.bind(r,149175)).then(e=>e.default),"Simple Presentation":()=>r.e(97583).then(r.bind(r,997583)).then(e=>e.default),"Business Proposal":()=>r.e(13193).then(r.bind(r,513193)).then(e=>e.default)}},{name:"Paws and pals",templates:()=>r.e(19166).then(r.bind(r,719166)).then(e=>e.default)}],o=[],i=e=>e.reduce((e,t)=>t?e.concat(t):e,[]),a={list:async e=>{let t=i(await Promise.all(o.map(t=>t.list(e)))),r=l.find(t=>t.name===e);return r?(r.templates instanceof Function?await r.templates():await Promise.all((0,n.HP)(r.templates).map(e=>r.templates[e]()))).concat(t):t},categories:async()=>{let e=i(await Promise.all(o.map(e=>e.categories())));return l.map(e=>e.name).concat(e)},search:async(e,t)=>{let r=i(await Promise.all(o.map(r=>r.search(e,t))));return e=e.trim().toLocaleLowerCase(),await Promise.all(l.map(async l=>{if((!t||t===l.name)&&!(l.templates instanceof Function))return Promise.all((0,n.HP)(l.templates).map(async t=>{if(function(e,t){let r=Array.from({length:e.length+1},()=>Array.from({length:t.length+1},()=>0));for(let n=1;n<=e.length;n++)for(let l=1;l<=t.length;l++)e[n-1]===t[l-1]?r[n][l]=r[n-1][l-1]+1:r[n][l]=Math.max(r[n-1][l],r[n][l-1]);return r[e.length][t.length]}(e,t.toLocaleLowerCase())===e.length){let e=await l.templates[t]();r.push(e)}}))})),r},extend(e){o.includes(e)||o.push(e)}}},673939:(e,t,r)=>{r.r(t),r.d(t,{default:()=>R});var n=r(695155),l=r(212115),o=r(307352),i=r(666136),a=r(576546),s=r(202366),c=r(279575),u=r(602852),d=r(334367),f=r(83391),p=r(451538),h=r(255205),m=r(311536);r(517686);var g=r(798925),v=r(405622),y=r(361789),x=r(757531);async function b(e){let t="images/".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2),".png"),r=(0,v.KR)(y.IG,t);return await (0,v.D)(r,e,{contentType:e.type}),await (0,v.qk)(r)}var w=r(7266),k=r(820385),j=r(76046),E=r(166603),S=r(822743),N=r(318813),C=r(456461),A=r(321169),B=r(16419),O=r(904515),T=r(658807),I=r(186514),M=r(947556);customElements.get("affine-editor-container")||((0,I.z)(),(0,M.z)());let D="BlockSuite.tsx",R=e=>{var t;let{isDrawerOpen:r,setIsDrawerOpen:v,chapter:y,chapterWidth:I,frameName:M,noteId:R,setNoteId:z,afterNoteWritting:L,setAfterNoteWritting:U,defaultMode:P,isFocusOnly:F}=e,J=(0,w.useTranslations)(),W=(0,j.useSearchParams)(),[Y,q]=(0,l.useState)(!1),H=(0,f.d4)(T.CS),V=(0,l.useRef)(null),_=(0,l.useRef)(null),K=(0,l.useRef)(null),$=(0,l.useRef)(null),G=(0,l.useRef)(null),Q=(0,l.useRef)(null),X=(0,l.useRef)(!0),Z=(0,f.d4)(p.$R),ee=(0,l.useRef)(null),et=(0,l.useRef)({}),er=(0,l.useRef)({}),en=(0,l.useRef)({}),el=(0,l.useRef)({}),eo=(0,l.useRef)({}),ei=(0,l.useRef)(new Set),ea=(0,l.useRef)(0),es=(0,l.useRef)(null),ec=null!==(t=W.get("token"))&&void 0!==t?t:"",{isExpanded:eu,toggle:ed}=(0,S.KZ)(),[ef,ep]=(0,l.useState)(!1),eh=(0,f.d4)(O.IT),[em,eg]=(0,l.useState)(),ev=(0,f.wA)(),ey=(0,l.useCallback)(()=>{if(P)return P;if(em&&H.length>0){let e=H.find(e=>(null==e?void 0:e.id)===(null==em?void 0:em.id));return(null==e?void 0:e.mode)||"edgeless"}return"edgeless"},[em,H,P]),[ex,eb]=(0,l.useState)(P||"edgeless"),[ew,ek]=(0,l.useState)("light");(0,l.useEffect)(()=>
1{if(em&&H.length>0){let e=H.find(e=>(null==e?void 0:e.id)===(null==em?void 0:em.id));(null==e?void 0:e.theme)&&ek(e.theme)}document.documentElement.dataset.theme="light"},[em,H]);let ej=(0,l.useRef)(ex);(0,l.useEffect)(()=>{let e=ey();eb(e),ej.current=e,$.current&&($.current.mode=e)},[em,H,ey,P]);let eE=(0,l.useCallback)(async()=>{let e="edgeless"===ex?"page":"edgeless";if(eb(e),ej.current=e,$.current&&($.current.mode=e),em)try{await (0,g.w3)({id:null==em?void 0:em.id,mode:e},ec)}catch(e){console.error("Failed to save mode:",e)}},[ex,em,ec]),eS=(0,l.useCallback)(async()=>{let e="dark"===ew?"light":"dark";if(ek(()=>(document.documentElement.dataset.theme=e,e)),em)try{await (0,g.w3)({id:null==em?void 0:em.id,theme:e},ec)}catch(e){console.error("Failed to save theme:",e)}},[ew,em,ec]);(0,l.useEffect)(()=>{ej.current=ex},[ex]);let eN=(0,l.useCallback)((e,t)=>{let r={};return Object.entries(e||{}).forEach(e=>{let[n,l]=e;r[t[n]||n]=l}),r},[]),eC=(0,l.useCallback)(()=>{let e=K.current,t=_.current;if(!e||!t)return;let r=new Set,n=async n=>{if(r.has(n))return;let l=e.getBlockById(n);if(!l||"affine:image"!==l.flavour)return;let o=!1,i=!1,a=async()=>{if(o||i)return;let e=l.sourceId;if(e){o=!0,r.add(n);try{let r=await t.blobSync.get(e);if(!r){console.error("â Blob not found for sourceId:",e);return}let n=await b(r);eo.current[e]=n,et&&(et.current[e]=n),i=!0,s&&s.dispose()}catch(e){console.error("â Error uploading image:",e),o=!1}}},s=l.propsUpdated.on(()=>{i||a()});await a()},l=e.slots.yBlockUpdated.on(e=>{let{type:t,id:r}=e;"add"===t&&n(r)});return()=>{null==l||l.dispose()}},[]),eA=()=>{let e=new o.S;e.register(c.g);let t="notes-collection-".concat(Date.now()),r=new i.r({id:t,schema:e});return r.meta.initialize(),_.current=r,r},eB=async(e,t,r,n,l)=>{let o;if(!t||!e||!r)return;let s=e[r];if(!s)return;let{"sys:flavour":c,"sys:children":u,"sys:id":d,...f}=s,p={};if("affine:paragraph"===c)f["prop:text"]&&(p.text=new a.E(f["prop:text"])),f["prop:type"]&&(p.type=f["prop:type"]);else if("affine:image"===c){let e=f["prop:sourceId"],t=null;if(e&&(null==et?void 0:et.current)&&et.current[e]?t=et.current[e]:e&&eo.current[e]&&(t=eo.current[e]),t&&"string"==typeof t&&""!==t.trim())try{let e=await fetch(t);if(!e.ok)throw Error("Failed to fetch image: ".concat(e.status));let r=await e.blob(),n=await (null==l?void 0:l.blobSync.set(r));p.sourceId=n,n&&(eo.current[n]=t),et&&n&&(et.current[n]=t)}catch(e){console.error("Error loading image:",e)}f["prop:xywh"]&&(p.xywh=f["prop:xywh"]),f["prop:width"]&&(p.width=f["prop:width"]),f["prop:height"]&&(p.height=f["prop:height"]),void 0!==f["prop:rotate"]&&(p.rotate=f["prop:rotate"]),f["prop:size"]&&(p.size=f["prop:size"]),f["prop:caption"]&&(p.caption=f["prop:caption"]),f["prop:index"]&&(p.index=f["prop:index"])}else"affine:list"===c?(p.type=f["prop:type"]||"bulleted",p.text=new a.E(f["prop:text"]),p.checked=f["prop:checked"]||!1,p.collapsed=f["prop:collapsed"]||!1):"affine:surface"===c||("affine:frame"===c?(f["prop:title"]&&(p.title=new a.E(f["prop:title"])),f["prop:background"]&&(p.background=f["prop:background"]),f["prop:xywh"]&&(p.xywh=f["prop:xywh"]),f["prop:index"]&&(p.index=f["prop:index"])):Object.keys(f).forEach(e=>{e.startsWith("prop:")&&(p[e.replace("prop:","")]=f[e])}));try{o=await t.addBlock(c,p,n),d&&d!==o&&"affine:surface"!==c&&(el.current[d]=o),"affine:frame"===c&&d!==o&&er.current[d]&&(er.current[o]=er.current[d],en.current[o]=er.current[d],delete er.current[d],delete en.current[d])}catch(e){console.error("Failed to add block with flavour ".concat(c,":"),e);return}if("affine:surface"===c&&(Q.current=o,f["prop:elements"])){let e=f["prop:elements"],r="$blocksuite:internal:native$"===e.type?e.value:e;setTimeout(()=>{var e,n;if(!X.current||!_.current||!t||!t.root)return;let l=t.getBlockById(o);if(!l||"function"!=typeof l.addElement||!l.yBlock||!l.elements)return;let s=0,c=0,u=Object.entries(r),d=u.filter(e=>{let[,t]=e;return(null==t?void 0:t.type)!=="connector"&&(null==t?void 0:t.type)!=="mindmap"&&(null==t?void 0:t.type)!=="group"}),f=u.filter(e=>{let[,t]=e;return(null==t?void 0:t.type)==="group"}
1),p=u.filter(e=>{let[,t]=e;return(null==t?void 0:t.type)==="connector"}),h=u.filter(e=>{let[,t]=e;return(null==t?void 0:t.type)==="mindmap"}),m=null===(n=l.elements)||void 0===n?void 0:null===(e=n.getValue)||void 0===e?void 0:e.call(n);if(!m)return;let g=e=>{if("string"!=typeof e)return e;let t=e.trim();if(!t||!(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]")))return e;try{return JSON.parse(t)}catch(t){return e}},v=e=>{if(!e||e instanceof i.r.Y.Text)return e;if(e instanceof a.E)return e.yText;if(Array.isArray(e)){let t=new i.r.Y.Text;return t.applyDelta(e),t}return"string"==typeof e?new i.r.Y.Text(e):e},y=e=>{let[t,r]=e;if(X.current)try{if(!r||"object"!=typeof r||!r.type)return;let e={...r};if(e.id||(e.id=t),e.source&&(e.source=g(e.source)),e.target&&(e.target=g(e.target)),e.text&&(e.text=g(e.text)),"string"==typeof e.points)try{e.points=JSON.parse(e.points)}catch(e){}if("brush"===e.type&&e.xywh&&Array.isArray(e.points))try{let[t,r]="string"==typeof e.xywh?JSON.parse(e.xywh):e.xywh;e.points=e.points.map(e=>[e[0]+t,e[1]+r])}catch(e){}if("group"===e.type){if(e.children&&!(e.children instanceof i.r.Y.Map)){let t=new i.r.Y.Map;Object.keys(e.children).forEach(e=>{t.set(e,!0)}),e.children=t}if(void 0!==e.title&&!(e.title instanceof i.r.Y.Text)){var n;e.title=new i.r.Y.Text(String(null!==(n=e.title)&&void 0!==n?n:""))}}if("mindmap"===e.type&&e.children)try{let t=new i.r.Y.Map;Object.entries(e.children).forEach(e=>{let[r,n]=e,l=n.parent?n.parent:void 0;t.set(r,{index:n.index,...l?{parent:l}:{}})}),e.children=t}catch(e){}if(X.current&&l&&m)try{if(m.has(t))return;let r=new i.r.Y.Map;r.set("type",e.type),r.set("id",t),Object.entries(e).forEach(t=>{let[n,l]=t;if(void 0!==l){if(("text"===e.type||"shape"===e.type)&&"text"===n){r.set("text",v(l));return}r.set(n,l)}}),m.set(t,r),s++}catch(e){c++}}catch(e){c++}},x=e=>{var r,n;let l=null==e?void 0:null===(r=e.source)||void 0===r?void 0:r.id,o=null==e?void 0:null===(n=e.target)||void 0===n?void 0:n.id,i=!l||m.has(l)||t.getBlockById(l),a=!o||m.has(o)||t.getBlockById(o);return i&&a},b=e=>Object.keys(e.children||{}).every(e=>!e||m.has(e)||t.getBlockById(e)),w=e=>Object.keys(e.children||{}).every(e=>!e||m.has(e)||t.getBlockById(e));t.transact(()=>{d.forEach(y)});let k=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!X.current||!m)return;let n=[];t.transact(()=>{e.forEach(e=>{let[t,r]=e;if(!m.has(t)){if(!x(r)){n.push([t,r]);return}y([t,r])}})}),n.length>0&&r<5&&setTimeout(()=>{k(n,r+1)},200)},j=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!X.current||!m)return;let n=[];t.transact(()=>{e.forEach(e=>{let[t,r]=e;if(!m.has(t)){if(!b(r)){n.push([t,r]);return}y([t,r])}})}),n.length>0&&r<5&&setTimeout(()=>{j(n,r+1)},200)},E=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!X.current||!m)return;let n=[];t.transact(()=>{e.forEach(e=>{let[t,r]=e;if(!m.has(t)){if(!w(r)){n.push([t,r]);return}y([t,r])}})}),n.length>0&&r<5&&setTimeout(()=>E(n,r+1),200)};k(p),j(h),E(f)},500)}if(u&&Array.isArray(u)&&u.length>0)for(let r of u)await eB(e,t,r,o,l)},eO=(0,l.useCallback)(()=>{try{var e,t,r,n;let l=K.current;if(!l)return;null===(t=l.history)||void 0===t||null===(e=t.clear)||void 0===e||e.call(t),null===(n=l.undoManager)||void 0===n||null===(r=n.clear)||void 0===r||r.call(n)}catch(e){}},[]);(0,l.useEffect)(()=>{if(!V.current)return;let e=()=>{var e;let t=null===(e=V.current)||void 0===e?void 0:e.querySelector("affine-edgeless-root");t&&("false"!==t.getAttribute("contenteditable")&&t.setAttribute("contenteditable","false"),t.querySelectorAll("affine-edgeless-note").forEach(e=>{let t=e.querySelector(".edgeless-note-page-content");t&&"true"!==t.getAttribute("contenteditable")&&t.setAttribute("contenteditable","true")}))},t=new MutationObserver(e);return t.observe(V.current,{subtree:!0,attributes:!0,attributeFilter:["contenteditable"],childList:!0}),e(),()=>t.disconnect()},[V]);let eT=async(e,t)=>{ep(!0);let r=K.current;if(!r)return console.error("Page is null");try{if(await r.load(),!e)return;let n=Object.values(e).find(e=>"affine:page"===e["sys:flavour"]);if(!n)throw Error("No affine:page block found");let l={title:n["prop:title"]?new a.E(n["prop:title"]):new a.E},o=r.addBlock("affine:page",l);if(G.current=o,n["sys:children"]&&Array.isArray(n["sys:children"])&&n["sys:children"].length>0)for(let l of n["sys:children"])await eB(e,r,l,o,t);eC();let i=new s.m;if(i.doc=r,i.mode=ej.current,$.current=i,V.current)V.current.innerHTML="",V.current.appendChild(i);else throw Error("Editor container not found");setTimeout(()=>eO(),700)}catch(e){(0,x.v)("".concat(D," - loadEditor Error"),e),console.error("Error loading editor with notes:",e),await eI()}finally{ep(!1)}},eI=async()=>{let e=K.current;if(e)try{await e.load();let t=e.addBlock("affine:page",{title:new a.E("My Notes")});G.current=t;let r=e.addBlock("affine:surface",{},t);Q.current=r;let n=e.addBlock("affine:note",{xywh:"[0,0,498,92]",background:"--affine-note-background-white",edgeless:{style:{borderRadius:8,borderSize:4,borderStyle:"none",shadowType:"--affine-note-shadow-box"}}},t);e.addBlock("affine:paragraph",{text:new a.E("New Card")},n),eC();let l=new s.m;if(l.doc=e,l.mode=ej.current,$.current=l,V.current)V.current.innerHTML="",V.current.appendChild(l);else throw Error("Editor container not found");setTimeout(()=>eO(),100)}catch(e){(0,x.v)("".concat(D," - initializeEditor Error"),e),console.error("Error initializing editor:",e)}},eM=async e=>{let t=K.current,r=Q.current,n=_.current;if(t&&r&&n)try{let l=await fetch(e);if(!l.ok)throw Error("Failed to fetch image");let o=await l.blob(),i=await n.blobSync.set(o),a=new Image,s=URL.createObjectURL(o);await new Promise((e,t)=>
1{a.onload=e,a.onerror=t,a.src=s});let{naturalWidth:c,naturalHeight:u}=a,d=await b(o);eo.current[i]=d,et.current[i]=d,t.addBlock("affine:image",{sourceId:i,xywh:"[".concat(500*Math.random(),",").concat(500*Math.random(),",").concat(c,",").concat(u,"]"),width:c,height:u},r),q(!1),URL.revokeObjectURL(s)}catch(e){(0,x.v)("".concat(D," - addImageBlock Error"),e),console.error("Error adding image block:",e)}else console.error("Page, surfaceBlockId, or workspace is null")},eD=async()=>{let e=K.current;if(e&&em){let t=e.spaceDoc.toJSON().blocks,r=(0,E.bJ)(t),n=eN(er.current,el.current);er.current=n,en.current={...n};let l=new Set;Object.values(r||{}).forEach(e=>{((null==e?void 0:e["sys:flavour"])==="affine:image"||(null==e?void 0:e["sys:flavour"])==="affine:edgeless-image")&&((null==e?void 0:e["prop:sourceId"])&&l.add(e["prop:sourceId"]),(null==e?void 0:e["sys:id"])&&l.add(e["sys:id"]))});let o={};if(Object.entries(et.current).forEach(e=>{let[t,r]=e;l.has(t)&&(o[t]=r)}),em.isNew){let e={name:em.name,blocks:r,frameDescriptions:n,imageUrls:o,imageAlts:em.imageAlts||{},refChapterId:null==y?void 0:y.id,historyId:null==eh?void 0:eh.id,mode:em.mode||"edgeless"},t=await (0,g.Cq)(e,ec);if(null==t?void 0:t.data){let e=t.data;ev((0,T.tS)(null==H?void 0:H.map(t=>(null==t?void 0:t.id)===(null==em?void 0:em.id)?e:t))),eg(e),z(e.id),(0,k.m)("success",J("common.saveSuccess"))}else(0,k.m)("error",J("common.saveFailed"))}else{let e={id:null==em?void 0:em.id,blocks:r,frameDescriptions:n,imageUrls:o},t=await (0,g.w3)(e,ec);t?(ev((0,T.tS)(null==H?void 0:H.map(e=>{var r;return(null==e?void 0:e.id)===(null==t?void 0:null===(r=t.data)||void 0===r?void 0:r.id)?null==t?void 0:t.data:e}))),(0,k.m)("success",J("common.updateSuccess"))):(console.error("Update failed"),(0,k.m)("error",J("common.updateFailed")))}}},eR=(0,l.useCallback)(async e=>{e.preventDefault();let t=e.dataTransfer.getData("text/plain");if(!t)return;let r=K.current,n=Q.current,l=_.current;if(!r||!n||!l){console.error("Doc, surfaceBlockId, or collection is null");return}try{var o;let i=await fetch(t);if(!i.ok)throw Error("Failed to fetch image");let a=await i.blob(),s=await l.blobSync.set(a),c=new Image,u=URL.createObjectURL(a);await new Promise((e,t)=>{c.onload=e,c.onerror=t,c.src=u});let{naturalWidth:d,naturalHeight:f}=c,p=await b(a);eo.current[s]=p,et.current[s]=p;let h=null===(o=V.current)||void 0===o?void 0:o.getBoundingClientRect();if(!h)return;let m=e.clientX-h.left,g=e.clientY-h.top;r.addBlock("affine:image",{sourceId:s,xywh:"[".concat(m,",").concat(g,",").concat(d,",").concat(f,"]"),width:d,height:f},n),URL.revokeObjectURL(u)}catch(e){(0,x.v)("".concat(D," - handleDrop Error"),e),console.error("Error adding dropped image:",e)}},[]);return(0,l.useEffect)(()=>{if(null==H?void 0:H.length){let e=null==H?void 0:H[0];if(R){let t=null==H?void 0:H.find(e=>(null==e?void 0:e.sourceId)===R||(null==e?void 0:e.id)==R);t&&(e=t)}z(null==e?void 0:e.id),(null==e?void 0:e.imageUrls)?(et.current=e.imageUrls,eo.current={...e.imageUrls}):(et.current={},eo.current={}),ei.current=new Set,ea.current=0,(null==e?void 0:e.frameDescriptions)?(er.current=e.frameDescriptions,en.current={...e.frameDescriptions}):(er.current={},en.current={}),el.current={}}function e(e){ee.current&&!ee.current.contains(e.target)&&q(!1)}return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]),(0,l.useEffect)(()=>{if(L&&((null==eh?void 0:eh.noteIds)||L)){if(V.current&&$.current){try{var e,t,r,n,l,o;let i=null===(n=$.current)||void 0===n?void 0:null===(r=n.host)||void 0===r?void 0:null===(t=r.std)||void 0===t?void 0:null===(e=t.getOptional)||void 0===e?void 0:e.call(t,u.U);null==i||null===(o=i.gfx)||void 0===o||null===(l=o.tool)||void 0===l||l.setTool("default")}catch(e){}V.current.removeChild($.current),$.current=null}es.current=null,G.current=null,Q.current=null,et.current={},eo.current={},ei.current=new Set,ea.current=0,eg(null),U(!1)}},[null==eh?void 0:eh.noteIds,L]),(0,l.useEffect)(()=>{R&&(null==H?void 0:H.length)&&eg(null==H?void 0:H.find(e=>(null==e?void 0:e.id)===R||(null==e?void 0:e.sourceId)===R))},[R,H]),(0,l.useEffect)(()=>
1{if(X.current=!0,!H.length||!(null==em?void 0:em.id)||$.current&&es.current===(null==em?void 0:em.id))return;V.current&&$.current&&(V.current.removeChild($.current),$.current=null),_.current&&("function"==typeof _.current.dispose&&_.current.dispose(),_.current=null),K.current&&(K.current=null),es.current=(null==em?void 0:em.id)||null,el.current={},ea.current=0,ei.current=new Set;let e=H.find(e=>(null==e?void 0:e.id)==(null==em?void 0:em.id));(null==e?void 0:e.imageUrls)?(et.current=e.imageUrls,eo.current={...e.imageUrls}):(et.current={},eo.current={}),(null==e?void 0:e.frameDescriptions)?(er.current=e.frameDescriptions,en.current={...e.frameDescriptions}):(er.current={},en.current={});let t=eA(),r=t.createDoc({id:"page0"});K.current=r,H?(r.clear(),eT((0,E.VJ)(null==e?void 0:e.blocks),t)):eI()},[null==em?void 0:em.id]),(0,l.useEffect)(()=>{if(M&&r){var e,t,n,l,o,i,a,s,c,d,f,p;let r=null===(l=$.current)||void 0===l?void 0:null===(n=l.host)||void 0===n?void 0:null===(t=n.std)||void 0===t?void 0:null===(e=t.getOptional)||void 0===e?void 0:e.call(t,u.U);if(!r)return;if("end"===M){null==r||null===(i=r.gfx)||void 0===i||null===(o=i.tool)||void 0===o||o.setTool({type:"default"});return}let h=(null!==(a=r.frames)&&void 0!==a?a:[]).find(e=>{var t;return(null===(t=e.title)||void 0===t?void 0:t.toString())===M});if(h){if(F){null==r||null===(c=r.gfx)||void 0===c||null===(s=c.tool)||void 0===s||s.setTool({type:"default"});try{if(null===(d=r.selection)||void 0===d||d.set({elements:[h.id],editing:!1}),h.xywh){let e="string"==typeof h.xywh?h.xywh:JSON.stringify(h.xywh),t=JSON.parse(e);Array.isArray(t)&&t.length>=4&&r.gfx.viewport.setViewportByBound({x:t[0],y:t[1],w:t[2],h:t[3]},[80,80,80,80],!0)}}catch(e){console.error("Focus frame failed",e)}}else null==r||null===(p=r.gfx)||void 0===p||null===(f=p.tool)||void 0===f||f.setTool({type:"frameNavigator",mode:"fit",frameBlockTitle:M})}}},[M,r,F]),(0,l.useMemo)(()=>{let e=eu?770:570,t="number"==typeof I&&I>0?I-480:0;return"calc(100vw - ".concat(e+t,"px)")},[eu,I]),(0,n.jsxs)("div",{className:"h-full w-full relative flex flex-col",children:[r&&(0,n.jsx)("div",{className:"absolute top-1 right-2 z-[102] cursor-pointer",children:(0,n.jsx)(d.WQq,{size:30,onClick:()=>{v(!1),ed(!1),z(null)},className:"text-gray-400 blocksuite-toolbar"})}),ef&&(0,n.jsxs)("div",{className:"absolute z-[103] w-full h-full flex flex-col items-center justify-center gap-4 text-[#ff6b35] bg-white",children:[(0,n.jsx)(N.A,{indicator:(0,n.jsx)(B.A,{style:{fontSize:40,color:"#ff6b35"},spin:!0})}),"ãã¼ããéãã¦ããã¾ããå°ã
ãå¾
ã¡ãã ããã"]}),(0,n.jsxs)("div",{className:(0,h.A)("flex-1 overflow-y-auto overflow-x-hidden border border-gray-200 shadow-sm","dark"===ew?"bg-[#141414]":"bg-white"),style:"dark"===ew?{"--affine-background-primary-color":"rgb(20, 20, 20)","--affine-edgeless-grid-color":"rgba(49, 49, 49, .35)"}:void 0,onDrop:eR,onDragOver:E.ji,children:[(0,n.jsx)("div",{ref:V,className:"h-full w-full min-h-[400px]"}),(0,n.jsxs)("div",{className:"absolute bottom-[100px] right-2 text-gray-800 rounded-lg border border-gray-300 bg-gray-100 z-10 w-[80px] flex flex-col items-center gap-2 p-2 blocksuite-toolbar overflow-y-auto max-h-[calc(100vh-200px)]",children:[(0,n.jsx)("button",{onClick:()=>{let e="temp_".concat(Date.now()),t={id:e,name:"".concat(J("common.newNote")," ").concat(H.length+1),blocks:{},frameDescriptions:{},imageUrls:{},imageAlts:{},refChapterId:null==y?void 0:y.id,historyId:null==eh?void 0:eh.id,mode:"edgeless",isNew:!0};ev((0,T.tS)([...H,t])),eg(t),z(e),er.current={},en.current={},el.current={},et.current={},eo.current={},ei.current=new Set,ea.current=0},className:"w-full aspect-square rounded-md border border-dashed border-gray-400 flex items-center justify-center text-2xl text-gray-600 hover:bg-gray-200",children:(0,n.jsx)(A.tNe,{size:20})}),H.map(e=>{var t;let r=(null==e?void 0:e.name)||(null==e?void 0:e.id);return(0,n.jsx)(C.A,{title:r,placement:"right",color:"#fff",children:(0,n.jsx)("div",{className:(0,h.A)("w-full aspect-square bg-gray-200 rounded-md flex items-center justify-center text-xl font-bold cursor-pointer",{"bg-gray-400":(null==e?void 0:e.id)==(null==em?void 0:em.id)}),onClick:()=>z(null==e?void 0:e.id),children:null==r?void 0:null===(t=r[0])||void 0===t?void 0:t.toUpperCase()})},r)})]}),(0,n.jsxs)("div",{className:"absolute top-1 left-[20px] flex items-center gap-2 z-10 blocksuite-toolbar",children:[(0,n.jsx)("button",{onClick:eD,title:em?J("common.update"):J("common.save"),className:"rounded-lg border transition-colors w-8 h-8 flex items-center justify-center ".concat("dark"===ew?"text-gray-200 border-gray-600 hover:bg-gray-700":"text-gray-800 border-gray-300 hover:bg-gray-100"),children:(0,n.jsx)(m.dIn,{size:16,color:"dark"===ew?"#4A9EFF":"#2269E4"})}),(0,n.jsx)("button",{onClick:()=>q(e=>!e),title:J("common.image"),className:"rounded-lg border transition-colors w-8 h-8 flex items-center justify-center ".concat("dark"===ew?"text-gray-200 border-gray-600 hover:bg-gray-700":"text-gray-800 border-gray-300 hover:bg-gray-100"),children:(0,n.jsx)(m.J4C,{size:16,color:"dark"===ew?"#4DD4E4":"#22C4E4"})}),(0,n.jsx)(C.A,{title:"edgeless"===ex?J("common.blocksuiteEditor.switchToPage"):J("common.blocksuiteEditor.switchToEdgeless"),placement:"bottom",overlayClassName:"blocksuite-tooltip",children:(0,n.jsxs)("div",{onClick:eE,className:"relative w-16 h-8 flex items-center justify-between px-2 rounded-full cursor-pointer transition-colors duration-300 ".concat("dark"===ew?"bg-gray-700":"bg-gray-200 border border-gray-300"),children:[(0,n.jsx)("span",{className:"z-10 flex items-center justify-center transition-colors duration-300 ".concat("page"===ex?"dark"===ew?"text-gray-900":"text-gray-800":"text-gray-400"),children:(0,n.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,n.jsx)("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),(0,n.jsx)("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),(0,n.jsx)("span",{className:"z-10 flex items-center justify-center transition-colors duration-300 ".concat("edgeless"===ex?"dark"===ew?"text-gray-900":"text-gray-800":"text-gray-400"),children:(0,n.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,n.jsx)("line",{x1:"3",y1:"9",x2:"21",y2:"9"})]})}),(0,n.jsx)("div",{className:"absolute w-6 h-6 rounded-full bg-white shadow-md transition-all duration-300 top-[3px]",style:{left:"page"===ex?"3px":"35px"}})]})}),(0,n.jsx)(C.A,{title:"dark"===ew?J("common.blocksuiteEditor.switchToLight"):J("common.blocksuiteEditor.switchToDark"),placement:"bottom",overlayClassName:"blocksuite-tooltip",children:(0,n.jsxs)("div",{onClick:eS,className:"relative w-16 h-8 flex items-center justify-between px-2 rounded-full cursor-pointer transition-colors duration-300 ".concat("dark"===ew?"bg-gray-700":"bg-gray-200 border border-gray-300"),children:[(0,n.jsx)("span",{className:"z-10 flex items-center justify-center transition-colors duration-300 ".concat("light"===ew?"text-amber-500":"text-gray-400"),children:(0,n.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,n.jsx)("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41
1M17.66 6.34l1.41-1.41"})]})}),(0,n.jsx)("span",{className:"z-10 flex items-center justify-center transition-colors duration-300 ".concat("dark"===ew?"text-yellow-200":"text-gray-400"),children:(0,n.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}),(0,n.jsx)("div",{className:"absolute w-6 h-6 rounded-full bg-white shadow-md transition-all duration-300 top-[3px] ".concat("dark"===ew?"left-[35px]":"left-[3px]")})]})})]}),Y&&(0,n.jsxs)("div",{ref:ee,className:"absolute top-14 left-[20px] w-[300px] bg-white border border-gray-300 rounded-lg shadow-lg z-20 mt-2",children:[(0,n.jsx)("div",{className:"absolute -top-2 left-[70px] transform -translate-x-1/2 w-4 h-4 rotate-45 bg-white border-l border-t border-gray-300"}),(0,n.jsxs)("div",{className:"m-3 min-h-[100px] max-h-[450px] overflow-y-auto grid grid-cols-2 gap-2 items-center justify-center",children:[0===Z.length&&(0,n.jsx)("p",{children:J("common.noImage")}),Z.map((e,t)=>e&&(0,n.jsx)("img",{src:e,className:"w-25 h-25 object-cover rounded-lg cursor-pointer",draggable:!0,onDragStart:t=>(0,E.bS)(t,e),onClick:()=>eM(e)},t))]})]})]})]})}},166603:(e,t,r)=>{r.d(t,{VJ:()=>l,bJ:()=>o,bS:()=>i,ji:()=>a});let n=e=>{if(null==e)return e;if(Array.isArray(e))return e.map(e=>n(e));if("object"==typeof e){let t=e.constructor;if(t&&"Object"!==t.name&&"Array"!==t.name){if("function"==typeof e.getValue)return n(e.getValue());if("function"==typeof e.toJSON)return n(e.toJSON());if(e instanceof Date)return e;let t={};for(let r of Object.keys(e))t[r]=n(e[r]);return t}let r={};for(let t of Object.keys(e))r[t]=n(e[t]);return r}return e};function l(e){for(let r in e){var t;let n=e[r];if("affine:surface"===n["sys:flavour"]&&(null===(t=n["prop:elements"])||void 0===t?void 0:t.value))for(let e in n["prop:elements"].value){let t=n["prop:elements"].value[e];if("string"==typeof t.points)try{t.points=JSON.parse(t.points)}catch(t){console.error("Failed to parse points for element ".concat(e,":"),t)}}}return e}let o=e=>{let t=n(e);for(let e in t){var r;let n=t[e];if("affine:surface"===n["sys:flavour"]&&(null===(r=n["prop:elements"])||void 0===r?void 0:r.value))for(let e in n["prop:elements"].value){let t=n["prop:elements"].value[e];t.points&&Array.isArray(t.points)&&(t.points=JSON.stringify(t.points))}}return t},i=(e,t)=>{e.dataTransfer.setData("text/plain",t),e.dataTransfer.effectAllowed="move"},a=e=>{e.preventDefault(),e.dataTransfer.dropEffect="move"}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.