superdoc 2.4.0-next.1 β 2.4.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collaboration-upgrade-engine.cjs +1 -1
- package/dist/collaboration-upgrade-engine.es.js +1 -1
- package/dist/style.css +64 -64
- package/dist/style.layered.css +64 -64
- package/dist/superdoc.cjs +3 -3
- package/dist/superdoc.es.js +3 -3
- package/dist-cdn/style.layered.css +1 -1
- package/dist-cdn/superdoc.min.css +1 -1
- package/dist-cdn/superdoc.min.js +3 -3
- package/package.json +2 -2
package/dist-cdn/superdoc.min.js
CHANGED
|
@@ -11,7 +11,7 @@ ${n.toString()}`)};var bx=class{constructor(e){this.patterns=[],this.$state=e}if
|
|
|
11
11
|
|
|
12
12
|
`).replace(/^\n+/,"").replace(/\n+$/,"")};const aa=cC("comments",()=>{const e={kind:"story",storyType:"body"},t=I=>{if(!I?.trackedChange)return!1;const M=I?.trackedChangeStory?.storyType;return M==null||M==="body"?!0:I?.trackedChangeAnchorKey?.startsWith?.("tc::body::")===!0},n=I=>I==null?null:r0({storyKey:"body",rawId:String(I)}),r=I=>{const M=He(I);if(!M?.startsWith("tc::"))return null;const $=M.indexOf("::",4);if($<=4)return null;const ie=M.slice(4,$),se=M.slice($+2);return!ie||!se?null:{storyKey:ie,rawId:se}},o=(I,M)=>M==null?null:r0({storyKey:I||"body",rawId:String(M)}),i=I=>{if(!I)return null;const M=I.sourceId?String(I.sourceId):"";return M?`word:structural:${M}`:I.id?String(I.id):null},s=hu(),a=Gr({name:"comments",readOnly:!1,allowResolve:!0,showResolved:!1}),l=()=>({ok:!1,reason:"read-only-document"}),u=()=>({ok:!1,reason:"resolve-disabled"}),c=()=>a.allowResolve===!1,d=()=>a.readOnly===!0,h=Gr({documentMode:"editing",commentsVisible:!1,trackChangesVisible:!1}),m=!1,p={},v=new WeakMap,_=new Map;let C=0;const k=()=>typeof window>"u"?!1:"__labsSuperDocV2PreviewDebug"in window,y=(I,M=null)=>{if(k()){if(M!==null){console.debug("[SuperDoc][comments-store]",I,M);return}console.debug("[SuperDoc][comments-store]",I)}},b=tp,T=ne(!1),R=ne(!1),P=ne(null),j=ne(!1),O=ne(null),V=ne(null),Q=ne(null),F=ne([]),N=ne([]),x=new Set([]),z=ne(!0),J=ne(""),X=ne([]);let ae=new Map;const pe=ke(()=>{const I=N8(X.value,ae);return ae=I,I}),Fe=I=>{const M=I?.commentId??null;return(M!=null?pe.value.get(M):null)??[I].filter(Boolean)};let fe=new Map;const ye=ke(()=>{const I=B8(X.value,fe);return fe=I,I}),le=ne(!1),Se=ne([]),re=ne({}),xe=ne(!1),$e=ne(0),st=ne([]),At=ne([]),Ee=ne(!1),Ge=ne(!1),qe=ne([]),Z=ne(null),S=ne(null),ee=ne(null),D=ne(null),U=Kr(null),H=ke(()=>h.documentMode==="viewing"),G=ke(()=>H.value?h.commentsVisible||h.trackChangesVisible:!0),te=Kr(null),Y=I=>{te.value=I??null},K=I=>{const M=I?.activeEditor?.v2Comments??null;return M||te.value},be=I=>I?.activeEditor?.editorVersion===2||te.value!==null,me=Kr(null),Ce=I=>{me.value=I??null},Pe=I=>{const M=I?.activeEditor?.v2TrackedChanges??null;return M||me.value},it=(I={})=>{const M={...a,...I};Object.assign(a,M),z.value=a.suppressInternalExternal||!1,I.comments&&I.comments.length&&(X.value=I.comments?.map($=>ia($))||[])},He=I=>I==null?null:String(I),Ct=I=>Array.isArray(I)?[...new Set(I.map(M=>He(M)).filter(Boolean))]:[],Yt=I=>He(I?.id??I?.changeId??I?.address?.entityId),St=I=>Ct([Yt(I),I?.changeId,I?.address?.entityId,I?.trackedChangeAnchorKey,I?.anchorKey,I?.address?.anchorKey,...Array.isArray(I?.trackedChangePositionAliases)?I.trackedChangePositionAliases:[],...Array.isArray(I?.sourceIds?.rsids)?I.sourceIds.rsids:[],I?.sourceIds?.wordIdDelete,I?.sourceIds?.wordIdInsert,...Array.isArray(I?.sourceIds?.wordIdOther)?I.sourceIds.wordIdOther:[]]),Ft=I=>new Set(St(I).flatMap(M=>{const $=r(M);return $?.rawId?[M,$.rawId]:[M]})),Nt=I=>{const M=new Set,$=[];for(const ie of I){const se=Yt(ie);if(se){if(M.has(se))continue;M.add(se)}$.push(ie)}return $},sn=I=>{if(!I?.trackedChange)return null;const M=r(I.trackedChangeAnchorKey);if(M?.storyKey)return M.storyKey;const $=I.trackedChangeStory;switch($?.storyType){case"body":return"body";case"headerFooterPart":return $.refId?`hf:${$.refId}`:null;case"footnote":return $.noteId?`fn:${$.noteId}`:null;case"endnote":return $.noteId?`en:${$.noteId}`:null;case"textbox":return $.textboxId?`textbox:${$.textboxId}`:null;default:return null}},_n=I=>I?.startsWith("hf:part:")?`hf:${I.slice(8)}`:I?.startsWith("headerFooterPart:")?`hf:${I.slice(17)}`:I,Qt=(I,M)=>{const $=_n(I),ie=_n(M);return!$||!ie||$===ie},Ye=(I,M)=>Qt(_n(sn(M)),_n(He(I?.storyKey))),Et=I=>{const M=He(I);return M?M.startsWith("imported:")?M:`imported:${M}`:null},Ot=I=>{const M=He(I);if(!M)return{key:null,entry:null};const $=re.value||{};if($[M]!==void 0)return{key:M,entry:$[M]};for(const[ie,se]of Object.entries($)){const de=He(se?.key),he=He(se?.threadId);if(de===M||he===M)return{key:ie,entry:se}}return{key:null,entry:null}},wn=(I,M)=>{if(!I||!M)return!1;const $=Math.max(Number(I.left),Number(M.left)),ie=Math.min(Number(I.right),Number(M.right)),se=Math.max(Number(I.top),Number(M.top)),de=Math.min(Number(I.bottom),Number(M.bottom));return[$,ie,se,de].every(Number.isFinite)&&ie>$&&de>se},Kt=(I,M)=>{if(!I||!M||I.kind!=="trackedChange"||M.kind!=="trackedChange"||I.storyKey&&M.storyKey&&I.storyKey!==M.storyKey)return!1;const $=Number(I.pageIndex),ie=Number(M.pageIndex);if(Number.isFinite($)&&Number.isFinite(ie)&&$!==ie)return!1;if(wn(I.bounds,M.bounds))return!0;const se=Number(I.start),de=Number(I.end),he=Number(M.start),ue=Number(M.end);return[se,de,he,ue].every(Number.isFinite)&&se===he&&de===ue},Sn=I=>{const{entry:M}=Ot(I);if(!M)return null;const $=X.value.filter(ie=>ie?.trackedChange?kt(ie).some(se=>{const{entry:de}=Ot(se);return Kt(M,de)}):!1);return $.length===1?$[0]:null},Pt=I=>I==null?null:X.value.find(M=>M.commentId==I||M.importedId==I||M.trackedChangeAnchorKey==I||M?.trackedChange&&Et(M.importedId)==I)||Sn(I),De=I=>I?.parentCommentId?Pt(I.parentCommentId):I,je=I=>I?.trackedChangeThreadParentId?I.trackedChangeThreadParentId:uf(I)&&I?.trackedChange===!0?null:Mp(I),Ke=I=>{const M=je(I);return M?!!Pt(M)?.trackedChange:!1},pt=I=>{if(!I)return null;const M=re.value||{};if(typeof I=="string"){if(M[I])return I;const he=Pt(I);if(!he)return I;const ue=he.commentId??null,Te=he.importedId??null,Ne=he.trackedChange?Et(Te):null,Oe=he.trackedChangeAnchorKey??null;return Oe&&M[Oe]?Oe:ue&&M[ue]?ue:Te&&M[Te]?Te:Ne&&M[Ne]?Ne:Oe??ue??Ne??Te??null}const $=I.commentId??null,ie=I.importedId??null,se=I.trackedChange?Et(ie):null,de=I.trackedChangeAnchorKey??null;return de&&M[de]?de:$&&M[$]?$:ie&&M[ie]?ie:se&&M[se]?se:de??$??se??ie??null},kt=I=>{if(I==null)return[];const M=typeof I=="object"?null:I,$=typeof I=="object"?I:Pt(I),ie=$?.trackedChange?Ct($?.trackedChangePositionAliases):[],se=_n(sn($)),de=new Set;return[M,pt($),$?.trackedChangeAnchorKey,$?.commentId,$?.importedId,$?.trackedChange?Et($?.importedId):null,...ie.flatMap(he=>[se&&!he.startsWith("tc::")?r0({storyKey:se,rawId:he}):null,he])].map(he=>He(he)).filter(he=>!he||de.has(he)?!1:(de.add(he),!0))},ft=(I,M)=>{const $=re.value||{},ie=typeof I=="object"?I:Pt(I),se=new Set;for(const de of[M,...kt(I)].map(he=>He(he)).filter(Boolean)){if(se.has(de))continue;se.add(de);const he=$[de];if(he!==void 0&&Ye(he,ie))return{key:de,entry:he}}return{key:null,entry:null}},an=I=>{I&&((I.resolvedTime!=null||I.resolvedById!=null||I.resolvedByEmail!=null||I.resolvedByName!=null)&&v.set(I,{resolvedTime:I.resolvedTime??null,resolvedById:I.resolvedById??null,resolvedByEmail:I.resolvedByEmail??null,resolvedByName:I.resolvedByName??null,trackedChangeDecision:I.trackedChangeDecision??null}),I.resolvedTime=null,I.resolvedById=null,I.resolvedByEmail=null,I.resolvedByName=null,I.trackedChangeDecision=null)},qt=I=>{if(!I)return!1;const M=v.get(I);return M?(I.resolvedTime=M.resolvedTime??Date.now(),I.resolvedById=M.resolvedById??null,I.resolvedByEmail=M.resolvedByEmail??null,I.resolvedByName=M.resolvedByName??null,I.trackedChangeDecision=M.trackedChangeDecision??null,!0):!1},cn=I=>typeof I?.getValues=="function"?I.getValues():{...I},hn=I=>{const M=I?.selection?.source;return M==null?!0:M===fu},oo=I=>!!I?.trackedChange||!!je(I),Jt=({documentId:I,editor:M}={})=>{if(!M?.state||!X.value?.length)return 0;const $=re.value||{};if(!Object.keys($).length)return 0;const ie=nt=>nt.find(ln=>$[ln]!==void 0)??null,se=new Set,de=new Map;if(X.value.forEach(nt=>{if(!nt?.trackedChange)return;if(I){const Vn=nt?.fileId??null;if(Vn&&Vn!==I)return}const ln=kt(nt),nn=ie(ln);nn&&(se.add(nn),de.set(nn,new Set(ln)))}),!se.size)return 0;const he=new Set(sa.getTrackChanges(M.state).map(({mark:nt})=>nt?.attrs?.id).filter(nt=>nt!=null).map(nt=>String(nt))),ue=typeof mu=="function"?mu(M):null;let Te=[];try{Te=ue?.getAll?.()??[]}catch{}const Ne=new Set(Te.map(nt=>nt?.anchorKey).filter(nt=>typeof nt=="string"&&nt.length>0)),Oe=new Set(Array.from(se).filter(nt=>{const ln=de.get(nt)??new Set([nt]);return Array.from(ln).some(nn=>Ne.has(nn))?!1:!Array.from(ln).some(nn=>he.has(nn))}));if(!Oe.size)return 0;const Qe=new Set;Oe.forEach(nt=>{(de.get(nt)??new Set([nt])).forEach(ln=>Qe.add(ln))});const ct=new Set(Oe);X.value.forEach(nt=>{const ln=ie(kt(nt));ln&&[je(nt),nt?.threadingParentCommentId,nt?.parentCommentId].map(nn=>He(nn)).filter(Boolean).some(nn=>Qe.has(nn))&&ct.add(ln)});const yt={...$};if(ct.forEach(nt=>{delete yt[nt]}),re.value=yt,O.value!==void 0&&O.value!==null){const nt=Pt(O.value),ln=new Set(kt(nt??O.value)),nn=[je(nt),nt?.threadingParentCommentId,nt?.parentCommentId].map(Vn=>He(Vn)).filter(Boolean);(Array.from(ln).some(Vn=>Qe.has(Vn))||nn.some(Vn=>Qe.has(Vn)))&&Lo()}return ct.size},Yn=I=>{const M=I?.state?.doc;if(!M||typeof M.descendants!="function")return null;const $=new Set,ie=new Set;return M.descendants(se=>{se.marks?.filter(ue=>ue?.type?.name==="commentMark").forEach(ue=>{[ue.attrs?.commentId,ue.attrs?.importedId].map(Te=>He(Te)).filter(Boolean).forEach(Te=>$.add(Te))});const de=se.type?.name;if(de!=="commentRangeStart"&&de!=="commentRangeEnd")return;const he=He(se.attrs?.["w:id"]);he&&ie.add(he)}),{liveMarkIds:$,resolvedAnchorIds:ie}},Nr=()=>{const I=s.documents;if(!Array.isArray(I))return null;for(const M of I){const $=typeof M?.getEditor=="function"?M.getEditor():null;if($?.state?.doc)return $}return null},io=({editor:I}={})=>{if(te.value)return 0;const M=Yn(I??Nr()),$=re.value||{},ie=new Set(Object.keys($));if(!M&&!ie.size)return 0;let se=0;return X.value.forEach(de=>{if(!hn(de)||oo(de))return;if(M){const ue=kt(de),Te=ue.some(Oe=>M.liveMarkIds.has(Oe)),Ne=ue.some(Oe=>M.resolvedAnchorIds.has(Oe));if(Te&&de.resolvedTime!=null){an(de),se+=1;return}!Te&&Ne&&de.resolvedTime==null&&qt(de)&&(se+=1);return}const{key:he}=ft(de);he&&ie.has(String(he))&&de.resolvedTime!=null&&(an(de),se+=1)}),se};Lt(re,()=>{io()}),Lt(X,()=>{io()},{deep:!1});const vo=I=>{if(!I)return null;const M=I.start??I.pos??I.from,$=I.end??I.to??M;return!Number.isFinite(M)||!Number.isFinite($)?null:{start:M,end:$}},$t=I=>ft(I).entry??null,Bn=(I,M={})=>{const $=typeof I=="object"?I:Pt(I);if(!$)return null;const ie=vo(ft(I).entry??null);if(!ie)return null;const se=s.getDocument($.fileId)?.getEditor?.()?.state?.doc;if(!se?.textBetween)return null;const de=M.separator??" ",he=se.textBetween(ie.start,ie.end,de,de);return M.trim===!1?he:he?.trim()},xi=(I,M={})=>{const $=$t(I);return $?{position:$,anchoredText:Bn(I,M)}:null},Is=I=>{if(!H.value)return!0;const M=De(I);return!M&&I?.parentCommentId?!1:M?.trackedChange||je(I)?h.trackChangesVisible:h.commentsVisible},so=(I,M)=>{const $=I?.activeEditor,ie=K(I);if(M==null){if(Lo(),ie){ie.setActiveComment(null);return}$?.commands?.setActiveComment({commentId:null});return}const se=Pt(M);if(se){if(O.value=se.commentId,Wu(se.commentId),ie){ie.setActiveComment(se.commentId);return}$?.commands?.setActiveComment({commentId:O.value})}},cr=({superdoc:I,params:M,broadcastChanges:$=!0,documentState:ie=void 0})=>{const se=u_("store.trackedChanges.handleUpdate","store-reconciliation",{event:M?.event??null,changeId:M?.changeId??null,documentId:M?.documentId??null});try{const{event:de,changeId:he,trackedChangeText:ue,trackedChangeType:Te,trackedChangeDisplayType:Ne,semanticColorKey:Oe,semanticColor:Qe,deletedText:ct,trackedChangeLabel:yt,trackedChangeDetailLines:nt,trackedChangeImagePreview:ln,authorId:nn,authorEmail:Vn,authorImage:Ut,date:Cn,author:Sr,importedAuthor:Kn,documentId:dr,coords:yr,trackedChangeStory:Bo,trackedChangeStoryKind:Rn,trackedChangeStoryLabel:at,trackedChangeAnchorKey:pn,trackedChangeCanonicalId:An,trackedChangePositionAliases:Ur,importedId:oi}=M,zo=he!=null?String(he):null,Ps=An!=null?String(An):null,ka=Object.prototype.hasOwnProperty.call(M,"trackedChangePositionAliases"),bi=ka?Ct(Ur):void 0,Vo=Object.prototype.hasOwnProperty.call(M,"importedId"),Po=Vo?oi!=null?String(oi):null:void 0,Aa=dr!=null?String(dr):null;if(!(Ne==="tableInsert"||Ne==="tableDelete")&&zo){const zt=Aa??(I?.activeEditor?.options?.documentId!=null?String(I.activeEditor.options.documentId):null),Hn=zt?s.getDocument(zt)?.getEditor?.():null,Br=ie!==void 0?ie:Hn?.state??I?.activeEditor?.state??null;if(Br){const{ranges:fr,ids:jo}=Uu(Br),os=sa.getTrackChanges(Br,zo),is=fr.length>0&&os.length>0&&El(os,fr),Ta=os.length===0&&jo.has(zo);if(is||Ta){Wf({suppressedIds:new Set([zo]),activeDocumentId:zt,superdoc:I,broadcastChanges:$});return}}}const Tl=Bo!==void 0||Rn!==void 0||at!==void 0||pn!==void 0,Ho=Tl?Bo??null:e,ut=Tl?Rn??null:"body",Di=Tl&&at!==void 0?at:"",Dt=pn!==void 0?pn??null:Tl?null:n(zo),Rl=typeof yt=="string"&&yt.length>0?yt:null,Ia=K8(nt),Ea=Y8(ln),Ac=No({documentId:dr,commentId:he,trackedChange:!0,trackedChangeText:ue,trackedChangeType:Te,trackedChangeDisplayType:Ne,semanticColorKey:Oe,semanticColor:Qe,deletedText:ct,trackedChangeLabel:Rl,trackedChangeDetailLines:Ia,trackedChangeImagePreview:Ea,createdTime:Cn,creatorId:nn??null,creatorName:Sr,creatorEmail:Vn,creatorImage:Ut,isInternal:!1,importedAuthor:Kn,...Vo?{importedId:Po}:{},trackedChangeStory:Ho,trackedChangeStoryKind:ut,trackedChangeStoryLabel:Di,trackedChangeAnchorKey:Dt,trackedChangeCanonicalId:Ps,...ka?{trackedChangePositionAliases:bi}:{},selection:{source:fu,selectionBounds:yr}}),Ml=()=>{const zt=Dt!=null?String(Dt):null;if(!zo)return null;const Hn=sn(Ac),Br=fr=>{if(!fr)return!1;const jo=fr.trackedChangeAnchorKey!=null?String(fr.trackedChangeAnchorKey):null,os=fr.commentId!=null?String(fr.commentId):null,is=fr.importedId!=null?String(fr.importedId):null,Ta=fr.trackedChangeCanonicalId!=null?String(fr.trackedChangeCanonicalId):null,Ku=kt(fr),qu=Qt(sn(fr),Hn);if(qu&&Ku.includes(zo))return!0;const Yu=new Set(bi??[]);if(qu&&Yu.size>0&&[os,is,Ta,jo,...Ku].filter(Boolean).some(Oi=>Yu.has(Oi)))return!0;const Xu=Ps&&Ps!==zo||Ta&&Ta!==os;return os===zo||!Xu&&(is===zo||Po!==void 0&&Po!=null&&is===Po)?!0:Xu?!1:zt&&jo?jo===zt:!1};return Aa?X.value.find(fr=>Br(fr)&&yo(fr,Aa)):X.value.find(Br)},Ll=zt=>{$&&($l(I,zt),Ti(he,zt,I))},Pl=(zt,Hn,Br)=>zt?.[Hn]==null&&Br==null||!zt||p_(zt[Hn],Br)?!1:(zt[Hn]=Br,!0),xa=zt=>{if(!zt)return!1;let Hn=!1;return Ho!=null&&(Hn=Pl(zt,"trackedChangeStory",Ho)||Hn),ut!=null&&(Hn=Pl(zt,"trackedChangeStoryKind",ut)||Hn),Di!==void 0&&Di!==""&&(Hn=Pl(zt,"trackedChangeStoryLabel",Di)||Hn),Dt!=null&&(Hn=Pl(zt,"trackedChangeAnchorKey",Dt)||Hn),Hn},ii=zt=>{const Hn={trackedChangeText:ue??null,trackedChangeType:Te??null,trackedChangeDisplayType:Ne??null,semanticColorKey:Oe??null,semanticColor:Qe??null,deletedText:ct??null,trackedChangeLabel:Rl,trackedChangeImagePreview:Ea,trackedChangeCanonicalId:Ps,creatorId:nn??null,creatorName:Sr??null,creatorEmail:Vn??null,creatorImage:Ut??null,createdTime:Cn??null};if(Vo&&(Hn.importedId=Po),ka){const fr=new Set([zt?.commentId,zt?.importedId,zt?.trackedChangeCanonicalId,zt?.trackedChangeAnchorKey,...kt(zt)].map(jo=>He(jo)).filter(Boolean));Hn.trackedChangePositionAliases=bi.some(jo=>fr.has(jo))?Ct([...Array.isArray(zt?.trackedChangePositionAliases)?zt.trackedChangePositionAliases:[],...bi]):bi}let Br=!1;for(const[fr,jo]of Object.entries(Hn))Br=Pl(zt,fr,jo)||Br;return zt&&!(zt.trackedChangeDetailLines==null&&Ia==null)&&!q8(zt.trackedChangeDetailLines,Ia)&&(zt.trackedChangeDetailLines=Ia,Br=!0),xa(zt)||Br},wo=zt=>{const Hn=!!(zt.resolvedTime||zt.resolvedById||zt.resolvedByEmail||zt.resolvedByName);return Hn&&an(zt),ii(zt)||Hn};if(de==="add"){const zt=Ml();if(zt){if(!wo(zt))return;Ll({type:b.UPDATE,comment:cn(zt)});return}lo({superdoc:I,comment:Ac,broadcastChanges:$})}else if(de==="update"){const zt=Ml();if(!zt||!wo(zt))return;Ll({type:b.UPDATE,comment:cn(zt)})}else if(de==="resolve"){const zt=Ml(),Hn={id:M.resolvedById??I?.user?.id??null,email:M.resolvedByEmail??I?.user?.email??null,name:M.resolvedByName??I?.user?.name??null,decision:M.decision??null,superdoc:I};zt&&!zt.resolvedTime&&zt.resolveComment({...Hn,reconciliationToken:r_})}}finally{df(se)}},Qo=(I=[])=>({insertedMark:I.find(({mark:M})=>M?.type?.name==="trackInsert")?.mark??null,deletionMark:I.find(({mark:M})=>M?.type?.name==="trackDelete")?.mark??null,formatMark:I.find(({mark:M})=>M?.type?.name==="trackFormat")?.mark??null}),Zi=({superdoc:I,editor:M,changeIds:$,broadcastChanges:ie=!0})=>{if(!I||!M?.state||!Array.isArray($)||!$.length)return;const se=M?.options?.documentId!=null?String(M.options.documentId):null;if(se)for(const de of new Set($.map(he=>he!=null?String(he):null).filter(Boolean))){const he=sa.getTrackChanges(M.state,de);if(!he.length)continue;const ue=n0({event:"update",marks:Qo(he),nodes:[],newEditorState:M.state,documentId:se,trackedChangesForId:he});ue&&(ue.trackedChangeStory=e,ue.trackedChangeStoryKind="body",ue.trackedChangeStoryLabel="",ue.trackedChangeAnchorKey=n(ue.changeId??de),cr({superdoc:I,params:ue,broadcastChanges:ie}))}},va=(I=null,M=null,$=null)=>{const ie=Number.isFinite(I);Z.value=ie?I:null,S.value=ie&&M!=null?String(M):null;const se=$??M;ee.value=ie&&se!=null?String(se):null},Qi=()=>{const I=Z.value;return Number.isFinite(I)?I:null},hl=()=>{Z.value=null,S.value=null,ee.value=null},Ti=(I,M,$,ie=1e3)=>{p[I]&&clearTimeout(p[I]),p[I]=setTimeout(()=>{$&&$.emit("comments-update",M),delete p[I]},ie)},ao=(I,M)=>{if(M?.source!=="document-editor")return null;const $=M?.documentId??null,ie=I?.activeEditor?.options?.documentId??null;if(!$||!ie||$!==ie)return null;let se;try{se=I?.activeEditor?.doc?.selection?.current}catch{return null}if(typeof se!="function")return null;try{return se()}catch{return null}},Ri=(I,M=null)=>{const $=K(I),ie=ao(I,s.activeSelection),se={type:b.PENDING,pendingSelection:ie};if(I.emit("comments-update",se),$){const he=$.getCapabilityState?.();return he&&he.canWrite===!1?{ok:!1,reason:he.reason}:Promise.resolve($.captureCurrentSelection?.()).then(ue=>{if(!ue?.ok)return{ok:!1,reason:ue?.reason??"editing-range-required",detail:ue?.detail};U.value=ue.target??null;const Te=$.documentId??I?.activeEditor?.options?.documentId??null;return D.value=No({selection:{source:fu,documentId:Te,page:1,selectionBounds:{}},documentId:Te,parentCommentId:null}),I.config.isInternal||(D.value.isInternal=!1),va(M,"pending"),Ls(null),O.value=D.value.commentId,{ok:!0}}).catch(ue=>({ok:!1,reason:"selection-capture-failed",detail:ue?.message??String(ue)}))}const de={...s.activeSelection};return de.selectionBounds={...de.selectionBounds},s.selectionPosition?.source&&s.selectionPosition.source!=="pdf"&&(s.selectionPosition.source=null),D.value=No({selection:de,documentId:de.documentId,parentCommentId:null}),I.config.isInternal||(D.value.isInternal=!1),I.activeEditor?.commands&&I.activeEditor.commands.insertComment({...D.value.getValues(),commentId:"pending",skipEmit:!0}),D.value.selection.source==="document-editor"&&s.selectionPosition&&(s.selectionPosition.source=fu),va(M,"pending"),Ls(null),O.value=D.value.commentId,{ok:!0}},_e=I=>{const M=ft(I).entry;return M?Number.isFinite(M.start)?M.start:Number.isFinite(M.pos)?M.pos:Number.isFinite(M.from)?M.from:Number.isFinite(M.to)?M.to:Number.isFinite(M.pageIndex)&&Number.isFinite(M?.bounds?.top)?M.pageIndex*1e6+M.bounds.top:null:null},ze=(I,M)=>(I.createdTime??0)-(M.createdTime??0),vt=(I,M)=>{const $=_e(I),ie=_e(M),se=Number.isFinite($),de=Number.isFinite(ie);return se&&de&&$!==ie?$-ie:se&&!de?-1:!se&&de?1:ze(I,M)},ot=I=>{const M=[],$=[],ie=new Map;return X.value.forEach(se=>{if(!Is(se))return;const de=Ke(se)?je(se):null,he=se.trackedChange?null:se.parentCommentId||de;se.resolvedTime?$.push(se):!he&&!se.resolvedTime?M.push({...se}):he&&(ie.has(he)||ie.set(he,[]),ie.get(he).push(se))}),{parentComments:M.sort(I),resolvedComments:$.sort(I)}},xn=ke(()=>ot(ze)),Tn=ke(()=>xn.value?.parentComments.some(I=>I.trackedChange&&!I.resolvedTime)??!1),_r=ke(()=>ot(vt)),jr=I=>x.includes(I),gi=ke(()=>s.documents),Ji=ke(()=>a),Es=(I,M)=>{const $=I.getContainerLocation(M);return{top:$.top+I.selectionBounds.top,left:$.left+I.selectionBounds.left}},No=({selection:I,documentId:M,parentCommentId:$,...ie})=>Yr({selection:I,documentId:M,parentCommentId:$,...ie}),Yr=({selection:I,documentId:M,parentCommentId:$,...ie})=>{let se;return M?se=s.getDocument(M):I&&(se=s.getDocument(I.documentId)),se||(se=s.documents[0]),ia({fileId:se.id,fileType:se.type,parentCommentId:$,creatorId:s.user.id,creatorEmail:s.user.email,creatorName:s.user.name,creatorImage:s.user.image,commentText:J.value,selection:I,...ie})},Jo=I=>{const M=!!D.value;J.value="",D.value=null,U.value=null,s.selectionPosition=null,M&&Lo(),!be(I)&&I?.activeEditor?.commands?.removeComment({commentId:"pending"})},$i=({superdoc:I,comment:M,skipEditorUpdate:$=!1,broadcastChanges:ie=!0,isHydration:se=!1})=>{if(d()&&!se)return l();const de=!$&&!se?K(I):null;if(de&&!M.trackedChange){const Ne=o0(D.value?J.value:M.commentText),Oe=D.value?U.value:null,Qe=M.parentCommentId?String(M.parentCommentId):(D.value,null);return(async()=>{try{return await(Qe?de.reply({parentCommentId:Qe,text:Ne}):de.commitPendingComment({text:Ne,target:Oe}))}catch(ct){return{ok:!1,reason:"adapter-threw",detail:ct?.message??String(ct)}}})().then(ct=>{if(!ei(de))return{ok:!1,reason:"adapter-stale"};if(!ct?.ok)return ie&&I.emit("comments-update",{type:b.PENDING,rejected:!0,reason:ct?.reason??"v2-create-failed",...ct?.committed?{committed:!0}:{}}),ct;const yt=ti({superdoc:I,adapter:de,documentId:de.documentId,items:ct.items});return D.value&&Jo(I),ie&&I.emit("comments-update",{type:b.ADD,comment:yt?.added?.getValues?.()??null}),{ok:!0,comment:yt?.added??null}})}let he=X.value.find(Ne=>Ne.commentId===O.value);he||(he=M);const ue=ia(M.getValues());D.value?ue.setText({text:J.value,suppressUpdate:!0}):ue.setText({text:M.commentText,suppressUpdate:!0}),ue.selection.source=D.value?.selection?.source??ue.selection.source,he&&(ue.isInternal=he.isInternal),I.config.isInternal||(ue.isInternal=!1),X.value.push(ue),Jo(I),!$&&!M.trackedChange&&I.activeEditor?.commands&&!M.parentCommentId&&I.activeEditor.commands.insertComment({...ue.getValues(),skipEmit:!0});const Te={type:b.ADD,comment:ue.getValues()};return ie&&($l(I,Te),I.emit("comments-update",Te)),{ok:!0,comment:ue}},Mi=({superdoc:I,comment:M,skipEditorUpdate:$=!1,broadcastChanges:ie=!0})=>$i({superdoc:I,comment:M,skipEditorUpdate:$,broadcastChanges:ie}),lo=({superdoc:I,comment:M,skipEditorUpdate:$=!1,broadcastChanges:ie=!0})=>$i({superdoc:I,comment:M,skipEditorUpdate:$,broadcastChanges:ie,isHydration:!0}),$o=({commentId:I,superdoc:M})=>{if(d())return Promise.resolve(l());const $=X.value.findIndex(Oe=>Oe.commentId===I),ie=X.value[$];if(!ie)return Promise.resolve({ok:!1,reason:"comment-not-found"});const{commentId:se,importedId:de}=ie,{fileId:he}=ie,ue=K(M);if(ue&&!ie.trackedChange)return(async()=>{try{return await ue.delete({commentId:se})}catch(Oe){return{ok:!1,reason:"adapter-threw",detail:Oe?.message??String(Oe)}}})().then(Oe=>ei(ue)?Oe?.ok?(ti({superdoc:M,adapter:ue,documentId:ue.documentId??he,items:Oe.items}),M.emit("comments-update",{type:b.DELETED,comment:ie.getValues(),changes:[{key:"deleted",commentId:se,fileId:he}]}),{ok:!0}):(M.emit("comments-update",{type:b.DELETED,rejected:!0,comment:ie.getValues(),reason:Oe?.reason??"v2-delete-failed",...Oe?.committed?{committed:!0}:{}}),Oe):{ok:!1,reason:"adapter-stale"});M.activeEditor?.commands?.removeComment({commentId:se,importedId:de}),X.value.splice($,1);const Te=X.value.filter(Oe=>Oe.parentCommentId===se).map(Oe=>Oe.commentId||Oe.importedId);X.value=X.value.filter(Oe=>!Te.includes(Oe.commentId)),(O.value===se||Te.includes(O.value))&&Lo();const Ne={type:b.DELETED,comment:ie.getValues(),changes:[{key:"deleted",commentId:se,fileId:he}]};return M.emit("comments-update",Ne),$l(M,Ne),Promise.resolve({ok:!0})},Xr=async({superdoc:I,adapter:M,fileId:$,operation:ie,eventType:se,rejectionFallbackReason:de,rejectionEventExtras:he={},validateOutcome:ue,successEventBuilder:Te})=>{let Ne;try{Ne=await ie()}catch(yt){Ne={ok:!1,reason:"adapter-threw",detail:yt?.message??String(yt)}}if(!ei(M))return{ok:!1,reason:"adapter-stale"};if(!Ne?.ok){const yt={type:se,rejected:!0,reason:Ne?.reason??de,...Ne?.committed?{committed:!0}:{},...Ne?.code!==void 0?{code:Ne.code}:{},...Ne?.detail!==void 0?{detail:Ne.detail}:{},...he};return I?.emit?.("comments-update",yt),Ne}const Oe=ue?.({outcome:Ne});if(Oe?.ok===!1){const yt={ok:!1,committed:Oe.committed??!0,reason:Oe.reason??de,...Oe.code!==void 0?{code:Oe.code}:{},...Oe.detail!==void 0?{detail:Oe.detail}:{}},nt={type:se,rejected:!0,reason:yt.reason,...yt.committed?{committed:!0}:{},...yt.code!==void 0?{code:yt.code}:{},...yt.detail!==void 0?{detail:yt.detail}:{},...he};return I?.emit?.("comments-update",nt),yt}const Qe=ti({superdoc:I,adapter:M,documentId:M.documentId??$,items:Ne.items??[]}),ct=Te?.({outcome:Ne,reconciled:Qe})??null;return ct&&I?.emit?.("comments-update",ct),{ok:!0,items:Ne.items??[],reconciled:Qe}},ur=({outcome:I,adapter:M,fileId:$})=>(I.items??[]).map(ie=>M.mapV2CommentToUseCommentInput(ie,{fileId:$,fileType:null})).filter(Boolean),Li=I=>{const M=I?.commentId??I?.importedId;return M!=null?String(M):null},pc=I=>I?.parentCommentId!=null?String(I.parentCommentId):null,Lu=({outcome:I,adapter:M,fileId:$,commentId:ie,expectedResolved:se,operation:de})=>{const he=ie!=null?String(ie):null,ue=ur({outcome:I,adapter:M,fileId:$}),Te=ue.find(nt=>Li(nt)===he)??null,Ne=Te?.parentCommentId?ue.find(nt=>Li(nt)===pc(Te))??null:Te,Oe=Li(Ne);if(!Ne||!Oe)return{ok:!1,reason:`v2-${de}-refresh-missing`,detail:`comment ${he} was absent from the refreshed v2 comment list after ${de}`};const Qe=[Ne,...ue.filter(nt=>pc(nt)===Oe)],ct=nt=>!!nt?.resolvedTime;if(Qe.filter(nt=>ct(nt)!==se).length===0)return{ok:!0};const yt=ct(Ne);return Qe.some(nt=>ct(nt)!==yt)?{ok:!1,reason:`v2-${de}-refresh-split-thread`,detail:{rootId:Oe,expected:se?"resolved":"open",observed:Qe.map(nt=>({commentId:Li(nt),parentCommentId:pc(nt),status:ct(nt)?"resolved":"open"}))}}:{ok:!1,reason:se?`v2-${de}-refresh-still-open`:`v2-${de}-refresh-still-resolved`,detail:`comment ${Oe} remained ${yt?"resolved":"open"} after ${de}`}},xs=async({superdoc:I,parentCommentId:M,text:$}={})=>{if(d())return l();const ie=K(I);if(!ie)return{ok:!1,reason:"v2-comments-adapter-missing"};const se=M!=null?String(M):null;if(!se)return{ok:!1,reason:"parent-comment-id-missing"};const de=o0($);if(de.length===0)return{ok:!1,reason:"comment-text-empty"};const he=X.value.find(ue=>String(ue.commentId)===se);return Xr({superdoc:I,adapter:ie,fileId:he?.fileId??ie.documentId??null,operation:()=>ie.reply({parentCommentId:se,text:de}),eventType:b.ADD,rejectionFallbackReason:"v2-reply-failed",rejectionEventExtras:he?{comment:cn(he)}:{},successEventBuilder:({reconciled:ue})=>({type:b.ADD,comment:ue?.added?.getValues?.()??null})})},Mo=async({superdoc:I,commentId:M,text:$}={})=>{if(d())return l();const ie=K(I);if(!ie)return{ok:!1,reason:"v2-comments-adapter-missing"};const se=M!=null?String(M):null;if(!se)return{ok:!1,reason:"comment-id-missing"};const de=o0($);if(de.length===0)return{ok:!1,reason:"comment-text-empty"};const he=X.value.find(ue=>String(ue.commentId)===se);return Xr({superdoc:I,adapter:ie,fileId:he?.fileId??ie.documentId??null,operation:()=>ie.edit({commentId:se,text:de}),eventType:b.UPDATE,rejectionFallbackReason:"v2-edit-failed",rejectionEventExtras:he?{comment:cn(he),changes:[{key:"text",value:de}]}:{},successEventBuilder:()=>{const ue=X.value.find(Te=>String(Te.commentId)===se)??he;return ue?{type:b.UPDATE,comment:cn(ue),changes:[{key:"text",value:ue.commentText??de}]}:null}})},mc=async({superdoc:I,commentId:M}={})=>{if(d())return l();if(c())return u();const $=K(I);if(!$)return{ok:!1,reason:"v2-comments-adapter-missing"};const ie=M!=null?String(M):null;if(!ie)return{ok:!1,reason:"comment-id-missing"};const se=X.value.find(ue=>String(ue.commentId)===ie),de=se?.fileId??$.documentId??null,he=await Xr({superdoc:I,adapter:$,fileId:de,operation:()=>$.resolve({commentId:ie}),eventType:b.RESOLVED,rejectionFallbackReason:"v2-resolve-failed",rejectionEventExtras:se?{comment:cn(se)}:{},validateOutcome:({outcome:ue})=>Lu({outcome:ue,adapter:$,fileId:de,commentId:ie,expectedResolved:!0,operation:"resolve"}),successEventBuilder:()=>{const ue=X.value.find(Te=>String(Te.commentId)===ie)??se;return ue?{type:b.RESOLVED,comment:cn(ue)}:null}});if(he?.ok){const Te=!!X.value.find(Oe=>String(Oe.commentId)===ie)?.resolvedTime,Ne=O.value!=null?String(O.value):null;Te&&Ne===ie&&Lo()}return he},ya=async({superdoc:I,commentId:M}={})=>{if(d())return l();if(c())return u();const $=K(I);if(!$)return{ok:!1,reason:"v2-comments-adapter-missing"};const ie=M!=null?String(M):null;if(!ie)return{ok:!1,reason:"comment-id-missing"};const se=X.value.find(he=>String(he.commentId)===ie),de=se?.fileId??$.documentId??null;return Xr({superdoc:I,adapter:$,fileId:de,operation:()=>$.reopen({commentId:ie}),eventType:b.UPDATE,rejectionFallbackReason:"v2-reopen-failed",rejectionEventExtras:se?{comment:cn(se),changes:[{key:"resolvedTime",value:null}]}:{},validateOutcome:({outcome:he})=>Lu({outcome:he,adapter:$,fileId:de,commentId:ie,expectedResolved:!1,operation:"reopen"}),successEventBuilder:()=>{const he=X.value.find(ue=>String(ue.commentId)===ie);return!he||he.resolvedTime?null:{type:b.UPDATE,comment:cn(he),changes:[{key:"resolvedTime",value:null}]}}})},ei=I=>I?te.value===I:!1,Wn=I=>I?me.value===I:!1,jf=({superdoc:I,commentsAdapter:M,trackedChangesAdapter:$,documentId:ie,commentItems:se,trackedChangeItems:de,trackedList:he,patch:ue}={})=>ec("store.reviewSnapshot.apply","store-reconciliation",{commentItemCount:Array.isArray(se)?se.length:null,trackedItemCount:Array.isArray(de)?de.length:null},()=>{if(!ei(M))return{ok:!1,reason:"comments-adapter-stale"};if(!Wn($))return{ok:!1,reason:"tracked-changes-adapter-stale"};const Te=ie!=null?String(ie):null,Ne=I?.activeEditor?.documentId??I?.activeEditor?.options?.documentId??null;if(!Te)return{ok:!1,reason:"document-mismatch"};for(const yt of[M.documentId,$.documentId,Ne])if(yt==null||String(yt)!==Te)return{ok:!1,reason:"document-mismatch"};if(!Array.isArray(se)||!Array.isArray(de))return{ok:!1,reason:"items-invalid"};if(he?.complete!==!1||!["review-snapshot","visible-window"].includes(he?.visibleWindowSource))return{ok:!1,reason:"tracked-list-not-partial-visible-window"};if(typeof M.mapV2CommentToUseCommentInput!="function"||typeof $.mapV2TrackedChangeToCommentParams!="function")return{ok:!1,reason:"adapter-mapper-missing"};const Oe=(Te?s.getDocument(Te):null)?.type??null;let Qe,ct;try{Qe=se.filter(yt=>!e0(yt)).map(yt=>M.mapV2CommentToUseCommentInput(yt,{fileId:Te,fileType:Oe})).filter(Boolean),ct=de.map(yt=>$.mapV2TrackedChangeToCommentParams(yt)).filter(Boolean)}catch(yt){return{ok:!1,reason:"mapper-failed",detail:yt?.message??String(yt)}}return typeof ue!="function"?{ok:!1,reason:"patch-missing"}:(ue(()=>{_a({superdoc:I,adapter:$,documentId:Te,items:de,preparedParams:ct,pruneStale:!1}),ti({superdoc:I,adapter:M,documentId:Te,items:se,preparedInputs:Qe})}),{ok:!0,commentItems:Qe.length,trackedItems:ct.length})}),Ts=async({superdoc:I,adapter:M,documentId:$}={})=>ec("store.comments.hydrateFromV2","comments-list",{documentId:$??null},async()=>{const ie=M??K(I);if(!ie||typeof ie.refresh!="function")return{ok:!1,reason:"adapter-missing"};let se;try{se=await ie.refresh()}catch(de){return{ok:!1,reason:"adapter-threw",detail:de?.message??String(de)}}return ei(ie)?se?.ok?(ti({superdoc:I,adapter:ie,documentId:$,items:se.items??[]}),{ok:!0,items:se.items??[]}):se:{ok:!1,reason:"adapter-stale"}}),ti=({superdoc:I,adapter:M,documentId:$,items:ie,preparedInputs:se=null}={})=>ec("store.comments.reconcile","store-reconciliation",{documentId:$??null,itemCount:Array.isArray(ie)?ie.length:null},()=>{if(!M||!Array.isArray(ie))return{added:null};if(!ei(M))return{added:null,dropped:"adapter-stale"};const de=$??M.documentId??null,he=de!=null?String(de):null,ue=(de?s.getDocument(de):null)?.type??null,Te=at=>typeof at!="string"?!0:at.replace(/<[^>]*>/g,"").replace(/ /gi," ").trim().length===0,Ne=at=>!at||at.trackedChange===!0||!at.trackedChangeThreadParentId||at.parentCommentId?!1:Te(at.commentText),Oe=O.value!=null?String(O.value):null,Qe=Oe?X.value.find(at=>String(at.commentId)===Oe)??null:null,ct=Qe!=null&&D.value!=null&&(Qe===D.value||D.value.commentId!=null&&String(Qe.commentId??"")===String(D.value.commentId)),yt=Qe!=null&&!ct&&Qe.trackedChange!==!0&&!uf(Qe)&&(he==null||Qe.fileId==null||String(Qe.fileId)===he),nt=new Map,ln=new Map,nn=[],Vn=Array.isArray(se)?se:ie.filter(at=>!e0(at)).map(at=>M.mapV2CommentToUseCommentInput(at,{fileId:de,fileType:ue})).filter(Boolean);for(const at of Vn){if(Ne(at)){ln.set(String(at.commentId),String(at.trackedChangeThreadParentId)),y("hydrate:drop-v2-sidecar-comment",{commentId:at.commentId??null,importedId:at.importedId??null,parentCommentId:at.parentCommentId??null,trackedChangeParentId:at.trackedChangeParentId??null,trackedChangeThreadParentId:at.trackedChangeThreadParentId??null,trackedChangeSide:at.trackedChangeSide??null,commentText:at.commentText??null});continue}nn.push(at)}for(const at of nn){const pn=at.parentCommentId!=null?String(at.parentCommentId):null,An=pn?ln.get(pn):null;An&&(at.threadingParentCommentId=An,at.trackedChangeThreadParentId==null&&(at.trackedChangeThreadParentId=An));const Ur=at.commentId!=null?String(at.commentId):null;Ur&&nt.set(Ur,at)}const Ut=at=>{if(he==null)return!0;const pn=at?.fileId!=null?String(at.fileId):null;return pn==null?!0:pn===he},Cn=D.value?.commentId!=null?String(D.value.commentId):null,Sr=at=>!at||!D.value?!1:at===D.value||Cn!=null&&String(at.commentId??"")===Cn,Kn=at=>!at||Sr(at)||at.trackedChange===!0||uf(at)?!1:at.commentId!=null,dr=(at,pn)=>{at.commentText=pn.commentText??at.commentText,at.isInternal=typeof pn.isInternal=="boolean"?pn.isInternal:at.isInternal,typeof pn.resolvedTime=="number"?(at.resolvedTime=pn.resolvedTimeWasSynthesized===!0&&typeof at.resolvedTime=="number"?at.resolvedTime:pn.resolvedTime,at.resolvedByEmail=pn.resolvedByEmail??null,at.resolvedByName=pn.resolvedByName??null):(at.resolvedTime=null,at.resolvedByEmail=null,at.resolvedByName=null),pn.parentCommentId!==void 0?at.parentCommentId=pn.parentCommentId:delete at.parentCommentId,pn.trackedChangeParentId!==void 0?at.trackedChangeParentId=pn.trackedChangeParentId:delete at.trackedChangeParentId,pn.trackedChangeThreadParentId!==void 0?at.trackedChangeThreadParentId=pn.trackedChangeThreadParentId:at.trackedChangeThreadParentId=void 0,pn.trackedChangeSide!==void 0?at.trackedChangeSide=pn.trackedChangeSide:delete at.trackedChangeSide,pn.threadingParentCommentId!==void 0?at.threadingParentCommentId=pn.threadingParentCommentId:delete at.threadingParentCommentId},yr=[],Bo=new Set,Rn=[];for(const at of X.value){if(!Kn(at)||!Ut(at)){yr.push(at);continue}const pn=String(at.commentId),An=nt.get(pn);An&&(dr(at,An),Bo.add(pn),yr.push(at))}for(const[at,pn]of nt.entries()){if(Bo.has(at))continue;const An=ia(pn);yr.push(An),Rn.push(An)}return X.value=yr,yt&&Oe&&!yr.some(at=>String(at.commentId)===Oe)&&Lo(),{added:Rn[Rn.length-1]??null}}),vi=I=>{Jo(I)},pl=I=>typeof I!="string"?null:I.replace(/\s*\(imported\)\s*$/u,"").trim()||null,es=I=>{if(!I)return null;try{if(I.isDestroyed===!0)return null;const M=I.view;if(!M||M.isDestroyed===!0||M.destroyed===!0)return null;const $=M.state;return $?{view:M,state:$}:null}catch{return null}},Pu=I=>I!=null&&String(I).length>0?String(I):null,ml=I=>{const M=Pu(I),$=M?[[M,_.get(M)]]:Array.from(_.entries());let ie=0;for(const[se,de]of $)de&&(_.delete(se),de.timeoutHandle!==null&&de.timeoutHandle!==void 0&&clearTimeout(de.timeoutHandle),ie+=1);return ie},gl=I=>{const M=es(I);if(!M)return null;let $=[];try{$=sa.getTrackChanges(M.state)??[]}catch{return null}const ie=sa?.enumerateStructuralRowChanges;let se=[];if(typeof ie=="function")try{se=ie(M.state)??[]}catch{se=[]}let de=[];if(typeof mu=="function")try{de=mu(I)?.getAll?.()??[]}catch{de=[]}return{...M,trackedChanges:$,structuralChanges:se,storySnapshots:de}},Uf=(I,M,$=null)=>{if(!I||!M)return!1;const ie=$??gl(I);return ie?(Du(I,M,ie.trackedChanges,{editorState:ie.state,editorView:ie.view}),Pi({superdoc:M,editor:I,snapshots:ie.storySnapshots,documentState:ie.state,resolveFromEditor:!1}),Cl({superdoc:M,editor:I,structuralChanges:ie.structuralChanges}),!0):!1},ba=I=>{if(!I||_.get(I.documentId)!==I)return!1;try{const M=I.editor?.options?.documentId;if(M!=null&&String(M)!==I.documentId)return!1;const $=s.getDocument(I.documentId);if(!$||$.getEditor?.()!==I.editor)return!1}catch{return!1}return!0},vl=I=>{if(!ba(I))return _.get(I?.documentId)===I&&_.delete(I.documentId),!1;const M=gl(I.editor);if(!M||!ba(I))return _.get(I.documentId)===I&&_.delete(I.documentId),!1;try{return Uf(I.editor,I.superdoc,M)}finally{_.get(I.documentId)===I&&_.delete(I.documentId)}},ts=({editor:I,superdoc:M,documentId:$,defer:ie=!0})=>{const se=Pu($);if(!se||!I||!M)return!1;ml(se);const de={documentId:se,editor:I,superdoc:M,generation:++C,timeoutHandle:null};return _.set(se,de),ie?(de.timeoutHandle=setTimeout(()=>{de.timeoutHandle=null,vl(de)},0),!0):vl(de)};function yi(I){const M=I!=null?String(I):null;if(!M)return;ml(M);const $=X.value.filter(de=>Ca(de,M,{allowSingleDocumentMismatch:!0}));if(!$.length)return;const ie=new Set;if($.forEach(de=>{kt(de).forEach(he=>ie.add(he))}),X.value=X.value.filter(de=>!$.includes(de)),ie.size){const de={...re.value||{}};ie.forEach(he=>{delete de[he]}),re.value=de}const se=O.value!=null?String(O.value):null;se&&ie.has(se)&&Lo()}function Gf(I){yi(I)}const wa=async({superdoc:I,editor:M,comments:$,documentId:ie,replacedFile:se=!1})=>{const de=s.getDocument(ie);if(de?.commentThreadingProfile&&(de.commentThreadingProfile.value=M?.converter?.commentThreadingProfile||null),se&&Gf(ie),$.forEach(he=>{const ue=Array.isArray(he.elements)?he.elements:[],Te=Qf(ue);if(!Te&&!he.trackedChange)return;const Ne=pl(he.creatorName),Oe=Ne?`${Ne} (imported)`:null;lo({superdoc:I,comment:ia({fileId:ie,fileType:de.type,docxCommentJSON:ue.length?ue:null,commentId:he.commentId,isInternal:!1,parentCommentId:he.parentCommentId,trackedChangeParentId:he.trackedChangeParentId,trackedChangeThreadParentId:he.trackedChangeThreadParentId,creatorId:null,creatorName:Ne,createdTime:he.createdTime,creatorEmail:he.creatorEmail,importedAuthor:{...Oe?{name:Oe}:{},email:he.creatorEmail},commentText:Te,resolvedTime:he.isDone?Date.now():null,resolvedById:null,resolvedByEmail:he.isDone?he.creatorEmail:null,resolvedByName:he.isDone?Oe||"(Imported)":null,trackedChange:he.trackedChange||!1,trackedChangeText:he.trackedChangeText,trackedChangeType:he.trackedChangeType,trackedChangeDisplayType:he.trackedChangeDisplayType,deletedText:he.trackedDeletedText,origin:he.origin||"word",threadingMethod:he.threadingMethod,threadingStyleOverride:he.threadingStyleOverride,threadingParentCommentId:he.threadingParentCommentId,originalXmlStructure:he.originalXmlStructure})})}),se){ts({editor:M,superdoc:I,documentId:ie,defer:!1});return}ts({editor:M,superdoc:I,documentId:ie})},Du=(I,M,$=null,ie={})=>{const{reopenResolved:se=!1,refreshExisting:de=!1,broadcastChanges:he=!0,editorState:ue=null,editorView:Te=null}=ie,Ne=ue?{state:ue,view:Te}:es(I);if(!Ne?.state)return;const Oe=Ne.state,Qe=$??sa.getTrackChanges(Oe),ct=g8(Qe),yt=I?.options?.documentId!=null?String(I.options.documentId):null;if(!yt)return;const nt=new Set,ln=new Map;X.value.forEach(Kn=>{if(!Kn?.trackedChange||!yo(Kn,yt)||!t(Kn))return;const dr=[Kn.commentId,Kn.importedId].map(yr=>yr!=null?String(yr):null).filter(Boolean);if(Kn.resolvedTime){se||dr.forEach(yr=>nt.add(yr));return}dr.forEach(yr=>{ln.set(yr,Kn),de||nt.add(yr)})});const nn=new Map;for(const Kn of Qe){const dr=Kn.mark.attrs.id;nn.has(dr)||nn.set(dr,[]),nn.get(dr).push(Kn)}const Vn=yt,Ut=new Set;ct.forEach(({insertedMark:Kn,deletionMark:dr,formatMark:yr})=>{const Bo=Kn?.mark.attrs.id||dr?.mark.attrs.id||yr?.mark.attrs.id;if(Bo==null)return;const Rn=String(Bo);if(Ut.has(Rn)||(Ut.add(Rn),!de&&nt.has(Rn)))return;const at=ln.get(Rn),pn={...Kn&&{insertedMark:Kn.mark},...dr&&{deletionMark:dr.mark},...yr&&{formatMark:yr.mark}},An=n0({event:at?"update":"add",marks:pn,nodes:[],newEditorState:Oe,documentId:Vn,trackedChangesForId:nn.get(Bo)||[]});if(An){const Ur=n(An.changeId??Bo);An.trackedChangeStory=e,An.trackedChangeStoryKind="body",An.trackedChangeStoryLabel="",An.trackedChangeAnchorKey=Ur,cr({superdoc:M,params:An,broadcastChanges:he,documentState:Oe}),at||(nt.add(Rn),An.changeId!=null&&nt.add(String(An.changeId)),An.importedId!=null&&nt.add(String(An.importedId)))}});const Cn=Ne.view;try{if(!Cn||I.view!==Cn||Cn.isDestroyed===!0||Cn.destroyed===!0)return}catch{return}const{tr:Sr}=Oe;Sr.setMeta(z8,{type:"force"}),Cn.dispatch(Sr)},Wf=({suppressedIds:I,activeDocumentId:M,superdoc:$=null,broadcastChanges:ie=!0})=>{if(!(I instanceof Set)||!I.size||!M)return;const se=[];if(X.value=X.value.filter(ue=>{if(!ue?.trackedChange||!t(ue)||Al(ue)||!yo(ue,M))return!0;const Te=ue.commentId!=null?String(ue.commentId):null,Ne=ue.importedId!=null?String(ue.importedId):null;return Te&&I.has(Te)||Ne&&I.has(Ne)?(se.push(ue),!1):!0}),!se.length)return;const de=new Set;se.forEach(ue=>{ue.commentId!=null&&de.add(String(ue.commentId)),ue.importedId!=null&&de.add(String(ue.importedId));const Te=cn(ue),Ne={type:b.DELETED,comment:Te,changes:[{key:"deleted",commentId:Te.commentId,fileId:Te.fileId}]};ie&&($l($,Ne),$?.emit?.("comments-update",Ne))});const he=O.value!=null?String(O.value):null;he&&de.has(he)&&Lo()},yl=I=>I?I.fileId!=null?String(I.fileId):I.documentId!=null?String(I.documentId):I.selection?.documentId!=null?String(I.selection.documentId):null:null,gc=()=>{const I=Array.isArray(s.documents)?s.documents:s.documents?.value;return Array.isArray(I)?I:[]},Ou=()=>{const I=gc();return I.length!==1?null:I[0]?.id!=null?String(I[0].id):null},Ca=(I,M,$={})=>{const{allowSingleDocumentMismatch:ie=!1}=$;if(!M)return!1;const se=yl(I);if(se){if(se===M)return!0;const de=Ou();return ie&&de===M}return Ou()===M},yo=(I,M)=>Ca(I,M,{allowSingleDocumentMismatch:!0}),bl=I=>{const M=typeof I=="string"?I.toLowerCase():"";return M?M==="insert"||M==="insertion"||M==="trackinsert"||M==="tableinsert"||M==="paragraphsplit"?"insertion":M==="delete"||M==="deletion"||M==="trackdelete"||M==="tabledelete"?"deletion":M:null},Rs=({comment:I,decision:M}={})=>{const $=M==="accept"||M==="reject"?M:null;if(!$)return!1;const ie=bl(I?.trackedChangeDisplayType)??bl(I?.trackedChangeType);return $==="accept"&&ie==="insertion"||$==="reject"&&ie==="deletion"},vc=(I,M,$,ie=null,{broadcastChanges:se=!0}={})=>ec("store.trackedChanges.pruneStaleComments","store-reconciliation",{activeDocumentId:$??null,liveIdCount:I instanceof Set?I.size:null,liveAnchorKeyCount:M instanceof Set?M.size:null},()=>{if(!(I instanceof Set)||!$)return;const de=new Set,he=[],ue=[...X.value];if(X.value=X.value.filter(Qe=>{if(!Qe?.trackedChange||!yo(Qe,$))return!0;const ct=Qe.commentId!=null?String(Qe.commentId):null,yt=Qe.importedId!=null?String(Qe.importedId):null,nt=Qe.trackedChangeAnchorKey!=null?String(Qe.trackedChangeAnchorKey):null,ln=!!(ct&&I.has(ct)),nn=!!(yt&&I.has(yt)),Vn=!!(nt&&M?.has(nt));if(!ct&&!yt&&!nt||ln||nn||Vn||Qe.resolvedTime)return!0;const Ut=v.get(Qe);return Ut?(Qe.resolvedTime=Ut.resolvedTime??Date.now(),Qe.resolvedById=Ut.resolvedById??null,Qe.resolvedByEmail=Ut.resolvedByEmail??null,Qe.resolvedByName=Ut.resolvedByName??null,Qe.trackedChangeDecision=Ut.trackedChangeDecision??null,he.push(Qe),!0):(ct&&de.add(ct),yt&&de.add(yt),!1)}),he.forEach(Qe=>{const ct=cn(Qe),yt={type:b.UPDATE,comment:ct};se&&($l(ie,yt),ie?.emit?.("comments-update",yt))}),!de.size)return;let Te=!0;for(;Te;)Te=!1,X.value=X.value.filter(Qe=>{if(!yo(Qe,$))return!0;const ct=Qe.parentCommentId!=null?String(Qe.parentCommentId):null,yt=je(Qe)!=null?String(je(Qe)):null;if(!(ct&&de.has(ct)||yt&&de.has(yt))||Qe.resolvedTime)return!0;const nt=Qe.commentId!=null?String(Qe.commentId):null,ln=Qe.importedId!=null?String(Qe.importedId):null;return nt&&de.add(nt),ln&&de.add(ln),Te=!0,!1});ue.filter(Qe=>{if(!yo(Qe,$))return!1;const ct=Qe.commentId!=null?String(Qe.commentId):null,yt=Qe.importedId!=null?String(Qe.importedId):null;return ct&&de.has(ct)||yt&&de.has(yt)}).forEach(Qe=>{const ct=cn(Qe),yt={type:b.DELETED,comment:ct,changes:[{key:"deleted",commentId:ct.commentId,fileId:ct.fileId}]};se&&($l(ie,yt),ie?.emit?.("comments-update",yt))});const Ne=O.value!=null?String(O.value):null,Oe=ue.some(Qe=>{const ct=Qe.commentId!=null?String(Qe.commentId):null,yt=Qe.importedId!=null?String(Qe.importedId):null;return yo(Qe,$)&&(ct&&ct===Ne||yt&&yt===Ne)});Ne&&de.has(Ne)&&Oe&&Lo()}),Fu=({superdoc:I,comment:M,decision:$}={})=>{if(!M?.trackedChange||Rs({comment:M,decision:$}))return 0;const ie=bo(M);if(!ie.size)return 0;const se={email:I?.user?.email??null,name:I?.user?.name??null,superdoc:I};let de=0;return ns(M).forEach(he=>{!he||he===M||he.resolvedTime||[je(he),he.threadingParentCommentId,he.parentCommentId].map(ue=>He(ue)).filter(Boolean).some(ue=>ie.has(ue))&&typeof he.resolveComment=="function"&&(he.resolveComment(se),de+=1)}),de},bo=I=>{const M=new Set(kt(I));I?.trackedChangeCanonicalId!=null&&M.add(String(I.trackedChangeCanonicalId));const $=I?.trackedChangeAnchorKey!=null?String(I.trackedChangeAnchorKey):null;if($&&(M.add($),$.startsWith("tc::"))){const ie=$.slice($.lastIndexOf("::")+2);ie&&M.add(ie)}return M},ns=I=>{const M=[],$=new Set;for(const ie of bo(I))for(const se of ye.value.get(String(ie))??[])$.has(se)||($.add(se),M.push(se));return M},Nu=I=>{const M=I&&typeof I=="object"?I:null;if(!M?.success)return new Set;const $=new Set,ie=se=>{const de=se&&typeof se=="object"?se:null;de?.kind!=="entity"||de.entityType!=="trackedChange"||de.entityId!=null&&String(de.entityId).length>0&&$.add(String(de.entityId))};return Array.isArray(M.removed)&&M.removed.forEach(ie),Array.isArray(M.invalidatedRefs)&&M.invalidatedRefs.forEach(ie),$},yc=I=>{const M=new Set;return I?.decidedId!=null&&String(I.decidedId).length>0&&M.add(String(I.decidedId)),Array.isArray(I?.decidedIds)&&I.decidedIds.forEach($=>{$!=null&&String($).length>0&&M.add(String($))}),Nu(I?.receipt).forEach($=>M.add($)),M},Bu=({comment:I,decision:M}={})=>{if(!I?.trackedChange||!Rs({comment:I,decision:M}))return 0;const $=bo(I);if(!$.size)return 0;let ie=0;return ns(I).forEach(se=>{if(!se||se===I)return;const de=He(se.trackedChangeParentId),he=He(se.trackedChangeThreadParentId),ue=He(se.threadingParentCommentId),Te=He(se.parentCommentId);(de&&$.has(de)||he&&$.has(he)||ue&&$.has(ue)||Te&&$.has(Te))&&(delete se.trackedChangeParentId,se.trackedChangeThreadParentId=void 0,delete se.trackedChangeSide,delete se.threadingParentCommentId,Te&&$.has(Te)&&delete se.parentCommentId,ie+=1)}),ie},bc=(I=[],{documentId:M}={})=>{const $=He(M);if(!Array.isArray(I)||I.length===0||!$)return;const ie=re.value||{};let se=!1;const de=(ue,Te,Ne,Oe)=>He(ue?.[Te])!==Ne?!1:(ue[Te]=Oe,!0),he=(ue,Te)=>ue?.trackedChange&&yo(ue,$)&&[ue.commentId,ue.importedId,ue.trackedChangeCanonicalId,...kt(ue)].map(Ne=>He(Ne)).includes(Te);for(const ue of I){const Te=He(ue?.from),Ne=He(ue?.to);if(!Te||!Ne||Te===Ne)continue;const Oe=X.value.find(Ut=>he(Ut,Te));if(!Oe)continue;const Qe={};for(const Ut of["commentId","importedId"])de(Oe,Ut,Te,Ne)&&(Qe[Ut]=Ne);de(Oe,"trackedChangeCanonicalId",Te,Ne)&&(Qe.trackedChangeCanonicalId=Ne);const ct=n(Te),yt=r(Oe.trackedChangeAnchorKey)?.storyKey??_n(sn(Oe)),nt=o(yt,Te),ln=o(yt,Ne);(He(Oe.trackedChangeAnchorKey)===ct||Oe.trackedChangeAnchorKey==null||He(Oe.trackedChangeAnchorKey)===nt)&&(Oe.trackedChangeAnchorKey=ln),Array.isArray(Oe.trackedChangePositionAliases)&&(Oe.trackedChangePositionAliases=Oe.trackedChangePositionAliases.map(Ut=>He(Ut)===Te?Ne:Ut)),X.value.forEach(Ut=>{if(Ut===Oe||!yo(Ut,$))return;const Cn={};for(const Sr of["trackedChangeThreadParentId","trackedChangeParentId","threadingParentCommentId","parentCommentId"])de(Ut,Sr,Te,Ne)&&(Cn[Sr]=Ne);Object.keys(Cn).length&&typeof Ut.updateIdentityValues=="function"&&Ut.updateIdentityValues(Cn)}),Object.keys(Qe).length&&typeof Oe.updateIdentityValues=="function"&&Oe.updateIdentityValues(Qe);const nn=[ie[Te],ie[ct]],Vn=ie[nt]??nn.find(Ut=>Ut&&Ye(Ut,Oe));if(Vn)for(const Ut of[Ne,ln])ie[Ut]===void 0&&(ie[Ut]=Vn,se=!0);He(O.value)===Te&&(O.value=Ne),He(V.value)===Te&&(V.value=Ne)}se&&(re.value={...ie})},Ms=({superdoc:I,comment:M,decidedId:$,decidedIds:ie,documentId:se}={})=>{const de=new Set((Array.isArray(ie)||ie instanceof Set?Array.from(ie):[$]).map(ct=>He(ct)).filter(Boolean)),he=He(se);if(!de.size||!he)return{removed:!1,removedIds:new Set};const ue=new Set;let Te=!1;const Ne=M?X.value.indexOf(M):-1,Oe=M?.trackedChange?bo(M):new Set;if(Ne>=0&&yo(M,he)&&Array.from(de).some(ct=>Oe.has(ct))?(Oe.forEach(ct=>ue.add(ct)),X.value.splice(Ne,1),Te=!0):X.value=X.value.filter(ct=>{if(!ct?.trackedChange||!yo(ct,he))return!0;const yt=bo(ct);return Array.from(de).some(nt=>yt.has(nt))?(Te=!0,yt.forEach(nt=>ue.add(nt)),!1):!0}),!Te)return{removed:!1,removedIds:ue};const Qe=O.value!=null?String(O.value):null;return Qe&&ue.has(Qe)&&Lo(),{removed:!0,removedIds:ue}},ni=(I,M)=>{if(!(!M||typeof I?.clearActiveTrackedChangeTargetIfMatches!="function"))try{I.clearActiveTrackedChangeTargetIfMatches(M)}catch{}},zu=async({superdoc:I,receipt:M}={})=>{const $=I?.activeEditor?.documentMutationReadiness;if(!(M?.success!==!0||typeof M?.txId!="string"||!M.txId||typeof $?.whenPainted!="function"))try{await $.whenPainted(M);const ie=globalThis.requestAnimationFrame;typeof ie=="function"&&await new Promise(se=>{let de=!1;const he=()=>{de||(de=!0,clearTimeout(ue),se())},ue=setTimeout(he,250);ie(()=>ie(()=>setTimeout(he,0)))})}catch{}},wl=({superdoc:I,comment:M,decision:$})=>{if(d())return{ok:!1,reason:"read-only-document"};if(!M?.trackedChange)return{ok:!1};const ie=Pe(I);if(ie){if($!=="accept"&&$!=="reject")return Promise.resolve({ok:!1,reason:"decision-invalid"});const Oe=M?.trackedChangeCanonicalId!=null?String(M.trackedChangeCanonicalId):M?.commentId!=null?String(M.commentId):M?.trackedChangeAnchorKey?.startsWith?.("tc::body::")?M.trackedChangeAnchorKey.slice(10):null,Qe=Oe!=null&&String(O.value??"")===Oe;return ec("store.trackedChanges.sidebarDecision","command",{decision:$,decidedId:Oe},()=>(async()=>{try{return await($==="accept"?ie.accept(M):ie.reject(M))}catch(ct){return{ok:!1,reason:"adapter-threw",detail:ct?.message??String(ct)}}})().then(async ct=>{if(!Wn(ie))return{ok:!1,reason:"adapter-stale"};if(!ct?.ok)return{ok:!1,reason:ct?.reason,detail:ct?.detail};const yt=yc(ct),nt=ct?.documentId??ie.documentId??I?.activeEditor?.documentId??I?.activeEditor?.options?.documentId??null,ln=async()=>{let nn;try{nn=await ie.listTrackedChanges({mode:"all",refreshReason:"post-decision-blocking",blocking:!0})}catch(Cn){return{ok:!1,committed:!0,reason:"relist-after-commit-failed",detail:Cn?.message??String(Cn)}}if(!Wn(ie))return{ok:!1,committed:!0,reason:"adapter-stale"};if(!nn?.ok)return{ok:!1,committed:!0,reason:"relist-after-commit-failed",detail:nn?.reason??nn?.detail??null};Fu({superdoc:I,comment:M,decision:$}),Bu({comment:M,decision:$}),_a({superdoc:I,adapter:ie,documentId:nt,items:nn.items??[],pruneStale:nn.complete===!0&&nn.sourceCoverageComplete===!0});const Vn=new Set((nn.items??[]).map(Cn=>Cn&&Cn.id!=null?String(Cn.id):null).filter(Boolean));Oe!=null&&Vn.has(Oe)||(Qe&&Lo(),ni(ie,Oe));const Ut=K(I);if(Ut&&typeof Ut.refresh=="function"&&ei(Ut)){let Cn;try{Cn=await Ut.refresh()}catch(Sr){return{ok:!1,committed:!0,reason:"comments-relist-after-tracked-decision-failed",detail:Sr?.message??String(Sr)}}if(!ei(Ut))return{ok:!1,committed:!0,reason:"comments-adapter-stale"};if(!Cn?.ok)return{ok:!1,committed:!0,reason:"comments-relist-after-tracked-decision-failed",detail:Cn?.reason??Cn?.detail??null};ti({superdoc:I,adapter:Ut,documentId:Ut.documentId??nt,items:Cn.items??[]})}return{ok:!0,success:!0}};return!yt.size||!nt?ln():(yt.forEach(nn=>ni(ie,nn)),await zu({superdoc:I,receipt:ct.receipt}),Fu({superdoc:I,comment:M,decision:$}),Bu({comment:M,decision:$}),Ms({superdoc:I,comment:M,decidedIds:yt,documentId:nt}),Qe&&Lo(),{ok:!0,success:!0})}))}const se=I?.activeEditor;if(!se)return{ok:!1};const de=M.commentId??M.importedId;if(!de)return{ok:!1};const he=M.trackedChangeStory??void 0,ue=typeof se.doc=="object"?se.doc:null;if(ue?.trackChanges?.decide)try{const Oe=he?{id:de,story:he}:{id:de};return Promise.resolve(ue.trackChanges.decide({decision:$,target:Oe})).then(Qe=>({ok:!0,success:!!Qe?.success}))}catch(Oe){if(he)return{ok:!1,error:Oe}}const Te=$==="accept"?"acceptTrackedChangeById":"rejectTrackedChangeById",Ne=se.commands?.[Te];return typeof Ne!="function"?{ok:!1}:{ok:!0,success:!!Ne(de)}},Vu=async({superdoc:I,adapter:M,documentId:$,trackedChangesListMode:ie="all",refreshReason:se,blocking:de}={})=>ec("store.trackedChanges.hydrateFromV2","tracked-change-list",{documentId:$??null,trackedChangesListMode:ie,refreshReason:se??null,blocking:de??null},async()=>{const he=M??Pe(I);if(!he||typeof he.listTrackedChanges!="function")return{ok:!1,reason:"adapter-missing"};let ue;try{const Oe={mode:ie};se!=null&&(Oe.refreshReason=se),typeof de=="boolean"&&(Oe.blocking=de),ue=await he.listTrackedChanges(Oe)}catch(Oe){return{ok:!1,reason:"adapter-threw",detail:Oe?.message??String(Oe)}}if(!Wn(he))return{ok:!1,reason:"adapter-stale"};if(!ue?.ok)return ue;const Te=!(ie==="startup-page"||ie==="interaction-prime"||ie==="visible-window")&&ue.visibleWindowSource==null&&ue.complete===!0&&ue.sourceCoverageComplete===!0;_a({superdoc:I,adapter:he,documentId:$,items:ue.items??[],pruneStale:Te});const Ne={ok:!0,items:ue.items??[]};return typeof ue.complete=="boolean"&&(Ne.complete=ue.complete),typeof ue.sourceCoverageComplete=="boolean"&&(Ne.sourceCoverageComplete=ue.sourceCoverageComplete),ue.visibleWindowSource!=null&&(Ne.visibleWindowSource=ue.visibleWindowSource),ue.visibleWindowFallbackReason!=null&&(Ne.visibleWindowFallbackReason=ue.visibleWindowFallbackReason),typeof ue.visibleTrackedChangeExpectedRows=="number"&&(Ne.visibleTrackedChangeExpectedRows=ue.visibleTrackedChangeExpectedRows),typeof ue.visibleTrackedChangeObservedRows=="number"&&(Ne.visibleTrackedChangeObservedRows=ue.visibleTrackedChangeObservedRows),typeof ue.refreshReason=="string"&&(Ne.refreshReason=ue.refreshReason),typeof ue.blocking=="boolean"&&(Ne.blocking=ue.blocking),typeof ue.pageCount=="number"&&(Ne.pageCount=ue.pageCount),typeof ue.totalItems=="number"&&(Ne.totalItems=ue.totalItems),typeof ue.coalesced=="boolean"&&(Ne.coalesced=ue.coalesced),Ne}),wc=async({superdoc:I,adapter:M,documentId:$,upsertIds:ie=[],removedIds:se=[]}={})=>{const de=M??Pe(I);if(!de)return{ok:!1,reason:"adapter-missing"};if(!Wn(de))return{ok:!1,reason:"adapter-stale"};const he=$??de.documentId??I?.activeEditor?.documentId??null,ue=new Set(Array.from(se??[]).map(nt=>He(nt)).filter(Boolean)),Te=[...new Set(Array.from(ie??[]).map(nt=>He(nt)).filter(Boolean))];if(ue.size>0&&Te.length===0&&he!=null&&Ms({superdoc:I,decidedIds:ue,documentId:he}),Te.length===0)return{ok:!0,items:[],resolvedIds:[],unresolvedIds:[]};if(typeof de.getTrackedChange!="function")return{ok:!1,reason:"adapter-get-missing"};const Ne=await Promise.all(Te.map(async nt=>{try{return{id:nt,result:await de.getTrackedChange(nt)}}catch(ln){return{id:nt,result:{ok:!1,reason:"adapter-threw",detail:ln?.message??String(ln)}}}}));if(!Wn(de))return{ok:!1,reason:"adapter-stale"};const Oe=[],Qe=[],ct=[];for(const{id:nt,result:ln}of Ne){const nn=(ln?.ok&&Array.isArray(ln.items)?ln.items:[]).filter(Vn=>Ft(Vn).has(nt));nn.length>0?(Oe.push(nt),ct.push(...nn)):Qe.push(nt)}const yt=Nt(ct);return ct.length>0&&_a({superdoc:I,adapter:de,documentId:he,items:yt,pruneStale:!1}),{ok:Qe.length===0,items:yt,resolvedIds:Oe,unresolvedIds:Qe,failures:Ne.map(({result:nt})=>nt).filter(nt=>!nt?.ok)}},_a=({superdoc:I,adapter:M,documentId:$,items:ie,pruneStale:se=!0,preparedParams:de=null}={})=>ec("store.trackedChanges.reconcile","store-reconciliation",{documentId:$??null,itemCount:Array.isArray(ie)?ie.length:null,pruneStale:se},()=>{if(!M||!Array.isArray(ie)||!Wn(M))return;const he=$??M.documentId??I?.activeEditor?.documentId??null,ue=new Set,Te=new Set,Ne=Array.isArray(de)?de:ie.map(Oe=>M.mapV2TrackedChangeToCommentParams(Oe));for(const Oe of Ne)if(Oe){if(Oe.event==="omit"){Oe.changeId!=null&&Te.add(String(Oe.changeId));continue}he&&Oe.documentId==null&&(Oe.documentId=he),Oe.changeId!=null&&Te.add(String(Oe.changeId)),Oe.trackedChangeAnchorKey!=null&&ue.add(String(Oe.trackedChangeAnchorKey)),cr({superdoc:I,params:Oe,broadcastChanges:!1})}!he||!se||vc(Te,ue,String(he),I,{broadcastChanges:!1})}),rs=({superdoc:I,editor:M,broadcastChanges:$=!0})=>{if(!I||!M)return;const ie=M?.options?.documentId!=null?String(M.options.documentId):null;if(!ie)return;const se=gl(M);if(!se)return;const de=se.trackedChanges,he=new Set;de.forEach(Te=>{const Ne=Te?.mark?.attrs?.id;Ne!=null&&he.add(String(Ne))});const ue=se.storySnapshots;vc(he,new Set(ue.map(Te=>Te?.anchorKey).filter(Te=>typeof Te=="string"&&Te.length>0)),ie,I,{broadcastChanges:$}),Du(M,I,de,{reopenResolved:!0,refreshExisting:!0,broadcastChanges:$,editorState:se.state,editorView:se.view}),Pi({superdoc:I,editor:M,broadcastChanges:$,snapshots:ue,documentState:se.state}),Cl({superdoc:I,editor:M,broadcastChanges:$,structuralChanges:se.structuralChanges})},Cl=({superdoc:I,editor:M,broadcastChanges:$=!0,structuralChanges:ie=null})=>{const se=M?.options?.documentId!=null?String(M.options.documentId):null;if(!se)return;const de=sa?.enumerateStructuralRowChanges;if(typeof de!="function")return;let he=ie;if(!Array.isArray(he)){const ue=es(M);if(!ue)return;try{he=de(ue.state)??[]}catch{he=[]}}for(const ue of he){if(!ue?.decidable||!ue?.wholeTable)continue;const Te=i(ue);if(!Te)continue;const Ne=n(Te),Oe=ue.subtype==="table-insert"?"tableInsert":"tableDelete",Qe=ue.side==="insertion"?"trackInsert":"trackDelete",ct=String(Te),yt=Ne!=null?String(Ne):null;cr({superdoc:I,params:{event:X.value.find(nt=>{if(!nt?.trackedChange||!yo(nt,se))return!1;const ln=nt.trackedChangeAnchorKey!=null?String(nt.trackedChangeAnchorKey):null;if(yt&&ln)return ln===yt;const nn=nt.commentId!=null?String(nt.commentId):null,Vn=nt.importedId!=null?String(nt.importedId):null;return nn===ct||Vn===ct})?"update":"add",changeId:Te,trackedChangeText:"",trackedChangeType:Qe,trackedChangeDisplayType:Oe,deletedText:null,authorId:null,authorEmail:ue.authorEmail||null,authorImage:ue.authorImage||null,date:ue.date||null,author:ue.author||null,importedAuthor:ue.importedAuthor?{name:ue.importedAuthor}:null,semanticColorKey:ue.semanticColorKey??null,semanticColor:ue.semanticColor??null,documentId:se,coords:null,trackedChangeStory:e,trackedChangeStoryKind:"body",trackedChangeStoryLabel:"",trackedChangeAnchorKey:Ne},broadcastChanges:$})}},Pi=({superdoc:I,editor:M,broadcastChanges:$=!0,snapshots:ie=null,documentState:se=void 0,resolveFromEditor:de=!0})=>{const he=M?.options?.documentId!=null?String(M.options.documentId):null;if(!he)return;let ue=ie;if(!Array.isArray(ue)){if(typeof mu!="function"||!es(M))return;let Te=null;try{Te=mu(M)}catch{return}if(!Te)return;try{ue=Te.getAll()}catch{return}}for(const Te of ue)Te.storyKind!=="body"&&Hu({superdoc:I,editor:M,snapshot:Te,documentId:he,broadcastChanges:$,documentState:se,resolveFromEditor:de})},Kf=I=>I?.type!=="structural"?I?.type??null:I?.subtype==="table-delete"?"tableDelete":"tableInsert",qf=I=>I?.type!=="structural"?I?.type??null:I?.subtype==="table-delete"?"trackDelete":"trackInsert",Cc=I=>I?I.type==="delete"?!0:I.type==="structural"&&I.subtype==="table-delete":!1,_l=({editor:I,snapshot:M,documentId:$,event:ie,resolveFromEditor:se=!0})=>{const de=qf(M),he=Kf(M),ue={event:ie,changeId:M.runtimeRef.rawId,trackedChangeText:Cc(M)?"":M.excerpt??"",trackedChangeType:de,trackedChangeDisplayType:he,semanticColorKey:M.semanticColorKey??null,semanticColor:M.semanticColor??null,deletedText:Cc(M)?M.excerpt??"":null,authorId:M.authorId,authorEmail:M.authorEmail,authorImage:M.authorImage,date:M.date,author:M.author,documentId:$,coords:null,trackedChangeStory:M.story,trackedChangeStoryKind:M.storyKind,trackedChangeStoryLabel:M.storyLabel,trackedChangeAnchorKey:M.anchorKey};if(!se||typeof h_!="function")return ue;let Te=null;try{Te=h_(I,{kind:"entity",entityType:"trackedChange",entityId:M.runtimeRef.rawId,story:M.story})}catch{Te=null}const Ne=Te?.editor?.state??null;if(!Ne)return ue;let Oe=[];try{Oe=sa.getTrackChanges(Ne,Te.change.rawId)??[]}catch{Oe=[]}const Qe=n0({event:ie,marks:Qo(Oe),nodes:[],newEditorState:Ne,documentId:$,trackedChangesForId:Oe});return Qe?(Qe.semanticColorKey==null&&M.semanticColorKey!=null&&(Qe.semanticColorKey=M.semanticColorKey),Qe.semanticColor==null&&M.semanticColor!=null&&(Qe.semanticColor=M.semanticColor),Qe.trackedChangeStory=M.story,Qe.trackedChangeStoryKind=M.storyKind,Qe.trackedChangeStoryLabel=M.storyLabel,Qe.trackedChangeAnchorKey=M.anchorKey,Qe):ue},Hu=({superdoc:I,editor:M,snapshot:$,documentId:ie,broadcastChanges:se,documentState:de,resolveFromEditor:he})=>{if(!$?.runtimeRef?.rawId)return;const ue=X.value.find(Te=>{if(!Te?.trackedChange)return!1;const Ne=Te.trackedChangeAnchorKey!=null?String(Te.trackedChangeAnchorKey):null;return Ne&&$.anchorKey?Ne===$.anchorKey:Ne||$.anchorKey?!1:Te.commentId===$.runtimeRef.rawId||Te.importedId===$.runtimeRef.rawId});cr({superdoc:I,params:_l({editor:M,snapshot:$,documentId:ie,event:ue?"update":"add",resolveFromEditor:he}),broadcastChanges:se,documentState:de}),ue&&(ue.trackedChangeStory=$.story,ue.trackedChangeStoryKind=$.storyKind,ue.trackedChangeStoryLabel=$.storyLabel,ue.trackedChangeAnchorKey=$.anchorKey)},Sl=I=>I?(Array.isArray(I)?I:[I]).filter(Boolean):[],Sa=()=>{const I=[];return X.value.forEach(M=>{const $=M.getValues(),ie=$.commentText,se=Sl($.docxCommentJSON),de=se.length?se:ju(ie);I.push({...$,commentJSON:de})}),I},ju=I=>{const M=new d_({mode:"text",isHeadless:!0,content:I,extensions:f_()}).getJSON();return Array.isArray(M?.content)?M.content.filter(Boolean):[]},kl=(I,M={})=>{if(I==null)return;const $=M?.retainMissingTrackedChangeGeometry===!0,ie=$&&M?.retainedTrackedChangeIds!=null?new Set(Array.from(M.retainedTrackedChangeIds,Te=>He(Te)).filter(Boolean)):null,se=re.value||{},de={};Object.entries(I).forEach(([Te,Ne])=>{de[Te]=Ne;const Oe=Ne?.kind==="trackedChange"&&Ne?.storyKey==="body"&&Ne?.threadId!=null?String(Ne.threadId):null;Oe&&de[Oe]===void 0&&(de[Oe]=Ne);const Qe=typeof Ne?.key=="string"?Ne.key:null;Qe&&de[Qe]===void 0&&(de[Qe]=Ne)});const he=(Te,Ne)=>{for(const Oe of kt(Te)){const Qe=Ne[Oe];if(Qe!==void 0&&Ye(Qe,Te))return Qe}return null},ue=(Te,Ne,Oe=[])=>{const Qe=[...kt(Ne),...Oe.map(ct=>He(ct)).filter(Boolean)];for(const ct of new Set(Qe))de[ct]===void 0&&(de[ct]=Te)};X.value.forEach(Te=>{if(!Te?.trackedChange||Te.resolvedTime)return;const Ne=he(Te,de);if(Ne){ue(Ne,Te);return}if(!$||ie&&!kt(Te).some(Qe=>ie.has(Qe)))return;const Oe=he(Te,se);Oe&&ue(Oe,Te,[Oe.key,Oe.threadId])}),re.value=de},Yf=()=>{re.value={}},Al=I=>{if(!I?.trackedChange)return!1;const M=I?.trackedChangeDisplayType;return M==="tableInsert"||M==="tableDelete"?!0:[I?.commentId,I?.importedId,I?.trackedChangeAnchorKey].map($=>$!=null?String($):"").filter(Boolean).some($=>$.includes("word:structural:"))},Il=new WeakMap,Uu=I=>{if(!I)return{ranges:[],ids:new Set};const M=Il.get(I);if(M)return M;const $=[],ie=new Set,se=ue=>{ue!=null&&ue!==""&&ie.add(String(ue))},de=sa?.enumerateStructuralRowChanges;if(typeof de=="function"){let ue=[];try{ue=de(I)??[]}catch{ue=[]}for(const Te of ue){if(!Te?.decidable||!Te?.wholeTable)continue;const Ne=Number(Te.tableFrom),Oe=Number(Te.tableTo);Number.isFinite(Ne)&&Number.isFinite(Oe)&&$.push({from:Ne,to:Oe}),se(Te.id),se(Te.revisionId),se(Te.revisionGroupId),se(Te.sourceId);for(const Qe of Te.rows||[]){const ct=Qe?.node?.attrs?.trackChange;se(ct?.id),se(ct?.sourceId)}}}const he={ranges:$,ids:ie};return Il.set(I,he),he},Gu=I=>{const M=s.getDocument(I)?.getEditor?.();return Uu(M?.state).ranges},El=(I,M)=>!M?.length||!I?.length?!1:I.every($=>{const ie=Number($?.from),se=Number($?.to);return!Number.isFinite(ie)||!Number.isFinite(se)?!1:M.some(de=>ie>=de.from&&se<=de.to)}),Xf=I=>{if(!I?.trackedChange||Al(I))return!1;const M=Gu(I?.fileId);if(!M.length)return!1;const $=ft(I).entry,ie=vo($);return ie?M.some(se=>ie.start>=se.from&&ie.end<=se.to):!1},_c=ke(()=>xn.value?.parentComments.filter(I=>!I.resolvedTime).filter(I=>!hn(I)||oo(I)?!0:!!ft(I).entry).filter(I=>!Xf(I))),xl=ke(()=>_c.value.flatMap(I=>{const{key:M,entry:$}=ft(I);return A8({comment:I,positionKey:M,positionEntry:$,fallbackId:He(I?.commentId)??kt(I)[0]??null})})),Zf=I=>I==null?null:String(I),Ls=(I=null)=>{V.value=Zf(I)},Lo=()=>{O.value=null,Ls(null)},ri=(I,M)=>I==null||M==null?!1:xl.value.some($=>String($.id)===String(I)&&String($.comment?.commentId??$.threadId??"")===String(M)),Wu=I=>{ri(V.value,I)||Ls(null)},Sc=({documentMode:I,commentsVisible:M,trackChangesVisible:$}={})=>{typeof I=="string"&&(h.documentMode=I),typeof M=="boolean"&&(h.commentsVisible=M),typeof $=="boolean"&&(h.trackChangesVisible=$)},kc=I=>{if(Array.isArray(I))return I.map(he=>kc(he)).flat().filter(Boolean);if(!I||typeof I!="object")return I;const M=he=>{if(!he)return he;const ue={...he};return delete ue.fontSize,delete ue.fontFamily,delete ue.eastAsiaFontFamily,Object.keys(ue).length?ue:void 0},$=he=>{if(!he)return he;const ue=typeof he.type=="string"?he.type:he.type?.name,Te=he?.attrs?{...he.attrs}:void 0;return ue==="textStyle"&&Te?{...he,attrs:M(Te)}:{...he,attrs:Te}},ie=he=>Array.isArray(he)?he.filter(Boolean).map(ue=>$(ue)):void 0,se=he=>he&&typeof he=="object"?{...he}:void 0;if(!Array.isArray(I.content))return{type:I.type,...I.text!==void 0?{text:I.text}:{},...I.attrs?{attrs:se(I.attrs)}:{},...I.marks?{marks:ie(I.marks)}:{}};const de=I.content.map(he=>kc(he)).flat().filter(Boolean);return I.type==="run"?de:{type:I.type,...I.attrs?{attrs:se(I.attrs)}:{},...I.marks?{marks:ie(I.marks)}:{},content:de}},Qf=I=>{const M=Array.isArray(I)?I:I?[I]:[];if(M.some($=>$?.content?.length))try{const $=kc(M),ie=Array.isArray($)?$:$?[$]:[];return ie.length?new d_({mode:"text",isHeadless:!0,content:{type:"doc",content:ie},loadFromSchema:!0,extensions:f_()}).getHTML():null}catch($){console.warn("Failed to convert comment",$);return}};return{COMMENT_EVENTS:b,isDebugging:m,hasInitializedComments:T,hasSyncedCollaborationComments:R,editingCommentId:Q,activeComment:O,activeFloatingCommentInstanceId:V,commentDialogs:F,overlappingComments:N,overlappedIds:x,suppressInternalExternal:z,pendingComment:D,currentCommentText:J,commentsList:X,isCommentsListVisible:le,generalCommentIds:qe,editorCommentIds:Se,commentsParentElement:P,editorCommentPositions:re,hasInitializedLocations:j,isCommentHighlighted:xe,floatingCommentsOffset:$e,sortedConversations:st,visibleConversations:At,skipSelectionUpdate:Ee,isFloatingCommentsReady:Ge,instantSidebarAlignmentTargetY:Z,instantSidebarAlignmentThreadId:S,instantSidebarAlignmentInstanceId:ee,getConfig:Ji,documentsWithConverations:gi,getGroupedComments:xn,hasOpenTrackedChanges:Tn,getCommentsByPosition:_r,getFloatingComments:_c,getFloatingCommentInstances:xl,getCommentAliasIds:kt,getTrackedChangeThread:Fe,getCommentPositionKey:pt,getCommentPosition:$t,getCommentAnchoredText:Bn,getCommentAnchorData:xi,resolveCommentPositionEntry:ft,getCommentDocumentId:yl,belongsToDocument:Ca,viewingVisibility:h,isViewingMode:H,shouldRenderReviewInViewing:G,init:it,setViewingVisibility:Sc,getComment:Pt,setActiveComment:so,getCommentLocation:Es,hasOverlapId:jr,getPendingComment:No,showAddComment:Ri,addComment:Mi,addHydratedComment:lo,cancelComment:vi,deleteComment:$o,removePendingComment:Jo,cancelImportedTrackedChangeBootstrap:ml,removeCommentsForDocument:yi,processLoadedDocxComments:wa,translateCommentsForExport:Sa,handleEditorLocationsUpdate:kl,clearEditorCommentPositions:Yf,handleTrackedChangeUpdate:cr,refreshTrackedChangeCommentsByIds:Zi,syncResolvedCommentsWithDocument:io,syncTrackedChangePositionsWithDocument:Jt,setActiveFloatingCommentInstance:Ls,requestInstantSidebarAlignment:va,peekInstantSidebarAlignment:Qi,clearInstantSidebarAlignment:hl,syncTrackedChangeComments:rs,decideTrackedChangeFromSidebar:wl,v2CommentsAdapter:te,setV2CommentsAdapter:Y,getV2CommentsAdapter:K,hydrateCommentsFromV2:Ts,applyReviewSnapshotFromV2:jf,reconcileCommentsFromV2:ti,isV2EditorActive:be,replyCommentV2:xs,editCommentV2:Mo,resolveCommentV2:mc,reopenCommentV2:ya,v2TrackedChangesAdapter:me,setV2TrackedChangesAdapter:Ce,getV2TrackedChangesAdapter:Pe,hydrateTrackedChangesFromV2:Vu,reconcileTrackedChangeMutationFromV2:wc,reconcileTrackedChangesFromV2:_a,remapTrackedChangeIdentities:bc}});var m_='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4c0 0 0 0 0 0s0 0 0 0s0 0 0 0c0 0 0 0 0 0l.3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>',g_='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M137.4 374.6c12.5 12.5 32.8 12.5 45.3 0l128-128c9.2-9.2 11.9-22.9 6.9-34.9s-16.6-19.8-29.6-19.8L32 192c-12.9 0-24.6 7.8-29.6 19.8s-2.2 25.7 6.9 34.9l128 128z"/></svg>',Q8='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M96 128a128 128 0 1 1 256 0A128 128 0 1 1 96 128zM0 482.3C0 383.8 79.8 304 178.3 304l91.4 0C368.2 304 448 383.8 448 482.3c0 16.4-13.3 29.7-29.7 29.7L29.7 512C13.3 512 0 498.7 0 482.3zM625 177L497 305c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L591 143c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"/></svg>',J8='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M144 0a80 80 0 1 1 0 160A80 80 0 1 1 144 0zM512 0a80 80 0 1 1 0 160A80 80 0 1 1 512 0zM0 298.7C0 239.8 47.8 192 106.7 192l42.7 0c15.9 0 31 3.5 44.6 9.7c-1.3 7.2-1.9 14.7-1.9 22.3c0 38.2 16.8 72.5 43.3 96c-.2 0-.4 0-.7 0L21.3 320C9.6 320 0 310.4 0 298.7zM405.3 320c-.2 0-.4 0-.7 0c26.6-23.5 43.3-57.8 43.3-96c0-7.6-.7-15-1.9-22.3c13.6-6.3 28.7-9.7 44.6-9.7l42.7 0C592.2 192 640 239.8 640 298.7c0 11.8-9.6 21.3-21.3 21.3l-213.3 0zM224 224a96 96 0 1 1 192 0 96 96 0 1 1 -192 0zM128 485.3C128 411.7 187.7 352 261.3 352l117.3 0C452.3 352 512 411.7 512 485.3c0 14.7-11.9 26.7-26.7 26.7l-330.7 0c-14.7 0-26.7-11.9-26.7-26.7z"/></svg>',i0='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>',v_='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>',y_='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M64 360a56 56 0 1 0 0 112 56 56 0 1 0 0-112zm0-160a56 56 0 1 0 0 112 56 56 0 1 0 0-112zM120 96A56 56 0 1 0 8 96a56 56 0 1 0 112 0z"/></svg>',b_='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M48.5 224L40 224c-13.3 0-24-10.7-24-24L16 72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2L98.6 96.6c87.6-86.5 228.7-86.2 315.8 1c87.5 87.5 87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3c-62.2-62.2-162.7-62.5-225.3-1L185 183c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8L48.5 224z"/></svg>';const la={comment:m_,caretDown:g_,internal:Q8,external:J8,markDone:i0,acceptChange:i0,rejectChange:v_,overflow:y_,reopen:b_};var $8=.38,e7=".superdoc-comment-highlight",t7=e=>{if(typeof e?.getBoundingClientRect!="function")return!1;const t=e.getBoundingClientRect();return!Number.isFinite(t.top)||!Number.isFinite(t.bottom)?!1:t.bottom>0&&t.top<window.innerHeight},n7=e=>e?e.split(",").map(t=>t.trim()).filter(Boolean):[],r7=e=>{const t=[];return e?(e.split(",").forEach(n=>{const r=n.indexOf("=");r<=0||t.push(n.slice(0,r),n.slice(r+1))}),t.filter(Boolean)):t};const o7=()=>Math.round(window.innerHeight*$8),w_=(e,t)=>{const n=t?.bounds?.top;if(!Number.isFinite(n)||typeof e?.getBoundingClientRect!="function")return null;const r=e.getBoundingClientRect().top+n;return r<0||r>=window.innerHeight?null:r},i7=e=>{if(typeof document>"u")return null;const t=new Set((e??[]).map(o=>String(o)).filter(Boolean));if(t.size===0)return null;let n=null;const r=document.querySelectorAll(e7);for(const o of r){const i=new Set([...n7(o.getAttribute("data-comment-ids")),...r7(o.getAttribute("data-comment-imported-ids"))]);if(![...t].some(a=>i.has(a))||!t7(o))continue;const s=o.getBoundingClientRect().top;Number.isFinite(s)&&(n=n==null?s:Math.min(n,s))}return n},s7=(e,t,n,r)=>{if(!e||!Number.isFinite(r))return null;const o=s=>{if(!s)return null;const a=e.getReachableThreadAnchorClientY(s,r);return Number.isFinite(a)&&e.scrollThreadAnchorToClientY(s,r,{behavior:"auto"})?a:null},i=o(t);return Number.isFinite(i)?i:!n||n===t?null:o(n)};xt();const a7="Arial, Helvetica, sans-serif";function s0(){const e=ir();return{uiFontFamily:ke(()=>{const t=e?.proxy?.$superdoc?.config?.uiDisplayFallbackFont;return typeof t=="string"&&t.trim()?t.trim():a7})}}var fn,gn=Ir((()=>{fn=(e,t)=>{const n=e.__vccOpts||e;for(const[r,o]of t)n[r]=o;return n}}));xt(),gn();var l7={class:"comments-dropdown"},c7=["onClick"],u7={key:0,class:"comments-dropdown__option-icon"},d7=["innerHTML"],f7={class:"comments-dropdown__option-label"},h7={__name:"CommentsDropdown",props:{options:{type:Array,default:()=>[]},disabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})}},emits:["select"],setup(e,{emit:t}){const n=e,r=t,o=ne(!1),i=ne(null),s=ne(null),a=ne({top:"0px",left:"0px"}),l=ke(()=>({...n.contentStyle,position:"fixed",top:a.value.top,left:a.value.left,zIndex:1200})),u=b=>{n.disabled&&b||(o.value=b)},c=()=>{n.disabled||u(!o.value)},d=()=>{o.value&&u(!1)},h=()=>{if(!i.value)return;const b=i.value.getBoundingClientRect(),T=s.value?.offsetWidth??0,R=window.innerWidth||document.documentElement.clientWidth||0,P=8;let j=b.left;const O=Math.max(P,R-T-P);j=Math.min(Math.max(P,j),O),a.value={top:`${b.bottom+4}px`,left:`${j}px`}},m=b=>{b.stopPropagation(),c()},p=b=>{b?.disabled||(r("select",b?.key,b),d())},v=b=>!!b?.iconString||!!b?.icon,_=b=>b?.iconString?b.iconString:typeof b?.icon=="function"?b.icon(b):b?.icon||null,C=jl({name:"CommentsDropdownOptionIcon",props:{option:{type:Object,required:!0}},setup(b){return()=>_(b.option)}}),k=b=>{if(!o.value)return;const T=b.target;if(!(T instanceof Element))return;const R=i.value?.contains(T),P=s.value?.contains(T);R||P||d()},y=b=>{b.key==="Escape"&&d()};return Lt(o,async b=>{b&&(await _t(),h())}),Lt(o,b=>{b?(document.addEventListener("pointerdown",k,!0),document.addEventListener("keydown",y,!0),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0)):(document.removeEventListener("pointerdown",k,!0),document.removeEventListener("keydown",y,!0),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0))}),or(()=>{document.removeEventListener("pointerdown",k,!0),document.removeEventListener("keydown",y,!0),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0)}),(b,T)=>(ge(),Ae("div",l7,[Me("div",{ref_key:"triggerRef",ref:i,class:"comments-dropdown__trigger",onClick:m},[Ad(b.$slots,"default",{},void 0,!0)],512),(ge(),dn(Ha,{to:"body"},[o.value?(ge(),Ae("div",{key:0,ref_key:"menuRef",ref:s,class:"comments-dropdown__menu",style:yn(l.value)},[(ge(!0),Ae(Wt,null,rr(e.options,R=>(ge(),Ae("div",{key:R.key,class:rn(["comments-dropdown__option",{"sd-disabled":R.disabled}]),onClick:P=>p(R)},[v(R)?(ge(),Ae("span",u7,[R.iconString?(ge(),Ae("span",{key:0,innerHTML:R.iconString},null,8,d7)):(ge(),dn(et(C),{key:1,option:R},null,8,["option"]))])):ht("",!0),Me("span",f7,Bt(R.label),1)],10,c7))),128))],4)):ht("",!0)]))]))}},C_=fn(h7,[["__scopeId","data-v-7eced80a"]]);xt(),gn();var p7={class:"sd-comment-option"},m7=["innerHTML"],g7={class:"sd-option-state"},v7=["innerHTML"],y7={__name:"InternalDropdown",props:{state:{type:String,required:!1},isDisabled:{type:Boolean,default:!1}},emits:["select"],setup(e,{emit:t}){const n=t,r=e,{uiFontFamily:o}=s0(),i=[{label:"Internal",key:"internal",iconString:la.internal,backgroundColor:"var(--sd-ui-comments-internal-bg, #CDE6E6)"},{label:"External",key:"external",iconString:la.external,backgroundColor:"var(--sd-ui-comments-external-bg, #F5CFDA)"}],s=ke(()=>i.find(d=>d.key===u.value)?.label),a=ke(()=>{if(!r.state)return{};const d=i.find(m=>m.key===u.value);if(!d)return{};const h={backgroundColor:d.backgroundColor};return r.isDisabled&&(h.opacity=.5,h.cursor="default"),h}),l=(d,h=!1)=>{u.value=d,c.value=i.find(m=>m.key===d)?.iconString,!h&&n("select",d)},u=ne(r.state),c=ne(null);return Lt(()=>r.state,d=>{l(d)}),Nn(()=>{l(r.state,!0)}),(d,h)=>(ge(),Ae("div",{class:"sd-internal-dropdown",style:yn(a.value),"data-sd-part":"dropdown-trigger"},[jt(C_,{options:i,onSelect:h[0]||(h[0]=m=>l(m)),disabled:e.isDisabled,"content-style":{fontFamily:et(o)}},{default:Eo(()=>[Me("div",p7,[Me("div",{class:"sd-active-icon",innerHTML:c.value},null,8,m7),Me("div",g7,Bt(s.value),1),Me("div",{class:"sd-dropdown-caret",innerHTML:et(la).caretDown},null,8,v7)])]),_:1},8,["disabled","content-style"])],4))}},__=fn(y7,[["__scopeId","data-v-138d641e"]]);function b7(e){const t=new Date(e),n=t.getHours(),r=t.getMinutes(),o=n>=12?"PM":"AM",i=n%12||12,s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],a=t.getDate();return`${`${i}:${r.toString().padStart(2,"0")}${o}`} ${s} ${a}`}const no=Object.freeze({RESOLVE_OWN:"RESOLVE_OWN",RESOLVE_OTHER:"RESOLVE_OTHER",REJECT_OWN:"REJECT_OWN",REJECT_OTHER:"REJECT_OTHER",COMMENTS_OVERFLOW_OWN:"COMMENTS_OVERFLOW",COMMENTS_OVERFLOW_OTHER:"COMMENTS_OVERFLOW_OTHER",COMMENTS_DELETE_OWN:"COMMENTS_DELETE_OWN",COMMENTS_DELETE_OTHER:"COMMENTS_DELETE_OTHER",UPLOAD_VERSION:"UPLOAD_VERSION",VERSION_HISTORY:"VERSION_HISTORY"});var mr=Object.freeze({EDITOR:"editor",SUGGESTER:"suggester",VIEWER:"viewer"}),w7=Object.freeze({[no.RESOLVE_OWN]:{internal:[mr.EDITOR],external:[mr.EDITOR]},[no.RESOLVE_OTHER]:{internal:[mr.EDITOR],external:[mr.EDITOR]},[no.REJECT_OWN]:{internal:[mr.EDITOR,mr.SUGGESTER],external:[mr.EDITOR,mr.SUGGESTER]},[no.REJECT_OTHER]:{internal:[mr.EDITOR],external:[mr.EDITOR]},[no.COMMENTS_OVERFLOW_OWN]:{internal:[mr.EDITOR,mr.SUGGESTER],external:[mr.EDITOR,mr.SUGGESTER]},[no.COMMENTS_OVERFLOW_OTHER]:{internal:[mr.EDITOR],external:[mr.EDITOR]},[no.COMMENTS_DELETE_OWN]:{internal:[mr.EDITOR,mr.SUGGESTER],external:[mr.EDITOR,mr.SUGGESTER]},[no.COMMENTS_DELETE_OTHER]:{internal:[mr.EDITOR],external:[mr.EDITOR]},[no.UPLOAD_VERSION]:{internal:[mr.EDITOR],external:[]},[no.VERSION_HISTORY]:{internal:[mr.EDITOR],external:[]}}),C7=(e={})=>{if(typeof e.permissionResolver=="function")return e.permissionResolver;if(e.superdoc?.config?.modules?.comments?.permissionResolver){const t=e.superdoc.config.modules.comments.permissionResolver;if(typeof t=="function")return t}return typeof e.superdoc?.config?.permissionResolver=="function"?e.superdoc.config.permissionResolver:null},_7=(e,t,n)=>{const r=n?"internal":"external";return w7[e]?.[r]?.includes(t)??!1};const ca=(e,t,n,r={})=>{const o=_7(e,t,n),i=C7(r);if(typeof i!="function")return o;const s=i({permission:e,role:t,isInternal:n,defaultDecision:o,comment:r.comment??null,currentUser:r.currentUser??r.superdoc?.config?.user??null,superdoc:r.superdoc??null,trackedChange:r.trackedChange??null});return typeof s=="boolean"?s:o};xt(),gn();var S7={class:"user-container"},k7=["src"],A7={key:1,class:"user-bg"},I7={__name:"Avatar",props:{user:{type:Object,required:!0}},setup(e){const t=(n,r)=>{if(!(!n&&!r)){if(n){const o=n.trim().split(/\s+/).filter(i=>/^[a-zA-Z]/.test(i));if(o.length>=2)return(o[0][0]+o[o.length-1][0]).toUpperCase();if(o.length===1)return o[0][0].toUpperCase()}return r?.substring(0,1)?.toUpperCase()||null}};return(n,r)=>(ge(),Ae("div",S7,[e.user.image?(ge(),Ae("img",{key:0,class:"user-bg",src:e.user.image.startsWith("http")?e.user.image:`data:image/png;base64,${e.user.image}`},null,8,k7)):(ge(),Ae("span",A7,Bt(t(e.user.name,e.user.email)),1))]))}},S_=fn(I7,[["__scopeId","data-v-c95b2073"]]);xt(),gn();var E7={class:"card-section comment-header"},x7={class:"comment-header-left"},T7={class:"user-info"},R7={class:"user-name"},M7={key:0,class:"imported-tag"},L7={key:0,class:"user-timestamp"},P7=["data-disabled-reason","aria-disabled","innerHTML"],D7=["data-disabled-reason","aria-disabled","innerHTML"],O7=["data-disabled-reason","aria-disabled","innerHTML"],F7={class:"overflow-menu__icon"},N7=["innerHTML"],B7={__name:"CommentHeader",props:{timestamp:{type:Number,required:!1},config:{type:Object,required:!0},comment:{type:Object,required:!1},isPendingInput:{type:Boolean,required:!1,default:!1},isActive:{type:Boolean,default:!1},resolveDisabledReason:{type:String,default:null},rejectDisabledReason:{type:String,default:null},reopenDisabledReason:{type:String,default:null},reopenSupported:{type:Boolean,default:!1},writeDisabledReason:{type:String,default:null}},emits:["resolve","reject","reopen","overflow-select"],setup(e,{emit:t}){const n=t,r=aa(),o=e,{proxy:i}=ir(),s=i.$superdoc.config.role,a=i.$superdoc.config.isInternal,l=V=>{const Q=i.$superdoc.config.user,F={id:V?.creatorId,email:V?.creatorEmail};if(Zw({current:Q,other:F}))return!0;const N=Gd(Q),x=Gd(F);if(N.hasId||N.hasEmail||x.hasId||x.hasEmail||V?.origin!=null||V?.importedAuthor?.name)return!1;const z=Xw(Q?.name),J=Xw(V?.creatorName);return!!(z&&J&&z===J)},u=ke(()=>l(o.comment)),c=ke(()=>Mp(o.comment)),{uiFontFamily:d}=s0(),h=Object.freeze({edit:{label:"Edit",key:"edit"},delete:{label:"Delete",key:"delete"}}),m=ke(()=>o.config.readOnly!==!0),p=ke(()=>!(!m.value||!o.comment||o.comment.resolvedTime||r.pendingComment||o.isPendingInput)),v=ke(()=>{if(!p.value||!o.comment.trackedChange&&o.config.allowResolve===!1||o.comment.parentCommentId||c.value)return!1;const V={comment:o.comment,currentUser:i.$superdoc.config.user,superdoc:i.$superdoc};return u.value||o.comment.trackedChange?ca(no.RESOLVE_OWN,s,a,V):ca(no.RESOLVE_OTHER,s,a,V)}),_=ke(()=>{if(!p.value||!o.comment.trackedChange)return!1;const V={comment:o.comment,currentUser:i.$superdoc.config.user,superdoc:i.$superdoc};return u.value||o.comment.trackedChange?ca(no.REJECT_OWN,s,a,V):ca(no.REJECT_OTHER,s,a,V)}),C=ke(()=>{if(!m.value||o.config.allowResolve===!1||!o.reopenSupported||!o.comment||!o.comment.resolvedTime||r.pendingComment||o.isPendingInput||o.comment.parentCommentId||c.value||o.comment.trackedChange)return!1;const V={comment:o.comment,currentUser:i.$superdoc.config.user,superdoc:i.$superdoc};return u.value?ca(no.RESOLVE_OWN,s,a,V):ca(no.RESOLVE_OTHER,s,a,V)}),k=ke(()=>!(!p.value||o.comment.trackedChange||o.isPendingInput||y.value.length===0)),y=ke(()=>{if(!m.value)return[];if(!p.value)return[];if(o.writeDisabledReason)return[];const V=[],Q=new Set;l(o.comment)&&Q.add("edit");const F=l(o.comment),N={comment:o.comment,currentUser:i.$superdoc.config.user,superdoc:i.$superdoc};return(F&&ca(no.COMMENTS_DELETE_OWN,s,a,N)||!F&&ca(no.COMMENTS_DELETE_OTHER,s,a,N))&&Q.add("delete"),Q.forEach(x=>V.push(h[x])),V}),b=()=>{m.value&&(!o.comment?.trackedChange&&o.config.allowResolve===!1||o.resolveDisabledReason||n("resolve"))},T=()=>{m.value&&(o.rejectDisabledReason||n("reject"))},R=()=>{!m.value||o.config.allowResolve===!1||o.reopenDisabledReason||n("reopen")},P=V=>{m.value&&n("overflow-select",V)},j=ke(()=>!(!(o.comment.origin!=null||o.comment.importedAuthor?.name)||l(o.comment))),O=ke(()=>{if(o.isPendingInput)return i.$superdoc.config.user;const V=o.comment.getCommentUser();if(V?.name){const Q=V.name.replace(/\s*\(imported\)\s*/gi,"").trim();if(Q)return{...V,name:Q}}return V});return(V,Q)=>(ge(),Ae("div",E7,[Me("div",x7,[jt(S_,{user:O.value,class:"avatar"},null,8,["user"]),Me("div",T7,[Me("div",R7,[Ni(Bt(O.value.name),1),j.value?(ge(),Ae("span",M7,"IMPORTED")):ht("",!0)]),o.comment.createdTime?(ge(),Ae("div",L7,Bt(et(b7)(o.comment.createdTime)),1)):ht("",!0)])]),Me("div",{class:rn(["overflow-menu",{"is-visible":o.isActive}])},[v.value?(ge(),Ae("div",{key:0,class:rn(["overflow-menu__icon",{"sd-is-disabled":!!e.resolveDisabledReason}]),"data-comment-action":"resolve","data-disabled-reason":e.resolveDisabledReason||null,"aria-disabled":!!e.resolveDisabledReason,innerHTML:et(la).markDone,onClick:tn(b,["stop","prevent"])},null,10,P7)):ht("",!0),_.value?(ge(),Ae("div",{key:1,class:rn(["overflow-menu__icon",{"sd-is-disabled":!!e.rejectDisabledReason}]),"data-comment-action":"reject","data-disabled-reason":e.rejectDisabledReason||null,"aria-disabled":!!e.rejectDisabledReason,innerHTML:et(la).rejectChange,onClick:tn(T,["stop","prevent"])},null,10,D7)):ht("",!0),C.value?(ge(),Ae("div",{key:2,class:rn(["overflow-menu__icon overflow-menu__icon--reopen",{"sd-is-disabled":!!e.reopenDisabledReason}]),"data-disabled-reason":e.reopenDisabledReason||null,"data-comment-reopen":!0,"aria-disabled":!!e.reopenDisabledReason,title:"Reopen comment",innerHTML:et(la).reopen,onClick:tn(R,["stop","prevent"])},null,10,O7)):ht("",!0),k.value?(ge(),dn(C_,{key:3,"data-comment-action":"overflow",options:y.value,onSelect:P,"content-style":{fontFamily:et(d)}},{default:Eo(()=>[Me("div",F7,[Me("div",{class:"overflow-icon",innerHTML:et(la).overflow},null,8,N7)])]),_:1},8,["options","content-style"])):ht("",!0)],2)]))}},a0=fn(B7,[["__scopeId","data-v-ca6050aa"]]);xt(),gn();var z7={class:"input-section"},l0=28,k_=132,V7={__name:"CommentInput",props:{users:{type:Array,required:!1,default:()=>[]},config:{type:Object,required:!0},isFocused:{type:Boolean,default:!1},includeHeader:{type:Boolean,default:!0},comment:{type:Object,required:!1}},emits:["focus"],setup(e,{expose:t,emit:n}){const r=n,{currentCommentText:o}=Js(aa()),i=ne(null),s=p=>r("focus",p),a=()=>{i.value?.focus?.()},l=()=>{const p=i.value;if(!p)return;p.style.height=`${l0}px`;const v=p.scrollHeight||l0,_=Math.min(Math.max(v,l0),k_);p.style.height=`${_}px`,p.style.overflowY=v>k_?"auto":"hidden"},u=()=>{_t(l)},c=p=>String(p??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),d=p=>{const v=String(p??"");if(!v||v==="<p></p>")return"";if(typeof document>"u")return v.replace(/<br\s*\/?>/gi,`
|
|
13
13
|
`).replace(/<[^>]+>/g,"");const _=document.createElement("div");return _.innerHTML=v,_.innerText||_.textContent||""},h=p=>{const v=String(p??"").replace(/\r\n/g,`
|
|
14
|
-
`).trim();return v?v.split(/\n{2,}/).map(_=>`<p>${c(_).replace(/\n/g,"<br>")}</p>`).join(""):"<p></p>"},m=ke({get:()=>d(o.value),set:p=>{o.value=h(p)}});return Nn(u),Lt(o,u),t({focus:a}),(p,v)=>(ge(),Ae("div",z7,[e.includeHeader?(ge(),dn(a0,{key:0,config:e.config,comment:e.comment,"is-pending-input":!0},null,8,["config","comment"])):ht("",!0),Me("div",{class:rn(["comment-entry",{"sd-input-active":e.isFocused}])},[Us(Me("textarea",{ref_key:"inputRef",ref:i,class:"superdoc-field",placeholder:"Add a comment","onUpdate:modelValue":v[0]||(v[0]=_=>m.value=_),rows:"1",onInput:l,onFocus:v[1]||(v[1]=_=>s(!0)),onBlur:v[2]||(v[2]=_=>s(!1))},null,544),[[Ai,m.value]])],2)]))}},c0=fn(V7,[["__scopeId","data-v-cc54b489"]]);xt(),gn();var H7=["data-comment-instance-id","data-comment-thread-id","data-comment-position-key","data-comment-page-index"],j7={key:0,class:"existing-internal-input"},U7={class:"new-comment-input-wrapper"},G7={class:"reply-actions"},W7=["disabled"],K7={key:0,class:"resolved-badge"},q7=["innerHTML"],Y7={key:1,class:"existing-internal-input"},X7={key:0,class:"card-section comment-body"},Z7=["data-track-change-semantic-color-key"],Q7={key:0},J7={class:"change-type tracked-change-label"},$7={key:0,class:"tracked-change-detail-lines"},eR={key:0,class:"tracked-change-text"},tR={key:1,class:"change-type"},nR={class:"change-type"},rR={key:1},oR={class:"tracked-change-text is-inserted"},iR={key:2},sR={class:"tracked-change-text is-inserted"},aR={key:3},lR={key:4},cR={key:5},uR={key:6},dR={class:"tracked-change-text"},fR={key:7},hR={class:"tracked-change-text is-deleted"},pR={class:"tracked-change-text is-inserted"},mR={key:8},gR={class:"tracked-change-text is-deleted"},vR={key:9},yR={class:"tracked-change-text is-inserted"},bR=["data-track-change-image-preview-role"],wR=["src","alt"],CR={key:1,class:"card-section comment-body"},_R=["innerHTML"],SR={key:1,class:"comment"},kR={key:2,class:"reply-expanded"},AR={class:"reply-input-wrapper"},IR={class:"reply-actions"},ER=["onClick"],xR=["onClick","disabled","data-disabled-reason"],TR={class:"collapsed-avatars"},RR={key:3,class:"comment-separator"},MR={key:2,class:"tracked-change-decision-alert",role:"alert"},LR={class:"tracked-change-decision-alert__message"},PR=["disabled","data-disabled-reason"],DR={key:1,class:"reply-expanded"},OR={class:"reply-input-wrapper"},FR={class:"reply-actions"},NR=["disabled","data-disabled-reason"],Lp=3,A_=90,BR={__name:"CommentDialog",props:{comment:{type:Object,required:!0},autoFocus:{type:Boolean,default:!1},parent:{type:Object,required:!1},floatingInstanceId:{type:String,default:null},floatingPageIndex:{type:Number,default:null},floatingPositionEntry:{type:Object,default:null},isFloatingInstanceActive:{type:Boolean,default:void 0}},emits:["click-outside","ready","dialog-exit","resize"],setup(e,{emit:t}){const n=t,r=e,{proxy:o}=ir(),i=hu(),s=aa(),{addComment:a,cancelComment:l,deleteComment:u,getCommentAliasIds:c,removePendingComment:d,getCommentDocumentId:h,requestInstantSidebarAlignment:m,resolveCommentPositionEntry:p,clearInstantSidebarAlignment:v,setActiveFloatingCommentInstance:_}=s,{suppressInternalExternal:C,getConfig:k,activeComment:y,activeFloatingCommentInstanceId:b,floatingCommentsOffset:T,pendingComment:R,currentCommentText:P,isDebugging:j,editingCommentId:O,editorCommentPositions:V,isCommentHighlighted:Q}=Js(s),F=ne(!0),N=ne(null),x=ne(new Map),z=ne(null),J=[[0,0],[-Lp,0],[Lp,0],[0,-Lp],[0,Lp]],X=_e=>{const ze=typeof _e?.width=="number"&&Number.isFinite(_e.width)?_e.width:null,vt=typeof _e?.height=="number"&&Number.isFinite(_e.height)?_e.height:null;if(!ze||!vt||ze<=0||vt<=0)return{};const ot=Math.min(A_/ze,A_/vt,1);return{width:`${Math.max(1,Math.round(ze*ot))}px`,height:`${Math.max(1,Math.round(vt*ot))}px`}},ae=[".comments-dropdown__option-label",".comments-dropdown__menu",".comments-dropdown__option",".comments-dropdown__option-icon",".comments-dropdown__trigger",".superdoc-comment-highlight",".sd-editor-comment-highlight",".sd-editor-tracked-change-highlight","[data-track-change-id]",".track-insert",".track-insert-dec",".track-delete",".track-delete-dec",".track-format",".track-format-dec"].join(","),pe=_e=>ze=>{_e&&(ze?(x.value.set(_e,ze),O.value===_e&&_t(()=>{ye(_e)})):x.value.delete(_e))},Fe=(_e,ze,vt)=>{const ot=_e?.getBoundingClientRect?.();return!ot||![ot.left,ot.top,ot.right,ot.bottom].every(Number.isFinite)||ot.width<=0||ot.height<=0?!1:J.some(([xn,Tn])=>{const _r=ze+xn,jr=vt+Tn;return _r>=ot.left&&_r<=ot.right&&jr>=ot.top&&jr<=ot.bottom})},fe=(_e,ze)=>{if(!Number.isFinite(_e)||!Number.isFinite(ze))return null;const vt=document.querySelectorAll(ae);for(const ot of vt)if(ot instanceof HTMLElement&&Fe(ot,_e,ze))return ot;return null},ye=_e=>{x.value.get(_e)?.focus?.()},le=ne(null),Se=_e=>_e.resolvedTime?_e.commentId:_e.importedId||_e.commentId,re=_e=>_e?_e.trackedChange&&_e.importedId!=null?String(_e.importedId):_e.commentId!=null?String(_e.commentId):null:null,xe=(_e,ze)=>{const vt=_e?.bounds?.[ze];return Number.isFinite(vt)?vt:null},$e=(_e,ze)=>{if(!_e||!ze||_e.pageIndex!==ze.pageIndex)return!1;const vt=xe(_e,"top"),ot=xe(ze,"top");return vt!=null&&ot!=null&&Math.abs(vt-ot)<.5},st=(_e,ze)=>{const vt=xe(_e,"left"),ot=xe(ze,"left"),xn=xe(_e,"right"),Tn=xe(ze,"right");return[vt,ot,xn,Tn].some(_r=>_r==null)?!1:ot<xn&&vt<Tn},At=(_e,ze)=>{const vt=_e?.start,ot=_e?.end,xn=ze?.start,Tn=ze?.end;return[vt,ot,xn,Tn].every(Number.isFinite)?xn<=ot&&vt<=Tn:!1},Ee=(_e,ze)=>!_e||!ze||_e.kind&&ze.kind&&_e.kind!==ze.kind||_e.storyKey&&ze.storyKey&&_e.storyKey!==ze.storyKey?!1:ze.start===_e.start&&ze.end===_e.end?!0:$e(_e,ze)&&st(_e,ze)&&At(_e,ze),Ge=_e=>{const ze=new Set(c(_e)),{key:vt,entry:ot}=p(_e);return vt&&ze.add(vt),ot?(Object.entries(V.value??{}).forEach(([xn,Tn])=>{Ee(ot,Tn)&&ze.add(xn)}),[...ze]):[...ze]},qe=(_e,ze,vt=24)=>{if(!Number.isFinite(ze)||typeof _e?.getBoundingClientRect!="function")return!1;const ot=_e.getBoundingClientRect().top;return Number.isFinite(ot)&&Math.abs(ot-ze)<=vt},Z=ke(()=>r.floatingInstanceId??r.comment.commentId??null),S=ke(()=>typeof r.isFloatingInstanceActive=="boolean"?r.isFloatingInstanceActive:y.value!==r.comment.commentId?!1:r.floatingInstanceId==null?!0:b.value===r.floatingInstanceId),ee=ke(()=>r.comment.resolvedTime?r.comment.trackedChange?r.comment.trackedChangeDecision==="reject"?"Rejected":"Accepted":"Resolved":null),D=ke(()=>R.value&&R.value.commentId===r.comment.commentId),U=ke(()=>_e=>{const ze=Ye.value;return H.value&&_e===ze.length-1?!0:ze.length>1&&_e!==ze.length-1}),H=ke(()=>!k.readOnly&&S.value&&!r.comment.resolvedTime&&!Pt.value),G=()=>({ok:!1,reason:"read-only-document"}),te=()=>k.value?.readOnly===!0,Y=ne(!1),K=ne(!1),be=()=>{if(te())return G();if(hn.value)return{ok:!1,reason:cn.value?.reason??"v2-write-unavailable"};Y.value=!0,_t(()=>{N.value?.focus?.(),n("resize")})},me=ke(()=>{const _e=r.comment;return _e.trackedChange?s.getTrackedChangeThread(_e):s.commentsList.filter(ze=>{const vt=ze.parentCommentId===_e.commentId,ot=ze.commentId===_e.commentId;return vt||ot}).sort((ze,vt)=>ze.commentId===_e.commentId?-1:vt.commentId===_e.commentId?1:ze.createdTime-vt.createdTime)}),Ce=ne(!1),Pe=ne(null),it=ne(!1),He=ke(()=>!Ce.value),Ct=ke(()=>({"is-truncated":He.value,"is-scrollable":Ce.value&&it.value})),Yt=()=>{Ce.value=!Ce.value,_t(()=>n("resize"))},St=_e=>{Pe.value=_e??null},Ft=()=>{if(Ce.value)return;const _e=Pe.value;if(!_e){it.value=!1;return}it.value=_e.scrollHeight>_e.clientHeight+1};Lt(Pe,()=>{_t(Ft)});const Nt=()=>O.value?me.value.some(_e=>_e.commentId===O.value):!1;Lt(S,_e=>{_e||((Y.value||Nt())&&(P.value="",O.value=null),Ce.value=!1,sn.value=!1,Y.value=!1,_t(()=>n("resize")))});const sn=ne(!1),_n=ke(()=>me.value.slice(1)),Qt=ke(()=>sn.value?!1:_n.value.length>=2),Ye=ke(()=>Qt.value?[me.value[0],_n.value[_n.value.length-1]].filter(Boolean):me.value);Lt(ke(()=>{const _e=Ye.value[0];return _e?JSON.stringify({commentId:_e.commentId,commentText:_e.commentText,trackedChange:_e.trackedChange,trackedChangeText:_e.trackedChangeText,deletedText:_e.deletedText,trackedChangeLabel:_e.trackedChangeLabel,trackedChangeDisplayType:_e.trackedChangeDisplayType,trackedChangeDetailLines:_e.trackedChangeDetailLines}):""}),()=>{_t(Ft)});const Et=ke(()=>Qt.value?_n.value.length-1:0),Ot=ke(()=>{if(!Qt.value)return[];const _e=_n.value.slice(0,-1),ze=new Set;return _e.map(vt=>typeof vt.getCommentUser=="function"?vt.getCommentUser():{name:vt.creatorName,email:vt.creatorEmail||vt.email}).filter(vt=>{if(!vt)return!1;const ot=vt.email||vt.name;return ze.has(ot)?!1:(ze.add(ot),!0)}).slice(0,3)}),wn=()=>{sn.value=!0,Ke(),_t(()=>n("resize"))},Kt=ke(()=>r.comment.resolvedTime?!0:k.value.readOnly),Sn=ke(()=>_e=>S.value&&O.value===_e.commentId),Pt=ke(()=>!O.value||!S.value?!1:me.value.some(_e=>_e.commentId===O.value)),De=ke(()=>k.value.readOnly||!o.$superdoc.config.isInternal||ft.value?!1:!C.value&&!r.comment.trackedChange),je=ke(()=>P.value&&P.value!=="<p></p>"),Ke=async()=>{const _e=o.$superdoc.activeEditor,ze=_e?.editorVersion===2?_e?.v2Comments??null:null,vt=!!r.comment?.trackedChange,ot=o7(),xn=r.floatingInstanceId!=null,Tn=le.value?.getBoundingClientRect?.().top,_r=!r.comment.resolvedTime&&(y.value!==r.comment.commentId||xn&&Z.value!==b.value);let jr=ot;if(ze){const gi=!vt&&String(r.comment?.trackedChangeParentId??"").trim()?r.comment.trackedChangeParentId:null,Ji=_e?.editorVersion===2&&(vt||gi!=null)?_e?.v2TrackedChanges??null:null,Es=gi!=null?s.getComment(gi):null,No=vt?r.comment:Es?.trackedChange?Es:gi;let Yr=await(Ji?Ji.focusTrackedChange(No):ze.focusComment(r.comment));return!vt&&Yr?.reason==="tracked-change-anchor-not-found"&&(Yr=await ze.focusComment(r.comment)),Yr?.ok?(r.comment.resolvedTime||(y.value=r.comment.commentId,r.floatingInstanceId&&_(r.floatingInstanceId)),_r&&!xn?m(ot,r.comment.commentId,r.floatingInstanceId??null):_r&&Number.isFinite(Tn)?m(Tn,r.comment.commentId,r.floatingInstanceId):v(),Yr):(v(),Yr)}if(_e){const{entry:gi}=p(r.comment),Ji=r.floatingPositionEntry??gi,Es=Number.isFinite(r.floatingPageIndex)&&r.comment?.trackedChangeStory?.storyType==="headerFooterPart",No=w_(r.parent,Ji),Yr=Es?null:i7(Ge(r.comment)),Jo=Number.isFinite(Yr)?Yr:No,$i=qe(le.value,Jo),Mi=Se(r.comment),lo=null;let $o=null;if(vt)if(r.comment.trackedChangeStory&&(r.comment.trackedChangeStory,{...Number.isFinite(r.floatingPageIndex)?{pageIndex:r.floatingPageIndex}:{}}),r.comment.resolvedTime)_e.commands?.setCursorById(Mi);else{const Xr=r.comment.commentId;_e.commands?.setCursorById(Mi,{activeCommentId:Xr})||_e.commands?.setActiveComment({commentId:Xr})}else{if(r.comment.resolvedTime)_e.commands?.setCursorById(Mi);else{const ur=r.comment.commentId;_e.commands?.setCursorById(Mi,{activeCommentId:ur})||_e.commands?.setActiveComment({commentId:ur})}const Xr=r.comment.commentId;$o=$i?null:s7(lo,Mi,Xr,ot)}Number.isFinite(Yr)?jr=Yr:Number.isFinite(No)?jr=No:Number.isFinite($o)&&(jr=$o)}_r&&!xn?r.floatingInstanceId?m(jr,r.comment.commentId,r.floatingInstanceId):m(jr,r.comment.commentId):v(),r.comment.resolvedTime||(y.value=r.comment.commentId,r.floatingInstanceId&&_(r.floatingInstanceId))},pt=_e=>{const ze=_e.target instanceof Element?_e.target:_e.target?.parentElement,vt=document.elementFromPoint(_e.clientX,_e.clientY);if(!(ze?.closest?.(ae)||vt?.closest?.(ae)||fe(_e.clientX,_e.clientY)||Q.value)&&!(_e.target.closest?.(".comments-dialog")&&!le.value?.contains(_e.target))){if(D.value){l(o.$superdoc);return}S.value&&(T.value=0,n("dialog-exit"),y.value=null,s.setActiveComment(o.$superdoc,y.value),Q.value=!1)}},kt=async()=>{if(te())return G();if(hn.value)return{ok:!1,reason:cn.value?.reason??"v2-write-unavailable"};if(ft.value&&an.value&&!D.value){if(K.value)return{ok:!1,reason:"reply-submit-in-flight"};K.value=!0;try{const vt=await s.replyCommentV2({superdoc:o.$superdoc,parentCommentId:re(r.comment),text:P.value});return vt?.ok?(Y.value=!1,P.value="",_t(()=>n("resize")),vt):(_t(()=>n("resize")),vt)}finally{K.value=!1}}const _e={documentId:r.comment.fileId,isInternal:R.value?R.value.isInternal:F.value,parentCommentId:R.value?null:r.comment.commentId};R.value&&(_e.selection=R.value.selection.getValues());const ze=s.getPendingComment(_e);!R.value&&P.value&&ze.setText({text:P.value,suppressUpdate:!0}),Promise.resolve(a({superdoc:o.$superdoc,comment:ze})).finally(()=>{Y.value=!1,_t(()=>n("resize"))})},ft=ke(()=>o.$superdoc?.activeEditor?.editorVersion===2),an=ke(()=>ft.value?o.$superdoc?.activeEditor?.v2Comments??null:null),qt=ke(()=>ft.value?o.$superdoc?.activeEditor?.v2TrackedChanges??null:null),cn=ke(()=>{if(!an.value)return null;const _e=s.viewingVisibility.documentMode,ze=an.value.getCapabilityState?.()??null;return _e==="viewing"?{...ze??{},canWrite:!1,reason:"review-surface-read-only"}:ze}),hn=ke(()=>{if(!ft.value)return!1;const _e=cn.value;return _e?_e.canWrite===!1:!1}),oo=ke(()=>K.value?"reply-submit-in-flight":hn.value?cn.value?.reason??"v2-write-unavailable":null),Jt=ke(()=>{if(!qt.value)return null;const _e=s.viewingVisibility.documentMode,ze=qt.value.getCapabilityState?.()??null;return _e==="viewing"&&ze?.canDecide!==!1?{canDecide:!1,reason:"review-surface-read-only"}:ze}),Yn=_e=>{if(ft.value&&_e?.trackedChange){if(!qt.value)return"v2-tracked-change-adapter-missing";const ze=Jt.value;return ze&&ze.canDecide===!1?ze.reason??"v2-tracked-change-unavailable":null}return hn.value?cn.value?.reason??"v2-write-unavailable":null},Nr=_e=>{if(ft.value&&_e?.trackedChange){if(!qt.value)return"v2-tracked-change-adapter-missing";const ze=Jt.value;return ze&&ze.canDecide===!1?ze.reason??"v2-tracked-change-unavailable":null}return hn.value?cn.value?.reason??"v2-write-unavailable":null},io=()=>ft.value?an.value?k.value?.readOnly?"read-only-document":hn.value?cn.value?.reason??"v2-write-unavailable":null:"v2-comments-adapter-missing":null,vo=ke(()=>!ft.value||!hn.value?null:cn.value?.reason??"v2-write-unavailable"),$t=(_e,ze)=>{z.value={decision:_e,reason:ze?.reason??null},_t(()=>n("resize"))},Bn=()=>{z.value&&(z.value=null,_t(()=>n("resize")))},xi=ke(()=>{const _e=z.value;if(!_e)return null;const ze=_e.decision==="reject"?"reject":"accept";return _e.reason==="stale-catalog"?`Couldn't ${ze} this change because the review list is stale.`:`Couldn't ${ze} this change.`}),Is=()=>{const _e=z.value;if(_e){if(z.value=null,_e.decision==="reject"){so();return}cr()}},so=async()=>{if(te())return G();const _e=o.$superdoc.config.onTrackedChangeBubbleReject;if(r.comment.trackedChange){if(ft.value){const vt=await s.decideTrackedChangeFromSidebar({superdoc:o.$superdoc,comment:r.comment,decision:"reject"});if(!vt?.ok||vt.success===!1){$t("reject",vt);return}Bn(),typeof _e=="function"&&_e(r.comment,o.$superdoc.activeEditor),_t(()=>{s.lastUpdate=new Date,y.value=null,s.setActiveComment(o.$superdoc,y.value),o.$superdoc.focus?.({preventScroll:!0})});return}let ze=!0;if(typeof _e=="function")_e(r.comment,o.$superdoc.activeEditor);else{const vt=s.decideTrackedChangeFromSidebar({superdoc:o.$superdoc,comment:r.comment,decision:"reject"});ze=!!vt?.ok&&vt.success!==!1}ze&&r.comment.resolveComment({id:i.user.id,email:i.user.email,name:i.user.name,superdoc:o.$superdoc,decision:"reject"})}else if(ft.value&&an.value){if(!(await s.deleteComment({superdoc:o.$superdoc,commentId:r.comment.commentId}))?.ok)return}else s.deleteComment({superdoc:o.$superdoc,commentId:r.comment.commentId});_t(()=>{s.lastUpdate=new Date,y.value=null,s.setActiveComment(o.$superdoc,y.value),o.$superdoc.focus?.()})},cr=async()=>{if(te())return G();if(!r.comment.trackedChange&&k.value?.allowResolve===!1)return{ok:!1,reason:"resolve-disabled"};const _e=o.$superdoc.config.onTrackedChangeBubbleAccept;if(r.comment.trackedChange&&ft.value){const vt=await s.decideTrackedChangeFromSidebar({superdoc:o.$superdoc,comment:r.comment,decision:"accept"});if(!vt?.ok||vt.success===!1){$t("accept",vt);return}Bn(),typeof _e=="function"&&_e(r.comment,o.$superdoc.activeEditor),_t(()=>{s.lastUpdate=new Date,y.value=null,s.setActiveComment(o.$superdoc,y.value),o.$superdoc.focus?.({preventScroll:!0})});return}let ze=!0;if(r.comment.trackedChange&&typeof _e=="function")_e(r.comment,o.$superdoc.activeEditor);else if(r.comment.trackedChange){const vt=s.decideTrackedChangeFromSidebar({superdoc:o.$superdoc,comment:r.comment,decision:"accept"});ze=!!vt?.ok&&vt.success!==!1}else if(ft.value&&an.value){if(!(await s.resolveCommentV2({superdoc:o.$superdoc,commentId:r.comment.commentId}))?.ok)return}else r.comment.resolveComment({id:i.user.id,email:i.user.email,name:i.user.name,superdoc:o.$superdoc});r.comment.trackedChange&&!ft.value&&ze&&r.comment.resolveComment({id:i.user.id,email:i.user.email,name:i.user.name,superdoc:o.$superdoc,decision:"accept"}),_t(()=>{s.lastUpdate=new Date,y.value=null,s.setActiveComment(o.$superdoc,y.value),o.$superdoc.focus?.()})},Qo=async()=>{if(te())return G();if(k.value?.allowResolve===!1)return{ok:!1,reason:"resolve-disabled"};!ft.value||!an.value||(await s.reopenCommentV2({superdoc:o.$superdoc,commentId:r.comment.commentId}))?.ok&&_t(()=>{s.lastUpdate=new Date,s.setActiveComment(o.$superdoc,y.value),o.$superdoc.focus?.()})},Zi=(_e,ze)=>{if(te())return G();switch(_e){case"edit":P.value=ze?.commentText?.value??ze?.commentText??"",y.value=r.comment.commentId,r.floatingInstanceId&&_(r.floatingInstanceId),O.value=ze.commentId,s.setActiveComment(o.$superdoc,y.value),_t(()=>{ye(ze.commentId)});break;case"delete":u({superdoc:o.$superdoc,commentId:ze.commentId});break}},va=async _e=>{if(te())return G();if(ft.value&&an.value){const ze=await s.editCommentV2({superdoc:o.$superdoc,commentId:_e.commentId,text:P.value});return ze?.ok&&(O.value=null,d(o.$superdoc)),ze}O.value=null,_e.setText({text:P.value,superdoc:o.$superdoc}),d(o.$superdoc)},Qi=_e=>{if(te())return G();const ze=!!R.value,vt=_e.toLowerCase()==="internal";ze?R.value.isInternal=vt:r.comment.setIsInternal({isInternal:vt,superdoc:o.$superdoc})},hl=ke(()=>{const _e={};return(S.value||D.value||Pt.value)&&(_e.zIndex=50),_e}),Ti=_e=>typeof _e=="string"?new Date(_e).getTime():_e,ao=_e=>{O.value=null,Y.value=!1,l(o.$superdoc)},Ri=ke(()=>{const _e=o.$superdoc.users;return r.comment.isInternal===!0?_e.filter(ze=>ze.access?.role==="internal"):_e});return Nn(()=>{r.autoFocus&&_t(()=>Ke()),D.value&&_t(()=>{N.value?.focus?.()}),_t(()=>{n("ready",{commentId:r.floatingInstanceId??(r.comment.importedId!==void 0?r.comment.importedId:r.comment.commentId),elementRef:le}),Ft()})}),Lt(H,_e=>{_e&&_t(()=>{N.value?.focus?.()})},{immediate:!0}),Lt(O,_e=>{if(!_e||!S.value)return;const ze=me.value.find(vt=>vt.commentId===_e);!ze||ze.trackedChange||_t(()=>{ye(_e)})}),Lt(()=>k.value?.readOnly===!0,_e=>{_e&&(Y.value=!1,me.value.some(ze=>ze.commentId===O.value)&&(O.value=null),D.value&&l(o.$superdoc),_t(()=>n("resize")))},{immediate:!0}),Lt(hn,_e=>{_e&&(Y.value=!1,_t(()=>n("resize")))}),(_e,ze)=>{const vt=Y2("click-outside");return Us((ge(),Ae("div",{class:rn(["comments-dialog",{"is-active":S.value||D.value,"is-resolved":r.comment.resolvedTime}]),onClick:tn(Ke,["stop","prevent"]),style:yn(hl.value),ref_key:"commentDialogElement",ref:le,role:"dialog","data-sd-part":"comment-thread","data-editor-ui-surface":"","data-comment-instance-id":r.floatingInstanceId??"","data-comment-thread-id":r.comment.commentId??"","data-comment-position-key":r.comment.trackedChangeAnchorKey??"","data-comment-page-index":Number.isFinite(r.floatingPageIndex)?r.floatingPageIndex:""},[D.value?(ge(),Ae(Wt,{key:0},[De.value?(ge(),Ae("div",j7,[jt(__,{onClick:ze[0]||(ze[0]=tn(()=>{},["stop","prevent"])),class:"sd-internal-dropdown","is-disabled":!1,state:et(R).isInternal?"internal":"external",onSelect:Qi},null,8,["state"])])):ht("",!0),jt(a0,{config:et(k),comment:r.comment,"is-pending-input":!0},null,8,["config","comment"]),Me("div",U7,[jt(c0,{ref_key:"commentInput",ref:N,users:Ri.value,config:et(k),comment:r.comment,"include-header":!1},null,8,["users","config","comment"])]),Me("div",G7,[Me("button",{class:"sd-button reply-btn-cancel",onClick:tn(ao,["stop","prevent"])},"Cancel"),Me("button",{class:rn(["sd-button primary reply-btn-primary",{"sd-is-disabled":!je.value}]),onClick:tn(kt,["stop","prevent"]),disabled:!je.value}," Comment ",10,W7)])],64)):(ge(),Ae(Wt,{key:1},[ee.value?(ge(),Ae("div",K7,[Me("span",{class:"resolved-badge__icon",innerHTML:et(la).markDone},null,8,q7),Ni(" "+Bt(ee.value),1)])):ht("",!0),De.value?(ge(),Ae("div",Y7,[jt(__,{onClick:ze[1]||(ze[1]=tn(()=>{},["stop","prevent"])),class:"sd-internal-dropdown","is-disabled":Kt.value,state:e.comment.isInternal?"internal":"external",onSelect:Qi},null,8,["is-disabled","state"])])):ht("",!0),(ge(!0),Ae(Wt,null,rr(Ye.value,(ot,xn)=>(ge(),Ae("div",{key:ot.commentId,class:"conversation-item"},[jt(a0,{config:et(k),timestamp:Ti(ot.createdTime),comment:ot,"is-active":S.value,"resolve-disabled-reason":Yn(ot),"reject-disabled-reason":Nr(ot),"reopen-supported":ft.value&&!!an.value,"reopen-disabled-reason":io(),"write-disabled-reason":vo.value,onResolve:cr,onReject:so,onReopen:Qo,onOverflowSelect:Tn=>Zi(Tn,ot)},null,8,["config","timestamp","comment","is-active","resolve-disabled-reason","reject-disabled-reason","reopen-supported","reopen-disabled-reason","write-disabled-reason","onOverflowSelect"]),ot.trackedChange?(ge(),Ae("div",X7,[Me("div",{class:rn(["tracked-change",xn===0?Ct.value:void 0]),"data-track-change-semantic-color-key":ot.semanticColorKey??void 0,ref_for:!0,ref:xn===0?St:void 0},[ot.trackedChangeLabel?(ge(),Ae("div",Q7,[Me("span",J7,Bt(ot.trackedChangeLabel),1),ot.trackedChangeDetailLines&&ot.trackedChangeDetailLines.length?(ge(),Ae("div",$7,[(ge(!0),Ae(Wt,null,rr(ot.trackedChangeDetailLines,(Tn,_r)=>(ge(),Ae("div",{key:_r,class:"tracked-change-detail-line"},[Tn.excerpt?(ge(),Ae("span",eR,'"'+Bt(Tn.excerpt)+'"',1)):ht("",!0),Tn.excerpt?(ge(),Ae("span",tR," β ")):ht("",!0),Me("span",nR,Bt(Tn.label),1)]))),128))])):ht("",!0)])):ot.trackedChangeDisplayType==="hyperlinkAdded"?(ge(),Ae("div",rR,[ze[2]||(ze[2]=Me("span",{class:"change-type"},"Added hyperlink ",-1)),Me("span",oR,'"'+Bt(ot.trackedChangeText)+'"',1)])):ot.trackedChangeDisplayType==="hyperlinkModified"?(ge(),Ae("div",iR,[ze[3]||(ze[3]=Me("span",{class:"change-type"},"Changed hyperlink to ",-1)),Me("span",sR,'"'+Bt(ot.trackedChangeText)+'"',1)])):ot.trackedChangeDisplayType==="paragraphSplit"?(ge(),Ae("div",aR,[...ze[4]||(ze[4]=[Me("span",{class:"change-type"},"Added new line",-1)])])):ot.trackedChangeDisplayType==="tableInsert"?(ge(),Ae("div",lR,[...ze[5]||(ze[5]=[Me("span",{class:"change-type"},"Added table",-1)])])):ot.trackedChangeDisplayType==="tableDelete"?(ge(),Ae("div",cR,[...ze[6]||(ze[6]=[Me("span",{class:"change-type"},"Deleted table",-1)])])):ot.trackedChangeType==="trackFormat"?(ge(),Ae("div",uR,[ze[7]||(ze[7]=Me("span",{class:"change-type"},"Format: ",-1)),Me("span",dR,Bt(ot.trackedChangeText),1)])):ot.trackedChangeType==="both"?(ge(),Ae("div",fR,[ze[8]||(ze[8]=Me("span",{class:"change-type"},"Replaced ",-1)),Me("span",hR,'"'+Bt(ot.deletedText)+'"',1),ze[9]||(ze[9]=Me("span",{class:"change-type"}," with ",-1)),Me("span",pR,'"'+Bt(ot.trackedChangeText)+'"',1)])):ot.deletedText?(ge(),Ae("div",mR,[ze[10]||(ze[10]=Me("span",{class:"change-type"},"Deleted ",-1)),Me("span",gR,'"'+Bt(ot.deletedText)+'"',1)])):ot.trackedChangeText?(ge(),Ae("div",vR,[ze[11]||(ze[11]=Me("span",{class:"change-type"},"Added ",-1)),Me("span",yR,'"'+Bt(ot.trackedChangeText)+'"',1)])):ht("",!0),ot.trackedChangeImagePreview?.src?(ge(),Ae("div",{key:10,class:"tracked-change-image-preview","data-track-change-image-preview-role":ot.trackedChangeImagePreview.role??void 0},[Me("img",{class:"tracked-change-image-preview__image",src:ot.trackedChangeImagePreview.src,alt:ot.trackedChangeImagePreview.alt||"Tracked image preview",style:yn(X(ot.trackedChangeImagePreview)),loading:"lazy",decoding:"async"},null,12,wR)],8,bR)):ht("",!0)],10,Z7),He.value&&it.value&&xn===0?(ge(),Ae("div",{key:0,class:"show-more-toggle",onClick:tn(Yt,["stop","prevent"])}," Show more ")):ht("",!0),Ce.value&&it.value&&xn===0?(ge(),Ae("div",{key:1,class:"show-more-toggle",onClick:tn(Yt,["stop","prevent"])}," Show less ")):ht("",!0)])):ht("",!0),ot.trackedChange?ht("",!0):(ge(),Ae("div",CR,[!et(j)&&!Sn.value(ot)?(ge(),Ae("div",{key:0,class:rn(["comment",xn===0?Ct.value:void 0]),ref_for:!0,ref:xn===0?St:void 0,innerHTML:ot.commentText},null,10,_R)):et(j)&&!Sn.value(ot)?(ge(),Ae("div",SR,Bt(et(V)[ot.importedId!==void 0?ot.importedId:ot.commentId]?.bounds),1)):(ge(),Ae("div",kR,[Me("div",AR,[jt(c0,{ref_for:!0,ref:pe(ot.commentId),users:Ri.value,config:et(k),"include-header":!1,comment:ot},null,8,["users","config","comment"])]),Me("div",IR,[Me("button",{class:"sd-button reply-btn-cancel",onClick:tn(Tn=>ao(ot),["stop","prevent"])},"Cancel",8,ER),Me("button",{class:rn(["sd-button primary reply-btn-primary",{"sd-is-disabled":!je.value||hn.value}]),onClick:tn(Tn=>va(ot),["stop","prevent"]),disabled:!je.value||hn.value,"data-disabled-reason":hn.value?cn.value?.reason??null:null}," Update ",10,xR)])])),He.value&&it.value&&xn===0&&!Sn.value(ot)?(ge(),Ae("div",{key:3,class:"show-more-toggle",onClick:tn(Yt,["stop","prevent"])}," Show more ")):ht("",!0),Ce.value&&it.value&&xn===0&&!Sn.value(ot)?(ge(),Ae("div",{key:4,class:"show-more-toggle",onClick:tn(Yt,["stop","prevent"])}," Show less ")):ht("",!0)])),Qt.value&&xn===0?(ge(),Ae(Wt,{key:2},[ze[12]||(ze[12]=Me("div",{class:"comment-separator"},null,-1)),Me("div",{class:"collapsed-replies",onClick:tn(wn,["stop","prevent"])},[Me("div",TR,[(ge(!0),Ae(Wt,null,rr(Ot.value,Tn=>(ge(),dn(S_,{key:Tn.email||Tn.name,user:Tn,class:"mini-avatar"},null,8,["user"]))),128))]),Me("span",null,Bt(Et.value)+" more "+Bt(Et.value===1?"reply":"replies"),1)])],64)):ht("",!0),U.value(xn)?(ge(),Ae("div",RR)):ht("",!0)]))),128)),z.value?(ge(),Ae("div",MR,[Me("span",LR,Bt(xi.value),1),Me("button",{type:"button",class:"sd-button tracked-change-decision-alert__retry",onClick:tn(Is,["stop","prevent"])}," Retry ")])):ht("",!0),H.value&&!et(k).readOnly?(ge(),Ae(Wt,{key:3},[Y.value?(ge(),Ae("div",DR,[Me("div",OR,[jt(c0,{ref_key:"commentInput",ref:N,users:Ri.value,config:et(k),comment:r.comment,"include-header":!1},null,8,["users","config","comment"])]),Me("div",FR,[Me("button",{class:"sd-button reply-btn-cancel",onClick:tn(ao,["stop","prevent"])},"Cancel"),Me("button",{class:rn(["sd-button primary reply-btn-primary",{"sd-is-disabled":!je.value||hn.value||K.value}]),onClick:tn(kt,["stop","prevent"]),disabled:!je.value||hn.value||K.value,"data-disabled-reason":oo.value}," Reply ",10,NR)])])):(ge(),Ae("button",{key:0,type:"button",class:rn(["reply-pill",{"sd-is-disabled":hn.value}]),onClick:tn(be,["stop","prevent"]),disabled:hn.value,"data-disabled-reason":hn.value?cn.value?.reason??null:null}," Reply or add others with @ ",10,PR))],64)):ht("",!0)],64))],14,H7)),[[vt,pt]])}}},Pp=fn(BR,[["__scopeId","data-v-05d69162"]]);xt(),gn();var zR={class:"comments-list"},VR={key:0},HR=["data-comment-instance-id","data-comment-thread-id","data-comment-position-key","data-comment-page-index"],jR={key:1},UR="headerFooterPart",GR={__name:"commentsList",props:{showMainComments:{type:Boolean,default:!0},showResolvedComments:{type:Boolean,default:!0}},setup(e){const t=e,n=aa(),r=pg(n,"isCommentsListVisible"),o=ke(()=>n.getGroupedComments),i=ke(()=>n.getFloatingCommentInstances),{activeComment:s,activeFloatingCommentInstanceId:a}=Js(n),l=m=>{const p=i.value.filter(v=>v?.comment?.commentId===m?.commentId);return p.length<2?[]:m?.trackedChange?m?.trackedChangeStory?.storyType!==UR?[]:p:[]},u=m=>!m?.comment?.commentId||s.value!==m.comment.commentId?!1:a.value==null?m.isPrimary===!0:String(a.value)===String(m.id),c=m=>{const p=l(m);return p.length?p.map(v=>({id:v.id,comment:m,floatingInstanceId:String(v.id),floatingPageIndex:v.pageIndex,floatingPositionEntry:v.positionEntry??null,isFloatingInstanceActive:u(v)})):[{id:m.commentId,comment:m,floatingInstanceId:null,floatingPageIndex:null,floatingPositionEntry:null,isFloatingInstanceActive:void 0}]},d=ke(()=>o.value.parentComments.flatMap(m=>c(m))),h=ke(()=>t.showResolvedComments&&o.value?.resolvedComments?.length>0);return Nn(()=>{r.value=!0}),or(()=>{r.value=!1}),(m,p)=>(ge(),Ae("div",zR,[e.showMainComments?(ge(),Ae("div",VR,[(ge(!0),Ae(Wt,null,rr(d.value,v=>(ge(),Ae("div",{key:v.id,class:"comment-item","data-comment-instance-id":v.floatingInstanceId??"","data-comment-thread-id":v.comment.commentId??"","data-comment-position-key":v.comment.trackedChangeAnchorKey??"","data-comment-page-index":Number.isFinite(v.floatingPageIndex)?v.floatingPageIndex:""},[jt(Pp,{comment:v.comment,"floating-instance-id":v.floatingInstanceId,"floating-page-index":v.floatingPageIndex,"floating-position-entry":v.floatingPositionEntry,"is-floating-instance-active":v.isFloatingInstanceActive},null,8,["comment","floating-instance-id","floating-page-index","floating-position-entry","is-floating-instance-active"])],8,HR))),128))])):ht("",!0),h.value?(ge(),Ae("div",jR,[p[0]||(p[0]=Me("div",{class:"comment-title"},"Resolved",-1)),(ge(!0),Ae(Wt,null,rr(o.value.resolvedComments,v=>(ge(),Ae("div",{key:v.commentId,class:"comment-item"},[jt(Pp,{comment:v},null,8,["comment"])]))),128))])):ht("",!0)]))}},WR=fn(GR,[["__scopeId","data-v-e89dbc33"]]);xt();var KR=class extends Ym.default{element;config={comments:[],element:null,commentsStore:null};constructor(e,t){super(),this.config={...this.config,...e},this.element=this.config.element,this.app=null,this.superdoc=t,this.open()}createVueApp(){this.app=Zl(WR);const e=this.superdoc?.app?._context?.provides;e&&this.app?._context?.provides&&Object.setPrototypeOf(this.app._context.provides,e),this.superdoc?.pinia&&(Wd(this.superdoc.pinia),this.app.use(this.superdoc.pinia),this.app.config.globalProperties.$pinia=this.superdoc.pinia),this.app.directive("click-outside",Qv),this.app.config.globalProperties.$superdoc=this.superdoc,!this.element&&this.config.selector&&(this.element=document.getElementById(this.config.selector)),this.container=this.app.mount(this.element)}close(){this.app&&(this.app.unmount(),this.app=null,this.container=null,this.element=null)}open(){this.app||this.createVueApp()}},qR,$a,u0=Ir((()=>{qR=2,$a=96/72}));xt(),u0();var YR=96,XR=".superdoc__right-sidebar",ZR=".sd-pdf-viewer-page";const d0=Object.freeze({min:10,max:100,padding:0}),I_=e=>{const t=e&&typeof e=="object"?e:{},n=(s,a)=>typeof s=="number"&&Number.isFinite(s)&&s>0?s:a,r=n(t.min,d0.min),o=n(t.max,d0.max),i=typeof t.padding=="number"&&Number.isFinite(t.padding)&&t.padding>=0?t.padding:d0.padding;return{min:Math.min(r,o),max:Math.max(r,o),padding:i}},E_=(e,t)=>!(e>0)||!(t>0)?null:Math.round(e/t*100),QR=(e,t,n)=>{const r=E_(e-n.padding,t);return r===null?null:Math.max(1,Math.round(Math.min(n.max,Math.max(n.min,r))))},JR=(e,t,n)=>e>0?Number.isFinite(t)&&t>0?e/t*$a:n>0?e/n:e:null;function $R({getSuperdoc:e,superdocContainerWidth:t,isReady:n,activeZoom:r,zoomMode:o,viewportMetrics:i,showCommentsSidebar:s,rightSidebarRef:a,superdocRoot:l,documents:u}){const c=b=>{if(!b)return null;let T=0;try{const j=b.getPages?.();if(Array.isArray(j))for(const O of j){const V=O?.size?.w;typeof V=="number"&&Number.isFinite(V)&&V>T&&(T=V)}}catch{T=0}if(T>0)return T;let R=null;try{R=b.getPageStyles?.()??null}catch{R=null}const P=R?.pageSize?.width;return typeof P=="number"&&Number.isFinite(P)&&P>0?P*YR:null},d=()=>{if(!(u?.value??[]).some(R=>R?.type==="application/pdf"))return null;const b=l.value;if(!b?.querySelectorAll)return null;let T=0;for(const R of b.querySelectorAll(ZR)){const P=Number(R.clientWidth)||Number(R.getBoundingClientRect?.().width)||0;let j=NaN;typeof window<"u"&&typeof window.getComputedStyle=="function"&&(j=Number.parseFloat(window.getComputedStyle(R).getPropertyValue("--scale-factor")));const O=(r.value??100)/100,V=JR(P,j,O);V!==null&&V>T&&(T=V)}return T>0?T:null},h=()=>{const b=e();if(!b)return null;const T=[],R=u?.value??[];for(const j of R){if(j?.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")continue;const O=c(j.getEditor?.());O!==null&&T.push(O)}if(T.length===0){const j=c(b.activeEditor);j!==null&&T.push(j)}const P=d();if(P!==null&&T.push(P),T.length>0)return Math.max(...T);if(b.activeEditor){const j=l.value?.querySelector?.(".superdoc__document"),O=Number(j?.clientWidth)||Number(j?.getBoundingClientRect?.().width)||0;if(O>0){const V=(r.value??100)/100;return V>0?O/V:O}}return null},m=()=>{if(!s?.value)return 0;const b=a?.value??l.value?.querySelector?.(XR),T=Number(b?.offsetWidth)||Number(b?.getBoundingClientRect?.().width)||0;return T>0?T:0},p=(b,T)=>{const R=I_(b.config?.zoom?.fitWidth),P=QR(T.availableWidth,T.documentWidth,R);P!==null&&P!==r.value&&(r.value=P,b.emit("zoomChange",{zoom:P,mode:"fit-width"}))},v=()=>{const b=e();if(!b)return;const T=t.value;if(!(T>0)||!n.value)return;const R=h();if(R===null)return;const P=T-m(),j=E_(P,R);if(j===null)return;const O=Object.freeze({availableWidth:P,documentWidth:R,fitZoom:j}),V=i.value;(!V||V.availableWidth!==P||V.documentWidth!==R||V.fitZoom!==j)&&(i.value=O),(!V||V.fitZoom!==j||Math.round(V.documentWidth)!==Math.round(R))&&b.emit("viewport-change",O),o.value==="fit-width"&&p(b,O)};Lt(t,()=>{_t(()=>v())}),Lt(n,b=>{b&&v()}),Lt(o,b=>{b==="fit-width"&&v()}),s&&Lt(s,()=>{_t(()=>v())});const _=()=>{_t(()=>v())},C=()=>{_t(()=>v())},k=()=>{_t(()=>v())},y=e();return y?.on?.("editorCreate",_),y?.on?.("pagination-update",C),y?.on?.("pdf:document-ready",k),or(()=>{y?.off?.("editorCreate",_),y?.off?.("pagination-update",C),y?.off?.("pdf:document-ready",k)}),{evaluateViewport:v}}const e9=e=>!!e?.trackedChange,t9=e=>e,n9=(e,t,n,r=e)=>!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)?!1:(Number.isFinite(r)?r:e)<t||e>n,r9=({comment:e,anchorTop:t,anchorBottom:n,viewportTop:r,viewportBottom:o})=>e9(e)&&n9(t,r,o,n),o9=({comment:e,anchorTop:t,anchorBottom:n,cardHeight:r,viewportTop:o,viewportBottom:i})=>!r9({comment:e,anchorTop:t,anchorBottom:n,viewportTop:o,viewportBottom:i})||!Number.isFinite(r)?null:(Number.isFinite(n)?n:t)<o?Math.min(t,o-r-1):t,i9=({id:e,visibleIds:t,activeCommentInstanceId:n})=>e?!!(e==="pending"||n!=null&&String(e)===String(n)||t?.has?.(e)):!1,x_=({previousIds:e,currentIds:t,removedId:n})=>{if(!Array.isArray(e)||!(t instanceof Set)||!n)return null;const r=e.indexOf(n);if(r<0)return null;for(let o=r+1;o<e.length;o+=1){const i=e[o];if(t.has(i))return i}for(let o=r-1;o>=0;o-=1){const i=e[o];if(t.has(i))return i}return null};xt(),gn();var s9=["data-comment-id","data-comment-instance-id","data-comment-thread-id","data-comment-position-key","data-comment-page-index"],tc={},a9={__name:"FloatingComments",props:{currentDocument:{type:Object,required:!0},parent:{type:Object,required:!0}},setup(e){const r=(De,je,Ke)=>{if(je>=0){De[je].top=De[je].anchorTop;let pt=De[je].top+De[je].height+Ke;for(let ft=je+1;ft<De.length;ft++)De[ft].top=Math.max(De[ft].anchorTop,pt),pt=De[ft].top+De[ft].height+Ke;pt=De[je].top-Ke;for(let ft=je-1;ft>=0;ft--){const an=pt-De[ft].height;De[ft].top=Math.min(De[ft].anchorTop,an),pt=De[ft].top-Ke}const kt=Math.min(...De.map(ft=>ft.top));if(kt<0){const ft=Math.abs(kt);for(const an of De)an.top+=ft}}else for(let pt=1;pt<De.length;pt++){const kt=De[pt-1],ft=kt.top+kt.height+Ke;De[pt].top<ft&&(De[pt].top=ft)}},o=e,i=hu(),s=aa(),{clearInstantSidebarAlignment:a}=s,{activeComment:l,activeFloatingCommentInstanceId:u,editorCommentPositions:c,pendingComment:d,editingCommentId:h,instantSidebarAlignmentTargetY:m,instantSidebarAlignmentThreadId:p,instantSidebarAlignmentInstanceId:v}=Js(s),{activeZoom:_}=Js(i),C=ke(()=>{const De=s.getFloatingCommentInstances;if(!Array.isArray(De))return[];const je=o.currentDocument?.id;return je==null?De:De.filter(Ke=>s.belongsToDocument(Ke.comment,String(je),{allowSingleDocumentMismatch:!0}))}),k=ne(null),y=ne(0),b=ne(0),T=ne(!1),R=ne(null),P=ne(0),j=De=>{const je=d.value?.commentId;return je?typeof De=="object"?De?.commentId===je:De===je||De==="pending":!1},O=De=>De?.commentId??De?.importedId??null,V=ke(()=>{const De=new Map,je=new Map;for(const Ke of C.value){Ke?.id!=null&&De.set(String(Ke.id),Ke);const pt=O(Ke?.comment);if(pt==null)continue;const kt=String(pt),ft=je.get(kt)??[];ft.push(Ke),je.set(kt,ft)}return{byId:De,byThreadId:je}}),Q=(De,je=null)=>{if(De==null)return null;const Ke=String(De),pt=V.value.byThreadId.get(Ke)??[];if(!pt.length)return null;if(je!=null){const kt=pt.find(ft=>String(ft.id)===String(je));if(kt)return kt.id}return pt.find(kt=>kt.isPrimary)?.id??pt[0]?.id??null},F=ke(()=>l.value?Q(l.value,u.value):null),N=De=>{if(typeof De=="number")return Number.isFinite(De)?De:null;if(typeof De!="string"||De.trim()==="")return null;const je=Number(De);return Number.isFinite(je)?je:null},x=ne({...tc}),z=ne(new Set),J=ne({});let X=null;const ae=new Set;let pe=null;const Fe=()=>{pe==null&&(pe=requestAnimationFrame(()=>{pe=null,P.value+=1}))},fe=De=>{if(o.currentDocument.type==="application/pdf"){const je=(_.value??100)/100,Ke=N(De?.comment?.selection?.selectionBounds?.top);return Ke==null?null:Ke*je}return De?.positionEntry?.bounds?.top},ye=(De,je)=>{if(o.currentDocument.type==="application/pdf"){const pt=(_.value??100)/100,kt=N(De?.comment?.selection?.selectionBounds?.bottom);return kt!=null?kt*pt:je}const Ke=De?.positionEntry?.bounds?.bottom;return Number.isFinite(Ke)?Ke:je},le=ke(()=>{const De=[];for(const je of C.value){const Ke=je?.id,pt=O(je?.comment),kt=fe(je);if(Ke==null||pt==null||!Number.isFinite(kt))continue;const ft=t9(kt,je.comment);De.push({id:Ke,threadId:pt,instance:je,top:ft,anchorBottom:ye(je,ft)})}return De}),Se=()=>{const De=c.value.pending;if(typeof De?.bounds?.top=="number"&&!isNaN(De.bounds.top))return De.bounds.top;const je=o.currentDocument.type==="application/pdf"?(_.value??100)/100:1,Ke=N(d.value?.selection?.selectionBounds?.top);return Ke==null?null:Ke*je},re=De=>i9({id:De?.id,visibleIds:z.value,activeCommentInstanceId:F.value,comment:De?.commentRef}),xe=()=>{const De=k.value;if(!De)return null;const je=De.getBoundingClientRect();if(!Number.isFinite(je.top)||!Number.isFinite(window.innerHeight))return null;let Ke=0,pt=window.innerHeight;for(let ft=De.parentElement;ft;ft=ft.parentElement){const an=window.getComputedStyle(ft).overflowY;if(!["auto","scroll","hidden","clip"].includes(an))continue;const qt=ft.getBoundingClientRect();!Number.isFinite(qt.top)||!Number.isFinite(qt.bottom)||(Ke=Math.max(Ke,qt.top),pt=Math.min(pt,qt.bottom))}if(pt<=Ke)return null;const kt=o.parent?.getBoundingClientRect?.();if(kt&&Number.isFinite(kt.top)&&Number.isFinite(kt.bottom)){const ft=Math.max(Ke,kt.top),an=Math.min(pt,kt.bottom);an>ft&&(Ke=ft,pt=an)}return{top:Ke-je.top,bottom:pt-je.top}},$e=ke(()=>p.value?Q(p.value,v.value):null),st=ke(()=>{P.value;const De=le.value,je=d.value&&d.value.fileId===o.currentDocument.id;if(!De.length&&!C.value.length&&!je)return[];const Ke=[],pt=xe()??{top:0,bottom:Math.max(0,o.parent?.clientHeight||window.innerHeight||0)},kt=pt.top-600,ft=pt.bottom+600,an=je?"pending":F.value,qt=new Set,cn=({id:Jt,threadId:Yn,instance:Nr,top:io,anchorBottom:vo,hasAnchorGeometry:$t})=>{const Bn=String(Jt);qt.has(Bn)||(qt.add(Bn),Ke.push({id:Jt,threadId:Yn,pageIndex:Nr?.pageIndex??null,anchorTop:io,anchorBottom:vo,hasAnchorGeometry:$t,top:io,height:x.value[Jt]||110,commentRef:Nr.comment,instanceRef:Nr}))};for(const Jt of De){const{id:Yn,threadId:Nr,instance:io,top:vo,anchorBottom:$t}=Jt,Bn=an!=null&&String(Yn)===String(an),xi=h.value!=null&&String(Nr)===String(h.value);!Bn&&!xi&&($t<kt||vo>ft)||cn({id:Yn,threadId:Nr,instance:io,top:vo,anchorBottom:$t,hasAnchorGeometry:!0})}const hn=[];if(an&&an!=="pending"){const Jt=V.value.byId.get(String(an));Jt&&hn.push(Jt)}if(h.value!=null){const Jt=V.value.byThreadId.get(String(h.value))??[],Yn=Jt.find(Nr=>Nr.isPrimary)??Jt[0];Yn&&hn.push(Yn)}for(const Jt of hn){const Yn=Jt.id,Nr=O(Jt.comment);Yn==null||Nr==null||qt.has(String(Yn))||cn({id:Yn,threadId:Nr,instance:Jt,top:pt.top,anchorBottom:pt.top,hasAnchorGeometry:!1})}if(je){const Jt=Se();typeof Jt=="number"&&!isNaN(Jt)&&Ke.push({id:"pending",anchorTop:Jt,anchorBottom:Jt,hasAnchorGeometry:!0,top:Jt,height:x.value.pending||110,commentRef:d.value})}Ke.sort((Jt,Yn)=>Jt.anchorTop-Yn.anchorTop);const oo=[];for(const Jt of Ke){const Yn=Jt.hasAnchorGeometry?o9({comment:Jt.commentRef,anchorTop:Jt.anchorTop,anchorBottom:Jt.anchorBottom,cardHeight:Jt.height,viewportTop:pt.top,viewportBottom:pt.bottom}):null;Yn==null?oo.push(Jt):Jt.top=Yn}return r(oo,an?oo.findIndex(Jt=>Jt.id===an):-1,15),Ke}),At=ke(()=>(P.value,Math.max(0,o.parent?.clientHeight||0,o.parent?.scrollHeight||0))),Ee=()=>{X&&X.disconnect(),X=new IntersectionObserver(De=>{const je=new Set(z.value);for(const Ke of De){const pt=Ke.target.dataset.commentId;pt&&(Ke.isIntersecting?je.add(pt):je.delete(pt))}z.value=je},{rootMargin:"600px 0px 600px 0px"})},Ge=()=>{if(!X)return;const De=new Set;for(const je of st.value){const Ke=J.value[je.id];Ke&&(De.add(Ke),ae.has(Ke)||(X.observe(Ke),ae.add(Ke)))}for(const je of ae)De.has(je)||(X.unobserve(je),ae.delete(je))},qe=(De,je)=>{je<=0||je===x.value[De]||(tc[De]=je,x.value={...x.value,[De]:je})},Z=De=>{if(!De)return;const{elementRef:je,commentId:Ke}=De;je&&_t(()=>{const pt=je.value?.getBoundingClientRect();!pt||pt.height<=0||Ke&&qe(Ke,pt.height)})},S=De=>{const je=De?.id;je&&_t(()=>{const Ke=J.value[je];if(!Ke)return;const pt=Ke.querySelector(".comments-dialog");if(!pt)return;qe(je,pt.getBoundingClientRect().height);const kt=je===F.value,ft=je==="pending",an=!!h.value&&!!l.value&&De?.threadId!=null&&String(De.threadId)===String(l.value);!kt&&!ft&&!an||(St(st.value.map(qt=>qt.id)),sn(()=>st.value.map(qt=>qt.id)))})},ee=De=>{!De&&R.value!=null||(T.value=De)},D=(De,je,Ke)=>{if(!Number.isFinite(je)){Ke?.(!1);return}const pt=J.value[De];if(!pt){Ke?.(!1);return}const kt=pt.getBoundingClientRect().top;b.value+=je-kt,Ke?.(!0)},U=(De,je)=>{if(je)J.value[De]=je,X&&!ae.has(je)&&(X.observe(je),ae.add(je));else{const Ke=J.value[De];Ke&&X&&(X.unobserve(Ke),ae.delete(Ke)),delete J.value[De]}};let H=[],G=null,te=[],Y=null,K=!1,be=0,me=null,Ce=null,Pe=null,it=null;const He=()=>{Pe=null,it=null,R.value=null,ee(!1)},Ct=De=>{if(!Pe)return;const je=(De?.target instanceof Element?De.target:null)?.closest?.("[data-comment-action]"),Ke=je?.getAttribute?.("data-comment-action");(Ke==="resolve"||Ke==="reject")&&k.value?.contains?.(je)||He()},Yt=()=>{H.forEach(clearTimeout),H=[]},St=De=>{for(const je of De.filter(Boolean)){const Ke=J.value[je];if(!Ke)continue;const pt=Ke.querySelector(".comments-dialog");pt&&qe(je,pt.getBoundingClientRect().height)}},Ft=50,Nt=350,sn=De=>{Yt();const je=typeof De=="function"?De:()=>De;H.push(setTimeout(()=>St(je()),Ft)),H.push(setTimeout(()=>St(je()),Nt))},_n=()=>{a(),requestAnimationFrame(()=>{ee(!1)})},Qt=(De,je)=>{!De||!Number.isFinite(je)||(ee(!0),_t(()=>{St([De]),D(De,je,()=>{_n()})}))},Ye=()=>{Y=null,be+=1,me!=null&&(cancelAnimationFrame(me),me=null),ee(!1)},Et=()=>{if(!Y||K)return;K=!0;const De=be;me!=null&&(cancelAnimationFrame(me),me=null),ee(!0),_t(()=>{if(K=!1,De!==be){Et();return}const{key:je,targetClientY:Ke}=Y;St([je]),D(je,Ke,pt=>{if(De===be){if(!pt){ee(!1);return}me=requestAnimationFrame(()=>{me=null,De===be&&ee(!1)})}})})},Ot=(De,je)=>{const Ke=x_({previousIds:te,currentIds:je,removedId:De}),pt=(Ke?J.value[Ke]:null)?.getBoundingClientRect?.().top;return!Ke||!Number.isFinite(pt)?(Ye(),!1):(Y={key:Ke,targetClientY:pt},be+=1,Et(),!0)},wn=De=>{const je=De?.target?.closest?.("[data-comment-action]"),Ke=je?.getAttribute?.("data-comment-action");if(Ke!=="resolve"&&Ke!=="reject"||(He(),je.getAttribute?.("aria-disabled")==="true"))return;const pt=je.closest?.("[data-comment-id]")?.getAttribute?.("data-comment-id");if(!pt||String(F.value??"")===String(pt))return;const kt=st.value.filter(qt=>qt.commentRef?.trackedChange).map((qt,cn)=>({id:qt.id,index:cn,top:qt.top})).filter(qt=>Number.isFinite(qt.top)).sort((qt,cn)=>qt.top-cn.top||qt.index-cn.index).map(qt=>qt.id),ft=x_({previousIds:kt,currentIds:new Set(kt),removedId:pt}),an=(ft?J.value[ft]:null)?.getBoundingClientRect?.().top;!ft||!Number.isFinite(an)||(Pe={removedKey:pt,targetKey:ft,targetClientY:an,applied:!1},it=pt,R.value=ft,ee(!0))};Lt(F,(De,je)=>{if(Yt(),!(Pe!=null&&it!=null&&[De,je].some(kt=>kt!=null&&String(kt)===String(it)))){if(it=null,De)He(),Ye();else if(je){const kt=new Set(st.value.map(ft=>ft.id));kt.has(je)?Ye():Ot(je,kt)}}const Ke=[De,je],pt=De&&De===$e.value&&Number.isFinite(m.value);_t(()=>{if(pt){St(Ke);return}sn(Ke)})}),Lt([F,$e,m],([De,je,Ke])=>{!De||!je||De!==je||!Number.isFinite(Ke)||Qt(De,Ke)}),Lt(h,()=>{Yt(),_t(()=>{sn(()=>st.value.map(De=>De.id))})}),Lt(l,()=>{if(G&&clearTimeout(G),!l.value){if(a(),Y){Et();return}ee(!1),b.value=0;return}if(!(j(l.value)?d.value:s.getComment(l.value)))return;const De=j(l.value)?"pending":F.value;if(De){if(De===$e.value&&Number.isFinite(m.value)){ee(!0);return}_t(()=>{G=setTimeout(()=>{const Ke=J.value[De];if(!Ke)return;const pt=o.parent?.getBoundingClientRect?.();if(!pt)return;const kt=st.value.find(cn=>cn.id===De),ft=De==="pending"?Se():kt?.anchorTop;if(typeof ft!="number"||isNaN(ft))return;const an=Ke.getBoundingClientRect().top,qt=pt.top+ft;b.value+=qt-an},400)})}}),Lt(_,()=>{if(o.currentDocument.type==="application/pdf"){for(const De in tc)delete tc[De];x.value={},y.value+=1}});let Kt=new Set,Sn=null,Pt=null;return Lt(st,De=>{const je=F.value?De.find($t=>$t.id===F.value):null,Ke=typeof je?.anchorTop=="number"&&Number.isFinite(je.anchorTop)?je.anchorTop:null,pt=Ke!=null&&Sn!=null&&Math.abs(Ke-Sn)>1,kt=typeof je?.top=="number"&&Number.isFinite(je.top)?je.top:null,ft=kt!=null&&Pt!=null&&Math.abs(kt-Pt)>1;pt&&b.value!==0&&!Number.isFinite(m.value)?(b.value=0,ee(!1)):ft&&b.value!==0&&!Number.isFinite(m.value)&&!Y&&(ee(!0),b.value+=Pt-kt,Ce!=null&&cancelAnimationFrame(Ce),Ce=requestAnimationFrame(()=>{Ce=null,!Y&&!Number.isFinite(m.value)&&ee(!1)})),Sn=Ke,Pt=kt;const an=De.map($t=>$t.id),qt=new Set(an);if(Pe&&!Pe.applied&&!qt.has(Pe.removedKey)){const{targetKey:$t,targetClientY:Bn}=Pe;Pe.applied=!0,qt.has($t)&&Number.isFinite(Bn)?(Y={key:$t,targetClientY:Bn},be+=1,Et()):He()}if(Pe?.applied&&!qt.has(Pe.targetKey)&&He(),Y&&!qt.has(Y.key)){const $t=Y.key;Ot($t,qt)||(ee(!1),b.value=0)}const cn=new Set(z.value);let hn=!1,oo=-1/0,Jt=1/0;const Yn=k.value;if(Yn){const $t=Yn.getBoundingClientRect();oo=-$t.top-600,Jt=-$t.top+window.innerHeight+600}const Nr=new Map(De.map($t=>[$t.id,$t]));for(const $t of qt)if(!cn.has($t)){const Bn=Nr.get($t);(!Bn||Bn.top>=oo&&Bn.top<=Jt)&&(cn.add($t),hn=!0)}for(const $t of cn)qt.has($t)||(cn.delete($t),hn=!0);hn&&(z.value=cn);for(const $t of Kt)qt.has($t)||delete tc[$t];const io=Kt.size!==qt.size||[...Kt].some($t=>!qt.has($t)),vo=te.length!==an.length||te.some(($t,Bn)=>$t!==an[Bn]);if(io){const $t={};for(const Bn of qt)tc[Bn]&&($t[Bn]=tc[Bn]);x.value=$t,_t(()=>{for(const Bn of De){const xi=J.value[Bn.id];if(!xi)continue;const Is=xi.querySelector(".comments-dialog");Is&&qe(Bn.id,Is.getBoundingClientRect().height)}})}Y&&(io||vo)&&Et(),Kt=qt,_t(()=>{te=an,Ge()})}),Nn(()=>{Ee(),o.parent?.addEventListener?.("scroll",Fe,{passive:!0}),window.addEventListener("resize",Fe,{passive:!0}),document.addEventListener("pointerdown",Ct,!0),_t(Ge)}),or(()=>{Yt(),G&&clearTimeout(G),He(),Ye(),Ce!=null&&(cancelAnimationFrame(Ce),Ce=null),o.parent?.removeEventListener?.("scroll",Fe),window.removeEventListener("resize",Fe),document.removeEventListener("pointerdown",Ct,!0),pe!=null&&(cancelAnimationFrame(pe),pe=null),X&&(X.disconnect(),X=null,ae.clear())}),(De,je)=>(ge(),Ae("div",{class:"section-wrapper",ref_key:"floatingCommentsContainer",ref:k,onClickCapture:wn,style:yn({minHeight:At.value+"px",transition:T.value?"none":void 0})},[Me("div",{class:"sidebar-container",style:yn({transform:`translateY(${b.value}px)`,transition:T.value?"none":void 0})},[(ge(!0),Ae(Wt,null,rr(st.value,Ke=>(ge(),Ae("div",{key:Ke.id,ref_for:!0,ref:pt=>U(Ke.id,pt),"data-comment-id":Ke.id,"data-comment-instance-id":Ke.id,"data-comment-thread-id":Ke.threadId,"data-comment-position-key":Ke.instanceRef?.positionKey??"","data-comment-page-index":Ke.pageIndex??"",class:rn([{"is-direct-decision-continuity-target":Ke.id===R.value},"comment-placeholder"]),style:yn({top:Ke.top+"px",height:Ke.height+"px",transition:T.value?"none":void 0})},[re(Ke)?(ge(),dn(Pp,{key:Ke.id+y.value,onReady:Z,onResize:pt=>S(Ke),class:"floating-comment",parent:e.parent,comment:Ke.commentRef,"floating-instance-id":Ke.id,"floating-page-index":Ke.pageIndex,"floating-position-entry":Ke.instanceRef?.positionEntry??null,"is-floating-instance-active":Ke.id===F.value},null,8,["onResize","parent","comment","floating-instance-id","floating-page-index","floating-position-entry","is-floating-instance-active"])):ht("",!0)],14,s9))),128))],4)],36))}},l9=fn(a9,[["__scopeId","data-v-a0a841ce"]]);xt(),gn();var c9={class:"superdoc__pdf-comments-layer pdf-comments-layer","aria-hidden":"false"},u9=["data-id","data-comment-id","data-page-number","onClick","onKeydown"],d9="pdf",f9="#078383",h9="#B1124B",p9={__name:"PdfCommentsLayer",emits:["anchor-activate"],setup(e,{emit:t}){const n=t,r=aa(),o=hu(),{activeComment:i}=Js(r),{documents:s,activeZoom:a}=Js(o),{proxy:l}=ir(),u=y=>typeof y=="number"?Number.isFinite(y):typeof y=="string"&&y.trim()!==""?Number.isFinite(Number(y)):!1,c=y=>!!y&&u(y.top)&&u(y.left)&&u(y.right)&&u(y.bottom),d=ke(()=>{const y=Array.isArray(s.value)?s.value:[];return new Set(y.filter(b=>b?.type===Ql).map(b=>String(b.id)))}),h=y=>{const b=y?.fileId??y?.documentId??y?.selection?.documentId;return b!=null?String(b):null},m=y=>{const b=y?.commentId??y?.importedId;return b!=null&&String(b)!==""?String(b):null},p=y=>{const b=d.value;if(!b.size)return!1;const T=h(y);return T?b.has(T):b.size===1},v=y=>{const b=Math.min(Number(y.top),Number(y.bottom)),T=Math.max(Number(y.top),Number(y.bottom));return{top:b,left:Math.min(Number(y.left),Number(y.right)),right:Math.max(Number(y.left),Number(y.right)),bottom:T}},_=ke(()=>{const y=r.getFloatingComments;return Array.isArray(y)?y.filter(b=>b?.selection?.source===d9).filter(b=>!b.resolvedTime).filter(b=>m(b)!==null).filter(b=>c(b.selection?.selectionBounds)).filter(b=>p(b)).map(b=>{const T=m(b),R=v(b.selection.selectionBounds);return{commentId:T,page:b.selection?.page??null,isInternal:b.isInternal!==!1,bounds:R}}):[]}),C=y=>{const b=(a.value??100)/100,{top:T,left:R,right:P,bottom:j}=y.bounds,O=i.value===y.commentId,V=(y.isInternal?f9:h9)+(O?"66":"33");return{position:"absolute",top:T*b+"px",left:R*b+"px",width:(P-R)*b+"px",height:(j-T)*b+"px",backgroundColor:V}},k=y=>{r.setActiveComment(l.$superdoc,y.commentId),n("anchor-activate",y.commentId)};return(y,b)=>(ge(),Ae("div",c9,[(ge(!0),Ae(Wt,null,rr(_.value,T=>(ge(),Ae("div",{key:T.commentId,class:"sd-comment-anchor sd-highlight",role:"button",tabindex:"0","data-id":T.commentId,"data-comment-id":T.commentId,"data-page-number":T.page,style:yn(C(T)),onClick:tn(R=>k(T),["stop","prevent"]),onKeydown:[Yo(tn(R=>k(T),["stop","prevent"]),["enter"]),Yo(tn(R=>k(T),["stop","prevent"]),["space"])]},null,44,u9))),128))]))}},m9=fn(p9,[["__scopeId","data-v-b5ad4c58"]]);xt();const g9=({proxy:e,layers:t,documents:n,modules:r})=>{const o=ke(()=>{const V=r.value?.whiteboard??r.whiteboard;return V===!1||V==null?null:V}),i=e?.$superdoc?.whiteboard,s=Kr([]),a=Gr({}),l=Gr({}),u=ne(!1),c=ne(0),d=ne(0),h=ne(1),m=ne(o.value?.enabled??!1),p=()=>{if(u.value)return;c.value+=1;const V=d.value||s.value.length;V&&c.value>=V&&(u.value=!0,e?.$superdoc?.emit("whiteboard:ready",{whiteboard:i}))},v=V=>{if(!V)return;const Q=n.value?.[0];Q&&Q.type==="application/pdf"&&_(V)},_=V=>{const{pageIndex:Q,width:F,height:N,originalWidth:x,originalHeight:z}=V,J={width:F,height:N,originalWidth:x,originalHeight:z};i?.setPageSize(Q,J),a[Q]=J;const X=i?.getPage(Q);X&&X.setSize(J),i&&(s.value=i.getPages().sort((ae,pe)=>ae.pageIndex-pe.pageIndex).map(ae=>Wr(ae)),d.value=s.value.length),_t(()=>{j(),p()})},C=V=>{e?.$superdoc?.emit("whiteboard:change",V)},k=V=>{V.forEach(Q=>{const F=a[Q.pageIndex];F&&Q.setSize(F)}),s.value=V.map(Q=>Wr(Q)),d.value=s.value.length,_t(()=>j())},y=V=>{m.value=V,e?.$superdoc?.emit("whiteboard:enabled",V)},b=V=>{h.value=V},T=V=>{e?.$superdoc?.emit("whiteboard:tool",V)},R=()=>{const V=n.value?.[0];V&&V.type==="application/pdf"&&P({doc:V})},P=({doc:V})=>{s.value.forEach(Q=>{const F=`${V.id}-page-${Q.pageIndex+1}`,N=document.querySelector(`[data-page-id="${F}"]`);if(!N)return;const x=N.getBoundingClientRect(),z=a[Q.pageIndex]||{},J=z.originalWidth??Q.size?.originalWidth??x.width,X=z.originalHeight??Q.size?.originalHeight??x.height,ae={width:x.width,height:x.height,originalWidth:J,originalHeight:X};a[Q.pageIndex]=ae,Q.setSize(ae)})},j=()=>{const V=t.value?.getBoundingClientRect?.();if(!V)return;const Q=n.value?.[0];Q&&Q.type==="application/pdf"&&O({doc:Q,layerBounds:V})},O=({doc:V,layerBounds:Q})=>{s.value.forEach(F=>{const N=`${V.id}-page-${F.pageIndex+1}`,x=document.querySelector(`[data-page-id="${N}"]`);if(!x)return;const z=x.getBoundingClientRect();l[F.pageIndex]={top:z.top-Q.top,left:z.left-Q.left}})};return i&&(i.on("change",C),i.on("setData",k),i.on("enabled",y),i.on("opacity",b),i.on("tool",T)),or(()=>{i&&(i.off("change",C),i.off("setData",k),i.off("opacity",b),i.off("enabled",y),i.off("tool",T))}),{whiteboard:i,whiteboardModuleConfig:o,whiteboardPages:s,whiteboardPageSizes:a,whiteboardPageOffsets:l,whiteboardEnabled:m,whiteboardOpacity:h,whiteboardReady:u,handleWhiteboardPageReady:v,updateWhiteboardPageSizes:R,updateWhiteboardPageOffsets:j}};xt(),gn();var v9=["data-page-index"],y9={__name:"WhiteboardPage",props:{whiteboard:{type:Object,required:!0},page:{type:Object,required:!0},pageSize:{type:Object,default:null},pageOffset:{type:Object,default:null},enabled:{type:Boolean,default:!0}},setup(e){const t=e,n=ne(null),r=()=>{const u=n.value;!u||!t.page||(t.page.mount(u),t.pageSize&&t.page.resize(t.pageSize.width,t.pageSize.height))},o=u=>{if(!t.page||!u?.dataTransfer||!t.enabled||t.whiteboard.getTool()!=="select")return;u.preventDefault(),u.stopPropagation();const c=n.value;if(!c)return;const d=c.getBoundingClientRect(),h=u.clientX-d.left,m=u.clientY-d.top,p=t.pageSize?.width,v=t.pageSize?.originalWidth??p,_=Number.isFinite(p)&&Number.isFinite(v)&&v?p/v:1;i(u,h,m,_)||s(u,h,m,_)||a(u,h,m)||l(u,h,m)},i=(u,c,d,h)=>{const m=u.dataTransfer.getData("application/sticker");if(!m)return!1;const p=(t.whiteboard.getType("stickers")||[]).find(v=>v.id===m);return p?.src?(t.page.addImage({stickerId:p.id,x:c,y:d,src:p.src,width:Number.isFinite(p.width)?p.width*h:p.width,height:Number.isFinite(p.height)?p.height*h:p.height,type:"sticker"}),!0):!1},s=(u,c,d,h)=>{const m=Array.from(u.dataTransfer.files||[]).find(v=>v.type.startsWith("image/"));if(!m)return!1;const p=new FileReader;return p.onload=()=>{typeof p.result=="string"&&t.page.addImage({x:c,y:d,src:p.result,type:"image"})},p.readAsDataURL(m),!0},a=(u,c,d)=>{const h=u.dataTransfer.getData("application/comment");if(!h)return!1;const m=(t.whiteboard.getType("comments")||[]).find(p=>p.id===h);return m?.text?(t.page.addText({x:c,y:d,content:m.text}),!0):!1},l=(u,c,d)=>{const h=u.dataTransfer.getData("text/plain");return h?(t.page.addText({x:c,y:d,content:h}),!0):!1};return Lt(()=>[t.page,t.pageSize?.width,t.pageSize?.height],()=>{_t(r)}),Nn(()=>{r()}),or(()=>{t.page?.destroy()}),(u,c)=>(ge(),Ae("div",{ref_key:"containerRef",ref:n,class:"whiteboard-page","data-page-index":e.page.pageIndex,onDragover:c[0]||(c[0]=tn(()=>{},["prevent"])),onDrop:tn(o,["prevent"]),style:yn({width:(e.pageSize?.width??e.page.size?.width)+"px",height:(e.pageSize?.height??e.page.size?.height)+"px",transform:`translate(${e.pageOffset?.left??0}px, ${e.pageOffset?.top??0}px)`})},null,44,v9))}},b9=fn(y9,[["__scopeId","data-v-c876c9b5"]]);xt(),gn();var w9={__name:"WhiteboardLayer",props:{whiteboard:{type:Object,required:!0},pages:{type:Array,default:()=>[]},pageSizes:{type:Object,default:()=>({})},pageOffsets:{type:Object,default:()=>({})},enabled:{type:Boolean,default:!0},interactive:{type:Boolean,default:null},opacity:{type:Number,default:1}},setup(e){const t=e,n=ke(()=>t.interactive==null?t.enabled:t.interactive);return(r,o)=>(ge(),Ae("div",{class:"whiteboard-layer","aria-hidden":"true",style:yn({opacity:e.opacity,pointerEvents:n.value?"auto":"none"})},[(ge(!0),Ae(Wt,null,rr(e.pages,i=>(ge(),dn(b9,{key:i.pageIndex,page:i,"page-size":e.pageSizes?.[i.pageIndex],"page-offset":e.pageOffsets?.[i.pageIndex],whiteboard:e.whiteboard,enabled:e.enabled},null,8,["page","page-size","page-offset","whiteboard","enabled"]))),128))],4))}},C9=fn(w9,[["__scopeId","data-v-54546c3d"]]);function _9(e){const t=e?.directionContext?.inlineDirection;if(t!=null)return t;const n=e?.paragraphProperties?.rightToLeft;if(n===!0)return"rtl";if(n===!1)return"ltr"}var T_=["#1f6feb","#d1242f","#8250df","#bf3989","#1a7f37","#9a6700","#bc4c00","#0969da","#cf222e","#6639ba","#116329","#7d4e00"];const S9=e=>e?`${typeof e.name=="string"?e.name:""} ${typeof e.email=="string"?e.email:""}`:"";var k9=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0};const A9=e=>T_[k9(S9(e))%T_.length];var ff=e=>typeof e=="string"&&e.length>0;const I9=e=>{if(!e||e.enabled===!1)return;const t=e.overrides&&typeof e.overrides=="object"?e.overrides:void 0,n=typeof e.resolve=="function"?e.resolve:void 0;return r=>{const o=r??{};if(t){if(ff(o.email)&&ff(t[o.email]))return t[o.email];if(ff(o.name)&&ff(t[o.name]))return t[o.name]}if(n)try{const i=n(o);if(ff(i))return i}catch{}return A9(o)}},E9=["insertion","deletion","move","move-from","move-to","table-cell-insertion","table-cell-deletion","cell-merge","cell-split","image-insertion","image-deletion","image-property-change"];var AU=new Set(E9);const gr={externalImageDeferred:"render.media.external-image-deferred",missingRelationship:"render.drawing.missing-relationship",missingMediaPart:"render.media.missing-part",unsupportedRelationshipType:"render.drawing.unsupported-relationship-type",unsupportedMime:"render.media.unsupported-mime",imageTooLarge:"render.media.image-too-large",unsafeSvg:"render.media.unsafe-svg",unsupportedFormat:"render.media.unsupported-format",embeddedObjectNotSupported:"render.embedded-object-not-supported",unsupportedObject:"render.drawing.unsupported-object",vmlUnsupported:"render.drawing.vml-unsupported",vmlImageUnsupported:"render.drawing.vml-image-unsupported",unsupportedGeometryCommand:"render.drawing.unsupported-geometry-command",anchorUnsupported:"render.drawing.anchor-unsupported",wrapUnsupported:"render.drawing.wrap-unsupported",altContentNoSupportedChoice:"render.drawing.altcontent-no-supported-choice",groupChildUnsupported:"render.drawing.group-child-unsupported"},IU={"render.media.missing-relationship":gr.missingRelationship,"render.media.wrong-relationship-type":gr.unsupportedRelationshipType,"render.media.unsupported-target":gr.unsupportedRelationshipType,"render.media.invalid-image-size":gr.imageTooLarge,"render.media-resolver-unavailable":gr.missingMediaPart,"render.chart-not-supported":gr.unsupportedObject,"render.textbox.vml-unsupported":gr.vmlUnsupported},x9={inlineBitmap:{family:"inlineBitmap",support:"supported",description:"wp:inline pic:pic with internal media and browser-safe MIME (PNG/JPEG; WebP/SVG once the host media resolver lands).",contract:"ImageRun"},anchoredBitmap:{family:"anchoredBitmap",support:"supported",description:"wp:anchor bitmap with anchor/wrap expressible by ImageAnchor/ImageWrap. Never silently inlined.",contract:"ImageBlock"},imageChildInGroup:{family:"imageChildInGroup",support:"supported",description:"Bitmap child of a supported DrawingML group/drawing wrapper. Supported only when the parent is.",contract:"ImageDrawing"},vectorShape:{family:"vectorShape",support:"supported",description:"Block/floating DrawingML preset/custom shape with the supported geometry/style subset.",contract:"DrawingBlock",drawingKind:"vectorShape"},shapeGroup:{family:"shapeGroup",support:"supported",description:"DrawingML group whose rendered children are supported vector/image children.",contract:"DrawingBlock",drawingKind:"shapeGroup"},chart:{family:"chart",support:"supported",description:"DrawingML chart projected into a ChartDrawing with parsed cached chart XML data. Complete Word chart fidelity remains deferred to chartFidelity.",contract:"DrawingBlock",drawingKind:"chart"},alternateContent:{family:"alternateContent",support:"supported",description:"mc:AlternateContent traversal/select policy. Selected Choice/Fallback maps to its family contract; unselected branches preserved for save/reopen.",contract:"selected-choice"},externalImage:{family:"externalImage",support:"fail-closed",description:'External image relationship (r:link / TargetMode="External"). Not fetched.',contract:"none",diagnostic:gr.externalImageDeferred},missingRelationship:{family:"missingRelationship",support:"fail-closed",description:"Drawing references a relationship id absent from the owner part .rels.",contract:"none",diagnostic:gr.missingRelationship},missingMediaPart:{family:"missingMediaPart",support:"fail-closed",description:"Relationship resolves but the target media part bytes are missing or empty.",contract:"none",diagnostic:gr.missingMediaPart},wrongRelationshipType:{family:"wrongRelationshipType",support:"fail-closed",description:"Relationship exists but is not an image relationship type.",contract:"none",diagnostic:gr.unsupportedRelationshipType},unsupportedMime:{family:"unsupportedMime",support:"fail-closed",description:"Media MIME outside the supported allowlist (incl. GIF/BMP/ICO).",contract:"none",diagnostic:gr.unsupportedMime},oversizedMediaPart:{family:"oversizedMediaPart",support:"fail-closed",description:"Media part exceeds the host byte-size policy before bytes are materialized.",contract:"none",diagnostic:gr.imageTooLarge},unsafeSvg:{family:"unsafeSvg",support:"fail-closed",description:"SVG content rejected by the SVG safety policy.",contract:"none",diagnostic:gr.unsafeSvg},metafileOrTiff:{family:"metafileOrTiff",support:"fail-closed",description:"EMF/WMF/TIFF and other non-browser-native formats with no approved conversion path.",contract:"none",diagnostic:gr.unsupportedFormat},embeddedObject:{family:"embeddedObject",support:"fail-closed",description:"OLE / ActiveX / embedded package object.",contract:"none",diagnostic:gr.embeddedObjectNotSupported},smartArtOrDiagram:{family:"smartArtOrDiagram",support:"fail-closed",description:"SmartArt / diagram / unknown external graphic-data object.",contract:"none",diagnostic:gr.unsupportedObject},vml:{family:"vml",support:"fail-closed",description:"VML structure outside any supported image-like subset (default fail-closed policy).",contract:"none",diagnostic:gr.vmlUnsupported},vmlImageLike:{family:"vmlImageLike",support:"fail-closed",description:"Simple VML image references (v:imagedata) / watermark image metadata. Fail-closed unless a later change promotes a named subset with deterministic fixtures and exact oracles.",contract:"none",diagnostic:gr.vmlImageUnsupported},unsupportedGeometryCommand:{family:"unsupportedGeometryCommand",support:"fail-closed",description:"Custom geometry command the extractor does not implement, e.g. arcTo.",contract:"none",diagnostic:gr.unsupportedGeometryCommand},unsupportedAnchorFields:{family:"unsupportedAnchorFields",support:"fail-closed",description:"Anchor fields required for honest placement are unsupported (char-relative, alignment modes, etc.).",contract:"none",diagnostic:gr.anchorUnsupported},unsupportedWrapFields:{family:"unsupportedWrapFields",support:"fail-closed",description:"Wrap fields required for honest placement are unsupported (arbitrary wrap polygons, etc.).",contract:"none",diagnostic:gr.wrapUnsupported},alternateContentNoSupportedChoice:{family:"alternateContentNoSupportedChoice",support:"fail-closed",description:"mc:AlternateContent with no supported choice and no usable fallback.",contract:"none",diagnostic:gr.altContentNoSupportedChoice},groupChildUnsupported:{family:"groupChildUnsupported",support:"fail-closed",description:"Unsupported child inside an otherwise-supported group. Supported siblings are not dropped.",contract:"none",diagnostic:gr.groupChildUnsupported},objectEditing:{family:"objectEditing",support:"deferred",description:"Editing/mutation of anchored/vector objects.",contract:"none"},customWrapPolygon:{family:"customWrapPolygon",support:"deferred",description:"Full Word-compatible text wrapping for arbitrary custom wrap polygons.",contract:"none"},chartFidelity:{family:"chartFidelity",support:"deferred",description:"Complete chart fidelity (a dedicated chart effort owns the parsed subset).",contract:"none"},vmlFidelity:{family:"vmlFidelity",support:"deferred",description:"Complete VML fidelity.",contract:"none"},decorativeAccessibilityUi:{family:"decorativeAccessibilityUi",support:"deferred",description:"Full accessibility UI for decorative image semantics beyond preserving source data.",contract:"none"}},EU=Object.keys(x9),xU=Object.freeze(["multiple-sections","furniture-page-tokens","non-balanceable-multi-column-sections","body-anchored-objects","footnotes","page-references","keep-constraints","tables","furniture-anchored-objects"]);xt(),gn();var T9={class:"superdoc-html-viewer"},R9={class:"superdoc-html-viewer__document"},M9=["innerHTML"],L9={__name:"HtmlViewer",props:{fileSource:{type:[File,Blob],required:!0},documentId:{type:String,required:!0}},emits:["ready","selection-change"],setup(e,{emit:t}){const n=e,r=ne(""),o=t,i=()=>{const l=window.getSelection();console.debug("selection from html viewer",l),o("selection-change",l)},s=l=>new Promise((u,c)=>{const d=new FileReader;d.onload=h=>{const m=h.target.result;u(m)},d.onerror=h=>c(h),d.readAsText(l)}),a=async()=>{try{r.value=await s(n.fileSource),o("ready",n.documentId)}catch(l){o("error",l),console.error("Error loading document",l)}};return Nn(()=>{a()}),(l,u)=>(ge(),Ae("div",T9,[Me("div",R9,[Me("div",{class:"superdoc-html-viewer__content",innerHTML:r.value,onMouseup:i},null,40,M9)])]))}},P9=fn(L9,[["__scopeId","data-v-da3494ba"]]);const D9=(e,t,n=()=>!0)=>{const r=new Set(t.map(String)),o=new Set;e.forEach(s=>{if(!n(s))return;const a=s.commentId!=null?String(s.commentId):null,l=s.importedId!=null?String(s.importedId):null;!(a&&r.has(a))&&!(l&&r.has(l))||(a&&o.add(a),l&&o.add(l))});let i=!0;for(;i;)i=!1,e.forEach(s=>{if(!n(s))return;const a=s.commentId!=null?String(s.commentId):null,l=s.importedId!=null?String(s.importedId):null,u=s.parentCommentId!=null?String(s.parentCommentId):null,c=Mp(s),d=c!=null?String(c):null,h=a&&o.has(a)||l&&o.has(l),m=u&&o.has(u)||d&&o.has(d);if(!h&&!m)return;const p=o.size;a&&o.add(a),l&&o.add(l),o.size>p&&(i=!0)});return o};xt();var R_=ne(!1);function Hi(){return{isHighContrastMode:R_,setHighContrastMode:t=>{R_.value=t}}}const TU="[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor",RU=320,MU=24,LU=816,PU=250,DU="sidebar",M_=new Set(["auto","sidebar","inline"]);function L_(e){if(!e||e===!1||typeof e!="object")return e;const t={...e},n=t.displayMode;M_.has(n)||delete t.displayMode;const r=t.compactBreakpointPx;typeof r=="number"&&Number.isFinite(r)&&r>=0||delete t.compactBreakpointPx;const o=t.compactMeasurementSelector;return typeof o=="string"&&o.trim().length>0?t.compactMeasurementSelector=o.trim():delete t.compactMeasurementSelector,t}xt();var O9=".superdoc__document",F9=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0,N9=e=>e+320+24;function B9({commentsModuleConfig:e,superdocRoot:t,layers:n}){const r=ne(0),o=ne(!1);let i=null,s=null;const a=m=>{if(!(m instanceof HTMLElement)||(typeof window<"u"?window.getComputedStyle(m):null)?.display==="contents")return!1;const p=Number(m.clientWidth??0),v=Number(m.getBoundingClientRect?.().width??0);return Number.isFinite(p)&&p>0||Number.isFinite(v)&&v>0},l=()=>{const m=t.value,p=e.value?.compactMeasurementSelector;if(typeof p=="string"&&p.trim().length>0&&typeof document<"u"){const _=document.querySelector(p.trim());if(a(_))return _}let v=m?.parentElement??null;for(;v;){if(a(v))return v;v=v.parentElement}return a(m)||m instanceof HTMLElement?m:null},u=()=>{const m=typeof window<"u"?window.ResizeObserver:void 0;if(typeof m>"u")return;const p=l();p!==s&&(i&&(i.disconnect(),i=null),s=p,s&&(i=new m(()=>{h()}),i.observe(s)))},c=()=>{u();const m=Number(s?.clientWidth??0);if(Number.isFinite(m)&&m>0)return m;const p=Number(s?.getBoundingClientRect?.().width??0);return Number.isFinite(p)&&p>0?p:0},d=()=>{const m=t.value?.querySelector?.(O9),p=n.value,v=Number(m?.clientWidth??m?.getBoundingClientRect?.().width??0);if(Number.isFinite(v)&&v>0)return v;const _=Number(p?.clientWidth??p?.getBoundingClientRect?.().width??0);return Number.isFinite(_)&&_>0?_:816},h=()=>{const m=c(),p=e.value,v=p?.displayMode??"sidebar";if(v==="sidebar"){r.value=m,o.value=!1;return}if(v==="inline"){r.value=m,o.value=!0;return}if(!(Number.isFinite(m)&&m>0))return;r.value=m;const _=p?.compactBreakpointPx;if(F9(_)){o.value=m<_;return}o.value=m<N9(d())};return or(()=>{i&&(i.disconnect(),i=null),s=null}),{superdocContainerWidth:r,isCompactCommentsMode:o,recalculateCompactCommentsMode:h,ensureCompactMeasurementObserver:u}}xt();var P_=320,el=12,z9=220,V9=16,H9=500,D_=".superdoc-comment-highlight[data-comment-ids]",O_="data-comment-ids",j9=".sd-comment-anchor",f0=(e,t,n)=>Math.min(Math.max(e,t),n),ws=e=>Number(e),ji=e=>Number.isFinite(e),h0=e=>e?.commentId??e?.importedId??null,F_=e=>String(e||"").split(",").map(t=>t.trim()).filter(Boolean),U9=e=>{const t=e?.value;if(!t)return null;const n=ws(t.ts);if(!ji(n)||Date.now()-n>H9)return null;const r=ws(t.x),o=ws(t.anchorRect?.bottom),i=ji(o)?o:ws(t.y);return!ji(r)||!ji(i)?null:{x:r,y:i}},G9=({rootEl:e,comment:t,pendingComment:n})=>{if(n?.value&&t?.commentId===n.value?.commentId){const a=e.querySelectorAll(D_);for(const l of a)if(F_(l.getAttribute(O_)).includes("pending")&&typeof l.getBoundingClientRect=="function")return l.getBoundingClientRect()}const r=h0(t);if(!r)return null;const o=String(r),i=e.querySelectorAll(D_);for(const a of i)if(F_(a.getAttribute(O_)).includes(o)&&typeof a.getBoundingClientRect=="function")return a.getBoundingClientRect();const s=e.querySelector(`[data-track-change-id="${o}"]`);return s&&typeof s.getBoundingClientRect=="function"?s.getBoundingClientRect():null},W9=(e,t)=>{const{entry:n}=e(h0(t)),r=ws(n?.bounds?.bottom);return ji(r)?r:ws(n?.bounds?.top)},K9=({selectionPosition:e,comment:t,pendingComment:n})=>e.value?.source==="pdf"||t?.selection?.source==="pdf"||n.value?.selection?.source==="pdf",q9=({rootEl:e,layersRect:t,comment:n})=>{const r=h0(n);if(r==null)return NaN;const o=e.querySelector(`${j9}[data-id="${String(r)}"]`);return!o||typeof o.getBoundingClientRect!="function"?NaN:ws(o.getBoundingClientRect().bottom)-ws(t.top)},Y9=({comment:e,pendingComment:t,selectionPosition:n,activeZoom:r})=>{if(!t.value||e?.commentId!==t.value?.commentId)return NaN;const o=ws(n.value?.bottom);if(ji(o))return o*(n.value?.source==="pdf"?(r.value??100)/100:1);const i=ws(n.value?.top);return ji(i)?i*(n.value?.source==="pdf"?(r.value??100)/100:1):NaN},X9=({top:e,left:t})=>({top:`${Math.round(e)}px`,left:`${Math.round(t)}px`,right:"auto"}),Z9=({rootRect:e,layersRect:t,anchorBottom:n,anchorClientX:r=NaN})=>{const o=f0(t.top-e.top+n+V9,el,Math.max(el,e.height-z9)),i=Math.max(el,e.width-P_-el);let s;if(ji(r))s=f0(r-e.left+el,el,i);else{const a=e.width-(t.left-e.left+t.width)+el;s=f0(e.width-a-P_,el,i)}return{top:o,left:s}};function Q9({activeComment:e,pendingComment:t,activeCompactComment:n,showCommentsSidebar:r,selectionPosition:o,activeZoom:i,superdocRoot:s,layers:a,documents:l,resolveCommentPositionEntry:u,clearActiveComment:c,clearPendingComment:d}){const h={top:"12px",right:"12px"},m=ne(0),p=ne({x:null,y:null,ts:0,anchorRect:null});let v=null,_=null;const C=()=>{p.value={x:null,y:null,ts:0,anchorRect:null}},k=(R,P,j)=>{if(!l.value?.some(V=>V.type==="application/pdf"))return!1;const O=R.querySelector(".superdoc__compact-comment-popover");return!n.value||!O||O.contains(P)||j?!1:(t.value&&d(),c(),C(),!0)},y=R=>{const P=s.value;if(!P||!a.value?.contains(R.target))return;const j=(typeof document.elementsFromPoint=="function"?document.elementsFromPoint(R.clientX,R.clientY):[]).find(V=>V?.nodeType===1&&P.contains(V)&&V.closest("[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor"))?.closest("[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor")??(R.target?.nodeType===1?R.target.closest("[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor"):null);if(k(P,R.target,j)||R.button!==0||R.pointerType!=="mouse")return;const O=j&&typeof j.getBoundingClientRect=="function"?j.getBoundingClientRect():null;O&&(p.value={x:R.clientX,y:O.bottom,ts:Date.now(),anchorRect:{left:O.left,right:O.right,top:O.top,bottom:O.bottom}})},b=ke(()=>{m.value;const R=n.value;if(!R)return h;const P=s.value,j=a.value;if(!P||!j)return h;const O=P.getBoundingClientRect(),V=j.getBoundingClientRect(),Q=U9(p),F=Q?null:G9({rootEl:P,comment:R,pendingComment:t});let N=NaN,x=NaN;return Q?(N=Q.y-V.top,x=Q.x):F?(N=F.bottom-V.top,x=F.left):N=W9(u,R),!ji(N)&&K9({selectionPosition:o,comment:R,pendingComment:t})&&(N=q9({rootEl:P,layersRect:V,comment:R})),ji(N)||(N=Y9({comment:R,pendingComment:t,selectionPosition:o,activeZoom:i})),ji(N)?X9(Z9({rootRect:O,layersRect:V,anchorBottom:N,anchorClientX:x})):h});return Lt([e,t,o,i,r,p],()=>{const R=typeof window<"u"?window.requestAnimationFrame:null,P=typeof window<"u"?window.cancelAnimationFrame:null;v!=null&&P?.(v),R&&(v=R(()=>{m.value+=1,v=null}))},{deep:!1}),Lt(n,(R,P)=>{if(!P&&R){const j=document.activeElement;j instanceof HTMLElement&&(_=j)}},{deep:!1}),Lt(t,(R,P)=>{!P&&R&&C()}),Nn(()=>{document.addEventListener("pointerdown",y,!0)}),or(()=>{document.removeEventListener("pointerdown",y,!0);const R=typeof window<"u"?window.cancelAnimationFrame:null;v!=null&&(R?.(v),v=null),_=null}),{compactCommentPopoverStyle:b,closeCompactCommentPopover:()=>{n.value&&(t.value&&d(),c(),_&&typeof _.focus=="function"&&_.focus(),_=null)},resetClickAnchor:C}}function tl(...e){const t={};for(const n of e)if(!(typeof n!="object"||n===null))for(const[r,o]of Object.entries(n))o!==void 0&&(t[r]=o);return t}function N_(...e){for(const t of e)if(t!==void 0)return t}function B_(e){if(e?.type!=="mutation:committed")return null;const t=e.origin==="history"?e.result:e.receipt;if(!t||typeof t!="object")return null;const n=new Set,r=new Set,o=[],i=(a,l)=>{a?.kind!=="entity"||a.entityType!=="trackedChange"||typeof a.entityId=="string"&&a.entityId.length>0&&l.add(a.entityId)},s=a=>a?.kind!=="entity"||a.entityType!=="trackedChange"?null:typeof a.entityId=="string"&&a.entityId.length>0?a.entityId:null;if(Array.isArray(t.inserted)&&t.inserted.forEach(a=>i(a,n)),Array.isArray(t.updated)&&t.updated.forEach(a=>i(a,n)),Array.isArray(t.trackedChangeRefs)&&t.trackedChangeRefs.forEach(a=>i(a,n)),Array.isArray(t.removed)&&t.removed.forEach(a=>i(a,r)),Array.isArray(t.invalidatedRefs)&&t.invalidatedRefs.forEach(a=>i(a,r)),Array.isArray(t.remappedRefs))for(const a of t.remappedRefs){const l=s(a?.from),u=s(a?.to);l&&r.add(l),u&&n.add(u),l&&u&&l!==u&&o.push({from:l,to:u})}for(const a of r)n.delete(a);return n.size===0&&r.size===0?null:{upsertIds:n,removedIds:r,remappedPairs:o,reconcileMode:e.origin==="history"?"authoritative":"targeted"}}var hf=e=>new Set(Array.from(e??[]).filter(t=>typeof t=="string"&&t.length>0)),J9=e=>typeof e?.id=="string"&&e.id.length>0?e.id:typeof e?.changeId=="string"&&e.changeId.length>0?e.changeId:typeof e?.address?.entityId=="string"&&e.address.entityId.length>0?e.address.entityId:null,$9=(e,t)=>e?.adapter===t?.adapter&&e?.documentId===t?.documentId&&e?.editor===t?.editor&&e?.reconcileToken===t?.reconcileToken;function z_({getContext:e,reconcile:t,hydrate:n,onReconciled:r}){const o=new Map;let i=0,s=0,a=null,l=!1;const u=(R,P)=>s===R&&$9(P,e()),c=(R,P)=>{const j=new Set;for(const O of R)o.get(O)===P.get(O)&&(o.delete(O),j.add(O));return j},d=R=>new Map([...o].filter(([,P])=>P.ready===!0&&P.reconcileMode===R)),h=()=>{let R=!1;for(const P of o.values())P.gate!=="render"||P.ready||(P.ready=!0,R=!0);return R},m=R=>{let P=!1;for(const j of o.values())j.version>R||j.ready||(j.ready=!0,P=!0);return P},p=async(R,P,j,O=!1)=>{if(!(!O&&P.size===0||typeof r!="function"))try{await r(R,P,j)}catch{}},v=R=>hf(R?.resolvedIds??(R?.items??[]).map(J9).filter(Boolean)),_=async(R,P,j)=>{const O=await t(R,{upsertIds:new Set(P.keys()),removedIds:new Set,reconcileMode:"targeted"});if(!u(j,R)||(await p(R,c(v(O),P),O),new Set([...P].filter(([Q,F])=>o.get(Q)===F).map(([Q])=>Q)).size===0))return;const V=await n(R,{trackedChangesListMode:"interaction-prime",refreshReason:"mutation-render-reconcile",blocking:!1});u(j,R)&&await p(R,c(v(V),P),V)},C=async(R,P,j)=>{const O=await n(R,{trackedChangesListMode:"all",refreshReason:"mutation-history-render-reconcile",blocking:!0});if(!u(j,R)||![...P].some(([x,z])=>o.get(x)===z))return;const V=O?.ok===!0,Q=V&&O?.complete===!0&&O?.sourceCoverageComplete===!0,F=V?v(O):new Set,N=Q?c(new Set(P.keys()),P):new Set;await p(R,Q?N:F,{...O,reconcileMode:"authoritative"},!0)},k=()=>{if(a)return a;const R=d("targeted"),P=d("authoritative");if(R.size===0&&P.size===0)return null;const j=e();if(!j?.adapter)return null;l=!1;const O=s;return a=Promise.resolve().then(async()=>{P.size>0&&await C(j,P,O).catch(()=>{}),R.size>0&&await _(j,R,O).catch(()=>{})}).catch(()=>{}).finally(()=>{a=null,l&&k()}),a},y=(R,P)=>{if(!R)return;const j=R.reconcileMode==="authoritative"?"authoritative":"targeted",O=hf(R.removedIds),V=hf(R.upsertIds);for(const F of O){const N=o.get(F);N?.reconcileMode==="authoritative"?o.set(F,{...N,version:++i,gate:P,ready:!1}):o.delete(F)}const Q=e();if(O.size>0&&V.size===0&&Q?.adapter)try{Promise.resolve(t(Q,{upsertIds:new Set,removedIds:O})).catch(()=>{})}catch{}for(const F of V)if(!O.has(F)){const N=o.get(F);o.set(F,{version:++i,gate:P,ready:!1,reconcileMode:j==="authoritative"||N?.reconcileMode==="authoritative"?"authoritative":"targeted"})}},b=R=>y(R,"render");return{enqueue:b,enqueueAfterPaint(R,P){if(!R||typeof P!="function"){b(R);return}y(R,"exact-paint");const j=e();if(!j?.adapter)return;const O=s,V=i,Q=new Set([...hf(R.upsertIds),...hf(R.removedIds)]),F=new Map([...Q].flatMap(N=>{const x=o.get(N);return x?[[N,x]]:[]}));Promise.resolve().then(()=>P()).then(()=>{if(!u(O,j))return;let N=h();m(V)&&(N=!0);for(const[x,z]of F)o.get(x)===z&&(z.ready||(N=!0),z.ready=!0);a&&(N||V>0)&&(l=!0),k()}).catch(()=>{if(u(O,j))for(const[N,x]of F)o.get(N)===x&&(x.gate="render")})},onRender:(R=!1)=>{const P=h();a&&(P||R)&&(l=!0),k()},reset(){s+=1,o.clear(),l=!1},getPendingIds(){return new Set(o.keys())}}}function eM(e,t){if(!e||typeof e.entityId!="string"||e.entityType!=="comment"&&e.entityType!=="trackedChange")return null;const n=typeof t=="function"?t(e.entityId):null,r=n?.commentId??n?.importedId??e.entityId;return r!=null?String(r):null}var tM=new Set(["insert-text","replace-text","plain-text-paste","delete-backward","delete-forward","text.insert","text.replace","text.pastePlain","text.deleteBackward","text.deleteForward","structural.enter","structural:enter-split-paragraph","structural:enter-insert-paragraph-before","structural:enter-insert-paragraph-after","structural:shift-enter-line-break","structural:backspace-boundary-merge-with-previous","structural:delete-boundary-merge-with-next","backspace:boundary-merge-with-previous","backspace:list-remove","backspace:list-outdent"]);const V_=e=>e?.type!=="mutation:committed"||e.origin!=="command"?!1:tM.has(e.editableCommandKind);function H_(e){return e==null?null:String(e)}function nM({hydrate:e,getActiveDocumentId:t,debounceMs:n=250,ceilingMs:r=1e3,now:o=()=>Date.now(),setTimer:i=(a,l)=>setTimeout(a,l),clearTimer:s=a=>clearTimeout(a)}){let a=null,l=null,u=null;const c=m=>H_(t())===m,d=()=>{a!=null&&s(a),a=null,l=null,u=null};return{schedule:m=>{const p=H_(m);if(!c(p))return!1;u!==p&&d();const v=o();u=p,l??=v,a!=null&&s(a);const _=Math.max(0,r-(v-l));return a=i(()=>{const C=u;a=null,l=null,u=null,c(C)&&e()},Math.min(n,_)),!0},clear:d}}var rM="no-author-configured";const oM="author-required",j_="This edit needs an author identity. Set `user.name` in your SuperDoc configuration and reopen the document to make tracked or revision-overlapping edits.";function U_(e){return typeof e=="string"&&e.includes(rM)}function iM(e){if(!e||e.type!=="mutation:rejected")return!1;if(e.failureSource==="receipt"){const t=e.failure;return t?t.code==="PRECONDITION_FAILED"&&U_(t.message):!1}return e.failureSource==="shell"?e.reason==="author-required"?!0:e.reason==="PRECONDITION_FAILED"&&U_(e.message):!1}function sM(){const e=new Set,t=n=>typeof n=="string"&&n.length>0?n:"__default__";return{shouldNotify(n,r){if(!iM(r))return!1;const o=t(n);return e.has(o)?!1:(e.add(o),!0)},clear(n){e.delete(t(n))}}}const aM=e=>!!(e?.anchor&&e?.focus&&(e.anchor.blockId!==e.focus.blockId||e.anchor.blockOffset!==e.focus.blockOffset)),lM=(e,t)=>{if(!e||e.rangeCount<1||e.isCollapsed||!t)return!1;const n=e.getRangeAt(0);return!t.contains(n.startContainer)&&!t.contains(n.endContainer)},cM=(e,t)=>e!=="editing"&&e!=="suggesting"?!1:aM(t);var uM=Ir((()=>{})),dM=nd({default:()=>eS},1),G_,W_,K_,q_,Y_,X_,Z_,Q_,J_,$_,eS,fM=Ir((()=>{xt(),uM(),gn(),G_=["onKeydown"],W_=["id"],K_={class:"sd-password-prompt__description"},q_={class:"sd-password-prompt__field"},Y_=["placeholder","disabled","aria-label"],X_={key:0,class:"sd-password-prompt__error",role:"alert"},Z_={class:"sd-password-prompt__actions"},Q_=["disabled"],J_=["disabled"],$_={__name:"PasswordPromptSurface",props:{surfaceId:{type:String,default:""},mode:{type:String,default:"dialog"},request:{type:Object,default:()=>({})},resolve:{type:Function,default:()=>{}},close:{type:Function,default:()=>{}},passwordPrompt:{type:Object,required:!0}},setup(e){const t=e,n=ne(""),r=ne(!1),o=ne(t.passwordPrompt.errorCode==="DOCX_PASSWORD_INVALID"),i=ne(o.value?t.passwordPrompt.texts.invalidMessage:""),s=ke(()=>o.value?t.passwordPrompt.texts.invalidTitle:t.passwordPrompt.texts.title),a=ke(()=>n.value.length>0&&!r.value);async function l(){if(!a.value)return;r.value=!0,i.value="";const c=await t.passwordPrompt.attemptPassword(n.value);if(c.success){t.resolve({password:n.value});return}r.value=!1,n.value="",c.errorCode==="DOCX_PASSWORD_INVALID"?(o.value=!0,i.value=t.passwordPrompt.texts.invalidMessage):c.errorCode==="timeout"?i.value=t.passwordPrompt.texts.timeoutMessage:i.value=t.passwordPrompt.texts.genericErrorMessage}function u(){t.close("user-cancelled")}return(c,d)=>(ge(),Ae("div",{class:"sd-password-prompt",onKeydown:Yo(tn(l,["prevent"]),["enter"])},[Me("h3",{id:`sd-password-prompt-heading-${e.surfaceId}`,class:"sd-password-prompt__heading"},Bt(s.value),9,W_),Me("p",K_,Bt(e.passwordPrompt.texts.description),1),Me("div",q_,[Us(Me("input",{"onUpdate:modelValue":d[0]||(d[0]=h=>n.value=h),type:"password",class:"sd-password-prompt__input",placeholder:e.passwordPrompt.texts.placeholder,disabled:r.value,autocomplete:"current-password","aria-label":e.passwordPrompt.texts.inputAriaLabel},null,8,Y_),[[Ai,n.value]])]),i.value?(ge(),Ae("p",X_,Bt(i.value),1)):ht("",!0),Me("div",Z_,[Me("button",{type:"button",class:"sd-password-prompt__btn sd-password-prompt__btn--cancel",disabled:r.value,onClick:u},Bt(e.passwordPrompt.texts.cancelLabel),9,Q_),Me("button",{type:"button",class:"sd-password-prompt__btn sd-password-prompt__btn--submit",disabled:!a.value,onClick:l},Bt(r.value?e.passwordPrompt.texts.busyLabel:e.passwordPrompt.texts.submitLabel),9,J_)])],40,G_))}},eS=fn($_,[["__scopeId","data-v-ecf7f6fb"]])}));xt();var hM=["DOCX_PASSWORD_REQUIRED","DOCX_PASSWORD_INVALID"],pM=3e4,Ii={title:"Password Required",invalidTitle:"Incorrect Password",description:"This document is password protected. Enter the password to open it.",placeholder:"Enter password",inputAriaLabel:"Document password",submitLabel:"Open",cancelLabel:"Cancel",busyLabel:"Decryptingβ¦",invalidMessage:"Incorrect password. Please try again.",timeoutMessage:"Timed out while decrypting. Please try again.",genericErrorMessage:"Unable to decrypt this document."};function mM({getSurfaceManager:e,getPasswordPromptConfig:t,onUnhandled:n}){const r=[],o=Kr(null),i=new Map;let s=!1;function a(p,v,_){if(!p||!hM.includes(v)||t()===!1||!e())return!1;const C=i.get(p.id);if(C)return clearTimeout(C.timer),C.resolve({success:!1,errorCode:v}),i.delete(p.id),!0;const k=r.find(y=>y.doc.id===p.id);return k?(k.errorCode=v,k.originalException=_,!0):(o.value?.doc.id===p.id||(r.push({doc:p,errorCode:v,originalException:_}),c()),!0)}function l(p){if(!p)return;const v=i.get(p.id);v&&(clearTimeout(v.timer),v.resolve({success:!0}),i.delete(p.id))}function u(){s=!0;for(const[,p]of i)clearTimeout(p.timer),p.resolve({success:!1,errorCode:"destroyed"});i.clear(),r.length=0,o.value=null}function c(){if(s||o.value||r.length===0)return;const p=r.shift();p&&d(p).catch(v=>{o.value=null,console.error("[SuperDoc] Password prompt error:",v),n?.(p.doc,p.errorCode,p.originalException),c()})}async function d({doc:p,errorCode:v,originalException:_}){const C=e();if(!C||s)return;const k=h(),y=P=>(p.password=P,p.editorMountNonce++,new Promise(j=>{const O=setTimeout(()=>{i.delete(p.id),j({success:!1,errorCode:"timeout"})},pM);i.set(p.id,{resolve:j,timer:O})})),b={documentId:p.id,errorCode:v,texts:k.texts,attemptPassword:y},T=m(k,{documentId:p.id,errorCode:v,texts:k.texts});if(T.suppressed){n?.(p,v,_),c();return}o.value={doc:p,surfaceHandle:null};let R;if(T.component)R=C.open({mode:"dialog",closeOnBackdrop:!1,ariaLabel:k.texts.title,component:Wr(T.component),props:{...T.props,passwordPrompt:b}});else if(T.render){const P=T.render;R=C.open({mode:"dialog",closeOnBackdrop:!1,ariaLabel:k.texts.title,render:j=>P({container:j.container,passwordPrompt:b,resolve:j.resolve,close:j.close,surfaceId:j.surfaceId,mode:j.mode})})}else{const P=(await Promise.resolve().then(()=>(fM(),dM))).default,j=`password-prompt-${p.id}`;R=C.open({id:j,mode:"dialog",closeOnBackdrop:!1,ariaLabelledBy:`sd-password-prompt-heading-${j}`,component:Wr(P),props:{passwordPrompt:b}})}o.value={doc:p,surfaceHandle:R},await R.result,o.value=null,c()}function h(){const p=t();if(p===!1)return{enabled:!1,texts:Ii};const v=typeof p=="object"&&p!==null?p:{};if(v.component!=null&&typeof v.render=="function")throw new Error('modules.surfaces.passwordPrompt cannot provide both "component" and "render". Use one or the other.');return{enabled:!0,texts:{title:v.title??Ii.title,invalidTitle:v.invalidTitle??Ii.invalidTitle,description:v.description??Ii.description,placeholder:v.placeholder??Ii.placeholder,inputAriaLabel:v.inputAriaLabel??Ii.inputAriaLabel,submitLabel:v.submitLabel??Ii.submitLabel,cancelLabel:v.cancelLabel??Ii.cancelLabel,busyLabel:v.busyLabel??Ii.busyLabel,invalidMessage:v.invalidMessage??Ii.invalidMessage,timeoutMessage:v.timeoutMessage??Ii.timeoutMessage,genericErrorMessage:v.genericErrorMessage??Ii.genericErrorMessage},component:v.component,props:v.props,render:v.render,resolver:v.resolver}}function m(p,v){if(typeof p.resolver=="function"){const _=p.resolver(v);if(_!=null&&_.type!=="default"){if(_.type==="none")return{suppressed:!0};if(_.type==="custom")return{component:_.component,props:_.props};if(_.type==="external")return{render:_.render}}}return p.component!=null?{component:p.component,props:p.props}:typeof p.render=="function"?{render:p.render}:{builtin:!0}}return{handleEncryptionError:a,handleEditorReady:l,destroy:u}}function tS(e,{getCurrentSession:t,applySlice:n,onSettled:r}){return()=>{if(e===t())try{n(e.getSnapshot())}catch{}r()}}var gM=Ir((()=>{})),vM=nd({default:()=>kS},1),nS,rS,oS,iS,sS,aS,lS,cS,uS,dS,fS,hS,pS,mS,gS,vS,yS,bS,wS,CS,_S,SS,kS,yM=Ir((()=>{xt(),gM(),gn(),nS=["onKeydown"],rS={class:"sd-find-replace__row"},oS=["title","aria-label","aria-expanded"],iS=["value","placeholder","aria-label"],sS={key:0,class:"sd-find-replace__count"},aS=["title","aria-label","aria-pressed"],lS=["title","aria-label","aria-pressed"],cS=["title","aria-label","aria-pressed"],uS={class:"sd-find-replace__nav"},dS=["disabled","title","aria-label"],fS=["disabled","title","aria-label"],hS=["title","aria-label"],pS={key:0,class:"sd-find-replace__row"},mS={class:"sd-find-replace__field"},gS=["value","placeholder","aria-label"],vS={class:"sd-find-replace__nav sd-find-replace__nav--actions"},yS=["disabled","title"],bS=["disabled","title"],wS={key:1,class:"sd-find-replace__error",role:"alert"},CS={key:0,class:"sd-find-replace__row-indent","aria-hidden":"true"},_S={class:"sd-find-replace__error-text"},SS={__name:"FindReplaceSurface",props:{surfaceId:{type:String,default:""},mode:{type:String,default:"floating"},request:{type:Object,default:()=>({})},resolve:{type:Function,default:()=>{}},close:{type:Function,default:()=>{}},findReplace:{type:Object,required:!0}},setup(e){const t=e,n=ne(null),r=ke(()=>{const p=t.findReplace;return!!(!p.hasMatches?.value||p.replacePending?.value===!0||p.canReplace&&p.canReplace.value===!1)}),o=ke(()=>t.findReplace.ignoreDiacriticsSupported?.value!==!1),i=ke(()=>t.findReplace.replaceEnabled&&t.findReplace.replaceCanMutate?.value!==!1),s=ke(()=>t.findReplace.regexSupported?.value===!0),a=ke(()=>t.findReplace.searchError?.value??null);function l(p){p.key==="Enter"&&!p.shiftKey?(p.preventDefault(),u()):p.key==="Enter"&&p.shiftKey&&(p.preventDefault(),c())}function u(){t.findReplace.goNext(),m()}function c(){t.findReplace.goPrev(),m()}function d(){t.findReplace.close("user-closed")}function h(p){const v=[];let _=p?.parentElement??null;for(;_;){const k=_.ownerDocument?.defaultView?.getComputedStyle?.(_);if(k){const y=`${k.overflowY} ${k.overflowX}`;(y.includes("auto")||y.includes("scroll"))&&v.push(_)}_=_.parentElement}const C=p?.ownerDocument?.scrollingElement;return C&&!v.includes(C)&&v.push(C),v}function m(){const p=n.value;if(!p)return;const v=h(p).map(_=>({el:_,top:_.scrollTop,left:_.scrollLeft}));p.focus({preventScroll:!0});for(const{el:_,top:C,left:k}of v)_.scrollTop!==C&&(_.scrollTop=C),_.scrollLeft!==k&&(_.scrollLeft=k)}return Nn(()=>{n.value?.focus(),t.findReplace.registerFocusFn(m)}),(p,v)=>(ge(),Ae("div",{class:"sd-find-replace",onKeydown:Yo(tn(d,["stop"]),["esc"])},[Me("div",rS,[i.value?(ge(),Ae("button",{key:0,type:"button",class:rn(["sd-find-replace__btn sd-find-replace__btn--expander",{"sd-find-replace__btn--expander-open":e.findReplace.showReplace.value}]),title:e.findReplace.texts.toggleReplaceLabel,"aria-label":e.findReplace.texts.toggleReplaceAriaLabel,"aria-expanded":e.findReplace.showReplace.value?"true":"false",onClick:v[0]||(v[0]=_=>e.findReplace.showReplace.value=!e.findReplace.showReplace.value)},[...v[14]||(v[14]=[Me("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true"},[Me("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],10,oS)):ht("",!0),Me("div",{class:rn(["sd-find-replace__field",{"sd-find-replace__field--error":a.value}])},[v[15]||(v[15]=Me("svg",{class:"sd-find-replace__search-icon",viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},[Me("path",{d:"M7 1a6 6 0 1 0 3.7 10.7l3.3 3.3 1-1-3.3-3.3A6 6 0 0 0 7 1Zm0 1.5a4.5 4.5 0 1 1 0 9 4.5 4.5 0 0 1 0-9Z",fill:"currentColor"})],-1)),Me("input",{ref_key:"findInputRef",ref:n,value:e.findReplace.findQuery.value,onInput:v[1]||(v[1]=_=>e.findReplace.findQuery.value=_.target.value),type:"text",class:"sd-find-replace__input sd-find-replace__input--search","data-sd-autofocus":"",placeholder:e.findReplace.texts.findPlaceholder,"aria-label":e.findReplace.texts.findAriaLabel,onKeydown:l},null,40,iS),e.findReplace.findQuery.value&&!a.value?(ge(),Ae("span",sS,Bt(e.findReplace.matchLabel.value),1)):ht("",!0),Me("button",{type:"button",class:rn(["sd-find-replace__btn sd-find-replace__btn--toggle",{"sd-find-replace__btn--active":e.findReplace.caseSensitive.value}]),title:e.findReplace.texts.matchCaseAriaLabel,"aria-label":e.findReplace.texts.matchCaseAriaLabel,"aria-pressed":e.findReplace.caseSensitive.value?"true":"false",onMousedown:v[2]||(v[2]=tn(()=>{},["prevent"])),onClick:v[3]||(v[3]=_=>e.findReplace.caseSensitive.value=!e.findReplace.caseSensitive.value)},Bt(e.findReplace.texts.matchCaseLabel),43,aS),o.value?(ge(),Ae("button",{key:1,type:"button",class:rn(["sd-find-replace__btn sd-find-replace__btn--toggle",{"sd-find-replace__btn--active":e.findReplace.ignoreDiacritics.value}]),title:e.findReplace.texts.ignoreDiacriticsAriaLabel,"aria-label":e.findReplace.texts.ignoreDiacriticsAriaLabel,"aria-pressed":e.findReplace.ignoreDiacritics.value?"true":"false",onMousedown:v[4]||(v[4]=tn(()=>{},["prevent"])),onClick:v[5]||(v[5]=_=>e.findReplace.ignoreDiacritics.value=!e.findReplace.ignoreDiacritics.value)},Bt(e.findReplace.texts.ignoreDiacriticsLabel),43,lS)):ht("",!0),s.value?(ge(),Ae("button",{key:2,type:"button",class:rn(["sd-find-replace__btn sd-find-replace__btn--toggle",{"sd-find-replace__btn--active":e.findReplace.regex.value}]),title:e.findReplace.texts.regexAriaLabel,"aria-label":e.findReplace.texts.regexAriaLabel,"aria-pressed":e.findReplace.regex.value?"true":"false",onMousedown:v[6]||(v[6]=tn(()=>{},["prevent"])),onClick:v[7]||(v[7]=_=>e.findReplace.regex.value=!e.findReplace.regex.value)},Bt(e.findReplace.texts.regexLabel),43,cS)):ht("",!0)],2),Me("div",uS,[Me("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--icon",disabled:!e.findReplace.hasMatches.value,title:e.findReplace.texts.previousMatchLabel,"aria-label":e.findReplace.texts.previousMatchAriaLabel,onClick:v[8]||(v[8]=_=>c())},[...v[16]||(v[16]=[Me("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[Me("path",{d:"M10 3.5 5.5 8 10 12.5",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,dS),Me("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--icon",disabled:!e.findReplace.hasMatches.value,title:e.findReplace.texts.nextMatchLabel,"aria-label":e.findReplace.texts.nextMatchAriaLabel,onClick:v[9]||(v[9]=_=>u())},[...v[17]||(v[17]=[Me("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[Me("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,fS),v[19]||(v[19]=Me("span",{class:"sd-find-replace__divider","aria-hidden":"true"},null,-1)),Me("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--icon",title:e.findReplace.texts.closeLabel,"aria-label":e.findReplace.texts.closeAriaLabel,onClick:d},[...v[18]||(v[18]=[Me("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[Me("path",{d:"m4.5 4.5 7 7m0-7-7 7",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"})],-1)])],8,hS)])]),e.findReplace.showReplace.value&&i.value?(ge(),Ae("div",pS,[v[20]||(v[20]=Me("span",{class:"sd-find-replace__row-indent","aria-hidden":"true"},null,-1)),Me("div",mS,[Me("input",{value:e.findReplace.replaceText.value,onInput:v[10]||(v[10]=_=>e.findReplace.replaceText.value=_.target.value),type:"text",class:"sd-find-replace__input",placeholder:e.findReplace.texts.replacePlaceholder,"aria-label":e.findReplace.texts.replaceAriaLabel,onKeydown:v[11]||(v[11]=Yo(tn(_=>e.findReplace.replaceCurrent(),["prevent"]),["enter"]))},null,40,gS)]),Me("div",vS,[Me("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--action",disabled:r.value,title:e.findReplace.texts.replaceLabel,onClick:v[12]||(v[12]=_=>e.findReplace.replaceCurrent())},Bt(e.findReplace.texts.replaceLabel),9,yS),Me("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--action",disabled:r.value,title:e.findReplace.texts.replaceAllLabel,onClick:v[13]||(v[13]=_=>e.findReplace.replaceAll())},Bt(e.findReplace.texts.replaceAllLabel),9,bS)])])):ht("",!0),a.value?(ge(),Ae("div",wS,[i.value?(ge(),Ae("span",CS)):ht("",!0),Me("span",_S,Bt(a.value),1)])):ht("",!0)],40,nS))}},kS=fn(SS,[["__scopeId","data-v-fed15bd3"]])}));xt();var ar={findPlaceholder:"Find",findAriaLabel:"Find text",replacePlaceholder:"Replace",replaceAriaLabel:"Replace text",noResultsLabel:"No results",previousMatchLabel:"Previous match (Shift+Enter)",previousMatchAriaLabel:"Previous match",nextMatchLabel:"Next match (Enter)",nextMatchAriaLabel:"Next match",closeLabel:"Close (Escape)",closeAriaLabel:"Close find and replace",replaceLabel:"Replace",replaceAllLabel:"All",toggleReplaceLabel:"Toggle replace",toggleReplaceAriaLabel:"Toggle replace",matchCaseLabel:"Aa",matchCaseAriaLabel:"Match case",regexLabel:".*",regexAriaLabel:"Use regular expression",invalidPatternLabel:"Invalid pattern",ignoreDiacriticsLabel:"Γ€β‘a",ignoreDiacriticsAriaLabel:"Ignore diacritics"};function bM(e){if(!e)return null;const t=e.extensionStorage,n=e.storage,r=t?.Search??n?.Search;if(r?.searchIndex||r?.searchResults)return r;const o=e.extensionStorage??e.storage;if(o)for(const i of Object.keys(o)){const s=o[i];if(s&&typeof s=="object"&&"searchIndex"in s&&"searchResults"in s)return s}return null}function wM({getSurfaceManager:e,getActiveEditor:t,activeEditorRef:n,getFindReplaceConfig:r,getSuperDocUI:o}){let i=null,s=null,a=null,l=!1,u=!1;const c=ne(!1);let d=null;const h=ne(""),m=ne(""),p=ne(!1),v=ne(!1),_=ne(!1),C=ne(!1),k=ne(0),y=ne(-1),b=ne(!0),T=ne(!1),R=ne(!0),P=ne(!1),j=ne(null);let O=ar;const V=ke(()=>h.value?k.value===0?O.noResultsLabel:`${y.value+1} of ${k.value}`:""),Q=ke(()=>k.value>0),F=ke(()=>Q.value&&!T.value&&b.value);let N=null,x=null;function z(G){return typeof G?.commands?.setSearchSession=="function"}function J(){try{const G=(typeof o=="function"?o():null)?.search;return G&&typeof G.search=="function"?G:null}catch{return null}}function X(G){G&&(k.value=typeof G.total=="number"?G.total:0,y.value=typeof G.activeIndex=="number"?G.activeIndex:-1,b.value=G.canReplace===!0,j.value=G.reason==="search-invalid-pattern"?O.invalidPatternLabel:null)}function ae(){if(a){pe();return}if(s){if(!h.value){try{s.commands.clearSearchSession()}catch{}k.value=0,y.value=-1;return}try{const G=s.commands.setSearchSession(h.value,{caseSensitive:p.value,ignoreDiacritics:v.value,highlight:!0,searchModel:Ee().includeDeletedText?"raw":"visible"});k.value=G.matches.length,y.value=G.activeMatchIndex}catch{}}}function pe(){const G=a;if(G){if(!h.value){try{G.clear()}catch{}k.value=0,y.value=-1,j.value=null;return}try{X(G.search(h.value,{caseSensitive:p.value,includeDeletedText:Ee().includeDeletedText===!0,regex:_.value}))}catch{}}}function Fe(){N&&clearTimeout(N),N=setTimeout(ae,150)}Lt(h,()=>{c.value&&Fe()}),Lt(p,()=>{c.value&&ae()}),Lt(v,()=>{c.value&&ae()}),Lt(_,()=>{c.value&&ae()});let fe=!0;function ye(){if(Q.value){if(a){try{a.next(),X(a.getSnapshot())}catch{}return}if(s)try{y.value=s.commands.nextSearchMatch().activeMatchIndex}catch{}}}function le(){if(Q.value){if(a){try{a.previous(),X(a.getSnapshot())}catch{}return}if(s)try{y.value=s.commands.previousSearchMatch().activeMatchIndex}catch{}}}function Se(){if(fe&&!T.value&&Q.value){if(a){if(!b.value)return;const G=a;T.value=!0;const te=tS(G,{getCurrentSession:()=>a,applySlice:X,onSettled:()=>{T.value=!1}});let Y=null;try{Y=G.replace(m.value)}catch{}Y&&typeof Y.then=="function"?Promise.resolve(Y).then(te,te):te();return}if(s)try{const G=s.commands.replaceSearchMatch(m.value);k.value=G.matches.length,y.value=G.activeMatchIndex}catch{}}}function re(){if(fe&&!T.value&&Q.value){if(a){if(!b.value)return;const G=a;T.value=!0;const te=tS(G,{getCurrentSession:()=>a,applySlice:X,onSettled:()=>{T.value=!1}});let Y=null;try{Y=G.replaceAll(m.value)}catch{}Y&&typeof Y.then=="function"?Promise.resolve(Y).then(te,te):te();return}if(s)try{s.commands.replaceAllSearchMatches(m.value),k.value=0,y.value=-1}catch{}}}function xe(){if(a){try{X(a.getSnapshot())}catch{}return}const G=bM(s);if(!G)return;const te=G.searchResults,Y=Array.isArray(te)?te.length:0,K=G.activeMatchIndex??-1;Y!==k.value&&(k.value=Y),K!==y.value&&(y.value=K)}function $e(){st(),x=setInterval(xe,200)}function st(){N&&clearTimeout(N),N=null,x&&clearInterval(x),x=null}function At(){h.value="",m.value="",p.value=!1,v.value=!1,_.value=!1,j.value=null,C.value=!1,k.value=0,y.value=-1,b.value=!0,T.value=!1}function Ee(){const G=typeof r=="function"?r():void 0;if(G===!1||G==null)return{enabled:!1,texts:ar,replaceEnabled:!0};if(G===!0)return{enabled:!0,texts:ar,replaceEnabled:!0};const te=typeof G=="object"?G:{};if(te.component!=null&&typeof te.render=="function")throw new Error('modules.surfaces.findReplace cannot provide both "component" and "render". Use one or the other.');return{enabled:!0,texts:{findPlaceholder:te.findPlaceholder??ar.findPlaceholder,findAriaLabel:te.findAriaLabel??ar.findAriaLabel,replacePlaceholder:te.replacePlaceholder??ar.replacePlaceholder,replaceAriaLabel:te.replaceAriaLabel??ar.replaceAriaLabel,noResultsLabel:te.noResultsLabel??ar.noResultsLabel,previousMatchLabel:te.previousMatchLabel??ar.previousMatchLabel,previousMatchAriaLabel:te.previousMatchAriaLabel??ar.previousMatchAriaLabel,nextMatchLabel:te.nextMatchLabel??ar.nextMatchLabel,nextMatchAriaLabel:te.nextMatchAriaLabel??ar.nextMatchAriaLabel,closeLabel:te.closeLabel??ar.closeLabel,closeAriaLabel:te.closeAriaLabel??ar.closeAriaLabel,replaceLabel:te.replaceLabel??ar.replaceLabel,replaceAllLabel:te.replaceAllLabel??ar.replaceAllLabel,toggleReplaceLabel:te.toggleReplaceLabel??ar.toggleReplaceLabel,toggleReplaceAriaLabel:te.toggleReplaceAriaLabel??ar.toggleReplaceAriaLabel,matchCaseLabel:te.matchCaseLabel??ar.matchCaseLabel,matchCaseAriaLabel:te.matchCaseAriaLabel??ar.matchCaseAriaLabel,regexLabel:te.regexLabel??ar.regexLabel,regexAriaLabel:te.regexAriaLabel??ar.regexAriaLabel,invalidPatternLabel:te.invalidPatternLabel??ar.invalidPatternLabel,ignoreDiacriticsLabel:te.ignoreDiacriticsLabel??ar.ignoreDiacriticsLabel,ignoreDiacriticsAriaLabel:te.ignoreDiacriticsAriaLabel??ar.ignoreDiacriticsAriaLabel},replaceEnabled:te.replaceEnabled??!0,includeDeletedText:te.includeDeletedText??!1,component:te.component,props:te.props,render:te.render,resolver:te.resolver,floating:te.floating&&typeof te.floating=="object"?te.floating:void 0}}function Ge(G,te){if(typeof G.resolver=="function"){const Y=G.resolver(te);if(Y!=null&&Y.type!=="default"){if(Y.type==="none")return{suppressed:!0};if(Y.type==="custom")return{component:Y.component,props:Y.props};if(Y.type==="external")return{render:Y.render}}}return G.component!=null?{component:G.component,props:G.props}:typeof G.render=="function"?{render:G.render}:{builtin:!0}}function qe(G,te){return{findQuery:h,replaceText:m,caseSensitive:p,ignoreDiacritics:v,regex:_,showReplace:C,matchCount:k,activeMatchIndex:y,matchLabel:V,hasMatches:Q,canReplace:F,replaceCanMutate:b,replacePending:T,ignoreDiacriticsSupported:R,regexSupported:P,searchError:j,replaceEnabled:G.replaceEnabled??!0,texts:G.texts,goNext:ye,goPrev:le,replaceCurrent:Se,replaceAll:re,registerFocusFn:Y=>{d=Y},close:Y=>te(Y)}}function Z(G){return{get findQuery(){return G.findQuery.value},set findQuery(te){G.findQuery.value=te},get replaceText(){return G.replaceText.value},set replaceText(te){G.replaceText.value=te},get caseSensitive(){return G.caseSensitive.value},set caseSensitive(te){G.caseSensitive.value=te},get ignoreDiacritics(){return G.ignoreDiacritics.value},set ignoreDiacritics(te){G.ignoreDiacritics.value=te},get regex(){return G.regex.value},set regex(te){G.regex.value=te},get regexSupported(){return G.regexSupported.value},get searchError(){return G.searchError.value},get replaceCanMutate(){return G.replaceCanMutate.value},get showReplace(){return G.showReplace.value},set showReplace(te){G.showReplace.value=te},get matchCount(){return G.matchCount.value},get activeMatchIndex(){return G.activeMatchIndex.value},get matchLabel(){return G.matchLabel.value},get hasMatches(){return G.hasMatches.value},get canReplace(){return G.canReplace.value},get replacePending(){return G.replacePending.value},get ignoreDiacriticsSupported(){return G.ignoreDiacriticsSupported.value},replaceEnabled:G.replaceEnabled,texts:G.texts,goNext:G.goNext,goPrev:G.goPrev,replaceCurrent:G.replaceCurrent,replaceAll:G.replaceAll,registerFocusFn:G.registerFocusFn,close:G.close}}function S(G){if(G){if(typeof G?.commands?.clearSearchSession=="function"){try{G.commands.clearSearchSession()}catch{}return}if(a&&G===s)try{a.clear()}catch{}}}function ee(){try{if(l||!e()||!t())return!1;if(i&&c.value)return!0;const G=Ee();if(!G.enabled||Ge(G,{texts:G.texts,replaceEnabled:G.replaceEnabled??!0}).suppressed)return!1;if(!z(t())){const te=J();if(!te)return!1;try{if(te.getSnapshot?.().available!==!0)return!1}catch{return!1}}return!0}catch{return!1}}async function D(){if(l)return;const G=e();if(G){if(i&&c.value){d?.();return}if(!u){u=!0;try{const te=t();if(!te){u=!1;return}const Y=Ee();if(!Y.enabled){u=!1;return}const K=Ge(Y,{texts:Y.texts,replaceEnabled:Y.replaceEnabled??!0});if(K.suppressed){u=!1;return}At(),O=Y.texts,fe=Y.replaceEnabled??!0;const be={placement:"top-right",autoFocus:!0,width:420,...Y.floating??{}};if(s&&s!==te&&S(s),s=te,a=z(te)?null:J(),R.value=!a,P.value=!!a,a)try{X(a.getSnapshot())}catch{}d=null;let me=()=>{};const Ce=qe(Y,He=>me(He));let Pe;if(K.component)Pe=G.open({mode:"floating",ariaLabel:Y.texts.findAriaLabel,closeOnEscape:!0,floating:be,component:Wr(K.component),props:{...K.props,findReplace:Ce}});else if(K.render){const He=K.render;Pe=G.open({mode:"floating",ariaLabel:Y.texts.findAriaLabel,closeOnEscape:!0,floating:be,render:Ct=>He({container:Ct.container,findReplace:Z(Ce),resolve:Ct.resolve,close:Ct.close,surfaceId:Ct.surfaceId,mode:Ct.mode})})}else{let He;try{He=(await Promise.resolve().then(()=>(yM(),vM))).default}catch{u=!1;return}if(l||i&&c.value){u=!1;return}const Ct=t()||te;s!==Ct&&(S(s),s=Ct,a=z(Ct)?null:J(),R.value=!a),Pe=G.open({mode:"floating",ariaLabel:Y.texts.findAriaLabel,component:Wr(He),closeOnEscape:!0,floating:be,props:{findReplace:Ce}})}me=He=>Pe.close(He??"programmatic"),i=Pe,c.value=!0,u=!1,$e();const it=Pe.id;Pe.result.then(()=>{i?.id===it?(st(),S(s),i=null,c.value=!1,d=null):S(te!==s?te:null)})}catch(te){throw u=!1,te}}}}function U(){i&&i.close("programmatic")}n&&Lt(n,(G,te)=>{!c.value||!i||G!==te&&(S(te),U())});function H(){l=!0,st(),U(),s=null,a=null,d=null}return{open:D,close:U,isOpen:c,wouldOpen:ee,destroy:H}}var pf=null;function p0(e){e!=null&&(pf=e)}function CM(e){pf===e&&(pf=null)}function _M(e){return pf===null||pf===e}function SM(e,{focusInside:t,owner:n}){if(e.defaultPrevented)return!1;if(t)return!0;const r=document.activeElement;return(!r||r===document.body||r===document.documentElement)&&_M(n)}var kM=/^(https?|mailto|tel):/i,AM=/^(javascript|data|vbscript):/i,IM=/^[a-z][a-z0-9+.-]*:/i;function EM(e){if(typeof e!="string")return null;const t=e.trim();return t?t.startsWith("#")?{href:t}:AM.test(t)?null:IM.test(t)?kM.test(t)?{href:t}:null:{href:t}:null}var xM='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M0 64C0 46.3 14.3 32 32 32l48 0 16 0 128 0c70.7 0 128 57.3 128 128c0 31.3-11.3 60.1-30 82.3c37.1 22.4 62 63.1 62 109.7c0 70.7-57.3 128-128 128L96 480l-16 0-48 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l16 0 0-160L48 96 32 96C14.3 96 0 81.7 0 64zM224 224c35.3 0 64-28.7 64-64s-28.7-64-64-64L112 96l0 128 112 0zM112 288l0 128 144 0c35.3 0 64-28.7 64-64s-28.7-64-64-64l-32 0-112 0z"/></svg>',TM='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M128 64c0-17.7 14.3-32 32-32l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-58.7 0L160 416l64 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l58.7 0L224 96l-64 0c-17.7 0-32-14.3-32-32z"/></svg>',RM='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M16 64c0-17.7 14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 53 43 96 96 96s96-43 96-96l0-128-16 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 88.4-71.6 160-160 160s-160-71.6-160-160L64 96 48 96C30.3 96 16 81.7 16 64zM0 448c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32z"/></svg>',AS='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M40 48C26.7 48 16 58.7 16 72l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24L40 48zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM16 232l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24l-48 0c-13.3 0-24 10.7-24 24zM40 368c-13.3 0-24 10.7-24 24l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24l-48 0z"/></svg>',MM=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc. (bullet shapes modified)--><path fill-rule="evenodd" d="M192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM64 48 A48 48 0 1 0 64 144 A48 48 0 1 0 64 48 Z M64 68 A28 28 0 1 1 64 124 A28 28 0 1 1 64 68 Z M64 208 A48 48 0 1 0 64 304 A48 48 0 1 0 64 208 Z M64 228 A28 28 0 1 1 64 284 A28 28 0 1 1 64 228 Z M64 368 A48 48 0 1 0 64 464 A48 48 0 1 0 64 368 Z M64 388 A28 28 0 1 1 64 444 A28 28 0 1 1 64 388 Z"/></svg>
|
|
14
|
+
`).trim();return v?v.split(/\n{2,}/).map(_=>`<p>${c(_).replace(/\n/g,"<br>")}</p>`).join(""):"<p></p>"},m=ke({get:()=>d(o.value),set:p=>{o.value=h(p)}});return Nn(u),Lt(o,u),t({focus:a}),(p,v)=>(ge(),Ae("div",z7,[e.includeHeader?(ge(),dn(a0,{key:0,config:e.config,comment:e.comment,"is-pending-input":!0},null,8,["config","comment"])):ht("",!0),Me("div",{class:rn(["comment-entry",{"sd-input-active":e.isFocused}])},[Us(Me("textarea",{ref_key:"inputRef",ref:i,class:"superdoc-field",placeholder:"Add a comment","onUpdate:modelValue":v[0]||(v[0]=_=>m.value=_),rows:"1",onInput:l,onFocus:v[1]||(v[1]=_=>s(!0)),onBlur:v[2]||(v[2]=_=>s(!1))},null,544),[[Ai,m.value]])],2)]))}},c0=fn(V7,[["__scopeId","data-v-cc54b489"]]);xt(),gn();var H7=["data-comment-instance-id","data-comment-thread-id","data-comment-position-key","data-comment-page-index"],j7={key:0,class:"existing-internal-input"},U7={class:"new-comment-input-wrapper"},G7={class:"reply-actions"},W7=["disabled"],K7={key:0,class:"resolved-badge"},q7=["innerHTML"],Y7={key:1,class:"existing-internal-input"},X7={key:0,class:"card-section comment-body"},Z7=["data-track-change-semantic-color-key"],Q7={key:0},J7={class:"change-type tracked-change-label"},$7={key:0,class:"tracked-change-detail-lines"},eR={key:0,class:"tracked-change-text"},tR={key:1,class:"change-type"},nR={class:"change-type"},rR={key:1},oR={class:"tracked-change-text is-inserted"},iR={key:2},sR={class:"tracked-change-text is-inserted"},aR={key:3},lR={key:4},cR={key:5},uR={key:6},dR={class:"tracked-change-text"},fR={key:7},hR={class:"tracked-change-text is-deleted"},pR={class:"tracked-change-text is-inserted"},mR={key:8},gR={class:"tracked-change-text is-deleted"},vR={key:9},yR={class:"tracked-change-text is-inserted"},bR=["data-track-change-image-preview-role"],wR=["src","alt"],CR={key:1,class:"card-section comment-body"},_R=["innerHTML"],SR={key:1,class:"comment"},kR={key:2,class:"reply-expanded"},AR={class:"reply-input-wrapper"},IR={class:"reply-actions"},ER=["onClick"],xR=["onClick","disabled","data-disabled-reason"],TR={class:"collapsed-avatars"},RR={key:3,class:"comment-separator"},MR={key:2,class:"tracked-change-decision-alert",role:"alert"},LR={class:"tracked-change-decision-alert__message"},PR=["disabled","data-disabled-reason"],DR={key:1,class:"reply-expanded"},OR={class:"reply-input-wrapper"},FR={class:"reply-actions"},NR=["disabled","data-disabled-reason"],Lp=3,A_=90,BR={__name:"CommentDialog",props:{comment:{type:Object,required:!0},autoFocus:{type:Boolean,default:!1},parent:{type:Object,required:!1},floatingInstanceId:{type:String,default:null},floatingPageIndex:{type:Number,default:null},floatingPositionEntry:{type:Object,default:null},isFloatingInstanceActive:{type:Boolean,default:void 0}},emits:["click-outside","ready","dialog-exit","resize"],setup(e,{emit:t}){const n=t,r=e,{proxy:o}=ir(),i=hu(),s=aa(),{addComment:a,cancelComment:l,deleteComment:u,getCommentAliasIds:c,removePendingComment:d,getCommentDocumentId:h,requestInstantSidebarAlignment:m,resolveCommentPositionEntry:p,clearInstantSidebarAlignment:v,setActiveFloatingCommentInstance:_}=s,{suppressInternalExternal:C,getConfig:k,activeComment:y,activeFloatingCommentInstanceId:b,floatingCommentsOffset:T,pendingComment:R,currentCommentText:P,isDebugging:j,editingCommentId:O,editorCommentPositions:V,isCommentHighlighted:Q}=Js(s),F=ne(!0),N=ne(null),x=ne(new Map),z=ne(null),J=[[0,0],[-Lp,0],[Lp,0],[0,-Lp],[0,Lp]],X=_e=>{const ze=typeof _e?.width=="number"&&Number.isFinite(_e.width)?_e.width:null,vt=typeof _e?.height=="number"&&Number.isFinite(_e.height)?_e.height:null;if(!ze||!vt||ze<=0||vt<=0)return{};const ot=Math.min(A_/ze,A_/vt,1);return{width:`${Math.max(1,Math.round(ze*ot))}px`,height:`${Math.max(1,Math.round(vt*ot))}px`}},ae=[".comments-dropdown__option-label",".comments-dropdown__menu",".comments-dropdown__option",".comments-dropdown__option-icon",".comments-dropdown__trigger",".superdoc-comment-highlight",".sd-editor-comment-highlight",".sd-editor-tracked-change-highlight","[data-track-change-id]",".track-insert",".track-insert-dec",".track-delete",".track-delete-dec",".track-format",".track-format-dec"].join(","),pe=_e=>ze=>{_e&&(ze?(x.value.set(_e,ze),O.value===_e&&_t(()=>{ye(_e)})):x.value.delete(_e))},Fe=(_e,ze,vt)=>{const ot=_e?.getBoundingClientRect?.();return!ot||![ot.left,ot.top,ot.right,ot.bottom].every(Number.isFinite)||ot.width<=0||ot.height<=0?!1:J.some(([xn,Tn])=>{const _r=ze+xn,jr=vt+Tn;return _r>=ot.left&&_r<=ot.right&&jr>=ot.top&&jr<=ot.bottom})},fe=(_e,ze)=>{if(!Number.isFinite(_e)||!Number.isFinite(ze))return null;const vt=document.querySelectorAll(ae);for(const ot of vt)if(ot instanceof HTMLElement&&Fe(ot,_e,ze))return ot;return null},ye=_e=>{x.value.get(_e)?.focus?.()},le=ne(null),Se=_e=>_e.resolvedTime?_e.commentId:_e.importedId||_e.commentId,re=_e=>_e?_e.trackedChange&&_e.importedId!=null?String(_e.importedId):_e.commentId!=null?String(_e.commentId):null:null,xe=(_e,ze)=>{const vt=_e?.bounds?.[ze];return Number.isFinite(vt)?vt:null},$e=(_e,ze)=>{if(!_e||!ze||_e.pageIndex!==ze.pageIndex)return!1;const vt=xe(_e,"top"),ot=xe(ze,"top");return vt!=null&&ot!=null&&Math.abs(vt-ot)<.5},st=(_e,ze)=>{const vt=xe(_e,"left"),ot=xe(ze,"left"),xn=xe(_e,"right"),Tn=xe(ze,"right");return[vt,ot,xn,Tn].some(_r=>_r==null)?!1:ot<xn&&vt<Tn},At=(_e,ze)=>{const vt=_e?.start,ot=_e?.end,xn=ze?.start,Tn=ze?.end;return[vt,ot,xn,Tn].every(Number.isFinite)?xn<=ot&&vt<=Tn:!1},Ee=(_e,ze)=>!_e||!ze||_e.kind&&ze.kind&&_e.kind!==ze.kind||_e.storyKey&&ze.storyKey&&_e.storyKey!==ze.storyKey?!1:ze.start===_e.start&&ze.end===_e.end?!0:$e(_e,ze)&&st(_e,ze)&&At(_e,ze),Ge=_e=>{const ze=new Set(c(_e)),{key:vt,entry:ot}=p(_e);return vt&&ze.add(vt),ot?(Object.entries(V.value??{}).forEach(([xn,Tn])=>{Ee(ot,Tn)&&ze.add(xn)}),[...ze]):[...ze]},qe=(_e,ze,vt=24)=>{if(!Number.isFinite(ze)||typeof _e?.getBoundingClientRect!="function")return!1;const ot=_e.getBoundingClientRect().top;return Number.isFinite(ot)&&Math.abs(ot-ze)<=vt},Z=ke(()=>r.floatingInstanceId??r.comment.commentId??null),S=ke(()=>typeof r.isFloatingInstanceActive=="boolean"?r.isFloatingInstanceActive:y.value!==r.comment.commentId?!1:r.floatingInstanceId==null?!0:b.value===r.floatingInstanceId),ee=ke(()=>r.comment.resolvedTime?r.comment.trackedChange?r.comment.trackedChangeDecision==="reject"?"Rejected":"Accepted":"Resolved":null),D=ke(()=>R.value&&R.value.commentId===r.comment.commentId),U=ke(()=>_e=>{const ze=Ye.value;return H.value&&_e===ze.length-1?!0:ze.length>1&&_e!==ze.length-1}),H=ke(()=>!k.readOnly&&S.value&&!r.comment.resolvedTime&&!Pt.value),G=()=>({ok:!1,reason:"read-only-document"}),te=()=>k.value?.readOnly===!0,Y=ne(!1),K=ne(!1),be=()=>{if(te())return G();if(hn.value)return{ok:!1,reason:cn.value?.reason??"v2-write-unavailable"};Y.value=!0,_t(()=>{N.value?.focus?.(),n("resize")})},me=ke(()=>{const _e=r.comment;return _e.trackedChange?s.getTrackedChangeThread(_e):s.commentsList.filter(ze=>{const vt=ze.parentCommentId===_e.commentId,ot=ze.commentId===_e.commentId;return vt||ot}).sort((ze,vt)=>ze.commentId===_e.commentId?-1:vt.commentId===_e.commentId?1:ze.createdTime-vt.createdTime)}),Ce=ne(!1),Pe=ne(null),it=ne(!1),He=ke(()=>!Ce.value),Ct=ke(()=>({"is-truncated":He.value,"is-scrollable":Ce.value&&it.value})),Yt=()=>{Ce.value=!Ce.value,_t(()=>n("resize"))},St=_e=>{Pe.value=_e??null},Ft=()=>{if(Ce.value)return;const _e=Pe.value;if(!_e){it.value=!1;return}it.value=_e.scrollHeight>_e.clientHeight+1};Lt(Pe,()=>{_t(Ft)});const Nt=()=>O.value?me.value.some(_e=>_e.commentId===O.value):!1;Lt(S,_e=>{_e||((Y.value||Nt())&&(P.value="",O.value=null),Ce.value=!1,sn.value=!1,Y.value=!1,_t(()=>n("resize")))});const sn=ne(!1),_n=ke(()=>me.value.slice(1)),Qt=ke(()=>sn.value?!1:_n.value.length>=2),Ye=ke(()=>Qt.value?[me.value[0],_n.value[_n.value.length-1]].filter(Boolean):me.value);Lt(ke(()=>{const _e=Ye.value[0];return _e?JSON.stringify({commentId:_e.commentId,commentText:_e.commentText,trackedChange:_e.trackedChange,trackedChangeText:_e.trackedChangeText,deletedText:_e.deletedText,trackedChangeLabel:_e.trackedChangeLabel,trackedChangeDisplayType:_e.trackedChangeDisplayType,trackedChangeDetailLines:_e.trackedChangeDetailLines}):""}),()=>{_t(Ft)});const Et=ke(()=>Qt.value?_n.value.length-1:0),Ot=ke(()=>{if(!Qt.value)return[];const _e=_n.value.slice(0,-1),ze=new Set;return _e.map(vt=>typeof vt.getCommentUser=="function"?vt.getCommentUser():{name:vt.creatorName,email:vt.creatorEmail||vt.email}).filter(vt=>{if(!vt)return!1;const ot=vt.email||vt.name;return ze.has(ot)?!1:(ze.add(ot),!0)}).slice(0,3)}),wn=()=>{sn.value=!0,Ke(),_t(()=>n("resize"))},Kt=ke(()=>r.comment.resolvedTime?!0:k.value.readOnly),Sn=ke(()=>_e=>S.value&&O.value===_e.commentId),Pt=ke(()=>!O.value||!S.value?!1:me.value.some(_e=>_e.commentId===O.value)),De=ke(()=>k.value.readOnly||!o.$superdoc.config.isInternal||ft.value?!1:!C.value&&!r.comment.trackedChange),je=ke(()=>P.value&&P.value!=="<p></p>"),Ke=async()=>{const _e=o.$superdoc.activeEditor,ze=_e?.editorVersion===2?_e?.v2Comments??null:null,vt=!!r.comment?.trackedChange,ot=o7(),xn=r.floatingInstanceId!=null,Tn=le.value?.getBoundingClientRect?.().top,_r=!r.comment.resolvedTime&&(y.value!==r.comment.commentId||xn&&Z.value!==b.value);let jr=ot;if(ze){const gi=!vt&&!r.comment.resolvedTime&&String(r.comment?.trackedChangeParentId??"").trim()?r.comment.trackedChangeParentId:null,Ji=_e?.editorVersion===2&&(vt||gi!=null)?_e?.v2TrackedChanges??null:null,Es=gi!=null?s.getComment(gi):null,No=vt?r.comment:Es?.trackedChange?Es:gi;let Yr=await(Ji?Ji.focusTrackedChange(No):ze.focusComment(r.comment));return!vt&&Yr?.reason==="tracked-change-anchor-not-found"&&(Yr=await ze.focusComment(r.comment)),Yr?.ok?(r.comment.resolvedTime||(y.value=r.comment.commentId,r.floatingInstanceId&&_(r.floatingInstanceId)),_r&&!xn?m(ot,r.comment.commentId,r.floatingInstanceId??null):_r&&Number.isFinite(Tn)?m(Tn,r.comment.commentId,r.floatingInstanceId):v(),Yr):(v(),Yr)}if(_e){const{entry:gi}=p(r.comment),Ji=r.floatingPositionEntry??gi,Es=Number.isFinite(r.floatingPageIndex)&&r.comment?.trackedChangeStory?.storyType==="headerFooterPart",No=w_(r.parent,Ji),Yr=Es?null:i7(Ge(r.comment)),Jo=Number.isFinite(Yr)?Yr:No,$i=qe(le.value,Jo),Mi=Se(r.comment),lo=null;let $o=null;if(vt)if(r.comment.trackedChangeStory&&(r.comment.trackedChangeStory,{...Number.isFinite(r.floatingPageIndex)?{pageIndex:r.floatingPageIndex}:{}}),r.comment.resolvedTime)_e.commands?.setCursorById(Mi);else{const Xr=r.comment.commentId;_e.commands?.setCursorById(Mi,{activeCommentId:Xr})||_e.commands?.setActiveComment({commentId:Xr})}else{if(r.comment.resolvedTime)_e.commands?.setCursorById(Mi);else{const ur=r.comment.commentId;_e.commands?.setCursorById(Mi,{activeCommentId:ur})||_e.commands?.setActiveComment({commentId:ur})}const Xr=r.comment.commentId;$o=$i?null:s7(lo,Mi,Xr,ot)}Number.isFinite(Yr)?jr=Yr:Number.isFinite(No)?jr=No:Number.isFinite($o)&&(jr=$o)}_r&&!xn?r.floatingInstanceId?m(jr,r.comment.commentId,r.floatingInstanceId):m(jr,r.comment.commentId):v(),r.comment.resolvedTime||(y.value=r.comment.commentId,r.floatingInstanceId&&_(r.floatingInstanceId))},pt=_e=>{const ze=_e.target instanceof Element?_e.target:_e.target?.parentElement,vt=document.elementFromPoint(_e.clientX,_e.clientY);if(!(ze?.closest?.(ae)||vt?.closest?.(ae)||fe(_e.clientX,_e.clientY)||Q.value)&&!(_e.target.closest?.(".comments-dialog")&&!le.value?.contains(_e.target))){if(D.value){l(o.$superdoc);return}S.value&&(T.value=0,n("dialog-exit"),y.value=null,s.setActiveComment(o.$superdoc,y.value),Q.value=!1)}},kt=async()=>{if(te())return G();if(hn.value)return{ok:!1,reason:cn.value?.reason??"v2-write-unavailable"};if(ft.value&&an.value&&!D.value){if(K.value)return{ok:!1,reason:"reply-submit-in-flight"};K.value=!0;try{const vt=await s.replyCommentV2({superdoc:o.$superdoc,parentCommentId:re(r.comment),text:P.value});return vt?.ok?(Y.value=!1,P.value="",_t(()=>n("resize")),vt):(_t(()=>n("resize")),vt)}finally{K.value=!1}}const _e={documentId:r.comment.fileId,isInternal:R.value?R.value.isInternal:F.value,parentCommentId:R.value?null:r.comment.commentId};R.value&&(_e.selection=R.value.selection.getValues());const ze=s.getPendingComment(_e);!R.value&&P.value&&ze.setText({text:P.value,suppressUpdate:!0}),Promise.resolve(a({superdoc:o.$superdoc,comment:ze})).finally(()=>{Y.value=!1,_t(()=>n("resize"))})},ft=ke(()=>o.$superdoc?.activeEditor?.editorVersion===2),an=ke(()=>ft.value?o.$superdoc?.activeEditor?.v2Comments??null:null),qt=ke(()=>ft.value?o.$superdoc?.activeEditor?.v2TrackedChanges??null:null),cn=ke(()=>{if(!an.value)return null;const _e=s.viewingVisibility.documentMode,ze=an.value.getCapabilityState?.()??null;return _e==="viewing"?{...ze??{},canWrite:!1,reason:"review-surface-read-only"}:ze}),hn=ke(()=>{if(!ft.value)return!1;const _e=cn.value;return _e?_e.canWrite===!1:!1}),oo=ke(()=>K.value?"reply-submit-in-flight":hn.value?cn.value?.reason??"v2-write-unavailable":null),Jt=ke(()=>{if(!qt.value)return null;const _e=s.viewingVisibility.documentMode,ze=qt.value.getCapabilityState?.()??null;return _e==="viewing"&&ze?.canDecide!==!1?{canDecide:!1,reason:"review-surface-read-only"}:ze}),Yn=_e=>{if(ft.value&&_e?.trackedChange){if(!qt.value)return"v2-tracked-change-adapter-missing";const ze=Jt.value;return ze&&ze.canDecide===!1?ze.reason??"v2-tracked-change-unavailable":null}return hn.value?cn.value?.reason??"v2-write-unavailable":null},Nr=_e=>{if(ft.value&&_e?.trackedChange){if(!qt.value)return"v2-tracked-change-adapter-missing";const ze=Jt.value;return ze&&ze.canDecide===!1?ze.reason??"v2-tracked-change-unavailable":null}return hn.value?cn.value?.reason??"v2-write-unavailable":null},io=()=>ft.value?an.value?k.value?.readOnly?"read-only-document":hn.value?cn.value?.reason??"v2-write-unavailable":null:"v2-comments-adapter-missing":null,vo=ke(()=>!ft.value||!hn.value?null:cn.value?.reason??"v2-write-unavailable"),$t=(_e,ze)=>{z.value={decision:_e,reason:ze?.reason??null},_t(()=>n("resize"))},Bn=()=>{z.value&&(z.value=null,_t(()=>n("resize")))},xi=ke(()=>{const _e=z.value;if(!_e)return null;const ze=_e.decision==="reject"?"reject":"accept";return _e.reason==="stale-catalog"?`Couldn't ${ze} this change because the review list is stale.`:`Couldn't ${ze} this change.`}),Is=()=>{const _e=z.value;if(_e){if(z.value=null,_e.decision==="reject"){so();return}cr()}},so=async()=>{if(te())return G();const _e=o.$superdoc.config.onTrackedChangeBubbleReject;if(r.comment.trackedChange){if(ft.value){const vt=await s.decideTrackedChangeFromSidebar({superdoc:o.$superdoc,comment:r.comment,decision:"reject"});if(!vt?.ok||vt.success===!1){$t("reject",vt);return}Bn(),typeof _e=="function"&&_e(r.comment,o.$superdoc.activeEditor),_t(()=>{s.lastUpdate=new Date,y.value=null,s.setActiveComment(o.$superdoc,y.value),o.$superdoc.focus?.({preventScroll:!0})});return}let ze=!0;if(typeof _e=="function")_e(r.comment,o.$superdoc.activeEditor);else{const vt=s.decideTrackedChangeFromSidebar({superdoc:o.$superdoc,comment:r.comment,decision:"reject"});ze=!!vt?.ok&&vt.success!==!1}ze&&r.comment.resolveComment({id:i.user.id,email:i.user.email,name:i.user.name,superdoc:o.$superdoc,decision:"reject"})}else if(ft.value&&an.value){if(!(await s.deleteComment({superdoc:o.$superdoc,commentId:r.comment.commentId}))?.ok)return}else s.deleteComment({superdoc:o.$superdoc,commentId:r.comment.commentId});_t(()=>{s.lastUpdate=new Date,y.value=null,s.setActiveComment(o.$superdoc,y.value),o.$superdoc.focus?.()})},cr=async()=>{if(te())return G();if(!r.comment.trackedChange&&k.value?.allowResolve===!1)return{ok:!1,reason:"resolve-disabled"};const _e=o.$superdoc.config.onTrackedChangeBubbleAccept;if(r.comment.trackedChange&&ft.value){const vt=await s.decideTrackedChangeFromSidebar({superdoc:o.$superdoc,comment:r.comment,decision:"accept"});if(!vt?.ok||vt.success===!1){$t("accept",vt);return}Bn(),typeof _e=="function"&&_e(r.comment,o.$superdoc.activeEditor),_t(()=>{s.lastUpdate=new Date,y.value=null,s.setActiveComment(o.$superdoc,y.value),o.$superdoc.focus?.({preventScroll:!0})});return}let ze=!0;if(r.comment.trackedChange&&typeof _e=="function")_e(r.comment,o.$superdoc.activeEditor);else if(r.comment.trackedChange){const vt=s.decideTrackedChangeFromSidebar({superdoc:o.$superdoc,comment:r.comment,decision:"accept"});ze=!!vt?.ok&&vt.success!==!1}else if(ft.value&&an.value){if(!(await s.resolveCommentV2({superdoc:o.$superdoc,commentId:r.comment.commentId}))?.ok)return}else r.comment.resolveComment({id:i.user.id,email:i.user.email,name:i.user.name,superdoc:o.$superdoc});r.comment.trackedChange&&!ft.value&&ze&&r.comment.resolveComment({id:i.user.id,email:i.user.email,name:i.user.name,superdoc:o.$superdoc,decision:"accept"}),_t(()=>{s.lastUpdate=new Date,y.value=null,s.setActiveComment(o.$superdoc,y.value),o.$superdoc.focus?.()})},Qo=async()=>{if(te())return G();if(k.value?.allowResolve===!1)return{ok:!1,reason:"resolve-disabled"};!ft.value||!an.value||(await s.reopenCommentV2({superdoc:o.$superdoc,commentId:r.comment.commentId}))?.ok&&_t(()=>{s.lastUpdate=new Date,s.setActiveComment(o.$superdoc,y.value),o.$superdoc.focus?.()})},Zi=(_e,ze)=>{if(te())return G();switch(_e){case"edit":P.value=ze?.commentText?.value??ze?.commentText??"",y.value=r.comment.commentId,r.floatingInstanceId&&_(r.floatingInstanceId),O.value=ze.commentId,s.setActiveComment(o.$superdoc,y.value),_t(()=>{ye(ze.commentId)});break;case"delete":u({superdoc:o.$superdoc,commentId:ze.commentId});break}},va=async _e=>{if(te())return G();if(ft.value&&an.value){const ze=await s.editCommentV2({superdoc:o.$superdoc,commentId:_e.commentId,text:P.value});return ze?.ok&&(O.value=null,d(o.$superdoc)),ze}O.value=null,_e.setText({text:P.value,superdoc:o.$superdoc}),d(o.$superdoc)},Qi=_e=>{if(te())return G();const ze=!!R.value,vt=_e.toLowerCase()==="internal";ze?R.value.isInternal=vt:r.comment.setIsInternal({isInternal:vt,superdoc:o.$superdoc})},hl=ke(()=>{const _e={};return(S.value||D.value||Pt.value)&&(_e.zIndex=50),_e}),Ti=_e=>typeof _e=="string"?new Date(_e).getTime():_e,ao=_e=>{O.value=null,Y.value=!1,l(o.$superdoc)},Ri=ke(()=>{const _e=o.$superdoc.users;return r.comment.isInternal===!0?_e.filter(ze=>ze.access?.role==="internal"):_e});return Nn(()=>{r.autoFocus&&_t(()=>Ke()),D.value&&_t(()=>{N.value?.focus?.()}),_t(()=>{n("ready",{commentId:r.floatingInstanceId??(r.comment.importedId!==void 0?r.comment.importedId:r.comment.commentId),elementRef:le}),Ft()})}),Lt(H,_e=>{_e&&_t(()=>{N.value?.focus?.()})},{immediate:!0}),Lt(O,_e=>{if(!_e||!S.value)return;const ze=me.value.find(vt=>vt.commentId===_e);!ze||ze.trackedChange||_t(()=>{ye(_e)})}),Lt(()=>k.value?.readOnly===!0,_e=>{_e&&(Y.value=!1,me.value.some(ze=>ze.commentId===O.value)&&(O.value=null),D.value&&l(o.$superdoc),_t(()=>n("resize")))},{immediate:!0}),Lt(hn,_e=>{_e&&(Y.value=!1,_t(()=>n("resize")))}),(_e,ze)=>{const vt=Y2("click-outside");return Us((ge(),Ae("div",{class:rn(["comments-dialog",{"is-active":S.value||D.value,"is-resolved":r.comment.resolvedTime}]),onClick:tn(Ke,["stop","prevent"]),style:yn(hl.value),ref_key:"commentDialogElement",ref:le,role:"dialog","data-sd-part":"comment-thread","data-editor-ui-surface":"","data-comment-instance-id":r.floatingInstanceId??"","data-comment-thread-id":r.comment.commentId??"","data-comment-position-key":r.comment.trackedChangeAnchorKey??"","data-comment-page-index":Number.isFinite(r.floatingPageIndex)?r.floatingPageIndex:""},[D.value?(ge(),Ae(Wt,{key:0},[De.value?(ge(),Ae("div",j7,[jt(__,{onClick:ze[0]||(ze[0]=tn(()=>{},["stop","prevent"])),class:"sd-internal-dropdown","is-disabled":!1,state:et(R).isInternal?"internal":"external",onSelect:Qi},null,8,["state"])])):ht("",!0),jt(a0,{config:et(k),comment:r.comment,"is-pending-input":!0},null,8,["config","comment"]),Me("div",U7,[jt(c0,{ref_key:"commentInput",ref:N,users:Ri.value,config:et(k),comment:r.comment,"include-header":!1},null,8,["users","config","comment"])]),Me("div",G7,[Me("button",{class:"sd-button reply-btn-cancel",onClick:tn(ao,["stop","prevent"])},"Cancel"),Me("button",{class:rn(["sd-button primary reply-btn-primary",{"sd-is-disabled":!je.value}]),onClick:tn(kt,["stop","prevent"]),disabled:!je.value}," Comment ",10,W7)])],64)):(ge(),Ae(Wt,{key:1},[ee.value?(ge(),Ae("div",K7,[Me("span",{class:"resolved-badge__icon",innerHTML:et(la).markDone},null,8,q7),Ni(" "+Bt(ee.value),1)])):ht("",!0),De.value?(ge(),Ae("div",Y7,[jt(__,{onClick:ze[1]||(ze[1]=tn(()=>{},["stop","prevent"])),class:"sd-internal-dropdown","is-disabled":Kt.value,state:e.comment.isInternal?"internal":"external",onSelect:Qi},null,8,["is-disabled","state"])])):ht("",!0),(ge(!0),Ae(Wt,null,rr(Ye.value,(ot,xn)=>(ge(),Ae("div",{key:ot.commentId,class:"conversation-item"},[jt(a0,{config:et(k),timestamp:Ti(ot.createdTime),comment:ot,"is-active":S.value,"resolve-disabled-reason":Yn(ot),"reject-disabled-reason":Nr(ot),"reopen-supported":ft.value&&!!an.value,"reopen-disabled-reason":io(),"write-disabled-reason":vo.value,onResolve:cr,onReject:so,onReopen:Qo,onOverflowSelect:Tn=>Zi(Tn,ot)},null,8,["config","timestamp","comment","is-active","resolve-disabled-reason","reject-disabled-reason","reopen-supported","reopen-disabled-reason","write-disabled-reason","onOverflowSelect"]),ot.trackedChange?(ge(),Ae("div",X7,[Me("div",{class:rn(["tracked-change",xn===0?Ct.value:void 0]),"data-track-change-semantic-color-key":ot.semanticColorKey??void 0,ref_for:!0,ref:xn===0?St:void 0},[ot.trackedChangeLabel?(ge(),Ae("div",Q7,[Me("span",J7,Bt(ot.trackedChangeLabel),1),ot.trackedChangeDetailLines&&ot.trackedChangeDetailLines.length?(ge(),Ae("div",$7,[(ge(!0),Ae(Wt,null,rr(ot.trackedChangeDetailLines,(Tn,_r)=>(ge(),Ae("div",{key:_r,class:"tracked-change-detail-line"},[Tn.excerpt?(ge(),Ae("span",eR,'"'+Bt(Tn.excerpt)+'"',1)):ht("",!0),Tn.excerpt?(ge(),Ae("span",tR," β ")):ht("",!0),Me("span",nR,Bt(Tn.label),1)]))),128))])):ht("",!0)])):ot.trackedChangeDisplayType==="hyperlinkAdded"?(ge(),Ae("div",rR,[ze[2]||(ze[2]=Me("span",{class:"change-type"},"Added hyperlink ",-1)),Me("span",oR,'"'+Bt(ot.trackedChangeText)+'"',1)])):ot.trackedChangeDisplayType==="hyperlinkModified"?(ge(),Ae("div",iR,[ze[3]||(ze[3]=Me("span",{class:"change-type"},"Changed hyperlink to ",-1)),Me("span",sR,'"'+Bt(ot.trackedChangeText)+'"',1)])):ot.trackedChangeDisplayType==="paragraphSplit"?(ge(),Ae("div",aR,[...ze[4]||(ze[4]=[Me("span",{class:"change-type"},"Added new line",-1)])])):ot.trackedChangeDisplayType==="tableInsert"?(ge(),Ae("div",lR,[...ze[5]||(ze[5]=[Me("span",{class:"change-type"},"Added table",-1)])])):ot.trackedChangeDisplayType==="tableDelete"?(ge(),Ae("div",cR,[...ze[6]||(ze[6]=[Me("span",{class:"change-type"},"Deleted table",-1)])])):ot.trackedChangeType==="trackFormat"?(ge(),Ae("div",uR,[ze[7]||(ze[7]=Me("span",{class:"change-type"},"Format: ",-1)),Me("span",dR,Bt(ot.trackedChangeText),1)])):ot.trackedChangeType==="both"?(ge(),Ae("div",fR,[ze[8]||(ze[8]=Me("span",{class:"change-type"},"Replaced ",-1)),Me("span",hR,'"'+Bt(ot.deletedText)+'"',1),ze[9]||(ze[9]=Me("span",{class:"change-type"}," with ",-1)),Me("span",pR,'"'+Bt(ot.trackedChangeText)+'"',1)])):ot.deletedText?(ge(),Ae("div",mR,[ze[10]||(ze[10]=Me("span",{class:"change-type"},"Deleted ",-1)),Me("span",gR,'"'+Bt(ot.deletedText)+'"',1)])):ot.trackedChangeText?(ge(),Ae("div",vR,[ze[11]||(ze[11]=Me("span",{class:"change-type"},"Added ",-1)),Me("span",yR,'"'+Bt(ot.trackedChangeText)+'"',1)])):ht("",!0),ot.trackedChangeImagePreview?.src?(ge(),Ae("div",{key:10,class:"tracked-change-image-preview","data-track-change-image-preview-role":ot.trackedChangeImagePreview.role??void 0},[Me("img",{class:"tracked-change-image-preview__image",src:ot.trackedChangeImagePreview.src,alt:ot.trackedChangeImagePreview.alt||"Tracked image preview",style:yn(X(ot.trackedChangeImagePreview)),loading:"lazy",decoding:"async"},null,12,wR)],8,bR)):ht("",!0)],10,Z7),He.value&&it.value&&xn===0?(ge(),Ae("div",{key:0,class:"show-more-toggle",onClick:tn(Yt,["stop","prevent"])}," Show more ")):ht("",!0),Ce.value&&it.value&&xn===0?(ge(),Ae("div",{key:1,class:"show-more-toggle",onClick:tn(Yt,["stop","prevent"])}," Show less ")):ht("",!0)])):ht("",!0),ot.trackedChange?ht("",!0):(ge(),Ae("div",CR,[!et(j)&&!Sn.value(ot)?(ge(),Ae("div",{key:0,class:rn(["comment",xn===0?Ct.value:void 0]),ref_for:!0,ref:xn===0?St:void 0,innerHTML:ot.commentText},null,10,_R)):et(j)&&!Sn.value(ot)?(ge(),Ae("div",SR,Bt(et(V)[ot.importedId!==void 0?ot.importedId:ot.commentId]?.bounds),1)):(ge(),Ae("div",kR,[Me("div",AR,[jt(c0,{ref_for:!0,ref:pe(ot.commentId),users:Ri.value,config:et(k),"include-header":!1,comment:ot},null,8,["users","config","comment"])]),Me("div",IR,[Me("button",{class:"sd-button reply-btn-cancel",onClick:tn(Tn=>ao(ot),["stop","prevent"])},"Cancel",8,ER),Me("button",{class:rn(["sd-button primary reply-btn-primary",{"sd-is-disabled":!je.value||hn.value}]),onClick:tn(Tn=>va(ot),["stop","prevent"]),disabled:!je.value||hn.value,"data-disabled-reason":hn.value?cn.value?.reason??null:null}," Update ",10,xR)])])),He.value&&it.value&&xn===0&&!Sn.value(ot)?(ge(),Ae("div",{key:3,class:"show-more-toggle",onClick:tn(Yt,["stop","prevent"])}," Show more ")):ht("",!0),Ce.value&&it.value&&xn===0&&!Sn.value(ot)?(ge(),Ae("div",{key:4,class:"show-more-toggle",onClick:tn(Yt,["stop","prevent"])}," Show less ")):ht("",!0)])),Qt.value&&xn===0?(ge(),Ae(Wt,{key:2},[ze[12]||(ze[12]=Me("div",{class:"comment-separator"},null,-1)),Me("div",{class:"collapsed-replies",onClick:tn(wn,["stop","prevent"])},[Me("div",TR,[(ge(!0),Ae(Wt,null,rr(Ot.value,Tn=>(ge(),dn(S_,{key:Tn.email||Tn.name,user:Tn,class:"mini-avatar"},null,8,["user"]))),128))]),Me("span",null,Bt(Et.value)+" more "+Bt(Et.value===1?"reply":"replies"),1)])],64)):ht("",!0),U.value(xn)?(ge(),Ae("div",RR)):ht("",!0)]))),128)),z.value?(ge(),Ae("div",MR,[Me("span",LR,Bt(xi.value),1),Me("button",{type:"button",class:"sd-button tracked-change-decision-alert__retry",onClick:tn(Is,["stop","prevent"])}," Retry ")])):ht("",!0),H.value&&!et(k).readOnly?(ge(),Ae(Wt,{key:3},[Y.value?(ge(),Ae("div",DR,[Me("div",OR,[jt(c0,{ref_key:"commentInput",ref:N,users:Ri.value,config:et(k),comment:r.comment,"include-header":!1},null,8,["users","config","comment"])]),Me("div",FR,[Me("button",{class:"sd-button reply-btn-cancel",onClick:tn(ao,["stop","prevent"])},"Cancel"),Me("button",{class:rn(["sd-button primary reply-btn-primary",{"sd-is-disabled":!je.value||hn.value||K.value}]),onClick:tn(kt,["stop","prevent"]),disabled:!je.value||hn.value||K.value,"data-disabled-reason":oo.value}," Reply ",10,NR)])])):(ge(),Ae("button",{key:0,type:"button",class:rn(["reply-pill",{"sd-is-disabled":hn.value}]),onClick:tn(be,["stop","prevent"]),disabled:hn.value,"data-disabled-reason":hn.value?cn.value?.reason??null:null}," Reply or add others with @ ",10,PR))],64)):ht("",!0)],64))],14,H7)),[[vt,pt]])}}},Pp=fn(BR,[["__scopeId","data-v-f26decd0"]]);xt(),gn();var zR={class:"comments-list"},VR={key:0},HR=["data-comment-instance-id","data-comment-thread-id","data-comment-position-key","data-comment-page-index"],jR={key:1},UR="headerFooterPart",GR={__name:"commentsList",props:{showMainComments:{type:Boolean,default:!0},showResolvedComments:{type:Boolean,default:!0}},setup(e){const t=e,n=aa(),r=pg(n,"isCommentsListVisible"),o=ke(()=>n.getGroupedComments),i=ke(()=>n.getFloatingCommentInstances),{activeComment:s,activeFloatingCommentInstanceId:a}=Js(n),l=m=>{const p=i.value.filter(v=>v?.comment?.commentId===m?.commentId);return p.length<2?[]:m?.trackedChange?m?.trackedChangeStory?.storyType!==UR?[]:p:[]},u=m=>!m?.comment?.commentId||s.value!==m.comment.commentId?!1:a.value==null?m.isPrimary===!0:String(a.value)===String(m.id),c=m=>{const p=l(m);return p.length?p.map(v=>({id:v.id,comment:m,floatingInstanceId:String(v.id),floatingPageIndex:v.pageIndex,floatingPositionEntry:v.positionEntry??null,isFloatingInstanceActive:u(v)})):[{id:m.commentId,comment:m,floatingInstanceId:null,floatingPageIndex:null,floatingPositionEntry:null,isFloatingInstanceActive:void 0}]},d=ke(()=>o.value.parentComments.flatMap(m=>c(m))),h=ke(()=>t.showResolvedComments&&o.value?.resolvedComments?.length>0);return Nn(()=>{r.value=!0}),or(()=>{r.value=!1}),(m,p)=>(ge(),Ae("div",zR,[e.showMainComments?(ge(),Ae("div",VR,[(ge(!0),Ae(Wt,null,rr(d.value,v=>(ge(),Ae("div",{key:v.id,class:"comment-item","data-comment-instance-id":v.floatingInstanceId??"","data-comment-thread-id":v.comment.commentId??"","data-comment-position-key":v.comment.trackedChangeAnchorKey??"","data-comment-page-index":Number.isFinite(v.floatingPageIndex)?v.floatingPageIndex:""},[jt(Pp,{comment:v.comment,"floating-instance-id":v.floatingInstanceId,"floating-page-index":v.floatingPageIndex,"floating-position-entry":v.floatingPositionEntry,"is-floating-instance-active":v.isFloatingInstanceActive},null,8,["comment","floating-instance-id","floating-page-index","floating-position-entry","is-floating-instance-active"])],8,HR))),128))])):ht("",!0),h.value?(ge(),Ae("div",jR,[p[0]||(p[0]=Me("div",{class:"comment-title"},"Resolved",-1)),(ge(!0),Ae(Wt,null,rr(o.value.resolvedComments,v=>(ge(),Ae("div",{key:v.commentId,class:"comment-item"},[jt(Pp,{comment:v},null,8,["comment"])]))),128))])):ht("",!0)]))}},WR=fn(GR,[["__scopeId","data-v-e89dbc33"]]);xt();var KR=class extends Ym.default{element;config={comments:[],element:null,commentsStore:null};constructor(e,t){super(),this.config={...this.config,...e},this.element=this.config.element,this.app=null,this.superdoc=t,this.open()}createVueApp(){this.app=Zl(WR);const e=this.superdoc?.app?._context?.provides;e&&this.app?._context?.provides&&Object.setPrototypeOf(this.app._context.provides,e),this.superdoc?.pinia&&(Wd(this.superdoc.pinia),this.app.use(this.superdoc.pinia),this.app.config.globalProperties.$pinia=this.superdoc.pinia),this.app.directive("click-outside",Qv),this.app.config.globalProperties.$superdoc=this.superdoc,!this.element&&this.config.selector&&(this.element=document.getElementById(this.config.selector)),this.container=this.app.mount(this.element)}close(){this.app&&(this.app.unmount(),this.app=null,this.container=null,this.element=null)}open(){this.app||this.createVueApp()}},qR,$a,u0=Ir((()=>{qR=2,$a=96/72}));xt(),u0();var YR=96,XR=".superdoc__right-sidebar",ZR=".sd-pdf-viewer-page";const d0=Object.freeze({min:10,max:100,padding:0}),I_=e=>{const t=e&&typeof e=="object"?e:{},n=(s,a)=>typeof s=="number"&&Number.isFinite(s)&&s>0?s:a,r=n(t.min,d0.min),o=n(t.max,d0.max),i=typeof t.padding=="number"&&Number.isFinite(t.padding)&&t.padding>=0?t.padding:d0.padding;return{min:Math.min(r,o),max:Math.max(r,o),padding:i}},E_=(e,t)=>!(e>0)||!(t>0)?null:Math.round(e/t*100),QR=(e,t,n)=>{const r=E_(e-n.padding,t);return r===null?null:Math.max(1,Math.round(Math.min(n.max,Math.max(n.min,r))))},JR=(e,t,n)=>e>0?Number.isFinite(t)&&t>0?e/t*$a:n>0?e/n:e:null;function $R({getSuperdoc:e,superdocContainerWidth:t,isReady:n,activeZoom:r,zoomMode:o,viewportMetrics:i,showCommentsSidebar:s,rightSidebarRef:a,superdocRoot:l,documents:u}){const c=b=>{if(!b)return null;let T=0;try{const j=b.getPages?.();if(Array.isArray(j))for(const O of j){const V=O?.size?.w;typeof V=="number"&&Number.isFinite(V)&&V>T&&(T=V)}}catch{T=0}if(T>0)return T;let R=null;try{R=b.getPageStyles?.()??null}catch{R=null}const P=R?.pageSize?.width;return typeof P=="number"&&Number.isFinite(P)&&P>0?P*YR:null},d=()=>{if(!(u?.value??[]).some(R=>R?.type==="application/pdf"))return null;const b=l.value;if(!b?.querySelectorAll)return null;let T=0;for(const R of b.querySelectorAll(ZR)){const P=Number(R.clientWidth)||Number(R.getBoundingClientRect?.().width)||0;let j=NaN;typeof window<"u"&&typeof window.getComputedStyle=="function"&&(j=Number.parseFloat(window.getComputedStyle(R).getPropertyValue("--scale-factor")));const O=(r.value??100)/100,V=JR(P,j,O);V!==null&&V>T&&(T=V)}return T>0?T:null},h=()=>{const b=e();if(!b)return null;const T=[],R=u?.value??[];for(const j of R){if(j?.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")continue;const O=c(j.getEditor?.());O!==null&&T.push(O)}if(T.length===0){const j=c(b.activeEditor);j!==null&&T.push(j)}const P=d();if(P!==null&&T.push(P),T.length>0)return Math.max(...T);if(b.activeEditor){const j=l.value?.querySelector?.(".superdoc__document"),O=Number(j?.clientWidth)||Number(j?.getBoundingClientRect?.().width)||0;if(O>0){const V=(r.value??100)/100;return V>0?O/V:O}}return null},m=()=>{if(!s?.value)return 0;const b=a?.value??l.value?.querySelector?.(XR),T=Number(b?.offsetWidth)||Number(b?.getBoundingClientRect?.().width)||0;return T>0?T:0},p=(b,T)=>{const R=I_(b.config?.zoom?.fitWidth),P=QR(T.availableWidth,T.documentWidth,R);P!==null&&P!==r.value&&(r.value=P,b.emit("zoomChange",{zoom:P,mode:"fit-width"}))},v=()=>{const b=e();if(!b)return;const T=t.value;if(!(T>0)||!n.value)return;const R=h();if(R===null)return;const P=T-m(),j=E_(P,R);if(j===null)return;const O=Object.freeze({availableWidth:P,documentWidth:R,fitZoom:j}),V=i.value;(!V||V.availableWidth!==P||V.documentWidth!==R||V.fitZoom!==j)&&(i.value=O),(!V||V.fitZoom!==j||Math.round(V.documentWidth)!==Math.round(R))&&b.emit("viewport-change",O),o.value==="fit-width"&&p(b,O)};Lt(t,()=>{_t(()=>v())}),Lt(n,b=>{b&&v()}),Lt(o,b=>{b==="fit-width"&&v()}),s&&Lt(s,()=>{_t(()=>v())});const _=()=>{_t(()=>v())},C=()=>{_t(()=>v())},k=()=>{_t(()=>v())},y=e();return y?.on?.("editorCreate",_),y?.on?.("pagination-update",C),y?.on?.("pdf:document-ready",k),or(()=>{y?.off?.("editorCreate",_),y?.off?.("pagination-update",C),y?.off?.("pdf:document-ready",k)}),{evaluateViewport:v}}const e9=e=>!!e?.trackedChange,t9=e=>e,n9=(e,t,n,r=e)=>!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)?!1:(Number.isFinite(r)?r:e)<t||e>n,r9=({comment:e,anchorTop:t,anchorBottom:n,viewportTop:r,viewportBottom:o})=>e9(e)&&n9(t,r,o,n),o9=({comment:e,anchorTop:t,anchorBottom:n,cardHeight:r,viewportTop:o,viewportBottom:i})=>!r9({comment:e,anchorTop:t,anchorBottom:n,viewportTop:o,viewportBottom:i})||!Number.isFinite(r)?null:(Number.isFinite(n)?n:t)<o?Math.min(t,o-r-1):t,i9=({id:e,visibleIds:t,activeCommentInstanceId:n})=>e?!!(e==="pending"||n!=null&&String(e)===String(n)||t?.has?.(e)):!1,x_=({previousIds:e,currentIds:t,removedId:n})=>{if(!Array.isArray(e)||!(t instanceof Set)||!n)return null;const r=e.indexOf(n);if(r<0)return null;for(let o=r+1;o<e.length;o+=1){const i=e[o];if(t.has(i))return i}for(let o=r-1;o>=0;o-=1){const i=e[o];if(t.has(i))return i}return null};xt(),gn();var s9=["data-comment-id","data-comment-instance-id","data-comment-thread-id","data-comment-position-key","data-comment-page-index"],tc={},a9={__name:"FloatingComments",props:{currentDocument:{type:Object,required:!0},parent:{type:Object,required:!0}},setup(e){const r=(De,je,Ke)=>{if(je>=0){De[je].top=De[je].anchorTop;let pt=De[je].top+De[je].height+Ke;for(let ft=je+1;ft<De.length;ft++)De[ft].top=Math.max(De[ft].anchorTop,pt),pt=De[ft].top+De[ft].height+Ke;pt=De[je].top-Ke;for(let ft=je-1;ft>=0;ft--){const an=pt-De[ft].height;De[ft].top=Math.min(De[ft].anchorTop,an),pt=De[ft].top-Ke}const kt=Math.min(...De.map(ft=>ft.top));if(kt<0){const ft=Math.abs(kt);for(const an of De)an.top+=ft}}else for(let pt=1;pt<De.length;pt++){const kt=De[pt-1],ft=kt.top+kt.height+Ke;De[pt].top<ft&&(De[pt].top=ft)}},o=e,i=hu(),s=aa(),{clearInstantSidebarAlignment:a}=s,{activeComment:l,activeFloatingCommentInstanceId:u,editorCommentPositions:c,pendingComment:d,editingCommentId:h,instantSidebarAlignmentTargetY:m,instantSidebarAlignmentThreadId:p,instantSidebarAlignmentInstanceId:v}=Js(s),{activeZoom:_}=Js(i),C=ke(()=>{const De=s.getFloatingCommentInstances;if(!Array.isArray(De))return[];const je=o.currentDocument?.id;return je==null?De:De.filter(Ke=>s.belongsToDocument(Ke.comment,String(je),{allowSingleDocumentMismatch:!0}))}),k=ne(null),y=ne(0),b=ne(0),T=ne(!1),R=ne(null),P=ne(0),j=De=>{const je=d.value?.commentId;return je?typeof De=="object"?De?.commentId===je:De===je||De==="pending":!1},O=De=>De?.commentId??De?.importedId??null,V=ke(()=>{const De=new Map,je=new Map;for(const Ke of C.value){Ke?.id!=null&&De.set(String(Ke.id),Ke);const pt=O(Ke?.comment);if(pt==null)continue;const kt=String(pt),ft=je.get(kt)??[];ft.push(Ke),je.set(kt,ft)}return{byId:De,byThreadId:je}}),Q=(De,je=null)=>{if(De==null)return null;const Ke=String(De),pt=V.value.byThreadId.get(Ke)??[];if(!pt.length)return null;if(je!=null){const kt=pt.find(ft=>String(ft.id)===String(je));if(kt)return kt.id}return pt.find(kt=>kt.isPrimary)?.id??pt[0]?.id??null},F=ke(()=>l.value?Q(l.value,u.value):null),N=De=>{if(typeof De=="number")return Number.isFinite(De)?De:null;if(typeof De!="string"||De.trim()==="")return null;const je=Number(De);return Number.isFinite(je)?je:null},x=ne({...tc}),z=ne(new Set),J=ne({});let X=null;const ae=new Set;let pe=null;const Fe=()=>{pe==null&&(pe=requestAnimationFrame(()=>{pe=null,P.value+=1}))},fe=De=>{if(o.currentDocument.type==="application/pdf"){const je=(_.value??100)/100,Ke=N(De?.comment?.selection?.selectionBounds?.top);return Ke==null?null:Ke*je}return De?.positionEntry?.bounds?.top},ye=(De,je)=>{if(o.currentDocument.type==="application/pdf"){const pt=(_.value??100)/100,kt=N(De?.comment?.selection?.selectionBounds?.bottom);return kt!=null?kt*pt:je}const Ke=De?.positionEntry?.bounds?.bottom;return Number.isFinite(Ke)?Ke:je},le=ke(()=>{const De=[];for(const je of C.value){const Ke=je?.id,pt=O(je?.comment),kt=fe(je);if(Ke==null||pt==null||!Number.isFinite(kt))continue;const ft=t9(kt,je.comment);De.push({id:Ke,threadId:pt,instance:je,top:ft,anchorBottom:ye(je,ft)})}return De}),Se=()=>{const De=c.value.pending;if(typeof De?.bounds?.top=="number"&&!isNaN(De.bounds.top))return De.bounds.top;const je=o.currentDocument.type==="application/pdf"?(_.value??100)/100:1,Ke=N(d.value?.selection?.selectionBounds?.top);return Ke==null?null:Ke*je},re=De=>i9({id:De?.id,visibleIds:z.value,activeCommentInstanceId:F.value,comment:De?.commentRef}),xe=()=>{const De=k.value;if(!De)return null;const je=De.getBoundingClientRect();if(!Number.isFinite(je.top)||!Number.isFinite(window.innerHeight))return null;let Ke=0,pt=window.innerHeight;for(let ft=De.parentElement;ft;ft=ft.parentElement){const an=window.getComputedStyle(ft).overflowY;if(!["auto","scroll","hidden","clip"].includes(an))continue;const qt=ft.getBoundingClientRect();!Number.isFinite(qt.top)||!Number.isFinite(qt.bottom)||(Ke=Math.max(Ke,qt.top),pt=Math.min(pt,qt.bottom))}if(pt<=Ke)return null;const kt=o.parent?.getBoundingClientRect?.();if(kt&&Number.isFinite(kt.top)&&Number.isFinite(kt.bottom)){const ft=Math.max(Ke,kt.top),an=Math.min(pt,kt.bottom);an>ft&&(Ke=ft,pt=an)}return{top:Ke-je.top,bottom:pt-je.top}},$e=ke(()=>p.value?Q(p.value,v.value):null),st=ke(()=>{P.value;const De=le.value,je=d.value&&d.value.fileId===o.currentDocument.id;if(!De.length&&!C.value.length&&!je)return[];const Ke=[],pt=xe()??{top:0,bottom:Math.max(0,o.parent?.clientHeight||window.innerHeight||0)},kt=pt.top-600,ft=pt.bottom+600,an=je?"pending":F.value,qt=new Set,cn=({id:Jt,threadId:Yn,instance:Nr,top:io,anchorBottom:vo,hasAnchorGeometry:$t})=>{const Bn=String(Jt);qt.has(Bn)||(qt.add(Bn),Ke.push({id:Jt,threadId:Yn,pageIndex:Nr?.pageIndex??null,anchorTop:io,anchorBottom:vo,hasAnchorGeometry:$t,top:io,height:x.value[Jt]||110,commentRef:Nr.comment,instanceRef:Nr}))};for(const Jt of De){const{id:Yn,threadId:Nr,instance:io,top:vo,anchorBottom:$t}=Jt,Bn=an!=null&&String(Yn)===String(an),xi=h.value!=null&&String(Nr)===String(h.value);!Bn&&!xi&&($t<kt||vo>ft)||cn({id:Yn,threadId:Nr,instance:io,top:vo,anchorBottom:$t,hasAnchorGeometry:!0})}const hn=[];if(an&&an!=="pending"){const Jt=V.value.byId.get(String(an));Jt&&hn.push(Jt)}if(h.value!=null){const Jt=V.value.byThreadId.get(String(h.value))??[],Yn=Jt.find(Nr=>Nr.isPrimary)??Jt[0];Yn&&hn.push(Yn)}for(const Jt of hn){const Yn=Jt.id,Nr=O(Jt.comment);Yn==null||Nr==null||qt.has(String(Yn))||cn({id:Yn,threadId:Nr,instance:Jt,top:pt.top,anchorBottom:pt.top,hasAnchorGeometry:!1})}if(je){const Jt=Se();typeof Jt=="number"&&!isNaN(Jt)&&Ke.push({id:"pending",anchorTop:Jt,anchorBottom:Jt,hasAnchorGeometry:!0,top:Jt,height:x.value.pending||110,commentRef:d.value})}Ke.sort((Jt,Yn)=>Jt.anchorTop-Yn.anchorTop);const oo=[];for(const Jt of Ke){const Yn=Jt.hasAnchorGeometry?o9({comment:Jt.commentRef,anchorTop:Jt.anchorTop,anchorBottom:Jt.anchorBottom,cardHeight:Jt.height,viewportTop:pt.top,viewportBottom:pt.bottom}):null;Yn==null?oo.push(Jt):Jt.top=Yn}return r(oo,an?oo.findIndex(Jt=>Jt.id===an):-1,15),Ke}),At=ke(()=>(P.value,Math.max(0,o.parent?.clientHeight||0,o.parent?.scrollHeight||0))),Ee=()=>{X&&X.disconnect(),X=new IntersectionObserver(De=>{const je=new Set(z.value);for(const Ke of De){const pt=Ke.target.dataset.commentId;pt&&(Ke.isIntersecting?je.add(pt):je.delete(pt))}z.value=je},{rootMargin:"600px 0px 600px 0px"})},Ge=()=>{if(!X)return;const De=new Set;for(const je of st.value){const Ke=J.value[je.id];Ke&&(De.add(Ke),ae.has(Ke)||(X.observe(Ke),ae.add(Ke)))}for(const je of ae)De.has(je)||(X.unobserve(je),ae.delete(je))},qe=(De,je)=>{je<=0||je===x.value[De]||(tc[De]=je,x.value={...x.value,[De]:je})},Z=De=>{if(!De)return;const{elementRef:je,commentId:Ke}=De;je&&_t(()=>{const pt=je.value?.getBoundingClientRect();!pt||pt.height<=0||Ke&&qe(Ke,pt.height)})},S=De=>{const je=De?.id;je&&_t(()=>{const Ke=J.value[je];if(!Ke)return;const pt=Ke.querySelector(".comments-dialog");if(!pt)return;qe(je,pt.getBoundingClientRect().height);const kt=je===F.value,ft=je==="pending",an=!!h.value&&!!l.value&&De?.threadId!=null&&String(De.threadId)===String(l.value);!kt&&!ft&&!an||(St(st.value.map(qt=>qt.id)),sn(()=>st.value.map(qt=>qt.id)))})},ee=De=>{!De&&R.value!=null||(T.value=De)},D=(De,je,Ke)=>{if(!Number.isFinite(je)){Ke?.(!1);return}const pt=J.value[De];if(!pt){Ke?.(!1);return}const kt=pt.getBoundingClientRect().top;b.value+=je-kt,Ke?.(!0)},U=(De,je)=>{if(je)J.value[De]=je,X&&!ae.has(je)&&(X.observe(je),ae.add(je));else{const Ke=J.value[De];Ke&&X&&(X.unobserve(Ke),ae.delete(Ke)),delete J.value[De]}};let H=[],G=null,te=[],Y=null,K=!1,be=0,me=null,Ce=null,Pe=null,it=null;const He=()=>{Pe=null,it=null,R.value=null,ee(!1)},Ct=De=>{if(!Pe)return;const je=(De?.target instanceof Element?De.target:null)?.closest?.("[data-comment-action]"),Ke=je?.getAttribute?.("data-comment-action");(Ke==="resolve"||Ke==="reject")&&k.value?.contains?.(je)||He()},Yt=()=>{H.forEach(clearTimeout),H=[]},St=De=>{for(const je of De.filter(Boolean)){const Ke=J.value[je];if(!Ke)continue;const pt=Ke.querySelector(".comments-dialog");pt&&qe(je,pt.getBoundingClientRect().height)}},Ft=50,Nt=350,sn=De=>{Yt();const je=typeof De=="function"?De:()=>De;H.push(setTimeout(()=>St(je()),Ft)),H.push(setTimeout(()=>St(je()),Nt))},_n=()=>{a(),requestAnimationFrame(()=>{ee(!1)})},Qt=(De,je)=>{!De||!Number.isFinite(je)||(ee(!0),_t(()=>{St([De]),D(De,je,()=>{_n()})}))},Ye=()=>{Y=null,be+=1,me!=null&&(cancelAnimationFrame(me),me=null),ee(!1)},Et=()=>{if(!Y||K)return;K=!0;const De=be;me!=null&&(cancelAnimationFrame(me),me=null),ee(!0),_t(()=>{if(K=!1,De!==be){Et();return}const{key:je,targetClientY:Ke}=Y;St([je]),D(je,Ke,pt=>{if(De===be){if(!pt){ee(!1);return}me=requestAnimationFrame(()=>{me=null,De===be&&ee(!1)})}})})},Ot=(De,je)=>{const Ke=x_({previousIds:te,currentIds:je,removedId:De}),pt=(Ke?J.value[Ke]:null)?.getBoundingClientRect?.().top;return!Ke||!Number.isFinite(pt)?(Ye(),!1):(Y={key:Ke,targetClientY:pt},be+=1,Et(),!0)},wn=De=>{const je=De?.target?.closest?.("[data-comment-action]"),Ke=je?.getAttribute?.("data-comment-action");if(Ke!=="resolve"&&Ke!=="reject"||(He(),je.getAttribute?.("aria-disabled")==="true"))return;const pt=je.closest?.("[data-comment-id]")?.getAttribute?.("data-comment-id");if(!pt||String(F.value??"")===String(pt))return;const kt=st.value.filter(qt=>qt.commentRef?.trackedChange).map((qt,cn)=>({id:qt.id,index:cn,top:qt.top})).filter(qt=>Number.isFinite(qt.top)).sort((qt,cn)=>qt.top-cn.top||qt.index-cn.index).map(qt=>qt.id),ft=x_({previousIds:kt,currentIds:new Set(kt),removedId:pt}),an=(ft?J.value[ft]:null)?.getBoundingClientRect?.().top;!ft||!Number.isFinite(an)||(Pe={removedKey:pt,targetKey:ft,targetClientY:an,applied:!1},it=pt,R.value=ft,ee(!0))};Lt(F,(De,je)=>{if(Yt(),!(Pe!=null&&it!=null&&[De,je].some(kt=>kt!=null&&String(kt)===String(it)))){if(it=null,De)He(),Ye();else if(je){const kt=new Set(st.value.map(ft=>ft.id));kt.has(je)?Ye():Ot(je,kt)}}const Ke=[De,je],pt=De&&De===$e.value&&Number.isFinite(m.value);_t(()=>{if(pt){St(Ke);return}sn(Ke)})}),Lt([F,$e,m],([De,je,Ke])=>{!De||!je||De!==je||!Number.isFinite(Ke)||Qt(De,Ke)}),Lt(h,()=>{Yt(),_t(()=>{sn(()=>st.value.map(De=>De.id))})}),Lt(l,()=>{if(G&&clearTimeout(G),!l.value){if(a(),Y){Et();return}ee(!1),b.value=0;return}if(!(j(l.value)?d.value:s.getComment(l.value)))return;const De=j(l.value)?"pending":F.value;if(De){if(De===$e.value&&Number.isFinite(m.value)){ee(!0);return}_t(()=>{G=setTimeout(()=>{const Ke=J.value[De];if(!Ke)return;const pt=o.parent?.getBoundingClientRect?.();if(!pt)return;const kt=st.value.find(cn=>cn.id===De),ft=De==="pending"?Se():kt?.anchorTop;if(typeof ft!="number"||isNaN(ft))return;const an=Ke.getBoundingClientRect().top,qt=pt.top+ft;b.value+=qt-an},400)})}}),Lt(_,()=>{if(o.currentDocument.type==="application/pdf"){for(const De in tc)delete tc[De];x.value={},y.value+=1}});let Kt=new Set,Sn=null,Pt=null;return Lt(st,De=>{const je=F.value?De.find($t=>$t.id===F.value):null,Ke=typeof je?.anchorTop=="number"&&Number.isFinite(je.anchorTop)?je.anchorTop:null,pt=Ke!=null&&Sn!=null&&Math.abs(Ke-Sn)>1,kt=typeof je?.top=="number"&&Number.isFinite(je.top)?je.top:null,ft=kt!=null&&Pt!=null&&Math.abs(kt-Pt)>1;pt&&b.value!==0&&!Number.isFinite(m.value)?(b.value=0,ee(!1)):ft&&b.value!==0&&!Number.isFinite(m.value)&&!Y&&(ee(!0),b.value+=Pt-kt,Ce!=null&&cancelAnimationFrame(Ce),Ce=requestAnimationFrame(()=>{Ce=null,!Y&&!Number.isFinite(m.value)&&ee(!1)})),Sn=Ke,Pt=kt;const an=De.map($t=>$t.id),qt=new Set(an);if(Pe&&!Pe.applied&&!qt.has(Pe.removedKey)){const{targetKey:$t,targetClientY:Bn}=Pe;Pe.applied=!0,qt.has($t)&&Number.isFinite(Bn)?(Y={key:$t,targetClientY:Bn},be+=1,Et()):He()}if(Pe?.applied&&!qt.has(Pe.targetKey)&&He(),Y&&!qt.has(Y.key)){const $t=Y.key;Ot($t,qt)||(ee(!1),b.value=0)}const cn=new Set(z.value);let hn=!1,oo=-1/0,Jt=1/0;const Yn=k.value;if(Yn){const $t=Yn.getBoundingClientRect();oo=-$t.top-600,Jt=-$t.top+window.innerHeight+600}const Nr=new Map(De.map($t=>[$t.id,$t]));for(const $t of qt)if(!cn.has($t)){const Bn=Nr.get($t);(!Bn||Bn.top>=oo&&Bn.top<=Jt)&&(cn.add($t),hn=!0)}for(const $t of cn)qt.has($t)||(cn.delete($t),hn=!0);hn&&(z.value=cn);for(const $t of Kt)qt.has($t)||delete tc[$t];const io=Kt.size!==qt.size||[...Kt].some($t=>!qt.has($t)),vo=te.length!==an.length||te.some(($t,Bn)=>$t!==an[Bn]);if(io){const $t={};for(const Bn of qt)tc[Bn]&&($t[Bn]=tc[Bn]);x.value=$t,_t(()=>{for(const Bn of De){const xi=J.value[Bn.id];if(!xi)continue;const Is=xi.querySelector(".comments-dialog");Is&&qe(Bn.id,Is.getBoundingClientRect().height)}})}Y&&(io||vo)&&Et(),Kt=qt,_t(()=>{te=an,Ge()})}),Nn(()=>{Ee(),o.parent?.addEventListener?.("scroll",Fe,{passive:!0}),window.addEventListener("resize",Fe,{passive:!0}),document.addEventListener("pointerdown",Ct,!0),_t(Ge)}),or(()=>{Yt(),G&&clearTimeout(G),He(),Ye(),Ce!=null&&(cancelAnimationFrame(Ce),Ce=null),o.parent?.removeEventListener?.("scroll",Fe),window.removeEventListener("resize",Fe),document.removeEventListener("pointerdown",Ct,!0),pe!=null&&(cancelAnimationFrame(pe),pe=null),X&&(X.disconnect(),X=null,ae.clear())}),(De,je)=>(ge(),Ae("div",{class:"section-wrapper",ref_key:"floatingCommentsContainer",ref:k,onClickCapture:wn,style:yn({minHeight:At.value+"px",transition:T.value?"none":void 0})},[Me("div",{class:"sidebar-container",style:yn({transform:`translateY(${b.value}px)`,transition:T.value?"none":void 0})},[(ge(!0),Ae(Wt,null,rr(st.value,Ke=>(ge(),Ae("div",{key:Ke.id,ref_for:!0,ref:pt=>U(Ke.id,pt),"data-comment-id":Ke.id,"data-comment-instance-id":Ke.id,"data-comment-thread-id":Ke.threadId,"data-comment-position-key":Ke.instanceRef?.positionKey??"","data-comment-page-index":Ke.pageIndex??"",class:rn([{"is-direct-decision-continuity-target":Ke.id===R.value},"comment-placeholder"]),style:yn({top:Ke.top+"px",height:Ke.height+"px",transition:T.value?"none":void 0})},[re(Ke)?(ge(),dn(Pp,{key:Ke.id+y.value,onReady:Z,onResize:pt=>S(Ke),class:"floating-comment",parent:e.parent,comment:Ke.commentRef,"floating-instance-id":Ke.id,"floating-page-index":Ke.pageIndex,"floating-position-entry":Ke.instanceRef?.positionEntry??null,"is-floating-instance-active":Ke.id===F.value},null,8,["onResize","parent","comment","floating-instance-id","floating-page-index","floating-position-entry","is-floating-instance-active"])):ht("",!0)],14,s9))),128))],4)],36))}},l9=fn(a9,[["__scopeId","data-v-a0a841ce"]]);xt(),gn();var c9={class:"superdoc__pdf-comments-layer pdf-comments-layer","aria-hidden":"false"},u9=["data-id","data-comment-id","data-page-number","onClick","onKeydown"],d9="pdf",f9="#078383",h9="#B1124B",p9={__name:"PdfCommentsLayer",emits:["anchor-activate"],setup(e,{emit:t}){const n=t,r=aa(),o=hu(),{activeComment:i}=Js(r),{documents:s,activeZoom:a}=Js(o),{proxy:l}=ir(),u=y=>typeof y=="number"?Number.isFinite(y):typeof y=="string"&&y.trim()!==""?Number.isFinite(Number(y)):!1,c=y=>!!y&&u(y.top)&&u(y.left)&&u(y.right)&&u(y.bottom),d=ke(()=>{const y=Array.isArray(s.value)?s.value:[];return new Set(y.filter(b=>b?.type===Ql).map(b=>String(b.id)))}),h=y=>{const b=y?.fileId??y?.documentId??y?.selection?.documentId;return b!=null?String(b):null},m=y=>{const b=y?.commentId??y?.importedId;return b!=null&&String(b)!==""?String(b):null},p=y=>{const b=d.value;if(!b.size)return!1;const T=h(y);return T?b.has(T):b.size===1},v=y=>{const b=Math.min(Number(y.top),Number(y.bottom)),T=Math.max(Number(y.top),Number(y.bottom));return{top:b,left:Math.min(Number(y.left),Number(y.right)),right:Math.max(Number(y.left),Number(y.right)),bottom:T}},_=ke(()=>{const y=r.getFloatingComments;return Array.isArray(y)?y.filter(b=>b?.selection?.source===d9).filter(b=>!b.resolvedTime).filter(b=>m(b)!==null).filter(b=>c(b.selection?.selectionBounds)).filter(b=>p(b)).map(b=>{const T=m(b),R=v(b.selection.selectionBounds);return{commentId:T,page:b.selection?.page??null,isInternal:b.isInternal!==!1,bounds:R}}):[]}),C=y=>{const b=(a.value??100)/100,{top:T,left:R,right:P,bottom:j}=y.bounds,O=i.value===y.commentId,V=(y.isInternal?f9:h9)+(O?"66":"33");return{position:"absolute",top:T*b+"px",left:R*b+"px",width:(P-R)*b+"px",height:(j-T)*b+"px",backgroundColor:V}},k=y=>{r.setActiveComment(l.$superdoc,y.commentId),n("anchor-activate",y.commentId)};return(y,b)=>(ge(),Ae("div",c9,[(ge(!0),Ae(Wt,null,rr(_.value,T=>(ge(),Ae("div",{key:T.commentId,class:"sd-comment-anchor sd-highlight",role:"button",tabindex:"0","data-id":T.commentId,"data-comment-id":T.commentId,"data-page-number":T.page,style:yn(C(T)),onClick:tn(R=>k(T),["stop","prevent"]),onKeydown:[Yo(tn(R=>k(T),["stop","prevent"]),["enter"]),Yo(tn(R=>k(T),["stop","prevent"]),["space"])]},null,44,u9))),128))]))}},m9=fn(p9,[["__scopeId","data-v-b5ad4c58"]]);xt();const g9=({proxy:e,layers:t,documents:n,modules:r})=>{const o=ke(()=>{const V=r.value?.whiteboard??r.whiteboard;return V===!1||V==null?null:V}),i=e?.$superdoc?.whiteboard,s=Kr([]),a=Gr({}),l=Gr({}),u=ne(!1),c=ne(0),d=ne(0),h=ne(1),m=ne(o.value?.enabled??!1),p=()=>{if(u.value)return;c.value+=1;const V=d.value||s.value.length;V&&c.value>=V&&(u.value=!0,e?.$superdoc?.emit("whiteboard:ready",{whiteboard:i}))},v=V=>{if(!V)return;const Q=n.value?.[0];Q&&Q.type==="application/pdf"&&_(V)},_=V=>{const{pageIndex:Q,width:F,height:N,originalWidth:x,originalHeight:z}=V,J={width:F,height:N,originalWidth:x,originalHeight:z};i?.setPageSize(Q,J),a[Q]=J;const X=i?.getPage(Q);X&&X.setSize(J),i&&(s.value=i.getPages().sort((ae,pe)=>ae.pageIndex-pe.pageIndex).map(ae=>Wr(ae)),d.value=s.value.length),_t(()=>{j(),p()})},C=V=>{e?.$superdoc?.emit("whiteboard:change",V)},k=V=>{V.forEach(Q=>{const F=a[Q.pageIndex];F&&Q.setSize(F)}),s.value=V.map(Q=>Wr(Q)),d.value=s.value.length,_t(()=>j())},y=V=>{m.value=V,e?.$superdoc?.emit("whiteboard:enabled",V)},b=V=>{h.value=V},T=V=>{e?.$superdoc?.emit("whiteboard:tool",V)},R=()=>{const V=n.value?.[0];V&&V.type==="application/pdf"&&P({doc:V})},P=({doc:V})=>{s.value.forEach(Q=>{const F=`${V.id}-page-${Q.pageIndex+1}`,N=document.querySelector(`[data-page-id="${F}"]`);if(!N)return;const x=N.getBoundingClientRect(),z=a[Q.pageIndex]||{},J=z.originalWidth??Q.size?.originalWidth??x.width,X=z.originalHeight??Q.size?.originalHeight??x.height,ae={width:x.width,height:x.height,originalWidth:J,originalHeight:X};a[Q.pageIndex]=ae,Q.setSize(ae)})},j=()=>{const V=t.value?.getBoundingClientRect?.();if(!V)return;const Q=n.value?.[0];Q&&Q.type==="application/pdf"&&O({doc:Q,layerBounds:V})},O=({doc:V,layerBounds:Q})=>{s.value.forEach(F=>{const N=`${V.id}-page-${F.pageIndex+1}`,x=document.querySelector(`[data-page-id="${N}"]`);if(!x)return;const z=x.getBoundingClientRect();l[F.pageIndex]={top:z.top-Q.top,left:z.left-Q.left}})};return i&&(i.on("change",C),i.on("setData",k),i.on("enabled",y),i.on("opacity",b),i.on("tool",T)),or(()=>{i&&(i.off("change",C),i.off("setData",k),i.off("opacity",b),i.off("enabled",y),i.off("tool",T))}),{whiteboard:i,whiteboardModuleConfig:o,whiteboardPages:s,whiteboardPageSizes:a,whiteboardPageOffsets:l,whiteboardEnabled:m,whiteboardOpacity:h,whiteboardReady:u,handleWhiteboardPageReady:v,updateWhiteboardPageSizes:R,updateWhiteboardPageOffsets:j}};xt(),gn();var v9=["data-page-index"],y9={__name:"WhiteboardPage",props:{whiteboard:{type:Object,required:!0},page:{type:Object,required:!0},pageSize:{type:Object,default:null},pageOffset:{type:Object,default:null},enabled:{type:Boolean,default:!0}},setup(e){const t=e,n=ne(null),r=()=>{const u=n.value;!u||!t.page||(t.page.mount(u),t.pageSize&&t.page.resize(t.pageSize.width,t.pageSize.height))},o=u=>{if(!t.page||!u?.dataTransfer||!t.enabled||t.whiteboard.getTool()!=="select")return;u.preventDefault(),u.stopPropagation();const c=n.value;if(!c)return;const d=c.getBoundingClientRect(),h=u.clientX-d.left,m=u.clientY-d.top,p=t.pageSize?.width,v=t.pageSize?.originalWidth??p,_=Number.isFinite(p)&&Number.isFinite(v)&&v?p/v:1;i(u,h,m,_)||s(u,h,m,_)||a(u,h,m)||l(u,h,m)},i=(u,c,d,h)=>{const m=u.dataTransfer.getData("application/sticker");if(!m)return!1;const p=(t.whiteboard.getType("stickers")||[]).find(v=>v.id===m);return p?.src?(t.page.addImage({stickerId:p.id,x:c,y:d,src:p.src,width:Number.isFinite(p.width)?p.width*h:p.width,height:Number.isFinite(p.height)?p.height*h:p.height,type:"sticker"}),!0):!1},s=(u,c,d,h)=>{const m=Array.from(u.dataTransfer.files||[]).find(v=>v.type.startsWith("image/"));if(!m)return!1;const p=new FileReader;return p.onload=()=>{typeof p.result=="string"&&t.page.addImage({x:c,y:d,src:p.result,type:"image"})},p.readAsDataURL(m),!0},a=(u,c,d)=>{const h=u.dataTransfer.getData("application/comment");if(!h)return!1;const m=(t.whiteboard.getType("comments")||[]).find(p=>p.id===h);return m?.text?(t.page.addText({x:c,y:d,content:m.text}),!0):!1},l=(u,c,d)=>{const h=u.dataTransfer.getData("text/plain");return h?(t.page.addText({x:c,y:d,content:h}),!0):!1};return Lt(()=>[t.page,t.pageSize?.width,t.pageSize?.height],()=>{_t(r)}),Nn(()=>{r()}),or(()=>{t.page?.destroy()}),(u,c)=>(ge(),Ae("div",{ref_key:"containerRef",ref:n,class:"whiteboard-page","data-page-index":e.page.pageIndex,onDragover:c[0]||(c[0]=tn(()=>{},["prevent"])),onDrop:tn(o,["prevent"]),style:yn({width:(e.pageSize?.width??e.page.size?.width)+"px",height:(e.pageSize?.height??e.page.size?.height)+"px",transform:`translate(${e.pageOffset?.left??0}px, ${e.pageOffset?.top??0}px)`})},null,44,v9))}},b9=fn(y9,[["__scopeId","data-v-c876c9b5"]]);xt(),gn();var w9={__name:"WhiteboardLayer",props:{whiteboard:{type:Object,required:!0},pages:{type:Array,default:()=>[]},pageSizes:{type:Object,default:()=>({})},pageOffsets:{type:Object,default:()=>({})},enabled:{type:Boolean,default:!0},interactive:{type:Boolean,default:null},opacity:{type:Number,default:1}},setup(e){const t=e,n=ke(()=>t.interactive==null?t.enabled:t.interactive);return(r,o)=>(ge(),Ae("div",{class:"whiteboard-layer","aria-hidden":"true",style:yn({opacity:e.opacity,pointerEvents:n.value?"auto":"none"})},[(ge(!0),Ae(Wt,null,rr(e.pages,i=>(ge(),dn(b9,{key:i.pageIndex,page:i,"page-size":e.pageSizes?.[i.pageIndex],"page-offset":e.pageOffsets?.[i.pageIndex],whiteboard:e.whiteboard,enabled:e.enabled},null,8,["page","page-size","page-offset","whiteboard","enabled"]))),128))],4))}},C9=fn(w9,[["__scopeId","data-v-54546c3d"]]);function _9(e){const t=e?.directionContext?.inlineDirection;if(t!=null)return t;const n=e?.paragraphProperties?.rightToLeft;if(n===!0)return"rtl";if(n===!1)return"ltr"}var T_=["#1f6feb","#d1242f","#8250df","#bf3989","#1a7f37","#9a6700","#bc4c00","#0969da","#cf222e","#6639ba","#116329","#7d4e00"];const S9=e=>e?`${typeof e.name=="string"?e.name:""} ${typeof e.email=="string"?e.email:""}`:"";var k9=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0};const A9=e=>T_[k9(S9(e))%T_.length];var ff=e=>typeof e=="string"&&e.length>0;const I9=e=>{if(!e||e.enabled===!1)return;const t=e.overrides&&typeof e.overrides=="object"?e.overrides:void 0,n=typeof e.resolve=="function"?e.resolve:void 0;return r=>{const o=r??{};if(t){if(ff(o.email)&&ff(t[o.email]))return t[o.email];if(ff(o.name)&&ff(t[o.name]))return t[o.name]}if(n)try{const i=n(o);if(ff(i))return i}catch{}return A9(o)}},E9=["insertion","deletion","move","move-from","move-to","table-cell-insertion","table-cell-deletion","cell-merge","cell-split","image-insertion","image-deletion","image-property-change"];var AU=new Set(E9);const gr={externalImageDeferred:"render.media.external-image-deferred",missingRelationship:"render.drawing.missing-relationship",missingMediaPart:"render.media.missing-part",unsupportedRelationshipType:"render.drawing.unsupported-relationship-type",unsupportedMime:"render.media.unsupported-mime",imageTooLarge:"render.media.image-too-large",unsafeSvg:"render.media.unsafe-svg",unsupportedFormat:"render.media.unsupported-format",embeddedObjectNotSupported:"render.embedded-object-not-supported",unsupportedObject:"render.drawing.unsupported-object",vmlUnsupported:"render.drawing.vml-unsupported",vmlImageUnsupported:"render.drawing.vml-image-unsupported",unsupportedGeometryCommand:"render.drawing.unsupported-geometry-command",anchorUnsupported:"render.drawing.anchor-unsupported",wrapUnsupported:"render.drawing.wrap-unsupported",altContentNoSupportedChoice:"render.drawing.altcontent-no-supported-choice",groupChildUnsupported:"render.drawing.group-child-unsupported"},IU={"render.media.missing-relationship":gr.missingRelationship,"render.media.wrong-relationship-type":gr.unsupportedRelationshipType,"render.media.unsupported-target":gr.unsupportedRelationshipType,"render.media.invalid-image-size":gr.imageTooLarge,"render.media-resolver-unavailable":gr.missingMediaPart,"render.chart-not-supported":gr.unsupportedObject,"render.textbox.vml-unsupported":gr.vmlUnsupported},x9={inlineBitmap:{family:"inlineBitmap",support:"supported",description:"wp:inline pic:pic with internal media and browser-safe MIME (PNG/JPEG; WebP/SVG once the host media resolver lands).",contract:"ImageRun"},anchoredBitmap:{family:"anchoredBitmap",support:"supported",description:"wp:anchor bitmap with anchor/wrap expressible by ImageAnchor/ImageWrap. Never silently inlined.",contract:"ImageBlock"},imageChildInGroup:{family:"imageChildInGroup",support:"supported",description:"Bitmap child of a supported DrawingML group/drawing wrapper. Supported only when the parent is.",contract:"ImageDrawing"},vectorShape:{family:"vectorShape",support:"supported",description:"Block/floating DrawingML preset/custom shape with the supported geometry/style subset.",contract:"DrawingBlock",drawingKind:"vectorShape"},shapeGroup:{family:"shapeGroup",support:"supported",description:"DrawingML group whose rendered children are supported vector/image children.",contract:"DrawingBlock",drawingKind:"shapeGroup"},chart:{family:"chart",support:"supported",description:"DrawingML chart projected into a ChartDrawing with parsed cached chart XML data. Complete Word chart fidelity remains deferred to chartFidelity.",contract:"DrawingBlock",drawingKind:"chart"},alternateContent:{family:"alternateContent",support:"supported",description:"mc:AlternateContent traversal/select policy. Selected Choice/Fallback maps to its family contract; unselected branches preserved for save/reopen.",contract:"selected-choice"},externalImage:{family:"externalImage",support:"fail-closed",description:'External image relationship (r:link / TargetMode="External"). Not fetched.',contract:"none",diagnostic:gr.externalImageDeferred},missingRelationship:{family:"missingRelationship",support:"fail-closed",description:"Drawing references a relationship id absent from the owner part .rels.",contract:"none",diagnostic:gr.missingRelationship},missingMediaPart:{family:"missingMediaPart",support:"fail-closed",description:"Relationship resolves but the target media part bytes are missing or empty.",contract:"none",diagnostic:gr.missingMediaPart},wrongRelationshipType:{family:"wrongRelationshipType",support:"fail-closed",description:"Relationship exists but is not an image relationship type.",contract:"none",diagnostic:gr.unsupportedRelationshipType},unsupportedMime:{family:"unsupportedMime",support:"fail-closed",description:"Media MIME outside the supported allowlist (incl. GIF/BMP/ICO).",contract:"none",diagnostic:gr.unsupportedMime},oversizedMediaPart:{family:"oversizedMediaPart",support:"fail-closed",description:"Media part exceeds the host byte-size policy before bytes are materialized.",contract:"none",diagnostic:gr.imageTooLarge},unsafeSvg:{family:"unsafeSvg",support:"fail-closed",description:"SVG content rejected by the SVG safety policy.",contract:"none",diagnostic:gr.unsafeSvg},metafileOrTiff:{family:"metafileOrTiff",support:"fail-closed",description:"EMF/WMF/TIFF and other non-browser-native formats with no approved conversion path.",contract:"none",diagnostic:gr.unsupportedFormat},embeddedObject:{family:"embeddedObject",support:"fail-closed",description:"OLE / ActiveX / embedded package object.",contract:"none",diagnostic:gr.embeddedObjectNotSupported},smartArtOrDiagram:{family:"smartArtOrDiagram",support:"fail-closed",description:"SmartArt / diagram / unknown external graphic-data object.",contract:"none",diagnostic:gr.unsupportedObject},vml:{family:"vml",support:"fail-closed",description:"VML structure outside any supported image-like subset (default fail-closed policy).",contract:"none",diagnostic:gr.vmlUnsupported},vmlImageLike:{family:"vmlImageLike",support:"fail-closed",description:"Simple VML image references (v:imagedata) / watermark image metadata. Fail-closed unless a later change promotes a named subset with deterministic fixtures and exact oracles.",contract:"none",diagnostic:gr.vmlImageUnsupported},unsupportedGeometryCommand:{family:"unsupportedGeometryCommand",support:"fail-closed",description:"Custom geometry command the extractor does not implement, e.g. arcTo.",contract:"none",diagnostic:gr.unsupportedGeometryCommand},unsupportedAnchorFields:{family:"unsupportedAnchorFields",support:"fail-closed",description:"Anchor fields required for honest placement are unsupported (char-relative, alignment modes, etc.).",contract:"none",diagnostic:gr.anchorUnsupported},unsupportedWrapFields:{family:"unsupportedWrapFields",support:"fail-closed",description:"Wrap fields required for honest placement are unsupported (arbitrary wrap polygons, etc.).",contract:"none",diagnostic:gr.wrapUnsupported},alternateContentNoSupportedChoice:{family:"alternateContentNoSupportedChoice",support:"fail-closed",description:"mc:AlternateContent with no supported choice and no usable fallback.",contract:"none",diagnostic:gr.altContentNoSupportedChoice},groupChildUnsupported:{family:"groupChildUnsupported",support:"fail-closed",description:"Unsupported child inside an otherwise-supported group. Supported siblings are not dropped.",contract:"none",diagnostic:gr.groupChildUnsupported},objectEditing:{family:"objectEditing",support:"deferred",description:"Editing/mutation of anchored/vector objects.",contract:"none"},customWrapPolygon:{family:"customWrapPolygon",support:"deferred",description:"Full Word-compatible text wrapping for arbitrary custom wrap polygons.",contract:"none"},chartFidelity:{family:"chartFidelity",support:"deferred",description:"Complete chart fidelity (a dedicated chart effort owns the parsed subset).",contract:"none"},vmlFidelity:{family:"vmlFidelity",support:"deferred",description:"Complete VML fidelity.",contract:"none"},decorativeAccessibilityUi:{family:"decorativeAccessibilityUi",support:"deferred",description:"Full accessibility UI for decorative image semantics beyond preserving source data.",contract:"none"}},EU=Object.keys(x9),xU=Object.freeze(["multiple-sections","furniture-page-tokens","non-balanceable-multi-column-sections","body-anchored-objects","footnotes","page-references","keep-constraints","tables","furniture-anchored-objects"]);xt(),gn();var T9={class:"superdoc-html-viewer"},R9={class:"superdoc-html-viewer__document"},M9=["innerHTML"],L9={__name:"HtmlViewer",props:{fileSource:{type:[File,Blob],required:!0},documentId:{type:String,required:!0}},emits:["ready","selection-change"],setup(e,{emit:t}){const n=e,r=ne(""),o=t,i=()=>{const l=window.getSelection();console.debug("selection from html viewer",l),o("selection-change",l)},s=l=>new Promise((u,c)=>{const d=new FileReader;d.onload=h=>{const m=h.target.result;u(m)},d.onerror=h=>c(h),d.readAsText(l)}),a=async()=>{try{r.value=await s(n.fileSource),o("ready",n.documentId)}catch(l){o("error",l),console.error("Error loading document",l)}};return Nn(()=>{a()}),(l,u)=>(ge(),Ae("div",T9,[Me("div",R9,[Me("div",{class:"superdoc-html-viewer__content",innerHTML:r.value,onMouseup:i},null,40,M9)])]))}},P9=fn(L9,[["__scopeId","data-v-da3494ba"]]);const D9=(e,t,n=()=>!0)=>{const r=new Set(t.map(String)),o=new Set;e.forEach(s=>{if(!n(s))return;const a=s.commentId!=null?String(s.commentId):null,l=s.importedId!=null?String(s.importedId):null;!(a&&r.has(a))&&!(l&&r.has(l))||(a&&o.add(a),l&&o.add(l))});let i=!0;for(;i;)i=!1,e.forEach(s=>{if(!n(s))return;const a=s.commentId!=null?String(s.commentId):null,l=s.importedId!=null?String(s.importedId):null,u=s.parentCommentId!=null?String(s.parentCommentId):null,c=Mp(s),d=c!=null?String(c):null,h=a&&o.has(a)||l&&o.has(l),m=u&&o.has(u)||d&&o.has(d);if(!h&&!m)return;const p=o.size;a&&o.add(a),l&&o.add(l),o.size>p&&(i=!0)});return o};xt();var R_=ne(!1);function Hi(){return{isHighContrastMode:R_,setHighContrastMode:t=>{R_.value=t}}}const TU="[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor",RU=320,MU=24,LU=816,PU=250,DU="sidebar",M_=new Set(["auto","sidebar","inline"]);function L_(e){if(!e||e===!1||typeof e!="object")return e;const t={...e},n=t.displayMode;M_.has(n)||delete t.displayMode;const r=t.compactBreakpointPx;typeof r=="number"&&Number.isFinite(r)&&r>=0||delete t.compactBreakpointPx;const o=t.compactMeasurementSelector;return typeof o=="string"&&o.trim().length>0?t.compactMeasurementSelector=o.trim():delete t.compactMeasurementSelector,t}xt();var O9=".superdoc__document",F9=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0,N9=e=>e+320+24;function B9({commentsModuleConfig:e,superdocRoot:t,layers:n}){const r=ne(0),o=ne(!1);let i=null,s=null;const a=m=>{if(!(m instanceof HTMLElement)||(typeof window<"u"?window.getComputedStyle(m):null)?.display==="contents")return!1;const p=Number(m.clientWidth??0),v=Number(m.getBoundingClientRect?.().width??0);return Number.isFinite(p)&&p>0||Number.isFinite(v)&&v>0},l=()=>{const m=t.value,p=e.value?.compactMeasurementSelector;if(typeof p=="string"&&p.trim().length>0&&typeof document<"u"){const _=document.querySelector(p.trim());if(a(_))return _}let v=m?.parentElement??null;for(;v;){if(a(v))return v;v=v.parentElement}return a(m)||m instanceof HTMLElement?m:null},u=()=>{const m=typeof window<"u"?window.ResizeObserver:void 0;if(typeof m>"u")return;const p=l();p!==s&&(i&&(i.disconnect(),i=null),s=p,s&&(i=new m(()=>{h()}),i.observe(s)))},c=()=>{u();const m=Number(s?.clientWidth??0);if(Number.isFinite(m)&&m>0)return m;const p=Number(s?.getBoundingClientRect?.().width??0);return Number.isFinite(p)&&p>0?p:0},d=()=>{const m=t.value?.querySelector?.(O9),p=n.value,v=Number(m?.clientWidth??m?.getBoundingClientRect?.().width??0);if(Number.isFinite(v)&&v>0)return v;const _=Number(p?.clientWidth??p?.getBoundingClientRect?.().width??0);return Number.isFinite(_)&&_>0?_:816},h=()=>{const m=c(),p=e.value,v=p?.displayMode??"sidebar";if(v==="sidebar"){r.value=m,o.value=!1;return}if(v==="inline"){r.value=m,o.value=!0;return}if(!(Number.isFinite(m)&&m>0))return;r.value=m;const _=p?.compactBreakpointPx;if(F9(_)){o.value=m<_;return}o.value=m<N9(d())};return or(()=>{i&&(i.disconnect(),i=null),s=null}),{superdocContainerWidth:r,isCompactCommentsMode:o,recalculateCompactCommentsMode:h,ensureCompactMeasurementObserver:u}}xt();var P_=320,el=12,z9=220,V9=16,H9=500,D_=".superdoc-comment-highlight[data-comment-ids]",O_="data-comment-ids",j9=".sd-comment-anchor",f0=(e,t,n)=>Math.min(Math.max(e,t),n),ws=e=>Number(e),ji=e=>Number.isFinite(e),h0=e=>e?.commentId??e?.importedId??null,F_=e=>String(e||"").split(",").map(t=>t.trim()).filter(Boolean),U9=e=>{const t=e?.value;if(!t)return null;const n=ws(t.ts);if(!ji(n)||Date.now()-n>H9)return null;const r=ws(t.x),o=ws(t.anchorRect?.bottom),i=ji(o)?o:ws(t.y);return!ji(r)||!ji(i)?null:{x:r,y:i}},G9=({rootEl:e,comment:t,pendingComment:n})=>{if(n?.value&&t?.commentId===n.value?.commentId){const a=e.querySelectorAll(D_);for(const l of a)if(F_(l.getAttribute(O_)).includes("pending")&&typeof l.getBoundingClientRect=="function")return l.getBoundingClientRect()}const r=h0(t);if(!r)return null;const o=String(r),i=e.querySelectorAll(D_);for(const a of i)if(F_(a.getAttribute(O_)).includes(o)&&typeof a.getBoundingClientRect=="function")return a.getBoundingClientRect();const s=e.querySelector(`[data-track-change-id="${o}"]`);return s&&typeof s.getBoundingClientRect=="function"?s.getBoundingClientRect():null},W9=(e,t)=>{const{entry:n}=e(h0(t)),r=ws(n?.bounds?.bottom);return ji(r)?r:ws(n?.bounds?.top)},K9=({selectionPosition:e,comment:t,pendingComment:n})=>e.value?.source==="pdf"||t?.selection?.source==="pdf"||n.value?.selection?.source==="pdf",q9=({rootEl:e,layersRect:t,comment:n})=>{const r=h0(n);if(r==null)return NaN;const o=e.querySelector(`${j9}[data-id="${String(r)}"]`);return!o||typeof o.getBoundingClientRect!="function"?NaN:ws(o.getBoundingClientRect().bottom)-ws(t.top)},Y9=({comment:e,pendingComment:t,selectionPosition:n,activeZoom:r})=>{if(!t.value||e?.commentId!==t.value?.commentId)return NaN;const o=ws(n.value?.bottom);if(ji(o))return o*(n.value?.source==="pdf"?(r.value??100)/100:1);const i=ws(n.value?.top);return ji(i)?i*(n.value?.source==="pdf"?(r.value??100)/100:1):NaN},X9=({top:e,left:t})=>({top:`${Math.round(e)}px`,left:`${Math.round(t)}px`,right:"auto"}),Z9=({rootRect:e,layersRect:t,anchorBottom:n,anchorClientX:r=NaN})=>{const o=f0(t.top-e.top+n+V9,el,Math.max(el,e.height-z9)),i=Math.max(el,e.width-P_-el);let s;if(ji(r))s=f0(r-e.left+el,el,i);else{const a=e.width-(t.left-e.left+t.width)+el;s=f0(e.width-a-P_,el,i)}return{top:o,left:s}};function Q9({activeComment:e,pendingComment:t,activeCompactComment:n,showCommentsSidebar:r,selectionPosition:o,activeZoom:i,superdocRoot:s,layers:a,documents:l,resolveCommentPositionEntry:u,clearActiveComment:c,clearPendingComment:d}){const h={top:"12px",right:"12px"},m=ne(0),p=ne({x:null,y:null,ts:0,anchorRect:null});let v=null,_=null;const C=()=>{p.value={x:null,y:null,ts:0,anchorRect:null}},k=(R,P,j)=>{if(!l.value?.some(V=>V.type==="application/pdf"))return!1;const O=R.querySelector(".superdoc__compact-comment-popover");return!n.value||!O||O.contains(P)||j?!1:(t.value&&d(),c(),C(),!0)},y=R=>{const P=s.value;if(!P||!a.value?.contains(R.target))return;const j=(typeof document.elementsFromPoint=="function"?document.elementsFromPoint(R.clientX,R.clientY):[]).find(V=>V?.nodeType===1&&P.contains(V)&&V.closest("[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor"))?.closest("[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor")??(R.target?.nodeType===1?R.target.closest("[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor"):null);if(k(P,R.target,j)||R.button!==0||R.pointerType!=="mouse")return;const O=j&&typeof j.getBoundingClientRect=="function"?j.getBoundingClientRect():null;O&&(p.value={x:R.clientX,y:O.bottom,ts:Date.now(),anchorRect:{left:O.left,right:O.right,top:O.top,bottom:O.bottom}})},b=ke(()=>{m.value;const R=n.value;if(!R)return h;const P=s.value,j=a.value;if(!P||!j)return h;const O=P.getBoundingClientRect(),V=j.getBoundingClientRect(),Q=U9(p),F=Q?null:G9({rootEl:P,comment:R,pendingComment:t});let N=NaN,x=NaN;return Q?(N=Q.y-V.top,x=Q.x):F?(N=F.bottom-V.top,x=F.left):N=W9(u,R),!ji(N)&&K9({selectionPosition:o,comment:R,pendingComment:t})&&(N=q9({rootEl:P,layersRect:V,comment:R})),ji(N)||(N=Y9({comment:R,pendingComment:t,selectionPosition:o,activeZoom:i})),ji(N)?X9(Z9({rootRect:O,layersRect:V,anchorBottom:N,anchorClientX:x})):h});return Lt([e,t,o,i,r,p],()=>{const R=typeof window<"u"?window.requestAnimationFrame:null,P=typeof window<"u"?window.cancelAnimationFrame:null;v!=null&&P?.(v),R&&(v=R(()=>{m.value+=1,v=null}))},{deep:!1}),Lt(n,(R,P)=>{if(!P&&R){const j=document.activeElement;j instanceof HTMLElement&&(_=j)}},{deep:!1}),Lt(t,(R,P)=>{!P&&R&&C()}),Nn(()=>{document.addEventListener("pointerdown",y,!0)}),or(()=>{document.removeEventListener("pointerdown",y,!0);const R=typeof window<"u"?window.cancelAnimationFrame:null;v!=null&&(R?.(v),v=null),_=null}),{compactCommentPopoverStyle:b,closeCompactCommentPopover:()=>{n.value&&(t.value&&d(),c(),_&&typeof _.focus=="function"&&_.focus(),_=null)},resetClickAnchor:C}}function tl(...e){const t={};for(const n of e)if(!(typeof n!="object"||n===null))for(const[r,o]of Object.entries(n))o!==void 0&&(t[r]=o);return t}function N_(...e){for(const t of e)if(t!==void 0)return t}function B_(e){if(e?.type!=="mutation:committed")return null;const t=e.origin==="history"?e.result:e.receipt;if(!t||typeof t!="object")return null;const n=new Set,r=new Set,o=[],i=(a,l)=>{a?.kind!=="entity"||a.entityType!=="trackedChange"||typeof a.entityId=="string"&&a.entityId.length>0&&l.add(a.entityId)},s=a=>a?.kind!=="entity"||a.entityType!=="trackedChange"?null:typeof a.entityId=="string"&&a.entityId.length>0?a.entityId:null;if(Array.isArray(t.inserted)&&t.inserted.forEach(a=>i(a,n)),Array.isArray(t.updated)&&t.updated.forEach(a=>i(a,n)),Array.isArray(t.trackedChangeRefs)&&t.trackedChangeRefs.forEach(a=>i(a,n)),Array.isArray(t.removed)&&t.removed.forEach(a=>i(a,r)),Array.isArray(t.invalidatedRefs)&&t.invalidatedRefs.forEach(a=>i(a,r)),Array.isArray(t.remappedRefs))for(const a of t.remappedRefs){const l=s(a?.from),u=s(a?.to);l&&r.add(l),u&&n.add(u),l&&u&&l!==u&&o.push({from:l,to:u})}for(const a of r)n.delete(a);return n.size===0&&r.size===0?null:{upsertIds:n,removedIds:r,remappedPairs:o,reconcileMode:e.origin==="history"?"authoritative":"targeted"}}var hf=e=>new Set(Array.from(e??[]).filter(t=>typeof t=="string"&&t.length>0)),J9=e=>typeof e?.id=="string"&&e.id.length>0?e.id:typeof e?.changeId=="string"&&e.changeId.length>0?e.changeId:typeof e?.address?.entityId=="string"&&e.address.entityId.length>0?e.address.entityId:null,$9=(e,t)=>e?.adapter===t?.adapter&&e?.documentId===t?.documentId&&e?.editor===t?.editor&&e?.reconcileToken===t?.reconcileToken;function z_({getContext:e,reconcile:t,hydrate:n,onReconciled:r}){const o=new Map;let i=0,s=0,a=null,l=!1;const u=(R,P)=>s===R&&$9(P,e()),c=(R,P)=>{const j=new Set;for(const O of R)o.get(O)===P.get(O)&&(o.delete(O),j.add(O));return j},d=R=>new Map([...o].filter(([,P])=>P.ready===!0&&P.reconcileMode===R)),h=()=>{let R=!1;for(const P of o.values())P.gate!=="render"||P.ready||(P.ready=!0,R=!0);return R},m=R=>{let P=!1;for(const j of o.values())j.version>R||j.ready||(j.ready=!0,P=!0);return P},p=async(R,P,j,O=!1)=>{if(!(!O&&P.size===0||typeof r!="function"))try{await r(R,P,j)}catch{}},v=R=>hf(R?.resolvedIds??(R?.items??[]).map(J9).filter(Boolean)),_=async(R,P,j)=>{const O=await t(R,{upsertIds:new Set(P.keys()),removedIds:new Set,reconcileMode:"targeted"});if(!u(j,R)||(await p(R,c(v(O),P),O),new Set([...P].filter(([Q,F])=>o.get(Q)===F).map(([Q])=>Q)).size===0))return;const V=await n(R,{trackedChangesListMode:"interaction-prime",refreshReason:"mutation-render-reconcile",blocking:!1});u(j,R)&&await p(R,c(v(V),P),V)},C=async(R,P,j)=>{const O=await n(R,{trackedChangesListMode:"all",refreshReason:"mutation-history-render-reconcile",blocking:!0});if(!u(j,R)||![...P].some(([x,z])=>o.get(x)===z))return;const V=O?.ok===!0,Q=V&&O?.complete===!0&&O?.sourceCoverageComplete===!0,F=V?v(O):new Set,N=Q?c(new Set(P.keys()),P):new Set;await p(R,Q?N:F,{...O,reconcileMode:"authoritative"},!0)},k=()=>{if(a)return a;const R=d("targeted"),P=d("authoritative");if(R.size===0&&P.size===0)return null;const j=e();if(!j?.adapter)return null;l=!1;const O=s;return a=Promise.resolve().then(async()=>{P.size>0&&await C(j,P,O).catch(()=>{}),R.size>0&&await _(j,R,O).catch(()=>{})}).catch(()=>{}).finally(()=>{a=null,l&&k()}),a},y=(R,P)=>{if(!R)return;const j=R.reconcileMode==="authoritative"?"authoritative":"targeted",O=hf(R.removedIds),V=hf(R.upsertIds);for(const F of O){const N=o.get(F);N?.reconcileMode==="authoritative"?o.set(F,{...N,version:++i,gate:P,ready:!1}):o.delete(F)}const Q=e();if(O.size>0&&V.size===0&&Q?.adapter)try{Promise.resolve(t(Q,{upsertIds:new Set,removedIds:O})).catch(()=>{})}catch{}for(const F of V)if(!O.has(F)){const N=o.get(F);o.set(F,{version:++i,gate:P,ready:!1,reconcileMode:j==="authoritative"||N?.reconcileMode==="authoritative"?"authoritative":"targeted"})}},b=R=>y(R,"render");return{enqueue:b,enqueueAfterPaint(R,P){if(!R||typeof P!="function"){b(R);return}y(R,"exact-paint");const j=e();if(!j?.adapter)return;const O=s,V=i,Q=new Set([...hf(R.upsertIds),...hf(R.removedIds)]),F=new Map([...Q].flatMap(N=>{const x=o.get(N);return x?[[N,x]]:[]}));Promise.resolve().then(()=>P()).then(()=>{if(!u(O,j))return;let N=h();m(V)&&(N=!0);for(const[x,z]of F)o.get(x)===z&&(z.ready||(N=!0),z.ready=!0);a&&(N||V>0)&&(l=!0),k()}).catch(()=>{if(u(O,j))for(const[N,x]of F)o.get(N)===x&&(x.gate="render")})},onRender:(R=!1)=>{const P=h();a&&(P||R)&&(l=!0),k()},reset(){s+=1,o.clear(),l=!1},getPendingIds(){return new Set(o.keys())}}}function eM(e,t){if(!e||typeof e.entityId!="string"||e.entityType!=="comment"&&e.entityType!=="trackedChange")return null;const n=typeof t=="function"?t(e.entityId):null,r=n?.commentId??n?.importedId??e.entityId;return r!=null?String(r):null}var tM=new Set(["insert-text","replace-text","plain-text-paste","delete-backward","delete-forward","text.insert","text.replace","text.pastePlain","text.deleteBackward","text.deleteForward","structural.enter","structural:enter-split-paragraph","structural:enter-insert-paragraph-before","structural:enter-insert-paragraph-after","structural:shift-enter-line-break","structural:backspace-boundary-merge-with-previous","structural:delete-boundary-merge-with-next","backspace:boundary-merge-with-previous","backspace:list-remove","backspace:list-outdent"]);const V_=e=>e?.type!=="mutation:committed"||e.origin!=="command"?!1:tM.has(e.editableCommandKind);function H_(e){return e==null?null:String(e)}function nM({hydrate:e,getActiveDocumentId:t,debounceMs:n=250,ceilingMs:r=1e3,now:o=()=>Date.now(),setTimer:i=(a,l)=>setTimeout(a,l),clearTimer:s=a=>clearTimeout(a)}){let a=null,l=null,u=null;const c=m=>H_(t())===m,d=()=>{a!=null&&s(a),a=null,l=null,u=null};return{schedule:m=>{const p=H_(m);if(!c(p))return!1;u!==p&&d();const v=o();u=p,l??=v,a!=null&&s(a);const _=Math.max(0,r-(v-l));return a=i(()=>{const C=u;a=null,l=null,u=null,c(C)&&e()},Math.min(n,_)),!0},clear:d}}var rM="no-author-configured";const oM="author-required",j_="This edit needs an author identity. Set `user.name` in your SuperDoc configuration and reopen the document to make tracked or revision-overlapping edits.";function U_(e){return typeof e=="string"&&e.includes(rM)}function iM(e){if(!e||e.type!=="mutation:rejected")return!1;if(e.failureSource==="receipt"){const t=e.failure;return t?t.code==="PRECONDITION_FAILED"&&U_(t.message):!1}return e.failureSource==="shell"?e.reason==="author-required"?!0:e.reason==="PRECONDITION_FAILED"&&U_(e.message):!1}function sM(){const e=new Set,t=n=>typeof n=="string"&&n.length>0?n:"__default__";return{shouldNotify(n,r){if(!iM(r))return!1;const o=t(n);return e.has(o)?!1:(e.add(o),!0)},clear(n){e.delete(t(n))}}}const aM=e=>!!(e?.anchor&&e?.focus&&(e.anchor.blockId!==e.focus.blockId||e.anchor.blockOffset!==e.focus.blockOffset)),lM=(e,t)=>{if(!e||e.rangeCount<1||e.isCollapsed||!t)return!1;const n=e.getRangeAt(0);return!t.contains(n.startContainer)&&!t.contains(n.endContainer)},cM=(e,t)=>e!=="editing"&&e!=="suggesting"?!1:aM(t);var uM=Ir((()=>{})),dM=nd({default:()=>eS},1),G_,W_,K_,q_,Y_,X_,Z_,Q_,J_,$_,eS,fM=Ir((()=>{xt(),uM(),gn(),G_=["onKeydown"],W_=["id"],K_={class:"sd-password-prompt__description"},q_={class:"sd-password-prompt__field"},Y_=["placeholder","disabled","aria-label"],X_={key:0,class:"sd-password-prompt__error",role:"alert"},Z_={class:"sd-password-prompt__actions"},Q_=["disabled"],J_=["disabled"],$_={__name:"PasswordPromptSurface",props:{surfaceId:{type:String,default:""},mode:{type:String,default:"dialog"},request:{type:Object,default:()=>({})},resolve:{type:Function,default:()=>{}},close:{type:Function,default:()=>{}},passwordPrompt:{type:Object,required:!0}},setup(e){const t=e,n=ne(""),r=ne(!1),o=ne(t.passwordPrompt.errorCode==="DOCX_PASSWORD_INVALID"),i=ne(o.value?t.passwordPrompt.texts.invalidMessage:""),s=ke(()=>o.value?t.passwordPrompt.texts.invalidTitle:t.passwordPrompt.texts.title),a=ke(()=>n.value.length>0&&!r.value);async function l(){if(!a.value)return;r.value=!0,i.value="";const c=await t.passwordPrompt.attemptPassword(n.value);if(c.success){t.resolve({password:n.value});return}r.value=!1,n.value="",c.errorCode==="DOCX_PASSWORD_INVALID"?(o.value=!0,i.value=t.passwordPrompt.texts.invalidMessage):c.errorCode==="timeout"?i.value=t.passwordPrompt.texts.timeoutMessage:i.value=t.passwordPrompt.texts.genericErrorMessage}function u(){t.close("user-cancelled")}return(c,d)=>(ge(),Ae("div",{class:"sd-password-prompt",onKeydown:Yo(tn(l,["prevent"]),["enter"])},[Me("h3",{id:`sd-password-prompt-heading-${e.surfaceId}`,class:"sd-password-prompt__heading"},Bt(s.value),9,W_),Me("p",K_,Bt(e.passwordPrompt.texts.description),1),Me("div",q_,[Us(Me("input",{"onUpdate:modelValue":d[0]||(d[0]=h=>n.value=h),type:"password",class:"sd-password-prompt__input",placeholder:e.passwordPrompt.texts.placeholder,disabled:r.value,autocomplete:"current-password","aria-label":e.passwordPrompt.texts.inputAriaLabel},null,8,Y_),[[Ai,n.value]])]),i.value?(ge(),Ae("p",X_,Bt(i.value),1)):ht("",!0),Me("div",Z_,[Me("button",{type:"button",class:"sd-password-prompt__btn sd-password-prompt__btn--cancel",disabled:r.value,onClick:u},Bt(e.passwordPrompt.texts.cancelLabel),9,Q_),Me("button",{type:"button",class:"sd-password-prompt__btn sd-password-prompt__btn--submit",disabled:!a.value,onClick:l},Bt(r.value?e.passwordPrompt.texts.busyLabel:e.passwordPrompt.texts.submitLabel),9,J_)])],40,G_))}},eS=fn($_,[["__scopeId","data-v-ecf7f6fb"]])}));xt();var hM=["DOCX_PASSWORD_REQUIRED","DOCX_PASSWORD_INVALID"],pM=3e4,Ii={title:"Password Required",invalidTitle:"Incorrect Password",description:"This document is password protected. Enter the password to open it.",placeholder:"Enter password",inputAriaLabel:"Document password",submitLabel:"Open",cancelLabel:"Cancel",busyLabel:"Decryptingβ¦",invalidMessage:"Incorrect password. Please try again.",timeoutMessage:"Timed out while decrypting. Please try again.",genericErrorMessage:"Unable to decrypt this document."};function mM({getSurfaceManager:e,getPasswordPromptConfig:t,onUnhandled:n}){const r=[],o=Kr(null),i=new Map;let s=!1;function a(p,v,_){if(!p||!hM.includes(v)||t()===!1||!e())return!1;const C=i.get(p.id);if(C)return clearTimeout(C.timer),C.resolve({success:!1,errorCode:v}),i.delete(p.id),!0;const k=r.find(y=>y.doc.id===p.id);return k?(k.errorCode=v,k.originalException=_,!0):(o.value?.doc.id===p.id||(r.push({doc:p,errorCode:v,originalException:_}),c()),!0)}function l(p){if(!p)return;const v=i.get(p.id);v&&(clearTimeout(v.timer),v.resolve({success:!0}),i.delete(p.id))}function u(){s=!0;for(const[,p]of i)clearTimeout(p.timer),p.resolve({success:!1,errorCode:"destroyed"});i.clear(),r.length=0,o.value=null}function c(){if(s||o.value||r.length===0)return;const p=r.shift();p&&d(p).catch(v=>{o.value=null,console.error("[SuperDoc] Password prompt error:",v),n?.(p.doc,p.errorCode,p.originalException),c()})}async function d({doc:p,errorCode:v,originalException:_}){const C=e();if(!C||s)return;const k=h(),y=P=>(p.password=P,p.editorMountNonce++,new Promise(j=>{const O=setTimeout(()=>{i.delete(p.id),j({success:!1,errorCode:"timeout"})},pM);i.set(p.id,{resolve:j,timer:O})})),b={documentId:p.id,errorCode:v,texts:k.texts,attemptPassword:y},T=m(k,{documentId:p.id,errorCode:v,texts:k.texts});if(T.suppressed){n?.(p,v,_),c();return}o.value={doc:p,surfaceHandle:null};let R;if(T.component)R=C.open({mode:"dialog",closeOnBackdrop:!1,ariaLabel:k.texts.title,component:Wr(T.component),props:{...T.props,passwordPrompt:b}});else if(T.render){const P=T.render;R=C.open({mode:"dialog",closeOnBackdrop:!1,ariaLabel:k.texts.title,render:j=>P({container:j.container,passwordPrompt:b,resolve:j.resolve,close:j.close,surfaceId:j.surfaceId,mode:j.mode})})}else{const P=(await Promise.resolve().then(()=>(fM(),dM))).default,j=`password-prompt-${p.id}`;R=C.open({id:j,mode:"dialog",closeOnBackdrop:!1,ariaLabelledBy:`sd-password-prompt-heading-${j}`,component:Wr(P),props:{passwordPrompt:b}})}o.value={doc:p,surfaceHandle:R},await R.result,o.value=null,c()}function h(){const p=t();if(p===!1)return{enabled:!1,texts:Ii};const v=typeof p=="object"&&p!==null?p:{};if(v.component!=null&&typeof v.render=="function")throw new Error('modules.surfaces.passwordPrompt cannot provide both "component" and "render". Use one or the other.');return{enabled:!0,texts:{title:v.title??Ii.title,invalidTitle:v.invalidTitle??Ii.invalidTitle,description:v.description??Ii.description,placeholder:v.placeholder??Ii.placeholder,inputAriaLabel:v.inputAriaLabel??Ii.inputAriaLabel,submitLabel:v.submitLabel??Ii.submitLabel,cancelLabel:v.cancelLabel??Ii.cancelLabel,busyLabel:v.busyLabel??Ii.busyLabel,invalidMessage:v.invalidMessage??Ii.invalidMessage,timeoutMessage:v.timeoutMessage??Ii.timeoutMessage,genericErrorMessage:v.genericErrorMessage??Ii.genericErrorMessage},component:v.component,props:v.props,render:v.render,resolver:v.resolver}}function m(p,v){if(typeof p.resolver=="function"){const _=p.resolver(v);if(_!=null&&_.type!=="default"){if(_.type==="none")return{suppressed:!0};if(_.type==="custom")return{component:_.component,props:_.props};if(_.type==="external")return{render:_.render}}}return p.component!=null?{component:p.component,props:p.props}:typeof p.render=="function"?{render:p.render}:{builtin:!0}}return{handleEncryptionError:a,handleEditorReady:l,destroy:u}}function tS(e,{getCurrentSession:t,applySlice:n,onSettled:r}){return()=>{if(e===t())try{n(e.getSnapshot())}catch{}r()}}var gM=Ir((()=>{})),vM=nd({default:()=>kS},1),nS,rS,oS,iS,sS,aS,lS,cS,uS,dS,fS,hS,pS,mS,gS,vS,yS,bS,wS,CS,_S,SS,kS,yM=Ir((()=>{xt(),gM(),gn(),nS=["onKeydown"],rS={class:"sd-find-replace__row"},oS=["title","aria-label","aria-expanded"],iS=["value","placeholder","aria-label"],sS={key:0,class:"sd-find-replace__count"},aS=["title","aria-label","aria-pressed"],lS=["title","aria-label","aria-pressed"],cS=["title","aria-label","aria-pressed"],uS={class:"sd-find-replace__nav"},dS=["disabled","title","aria-label"],fS=["disabled","title","aria-label"],hS=["title","aria-label"],pS={key:0,class:"sd-find-replace__row"},mS={class:"sd-find-replace__field"},gS=["value","placeholder","aria-label"],vS={class:"sd-find-replace__nav sd-find-replace__nav--actions"},yS=["disabled","title"],bS=["disabled","title"],wS={key:1,class:"sd-find-replace__error",role:"alert"},CS={key:0,class:"sd-find-replace__row-indent","aria-hidden":"true"},_S={class:"sd-find-replace__error-text"},SS={__name:"FindReplaceSurface",props:{surfaceId:{type:String,default:""},mode:{type:String,default:"floating"},request:{type:Object,default:()=>({})},resolve:{type:Function,default:()=>{}},close:{type:Function,default:()=>{}},findReplace:{type:Object,required:!0}},setup(e){const t=e,n=ne(null),r=ke(()=>{const p=t.findReplace;return!!(!p.hasMatches?.value||p.replacePending?.value===!0||p.canReplace&&p.canReplace.value===!1)}),o=ke(()=>t.findReplace.ignoreDiacriticsSupported?.value!==!1),i=ke(()=>t.findReplace.replaceEnabled&&t.findReplace.replaceCanMutate?.value!==!1),s=ke(()=>t.findReplace.regexSupported?.value===!0),a=ke(()=>t.findReplace.searchError?.value??null);function l(p){p.key==="Enter"&&!p.shiftKey?(p.preventDefault(),u()):p.key==="Enter"&&p.shiftKey&&(p.preventDefault(),c())}function u(){t.findReplace.goNext(),m()}function c(){t.findReplace.goPrev(),m()}function d(){t.findReplace.close("user-closed")}function h(p){const v=[];let _=p?.parentElement??null;for(;_;){const k=_.ownerDocument?.defaultView?.getComputedStyle?.(_);if(k){const y=`${k.overflowY} ${k.overflowX}`;(y.includes("auto")||y.includes("scroll"))&&v.push(_)}_=_.parentElement}const C=p?.ownerDocument?.scrollingElement;return C&&!v.includes(C)&&v.push(C),v}function m(){const p=n.value;if(!p)return;const v=h(p).map(_=>({el:_,top:_.scrollTop,left:_.scrollLeft}));p.focus({preventScroll:!0});for(const{el:_,top:C,left:k}of v)_.scrollTop!==C&&(_.scrollTop=C),_.scrollLeft!==k&&(_.scrollLeft=k)}return Nn(()=>{n.value?.focus(),t.findReplace.registerFocusFn(m)}),(p,v)=>(ge(),Ae("div",{class:"sd-find-replace",onKeydown:Yo(tn(d,["stop"]),["esc"])},[Me("div",rS,[i.value?(ge(),Ae("button",{key:0,type:"button",class:rn(["sd-find-replace__btn sd-find-replace__btn--expander",{"sd-find-replace__btn--expander-open":e.findReplace.showReplace.value}]),title:e.findReplace.texts.toggleReplaceLabel,"aria-label":e.findReplace.texts.toggleReplaceAriaLabel,"aria-expanded":e.findReplace.showReplace.value?"true":"false",onClick:v[0]||(v[0]=_=>e.findReplace.showReplace.value=!e.findReplace.showReplace.value)},[...v[14]||(v[14]=[Me("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true"},[Me("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],10,oS)):ht("",!0),Me("div",{class:rn(["sd-find-replace__field",{"sd-find-replace__field--error":a.value}])},[v[15]||(v[15]=Me("svg",{class:"sd-find-replace__search-icon",viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},[Me("path",{d:"M7 1a6 6 0 1 0 3.7 10.7l3.3 3.3 1-1-3.3-3.3A6 6 0 0 0 7 1Zm0 1.5a4.5 4.5 0 1 1 0 9 4.5 4.5 0 0 1 0-9Z",fill:"currentColor"})],-1)),Me("input",{ref_key:"findInputRef",ref:n,value:e.findReplace.findQuery.value,onInput:v[1]||(v[1]=_=>e.findReplace.findQuery.value=_.target.value),type:"text",class:"sd-find-replace__input sd-find-replace__input--search","data-sd-autofocus":"",placeholder:e.findReplace.texts.findPlaceholder,"aria-label":e.findReplace.texts.findAriaLabel,onKeydown:l},null,40,iS),e.findReplace.findQuery.value&&!a.value?(ge(),Ae("span",sS,Bt(e.findReplace.matchLabel.value),1)):ht("",!0),Me("button",{type:"button",class:rn(["sd-find-replace__btn sd-find-replace__btn--toggle",{"sd-find-replace__btn--active":e.findReplace.caseSensitive.value}]),title:e.findReplace.texts.matchCaseAriaLabel,"aria-label":e.findReplace.texts.matchCaseAriaLabel,"aria-pressed":e.findReplace.caseSensitive.value?"true":"false",onMousedown:v[2]||(v[2]=tn(()=>{},["prevent"])),onClick:v[3]||(v[3]=_=>e.findReplace.caseSensitive.value=!e.findReplace.caseSensitive.value)},Bt(e.findReplace.texts.matchCaseLabel),43,aS),o.value?(ge(),Ae("button",{key:1,type:"button",class:rn(["sd-find-replace__btn sd-find-replace__btn--toggle",{"sd-find-replace__btn--active":e.findReplace.ignoreDiacritics.value}]),title:e.findReplace.texts.ignoreDiacriticsAriaLabel,"aria-label":e.findReplace.texts.ignoreDiacriticsAriaLabel,"aria-pressed":e.findReplace.ignoreDiacritics.value?"true":"false",onMousedown:v[4]||(v[4]=tn(()=>{},["prevent"])),onClick:v[5]||(v[5]=_=>e.findReplace.ignoreDiacritics.value=!e.findReplace.ignoreDiacritics.value)},Bt(e.findReplace.texts.ignoreDiacriticsLabel),43,lS)):ht("",!0),s.value?(ge(),Ae("button",{key:2,type:"button",class:rn(["sd-find-replace__btn sd-find-replace__btn--toggle",{"sd-find-replace__btn--active":e.findReplace.regex.value}]),title:e.findReplace.texts.regexAriaLabel,"aria-label":e.findReplace.texts.regexAriaLabel,"aria-pressed":e.findReplace.regex.value?"true":"false",onMousedown:v[6]||(v[6]=tn(()=>{},["prevent"])),onClick:v[7]||(v[7]=_=>e.findReplace.regex.value=!e.findReplace.regex.value)},Bt(e.findReplace.texts.regexLabel),43,cS)):ht("",!0)],2),Me("div",uS,[Me("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--icon",disabled:!e.findReplace.hasMatches.value,title:e.findReplace.texts.previousMatchLabel,"aria-label":e.findReplace.texts.previousMatchAriaLabel,onClick:v[8]||(v[8]=_=>c())},[...v[16]||(v[16]=[Me("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[Me("path",{d:"M10 3.5 5.5 8 10 12.5",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,dS),Me("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--icon",disabled:!e.findReplace.hasMatches.value,title:e.findReplace.texts.nextMatchLabel,"aria-label":e.findReplace.texts.nextMatchAriaLabel,onClick:v[9]||(v[9]=_=>u())},[...v[17]||(v[17]=[Me("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[Me("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,fS),v[19]||(v[19]=Me("span",{class:"sd-find-replace__divider","aria-hidden":"true"},null,-1)),Me("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--icon",title:e.findReplace.texts.closeLabel,"aria-label":e.findReplace.texts.closeAriaLabel,onClick:d},[...v[18]||(v[18]=[Me("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[Me("path",{d:"m4.5 4.5 7 7m0-7-7 7",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"})],-1)])],8,hS)])]),e.findReplace.showReplace.value&&i.value?(ge(),Ae("div",pS,[v[20]||(v[20]=Me("span",{class:"sd-find-replace__row-indent","aria-hidden":"true"},null,-1)),Me("div",mS,[Me("input",{value:e.findReplace.replaceText.value,onInput:v[10]||(v[10]=_=>e.findReplace.replaceText.value=_.target.value),type:"text",class:"sd-find-replace__input",placeholder:e.findReplace.texts.replacePlaceholder,"aria-label":e.findReplace.texts.replaceAriaLabel,onKeydown:v[11]||(v[11]=Yo(tn(_=>e.findReplace.replaceCurrent(),["prevent"]),["enter"]))},null,40,gS)]),Me("div",vS,[Me("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--action",disabled:r.value,title:e.findReplace.texts.replaceLabel,onClick:v[12]||(v[12]=_=>e.findReplace.replaceCurrent())},Bt(e.findReplace.texts.replaceLabel),9,yS),Me("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--action",disabled:r.value,title:e.findReplace.texts.replaceAllLabel,onClick:v[13]||(v[13]=_=>e.findReplace.replaceAll())},Bt(e.findReplace.texts.replaceAllLabel),9,bS)])])):ht("",!0),a.value?(ge(),Ae("div",wS,[i.value?(ge(),Ae("span",CS)):ht("",!0),Me("span",_S,Bt(a.value),1)])):ht("",!0)],40,nS))}},kS=fn(SS,[["__scopeId","data-v-fed15bd3"]])}));xt();var ar={findPlaceholder:"Find",findAriaLabel:"Find text",replacePlaceholder:"Replace",replaceAriaLabel:"Replace text",noResultsLabel:"No results",previousMatchLabel:"Previous match (Shift+Enter)",previousMatchAriaLabel:"Previous match",nextMatchLabel:"Next match (Enter)",nextMatchAriaLabel:"Next match",closeLabel:"Close (Escape)",closeAriaLabel:"Close find and replace",replaceLabel:"Replace",replaceAllLabel:"All",toggleReplaceLabel:"Toggle replace",toggleReplaceAriaLabel:"Toggle replace",matchCaseLabel:"Aa",matchCaseAriaLabel:"Match case",regexLabel:".*",regexAriaLabel:"Use regular expression",invalidPatternLabel:"Invalid pattern",ignoreDiacriticsLabel:"Γ€β‘a",ignoreDiacriticsAriaLabel:"Ignore diacritics"};function bM(e){if(!e)return null;const t=e.extensionStorage,n=e.storage,r=t?.Search??n?.Search;if(r?.searchIndex||r?.searchResults)return r;const o=e.extensionStorage??e.storage;if(o)for(const i of Object.keys(o)){const s=o[i];if(s&&typeof s=="object"&&"searchIndex"in s&&"searchResults"in s)return s}return null}function wM({getSurfaceManager:e,getActiveEditor:t,activeEditorRef:n,getFindReplaceConfig:r,getSuperDocUI:o}){let i=null,s=null,a=null,l=!1,u=!1;const c=ne(!1);let d=null;const h=ne(""),m=ne(""),p=ne(!1),v=ne(!1),_=ne(!1),C=ne(!1),k=ne(0),y=ne(-1),b=ne(!0),T=ne(!1),R=ne(!0),P=ne(!1),j=ne(null);let O=ar;const V=ke(()=>h.value?k.value===0?O.noResultsLabel:`${y.value+1} of ${k.value}`:""),Q=ke(()=>k.value>0),F=ke(()=>Q.value&&!T.value&&b.value);let N=null,x=null;function z(G){return typeof G?.commands?.setSearchSession=="function"}function J(){try{const G=(typeof o=="function"?o():null)?.search;return G&&typeof G.search=="function"?G:null}catch{return null}}function X(G){G&&(k.value=typeof G.total=="number"?G.total:0,y.value=typeof G.activeIndex=="number"?G.activeIndex:-1,b.value=G.canReplace===!0,j.value=G.reason==="search-invalid-pattern"?O.invalidPatternLabel:null)}function ae(){if(a){pe();return}if(s){if(!h.value){try{s.commands.clearSearchSession()}catch{}k.value=0,y.value=-1;return}try{const G=s.commands.setSearchSession(h.value,{caseSensitive:p.value,ignoreDiacritics:v.value,highlight:!0,searchModel:Ee().includeDeletedText?"raw":"visible"});k.value=G.matches.length,y.value=G.activeMatchIndex}catch{}}}function pe(){const G=a;if(G){if(!h.value){try{G.clear()}catch{}k.value=0,y.value=-1,j.value=null;return}try{X(G.search(h.value,{caseSensitive:p.value,includeDeletedText:Ee().includeDeletedText===!0,regex:_.value}))}catch{}}}function Fe(){N&&clearTimeout(N),N=setTimeout(ae,150)}Lt(h,()=>{c.value&&Fe()}),Lt(p,()=>{c.value&&ae()}),Lt(v,()=>{c.value&&ae()}),Lt(_,()=>{c.value&&ae()});let fe=!0;function ye(){if(Q.value){if(a){try{a.next(),X(a.getSnapshot())}catch{}return}if(s)try{y.value=s.commands.nextSearchMatch().activeMatchIndex}catch{}}}function le(){if(Q.value){if(a){try{a.previous(),X(a.getSnapshot())}catch{}return}if(s)try{y.value=s.commands.previousSearchMatch().activeMatchIndex}catch{}}}function Se(){if(fe&&!T.value&&Q.value){if(a){if(!b.value)return;const G=a;T.value=!0;const te=tS(G,{getCurrentSession:()=>a,applySlice:X,onSettled:()=>{T.value=!1}});let Y=null;try{Y=G.replace(m.value)}catch{}Y&&typeof Y.then=="function"?Promise.resolve(Y).then(te,te):te();return}if(s)try{const G=s.commands.replaceSearchMatch(m.value);k.value=G.matches.length,y.value=G.activeMatchIndex}catch{}}}function re(){if(fe&&!T.value&&Q.value){if(a){if(!b.value)return;const G=a;T.value=!0;const te=tS(G,{getCurrentSession:()=>a,applySlice:X,onSettled:()=>{T.value=!1}});let Y=null;try{Y=G.replaceAll(m.value)}catch{}Y&&typeof Y.then=="function"?Promise.resolve(Y).then(te,te):te();return}if(s)try{s.commands.replaceAllSearchMatches(m.value),k.value=0,y.value=-1}catch{}}}function xe(){if(a){try{X(a.getSnapshot())}catch{}return}const G=bM(s);if(!G)return;const te=G.searchResults,Y=Array.isArray(te)?te.length:0,K=G.activeMatchIndex??-1;Y!==k.value&&(k.value=Y),K!==y.value&&(y.value=K)}function $e(){st(),x=setInterval(xe,200)}function st(){N&&clearTimeout(N),N=null,x&&clearInterval(x),x=null}function At(){h.value="",m.value="",p.value=!1,v.value=!1,_.value=!1,j.value=null,C.value=!1,k.value=0,y.value=-1,b.value=!0,T.value=!1}function Ee(){const G=typeof r=="function"?r():void 0;if(G===!1||G==null)return{enabled:!1,texts:ar,replaceEnabled:!0};if(G===!0)return{enabled:!0,texts:ar,replaceEnabled:!0};const te=typeof G=="object"?G:{};if(te.component!=null&&typeof te.render=="function")throw new Error('modules.surfaces.findReplace cannot provide both "component" and "render". Use one or the other.');return{enabled:!0,texts:{findPlaceholder:te.findPlaceholder??ar.findPlaceholder,findAriaLabel:te.findAriaLabel??ar.findAriaLabel,replacePlaceholder:te.replacePlaceholder??ar.replacePlaceholder,replaceAriaLabel:te.replaceAriaLabel??ar.replaceAriaLabel,noResultsLabel:te.noResultsLabel??ar.noResultsLabel,previousMatchLabel:te.previousMatchLabel??ar.previousMatchLabel,previousMatchAriaLabel:te.previousMatchAriaLabel??ar.previousMatchAriaLabel,nextMatchLabel:te.nextMatchLabel??ar.nextMatchLabel,nextMatchAriaLabel:te.nextMatchAriaLabel??ar.nextMatchAriaLabel,closeLabel:te.closeLabel??ar.closeLabel,closeAriaLabel:te.closeAriaLabel??ar.closeAriaLabel,replaceLabel:te.replaceLabel??ar.replaceLabel,replaceAllLabel:te.replaceAllLabel??ar.replaceAllLabel,toggleReplaceLabel:te.toggleReplaceLabel??ar.toggleReplaceLabel,toggleReplaceAriaLabel:te.toggleReplaceAriaLabel??ar.toggleReplaceAriaLabel,matchCaseLabel:te.matchCaseLabel??ar.matchCaseLabel,matchCaseAriaLabel:te.matchCaseAriaLabel??ar.matchCaseAriaLabel,regexLabel:te.regexLabel??ar.regexLabel,regexAriaLabel:te.regexAriaLabel??ar.regexAriaLabel,invalidPatternLabel:te.invalidPatternLabel??ar.invalidPatternLabel,ignoreDiacriticsLabel:te.ignoreDiacriticsLabel??ar.ignoreDiacriticsLabel,ignoreDiacriticsAriaLabel:te.ignoreDiacriticsAriaLabel??ar.ignoreDiacriticsAriaLabel},replaceEnabled:te.replaceEnabled??!0,includeDeletedText:te.includeDeletedText??!1,component:te.component,props:te.props,render:te.render,resolver:te.resolver,floating:te.floating&&typeof te.floating=="object"?te.floating:void 0}}function Ge(G,te){if(typeof G.resolver=="function"){const Y=G.resolver(te);if(Y!=null&&Y.type!=="default"){if(Y.type==="none")return{suppressed:!0};if(Y.type==="custom")return{component:Y.component,props:Y.props};if(Y.type==="external")return{render:Y.render}}}return G.component!=null?{component:G.component,props:G.props}:typeof G.render=="function"?{render:G.render}:{builtin:!0}}function qe(G,te){return{findQuery:h,replaceText:m,caseSensitive:p,ignoreDiacritics:v,regex:_,showReplace:C,matchCount:k,activeMatchIndex:y,matchLabel:V,hasMatches:Q,canReplace:F,replaceCanMutate:b,replacePending:T,ignoreDiacriticsSupported:R,regexSupported:P,searchError:j,replaceEnabled:G.replaceEnabled??!0,texts:G.texts,goNext:ye,goPrev:le,replaceCurrent:Se,replaceAll:re,registerFocusFn:Y=>{d=Y},close:Y=>te(Y)}}function Z(G){return{get findQuery(){return G.findQuery.value},set findQuery(te){G.findQuery.value=te},get replaceText(){return G.replaceText.value},set replaceText(te){G.replaceText.value=te},get caseSensitive(){return G.caseSensitive.value},set caseSensitive(te){G.caseSensitive.value=te},get ignoreDiacritics(){return G.ignoreDiacritics.value},set ignoreDiacritics(te){G.ignoreDiacritics.value=te},get regex(){return G.regex.value},set regex(te){G.regex.value=te},get regexSupported(){return G.regexSupported.value},get searchError(){return G.searchError.value},get replaceCanMutate(){return G.replaceCanMutate.value},get showReplace(){return G.showReplace.value},set showReplace(te){G.showReplace.value=te},get matchCount(){return G.matchCount.value},get activeMatchIndex(){return G.activeMatchIndex.value},get matchLabel(){return G.matchLabel.value},get hasMatches(){return G.hasMatches.value},get canReplace(){return G.canReplace.value},get replacePending(){return G.replacePending.value},get ignoreDiacriticsSupported(){return G.ignoreDiacriticsSupported.value},replaceEnabled:G.replaceEnabled,texts:G.texts,goNext:G.goNext,goPrev:G.goPrev,replaceCurrent:G.replaceCurrent,replaceAll:G.replaceAll,registerFocusFn:G.registerFocusFn,close:G.close}}function S(G){if(G){if(typeof G?.commands?.clearSearchSession=="function"){try{G.commands.clearSearchSession()}catch{}return}if(a&&G===s)try{a.clear()}catch{}}}function ee(){try{if(l||!e()||!t())return!1;if(i&&c.value)return!0;const G=Ee();if(!G.enabled||Ge(G,{texts:G.texts,replaceEnabled:G.replaceEnabled??!0}).suppressed)return!1;if(!z(t())){const te=J();if(!te)return!1;try{if(te.getSnapshot?.().available!==!0)return!1}catch{return!1}}return!0}catch{return!1}}async function D(){if(l)return;const G=e();if(G){if(i&&c.value){d?.();return}if(!u){u=!0;try{const te=t();if(!te){u=!1;return}const Y=Ee();if(!Y.enabled){u=!1;return}const K=Ge(Y,{texts:Y.texts,replaceEnabled:Y.replaceEnabled??!0});if(K.suppressed){u=!1;return}At(),O=Y.texts,fe=Y.replaceEnabled??!0;const be={placement:"top-right",autoFocus:!0,width:420,...Y.floating??{}};if(s&&s!==te&&S(s),s=te,a=z(te)?null:J(),R.value=!a,P.value=!!a,a)try{X(a.getSnapshot())}catch{}d=null;let me=()=>{};const Ce=qe(Y,He=>me(He));let Pe;if(K.component)Pe=G.open({mode:"floating",ariaLabel:Y.texts.findAriaLabel,closeOnEscape:!0,floating:be,component:Wr(K.component),props:{...K.props,findReplace:Ce}});else if(K.render){const He=K.render;Pe=G.open({mode:"floating",ariaLabel:Y.texts.findAriaLabel,closeOnEscape:!0,floating:be,render:Ct=>He({container:Ct.container,findReplace:Z(Ce),resolve:Ct.resolve,close:Ct.close,surfaceId:Ct.surfaceId,mode:Ct.mode})})}else{let He;try{He=(await Promise.resolve().then(()=>(yM(),vM))).default}catch{u=!1;return}if(l||i&&c.value){u=!1;return}const Ct=t()||te;s!==Ct&&(S(s),s=Ct,a=z(Ct)?null:J(),R.value=!a),Pe=G.open({mode:"floating",ariaLabel:Y.texts.findAriaLabel,component:Wr(He),closeOnEscape:!0,floating:be,props:{findReplace:Ce}})}me=He=>Pe.close(He??"programmatic"),i=Pe,c.value=!0,u=!1,$e();const it=Pe.id;Pe.result.then(()=>{i?.id===it?(st(),S(s),i=null,c.value=!1,d=null):S(te!==s?te:null)})}catch(te){throw u=!1,te}}}}function U(){i&&i.close("programmatic")}n&&Lt(n,(G,te)=>{!c.value||!i||G!==te&&(S(te),U())});function H(){l=!0,st(),U(),s=null,a=null,d=null}return{open:D,close:U,isOpen:c,wouldOpen:ee,destroy:H}}var pf=null;function p0(e){e!=null&&(pf=e)}function CM(e){pf===e&&(pf=null)}function _M(e){return pf===null||pf===e}function SM(e,{focusInside:t,owner:n}){if(e.defaultPrevented)return!1;if(t)return!0;const r=document.activeElement;return(!r||r===document.body||r===document.documentElement)&&_M(n)}var kM=/^(https?|mailto|tel):/i,AM=/^(javascript|data|vbscript):/i,IM=/^[a-z][a-z0-9+.-]*:/i;function EM(e){if(typeof e!="string")return null;const t=e.trim();return t?t.startsWith("#")?{href:t}:AM.test(t)?null:IM.test(t)?kM.test(t)?{href:t}:null:{href:t}:null}var xM='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M0 64C0 46.3 14.3 32 32 32l48 0 16 0 128 0c70.7 0 128 57.3 128 128c0 31.3-11.3 60.1-30 82.3c37.1 22.4 62 63.1 62 109.7c0 70.7-57.3 128-128 128L96 480l-16 0-48 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l16 0 0-160L48 96 32 96C14.3 96 0 81.7 0 64zM224 224c35.3 0 64-28.7 64-64s-28.7-64-64-64L112 96l0 128 112 0zM112 288l0 128 144 0c35.3 0 64-28.7 64-64s-28.7-64-64-64l-32 0-112 0z"/></svg>',TM='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M128 64c0-17.7 14.3-32 32-32l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-58.7 0L160 416l64 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l58.7 0L224 96l-64 0c-17.7 0-32-14.3-32-32z"/></svg>',RM='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M16 64c0-17.7 14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 53 43 96 96 96s96-43 96-96l0-128-16 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 88.4-71.6 160-160 160s-160-71.6-160-160L64 96 48 96C30.3 96 16 81.7 16 64zM0 448c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32z"/></svg>',AS='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M40 48C26.7 48 16 58.7 16 72l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24L40 48zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM16 232l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24l-48 0c-13.3 0-24 10.7-24 24zM40 368c-13.3 0-24 10.7-24 24l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24l-48 0z"/></svg>',MM=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc. (bullet shapes modified)--><path fill-rule="evenodd" d="M192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM64 48 A48 48 0 1 0 64 144 A48 48 0 1 0 64 48 Z M64 68 A28 28 0 1 1 64 124 A28 28 0 1 1 64 68 Z M64 208 A48 48 0 1 0 64 304 A48 48 0 1 0 64 208 Z M64 228 A28 28 0 1 1 64 284 A28 28 0 1 1 64 228 Z M64 368 A48 48 0 1 0 64 464 A48 48 0 1 0 64 368 Z M64 388 A28 28 0 1 1 64 444 A28 28 0 1 1 64 388 Z"/></svg>
|
|
15
15
|
`,LM=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc. (bullet shapes modified)--><path d="M192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM16 48 L112 48 L112 144 L16 144 Z M16 208 L112 208 L112 304 L16 304 Z M16 368 L112 368 L112 464 L16 464 Z"/></svg>
|
|
16
16
|
`,PM='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"/></svg>',DM=`<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
17
17
|
<g clip-path="url(#clip0_0_1)">
|
|
@@ -99,10 +99,10 @@ js: import "konva/skia-backend";
|
|
|
99
99
|
`,wk=()=>{if(typeof document>"u")throw new Error(ED)},Ui=class oI{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new oI(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const n=this.m;return{x:n[0]*t.x+n[2]*t.y+n[4],y:n[1]*t.x+n[3]*t.y+n[5]}}translate(t,n){return this.m[4]+=this.m[0]*t+this.m[2]*n,this.m[5]+=this.m[1]*t+this.m[3]*n,this}scale(t,n){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=n,this.m[3]*=n,this}rotate(t){const n=Math.cos(t),r=Math.sin(t),o=this.m[0]*n+this.m[2]*r,i=this.m[1]*n+this.m[3]*r,s=this.m[0]*-r+this.m[2]*n,a=this.m[1]*-r+this.m[3]*n;return this.m[0]=o,this.m[1]=i,this.m[2]=s,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,n){const r=this.m[0]+this.m[2]*n,o=this.m[1]+this.m[3]*n,i=this.m[2]+this.m[0]*t,s=this.m[3]+this.m[1]*t;return this.m[0]=r,this.m[1]=o,this.m[2]=i,this.m[3]=s,this}multiply(t){const n=this.m[0]*t.m[0]+this.m[2]*t.m[1],r=this.m[1]*t.m[0]+this.m[3]*t.m[1],o=this.m[0]*t.m[2]+this.m[2]*t.m[3],i=this.m[1]*t.m[2]+this.m[3]*t.m[3],s=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=n,this.m[1]=r,this.m[2]=o,this.m[3]=i,this.m[4]=s,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),n=this.m[3]*t,r=-this.m[1]*t,o=-this.m[2]*t,i=this.m[0]*t,s=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=n,this.m[1]=r,this.m[2]=o,this.m[3]=i,this.m[4]=s,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],n=this.m[1],r=this.m[2],o=this.m[3],i=this.m[4],s=this.m[5],a=t*o-n*r,l={x:i,y:s,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(t!=0||n!=0){const u=Math.sqrt(t*t+n*n);l.rotation=n>0?Math.acos(t/u):-Math.acos(t/u),l.scaleX=u,l.scaleY=a/u,l.skewX=(t*r+n*o)/a,l.skewY=0}else if(r!=0||o!=0){const u=Math.sqrt(r*r+o*o);l.rotation=Math.PI/2-(o>0?Math.acos(-r/u):-Math.acos(r/u)),l.scaleX=a/u,l.scaleY=u,l.skewX=0,l.skewY=(t*r+n*o)/a}return l.rotation=Ie._getRotation(l.rotation),l}},xD="[object Array]",TD="[object Number]",RD="[object String]",MD="[object Boolean]",LD=Math.PI/180,PD=180/Math.PI,yf="#",DD="",OD="0",FD="Konva warning: ",Ck="Konva error: ",ND="rgb(",S0={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},BD=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,Up=[],bf=null,zD=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(e){setTimeout(e,16)};const Ie={_isElement(e){return!!(e&&e.nodeType==1)},_isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},_isPlainObject(e){return!!e&&e.constructor===Object},_isArray(e){return Object.prototype.toString.call(e)===xD},_isNumber(e){return Object.prototype.toString.call(e)===TD&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===RD},_isBoolean(e){return Object.prototype.toString.call(e)===MD},isObject(e){return e instanceof Object},isValidSelector(e){if(typeof e!="string")return!1;const t=e[0];return t==="#"||t==="."||t===t.toUpperCase()},_sign(e){return e===0||e>0?1:-1},requestAnimFrame(e){Up.push(e),Up.length===1&&zD(function(){const t=Up;Up=[],t.forEach(function(n){n()})})},createCanvasElement(){wk();const e=document.createElement("canvas");try{e.style=e.style||{}}catch{}return e},createImageElement(){return wk(),document.createElement("img")},_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){const n=Ie.createImageElement();n.onload=function(){t(n)},n.src=e},_rgbToHex(e,t,n){return((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)},_hexToRgb(e){e=e.replace(yf,DD);const t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:t&255}},getRandomColor(){let e=(Math.random()*16777215<<0).toString(16);for(;e.length<6;)e=OD+e;return yf+e},isCanvasFarblingActive(){if(bf!==null)return bf;if(typeof document>"u")return bf=!1,!1;const e=this.createCanvasElement();e.width=10,e.height=10;const t=e.getContext("2d",{willReadFrequently:!0});t.clearRect(0,0,10,10),t.fillStyle="#282828",t.fillRect(0,0,10,10);const n=t.getImageData(0,0,10,10).data;let r=!1;for(let o=0;o<100;o++)if(n[o*4]!==40||n[o*4+1]!==40||n[o*4+2]!==40||n[o*4+3]!==255){r=!0;break}return bf=r,this.releaseCanvas(e),bf},getHitColor(){const e=this.getRandomColor();return this.isCanvasFarblingActive()?this.getSnappedHexColor(e):e},getHitColorKey(e,t,n){return this.isCanvasFarblingActive()&&(e=Math.round(e/5)*5,t=Math.round(t/5)*5,n=Math.round(n/5)*5),yf+this._rgbToHex(e,t,n)},getSnappedHexColor(e){const t=this._hexToRgb(e);return yf+this._rgbToHex(Math.round(t.r/5)*5,Math.round(t.g/5)*5,Math.round(t.b/5)*5)},getRGB(e){let t;return e in S0?(t=S0[e],{r:t[0],g:t[1],b:t[2]}):e[0]===yf?this._hexToRgb(e.substring(1)):e.substr(0,4)===ND?(t=BD.exec(e.replace(/ /g,"")),{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}):{r:0,g:0,b:0}},colorToRGBA(e){return e=e||"black",Ie._namedColorToRBA(e)||Ie._hex3ColorToRGBA(e)||Ie._hex4ColorToRGBA(e)||Ie._hex6ColorToRGBA(e)||Ie._hex8ColorToRGBA(e)||Ie._rgbColorToRGBA(e)||Ie._rgbaColorToRGBA(e)||Ie._hslColorToRGBA(e)},_namedColorToRBA(e){const t=S0[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:1}:null},_rgbColorToRGBA(e){if(e.indexOf("rgb(")===0){e=e.match(/rgb\(([^)]+)\)/)[1];const t=e.split(/ *, */).map(Number);return{r:t[0],g:t[1],b:t[2],a:1}}},_rgbaColorToRGBA(e){if(e.indexOf("rgba(")===0){e=e.match(/rgba\(([^)]+)\)/)[1];const t=e.split(/ *, */).map((n,r)=>n.slice(-1)==="%"?r===3?parseInt(n)/100:parseInt(n)/100*255:Number(n));return{r:t[0],g:t[1],b:t[2],a:t[3]}}},_hex8ColorToRGBA(e){if(e[0]==="#"&&e.length===9)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if(e[0]==="#"&&e.length===7)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if(e[0]==="#"&&e.length===5)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if(e[0]==="#"&&e.length===4)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(e)){const[t,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e),r=Number(n[0])/360,o=Number(n[1])/100,i=Number(n[2])/100;let s,a,l;if(o===0)return l=i*255,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};i<.5?s=i*(1+o):s=i+o-i*o;const u=2*i-s,c=[0,0,0];for(let d=0;d<3;d++)a=r+1/3*-(d-1),a<0&&a++,a>1&&a--,6*a<1?l=u+(s-u)*6*a:2*a<1?l=s:3*a<2?l=u+(s-u)*(2/3-a)*6:l=u,c[d]=l*255;return{r:Math.round(c[0]),g:Math.round(c[1]),b:Math.round(c[2]),a:1}}},haveIntersection(e,t){return!(t.x>e.x+e.width||t.x+t.width<e.x||t.y>e.y+e.height||t.y+t.height<e.y)},cloneObject(e){const t={};for(const n in e)this._isPlainObject(e[n])?t[n]=this.cloneObject(e[n]):this._isArray(e[n])?t[n]=this.cloneArray(e[n]):t[n]=e[n];return t},cloneArray(e){return e.slice(0)},degToRad(e){return e*LD},radToDeg(e){return e*PD},_degToRad(e){return Ie.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),Ie.degToRad(e)},_radToDeg(e){return Ie.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),Ie.radToDeg(e)},_getRotation(e){return bt.angleDeg?Ie.radToDeg(e):e},_capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)},throw(e){throw new Error(Ck+e)},error(e){console.error(Ck+e)},warn(e){bt.showWarnings&&console.warn(FD+e)},each(e,t){for(const n in e)t(n,e[n])},_inRange(e,t,n){return t<=e&&e<n},_getProjectionToSegment(e,t,n,r,o,i){let s,a,l;const u=(e-n)*(e-n)+(t-r)*(t-r);if(u==0)s=e,a=t,l=(o-n)*(o-n)+(i-r)*(i-r);else{const c=((o-e)*(n-e)+(i-t)*(r-t))/u;c<0?(s=e,a=t,l=(e-o)*(e-o)+(t-i)*(t-i)):c>1?(s=n,a=r,l=(n-o)*(n-o)+(r-i)*(r-i)):(s=e+c*(n-e),a=t+c*(r-t),l=(s-o)*(s-o)+(a-i)*(a-i))}return[s,a,l]},_getProjectionToLine(e,t,n){const r=Ie.cloneObject(e);let o=Number.MAX_VALUE;return t.forEach(function(i,s){if(!n&&s===t.length-1)return;const a=t[(s+1)%t.length],l=Ie._getProjectionToSegment(i.x,i.y,a.x,a.y,e.x,e.y),u=l[0],c=l[1],d=l[2];d<o&&(r.x=u,r.y=c,o=d)}),r},_prepareArrayForTween(e,t,n){const r=[],o=[];if(e.length>t.length){const s=t;t=e,e=s}for(let s=0;s<e.length;s+=2)r.push({x:e[s],y:e[s+1]});for(let s=0;s<t.length;s+=2)o.push({x:t[s],y:t[s+1]});const i=[];return o.forEach(function(s){const a=Ie._getProjectionToLine(s,r,n);i.push(a.x),i.push(a.y)}),i},_prepareToStringify(e){let t;e.visitedByCircularReferenceRemoval=!0;for(const n in e)if(e.hasOwnProperty(n)&&e[n]&&typeof e[n]=="object"){if(t=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||Ie._isElement(e[n]))if(t.configurable)delete e[n];else return null;else if(Ie._prepareToStringify(e[n])===null)if(t.configurable)delete e[n];else return null}return delete e.visitedByCircularReferenceRemoval,e},_assign(e,t){for(const n in t)e[n]=t[n];return e},_getFirstPointerId(e){return e.touches?e.changedTouches[0].identifier:e.pointerId||999},releaseCanvas(...e){bt.releaseCanvasOnDestroy&&e.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(e,t,n,r){let o=t<0?t:0,i=n<0?n:0;t=Math.abs(t),n=Math.abs(n);let s=0,a=0,l=0,u=0;typeof r=="number"?s=a=l=u=Math.min(r,t/2,n/2):(s=Math.min(r[0]||0,t/2,n/2),a=Math.min(r[1]||0,t/2,n/2),u=Math.min(r[2]||0,t/2,n/2),l=Math.min(r[3]||0,t/2,n/2)),e.moveTo(o+s,i),e.lineTo(o+t-a,i),e.arc(o+t-a,i+a,a,Math.PI*3/2,0,!1),e.lineTo(o+t,i+n-u),e.arc(o+t-u,i+n-u,u,0,Math.PI/2,!1),e.lineTo(o+l,i+n),e.arc(o+l,i+n-l,l,Math.PI/2,Math.PI,!1),e.lineTo(o,i+s),e.arc(o+s,i+s,s,Math.PI,Math.PI*3/2,!1)},drawRoundedPolygonPath(e,t,n,r,o){r=Math.abs(r);for(let i=0;i<n;i++){const s=t[(i-1+n)%n],a=t[i],l=t[(i+1)%n],u={x:a.x-s.x,y:a.y-s.y},c={x:l.x-a.x,y:l.y-a.y},d=Math.hypot(u.x,u.y),h=Math.hypot(c.x,c.y);let m;typeof o=="number"?m=o:m=i<o.length?o[i]:0,m=r*Math.cos(Math.PI/n)*Math.min(1,m/r*2);const p={x:u.x/d,y:u.y/d},v={x:c.x/h,y:c.y/h},_={x:a.x-p.x*m,y:a.y-p.y*m},C={x:a.x+v.x*m,y:a.y+v.y*m};i===0?e.moveTo(_.x,_.y):e.lineTo(_.x,_.y),e.arcTo(a.x,a.y,C.x,C.y,m)}}};function VD(e){const t=[],n=e.length,r=Ie;for(let o=0;o<n;o++){let i=e[o];r._isNumber(i)?i=Math.round(i*1e3)/1e3:r._isString(i)||(i=i+""),t.push(i)}return t}var _k=",",HD="(",jD=")",UD="([",GD="])",WD=";",KD="()",qD="=",Sk=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],YD=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"],XD=100,Gp=null;function kk(){if(Gp!==null)return Gp;try{const e=Ie.createCanvasElement().getContext("2d");return e?!!e&&"filter"in e:(Gp=!1,!1)}catch{return Gp=!1,!1}}var Wp=class{constructor(e){this.canvas=e,bt.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,t){let n=this.traceArr,r=n.length,o="",i,s,a,l;for(i=0;i<r;i++)s=n[i],a=s.method,a?(l=s.args,o+=a,e?o+=KD:Ie._isArray(l[0])?o+=UD+l.join(_k)+GD:(t&&(l=l.map(u=>typeof u=="number"?Math.floor(u):u)),o+=HD+l.join(_k)+jD)):(o+=s.property,e||(o+=qD+s.val)),o+=WD;return o}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=XD&&t.shift()}reset(){const e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){const t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){const t=e.attrs.lineCap;t&&this.setAttr("lineCap",t)}_applyOpacity(e){const t=e.getAbsoluteOpacity();t!==1&&this.setAttr("globalAlpha",t)}_applyLineJoin(e){const t=e.attrs.lineJoin;t&&this.setAttr("lineJoin",t)}_applyMiterLimit(e){const t=e.attrs.miterLimit;t!=null&&this.setAttr("miterLimit",t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,o,i){this._context.arc(e,t,n,r,o,i)}arcTo(e,t,n,r,o){this._context.arcTo(e,t,n,r,o)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,o,i){this._context.bezierCurveTo(e,t,n,r,o,i)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,t){const n=arguments;if(n.length===2)return this._context.createImageData(e,t);if(n.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,o,i){return this._context.createRadialGradient(e,t,n,r,o,i)}drawImage(e,t,n,r,o,i,s,a,l){const u=arguments,c=this._context;u.length===3?c.drawImage(e,t,n):u.length===5?c.drawImage(e,t,n,r,o):u.length===9&&c.drawImage(e,t,n,r,o,i,s,a,l)}ellipse(e,t,n,r,o,i,s,a){this._context.ellipse(e,t,n,r,o,i,s,a)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}roundRect(e,t,n,r,o){this._context.roundRect(e,t,n,r,o)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,r,o,i){this._context.setTransform(e,t,n,r,o,i)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,o,i){this._context.transform(e,t,n,r,o,i)}translate(e,t){this._context.translate(e,t)}_enableTrace(){let e=this,t=Sk.length,n=this.setAttr,r,o;const i=function(s){let a=e[s],l;e[s]=function(){return o=VD(Array.prototype.slice.call(arguments,0)),l=a.apply(e,arguments),e._trace({method:s,args:o}),l}};for(r=0;r<t;r++)i(Sk[r]);e.setAttr=function(){n.apply(e,arguments);const s=arguments[0];let a=arguments[1];(s==="shadowOffsetX"||s==="shadowOffsetY"||s==="shadowBlur")&&(a=a/this.canvas.getPixelRatio()),e._trace({property:s,val:a})}}_applyGlobalCompositeOperation(e){const t=e.attrs.globalCompositeOperation;!t||t==="source-over"||this.setAttr("globalCompositeOperation",t)}};YD.forEach(function(e){Object.defineProperty(Wp.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});var ZD=class extends Wp{constructor(e,{willReadFrequently:t=!1}={}){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:t})}_fillColor(e){const t=e.fill();this.setAttr("fillStyle",t),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){const t=e._getLinearGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fillRadialGradient(e){const t=e._getRadialGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fill(e){const t=e.fill(),n=e.getFillPriority();if(t&&n==="color"){this._fillColor(e);return}const r=e.getFillPatternImage();if(r&&n==="pattern"){this._fillPattern(e);return}const o=e.getFillLinearGradientColorStops();if(o&&n==="linear-gradient"){this._fillLinearGradient(e);return}const i=e.getFillRadialGradientColorStops();if(i&&n==="radial-gradient"){this._fillRadialGradient(e);return}t?this._fillColor(e):r?this._fillPattern(e):o?this._fillLinearGradient(e):i&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint(),r=e.getStrokeLinearGradientColorStops(),o=this.createLinearGradient(t.x,t.y,n.x,n.y);if(r){for(let i=0;i<r.length;i+=2)o.addColorStop(r[i],r[i+1]);this.setAttr("strokeStyle",o)}}_stroke(e){const t=e.dash(),n=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!n){this.save();const r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),e.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),n||this.restore()}}_applyShadow(e){var t,n,r;const o=(t=e.getShadowRGBA())!==null&&t!==void 0?t:"black",i=(n=e.getShadowBlur())!==null&&n!==void 0?n:5,s=(r=e.getShadowOffset())!==null&&r!==void 0?r:{x:0,y:0},a=e.getAbsoluteScale(),l=this.canvas.getPixelRatio(),u=a.x*l,c=a.y*l;this.setAttr("shadowColor",o),this.setAttr("shadowBlur",i*Math.min(Math.abs(u),Math.abs(c))),this.setAttr("shadowOffsetX",s.x*u),this.setAttr("shadowOffsetY",s.y*c)}},QD=class extends Wp{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){const t=e.getStrokeScaleEnabled();if(!t){this.save();const o=this.getCanvas().getPixelRatio();this.setTransform(o,0,0,o,0,0)}this._applyLineCap(e);const n=e.hitStrokeWidth(),r=n==="auto"?e.strokeWidth():n;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),t||this.restore()}}},Kp;function JD(){if(Kp)return Kp;const e=Ie.createCanvasElement(),t=e.getContext("2d");return Kp=(function(){return(bt._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)})(),Ie.releaseCanvas(e),Kp}var k0=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1,this.pixelRatio=(e||{}).pixelRatio||bt.pixelRatio||JD(),this._canvas=Ie.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){const t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";const t=this.pixelRatio;this.getContext()._context.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";const t=this.pixelRatio;this.getContext()._context.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch{try{return this._canvas.toDataURL()}catch(r){return Ie.error("Unable to get data URL. "+r.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}},nl=class extends k0{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this.context=new ZD(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},A0=class extends k0{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new QD(this),this.setSize(e.width,e.height)}};const Pn={get isDragging(){let e=!1;return Pn._dragElements.forEach(t=>{t.dragStatus==="dragging"&&(e=!0)}),e},justDragged:!1,get node(){let e;return Pn._dragElements.forEach(t=>{e=t.node}),e},_dragElements:new Map,_drag(e){const t=[];Pn._dragElements.forEach((n,r)=>{const{node:o}=n,i=o.getStage();i.setPointersPositions(e),n.pointerId===void 0&&(n.pointerId=Ie._getFirstPointerId(e));const s=i._changedPointerPositions.find(a=>a.id===n.pointerId);if(s){if(n.dragStatus!=="dragging"){const a=o.dragDistance();if(Math.max(Math.abs(s.x-n.startPointerPos.x),Math.abs(s.y-n.startPointerPos.y))<a||(o.startDrag({evt:e}),!o.isDragging()))return}o._setDragPosition(e,n),t.push(o)}}),t.forEach(n=>{n.getStage()&&n.fire("dragmove",{type:"dragmove",target:n,evt:e},!0)})},_endDragBefore(e){const t=[];Pn._dragElements.forEach(n=>{const{node:r}=n,o=r.getStage();if(e&&o.setPointersPositions(e),!o._changedPointerPositions.find(s=>s.id===n.pointerId))return;(n.dragStatus==="dragging"||n.dragStatus==="stopped")&&(Pn.justDragged=!0,bt._mouseListenClick=!1,bt._touchListenClick=!1,bt._pointerListenClick=!1,n.dragStatus="stopped");const i=n.node.getLayer()||n.node instanceof bt.Stage&&n.node;i&&t.indexOf(i)===-1&&t.push(i)}),t.forEach(n=>{n.draw()})},_endDragAfter(e){Pn._dragElements.forEach((t,n)=>{t.dragStatus==="stopped"&&t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0),t.dragStatus!=="dragging"&&Pn._dragElements.delete(n)})}};bt.isBrowser&&(window.addEventListener("mouseup",Pn._endDragBefore,!0),window.addEventListener("touchend",Pn._endDragBefore,!0),window.addEventListener("touchcancel",Pn._endDragBefore,!0),window.addEventListener("mousemove",Pn._drag),window.addEventListener("touchmove",Pn._drag),window.addEventListener("mouseup",Pn._endDragAfter,!1),window.addEventListener("touchend",Pn._endDragAfter,!1),window.addEventListener("touchcancel",Pn._endDragAfter,!1));function rl(e){return Ie._isString(e)?'"'+e+'"':Object.prototype.toString.call(e)==="[object Number]"||Ie._isBoolean(e)?e:Object.prototype.toString.call(e)}function Ak(e){return e>255?255:e<0?0:Math.round(e)}function mt(){if(bt.isUnminified)return function(e,t){return Ie._isNumber(e)||Ie.warn(rl(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.'),e}}function qp(e){if(bt.isUnminified)return function(t,n){let r=Ie._isNumber(t),o=Ie._isArray(t)&&t.length==e;return!r&&!o&&Ie.warn(rl(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+e+")"),t}}function I0(){if(bt.isUnminified)return function(e,t){return Ie._isNumber(e)||e==="auto"||Ie.warn(rl(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".'),e}}function rc(){if(bt.isUnminified)return function(e,t){return Ie._isString(e)||Ie.warn(rl(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.'),e}}function Ik(){if(bt.isUnminified)return function(e,t){const n=Ie._isString(e),r=Object.prototype.toString.call(e)==="[object CanvasGradient]"||e&&e.addColorStop;return n||r||Ie.warn(rl(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.'),e}}function $D(){if(bt.isUnminified)return function(e,t){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(Ie._isArray(e)?e.forEach(function(r){Ie._isNumber(r)||Ie.warn('"'+t+'" attribute has non numeric element '+r+". Make sure that all elements are numbers.")}):Ie.warn(rl(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.')),e}}function Gi(){if(bt.isUnminified)return function(e,t){return e===!0||e===!1||Ie.warn(rl(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.'),e}}function eO(e){if(bt.isUnminified)return function(t,n){return t==null||Ie.isObject(t)||Ie.warn(rl(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+e),t}}var wf="get",Cf="set";const ce={addGetterSetter(e,t,n,r,o){ce.addGetter(e,t,n),ce.addSetter(e,t,r,o),ce.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){const r=wf+Ie._capitalize(t);e.prototype[r]=e.prototype[r]||function(){const o=this.attrs[t];return o===void 0?n:o}},addSetter(e,t,n,r){const o=Cf+Ie._capitalize(t);e.prototype[o]||ce.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){const o=Cf+Ie._capitalize(t);e.prototype[o]=function(i){return n&&i!==void 0&&i!==null&&(i=n.call(this,i,t)),this._setAttr(t,i),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,o){const i=n.length,s=Ie._capitalize,a=wf+s(t),l=Cf+s(t);e.prototype[a]=function(){const c={};for(let d=0;d<i;d++){const h=n[d];c[h]=this.getAttr(t+s(h))}return c};const u=eO(n);e.prototype[l]=function(c){const d=this.attrs[t];r&&(c=r.call(this,c,t)),u&&u.call(this,c,t);for(const h in c)c.hasOwnProperty(h)&&this._setAttr(t+s(h),c[h]);return c||n.forEach(h=>{this._setAttr(t+s(h),void 0)}),this._fireChangeEvent(t,d,c),o&&o.call(this),this},ce.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){const n=Ie._capitalize(t),r=Cf+n,o=wf+n;e.prototype[t]=function(){return arguments.length?(this[r](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(e,t,n,r){Ie.error("Adding deprecated "+t);const o=wf+Ie._capitalize(t),i=t+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[o]=function(){Ie.error(i);const s=this.attrs[t];return s===void 0?n:s},ce.addSetter(e,t,r,function(){Ie.error(i)}),ce.addOverloadedGetterSetter(e,t)},backCompat(e,t){Ie.each(t,function(n,r){const o=e.prototype[r],i=wf+Ie._capitalize(n),s=Cf+Ie._capitalize(n);function a(){o.apply(this,arguments),Ie.error('"'+n+'" method is deprecated and will be removed soon. Use ""'+r+'" instead.')}e.prototype[n]=a,e.prototype[i]=a,e.prototype[s]=a})},afterSetFilter(){this._filterUpToDate=!1}};function tO(e){const t=/(\w+)\(([^)]+)\)/g;let n;for(;(n=t.exec(e))!==null;){const[,r,o]=n;switch(r){case"blur":{const i=parseFloat(o.replace("px",""));return function(s){this.blurRadius(i*.5);const a=bt.Filters;a&&a.Blur&&a.Blur.call(this,s)}}case"brightness":{const i=o.includes("%")?parseFloat(o)/100:parseFloat(o);return function(s){this.brightness(i);const a=bt.Filters;a&&a.Brightness&&a.Brightness.call(this,s)}}case"contrast":{const i=parseFloat(o);return function(s){const a=100*(Math.sqrt(i)-1);this.contrast(a);const l=bt.Filters;l&&l.Contrast&&l.Contrast.call(this,s)}}case"grayscale":return function(i){const s=bt.Filters;s&&s.Grayscale&&s.Grayscale.call(this,i)};case"sepia":return function(i){const s=bt.Filters;s&&s.Sepia&&s.Sepia.call(this,i)};case"invert":return function(i){const s=bt.Filters;s&&s.Invert&&s.Invert.call(this,i)};default:Ie.warn(`CSS filter "${r}" is not supported in fallback mode. Consider using function filters for better compatibility.`);break}}return()=>{}}var Yp="absoluteOpacity",Ek="allEventListeners",ua="absoluteTransform",xk="absoluteScale",oc="canvas",nO="Change",rO="children",oO="konva",E0="listening",iO="mouseenter",sO="mouseleave",aO="pointerenter",lO="pointerleave",cO="touchenter",uO="touchleave",Tk="set",Rk="Shape",Xp=" ",Mk="stage",ol="transform",dO="Stage",x0="visible",fO=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Xp),hO=1,wt=class ih{constructor(t){this._id=hO++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){(t===ol||t===ua)&&this._cache.get(t)?this._cache.get(t).dirty=!0:t?this._cache.delete(t):this._cache.clear()}_getCache(t,n){let r=this._cache.get(t);return(r===void 0||(t===ol||t===ua)&&r.dirty===!0)&&(r=n.call(this),this._cache.set(t,r)),r}_calculate(t,n,r){if(!this._attachedDepsListeners.get(t)){const o=n.map(i=>i+"Change.konva").join(Xp);this.on(o,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,r)}_getCanvasCache(){return this._cache.get(oc)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===ua&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(oc)){const{scene:t,filter:n,hit:r}=this._cache.get(oc);Ie.releaseCanvas(t._canvas,n._canvas,r._canvas),this._cache.delete(oc)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const n=t||{};let r={};(n.x===void 0||n.y===void 0||n.width===void 0||n.height===void 0)&&(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let o=Math.ceil(n.width||r.width),i=Math.ceil(n.height||r.height),s=n.pixelRatio,a=n.x===void 0?Math.floor(r.x):n.x,l=n.y===void 0?Math.floor(r.y):n.y,u=n.offset||0,c=n.drawBorder||!1,d=n.hitCanvasPixelRatio||1;if(!o||!i){Ie.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}const h=Math.abs(Math.round(r.x)-a)>.5?1:0,m=Math.abs(Math.round(r.y)-l)>.5?1:0;o+=u*2+h,i+=u*2+m,a-=u,l-=u;const p=new nl({pixelRatio:s,width:o,height:i}),v=new nl({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),_=new A0({pixelRatio:d,width:o,height:i}),C=p.getContext(),k=_.getContext(),y=new nl({width:p.width/p.pixelRatio+Math.abs(a),height:p.height/p.pixelRatio+Math.abs(l),pixelRatio:p.pixelRatio}),b=y.getContext();return _.isCache=!0,p.isCache=!0,this._cache.delete(oc),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(p.getContext()._context.imageSmoothingEnabled=!1,v.getContext()._context.imageSmoothingEnabled=!1),C.save(),k.save(),b.save(),C.translate(-a,-l),k.translate(-a,-l),b.translate(-a,-l),y.x=a,y.y=l,this._isUnderCache=!0,this._clearSelfAndDescendantCache(Yp),this._clearSelfAndDescendantCache(xk),this.drawScene(p,this,y),this.drawHit(_,this),this._isUnderCache=!1,C.restore(),k.restore(),c&&(C.save(),C.beginPath(),C.rect(0,0,o,i),C.closePath(),C.setAttr("strokeStyle","red"),C.setAttr("lineWidth",5),C.stroke(),C.restore()),Ie.releaseCanvas(y._canvas),this._cache.set(oc,{scene:p,filter:v,hit:_,x:a,y:l}),this._requestDraw(),this}isCached(){return this._cache.has(oc)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,n){const r=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let o=1/0,i=1/0,s=-1/0,a=-1/0;const l=this.getAbsoluteTransform(n);return r.forEach(function(u){const c=l.point(u);o===void 0&&(o=s=c.x,i=a=c.y),o=Math.min(o,c.x),i=Math.min(i,c.y),s=Math.max(s,c.x),a=Math.max(a,c.y)}),{x:o,y:i,width:s-o,height:a-i}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const n=this._getCanvasCache();t.translate(n.x,n.y);const r=this._getCachedSceneCanvas(),o=r.pixelRatio;t.drawImage(r._canvas,0,0,r.width/o,r.height/o),t.restore()}_drawCachedHitCanvas(t){const n=this._getCanvasCache(),r=n.hit;t.save(),t.translate(n.x,n.y),t.drawImage(r._canvas,0,0,r.width/r.pixelRatio,r.height/r.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t=this.filters(),n=this._getCanvasCache(),r=n.scene,o=n.filter,i=o.getContext(),s,a,l,u;if(!t||t.length===0)return r;if(this._filterUpToDate)return o;let c=!0;for(let h=0;h<t.length;h++)if(typeof t[h]=="string"&&kk(),typeof t[h]!="string"||!kk()){c=!1;break}const d=r.pixelRatio;if(o.setSize(r.width/r.pixelRatio,r.height/r.pixelRatio),c){const h=t.join(" ");return i.save(),i.setAttr("filter",h),i.drawImage(r._canvas,0,0,r.getWidth()/d,r.getHeight()/d),i.restore(),this._filterUpToDate=!0,o}try{for(s=t.length,i.clear(),i.drawImage(r._canvas,0,0,r.getWidth()/d,r.getHeight()/d),a=i.getImageData(0,0,o.getWidth(),o.getHeight()),l=0;l<s;l++)u=t[l],typeof u=="string"&&(u=tO(u)),u.call(this,a),i.putImageData(a,0,0)}catch(h){Ie.error("Unable to apply filter. "+h.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}return this._filterUpToDate=!0,o}on(...t){const n=t[0],r=t[1];if(t[2],this._cache&&this._cache.delete(Ek),t.length===3)return this._delegate.apply(this,t);const o=n.split(Xp);for(let i=0;i<o.length;i++){const s=o[i].split("."),a=s[0],l=s[1]||"";this.eventListeners[a]||(this.eventListeners[a]=[]),this.eventListeners[a].push({name:l,handler:r})}return this}off(t,n){let r=(t||"").split(Xp),o=r.length,i,s,a,l,u,c;if(this._cache&&this._cache.delete(Ek),!t)for(s in this.eventListeners)this._off(s);for(i=0;i<o;i++)if(a=r[i],l=a.split("."),u=l[0],c=l[1],u)this.eventListeners[u]&&this._off(u,c,n);else for(s in this.eventListeners)this._off(s,c,n);return this}dispatchEvent(t){const n={target:this,type:t.type,evt:t};return this.fire(t.type,n),this}addEventListener(t,n){return this.on(t,function(r){n.call(this,r.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,n,r){const o=this;return this.on(t,function(i){const s=i.target.findAncestors(n,!0,o);for(let a=0;a<s.length;a++)i=Ie.cloneObject(i),i.currentTarget=s[a],r.call(s[a],i)}),this}remove(){return this.isDragging()&&this.stopDrag(),Pn._dragElements.delete(this._id),Pn._dragElements.forEach((t,n)=>{this.isAncestorOf(t.node)&&Pn._dragElements.delete(n)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(ua),this._clearSelfAndDescendantCache(Yp),this._clearSelfAndDescendantCache(xk),this._clearSelfAndDescendantCache(Mk),this._clearSelfAndDescendantCache(x0),this._clearSelfAndDescendantCache(E0)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){const n="get"+Ie._capitalize(t);return Ie._isFunction(this[n])?this[n]():this.attrs[t]}getAncestors(){let t=this.getParent(),n=[];for(;t;)n.push(t),t=t.getParent();return n}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let n,r;if(!t)return this;for(n in t)n!==rO&&(r=Tk+Ie._capitalize(n),Ie._isFunction(this[r])?this[r](t[n]):this._setAttr(n,t[n]))}),this}isListening(){return this._getCache(E0,this._isListening)}_isListening(t){if(!this.listening())return!1;const n=this.getParent();return n&&n!==t&&this!==t?n._isListening(t):!0}isVisible(){return this._getCache(x0,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const n=this.getParent();return n&&n!==t&&this!==t?n._isVisible(t):!0}shouldDrawHit(t,n=!1){if(t)return this._isVisible(t)&&this._isListening(t);const r=this.getLayer();let o=!1;Pn._dragElements.forEach(s=>{s.dragStatus==="dragging"&&(s.node.nodeType==="Stage"||s.node.getLayer()===r)&&(o=!0)});const i=!n&&!bt.hitOnDragEnabled&&(o||bt.isTransforming());return this.isListening()&&this.isVisible()&&!i}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t=this.getDepth(),n=this,r=0,o,i,s,a;function l(c){for(o=[],i=c.length,s=0;s<i;s++)a=c[s],r++,a.nodeType!==Rk&&(o=o.concat(a.getChildren().slice())),a._id===n._id&&(s=i);o.length>0&&o[0].getDepth()<=t&&l(o)}const u=this.getStage();return n.nodeType!==dO&&u&&l(u.getChildren()),r}getDepth(){let t=0,n=this.parent;for(;n;)t++,n=n.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(ol),this._clearSelfAndDescendantCache(ua)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges(()=>{this.x(t.x),this.y(t.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const n=t.getPointerPosition();if(!n)return null;const r=this.getAbsoluteTransform().copy();return r.invert(),r.point(n)}getAbsolutePosition(t){let n=!1,r=this.parent;for(;r;){if(r.isCached()){n=!0;break}r=r.parent}n&&!t&&(t=!0);const o=this.getAbsoluteTransform(t).getMatrix(),i=new Ui,s=this.offset();return i.m=o.slice(),i.translate(s.x,s.y),i.getTranslation()}setAbsolutePosition(t){const{x:n,y:r,...o}=this._clearTransform();this.attrs.x=n,this.attrs.y=r,this._clearCache(ol);const i=this._getAbsoluteTransform().copy();return i.invert(),i.translate(t.x,t.y),t={x:this.attrs.x+i.getTranslation().x,y:this.attrs.y+i.getTranslation().y},this._setTransform(o),this.setPosition({x:t.x,y:t.y}),this._clearCache(ol),this._clearSelfAndDescendantCache(ua),this}_setTransform(t){let n;for(n in t)this.attrs[n]=t[n]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let n=t.x,r=t.y,o=this.x(),i=this.y();return n!==void 0&&(o+=n),r!==void 0&&(i+=r),this.setPosition({x:o,y:i}),this}_eachAncestorReverse(t,n){let r=[],o=this.getParent(),i,s;if(!(n&&n._id===this._id)){for(r.unshift(this);o&&(!n||o._id!==n._id);)r.unshift(o),o=o.parent;for(i=r.length,s=0;s<i;s++)t(r[s])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return Ie.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1?(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return Ie.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1?(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return Ie.warn("Node has no parent. moveDown function is ignored."),!1;const t=this.index;return t>0?(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return Ie.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0?(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(t){if(!this.parent)return Ie.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&Ie.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const n=this.index;return this.parent.children.splice(n,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(Yp,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const n=this.getParent();return n&&!n._isUnderCache&&(t*=n.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t=this.getAttrs(),n,r,o,i,s;const a={attrs:{},className:this.getClassName()};for(n in t)r=t[n],s=Ie.isObject(r)&&!Ie._isPlainObject(r)&&!Ie._isArray(r),!s&&(o=typeof this[n]=="function"&&this[n],delete t[n],i=o?o.call(this):null,t[n]=r,i!==r&&(a.attrs[n]=r));return Ie._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,n,r){const o=[];n&&this._isMatch(t)&&o.push(this);let i=this.parent;for(;i;){if(i===r)return o;i._isMatch(t)&&o.push(i),i=i.parent}return o}isAncestorOf(t){return!1}findAncestor(t,n,r){return this.findAncestors(t,n,r)[0]}_isMatch(t){if(!t)return!1;if(typeof t=="function")return t(this);let n=t.replace(/ /g,"").split(","),r=n.length,o,i;for(o=0;o<r;o++)if(i=n[o],Ie.isValidSelector(i)||(Ie.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Ie.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Ie.warn("Konva is awesome, right?")),i.charAt(0)==="#"){if(this.id()===i.slice(1))return!0}else if(i.charAt(0)==="."){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(Mk,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,n={},r){return n.target=n.target||this,r?this._fireAndBubble(t,n):this._fire(t,n),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(ua,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let n;if(t)return n=new Ui,this._eachAncestorReverse(function(r){const o=r.transformsEnabled();o==="all"?n.multiply(r.getTransform()):o==="position"&&n.translate(r.x()-r.offsetX(),r.y()-r.offsetY())},t),n;{n=this._cache.get(ua)||new Ui,this.parent?this.parent.getAbsoluteTransform().copyInto(n):n.reset();const r=this.transformsEnabled();if(r==="all")n.multiply(this.getTransform());else if(r==="position"){const o=this.attrs.x||0,i=this.attrs.y||0,s=this.attrs.offsetX||0,a=this.attrs.offsetY||0;n.translate(o-s,i-a)}return n.dirty=!1,n}}getAbsoluteScale(t){let n=this;for(;n;)n._isUnderCache&&(t=n),n=n.getParent();const r=this.getAbsoluteTransform(t).decompose();return{x:r.scaleX,y:r.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(ol,this._getTransform)}_getTransform(){var t,n;const r=this._cache.get(ol)||new Ui;r.reset();const o=this.x(),i=this.y(),s=bt.getAngle(this.rotation()),a=(t=this.attrs.scaleX)!==null&&t!==void 0?t:1,l=(n=this.attrs.scaleY)!==null&&n!==void 0?n:1,u=this.attrs.skewX||0,c=this.attrs.skewY||0,d=this.attrs.offsetX||0,h=this.attrs.offsetY||0;return(o!==0||i!==0)&&r.translate(o,i),s!==0&&r.rotate(s),(u!==0||c!==0)&&r.skew(u,c),(a!==1||l!==1)&&r.scale(a,l),(d!==0||h!==0)&&r.translate(-1*d,-1*h),r.dirty=!1,r}clone(t){let n=Ie.cloneObject(this.attrs),r,o,i,s,a;for(r in t)n[r]=t[r];const l=new this.constructor(n);for(r in this.eventListeners)for(o=this.eventListeners[r],i=o.length,s=0;s<i;s++)a=o[s],a.name.indexOf(oO)<0&&(l.eventListeners[r]||(l.eventListeners[r]=[]),l.eventListeners[r].push(a));return l}_toKonvaCanvas(t){t=t||{};const n=this.getClientRect(),r=this.getStage(),o=t.x!==void 0?t.x:Math.floor(n.x),i=t.y!==void 0?t.y:Math.floor(n.y),s=t.pixelRatio||1,a=new nl({width:t.width||Math.ceil(n.width)||(r?r.width():0),height:t.height||Math.ceil(n.height)||(r?r.height():0),pixelRatio:s}),l=a.getContext(),u=new nl({width:a.width/a.pixelRatio+Math.abs(o),height:a.height/a.pixelRatio+Math.abs(i),pixelRatio:a.pixelRatio});return t.imageSmoothingEnabled===!1&&(l._context.imageSmoothingEnabled=!1),l.save(),(o||i)&&l.translate(-1*o,-1*i),this.drawScene(a,void 0,u),l.restore(),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){t=t||{};const n=t.mimeType||null,r=t.quality||null,o=this._toKonvaCanvas(t).toDataURL(n,r);return t.callback&&t.callback(o),o}toImage(t){return new Promise((n,r)=>{try{const o=t?.callback;o&&delete t.callback,Ie._urlToImage(this.toDataURL(t),function(i){n(i),o?.(i)})}catch(o){r(o)}})}toBlob(t){return new Promise((n,r)=>{try{const o=t?.callback;o&&delete t.callback,this.toCanvas(t).toBlob(i=>{n(i),o?.(i)},t?.mimeType,t?.quality)}catch(o){r(o)}})}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance!==void 0?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():bt.dragDistance}_off(t,n,r){let o=this.eventListeners[t],i,s,a;for(i=0;i<o.length;i++)if(s=o[i].name,a=o[i].handler,(s!=="konva"||n==="konva")&&(!n||s===n)&&(!r||r===a)){if(o.splice(i,1),o.length===0){delete this.eventListeners[t];break}i--}}_fireChangeEvent(t,n,r){this._fire(t+nO,{oldVal:n,newVal:r})}addName(t){if(!this.hasName(t)){const n=this.name(),r=n?n+" "+t:t;this.name(r)}return this}hasName(t){if(!t)return!1;const n=this.name();return n?(n||"").split(/\s/g).indexOf(t)!==-1:!1}removeName(t){const n=(this.name()||"").split(/\s/g),r=n.indexOf(t);return r!==-1&&(n.splice(r,1),this.name(n.join(" "))),this}setAttr(t,n){const r=this[Tk+Ie._capitalize(t)];return Ie._isFunction(r)?r.call(this,n):this._setAttr(t,n),this}_requestDraw(){if(bt.autoDrawEnabled){const t=this.getLayer()||this.getStage();t?.batchDraw()}}_setAttr(t,n){const r=this.attrs[t];r===n&&!Ie.isObject(n)||(n==null?delete this.attrs[t]:this.attrs[t]=n,this._shouldFireChangeEvents&&this._fireChangeEvent(t,r,n),this._requestDraw())}_setComponentAttr(t,n,r){let o;r!==void 0&&(o=this.attrs[t],o||(this.attrs[t]=this.getAttr(t)),this.attrs[t][n]=r,this._fireChangeEvent(t,o,r))}_fireAndBubble(t,n,r){n&&this.nodeType===Rk&&(n.target=this);const o=[iO,sO,aO,lO,cO,uO];if(!(o.indexOf(t)!==-1&&(r&&(this===r||this.isAncestorOf&&this.isAncestorOf(r))||this.nodeType==="Stage"&&!r))){this._fire(t,n);const i=o.indexOf(t)!==-1&&r&&r.isAncestorOf&&r.isAncestorOf(this)&&!r.isAncestorOf(this.parent);(n&&!n.cancelBubble||!n)&&this.parent&&this.parent.isListening()&&!i&&(r&&r.parent?this._fireAndBubble.call(this.parent,t,n,r):this._fireAndBubble.call(this.parent,t,n))}}_getProtoListeners(t){var n,r;const{nodeType:o}=this,i=ih.protoListenerMap.get(o)||{};let s=i?.[t];if(s===void 0){s=[];let a=Object.getPrototypeOf(this);for(;a;){const l=(r=(n=a.eventListeners)===null||n===void 0?void 0:n[t])!==null&&r!==void 0?r:[];s.push(...l),a=Object.getPrototypeOf(a)}i[t]=s,ih.protoListenerMap.set(o,i)}return s}_fire(t,n){n=n||{},n.currentTarget=this,n.type=t;const r=this._getProtoListeners(t);if(r){const i=r.slice();for(let s=0;s<i.length;s++)i[s].handler.call(this,n)}const o=this.eventListeners[t];if(o){const i=o.slice(),s=i.length;for(let l=0;l<i.length;l++)i[l].handler.call(this,n);const a=this.eventListeners[t];if(a)for(let l=s;l<a.length;l++)a[l].handler.call(this,n)}}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const n=t?t.pointerId:void 0,r=this.getStage(),o=this.getAbsolutePosition();if(!r)return;const i=r._getPointerById(n)||r._changedPointerPositions[0]||o;Pn._dragElements.set(this._id,{node:this,startPointerPos:i,offset:{x:i.x-o.x,y:i.y-o.y},dragStatus:"ready",pointerId:n,startEvent:t})}startDrag(t,n=!0){Pn._dragElements.has(this._id)||this._createDragElement(t);const r=Pn._dragElements.get(this._id);r.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:r.startEvent&&r.startEvent.evt||t&&t.evt},n)}_setDragPosition(t,n){const r=this.getStage()._getPointerById(n.pointerId);if(!r)return;let o={x:r.x-n.offset.x,y:r.y-n.offset.y};const i=this.dragBoundFunc();if(i!==void 0){const s=i.call(this,o,t);s?o=s:Ie.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}(!this._lastPos||this._lastPos.x!==o.x||this._lastPos.y!==o.y)&&(this.setAbsolutePosition(o),this._requestDraw()),this._lastPos=o}stopDrag(t){const n=Pn._dragElements.get(this._id);n&&(n.dragStatus="stopped"),Pn._endDragBefore(t),Pn._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=Pn._dragElements.get(this._id);return t?t.dragStatus==="dragging":!1}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(t){if(!(t.evt.button===void 0||bt.dragButtons.indexOf(t.evt.button)>=0)||this.isDragging())return;let n=!1;Pn._dragElements.forEach(r=>{this.isAncestorOf(r.node)&&(n=!0)}),n||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const t=Pn._dragElements.get(this._id),n=t&&t.dragStatus==="dragging",r=t&&t.dragStatus==="ready";n?this.stopDrag():r&&Pn._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const n=this.getStage();if(!n)return!1;const r={x:-t.x,y:-t.y,width:n.width()+2*t.x,height:n.height()+2*t.y};return Ie.haveIntersection(r,this.getClientRect())}static create(t,n){return Ie._isString(t)&&(t=JSON.parse(t)),this._createNode(t,n)}static _createNode(t,n){let r=ih.prototype.getClassName.call(t),o=t.children,i,s,a;n&&(t.attrs.container=n),bt[r]||(Ie.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");const l=bt[r];if(i=new l(t.attrs),o)for(s=o.length,a=0;a<s;a++)i.add(ih._createNode(o[a]));return i}};wt.protoListenerMap=new Map,wt.prototype.nodeType="Node",wt.prototype._attrsAffectingSize=[],wt.prototype.eventListeners={},wt.prototype.on(fO,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(ol),this._clearSelfAndDescendantCache(ua)}),wt.prototype.on("visibleChange.konva",function(){this._clearSelfAndDescendantCache(x0)}),wt.prototype.on("listeningChange.konva",function(){this._clearSelfAndDescendantCache(E0)}),wt.prototype.on("opacityChange.konva",function(){this._clearSelfAndDescendantCache(Yp)});var Qn=ce.addGetterSetter;Qn(wt,"zIndex"),Qn(wt,"absolutePosition"),Qn(wt,"position"),Qn(wt,"x",0,mt()),Qn(wt,"y",0,mt()),Qn(wt,"globalCompositeOperation","source-over",rc()),Qn(wt,"opacity",1,mt()),Qn(wt,"name","",rc()),Qn(wt,"id","",rc()),Qn(wt,"rotation",0,mt()),ce.addComponentsGetterSetter(wt,"scale",["x","y"]),Qn(wt,"scaleX",1,mt()),Qn(wt,"scaleY",1,mt()),ce.addComponentsGetterSetter(wt,"skew",["x","y"]),Qn(wt,"skewX",0,mt()),Qn(wt,"skewY",0,mt()),ce.addComponentsGetterSetter(wt,"offset",["x","y"]),Qn(wt,"offsetX",0,mt()),Qn(wt,"offsetY",0,mt()),Qn(wt,"dragDistance",void 0,mt()),Qn(wt,"width",0,mt()),Qn(wt,"height",0,mt()),Qn(wt,"listening",!0,Gi()),Qn(wt,"preventDefault",!0,Gi()),Qn(wt,"filters",void 0,function(e){return this._filterUpToDate=!1,e}),Qn(wt,"visible",!0,Gi()),Qn(wt,"transformsEnabled","all",rc()),Qn(wt,"size"),Qn(wt,"dragBoundFunc"),Qn(wt,"draggable",!1,Gi()),ce.backCompat(wt,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var pi=class extends wt{constructor(){super(...arguments),this.children=[]}getChildren(e){const t=this.children||[];return e?t.filter(e):t}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(let n=0;n<e.length;n++)this.add(e[n]);return this}const t=e[0];return t.getParent()?(t.moveTo(this),this):(this._validateAdd(t),t.index=this.getChildren().length,t.parent=this,t._clearCaches(),this.getChildren().push(t),this._fire("add",{child:t}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){const t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){const n=[];return this._descendants(r=>{const o=r._isMatch(e);return o&&n.push(r),!!(o&&t)}),n}_descendants(e){let t=!1;const n=this.getChildren();for(const r of n){if(t=e(r),t)return!0;if(r.hasChildren()&&(t=r._descendants(e),t))return!0}return!1}toObject(){const e=wt.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){let t=e.getParent();for(;t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){const t=wt.prototype.clone.call(this,e);return this.getChildren().forEach(function(n){t.add(n.clone())}),t}getAllIntersections(e){const t=[];return this.find("Shape").forEach(n=>{n.isVisible()&&n.intersects(e)&&t.push(n)}),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),!this.isCached()&&((t=this.children)===null||t===void 0||t.forEach(function(n){n._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(t,n){t.index=n}),this._requestDraw()}drawScene(e,t,n){const r=this.getLayer(),o=e||r&&r.getCanvas(),i=o&&o.getContext(),s=this._getCanvasCache(),a=s&&s.scene,l=o&&o.isCache;if(!this.isVisible()&&!l)return this;if(a){i.save();const u=this.getAbsoluteTransform(t).getMatrix();i.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedSceneCanvas(i),i.restore()}else this._drawChildren("drawScene",o,t,n);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;const n=this.getLayer(),r=e||n&&n.hitCanvas,o=r&&r.getContext(),i=this._getCanvasCache();if(i&&i.hit){o.save();const s=this.getAbsoluteTransform(t).getMatrix();o.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._drawCachedHitCanvas(o),o.restore()}else this._drawChildren("drawHit",r,t);return this}_drawChildren(e,t,n,r){var o;const i=t&&t.getContext(),s=this.clipWidth(),a=this.clipHeight(),l=this.clipFunc(),u=typeof s=="number"&&typeof a=="number"||l,c=n===this;if(u){i.save();const h=this.getAbsoluteTransform(n);let m=h.getMatrix();i.transform(m[0],m[1],m[2],m[3],m[4],m[5]),i.beginPath();let p;if(l)p=l.call(this,i,this);else{const v=this.clipX(),_=this.clipY();i.rect(v||0,_||0,s,a)}i.clip.apply(i,p),m=h.copy().invert().getMatrix(),i.transform(m[0],m[1],m[2],m[3],m[4],m[5])}const d=!c&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";d&&(i.save(),i._applyGlobalCompositeOperation(this)),(o=this.children)===null||o===void 0||o.forEach(function(h){h[e](t,n,r)}),d&&i.restore(),u&&i.restore()}getClientRect(e={}){var t;const n=e.skipTransform,r=e.relativeTo;let o,i,s,a,l={x:1/0,y:1/0,width:0,height:0};const u=this;(t=this.children)===null||t===void 0||t.forEach(function(h){if(!h.visible())return;const m=h.getClientRect({relativeTo:u,skipShadow:e.skipShadow,skipStroke:e.skipStroke});m.width===0&&m.height===0||(o===void 0?(o=m.x,i=m.y,s=m.x+m.width,a=m.y+m.height):(o=Math.min(o,m.x),i=Math.min(i,m.y),s=Math.max(s,m.x+m.width),a=Math.max(a,m.y+m.height)))});const c=this.find("Shape");let d=!1;for(let h=0;h<c.length;h++)if(c[h]._isVisible(this)){d=!0;break}return d&&o!==void 0?l={x:o,y:i,width:s-o,height:a-i}:l={x:0,y:0,width:0,height:0},n?l:this._transformedRect(l,r)}};ce.addComponentsGetterSetter(pi,"clip",["x","y","width","height"]),ce.addGetterSetter(pi,"clipX",void 0,mt()),ce.addGetterSetter(pi,"clipY",void 0,mt()),ce.addGetterSetter(pi,"clipWidth",void 0,mt()),ce.addGetterSetter(pi,"clipHeight",void 0,mt()),ce.addGetterSetter(pi,"clipFunc");var _f=new Map,Lk=bt._global.PointerEvent!==void 0;function T0(e){return _f.get(e)}function R0(e){return{evt:e,pointerId:e.pointerId}}function Pk(e,t){return _f.get(e)===t}function Dk(e,t){Sf(e),t.getStage()&&(_f.set(e,t),Lk&&t._fire("gotpointercapture",R0(new PointerEvent("gotpointercapture"))))}function Sf(e,t){const n=_f.get(e);if(!n)return;const r=n.getStage();r&&r.content,_f.delete(e),Lk&&n._fire("lostpointercapture",R0(new PointerEvent("lostpointercapture")))}var pO="Stage",mO="string",Ok="px",gO="mouseout",Fk="mouseleave",Nk="mouseover",Bk="mouseenter",zk="mousemove",Vk="mousedown",Hk="mouseup",kf="pointermove",Af="pointerdown",gu="pointerup",If="pointercancel",vO="lostpointercapture",Zp="pointerout",Ef="pointerleave",Qp="pointerover",Jp="pointerenter",M0="contextmenu",jk="touchstart",Uk="touchend",Gk="touchmove",Wk="touchcancel",L0="wheel",yO=5,bO=[[Bk,"_pointerenter"],[Vk,"_pointerdown"],[zk,"_pointermove"],[Hk,"_pointerup"],[Fk,"_pointerleave"],[jk,"_pointerdown"],[Gk,"_pointermove"],[Uk,"_pointerup"],[Wk,"_pointercancel"],[Nk,"_pointerover"],[L0,"_wheel"],[M0,"_contextmenu"],[Af,"_pointerdown"],[kf,"_pointermove"],[gu,"_pointerup"],[If,"_pointercancel"],[Ef,"_pointerleave"],[vO,"_lostpointercapture"]],P0={mouse:{[Zp]:gO,[Ef]:Fk,[Qp]:Nk,[Jp]:Bk,[kf]:zk,[Af]:Vk,[gu]:Hk,[If]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[Zp]:"touchout",[Ef]:"touchleave",[Qp]:"touchover",[Jp]:"touchenter",[kf]:Gk,[Af]:jk,[gu]:Uk,[If]:Wk,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[Zp]:Zp,[Ef]:Ef,[Qp]:Qp,[Jp]:Jp,[kf]:kf,[Af]:Af,[gu]:gu,[If]:If,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},xf=e=>e.indexOf("pointer")>=0?"pointer":e.indexOf("touch")>=0?"touch":"mouse",vu=e=>{const t=xf(e);if(t==="pointer")return bt.pointerEventsEnabled&&P0.pointer;if(t==="touch")return P0.touch;if(t==="mouse")return P0.mouse};function Kk(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&Ie.warn("Stage does not support clipping. Please use clip for Layers or Groups."),e}var wO="Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);";const Tf=[];var $p=class extends pi{constructor(e){super(Kk(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),Tf.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{Kk(this.attrs)}),this._checkVisibility()}_validateAdd(e){const t=e.getType()==="Layer",n=e.getType()==="FastLayer";t||n||Ie.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const e=this.visible()?"":"none";this.content.style.display=e}setContainer(e){if(typeof e===mO){let t;if(e.charAt(0)==="."){const n=e.slice(1);e=document.getElementsByClassName(n)[0]}else e.charAt(0)!=="#"?t=e:t=e.slice(1),e=document.getElementById(t);if(!e)throw"Can not find container in document with id "+t}return this._setAttr("container",e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const e=this.children,t=e.length;for(let n=0;n<t;n++)e[n].clear();return this}clone(e){return e||(e={}),e.container=typeof document<"u"&&document.createElement("div"),pi.prototype.clone.call(this,e)}destroy(){super.destroy();const e=this.content;e&&Ie._isInDocument(e)&&this.container().removeChild(e);const t=Tf.indexOf(this);return t>-1&&Tf.splice(t,1),Ie.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(Ie.warn(wO),null)}_getPointerById(e){return this._pointerPositions.find(t=>t.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e={...e},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();const t=new nl({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach(function(o){if(!o.isVisible())return;const i=o._toKonvaCanvas(e);n.drawImage(i._canvas,e.x,e.y,i.getWidth()/i.getPixelRatio(),i.getHeight()/i.getPixelRatio())}),t}getIntersection(e){if(!e)return null;const t=this.children,n=t.length-1;for(let r=n;r>=0;r--){const o=t[r].getIntersection(e);if(o)return o}return null}_resizeDOM(){const e=this.width(),t=this.height();this.content&&(this.content.style.width=e+Ok,this.content.style.height=t+Ok),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach(n=>{n.setSize({width:e,height:t}),n.draw()})}add(e,...t){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.add(arguments[r]);return this}super.add(e);const n=this.children.length;return n>yO&&Ie.warn("The stage has "+n+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),e.setSize({width:this.width(),height:this.height()}),e.draw(),bt.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return Pk(e,this)}setPointerCapture(e){Dk(e,this)}releaseCapture(e){Sf(e,this)}getLayers(){return this.children}_bindContentEvents(){bt.isBrowser&&bO.forEach(([e,t])=>{this.content.addEventListener(e,n=>{this[t](n)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const t=vu(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=vu(e.type);t&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+"targetShape"];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){const t=vu(e.type),n=xf(e.type);if(!t)return;this.setPointersPositions(e);const r=this._getTargetShape(n),o=!(bt.isDragging()||bt.isTransforming())||bt.hitOnDragEnabled;r&&o?(r._fireAndBubble(t.pointerout,{evt:e}),r._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[n+"targetShape"]=null):o&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(e){const t=vu(e.type),n=xf(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(o=>{const i=this.getIntersection(o);if(Pn.justDragged=!1,bt["_"+n+"ListenClick"]=!0,!i||!i.isListening()){this[n+"ClickStartShape"]=void 0;return}bt.capturePointerEventsEnabled&&i.setPointerCapture(o.id),this[n+"ClickStartShape"]=i,i._fireAndBubble(t.pointerdown,{evt:e,pointerId:o.id}),r=!0;const s=e.type.indexOf("touch")>=0;i.preventDefault()&&e.cancelable&&s&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(e){const t=vu(e.type),n=xf(e.type);if(!t)return;const r=e.type.indexOf("touch")>=0||e.pointerType==="touch";if(bt.isDragging()&&Pn.node.preventDefault()&&e.cancelable&&r&&e.preventDefault(),this.setPointersPositions(e),!(!(bt.isDragging()||bt.isTransforming())||bt.hitOnDragEnabled))return;const o={};let i=!1;const s=this._getTargetShape(n);this._changedPointerPositions.forEach(a=>{const l=T0(a.id)||this.getIntersection(a),u=a.id,c={evt:e,pointerId:u},d=s!==l;if(d&&s&&(s._fireAndBubble(t.pointerout,{...c},l),s._fireAndBubble(t.pointerleave,{...c},l)),l){if(o[l._id])return;o[l._id]=!0}l&&l.isListening()?(i=!0,d&&(l._fireAndBubble(t.pointerover,{...c},s),l._fireAndBubble(t.pointerenter,{...c},s),this[n+"targetShape"]=l),l._fireAndBubble(t.pointermove,{...c})):s&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:u}),this[n+"targetShape"]=null)}),i||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=vu(e.type),n=xf(e.type);if(!t)return;this.setPointersPositions(e);const r=this[n+"ClickStartShape"],o=this[n+"ClickEndShape"],i={};let s=!1;this._changedPointerPositions.forEach(a=>{const l=T0(a.id)||this.getIntersection(a);if(l){if(l.releaseCapture(a.id),i[l._id])return;i[l._id]=!0}const u=a.id,c={evt:e,pointerId:u};let d=!1;bt["_"+n+"InDblClickWindow"]?(d=!0,clearTimeout(this[n+"DblTimeout"])):Pn.justDragged||(bt["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout(function(){bt["_"+n+"InDblClickWindow"]=!1},bt.dblClickWindow),l&&l.isListening()?(s=!0,this[n+"ClickEndShape"]=l,l._fireAndBubble(t.pointerup,{...c}),bt["_"+n+"ListenClick"]&&r&&r===l&&(l._fireAndBubble(t.pointerclick,{...c}),d&&o&&o===l&&l._fireAndBubble(t.pointerdblclick,{...c}))):(this[n+"ClickEndShape"]=null,s||(this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),s=!0),bt["_"+n+"ListenClick"]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:u}),d&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:u}))}),s||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),bt["_"+n+"ListenClick"]=!1,e.cancelable&&n!=="touch"&&n!=="pointer"&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(M0,{evt:e}):this._fire(M0,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(L0,{evt:e}):this._fire(L0,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=T0(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(gu,R0(e)),Sf(e.pointerId)}_lostpointercapture(e){Sf(e.pointerId)}setPointersPositions(e){const t=this._getContentPosition();let n=null,r=null;e=e||window.event,e.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,o=>{this._pointerPositions.push({id:o.identifier,x:(o.clientX-t.left)/t.scaleX,y:(o.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,o=>{this._changedPointerPositions.push({id:o.identifier,x:(o.clientX-t.left)/t.scaleX,y:(o.clientY-t.top)/t.scaleY})})):(n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:Ie._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:Ie._getFirstPointerId(e)}])}_setPointerPosition(e){Ie.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new nl({width:this.width(),height:this.height()}),this.bufferHitCanvas=new A0({pixelRatio:1,width:this.width(),height:this.height()}),!bt.isBrowser)return;const e=this.container();if(!e)throw"Stage has no container. A container is required.";e.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),e.appendChild(this.content),this._resizeDOM()}cache(){return Ie.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(e){e.batchDraw()}),this}};$p.prototype.nodeType=pO,wr($p),ce.addGetterSetter($p,"container"),bt.isBrowser&&document.addEventListener("visibilitychange",()=>{Tf.forEach(e=>{e.batchDraw()})});var qk="hasShadow",Yk="shadowRGBA",Xk="patternImage",Zk="linearGradient",Qk="radialGradient",em;function D0(){return em||(em=Ie.createCanvasElement().getContext("2d"),em)}const Rf={};function CO(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function _O(e){e.stroke()}function SO(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function kO(e){e.stroke()}function AO(){this._clearCache(qk)}function IO(){this._clearCache(Yk)}function EO(){this._clearCache(Xk)}function xO(){this._clearCache(Zk)}function TO(){this._clearCache(Qk)}var dt=class extends wt{constructor(e){super(e);let t,n=0;for(;t=Ie.getHitColor(),!(t&&!(t in Rf));)if(n++,n>=1e4){Ie.warn("Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it."),t=Ie.getRandomColor();break}this.colorKey=t,Rf[t]=this}getContext(){return Ie.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return Ie.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(qk,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(Xk,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const e=D0().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(e&&e.setTransform){const t=new Ui;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(bt.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=t.getMatrix(),r=typeof DOMMatrix>"u"?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(r)}return e}}_getLinearGradient(){return this._getCache(Zk,this.__getLinearGradient)}__getLinearGradient(){const e=this.fillLinearGradientColorStops();if(e){const t=D0(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),o=t.createLinearGradient(n.x,n.y,r.x,r.y);for(let i=0;i<e.length;i+=2)o.addColorStop(e[i],e[i+1]);return o}}_getRadialGradient(){return this._getCache(Qk,this.__getRadialGradient)}__getRadialGradient(){const e=this.fillRadialGradientColorStops();if(e){const t=D0(),n=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),o=t.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius());for(let i=0;i<e.length;i+=2)o.addColorStop(e[i],e[i+1]);return o}}getShadowRGBA(){return this._getCache(Yk,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const e=Ie.colorToRGBA(this.shadowColor());if(e)return"rgba("+e.r+","+e.g+","+e.b+","+e.a*(this.shadowOpacity()||1)+")"}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){const e=this.hitStrokeWidth();return e==="auto"?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){const t=this.getStage();if(!t)return!1;const n=t.bufferHitCanvas;return n.getContext().clear(),this.drawHit(n,void 0,!0),n.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data[3]>0}destroy(){return wt.prototype.destroy.call(this),delete Rf[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var t;if(!(!((t=this.attrs.perfectDrawEnabled)!==null&&t!==void 0)||t))return!1;const n=e||this.hasFill(),r=this.hasStroke(),o=this.getAbsoluteOpacity()!==1;if(n&&r&&o)return!0;const i=this.hasShadow(),s=this.shadowForStrokeEnabled();return!!(n&&r&&i&&s)}setStrokeHitEnabled(e){Ie.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),e?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){const e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){let t=!1,n=this.getParent();for(;n;){if(n.isCached()){t=!0;break}n=n.getParent()}const r=e.skipTransform,o=e.relativeTo||t&&this.getStage()||void 0,i=this.getSelfRect(),s=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=i.width+s,l=i.height+s,u=!e.skipShadow&&this.hasShadow(),c=u?this.shadowOffsetX():0,d=u?this.shadowOffsetY():0,h=a+Math.abs(c),m=l+Math.abs(d),p=u&&this.shadowBlur()||0,v={width:h+p*2,height:m+p*2,x:-(s/2+p)+Math.min(c,0)+i.x,y:-(s/2+p)+Math.min(d,0)+i.y};return r?v:this._transformedRect(v,o)}drawScene(e,t,n){const r=this.getLayer(),o=(e||r.getCanvas()).getContext(),i=this._getCanvasCache(),s=this.getSceneFunc(),a=this.hasShadow();let l;const u=t===this;if(!this.isVisible()&&!u)return this;if(i){o.save();const c=this.getAbsoluteTransform(t).getMatrix();return o.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!s)return this;if(o.save(),this._useBufferCanvas()){l=this.getStage();const c=n||l.bufferCanvas,d=c.getContext();n?(d.save(),d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,c.width,c.height),d.restore()):d.clear(),d.save(),d._applyLineJoin(this),d._applyMiterLimit(this);const h=this.getAbsoluteTransform(t).getMatrix();d.transform(h[0],h[1],h[2],h[3],h[4],h[5]),s.call(this,d,this),d.restore();const m=c.pixelRatio;a&&o._applyShadow(this),u||(o._applyOpacity(this),o._applyGlobalCompositeOperation(this)),o.drawImage(c._canvas,c.x||0,c.y||0,c.width/m,c.height/m)}else{if(o._applyLineJoin(this),o._applyMiterLimit(this),!u){const c=this.getAbsoluteTransform(t).getMatrix();o.transform(c[0],c[1],c[2],c[3],c[4],c[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}a&&o._applyShadow(this),s.call(this,o,this)}return o.restore(),this}drawHit(e,t,n=!1){if(!this.shouldDrawHit(t,n))return this;const r=this.getLayer(),o=e||r.hitCanvas,i=o&&o.getContext(),s=this.hitFunc()||this.sceneFunc(),a=this._getCanvasCache(),l=a&&a.hit;if(this.colorKey||Ie.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){i.save();const u=this.getAbsoluteTransform(t).getMatrix();return i.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedHitCanvas(i),i.restore(),this}if(!s)return this;if(i.save(),i._applyLineJoin(this),i._applyMiterLimit(this),this!==t){const u=this.getAbsoluteTransform(t).getMatrix();i.transform(u[0],u[1],u[2],u[3],u[4],u[5])}return s.call(this,i,this),i.restore(),this}drawHitFromCache(e=0){const t=this._getCanvasCache(),n=this._getCachedSceneCanvas(),r=t.hit,o=r.getContext(),i=r.getWidth(),s=r.getHeight();o.clear(),o.drawImage(n._canvas,0,0,i,s);try{const a=o.getImageData(0,0,i,s),l=a.data,u=l.length,c=Ie._hexToRgb(this.colorKey);for(let d=0;d<u;d+=4)l[d+3]>e?(l[d]=c.r,l[d+1]=c.g,l[d+2]=c.b,l[d+3]=255):l[d+3]=0;o.putImageData(a,0,0)}catch(a){Ie.error("Unable to draw hit graph from cached scene canvas. "+a.message)}return this}hasPointerCapture(e){return Pk(e,this)}setPointerCapture(e){Dk(e,this)}releaseCapture(e){Sf(e,this)}};dt.prototype._fillFunc=CO,dt.prototype._strokeFunc=_O,dt.prototype._fillFuncHit=SO,dt.prototype._strokeFuncHit=kO,dt.prototype._centroid=!1,dt.prototype.nodeType="Shape",wr(dt),dt.prototype.eventListeners={},dt.prototype.on("shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",AO),dt.prototype.on("shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",IO),dt.prototype.on("fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",EO),dt.prototype.on("fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",xO),dt.prototype.on("fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",TO),ce.addGetterSetter(dt,"stroke",void 0,Ik()),ce.addGetterSetter(dt,"strokeWidth",2,mt()),ce.addGetterSetter(dt,"fillAfterStrokeEnabled",!1),ce.addGetterSetter(dt,"hitStrokeWidth","auto",I0()),ce.addGetterSetter(dt,"strokeHitEnabled",!0,Gi()),ce.addGetterSetter(dt,"perfectDrawEnabled",!0,Gi()),ce.addGetterSetter(dt,"shadowForStrokeEnabled",!0,Gi()),ce.addGetterSetter(dt,"lineJoin"),ce.addGetterSetter(dt,"lineCap"),ce.addGetterSetter(dt,"miterLimit"),ce.addGetterSetter(dt,"sceneFunc"),ce.addGetterSetter(dt,"hitFunc"),ce.addGetterSetter(dt,"dash"),ce.addGetterSetter(dt,"dashOffset",0,mt()),ce.addGetterSetter(dt,"shadowColor",void 0,rc()),ce.addGetterSetter(dt,"shadowBlur",0,mt()),ce.addGetterSetter(dt,"shadowOpacity",1,mt()),ce.addComponentsGetterSetter(dt,"shadowOffset",["x","y"]),ce.addGetterSetter(dt,"shadowOffsetX",0,mt()),ce.addGetterSetter(dt,"shadowOffsetY",0,mt()),ce.addGetterSetter(dt,"fillPatternImage"),ce.addGetterSetter(dt,"fill",void 0,Ik()),ce.addGetterSetter(dt,"fillPatternX",0,mt()),ce.addGetterSetter(dt,"fillPatternY",0,mt()),ce.addGetterSetter(dt,"fillLinearGradientColorStops"),ce.addGetterSetter(dt,"strokeLinearGradientColorStops"),ce.addGetterSetter(dt,"fillRadialGradientStartRadius",0),ce.addGetterSetter(dt,"fillRadialGradientEndRadius",0),ce.addGetterSetter(dt,"fillRadialGradientColorStops"),ce.addGetterSetter(dt,"fillPatternRepeat","repeat"),ce.addGetterSetter(dt,"fillEnabled",!0),ce.addGetterSetter(dt,"strokeEnabled",!0),ce.addGetterSetter(dt,"shadowEnabled",!0),ce.addGetterSetter(dt,"dashEnabled",!0),ce.addGetterSetter(dt,"strokeScaleEnabled",!0),ce.addGetterSetter(dt,"fillPriority","color"),ce.addComponentsGetterSetter(dt,"fillPatternOffset",["x","y"]),ce.addGetterSetter(dt,"fillPatternOffsetX",0,mt()),ce.addGetterSetter(dt,"fillPatternOffsetY",0,mt()),ce.addComponentsGetterSetter(dt,"fillPatternScale",["x","y"]),ce.addGetterSetter(dt,"fillPatternScaleX",1,mt()),ce.addGetterSetter(dt,"fillPatternScaleY",1,mt()),ce.addComponentsGetterSetter(dt,"fillLinearGradientStartPoint",["x","y"]),ce.addComponentsGetterSetter(dt,"strokeLinearGradientStartPoint",["x","y"]),ce.addGetterSetter(dt,"fillLinearGradientStartPointX",0),ce.addGetterSetter(dt,"strokeLinearGradientStartPointX",0),ce.addGetterSetter(dt,"fillLinearGradientStartPointY",0),ce.addGetterSetter(dt,"strokeLinearGradientStartPointY",0),ce.addComponentsGetterSetter(dt,"fillLinearGradientEndPoint",["x","y"]),ce.addComponentsGetterSetter(dt,"strokeLinearGradientEndPoint",["x","y"]),ce.addGetterSetter(dt,"fillLinearGradientEndPointX",0),ce.addGetterSetter(dt,"strokeLinearGradientEndPointX",0),ce.addGetterSetter(dt,"fillLinearGradientEndPointY",0),ce.addGetterSetter(dt,"strokeLinearGradientEndPointY",0),ce.addComponentsGetterSetter(dt,"fillRadialGradientStartPoint",["x","y"]),ce.addGetterSetter(dt,"fillRadialGradientStartPointX",0),ce.addGetterSetter(dt,"fillRadialGradientStartPointY",0),ce.addComponentsGetterSetter(dt,"fillRadialGradientEndPoint",["x","y"]),ce.addGetterSetter(dt,"fillRadialGradientEndPointX",0),ce.addGetterSetter(dt,"fillRadialGradientEndPointY",0),ce.addGetterSetter(dt,"fillPatternRotation",0),ce.addGetterSetter(dt,"fillRule",void 0,rc()),ce.backCompat(dt,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var RO="beforeDraw",MO="draw",Jk=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],LO=Jk.length,ic=class extends pi{constructor(e){super(e),this.canvas=new nl,this.hitCanvas=new A0({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[e+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){wt.prototype.moveToTop.call(this);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!wt.prototype.moveUp.call(this))return!1;const e=this.getStage();return!e||!e.content?!1:(e.content.removeChild(this.getNativeCanvasElement()),this.index<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[this.index+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(wt.prototype.moveDown.call(this)){const e=this.getStage();if(e){const t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(wt.prototype.moveToBottom.call(this)){const e=this.getStage();if(e){const t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const e=this.getNativeCanvasElement();return wt.prototype.remove.call(this),e&&e.parentNode&&Ie._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&&Ie.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return e={...e},e.width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=e.x!==void 0?e.x:this.x(),e.y=e.y!==void 0?e.y:this.y(),wt.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){this.visible()?this.canvas._canvas.style.display="block":this.canvas._canvas.style.display="none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){Ie.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){Ie.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,Ie.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=1,n=!1;for(;;){for(let r=0;r<LO;r++){const o=Jk[r],i=this._getIntersection({x:e.x+o.x*t,y:e.y+o.y*t}),s=i.shape;if(s)return s;if(n=!!i.antialiased,!i.antialiased)break}if(n)t+=1;else return null}}_getIntersection(e){const t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,r=n[3];if(r===255){const o=Rf[Ie.getHitColorKey(n[0],n[1],n[2])];return o?{shape:o}:{antialiased:!0}}else if(r>0)return{antialiased:!0};return{}}drawScene(e,t,n){const r=this.getLayer(),o=e||r&&r.getCanvas();return this._fire(RO,{node:this}),this.clearBeforeDraw()&&o.getContext().clear(),pi.prototype.drawScene.call(this,o,t,n),this._fire(MO,{node:this}),this}drawHit(e,t){const n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),pi.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){Ie.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return Ie.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}destroy(){return Ie.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};ic.prototype.nodeType="Layer",wr(ic),ce.addGetterSetter(ic,"imageSmoothingEnabled",!0),ce.addGetterSetter(ic,"clearBeforeDraw",!0),ce.addGetterSetter(ic,"hitGraphEnabled",!0,Gi());var O0=class extends ic{constructor(e){super(e),this.listening(!1),Ie.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};O0.prototype.nodeType="FastLayer",wr(O0);var yu=class extends pi{_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&&Ie.throw("You may only add groups and shapes to groups.")}};yu.prototype.nodeType="Group",wr(yu);var F0=(function(){return nc.performance&&nc.performance.now?function(){return nc.performance.now()}:function(){return new Date().getTime()}})(),bu=class td{constructor(t,n){this.id=td.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:F0(),frameRate:0},this.func=t,this.setLayers(n)}setLayers(t){let n=[];return t&&(n=Array.isArray(t)?t:[t]),this.layers=n,this}getLayers(){return this.layers}addLayer(t){const n=this.layers,r=n.length;for(let o=0;o<r;o++)if(n[o]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=td.animations,n=t.length;for(let r=0;r<n;r++)if(t[r].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=F0(),td._addAnimation(this),this}stop(){return td._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const n=t.id,r=this.animations,o=r.length;for(let i=0;i<o;i++)if(r[i].id===n){this.animations.splice(i,1);break}}static _runFrames(){const t={},n=this.animations;for(let r=0;r<n.length;r++){const o=n[r],i=o.layers,s=o.func;o._updateFrameObject(F0());const a=i.length;let l;if(s?l=s.call(o,o.frame)!==!1:l=!0,!!l)for(let u=0;u<a;u++){const c=i[u];c._id!==void 0&&(t[c._id]=c)}}for(const r in t)t.hasOwnProperty(r)&&t[r].batchDraw()}static _animationLoop(){const t=td;t.animations.length?(t._runFrames(),Ie.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Ie.requestAnimFrame(this._animationLoop))}};bu.animations=[],bu.animIdCounter=0,bu.animRunning=!1;var PO={node:1,duration:1,easing:1,onFinish:1,yoyo:1},DO=1,$k=2,e4=3,t4=["fill","stroke","shadowColor"],OO=0,FO=class{constructor(e,t,n,r,o,i,s){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=i,this._change=0,this.prevPos=0,this.yoyo=s,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=o-this.begin,this.pause()}fire(e){const t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return e===void 0&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=$k,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=e4,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(e){this.pause(),this._time=e,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const e=this.getTimer()-this._startTime;this.state===$k?this.setTime(e):this.state===e4&&this.setTime(this.duration-e)}pause(){this.state=DO,this.fire("onPause")}getTimer(){return new Date().getTime()}},tm=class Lr{constructor(t){const n=this,r=t.node,o=r._id,i=t.easing||Mf.Linear,s=!!t.yoyo;let a,l;typeof t.duration>"u"?a=.3:t.duration===0?a=.001:a=t.duration,this.node=r,this._id=OO++;const u=r.getLayer()||(r instanceof bt.Stage?r.getLayers():null);u||Ie.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new bu(function(){n.tween.onEnterFrame()},u),this.tween=new FO(l,function(c){n._tweenFunc(c)},i,0,1,a*1e3,s),this._addListeners(),Lr.attrs[o]||(Lr.attrs[o]={}),Lr.attrs[o][this._id]||(Lr.attrs[o][this._id]={}),Lr.tweens[o]||(Lr.tweens[o]={});for(l in t)PO[l]===void 0&&this._addAttr(l,t[l]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,n){const r=this.node,o=r._id;let i,s,a,l,u;const c=Lr.tweens[o][t];c&&delete Lr.attrs[o][c][t];let d=r.getAttr(t);if(Ie._isArray(n))if(i=[],s=Math.max(n.length,d.length),t==="points"&&n.length!==d.length&&(n.length>d.length?(l=d,d=Ie._prepareArrayForTween(d,n,r.closed())):(a=n,n=Ie._prepareArrayForTween(n,d,r.closed()))),t.indexOf("fill")===0)for(let h=0;h<s;h++)if(h%2===0)i.push(n[h]-d[h]);else{const m=Ie.colorToRGBA(d[h]);u=Ie.colorToRGBA(n[h]),d[h]=m,i.push({r:u.r-m.r,g:u.g-m.g,b:u.b-m.b,a:u.a-m.a})}else for(let h=0;h<s;h++)i.push(n[h]-d[h]);else t4.indexOf(t)!==-1?(d=Ie.colorToRGBA(d),u=Ie.colorToRGBA(n),i={r:u.r-d.r,g:u.g-d.g,b:u.b-d.b,a:u.a-d.a}):i=n-d;Lr.attrs[o][this._id][t]={start:d,diff:i,end:n,trueEnd:a,trueStart:l},Lr.tweens[o][t]=this._id}_tweenFunc(t){const n=this.node,r=Lr.attrs[n._id][this._id];let o,i,s,a,l,u,c,d;for(o in r){if(i=r[o],s=i.start,a=i.diff,d=i.end,Ie._isArray(s))if(l=[],c=Math.max(s.length,d.length),o.indexOf("fill")===0)for(u=0;u<c;u++)u%2===0?l.push((s[u]||0)+a[u]*t):l.push("rgba("+Math.round(s[u].r+a[u].r*t)+","+Math.round(s[u].g+a[u].g*t)+","+Math.round(s[u].b+a[u].b*t)+","+(s[u].a+a[u].a*t)+")");else for(u=0;u<c;u++)l.push((s[u]||0)+a[u]*t);else t4.indexOf(o)!==-1?l="rgba("+Math.round(s.r+a.r*t)+","+Math.round(s.g+a.g*t)+","+Math.round(s.b+a.b*t)+","+(s.a+a.a*t)+")":l=s+a*t;n.setAttr(o,l)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,n=Lr.attrs[t._id][this._id];n.points&&n.points.trueEnd&&t.setAttr("points",n.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,n=Lr.attrs[t._id][this._id];n.points&&n.points.trueStart&&t.points(n.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(t*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,n=this._id,r=Lr.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const o in r)delete Lr.tweens[t][o];delete Lr.attrs[t][n],Lr.tweens[t]&&(Object.keys(Lr.tweens[t]).length===0&&delete Lr.tweens[t],Object.keys(Lr.attrs[t]).length===0&&delete Lr.attrs[t])}};tm.attrs={},tm.tweens={},wt.prototype.to=function(e){const t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new tm(e).play()};const Mf={BackEaseIn(e,t,n,r){return n*(e/=r)*e*((1.70158+1)*e-1.70158)+t},BackEaseOut(e,t,n,r){return n*((e=e/r-1)*e*((1.70158+1)*e+1.70158)+1)+t},BackEaseInOut(e,t,n,r){let o=1.70158;return(e/=r/2)<1?n/2*(e*e*(((o*=1.525)+1)*e-o))+t:n/2*((e-=2)*e*(((o*=1.525)+1)*e+o)+2)+t},ElasticEaseIn(e,t,n,r,o,i){let s=0;return e===0?t:(e/=r)===1?t+n:(i||(i=r*.3),!o||o<Math.abs(n)?(o=n,s=i/4):s=i/(2*Math.PI)*Math.asin(n/o),-(o*Math.pow(2,10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/i))+t)},ElasticEaseOut(e,t,n,r,o,i){let s=0;return e===0?t:(e/=r)===1?t+n:(i||(i=r*.3),!o||o<Math.abs(n)?(o=n,s=i/4):s=i/(2*Math.PI)*Math.asin(n/o),o*Math.pow(2,-10*e)*Math.sin((e*r-s)*(2*Math.PI)/i)+n+t)},ElasticEaseInOut(e,t,n,r,o,i){let s=0;return e===0?t:(e/=r/2)===2?t+n:(i||(i=r*(.3*1.5)),!o||o<Math.abs(n)?(o=n,s=i/4):s=i/(2*Math.PI)*Math.asin(n/o),e<1?-.5*(o*Math.pow(2,10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/i))+t:o*Math.pow(2,-10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/i)*.5+n+t)},BounceEaseOut(e,t,n,r){return(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t},BounceEaseIn(e,t,n,r){return n-Mf.BounceEaseOut(r-e,0,n,r)+t},BounceEaseInOut(e,t,n,r){return e<r/2?Mf.BounceEaseIn(e*2,0,n,r)*.5+t:Mf.BounceEaseOut(e*2-r,0,n,r)*.5+n*.5+t},EaseIn(e,t,n,r){return n*(e/=r)*e+t},EaseOut(e,t,n,r){return-n*(e/=r)*(e-2)+t},EaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t},StrongEaseIn(e,t,n,r){return n*(e/=r)*e*e*e*e+t},StrongEaseOut(e,t,n,r){return n*((e=e/r-1)*e*e*e*e+1)+t},StrongEaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t},Linear(e,t,n,r){return n*e/r+t}},n4=Ie._assign(bt,{Util:Ie,Transform:Ui,Node:wt,Container:pi,Stage:$p,stages:Tf,Layer:ic,FastLayer:O0,Group:yu,DD:Pn,Shape:dt,shapes:Rf,Animation:bu,Tween:tm,Easings:Mf,Context:Wp,Canvas:k0});var da=class extends dt{_sceneFunc(e){const t=bt.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,n),e.arc(0,0,this.innerRadius(),t,0,!n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),t=this.outerRadius(),n=this.clockwise(),r=bt.getAngle(n?360-this.angle():this.angle()),o=Math.cos(Math.min(r,Math.PI)),i=1,s=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),a=Math.sin(Math.min(r,Math.PI/2)),l=o*(o>0?e:t),u=i*(i>0?t:e),c=s*(s>0?e:t),d=a*(a>0?t:e);return{x:l,y:n?-1*d:c,width:u-l,height:d-c}}};da.prototype._centroid=!0,da.prototype.className="Arc",da.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],wr(da),ce.addGetterSetter(da,"innerRadius",0,mt()),ce.addGetterSetter(da,"outerRadius",0,mt()),ce.addGetterSetter(da,"angle",0,mt()),ce.addGetterSetter(da,"clockwise",!1,Gi());function N0(e,t,n,r,o,i,s){const a=Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2)),l=Math.sqrt(Math.pow(o-n,2)+Math.pow(i-r,2)),u=s*a/(a+l),c=s*l/(a+l);return[n-u*(o-e),r-u*(i-t),n+c*(o-e),r+c*(i-t)]}function r4(e,t){const n=e.length,r=[];for(let o=2;o<n-2;o+=2){const i=N0(e[o-2],e[o-1],e[o],e[o+1],e[o+2],e[o+3],t);isNaN(i[0])||(r.push(i[0]),r.push(i[1]),r.push(e[o]),r.push(e[o+1]),r.push(i[2]),r.push(i[3]))}return r}function NO(e){const t=[[e[0],e[2],e[4],e[6]],[e[1],e[3],e[5],e[7]]],n=[];for(const r of t){const o=-3*r[0]+9*r[1]-9*r[2]+3*r[3];if(o!==0){const i=6*r[0]-12*r[1]+6*r[2],s=-3*r[0]+3*r[1],a=i*i-4*o*s;if(a>=0){const l=Math.sqrt(a);n.push((-i+l)/(2*o)),n.push((-i-l)/(2*o))}}}return n.filter(r=>r>0&&r<1).flatMap(r=>t.map(o=>{const i=1-r;return i*i*i*o[0]+3*i*i*r*o[1]+3*i*r*r*o[2]+r*r*r*o[3]}))}var fa=class extends dt{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(e){const t=this.points(),n=t.length,r=this.tension(),o=this.closed(),i=this.bezier();if(!n)return;let s=0;if(e.beginPath(),e.moveTo(t[0],t[1]),r!==0&&n>4){const a=this.getTensionPoints(),l=a.length;for(s=o?0:4,o||e.quadraticCurveTo(a[0],a[1],a[2],a[3]);s<l-2;)e.bezierCurveTo(a[s++],a[s++],a[s++],a[s++],a[s++],a[s++]);o||e.quadraticCurveTo(a[l-2],a[l-1],t[n-2],t[n-1])}else if(i)for(s=2;s<n;)e.bezierCurveTo(t[s++],t[s++],t[s++],t[s++],t[s++],t[s++]);else for(s=2;s<n;s+=2)e.lineTo(t[s],t[s+1]);o?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():r4(this.points(),this.tension())}_getTensionPointsClosed(){const e=this.points(),t=e.length,n=this.tension(),r=N0(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),o=N0(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),i=r4(e,n);return[r[2],r[3]].concat(i).concat([o[0],o[1],e[t-2],e[t-1],o[2],o[3],r[0],r[1],e[0],e[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};this.tension()!==0?e=[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:this.bezier()?e=[e[0],e[1],...NO(this.points()),e[e.length-2],e[e.length-1]]:e=this.points();let t=e[0],n=e[0],r=e[1],o=e[1],i,s;for(let a=0;a<e.length/2;a++)i=e[a*2],s=e[a*2+1],t=Math.min(t,i),n=Math.max(n,i),r=Math.min(r,s),o=Math.max(o,s);return{x:t,y:r,width:n-t,height:o-r}}};fa.prototype.className="Line",fa.prototype._attrsAffectingSize=["points","bezier","tension"],wr(fa),ce.addGetterSetter(fa,"closed",!1),ce.addGetterSetter(fa,"bezier",!1),ce.addGetterSetter(fa,"tension",0,mt()),ce.addGetterSetter(fa,"points",[],$D());const BO=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],zO=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],VO=[[1],[1,1],[1,2,1],[1,3,3,1]],o4=(e,t,n)=>{let r,o;const s=n/2;r=0;for(let a=0;a<20;a++)o=s*BO[20][a]+s,r+=zO[20][a]*HO(e,t,o);return s*r},i4=(e,t,n)=>{n===void 0&&(n=1);const r=e[0]-2*e[1]+e[2],o=t[0]-2*t[1]+t[2],i=2*e[1]-2*e[0],s=2*t[1]-2*t[0],a=4*(r*r+o*o),l=4*(r*i+o*s),u=i*i+s*s;if(a===0)return n*Math.sqrt(Math.pow(e[2]-e[0],2)+Math.pow(t[2]-t[0],2));const c=l/(2*a),d=u/a,h=n+c,m=d-c*c,p=h*h+m>0?Math.sqrt(h*h+m):0,v=c*c+m>0?Math.sqrt(c*c+m):0,_=c+Math.sqrt(c*c+m)!==0?m*Math.log(Math.abs((h+p)/(c+v))):0;return Math.sqrt(a)/2*(h*p-c*v+_)};function HO(e,t,n){const r=B0(1,n,e),o=B0(1,n,t),i=r*r+o*o;return Math.sqrt(i)}var B0=(e,t,n)=>{const r=n.length-1;let o,i;if(r===0)return 0;if(e===0){i=0;for(let s=0;s<=r;s++)i+=VO[r][s]*Math.pow(1-t,r-s)*Math.pow(t,s)*n[s];return i}else{o=new Array(r);for(let s=0;s<r;s++)o[s]=r*(n[s+1]-n[s]);return B0(e-1,t,o)}};const s4=(e,t,n)=>{let r=1,o=e/t,i=(e-n(o))/t,s=0;for(;r>.001;){const a=n(o+i),l=Math.abs(e-a)/t;if(l<r)r=l,o+=i;else{const u=n(o-i),c=Math.abs(e-u)/t;c<r?(r=c,o-=i):i/=2}if(s++,s>500)break}return o};var Ei=class li extends dt{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=li.parsePathData(this.data()),this.pathLength=li.getPathLength(this.dataArray)}_sceneFunc(t){const n=this.dataArray;t.beginPath();let r=!1;for(let o=0;o<n.length;o++){const i=n[o].command,s=n[o].points;switch(i){case"L":t.lineTo(s[0],s[1]);break;case"M":t.moveTo(s[0],s[1]);break;case"C":t.bezierCurveTo(s[0],s[1],s[2],s[3],s[4],s[5]);break;case"Q":t.quadraticCurveTo(s[0],s[1],s[2],s[3]);break;case"A":const a=s[0],l=s[1],u=s[2],c=s[3],d=s[4],h=s[5],m=s[6],p=s[7],v=u>c?u:c,_=u>c?1:u/c,C=u>c?c/u:1;t.translate(a,l),t.rotate(m),t.scale(_,C),t.arc(0,0,v,d,d+h,1-p),t.scale(1/_,1/C),t.rotate(-m),t.translate(-a,-l);break;case"z":r=!0,t.closePath();break}}!r&&!this.hasFill()?t.strokeShape(this):t.fillStrokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(l){if(l.command==="A"){const u=l.points[4],c=l.points[5],d=l.points[4]+c;let h=Math.PI/180;if(Math.abs(u-d)<h&&(h=Math.abs(u-d)),c<0)for(let m=u-h;m>d;m-=h){const p=li.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],m,0);t.push(p.x,p.y)}else for(let m=u+h;m<d;m+=h){const p=li.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],m,0);t.push(p.x,p.y)}}else if(l.command==="C")for(let u=0;u<=1;u+=.01){const c=li.getPointOnCubicBezier(u,l.start.x,l.start.y,l.points[0],l.points[1],l.points[2],l.points[3],l.points[4],l.points[5]);t.push(c.x,c.y)}else t=t.concat(l.points)});let n=t[0],r=t[0],o=t[1],i=t[1],s,a;for(let l=0;l<t.length/2;l++)s=t[l*2],a=t[l*2+1],isNaN(s)||(n=Math.min(n,s),r=Math.max(r,s)),isNaN(a)||(o=Math.min(o,a),i=Math.max(i,a));return{x:n,y:o,width:r-n,height:i-o}}getLength(){return this.pathLength}getPointAtLength(t){return li.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,n,r,o){return Math.sqrt((r-t)*(r-t)+(o-n)*(o-n))}static getPathLength(t){let n=0;for(let r=0;r<t.length;++r)n+=t[r].pathLength;return n}static getPointAtLengthOfDataArray(t,n){let r,o=0,i=n.length;if(!i)return null;for(;o<i&&t>n[o].pathLength;)t-=n[o].pathLength,++o;if(o===i)return r=n[o-1].points.slice(-2),{x:r[0],y:r[1]};if(t<.01)return n[o].command==="M"?(r=n[o].points.slice(0,2),{x:r[0],y:r[1]}):{x:n[o].start.x,y:n[o].start.y};const s=n[o],a=s.points;switch(s.command){case"L":return li.getPointOnLine(t,s.start.x,s.start.y,a[0],a[1]);case"C":return li.getPointOnCubicBezier(s4(t,li.getPathLength(n),v=>o4([s.start.x,a[0],a[2],a[4]],[s.start.y,a[1],a[3],a[5]],v)),s.start.x,s.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return li.getPointOnQuadraticBezier(s4(t,li.getPathLength(n),v=>i4([s.start.x,a[0],a[2]],[s.start.y,a[1],a[3]],v)),s.start.x,s.start.y,a[0],a[1],a[2],a[3]);case"A":const l=a[0],u=a[1],c=a[2],d=a[3],h=a[5],m=a[6];let p=a[4];return p+=h*t/s.pathLength,li.getPointOnEllipticalArc(l,u,c,d,p,m)}return null}static getPointOnLine(t,n,r,o,i,s,a){s=s??n,a=a??r;const l=this.getLineLength(n,r,o,i);if(l<1e-10)return{x:n,y:r};if(o===n)return{x:s,y:a+(i>r?t:-t)};const u=(i-r)/(o-n),c=Math.sqrt(t*t/(1+u*u))*(o<n?-1:1),d=u*c;if(Math.abs(a-r-u*(s-n))<1e-10)return{x:s+c,y:a+d};const h=((s-n)*(o-n)+(a-r)*(i-r))/(l*l),m=n+h*(o-n),p=r+h*(i-r),v=this.getLineLength(s,a,m,p),_=Math.sqrt(t*t-v*v),C=Math.sqrt(_*_/(1+u*u))*(o<n?-1:1),k=u*C;return{x:m+C,y:p+k}}static getPointOnCubicBezier(t,n,r,o,i,s,a,l,u){function c(p){return p*p*p}function d(p){return 3*p*p*(1-p)}function h(p){return 3*p*(1-p)*(1-p)}function m(p){return(1-p)*(1-p)*(1-p)}return{x:l*c(t)+s*d(t)+o*h(t)+n*m(t),y:u*c(t)+a*d(t)+i*h(t)+r*m(t)}}static getPointOnQuadraticBezier(t,n,r,o,i,s,a){function l(d){return d*d}function u(d){return 2*d*(1-d)}function c(d){return(1-d)*(1-d)}return{x:s*l(t)+o*u(t)+n*c(t),y:a*l(t)+i*u(t)+r*c(t)}}static getPointOnEllipticalArc(t,n,r,o,i,s){const a=Math.cos(s),l=Math.sin(s),u={x:r*Math.cos(i),y:o*Math.sin(i)};return{x:t+(u.x*a-u.y*l),y:n+(u.x*l+u.y*a)}}static parsePathData(t){if(!t)return[];let n=t;const r=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];n=n.replace(new RegExp(" ","g"),",");for(let d=0;d<r.length;d++)n=n.replace(new RegExp(r[d],"g"),"|"+r[d]);const o=n.split("|"),i=[],s=[];let a=0,l=0;const u=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let c;for(let d=1;d<o.length;d++){let h=o[d],m=h.charAt(0);for(h=h.slice(1),s.length=0;c=u.exec(h);)s.push(c[0]);let p=[],v=m==="A"||m==="a"?0:-1;for(let _=0,C=s.length;_<C;_++){const k=s[_];if(k==="00"){p.push(0,0),v>=0&&(v+=2,v>=7&&(v-=7));continue}if(v>=0){if(v===3){if(/^[01]{2}\d+(?:\.\d+)?$/.test(k)){p.push(parseInt(k[0],10)),p.push(parseInt(k[1],10)),p.push(parseFloat(k.slice(2))),v+=3,v>=7&&(v-=7);continue}if(k==="11"||k==="10"||k==="01"){p.push(parseInt(k[0],10)),p.push(parseInt(k[1],10)),v+=2,v>=7&&(v-=7);continue}if(k==="0"||k==="1"){p.push(parseInt(k,10)),v+=1,v>=7&&(v-=7);continue}}else if(v===4){if(/^[01]\d+(?:\.\d+)?$/.test(k)){p.push(parseInt(k[0],10)),p.push(parseFloat(k.slice(1))),v+=2,v>=7&&(v-=7);continue}if(k==="0"||k==="1"){p.push(parseInt(k,10)),v+=1,v>=7&&(v-=7);continue}}const y=parseFloat(k);isNaN(y)?p.push(0):p.push(y),v+=1,v>=7&&(v-=7)}else{const y=parseFloat(k);isNaN(y)?p.push(0):p.push(y)}}for(;p.length>0&&!isNaN(p[0]);){let _="",C=[];const k=a,y=l;let b,T,R,P,j,O,V,Q,F,N;switch(m){case"l":a+=p.shift(),l+=p.shift(),_="L",C.push(a,l);break;case"L":a=p.shift(),l=p.shift(),C.push(a,l);break;case"m":const x=p.shift(),z=p.shift();if(a+=x,l+=z,_="M",i.length>2&&i[i.length-1].command==="z"){for(let J=i.length-2;J>=0;J--)if(i[J].command==="M"){a=i[J].points[0]+x,l=i[J].points[1]+z;break}}C.push(a,l),m="l";break;case"M":a=p.shift(),l=p.shift(),_="M",C.push(a,l),m="L";break;case"h":a+=p.shift(),_="L",C.push(a,l);break;case"H":a=p.shift(),_="L",C.push(a,l);break;case"v":l+=p.shift(),_="L",C.push(a,l);break;case"V":l=p.shift(),_="L",C.push(a,l);break;case"C":C.push(p.shift(),p.shift(),p.shift(),p.shift()),a=p.shift(),l=p.shift(),C.push(a,l);break;case"c":C.push(a+p.shift(),l+p.shift(),a+p.shift(),l+p.shift()),a+=p.shift(),l+=p.shift(),_="C",C.push(a,l);break;case"S":T=a,R=l,b=i[i.length-1],b.command==="C"&&(T=a+(a-b.points[2]),R=l+(l-b.points[3])),C.push(T,R,p.shift(),p.shift()),a=p.shift(),l=p.shift(),_="C",C.push(a,l);break;case"s":T=a,R=l,b=i[i.length-1],b.command==="C"&&(T=a+(a-b.points[2]),R=l+(l-b.points[3])),C.push(T,R,a+p.shift(),l+p.shift()),a+=p.shift(),l+=p.shift(),_="C",C.push(a,l);break;case"Q":C.push(p.shift(),p.shift()),a=p.shift(),l=p.shift(),C.push(a,l);break;case"q":C.push(a+p.shift(),l+p.shift()),a+=p.shift(),l+=p.shift(),_="Q",C.push(a,l);break;case"T":T=a,R=l,b=i[i.length-1],b.command==="Q"&&(T=a+(a-b.points[0]),R=l+(l-b.points[1])),a=p.shift(),l=p.shift(),_="Q",C.push(T,R,a,l);break;case"t":T=a,R=l,b=i[i.length-1],b.command==="Q"&&(T=a+(a-b.points[0]),R=l+(l-b.points[1])),a+=p.shift(),l+=p.shift(),_="Q",C.push(T,R,a,l);break;case"A":P=p.shift(),j=p.shift(),O=p.shift(),V=p.shift(),Q=p.shift(),F=a,N=l,a=p.shift(),l=p.shift(),_="A",C=this.convertEndpointToCenterParameterization(F,N,a,l,V,Q,P,j,O);break;case"a":P=p.shift(),j=p.shift(),O=p.shift(),V=p.shift(),Q=p.shift(),F=a,N=l,a+=p.shift(),l+=p.shift(),_="A",C=this.convertEndpointToCenterParameterization(F,N,a,l,V,Q,P,j,O);break}i.push({command:_||m,points:C,start:{x:k,y},pathLength:this.calcLength(k,y,_||m,C)})}(m==="z"||m==="Z")&&i.push({command:"z",points:[],start:void 0,pathLength:0})}return i}static calcLength(t,n,r,o){let i,s,a,l;const u=li;switch(r){case"L":return u.getLineLength(t,n,o[0],o[1]);case"C":return o4([t,o[0],o[2],o[4]],[n,o[1],o[3],o[5]],1);case"Q":return i4([t,o[0],o[2]],[n,o[1],o[3]],1);case"A":i=0;const c=o[4],d=o[5],h=o[4]+d;let m=Math.PI/180;if(Math.abs(c-h)<m&&(m=Math.abs(c-h)),s=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],c,0),d<0)for(l=c-m;l>h;l-=m)a=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],l,0),i+=u.getLineLength(s.x,s.y,a.x,a.y),s=a;else for(l=c+m;l<h;l+=m)a=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],l,0),i+=u.getLineLength(s.x,s.y,a.x,a.y),s=a;return a=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],h,0),i+=u.getLineLength(s.x,s.y,a.x,a.y),i}return 0}static convertEndpointToCenterParameterization(t,n,r,o,i,s,a,l,u){const c=u*(Math.PI/180),d=Math.cos(c)*(t-r)/2+Math.sin(c)*(n-o)/2,h=-1*Math.sin(c)*(t-r)/2+Math.cos(c)*(n-o)/2,m=d*d/(a*a)+h*h/(l*l);m>1&&(a*=Math.sqrt(m),l*=Math.sqrt(m));let p=Math.sqrt((a*a*(l*l)-a*a*(h*h)-l*l*(d*d))/(a*a*(h*h)+l*l*(d*d)));i===s&&(p*=-1),isNaN(p)&&(p=0);const v=p*a*h/l,_=p*-l*d/a,C=(t+r)/2+Math.cos(c)*v-Math.sin(c)*_,k=(n+o)/2+Math.sin(c)*v+Math.cos(c)*_,y=function(V){return Math.sqrt(V[0]*V[0]+V[1]*V[1])},b=function(V,Q){return(V[0]*Q[0]+V[1]*Q[1])/(y(V)*y(Q))},T=function(V,Q){return(V[0]*Q[1]<V[1]*Q[0]?-1:1)*Math.acos(b(V,Q))},R=T([1,0],[(d-v)/a,(h-_)/l]),P=[(d-v)/a,(h-_)/l],j=[(-1*d-v)/a,(-1*h-_)/l];let O=T(P,j);return b(P,j)<=-1&&(O=Math.PI),b(P,j)>=1&&(O=0),s===0&&O>0&&(O=O-2*Math.PI),s===1&&O<0&&(O=O+2*Math.PI),[C,k,a,l,R,O,c,s]}};Ei.prototype.className="Path",Ei.prototype._attrsAffectingSize=["data"],wr(Ei),ce.addGetterSetter(Ei,"data");var sc=class extends fa{_sceneFunc(e){super._sceneFunc(e);const t=Math.PI*2,n=this.points();let r=n;const o=this.tension()!==0&&n.length>4;o&&(r=this.getTensionPoints());const i=this.pointerLength(),s=n.length;let a,l;if(o){const d=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[s-2],n[s-1]],h=Ei.calcLength(r[r.length-4],r[r.length-3],"C",d),m=Ei.getPointOnQuadraticBezier(Math.min(1,1-i/h),d[0],d[1],d[2],d[3],d[4],d[5]);a=n[s-2]-m.x,l=n[s-1]-m.y}else a=n[s-2]-n[s-4],l=n[s-1]-n[s-3];const u=(Math.atan2(l,a)+t)%t,c=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(n[s-2],n[s-1]),e.rotate(u),e.moveTo(0,0),e.lineTo(-i,c/2),e.lineTo(-i,-c/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(n[0],n[1]),o?(a=(r[0]+r[2])/2-n[0],l=(r[1]+r[3])/2-n[1]):(a=n[2]-n[0],l=n[3]-n[1]),e.rotate((Math.atan2(-l,-a)+t)%t),e.moveTo(0,0),e.lineTo(-i,c/2),e.lineTo(-i,-c/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){const t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x,y:e.y-t,width:e.width,height:e.height+t*2}}};sc.prototype.className="Arrow",wr(sc),ce.addGetterSetter(sc,"pointerLength",10,mt()),ce.addGetterSetter(sc,"pointerWidth",10,mt()),ce.addGetterSetter(sc,"pointerAtBeginning",!1),ce.addGetterSetter(sc,"pointerAtEnding",!0);var wu=class extends dt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}};wu.prototype._centroid=!0,wu.prototype.className="Circle",wu.prototype._attrsAffectingSize=["radius"],wr(wu),ce.addGetterSetter(wu,"radius",0,mt());var il=class extends dt{_sceneFunc(e){const t=this.radiusX(),n=this.radiusY();e.beginPath(),e.save(),t!==n&&e.scale(1,n/t),e.arc(0,0,t,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}};il.prototype.className="Ellipse",il.prototype._centroid=!0,il.prototype._attrsAffectingSize=["radiusX","radiusY"],wr(il),ce.addComponentsGetterSetter(il,"radius",["x","y"]),ce.addGetterSetter(il,"radiusX",0,mt()),ce.addGetterSetter(il,"radiusY",0,mt());var Wi=class iI extends dt{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",n=>{this._removeImageLoad(n.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&t.readyState===4||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),n=this.hasShadow();return t&&n?!0:super._useBufferCanvas(!0)}_sceneFunc(t){const n=this.getWidth(),r=this.getHeight(),o=this.cornerRadius(),i=this.attrs.image;let s;if(i){const a=this.attrs.cropWidth,l=this.attrs.cropHeight;a&&l?s=[i,this.cropX(),this.cropY(),a,l,0,0,n,r]:s=[i,0,0,n,r]}(this.hasFill()||this.hasStroke()||o)&&(t.beginPath(),o?Ie.drawRoundedRectPath(t,n,r,o):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)),i&&(o&&t.clip(),t.drawImage.apply(t,s))}_hitFunc(t){const n=this.width(),r=this.height(),o=this.cornerRadius();t.beginPath(),o?Ie.drawRoundedRectPath(t,n,r,o):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,n,r;return(r=(t=this.attrs.width)!==null&&t!==void 0?t:(n=this.image())===null||n===void 0?void 0:n.width)!==null&&r!==void 0?r:0}getHeight(){var t,n,r;return(r=(t=this.attrs.height)!==null&&t!==void 0?t:(n=this.image())===null||n===void 0?void 0:n.height)!==null&&r!==void 0?r:0}static fromURL(t,n,r=null){const o=Ie.createImageElement();o.onload=function(){n(new iI({image:o}))},o.onerror=r,o.crossOrigin="Anonymous",o.src=t}};Wi.prototype.className="Image",Wi.prototype._attrsAffectingSize=["image"],wr(Wi),ce.addGetterSetter(Wi,"cornerRadius",0,qp(4)),ce.addGetterSetter(Wi,"image"),ce.addComponentsGetterSetter(Wi,"crop",["x","y","width","height"]),ce.addGetterSetter(Wi,"cropX",0,mt()),ce.addGetterSetter(Wi,"cropY",0,mt()),ce.addGetterSetter(Wi,"cropWidth",0,mt()),ce.addGetterSetter(Wi,"cropHeight",0,mt());var a4=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],jO="Change.konva",UO="none",z0="up",V0="right",H0="down",j0="left",GO=a4.length,U0=class extends yu{constructor(e){super(e),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){let t=this,n;const r=function(){t._sync()};for(n=0;n<GO;n++)e.on(a4[n]+jO,r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),n,r,o,i,s,a,l;if(e&&t){switch(n=e.width(),r=e.height(),o=t.pointerDirection(),i=t.pointerWidth(),l=t.pointerHeight(),s=0,a=0,o){case z0:s=n/2,a=-1*l;break;case V0:s=n+i,a=r/2;break;case H0:s=n/2,a=r+l;break;case j0:s=-1*i,a=r/2;break}t.setAttrs({x:-1*s,y:-1*a,width:n,height:r}),e.setAttrs({x:-1*s,y:-1*a})}}};U0.prototype.className="Label",wr(U0);var ac=class extends dt{_sceneFunc(e){const t=this.width(),n=this.height(),r=this.pointerDirection(),o=this.pointerWidth(),i=this.pointerHeight(),s=this.cornerRadius();let a=0,l=0,u=0,c=0;typeof s=="number"?a=l=u=c=Math.min(s,t/2,n/2):(a=Math.min(s[0]||0,t/2,n/2),l=Math.min(s[1]||0,t/2,n/2),c=Math.min(s[2]||0,t/2,n/2),u=Math.min(s[3]||0,t/2,n/2)),e.beginPath(),e.moveTo(a,0),r===z0&&(e.lineTo((t-o)/2,0),e.lineTo(t/2,-1*i),e.lineTo((t+o)/2,0)),e.lineTo(t-l,0),e.arc(t-l,l,l,Math.PI*3/2,0,!1),r===V0&&(e.lineTo(t,(n-i)/2),e.lineTo(t+o,n/2),e.lineTo(t,(n+i)/2)),e.lineTo(t,n-c),e.arc(t-c,n-c,c,0,Math.PI/2,!1),r===H0&&(e.lineTo((t+o)/2,n),e.lineTo(t/2,n+i),e.lineTo((t-o)/2,n)),e.lineTo(u,n),e.arc(u,n-u,u,Math.PI/2,Math.PI,!1),r===j0&&(e.lineTo(0,(n+i)/2),e.lineTo(-1*o,n/2),e.lineTo(0,(n-i)/2)),e.lineTo(0,a),e.arc(a,a,a,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=0,t=0,n=this.pointerWidth(),r=this.pointerHeight(),o=this.pointerDirection(),i=this.width(),s=this.height();return o===z0?(t-=r,s+=r):o===H0?s+=r:o===j0?(e-=n*1.5,i+=n):o===V0&&(i+=n*1.5),{x:e,y:t,width:i,height:s}}};ac.prototype.className="Tag",wr(ac),ce.addGetterSetter(ac,"pointerDirection",UO),ce.addGetterSetter(ac,"pointerWidth",0,mt()),ce.addGetterSetter(ac,"pointerHeight",0,mt()),ce.addGetterSetter(ac,"cornerRadius",0,qp(4));var Lf=class extends dt{_sceneFunc(e){const t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?Ie.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};Lf.prototype.className="Rect",wr(Lf),ce.addGetterSetter(Lf,"cornerRadius",0,qp(4));var sl=class extends dt{_sceneFunc(e){const t=this._getPoints(),n=this.radius(),r=this.sides(),o=this.cornerRadius();if(e.beginPath(),o)Ie.drawRoundedPolygonPath(e,t,r,n,o);else{e.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length;i++)e.lineTo(t[i].x,t[i].y)}e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,t=this.attrs.radius||0,n=[];for(let r=0;r<e;r++)n.push({x:t*Math.sin(r*2*Math.PI/e),y:-1*t*Math.cos(r*2*Math.PI/e)});return n}getSelfRect(){const e=this._getPoints();let t=e[0].x,n=e[0].x,r=e[0].y,o=e[0].y;return e.forEach(i=>{t=Math.min(t,i.x),n=Math.max(n,i.x),r=Math.min(r,i.y),o=Math.max(o,i.y)}),{x:t,y:r,width:n-t,height:o-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};sl.prototype.className="RegularPolygon",sl.prototype._centroid=!0,sl.prototype._attrsAffectingSize=["radius"],wr(sl),ce.addGetterSetter(sl,"radius",0,mt()),ce.addGetterSetter(sl,"sides",0,mt()),ce.addGetterSetter(sl,"cornerRadius",0,qp(4));var l4=Math.PI*2,lc=class extends dt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,l4,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),l4,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};lc.prototype.className="Ring",lc.prototype._centroid=!0,lc.prototype._attrsAffectingSize=["innerRadius","outerRadius"],wr(lc),ce.addGetterSetter(lc,"innerRadius",0,mt()),ce.addGetterSetter(lc,"outerRadius",0,mt());var Cs=class extends dt{constructor(e){super(e),this._updated=!0,this.anim=new bu(()=>{const t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){const t=this.animation(),n=this.frameIndex(),r=n*4,o=this.animations()[t],i=this.frameOffsets(),s=o[r+0],a=o[r+1],l=o[r+2],u=o[r+3],c=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,l,u),e.closePath(),e.fillStrokeShape(this)),c)if(i){const d=i[t],h=n*2;e.drawImage(c,s,a,l,u,d[h+0],d[h+1],l,u)}else e.drawImage(c,s,a,l,u,0,0,l,u)}_hitFunc(e){const t=this.animation(),n=this.frameIndex(),r=n*4,o=this.animations()[t],i=this.frameOffsets(),s=o[r+2],a=o[r+3];if(e.beginPath(),i){const l=i[t],u=n*2;e.rect(l[u+0],l[u+1],s,a)}else e.rect(0,0,s,a);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const e=this.frameIndex(),t=this.animation();e<this.animations()[t].length/4-1?this.frameIndex(e+1):this.frameIndex(0)}};Cs.prototype.className="Sprite",wr(Cs),ce.addGetterSetter(Cs,"animation"),ce.addGetterSetter(Cs,"animations"),ce.addGetterSetter(Cs,"frameOffsets"),ce.addGetterSetter(Cs,"image"),ce.addGetterSetter(Cs,"frameIndex",0,mt()),ce.addGetterSetter(Cs,"frameRate",17,mt()),ce.backCompat(Cs,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var al=class extends dt{_sceneFunc(e){const t=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(let o=1;o<r*2;o++){const i=o%2===0?n:t,s=i*Math.sin(o*Math.PI/r),a=-1*i*Math.cos(o*Math.PI/r);e.lineTo(s,a)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};al.prototype.className="Star",al.prototype._centroid=!0,al.prototype._attrsAffectingSize=["innerRadius","outerRadius"],wr(al),ce.addGetterSetter(al,"numPoints",5,mt()),ce.addGetterSetter(al,"innerRadius",0,mt()),ce.addGetterSetter(al,"outerRadius",0,mt());function ll(e){return[...e].reduce((t,n,r,o)=>{if(/\p{Emoji}/u.test(n)){const i=o[r+1];i&&/\p{Emoji_Modifier}|\u200D/u.test(i)?(t.push(n+i),o[r+1]=""):t.push(n)}else/\p{Regional_Indicator}{2}/u.test(n+(o[r+1]||""))?t.push(n+o[r+1]):r>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(n)?t[t.length-1]+=n:n&&t.push(n);return t},[])}var Cu="auto",WO="center",c4="inherit",Pf="justify",KO="Change.konva",u4="2d",d4="-",f4="left",qO="text",YO="Text",XO="top",ZO="bottom",h4="middle",p4="normal",QO="px ",nm=" ",JO="right",m4="rtl",$O="word",eF="char",g4="none",G0="β¦",v4=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],tF=v4.length,Df=null;function nF(){if(Df!==null)return Df;Df=!1;try{const e=document.createElement("canvas");e.width=10,e.height=10;const t=e.getContext(u4);if(t){t.globalAlpha=0,t.shadowColor="black",t.shadowBlur=5,t.shadowOffsetX=5,t.shadowOffsetY=5,t.fillStyle="black",t.font="10px Arial",t.fillText("X",0,10);const n=t.getImageData(0,0,10,10).data;for(let r=3;r<n.length;r+=4)if(n[r]>0){Df=!0;break}}}catch{}return Df}function rF(e){return e.split(",").map(t=>{t=t.trim();const n=t.indexOf(" ")>=0,r=t.indexOf('"')>=0||t.indexOf("'")>=0;return n&&!r&&(t=`"${t}"`),t}).join(", ")}var rm;function W0(){return rm||(rm=Ie.createCanvasElement().getContext(u4),rm)}function oF(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function iF(e){e.setAttr("miterLimit",2),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function sF(e){return e=e||{},!e.fillLinearGradientColorStops&&!e.fillRadialGradientColorStops&&!e.fillPatternImage&&(e.fill=e.fill||"black"),e}var tr=class extends dt{constructor(e){super(sF(e)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<tF;t++)this.on(v4[t]+KO,this._setTextData);this._setTextData()}_sceneFunc(e){var t,n;const r=this.textArr,o=r.length;if(!this.text())return;let i=this.padding(),s=this.fontSize(),a=this.lineHeight()*s,l=this.verticalAlign(),u=this.direction(),c=0,d=this.align(),h=this.getWidth(),m=this.letterSpacing(),p=this.charRenderFunc(),v=this.fill(),_=this.textDecoration(),C=this.underlineOffset(),k=_.indexOf("underline")!==-1,y=_.indexOf("line-through")!==-1,b;u=u===c4?e.direction:u;let T=a/2,R=h4;if(!bt.legacyTextRendering){const P=this.measureSize("M");R="alphabetic",T=(((t=P.fontBoundingBoxAscent)!==null&&t!==void 0?t:P.actualBoundingBoxAscent)-((n=P.fontBoundingBoxDescent)!==null&&n!==void 0?n:P.actualBoundingBoxDescent))/2+a/2}for(u===m4&&e.setAttr("direction",u),e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",R),e.setAttr("textAlign",f4),l===h4?c=(this.getHeight()-o*a-i*2)/2:l===ZO&&(c=this.getHeight()-o*a-i*2),e.translate(i,c+i),b=0;b<o;b++){let P=0,j=0;const O=r[b],V=O.text,Q=O.width,F=O.lastInParagraph;if(e.save(),d===JO?P+=h-Q-i*2:d===WO&&(P+=(h-Q-i*2)/2),k){e.save(),e.beginPath();const x=C??(bt.legacyTextRendering?Math.round(s/2):Math.round(s/4)),z=P,J=T+j+x;e.moveTo(z,J);const X=d===Pf&&!F?h-i*2:Q;e.lineTo(z+Math.round(X),J),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||v,e.stroke(),e.restore()}const N=P;if(u!==m4&&(m!==0||d===Pf||p)){const x=V.split(" ").length-1,z=ll(V);for(let J=0;J<z.length;J++){const X=z[J];if(X===" "&&!F&&d===Pf&&(P+=(h-i*2-Q)/x),this._partialTextX=P,this._partialTextY=T+j,this._partialText=X,p){e.save();const ae=r.slice(0,b).reduce((pe,Fe)=>pe+ll(Fe.text).length,0);p({char:X,index:J+ae,x:P,y:T+j,lineIndex:b,column:J,isLastInLine:F,width:this.measureSize(X).width,context:e})}e.fillStrokeShape(this),p&&e.restore(),P+=this.measureSize(X).width+m}}else m!==0&&e.setAttr("letterSpacing",`${m}px`),this._partialTextX=P,this._partialTextY=T+j,this._partialText=V,e.fillStrokeShape(this);if(y){e.save(),e.beginPath();const x=bt.legacyTextRendering?0:-Math.round(s/4),z=N;e.moveTo(z,T+j+x);const J=d===Pf&&!F?h-i*2:Q;e.lineTo(z+Math.round(J),T+j+x),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||v,e.stroke(),e.restore()}e.restore(),o>1&&(T+=a)}}_hitFunc(e){const t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){const t=Ie._isString(e)?e:e==null?"":e+"";return this._setAttr(qO,t),this}getWidth(){return this.attrs.width===Cu||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===Cu||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Ie.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var t,n,r,o,i,s,a,l,u,c,d;let h=W0(),m=this.fontSize(),p;h.save(),h.font=this._getContextFont(),p=h.measureText(e),h.restore();const v=m/100;return{actualBoundingBoxAscent:(t=p.actualBoundingBoxAscent)!==null&&t!==void 0?t:71.58203125*v,actualBoundingBoxDescent:(n=p.actualBoundingBoxDescent)!==null&&n!==void 0?n:0,actualBoundingBoxLeft:(r=p.actualBoundingBoxLeft)!==null&&r!==void 0?r:-7.421875*v,actualBoundingBoxRight:(o=p.actualBoundingBoxRight)!==null&&o!==void 0?o:75.732421875*v,alphabeticBaseline:(i=p.alphabeticBaseline)!==null&&i!==void 0?i:0,emHeightAscent:(s=p.emHeightAscent)!==null&&s!==void 0?s:100*v,emHeightDescent:(a=p.emHeightDescent)!==null&&a!==void 0?a:-20*v,fontBoundingBoxAscent:(l=p.fontBoundingBoxAscent)!==null&&l!==void 0?l:91*v,fontBoundingBoxDescent:(u=p.fontBoundingBoxDescent)!==null&&u!==void 0?u:21*v,hangingBaseline:(c=p.hangingBaseline)!==null&&c!==void 0?c:72.80000305175781*v,ideographicBaseline:(d=p.ideographicBaseline)!==null&&d!==void 0?d:-21*v,width:p.width,height:m}}_getContextFont(){return this.fontStyle()+nm+this.fontVariant()+nm+(this.fontSize()+QO)+rF(this.fontFamily())}_addTextLine(e){this.align()===Pf&&(e=e.trim());const t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){const t=this.letterSpacing(),n=e.length;return W0().measureText(e).width+t*n}_setTextData(){let e=this.text().split(`
|
|
100
100
|
`),t=+this.fontSize(),n=0,r=this.lineHeight()*t,o=this.attrs.width,i=this.attrs.height,s=o!==Cu&&o!==void 0,a=i!==Cu&&i!==void 0,l=this.padding(),u=o-l*2,c=i-l*2,d=0,h=this.wrap(),m=h!==eF&&h!==g4,p=this.ellipsis();this.textArr=[],W0().font=this._getContextFont();const v=p?this._getTextWidth(G0):0;for(let _=0,C=e.length;_<C;++_){let k=e[_],y=this._getTextWidth(k);if(s&&y>u)for(;k.length>0;){let b=0,T=ll(k).length,R="",P=0;for(;b<T;){const j=b+T>>>1,O=ll(k).slice(0,j+1).join(""),V=this._getTextWidth(O);(p&&a&&d+r>c?V+v:V)<=u?(b=j+1,R=O,P=V):T=j}if(R){if(m){const j=ll(k),O=ll(R),V=j[O.length],Q=V===nm||V===d4;let F;if(Q&&P<=u)F=O.length;else{const N=O.lastIndexOf(nm),x=O.lastIndexOf(d4);F=Math.max(N,x)+1}F>0&&(b=F,R=j.slice(0,b).join(""),P=this._getTextWidth(R))}if(R=R.trimRight(),this._addTextLine(R),n=Math.max(n,P),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(k=ll(k).slice(b).join("").trimLeft(),k.length>0&&(y=this._getTextWidth(k),y<=u)){this._addTextLine(k),d+=r,n=Math.max(n,y);break}}else break}else this._addTextLine(k),d+=r,n=Math.max(n,y),this._shouldHandleEllipsis(d)&&_<C-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),a&&d+r>c)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){const t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,o=r!==Cu&&r!==void 0,i=r-this.padding()*2;return this.wrap()===g4||o&&e+n>i}_tryToAddEllipsisToLastLine(){const e=this.attrs.width,t=e!==Cu&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),o=this.textArr[this.textArr.length-1];!o||!r||(t&&(this._getTextWidth(o.text+G0)<n||(o.text=o.text.slice(0,o.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(o.text+G0))}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const e=this.textDecoration().indexOf("underline")!==-1||this.textDecoration().indexOf("line-through")!==-1,t=this.hasShadow();return e&&t||t&&this.getAbsoluteOpacity()!==1&&nF()?!0:super._useBufferCanvas()}};tr.prototype._fillFunc=oF,tr.prototype._strokeFunc=iF,tr.prototype.className=YO,tr.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],wr(tr),ce.overWriteSetter(tr,"width",I0()),ce.overWriteSetter(tr,"height",I0()),ce.addGetterSetter(tr,"direction",c4),ce.addGetterSetter(tr,"fontFamily","Arial"),ce.addGetterSetter(tr,"fontSize",12,mt()),ce.addGetterSetter(tr,"fontStyle",p4),ce.addGetterSetter(tr,"fontVariant",p4),ce.addGetterSetter(tr,"padding",0,mt()),ce.addGetterSetter(tr,"align",f4),ce.addGetterSetter(tr,"verticalAlign",XO),ce.addGetterSetter(tr,"lineHeight",1,mt()),ce.addGetterSetter(tr,"wrap",$O),ce.addGetterSetter(tr,"ellipsis",!1,Gi()),ce.addGetterSetter(tr,"letterSpacing",0,mt()),ce.addGetterSetter(tr,"text","",rc()),ce.addGetterSetter(tr,"textDecoration",""),ce.addGetterSetter(tr,"underlineOffset",void 0,mt()),ce.addGetterSetter(tr,"charRenderFunc",void 0);var aF="",y4="normal";function b4(e){e.fillText(this.partialText,0,0)}function w4(e){e.strokeText(this.partialText,0,0)}var qr=class extends dt{constructor(e){super(e),this.dummyCanvas=Ie.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return Ei.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:Ei.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=Ei.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();const t=this.textDecoration(),n=this.fill(),r=this.fontSize(),o=this.glyphInfo,i=t.indexOf("underline")!==-1,s=t.indexOf("line-through")!==-1;i&&e.beginPath();for(let a=0;a<o.length;a++){e.save();const l=o[a].p0;e.translate(l.x,l.y),e.rotate(o[a].rotation),this.partialText=o[a].text,e.fillStrokeShape(this),i&&(a===0&&e.moveTo(0,r/2+1),e.lineTo(o[a].width,r/2+1)),e.restore()}if(i&&(e.strokeStyle=n,e.lineWidth=r/20,e.stroke()),s){e.beginPath();for(let a=0;a<o.length;a++){e.save();const l=o[a].p0;e.translate(l.x,l.y),e.rotate(o[a].rotation),a===0&&e.moveTo(0,0),e.lineTo(o[a].width,0),e.restore()}e.strokeStyle=n,e.lineWidth=r/20,e.stroke()}e.restore()}_hitFunc(e){e.beginPath();const t=this.glyphInfo;if(t.length>=1){const n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;n<t.length;n++){const r=t[n].p1;e.lineTo(r.x,r.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Ie.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return tr.prototype.setText.call(this,e)}_getContextFont(){return tr.prototype._getContextFont.call(this)}_getTextSize(e){const t=this.dummyCanvas.getContext("2d");t.save(),t.font=this._getContextFont();const n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const e=ll(this.text()),t=[];let n=0;for(let h=0;h<e.length;h++)t.push({char:e[h],width:this._getTextSize(e[h]).width}),n+=t[h].width;const{width:r,height:o}=this._getTextSize(this.attrs.text);if(this.textWidth=n,this.textHeight=o,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),l=Math.max(0,n-r),u=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let c=0;s==="center"&&(c=Math.max(0,this.pathLength/2-u/2)),s==="right"&&(c=Math.max(0,this.pathLength-u));let d=c;for(let h=0;h<t.length;h++){const m=this._getPointAtLength(d);if(!m)return;const p=t[h].char;let v=t[h].width+i;if(p===" "&&s==="justify"){const R=this.text().split(" ").length-1;v+=(this.pathLength-u)/R}const _=d+v,C=this._getPointAtLength(_>this.pathLength&&_-this.pathLength<=l?this.pathLength:_);if(!C)return;const k=Ei.getLineLength(m.x,m.y,C.x,C.y);let y=0;if(a)try{y=a(t[h-1].char,p)*this.fontSize()}catch{y=0}m.x+=y,C.x+=y,this.textWidth+=y;const b=Ei.getPointOnLine(y+k/2,m.x,m.y,C.x,C.y),T=Math.atan2(C.y-m.y,C.x-m.x);this.glyphInfo.push({transposeX:b.x,transposeY:b.y,text:e[h],rotation:T,p0:m,p1:C,width:k}),d+=v}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const e=[];this.glyphInfo.forEach(function(l){e.push(l.p0.x),e.push(l.p0.y),e.push(l.p1.x),e.push(l.p1.y)});let t=e[0]||0,n=e[0]||0,r=e[1]||0,o=e[1]||0,i,s;for(let l=0;l<e.length/2;l++)i=e[l*2],s=e[l*2+1],t=Math.min(t,i),n=Math.max(n,i),r=Math.min(r,s),o=Math.max(o,s);const a=this.fontSize();return{x:t-a/2,y:r-a/2,width:n-t+a,height:o-r+a}}destroy(){return Ie.releaseCanvas(this.dummyCanvas),super.destroy()}};qr.prototype._fillFunc=b4,qr.prototype._strokeFunc=w4,qr.prototype._fillFuncHit=b4,qr.prototype._strokeFuncHit=w4,qr.prototype.className="TextPath",qr.prototype._attrsAffectingSize=["text","fontSize","data"],wr(qr),ce.addGetterSetter(qr,"data"),ce.addGetterSetter(qr,"fontFamily","Arial"),ce.addGetterSetter(qr,"fontSize",12,mt()),ce.addGetterSetter(qr,"fontStyle",y4),ce.addGetterSetter(qr,"align","left"),ce.addGetterSetter(qr,"letterSpacing",0,mt()),ce.addGetterSetter(qr,"textBaseline","middle"),ce.addGetterSetter(qr,"fontVariant",y4),ce.addGetterSetter(qr,"text",aF),ce.addGetterSetter(qr,"textDecoration",""),ce.addGetterSetter(qr,"kerningFunc",void 0);var C4="tr-konva",lF=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(e=>e+`.${C4}`).join(" "),_4="nodesRect",cF=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],uF={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},dF="ontouchstart"in bt._global;function fF(e,t,n){if(e==="rotater")return n;t+=Ie.degToRad(uF[e]||0);const r=(Ie.radToDeg(t)%360+360)%360;return Ie._inRange(r,337.5,360)||Ie._inRange(r,0,22.5)?"ns-resize":Ie._inRange(r,22.5,67.5)?"nesw-resize":Ie._inRange(r,67.5,112.5)?"ew-resize":Ie._inRange(r,112.5,157.5)?"nwse-resize":Ie._inRange(r,157.5,202.5)?"ns-resize":Ie._inRange(r,202.5,247.5)?"nesw-resize":Ie._inRange(r,247.5,292.5)?"ew-resize":Ie._inRange(r,292.5,337.5)?"nwse-resize":(Ie.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}var om=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],S4=1e8;function hF(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function k4(e,t,n){const r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),o=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:o}}function pF(e,t){return k4(e,t,hF(e))}function mF(e,t,n){let r=t;for(let o=0;o<e.length;o++){const i=bt.getAngle(e[o]),s=Math.abs(i-t)%(Math.PI*2);Math.min(s,Math.PI*2-s)<n&&(r=i)}return r}var K0=0,En=class extends yu{constructor(e){super(e),this._movingAnchorName=null,this._transforming=!1,this._elementsCreated=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(lF,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return Ie.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return C4+this._id}setNodes(e=[]){return this._nodes&&this._nodes.length&&this.detach(),this._nodes=e=e.filter(t=>t.isAncestorOf(this)?(Ie.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1):!0),e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const n=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()};if(t._attrsAffectingSize.length){const r=t._attrsAffectingSize.map(o=>o+"Change."+this._getEventNamespace()).join(" ");t.on(r,n)}t.on(cF.map(r=>r+`.${this._getEventNamespace()}`).join(" "),n),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,n),this._proxyDrag(t)}),this._resetTransformCache(),this.findOne(".top-left")&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;const r=e.getAbsolutePosition(),o=r.x-t.x,i=r.y-t.y;this.nodes().forEach(s=>{if(s===e||s.isDragging())return;const a=s.getAbsolutePosition();s.setAbsolutePosition({x:a.x+o,y:a.y+i}),s.startDrag(n)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(_4),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(_4,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){const r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),o=e.getAbsoluteScale(n),i=e.getAbsolutePosition(n),s=r.x*o.x-e.offsetX()*o.x,a=r.y*o.y-e.offsetY()*o.y,l=(bt.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return k4({x:i.x+s*Math.cos(l)+a*Math.sin(-l),y:i.y+a*Math.cos(l)+s*Math.sin(l),width:r.width*o.x,height:r.height*o.y,rotation:l},-bt.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-S4,y:-S4,width:0,height:0,rotation:0};const e=[];this.nodes().map(a=>{const l=a.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),u=[{x:l.x,y:l.y},{x:l.x+l.width,y:l.y},{x:l.x+l.width,y:l.y+l.height},{x:l.x,y:l.y+l.height}],c=a.getAbsoluteTransform();u.forEach(function(d){const h=c.point(d);e.push(h)})});const t=new Ui;t.rotate(-bt.getAngle(this.rotation()));let n=1/0,r=1/0,o=-1/0,i=-1/0;e.forEach(function(a){const l=t.point(a);n===void 0&&(n=o=l.x,r=i=l.y),n=Math.min(n,l.x),r=Math.min(r,l.y),o=Math.max(o,l.x),i=Math.max(i,l.y)}),t.invert();const s=t.point({x:n,y:r});return{x:s.x,y:s.y,width:o-n,height:i-r,rotation:bt.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),om.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){const t=new Lf({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:dF?10:"auto"}),n=this;t.on("mousedown touchstart",function(r){n._handleMouseDown(r)}),t.on("dragstart",r=>{t.stopDrag(),r.cancelBubble=!0}),t.on("dragend",r=>{r.cancelBubble=!0}),t.on("mouseenter",()=>{const r=fF(e,bt.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=r),this._cursorChange=!0}),t.on("mouseout",()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(t)}_createBack(){const e=new dt({name:"back",width:0,height:0,sceneFunc(t,n){const r=n.getParent(),o=r.padding(),i=n.width(),s=n.height();if(t.beginPath(),t.rect(-o,-o,i+o*2,s+o*2),r.rotateEnabled()&&r.rotateLineVisible()){const a=r.rotateAnchorAngle(),l=r.rotateAnchorOffset(),u=Ie.degToRad(a),c=Math.sin(u),d=-Math.cos(u),h=i/2,m=s/2;let p=1/0;d<0?p=Math.min(p,-m/d):d>0&&(p=Math.min(p,(s-m)/d)),c<0?p=Math.min(p,-h/c):c>0&&(p=Math.min(p,(i-h)/c));const v=h+c*p,_=m+d*p,C=Ie._sign(s),k=v+c*l*C,y=_+d*l*C;t.moveTo(v,_),t.lineTo(k,y)}t.fillStrokeShape(n)},hitFunc:(t,n)=>{if(!this.shouldOverdrawWholeArea())return;const r=this.padding();t.beginPath(),t.rect(-r,-r,n.width()+r*2,n.height()+r*2),t.fillStrokeShape(n)}});this.add(e),this._proxyDrag(e),e.on("dragstart",t=>{t.cancelBubble=!0}),e.on("dragmove",t=>{t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(e){if(this._transforming)return;this._movingAnchorName=e.target.name().split(" ")[0];const t=this._getNodeRect(),n=t.width,r=t.height,o=Math.sqrt(Math.pow(n,2)+Math.pow(r,2));this.sin=Math.abs(r/o),this.cos=Math.abs(n/o),typeof window<"u"&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const i=e.target.getAbsolutePosition(),s=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:s.x-i.x,y:s.y-i.y},K0++,this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach(a=>{a._fire("transformstart",{evt:e.evt,target:a})})}_handleMouseMove(e){let t,n,r;const o=this.findOne("."+this._movingAnchorName),i=o.getStage();i.setPointersPositions(e);const s=i.getPointerPosition();let a={x:s.x-this._anchorDragOffset.x,y:s.y-this._anchorDragOffset.y};const l=o.getAbsolutePosition();this.anchorDragBoundFunc()&&(a=this.anchorDragBoundFunc()(l,a,e)),o.setAbsolutePosition(a);const u=o.getAbsolutePosition();if(l.x===u.x&&l.y===u.y)return;if(this._movingAnchorName==="rotater"){const C=this._getNodeRect();t=o.x()-C.width/2,n=-o.y()+C.height/2;const k=bt.getAngle(this.rotateAnchorAngle());let y=Math.atan2(-n,t)+Math.PI/2-k;C.height<0&&(y-=Math.PI);const b=bt.getAngle(this.rotation())+y,T=bt.getAngle(this.rotationSnapTolerance()),R=pF(C,mF(this.rotationSnaps(),b,T)-C.rotation);this._fitNodesInto(R,e);return}const c=this.shiftBehavior();let d;c==="inverted"?d=this.keepRatio()&&!e.shiftKey:c==="none"?d=this.keepRatio():d=this.keepRatio()||e.shiftKey;let h=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(d){const C=h?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(C.x-o.x(),2)+Math.pow(C.y-o.y(),2));const k=this.findOne(".top-left").x()>C.x?-1:1,y=this.findOne(".top-left").y()>C.y?-1:1;t=r*this.cos*k,n=r*this.sin*y,this.findOne(".top-left").x(C.x-t),this.findOne(".top-left").y(C.y-n)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(o.y());else if(this._movingAnchorName==="top-right"){if(d){const C=h?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(o.x()-C.x,2)+Math.pow(C.y-o.y(),2));const k=this.findOne(".top-right").x()<C.x?-1:1,y=this.findOne(".top-right").y()>C.y?-1:1;t=r*this.cos*k,n=r*this.sin*y,this.findOne(".top-right").x(C.x+t),this.findOne(".top-right").y(C.y-n)}var m=o.position();this.findOne(".top-left").y(m.y),this.findOne(".bottom-right").x(m.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(o.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(o.x());else if(this._movingAnchorName==="bottom-left"){if(d){const C=h?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(C.x-o.x(),2)+Math.pow(o.y()-C.y,2));const k=C.x<o.x()?-1:1,y=o.y()<C.y?-1:1;t=r*this.cos*k,n=r*this.sin*y,o.x(C.x-t),o.y(C.y+n)}m=o.position(),this.findOne(".top-left").x(m.x),this.findOne(".bottom-right").y(m.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(o.y());else if(this._movingAnchorName==="bottom-right"){if(d){const C=h?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(o.x()-C.x,2)+Math.pow(o.y()-C.y,2));const k=this.findOne(".bottom-right").x()<C.x?-1:1,y=this.findOne(".bottom-right").y()<C.y?-1:1;t=r*this.cos*k,n=r*this.sin*y,this.findOne(".bottom-right").x(C.x+t),this.findOne(".bottom-right").y(C.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(h=this.centeredScaling()||e.altKey,h){const C=this.findOne(".top-left"),k=this.findOne(".bottom-right"),y=C.x(),b=C.y(),T=this.getWidth()-k.x(),R=this.getHeight()-k.y();k.move({x:-y,y:-b}),C.move({x:T,y:R})}const p=this.findOne(".top-left").getAbsolutePosition();t=p.x,n=p.y;const v=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),_=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:n,width:v,height:_,rotation:bt.getAngle(this.rotation())},e)}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){var t;if(this._transforming){this._transforming=!1,typeof window<"u"&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const n=this.getNode();K0--,this._fire("transformend",{evt:e,target:n}),(t=this.getLayer())===null||t===void 0||t.batchDraw(),n&&this._nodes.forEach(r=>{var o;r._fire("transformend",{evt:e,target:r}),(o=r.getLayer())===null||o===void 0||o.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t){const n=this._getNodeRect(),r=1;if(Ie._inRange(e.width,-this.padding()*2-r,r)){this.update();return}if(Ie._inRange(e.height,-this.padding()*2-r,r)){this.update();return}const o=new Ui;if(o.rotate(bt.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const d=o.point({x:-this.padding()*2,y:0});e.x+=d.x,e.y+=d.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const d=o.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const d=o.point({x:0,y:-this.padding()*2});e.x+=d.x,e.y+=d.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const d=o.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){const d=this.boundBoxFunc()(n,e);d?e=d:Ie.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const i=1e7,s=new Ui;s.translate(n.x,n.y),s.rotate(n.rotation),s.scale(n.width/i,n.height/i);const a=new Ui,l=e.width/i,u=e.height/i;this.flipEnabled()===!1?(a.translate(e.x,e.y),a.rotate(e.rotation),a.translate(e.width<0?e.width:0,e.height<0?e.height:0),a.scale(Math.abs(l),Math.abs(u))):(a.translate(e.x,e.y),a.rotate(e.rotation),a.scale(l,u));const c=a.multiply(s.invert());this._nodes.forEach(d=>{var h;if(!d.getStage())return;const m=d.getParent().getAbsoluteTransform(),p=d.getTransform().copy();p.translate(d.offsetX(),d.offsetY());const v=new Ui;v.multiply(m.copy().invert()).multiply(c).multiply(m).multiply(p);const _=v.decompose();d.setAttrs(_),(h=d.getLayer())===null||h===void 0||h.batchDraw()}),this.rotation(Ie._getRotation(e.rotation)),this._nodes.forEach(d=>{this._fire("transform",{evt:t,target:d}),d._fire("transform",{evt:t,target:d})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e;const t=this._getNodeRect();this.rotation(Ie._getRotation(t.rotation));const n=t.width,r=t.height,o=this.enabledAnchors(),i=this.resizeEnabled(),s=this.padding(),a=this.anchorSize(),l=this.find("._anchor");l.forEach(T=>{T.setAttrs({width:a,height:a,offsetX:a/2,offsetY:a/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:a/2+s,offsetY:a/2+s,visible:i&&o.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:a/2+s,visible:i&&o.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:a/2-s,offsetY:a/2+s,visible:i&&o.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:a/2+s,visible:i&&o.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:a/2-s,visible:i&&o.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:a/2+s,offsetY:a/2-s,visible:i&&o.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:a/2-s,visible:i&&o.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:a/2-s,offsetY:a/2-s,visible:i&&o.indexOf("bottom-right")>=0});const u=this.rotateAnchorAngle(),c=this.rotateAnchorOffset(),d=Ie.degToRad(u),h=Math.sin(d),m=-Math.cos(d),p=n/2,v=r/2;let _=1/0;m<0?_=Math.min(_,-v/m):m>0&&(_=Math.min(_,(r-v)/m)),h<0?_=Math.min(_,-p/h):h>0&&(_=Math.min(_,(n-p)/h));const C=p+h*_,k=v+m*_,y=Ie._sign(r);this._batchChangeChild(".rotater",{x:C+h*c*y,y:k+m*c*y-s*m,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(T=>T.draggable()),x:0,y:0});const b=this.anchorStyleFunc();b&&l.forEach(T=>{b(T)}),(e=this.getLayer())===null||e===void 0||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),yu.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(Ie.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this):super.add(...e)}toObject(){return wt.prototype.toObject.call(this)}clone(e){return wt.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};En.isTransforming=()=>K0>0;function gF(e){return e instanceof Array||Ie.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(t){om.indexOf(t)===-1&&Ie.warn("Unknown anchor name: "+t+". Available names are: "+om.join(", "))}),e||[]}En.prototype.className="Transformer",wr(En),ce.addGetterSetter(En,"enabledAnchors",om,gF),ce.addGetterSetter(En,"flipEnabled",!0,Gi()),ce.addGetterSetter(En,"resizeEnabled",!0),ce.addGetterSetter(En,"anchorSize",10,mt()),ce.addGetterSetter(En,"rotateEnabled",!0),ce.addGetterSetter(En,"rotateLineVisible",!0),ce.addGetterSetter(En,"rotationSnaps",[]),ce.addGetterSetter(En,"rotateAnchorOffset",50,mt()),ce.addGetterSetter(En,"rotateAnchorAngle",0,mt()),ce.addGetterSetter(En,"rotateAnchorCursor","crosshair"),ce.addGetterSetter(En,"rotationSnapTolerance",5,mt()),ce.addGetterSetter(En,"borderEnabled",!0),ce.addGetterSetter(En,"anchorStroke","rgb(0, 161, 255)"),ce.addGetterSetter(En,"anchorStrokeWidth",1,mt()),ce.addGetterSetter(En,"anchorFill","white"),ce.addGetterSetter(En,"anchorCornerRadius",0,mt()),ce.addGetterSetter(En,"borderStroke","rgb(0, 161, 255)"),ce.addGetterSetter(En,"borderStrokeWidth",1,mt()),ce.addGetterSetter(En,"borderDash"),ce.addGetterSetter(En,"keepRatio",!0),ce.addGetterSetter(En,"shiftBehavior","default"),ce.addGetterSetter(En,"centeredScaling",!1),ce.addGetterSetter(En,"ignoreStroke",!1),ce.addGetterSetter(En,"padding",0,mt()),ce.addGetterSetter(En,"nodes"),ce.addGetterSetter(En,"node"),ce.addGetterSetter(En,"boundBoxFunc"),ce.addGetterSetter(En,"anchorDragBoundFunc"),ce.addGetterSetter(En,"anchorStyleFunc"),ce.addGetterSetter(En,"shouldOverdrawWholeArea",!1),ce.addGetterSetter(En,"useSingleNodeRotation",!0),ce.backCompat(En,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var ha=class extends dt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,bt.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};ha.prototype.className="Wedge",ha.prototype._centroid=!0,ha.prototype._attrsAffectingSize=["radius"],wr(ha),ce.addGetterSetter(ha,"radius",0,mt()),ce.addGetterSetter(ha,"angle",0,mt()),ce.addGetterSetter(ha,"clockwise",!1),ce.backCompat(ha,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function A4(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var vF=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],yF=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function bF(e,t){const n=e.data,r=e.width,o=e.height;let i,s,a,l,u,c,d,h,m,p,v,_,C,k,y,b,T,R,P,j;const O=t+t+1,V=r-1,Q=o-1,F=t+1,N=F*(F+1)/2,x=new A4,z=vF[t],J=yF[t];let X=null,ae=x,pe=null,Fe=null;for(let fe=1;fe<O;fe++)ae=ae.next=new A4,fe===F&&(X=ae);ae.next=x,a=s=0;for(let fe=0;fe<o;fe++){_=C=k=y=l=u=c=d=0,h=F*(b=n[s]),m=F*(T=n[s+1]),p=F*(R=n[s+2]),v=F*(P=n[s+3]),l+=N*b,u+=N*T,c+=N*R,d+=N*P,ae=x;for(let ye=0;ye<F;ye++)ae.r=b,ae.g=T,ae.b=R,ae.a=P,ae=ae.next;for(let ye=1;ye<F;ye++)i=s+((V<ye?V:ye)<<2),l+=(ae.r=b=n[i])*(j=F-ye),u+=(ae.g=T=n[i+1])*j,c+=(ae.b=R=n[i+2])*j,d+=(ae.a=P=n[i+3])*j,_+=b,C+=T,k+=R,y+=P,ae=ae.next;pe=x,Fe=X;for(let ye=0;ye<r;ye++)n[s+3]=P=d*z>>J,P!==0?(P=255/P,n[s]=(l*z>>J)*P,n[s+1]=(u*z>>J)*P,n[s+2]=(c*z>>J)*P):n[s]=n[s+1]=n[s+2]=0,l-=h,u-=m,c-=p,d-=v,h-=pe.r,m-=pe.g,p-=pe.b,v-=pe.a,i=a+((i=ye+t+1)<V?i:V)<<2,_+=pe.r=n[i],C+=pe.g=n[i+1],k+=pe.b=n[i+2],y+=pe.a=n[i+3],l+=_,u+=C,c+=k,d+=y,pe=pe.next,h+=b=Fe.r,m+=T=Fe.g,p+=R=Fe.b,v+=P=Fe.a,_-=b,C-=T,k-=R,y-=P,Fe=Fe.next,s+=4;a+=r}for(let fe=0;fe<r;fe++){C=k=y=_=u=c=d=l=0,s=fe<<2,h=F*(b=n[s]),m=F*(T=n[s+1]),p=F*(R=n[s+2]),v=F*(P=n[s+3]),l+=N*b,u+=N*T,c+=N*R,d+=N*P,ae=x;for(let le=0;le<F;le++)ae.r=b,ae.g=T,ae.b=R,ae.a=P,ae=ae.next;let ye=r;for(let le=1;le<=t;le++)s=ye+fe<<2,l+=(ae.r=b=n[s])*(j=F-le),u+=(ae.g=T=n[s+1])*j,c+=(ae.b=R=n[s+2])*j,d+=(ae.a=P=n[s+3])*j,_+=b,C+=T,k+=R,y+=P,ae=ae.next,le<Q&&(ye+=r);s=fe,pe=x,Fe=X;for(let le=0;le<o;le++)i=s<<2,n[i+3]=P=d*z>>J,P>0?(P=255/P,n[i]=(l*z>>J)*P,n[i+1]=(u*z>>J)*P,n[i+2]=(c*z>>J)*P):n[i]=n[i+1]=n[i+2]=0,l-=h,u-=m,c-=p,d-=v,h-=pe.r,m-=pe.g,p-=pe.b,v-=pe.a,i=fe+((i=le+F)<Q?i:Q)*r<<2,l+=_+=pe.r=n[i],u+=C+=pe.g=n[i+1],c+=k+=pe.b=n[i+2],d+=y+=pe.a=n[i+3],pe=pe.next,h+=b=Fe.r,m+=T=Fe.g,p+=R=Fe.b,v+=P=Fe.a,_-=b,C-=T,k-=R,y-=P,Fe=Fe.next,s+=r}}const wF=function(t){const n=Math.round(this.blurRadius());n>0&&bF(t,n)};ce.addGetterSetter(wt,"blurRadius",0,mt(),ce.afterSetFilter);const CF=function(e){const t=this.brightness()*255,n=e.data,r=n.length;for(let o=0;o<r;o+=4)n[o]+=t,n[o+1]+=t,n[o+2]+=t};ce.addGetterSetter(wt,"brightness",0,mt(),ce.afterSetFilter);const _F=function(e){const t=this.brightness(),n=e.data,r=n.length;for(let o=0;o<r;o+=4)n[o]=Math.min(255,n[o]*t),n[o+1]=Math.min(255,n[o+1]*t),n[o+2]=Math.min(255,n[o+2]*t)},SF=function(e){const t=Math.pow((this.contrast()+100)/100,2),n=e.data,r=n.length;let o=150,i=150,s=150;for(let a=0;a<r;a+=4)o=n[a],i=n[a+1],s=n[a+2],o/=255,o-=.5,o*=t,o+=.5,o*=255,i/=255,i-=.5,i*=t,i+=.5,i*=255,s/=255,s-=.5,s*=t,s+=.5,s*=255,o=o<0?0:o>255?255:o,i=i<0?0:i>255?255:i,s=s<0?0:s>255?255:s,n[a]=o,n[a+1]=i,n[a+2]=s};ce.addGetterSetter(wt,"contrast",0,mt(),ce.afterSetFilter);const kF=function(e){var t,n,r,o,i,s,a,l,u;const c=e.data,d=e.width,h=e.height,m=Math.min(1,Math.max(0,(n=(t=this.embossStrength)===null||t===void 0?void 0:t.call(this))!==null&&n!==void 0?n:.5)),p=Math.min(1,Math.max(0,(o=(r=this.embossWhiteLevel)===null||r===void 0?void 0:r.call(this))!==null&&o!==void 0?o:.5)),v=(a={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[(s=(i=this.embossDirection)===null||i===void 0?void 0:i.call(this))!==null&&s!==void 0?s:"top-left"])!==null&&a!==void 0?a:315,_=!!((u=(l=this.embossBlend)===null||l===void 0?void 0:l.call(this))!==null&&u!==void 0&&u),C=m*10,k=p*255,y=v*Math.PI/180,b=Math.cos(y),T=Math.sin(y),R=128/1020*C,P=new Uint8ClampedArray(c),j=new Float32Array(d*h);for(let N=0,x=0;x<c.length;x+=4,N++)j[N]=.2126*P[x]+.7152*P[x+1]+.0722*P[x+2];const O=[-1,0,1,-2,0,2,-1,0,1],V=[-1,-2,-1,0,0,0,1,2,1],Q=[-d-1,-d,-d+1,-1,0,1,d-1,d,d+1],F=N=>N<0?0:N>255?255:N;for(let N=1;N<h-1;N++)for(let x=1;x<d-1;x++){const z=N*d+x;let J=0,X=0;J+=j[z+Q[0]]*O[0],X+=j[z+Q[0]]*V[0],J+=j[z+Q[1]]*O[1],X+=j[z+Q[1]]*V[1],J+=j[z+Q[2]]*O[2],X+=j[z+Q[2]]*V[2],J+=j[z+Q[3]]*O[3],X+=j[z+Q[3]]*V[3],J+=j[z+Q[5]]*O[5],X+=j[z+Q[5]]*V[5],J+=j[z+Q[6]]*O[6],X+=j[z+Q[6]]*V[6],J+=j[z+Q[7]]*O[7],X+=j[z+Q[7]]*V[7],J+=j[z+Q[8]]*O[8],X+=j[z+Q[8]]*V[8];const ae=F(k+(b*J+T*X)*R),pe=z*4;if(_){const Fe=ae-k;c[pe]=F(P[pe]+Fe),c[pe+1]=F(P[pe+1]+Fe),c[pe+2]=F(P[pe+2]+Fe),c[pe+3]=P[pe+3]}else c[pe]=c[pe+1]=c[pe+2]=ae,c[pe+3]=P[pe+3]}for(let N=0;N<d;N++){let x=N*4,z=((h-1)*d+N)*4;c[x]=P[x],c[x+1]=P[x+1],c[x+2]=P[x+2],c[x+3]=P[x+3],c[z]=P[z],c[z+1]=P[z+1],c[z+2]=P[z+2],c[z+3]=P[z+3]}for(let N=1;N<h-1;N++){let x=N*d*4,z=(N*d+(d-1))*4;c[x]=P[x],c[x+1]=P[x+1],c[x+2]=P[x+2],c[x+3]=P[x+3],c[z]=P[z],c[z+1]=P[z+1],c[z+2]=P[z+2],c[z+3]=P[z+3]}return e};ce.addGetterSetter(wt,"embossStrength",.5,mt(),ce.afterSetFilter),ce.addGetterSetter(wt,"embossWhiteLevel",.5,mt(),ce.afterSetFilter),ce.addGetterSetter(wt,"embossDirection","top-left",void 0,ce.afterSetFilter),ce.addGetterSetter(wt,"embossBlend",!1,void 0,ce.afterSetFilter);function q0(e,t,n,r,o){const i=n-t,s=o-r;if(i===0)return r+s/2;if(s===0)return r;let a=(e-t)/i;return a=s*a+r,a}const AF=function(e){const t=e.data,n=t.length;let r=t[0],o=r,i,s=t[1],a=s,l,u=t[2],c=u,d;const h=this.enhance();if(h===0)return;for(let y=0;y<n;y+=4)i=t[y+0],i<r?r=i:i>o&&(o=i),l=t[y+1],l<s?s=l:l>a&&(a=l),d=t[y+2],d<u?u=d:d>c&&(c=d);o===r&&(o=255,r=0),a===s&&(a=255,s=0),c===u&&(c=255,u=0);let m,p,v,_,C,k;if(h>0)m=o+h*(255-o),p=r-h*(r-0),v=a+h*(255-a),_=s-h*(s-0),C=c+h*(255-c),k=u-h*(u-0);else{const y=(o+r)*.5;m=o+h*(o-y),p=r+h*(r-y);const b=(a+s)*.5;v=a+h*(a-b),_=s+h*(s-b);const T=(c+u)*.5;C=c+h*(c-T),k=u+h*(u-T)}for(let y=0;y<n;y+=4)t[y+0]=q0(t[y+0],r,o,p,m),t[y+1]=q0(t[y+1],s,a,_,v),t[y+2]=q0(t[y+2],u,c,k,C)};ce.addGetterSetter(wt,"enhance",0,mt(),ce.afterSetFilter);const IF=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const o=.34*t[r]+.5*t[r+1]+.16*t[r+2];t[r]=o,t[r+1]=o,t[r+2]=o}};ce.addGetterSetter(wt,"hue",0,mt(),ce.afterSetFilter),ce.addGetterSetter(wt,"saturation",0,mt(),ce.afterSetFilter),ce.addGetterSetter(wt,"luminance",0,mt(),ce.afterSetFilter);const EF=function(e){const t=e.data,n=t.length,r=1,o=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,s=this.luminance()*127,a=r*o*Math.cos(i*Math.PI/180),l=r*o*Math.sin(i*Math.PI/180),u=.299*r+.701*a+.167*l,c=.587*r-.587*a+.33*l,d=.114*r-.114*a-.497*l,h=.299*r-.299*a-.328*l,m=.587*r+.413*a+.035*l,p=.114*r-.114*a+.293*l,v=.299*r-.3*a+1.25*l,_=.587*r-.586*a-1.05*l,C=.114*r+.886*a-.2*l;let k,y,b,T;for(let R=0;R<n;R+=4)k=t[R+0],y=t[R+1],b=t[R+2],T=t[R+3],t[R+0]=u*k+c*y+d*b+s,t[R+1]=h*k+m*y+p*b+s,t[R+2]=v*k+_*y+C*b+s,t[R+3]=T},xF=function(e){const t=e.data,n=t.length,r=Math.pow(2,this.value()),o=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,s=r*o*Math.cos(i*Math.PI/180),a=r*o*Math.sin(i*Math.PI/180),l=.299*r+.701*s+.167*a,u=.587*r-.587*s+.33*a,c=.114*r-.114*s-.497*a,d=.299*r-.299*s-.328*a,h=.587*r+.413*s+.035*a,m=.114*r-.114*s+.293*a,p=.299*r-.3*s+1.25*a,v=.587*r-.586*s-1.05*a,_=.114*r+.886*s-.2*a;for(let C=0;C<n;C+=4){const k=t[C+0],y=t[C+1],b=t[C+2],T=t[C+3];t[C+0]=l*k+u*y+c*b,t[C+1]=d*k+h*y+m*b,t[C+2]=p*k+v*y+_*b,t[C+3]=T}};ce.addGetterSetter(wt,"hue",0,mt(),ce.afterSetFilter),ce.addGetterSetter(wt,"saturation",0,mt(),ce.afterSetFilter),ce.addGetterSetter(wt,"value",0,mt(),ce.afterSetFilter);const TF=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4)t[r]=255-t[r],t[r+1]=255-t[r+1],t[r+2]=255-t[r+2]};var RF=function(e,t,n){const r=e.data,o=t.data,i=e.width,s=e.height,a=n.polarCenterX||i/2,l=n.polarCenterY||s/2;let u=Math.sqrt(a*a+l*l),c=i-a,d=s-l;const h=Math.sqrt(c*c+d*d);u=h>u?h:u;const m=s,p=i,v=360/p*Math.PI/180;for(let _=0;_<p;_+=1){const C=Math.sin(_*v),k=Math.cos(_*v);for(let y=0;y<m;y+=1){c=Math.floor(a+u*y/m*k),d=Math.floor(l+u*y/m*C);let b=(d*i+c)*4;const T=r[b+0],R=r[b+1],P=r[b+2],j=r[b+3];b=(_+y*i)*4,o[b+0]=T,o[b+1]=R,o[b+2]=P,o[b+3]=j}}},MF=function(e,t,n){const r=e.data,o=t.data,i=e.width,s=e.height,a=n.polarCenterX||i/2,l=n.polarCenterY||s/2;let u=Math.sqrt(a*a+l*l),c=i-a,d=s-l;const h=Math.sqrt(c*c+d*d);u=h>u?h:u;const m=s,p=i,v=n.polarRotation||0;let _,C;for(c=0;c<i;c+=1)for(d=0;d<s;d+=1){const k=c-a,y=d-l,b=Math.sqrt(k*k+y*y)*m/u;let T=(Math.atan2(y,k)*180/Math.PI+360+v)%360;T=T*p/360,_=Math.floor(T),C=Math.floor(b);let R=(C*i+_)*4;const P=r[R+0],j=r[R+1],O=r[R+2],V=r[R+3];R=(d*i+c)*4,o[R+0]=P,o[R+1]=j,o[R+2]=O,o[R+3]=V}};const LF=function(e){const t=e.width,n=e.height;let r,o,i,s,a,l,u,c,d,h,m=Math.round(this.kaleidoscopePower());const p=Math.round(this.kaleidoscopeAngle()),v=Math.floor(t*(p%360)/360);if(m<1)return;const _=Ie.createCanvasElement();_.width=t,_.height=n;const C=_.getContext("2d").getImageData(0,0,t,n);Ie.releaseCanvas(_),RF(e,C,{polarCenterX:t/2,polarCenterY:n/2});let k=t/Math.pow(2,m);for(;k<=8;)k=k*2,m-=1;k=Math.ceil(k);let y=k,b=0,T=y,R=1;for(v+k>t&&(b=y,T=0,R=-1),o=0;o<n;o+=1)for(r=b;r!==T;r+=R)i=Math.round(r+v)%t,d=(t*o+i)*4,a=C.data[d+0],l=C.data[d+1],u=C.data[d+2],c=C.data[d+3],h=(t*o+r)*4,C.data[h+0]=a,C.data[h+1]=l,C.data[h+2]=u,C.data[h+3]=c;for(o=0;o<n;o+=1)for(y=Math.floor(k),s=0;s<m;s+=1){for(r=0;r<y+1;r+=1)d=(t*o+r)*4,a=C.data[d+0],l=C.data[d+1],u=C.data[d+2],c=C.data[d+3],h=(t*o+y*2-r-1)*4,C.data[h+0]=a,C.data[h+1]=l,C.data[h+2]=u,C.data[h+3]=c;y*=2}MF(C,e,{polarRotation:0})};ce.addGetterSetter(wt,"kaleidoscopePower",2,mt(),ce.afterSetFilter),ce.addGetterSetter(wt,"kaleidoscopeAngle",0,mt(),ce.afterSetFilter);function im(e,t,n){let r=(n*e.width+t)*4;const o=[];return o.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),o}function Of(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2))}function PF(e){const t=[0,0,0];for(let n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}function DF(e,t){const n=im(e,0,0),r=im(e,e.width-1,0),o=im(e,0,e.height-1),i=im(e,e.width-1,e.height-1),s=t||10;if(Of(n,r)<s&&Of(r,i)<s&&Of(i,o)<s&&Of(o,n)<s){const a=PF([r,n,i,o]),l=[];for(let u=0;u<e.width*e.height;u++)l[u]=Of(a,[e.data[u*4],e.data[u*4+1],e.data[u*4+2]])<s?0:255;return l}}function OF(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function FF(e,t,n){const r=[1,1,1,1,0,1,1,1,1],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const u=a*t+l;let c=0;for(let d=0;d<o;d++)for(let h=0;h<o;h++){const m=a+d-i,p=l+h-i;if(m>=0&&m<n&&p>=0&&p<t){const v=m*t+p,_=r[d*o+h];c+=e[v]*_}}s[u]=c===2040?255:0}return s}function NF(e,t,n){const r=[1,1,1,1,1,1,1,1,1],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const u=a*t+l;let c=0;for(let d=0;d<o;d++)for(let h=0;h<o;h++){const m=a+d-i,p=l+h-i;if(m>=0&&m<n&&p>=0&&p<t){const v=m*t+p,_=r[d*o+h];c+=e[v]*_}}s[u]=c>=1020?255:0}return s}function BF(e,t,n){const r=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const u=a*t+l;let c=0;for(let d=0;d<o;d++)for(let h=0;h<o;h++){const m=a+d-i,p=l+h-i;if(m>=0&&m<n&&p>=0&&p<t){const v=m*t+p,_=r[d*o+h];c+=e[v]*_}}s[u]=c}return s}const zF=function(e){let t=DF(e,this.threshold());return t&&(t=FF(t,e.width,e.height),t=NF(t,e.width,e.height),t=BF(t,e.width,e.height),OF(e,t)),e};ce.addGetterSetter(wt,"threshold",0,mt(),ce.afterSetFilter);const VF=function(e){const t=this.noise()*255,n=e.data,r=n.length,o=t/2;for(let i=0;i<r;i+=4)n[i+0]+=o-2*o*Math.random(),n[i+1]+=o-2*o*Math.random(),n[i+2]+=o-2*o*Math.random()};ce.addGetterSetter(wt,"noise",.2,mt(),ce.afterSetFilter);const HF=function(e){let t=Math.ceil(this.pixelSize()),n=e.width,r=e.height,o=Math.ceil(n/t),i=Math.ceil(r/t),s=e.data;if(t<=0){Ie.error("pixelSize value can not be <= 0");return}for(let a=0;a<o;a+=1)for(let l=0;l<i;l+=1){let u=0,c=0,d=0,h=0;const m=a*t,p=m+t,v=l*t,_=v+t;let C=0;for(let k=m;k<p;k+=1)if(!(k>=n))for(let y=v;y<_;y+=1){if(y>=r)continue;const b=(n*y+k)*4;u+=s[b+0],c+=s[b+1],d+=s[b+2],h+=s[b+3],C+=1}u=u/C,c=c/C,d=d/C,h=h/C;for(let k=m;k<p;k+=1)if(!(k>=n))for(let y=v;y<_;y+=1){if(y>=r)continue;const b=(n*y+k)*4;s[b+0]=u,s[b+1]=c,s[b+2]=d,s[b+3]=h}}};ce.addGetterSetter(wt,"pixelSize",8,mt(),ce.afterSetFilter);const jF=function(e){const t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,o=255/t;for(let i=0;i<r;i+=1)n[i]=Math.floor(n[i]/o)*o};ce.addGetterSetter(wt,"levels",.5,mt(),ce.afterSetFilter);const UF=function(e){const t=e.data,n=t.length,r=this.red(),o=this.green(),i=this.blue();for(let s=0;s<n;s+=4){const a=(.34*t[s]+.5*t[s+1]+.16*t[s+2])/255;t[s]=a*r,t[s+1]=a*o,t[s+2]=a*i,t[s+3]=t[s+3]}};ce.addGetterSetter(wt,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ce.addGetterSetter(wt,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ce.addGetterSetter(wt,"blue",0,Ak,ce.afterSetFilter);const GF=function(e){const t=e.data,n=t.length,r=this.red(),o=this.green(),i=this.blue(),s=this.alpha();for(let a=0;a<n;a+=4){const l=1-s;t[a]=r*s+t[a]*l,t[a+1]=o*s+t[a+1]*l,t[a+2]=i*s+t[a+2]*l}};ce.addGetterSetter(wt,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ce.addGetterSetter(wt,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ce.addGetterSetter(wt,"blue",0,Ak,ce.afterSetFilter),ce.addGetterSetter(wt,"alpha",1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});const WF=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const o=t[r+0],i=t[r+1],s=t[r+2];t[r+0]=Math.min(255,o*.393+i*.769+s*.189),t[r+1]=Math.min(255,o*.349+i*.686+s*.168),t[r+2]=Math.min(255,o*.272+i*.534+s*.131)}},KF=function(e){const n=e.data;for(let r=0;r<n.length;r+=4){const o=n[r],i=n[r+1],s=n[r+2];.2126*o+.7152*i+.0722*s>=128&&(n[r]=255-o,n[r+1]=255-i,n[r+2]=255-s)}return e},qF=function(e){const t=this.threshold()*255,n=e.data,r=n.length;for(let o=0;o<r;o+=1)n[o]=n[o]<t?0:255};ce.addGetterSetter(wt,"threshold",.5,mt(),ce.afterSetFilter);var YF=n4.Util._assign(n4,{Arc:da,Arrow:sc,Circle:wu,Ellipse:il,Image:Wi,Label:U0,Tag:ac,Line:fa,Path:Ei,Rect:Lf,RegularPolygon:sl,Ring:lc,Sprite:Cs,Star:al,Text:tr,TextPath:qr,Transformer:En,Wedge:ha,Filters:{Blur:wF,Brightness:_F,Brighten:CF,Contrast:SF,Emboss:kF,Enhance:AF,Grayscale:IF,HSL:EF,HSV:xF,Invert:TF,Kaleidoscope:LF,Mask:zF,Noise:VF,Pixelate:HF,Posterize:jF,RGB:UF,RGBA:GF,Sepia:WF,Solarize:KF,Threshold:qF}});xt();var XF=["dialog","floating"],I4=["top-right","top-left","bottom-right","bottom-left","top-center","bottom-center"];function ZF(e){if(!e||typeof e!="object")throw new Error("SurfaceManager: request must be a non-null object.");if(!XF.includes(e.mode))throw new Error(`SurfaceManager: mode must be "dialog" or "floating", got "${e.mode}".`);const t="kind"in e&&e.kind!=null,n="component"in e&&e.component!=null,r="render"in e&&typeof e.render=="function";if(n&&r)throw new Error('SurfaceManager: request cannot provide both "component" and "render". Use one or the other.');if(!t&&!n&&!r)throw new Error('SurfaceManager: request must provide "kind" (intent-based) or "component"/"render" (direct-render).');if(e.mode==="floating"&&e.floating?.placement!=null&&!I4.includes(e.floating.placement))throw new Error(`SurfaceManager: floating.placement must be one of ${I4.join(", ")}, got "${e.floating.placement}".`)}var QF=class{activeDialog=Kr(null);activeFloating=Kr(null);#t=!1;#n=1;#e;constructor({getModuleConfig:e}){this.#e=e}open(e){if(this.#t)return this.#l(e);ZF(e);const t=this.#u(e),{component:n,props:r,render:o}=this.#d(t);let i,s=!1;const a=new Promise(m=>{i=p=>s?!1:(s=!0,m(p),!0)});let l;const u=m=>{i({status:"submitted",data:m})&&this.#s(l)},c=m=>{i({status:"closed",reason:m})&&this.#s(l)};l={id:t.id,mode:t.mode,request:t,component:n,props:r,render:o,resolve:u,close:c,settle:m=>i(m),get settled(){return s}};const d=t.mode==="dialog"?"activeDialog":"activeFloating",h=this[d].value;return h&&!h.settled&&h.settle({status:"replaced",replacedBy:t.id}),this[d].value=l,{id:t.id,mode:t.mode,close:m=>this.#i(l,m),result:a}}close(e,t){if(e!=null){const o=this.#a(e);o&&this.#i(o,t);return}const n=this.activeDialog.value;if(n&&!n.settled){this.#i(n,t);return}const r=this.activeFloating.value;r&&!r.settled&&this.#i(r,t)}settleAll(e){for(const t of[this.activeDialog,this.activeFloating]){const n=t.value;n&&!n.settled&&n.settle(e),t.value=null}}destroy(){this.#t=!0,this.settleAll({status:"destroyed"})}#i(e,t){e.settled||(e.settle({status:"closed",reason:t}),this.#s(e))}#s(e){const t=e.mode==="dialog"?this.activeDialog:this.activeFloating;t.value===e&&(t.value=null)}#a(e){return this.activeDialog.value?.id===e?this.activeDialog.value:this.activeFloating.value?.id===e?this.activeFloating.value:null}#u(e){const t=e.id??`surface-${this.#n++}`,n=this.#e()??{},r=e.mode==="dialog"?n.dialog:n.floating,o=e.mode==="dialog"?{maxWidth:r?.maxWidth,...e.dialog}:e.dialog,i=e.mode==="floating"?{placement:r?.placement??"top-right",width:r?.width,maxWidth:r?.maxWidth,maxHeight:r?.maxHeight,autoFocus:r?.autoFocus??!0,closeOnOutsidePointerDown:r?.closeOnOutsidePointerDown??!1,...e.floating}:e.floating;return{...e,id:t,closeOnEscape:e.closeOnEscape??r?.closeOnEscape??!0,closeOnBackdrop:e.mode==="dialog"?e.closeOnBackdrop??r?.closeOnBackdrop??!0:!1,dialog:o,floating:i}}#d(e){if("component"in e&&e.component!=null)return{component:e.component,props:e.props};if("render"in e&&typeof e.render=="function")return{render:e.render};const t=this.#e()?.resolver;if(typeof t=="function"){const n=t(e);if(n!=null){if(n.type==="none")throw new Error(`SurfaceManager: resolver explicitly suppressed surface for kind "${e.kind}".`);if(n.type==="custom")return{component:n.component,props:n.props};if(n.type==="external")return{render:n.render}}}throw new Error(`SurfaceManager: no renderer resolved for kind "${e.kind}". Provide a resolver via surfaces.resolver, or use a direct-render request.`)}#l(e){return{id:e?.id??`surface-${this.#n++}`,mode:e?.mode??"dialog",close:()=>{},result:Promise.resolve({status:"destroyed"})}}},JF="https://docs.superdoc.dev/guides/migration/document-api",E4=new Set;function $F(e,t){E4.has(e)||(E4.add(e),console.warn(t))}var eN={state:"editor.state",view:"editor.view",schema:"editor.schema",commands:"editor.commands",chain:"editor.chain()",can:"editor.can()",dispatch:"editor.dispatch()"},x4=Symbol.for("superdoc:rawEditor"),T4=new WeakMap;function R4(e){return!e||e[x4]?e:new Proxy(e,{get(t,n){if(n===x4)return t;const r=eN[n];r&&$F(`deprecated:${String(n)}`,`[SuperDoc] ${r} is deprecated and will be removed in a future version. Use the Document API (editor.doc) instead. See ${JF}`);const o=Reflect.get(t,n,t);if(typeof o=="function"){let i=T4.get(t);return i||(i=new Map,T4.set(t,i)),i.has(n)||i.set(n,o.bind(t)),i.get(n)}return o}})}var M4=["review","original","final","off"],tN=["paired","independent"],L4=Symbol.for("@superdoc/trackChanges:normalized"),P4=new Set;function D4(e,t){P4.has(e)||(P4.add(e),console.warn(`[SuperDoc] ${e} is deprecated β use ${t} instead.`))}function O4(e,t,n){return typeof e=="boolean"?e:typeof t=="boolean"?t:n}function nN(e,t,n){return typeof e=="string"&&M4.includes(e)?e:typeof t=="string"&&M4.includes(t)?t:n}function rN(e){return typeof e=="string"&&tN.includes(e)?e:null}function cc(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function oN(e){const t=e[L4]===!0;cc(e.modules)||(e.modules={});const n=cc(e.modules.trackChanges),r=cc(e.trackChanges),o=cc(e.layoutEngineOptions?.trackedChanges);t||(r&&D4("config.trackChanges","config.modules.trackChanges"),o&&D4("config.layoutEngineOptions.trackedChanges","config.modules.trackChanges"));const i=O4(n?.visible,r?.visible,!1),s=O4(n?.enabled,o?.enabled,!0),a=rN(n?.replacements)??"paired",l=cc(n?.authorColors)?n.authorColors:void 0,u=cc(n?.semanticColors)?n.semanticColors:void 0,c=e.documentMode==="viewing"?i?"review":"original":"review",d=nN(n?.mode,o?.mode,c),h={visible:i,mode:d,enabled:s,replacements:a};return l&&(h.authorColors=l),u&&(h.semanticColors=u),e.modules.trackChanges=h,e.trackChanges={visible:i},cc(e.layoutEngineOptions)||(e.layoutEngineOptions={}),e.layoutEngineOptions.trackedChanges={mode:d,enabled:s},Object.defineProperty(e,L4,{value:!0,writable:!0,configurable:!0,enumerable:!1}),h}const Y0=Object.freeze({id:null,name:"Default SuperDoc user",email:null});function iN(e){return!e||typeof e!="object"?{...Y0}:{...Y0,...e}}var F4=Object.freeze({toolbar:!0,comments:!0,contextMenu:!0,search:!1,linkPopover:!1,ruler:!1,contentControls:!0}),sN=Object.freeze(["left","center","right"]),FU=Object.freeze(Object.keys(F4)),_u=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function N4(e,t){const n=e?.[t];return n===!1?!1:n===void 0?F4[t]:!0}function aN(e,t){const n=e?.[t];return _u(n)?n:{}}var B4=Object.freeze(["readOnly","allowResolve","permissionResolver"]);function lN(e){if(!B4.some(n=>n in e))return e;const t={...e};for(const n of B4)delete t[n];return t}function z4(e={}){const t=e.ui,n=t===!1,r=_u(t)?t:void 0,o=T=>!n&&N4(r,T),i=T=>n?!1:r?.[T]===void 0?void 0:N4(r,T),s=T=>n?{}:aN(r,T),a=n||i("ruler")===!1,l=s("toolbar"),u=e.modules?.toolbar,c=_u(u)?u:{},d=e.modules?.contextMenu??e.modules?.slashMenu,h=_u(d)?d:{},m=e.modules?.surfaces?.findReplace,p=_u(m)?m:{},v=[l.groups,c.groups],_=v.find(_u),C=N_(v.find(Array.isArray),c.toolbarGroups,e.toolbarGroups),k=Array.isArray(C)?C:null,y=(T,R)=>Object.prototype.hasOwnProperty.call(T,R),b=_&&k?Object.fromEntries([...k.filter(T=>y(_,T)),...Object.keys(_).filter(T=>!sN.includes(T))].map(T=>[T,_[T]])):_;return{enabled:!n,toolbar:{enabled:o("toolbar"),container:n?null:N_(l.container,c.selector,e.toolbar)??null,options:n?{}:{...tl(c,l),groups:b,toolbarGroups:C,icons:tl(e.toolbarIcons,c.icons,l.icons),texts:tl(e.toolbarTexts,c.texts,l.texts)}},comments:{enabled:i("comments")??(!n&&e.modules?.comments!==!1),options:n?{}:L_(lN(s("comments")))},contextMenu:{enabled:i("contextMenu")??(!n&&e.disableContextMenu!==!0),suppressed:n||i("contextMenu")===!1,options:n?{}:tl(h,s("contextMenu"))},search:{enabled:i("search")??(!n&&!!e.modules?.surfaces?.findReplace),options:n?{}:tl(p,s("search"))},linkPopover:{enabled:i("linkPopover")??(!n&&!!e.modules?.links?.popoverResolver),suppressed:n||i("linkPopover")===!1,options:s("linkPopover")},ruler:{enabled:i("ruler")??(!n&&!!e.rulers),suppressed:a,container:a?null:s("ruler").container??e.rulerContainer??null},contentControls:{enabled:i("contentControls")??(!n&&e.modules?.contentControls?.chrome!=="none"),options:s("contentControls")}}}var X0=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function V4(e={}){const t=X0(e.interaction)?e.interaction:{},n=X0(t.comments)?t.comments:{},r=X0(e.modules?.comments)?e.modules.comments:{};return{comments:{readOnly:(n.readOnly??r.readOnly??!1)===!0,allowResolve:(n.allowResolve??r.allowResolve??!0)!==!1}}}var H4=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function j4(e={}){const t=H4(e.surfaces)?e.surfaces:{},n=H4(e.modules?.surfaces)?e.modules.surfaces:{},r=t.resolver===void 0?n.resolver:t.resolver;return{resolver:typeof r=="function"?r:null,dialog:tl(n.dialog,t.dialog),floating:tl(n.floating,t.floating)}}var cN=class{#t=new Map;#n=new Map;#e=null;#i=new Set;register(e){if(this.#t.has(e.id))throw new Error(`EditorRuntimeRegistry: duplicate runtime id "${e.id}"`);const t=e.root,n=t?this.#n.get(t):void 0;if(n!==void 0&&n!==e.id)throw new Error(`EditorRuntimeRegistry: root element already registered to runtime "${n}"`);this.#t.set(e.id,e),t&&this.#n.set(t,e.id)}unregister(e){const t=this.#t.get(e);return t?(this.#t.delete(e),t.root&&this.#n.delete(t.root),this.#e===e&&(this.#e=null,this.#s({previousRuntimeId:e,nextRuntimeId:null,reason:"active-runtime-unregistered",legacyEditorProjection:null})),!0):!1}get(e){return this.#t.get(e)??null}getAll(){return Array.from(this.#t.values())}getAllByDocumentId(e){const t=[];for(const n of this.#t.values())n.documentId===e&&t.push(n);return t}getActive(){return this.#e===null?null:this.#t.get(this.#e)}getActiveId(){return this.#e}setActive(e,t){if(e!==null&&!this.#t.has(e))throw new Error(`EditorRuntimeRegistry: cannot activate unknown runtime "${e}"`);if(e===this.#e)return;const n=this.#e;this.#e=e;let r=null;e!==null&&(r=this.#t.get(e).getLegacyEditorProjection?.()??null),this.#s({previousRuntimeId:n,nextRuntimeId:e,reason:t,legacyEditorProjection:r})}resolveFromEventTarget(e){const t=e instanceof Element?e:e instanceof Node?e.parentElement:null;if(!t)return null;const n=t.closest(`[${zp}]`);if(!n)return null;const r=n.getAttribute(zp),o=r?this.get(r):null;return o&&o.root===n?o:null}subscribe(e){return this.#i.add(e),()=>{this.#i.delete(e)}}clear(){this.#t.clear(),this.#n.clear(),this.#e=null,this.#i.clear()}#s(e){for(const t of Array.from(this.#i))try{t(e)}catch{}}};const lt={notReady:"not-ready",documentApiUnavailable:"document-api-unavailable",documentReadonly:"document-readonly",selectionRequired:"selection-required",rangeSelectionRequired:"range-selection-required",contextUnavailable:"context-unavailable",geometryUnavailable:"geometry-unavailable",targetUnresolved:"target-unresolved",targetNotVisible:"target-not-visible",commandUnsupported:"command-unsupported",commandDeferred:"command-deferred",tableContextUnavailable:"table-context-unavailable",operationUnavailable:"operation-unavailable",bulkDecisionsDisabled:"bulk-decisions-disabled",hostCapabilityUnavailable:"host-capability-unavailable",historyEmpty:"history-empty",searchUnavailable:"search-unavailable",searchInvalidPattern:"search-invalid-pattern",replaceUnsupported:"replace-unsupported",contentControlLocked:"content-control-locked"},U4={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikethrough",fontFamily:"font-family",fontSize:"font-size",setFontFamily:"setFontFamily",setFontSize:"setFontSize",undo:"undo",redo:"redo",acceptChange:"acceptChange",rejectChange:"rejectChange",acceptAllChanges:"acceptAllChanges",rejectAllChanges:"rejectAllChanges",bulletList:"bullet-list",numberedList:"numbered-list"};function G4(e){const t=n=>typeof n=="string"?n.replace(/\s*pt$/i,"").trim():n;if(typeof e=="string")return t(e);if(e&&typeof e=="object"&&"value"in e){const n=e;return{...n,value:t(n.value)}}return e}function uN(e){const t=(n,r)=>!r&&n>0&&n<=5?n*100:n;if(typeof e=="string"){const n=e.includes("%"),r=Number.parseFloat(e.replace("%","").trim());return Number.isFinite(r)?t(r,n):e}return typeof e=="number"&&Number.isFinite(e)?t(e,!1):e}function dN(e){const t=e&&typeof e=="object"&&"value"in e?e.value:e;if(t==="in"||t==="cm")return t;if(typeof t=="string"){const n=t.trim().toLowerCase();if(n==="in"||n==="inch"||n==="inches")return"in";if(n==="cm"||n==="centimeter"||n==="centimeters"||n==="centimetre"||n==="centimetres")return"cm"}return t}function W4(e){const t=n=>{if(n===null)return null;if(typeof n!="string")return n;const r=n.trim();return r===""?n:/^#[0-9a-fA-F]{6}$/.test(r)?r:/^[0-9a-fA-F]{6}$/.test(r)?`#${r}`:r};if(e&&typeof e=="object"&&"value"in e){const n=e;return{...n,value:t(n.value)}}return t(e)}function Z0(e,t){if(e&&typeof e=="object"){const n=e;for(const r of t)if(r in n)return n[r]}return e}function fN(e){const t=Z0(e,["alignment","value"]);if(typeof t!="string")return t;const n=t.trim().toLowerCase();return n==="justified"||n==="both"?"justify":n}function hN(e){const t=Z0(e,["line","lineHeight","value"]),n=typeof t=="number"?t:typeof t=="string"?Number.parseFloat(t.trim()):NaN;return!Number.isFinite(n)||n<=0?t:n<=10?Math.round(n*240):Math.round(n)}function pN(e){if(e&&typeof e=="object"&&"role"in e)return e;const t=Z0(e,["styleId","value","style"]);return typeof t=="string"?t.trim():t}function mN(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e.mode;if(typeof t=="string")return t}return e}var gN=lt.commandUnsupported,_s=lt.tableContextUnavailable;const K4=[{id:"bold",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.bold",activeMark:"bold",inline:{key:"bold",kind:"toggle"}},{id:"italic",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.italic",activeMark:"italic",inline:{key:"italic",kind:"toggle"}},{id:"underline",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.underline",activeMark:"underline",inline:{key:"underline",kind:"toggle"}},{id:"strikethrough",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.strikethrough",activeMark:"strikethrough",inline:{key:"strike",kind:"toggle"}},{id:"font-family",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontFamily",aliases:["setFontFamily"],inline:{key:"fontFamily",kind:"value-string"}},{id:"font-size",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontSize",aliases:["setFontSize"],normalizePayload:G4,inline:{key:"fontSize",kind:"value-number"}},{id:"setFontFamily",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontFamily",aliasOf:"font-family",inline:{key:"fontFamily",kind:"value-string"}},{id:"setFontSize",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontSize",aliasOf:"font-size",normalizePayload:G4,inline:{key:"fontSize",kind:"value-number"}},{id:"undo",family:"history",disposition:"routed",mutates:!0,docRoute:"history.undo"},{id:"redo",family:"history",disposition:"routed",mutates:!0,docRoute:"history.redo"},{id:"acceptChange",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"accept",scope:"id"},aliases:["track-changes-accept-selection"]},{id:"rejectChange",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"reject",scope:"id"},aliases:["track-changes-reject-selection"]},{id:"acceptAllChanges",family:"tracked changes (bulk)",disposition:"routed",mutates:!0,trackDecision:{kind:"accept",scope:"all"}},{id:"rejectAllChanges",family:"tracked changes (bulk)",disposition:"routed",mutates:!0,trackDecision:{kind:"reject",scope:"all"}},{id:"track-changes-accept-selection",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"accept",scope:"id"},aliasOf:"acceptChange"},{id:"track-changes-reject-selection",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"reject",scope:"id"},aliasOf:"rejectChange"},{id:"zoom",family:"zoom",disposition:"routed",mutates:!1,instanceRoute:"setZoom",valueFrom:"zoom",normalizePayload:uN},{id:"zoom-fit-width",family:"zoom",disposition:"routed",mutates:!1,instanceRoute:"setZoomMode",fixedArg:"fit-width",valueFrom:"zoom"},{id:"document-mode",family:"document",disposition:"routed",mutates:!1,instanceRoute:"setDocumentMode",valueFrom:"documentMode",normalizePayload:mN},{id:"measurement-unit",family:"measurement",disposition:"routed",mutates:!1,instanceRoute:"setMeasurementUnit",valueFrom:"measurementUnit",normalizePayload:dN},{id:"text-color",family:"color",disposition:"routed",mutates:!0,docRoute:"format.color",inline:{key:"color",kind:"value-string"},normalizePayload:W4},{id:"highlight-color",family:"color",disposition:"routed",mutates:!0,docRoute:"format.highlight",inline:{key:"highlight",kind:"value-string"},normalizePayload:W4},{id:"link",family:"links",disposition:"routed",mutates:!0,docRoute:"hyperlinks.wrap",activeMark:"link",link:{kind:"link"}},{id:"text-align",family:"paragraph",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setAlignment",blockParagraph:{kind:"alignment"},normalizePayload:fN},{id:"line-height",family:"paragraph",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setSpacing",blockParagraph:{kind:"spacing-line"},normalizePayload:hN},{id:"linked-style",family:"paragraph",disposition:"routed",mutates:!0,docRoute:"styles.paragraph.setStyle",blockParagraph:{kind:"style"},normalizePayload:pN},{id:"bullet-list",family:"lists",disposition:"routed",mutates:!0,docRoute:"lists.apply",list:{mode:"toggle-seed",seed:"bullet"}},{id:"numbered-list",family:"lists",disposition:"routed",mutates:!0,docRoute:"lists.apply",list:{mode:"toggle-seed",seed:"ordered"}},{id:"indent-increase",family:"lists/indent",disposition:"routed",mutates:!0,docRoute:"lists.indent",list:{mode:"indent"}},{id:"indent-decrease",family:"lists/indent",disposition:"routed",mutates:!0,docRoute:"lists.outdent",list:{mode:"outdent"}},{id:"direction-ltr",family:"direction",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setDirection",blockParagraph:{kind:"direction",fixedValue:"ltr"}},{id:"direction-rtl",family:"direction",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setDirection",blockParagraph:{kind:"direction",fixedValue:"rtl"}},{id:"clear-formatting",family:"formatting",disposition:"routed",mutates:!0,docRoute:"format.apply",inline:{key:"*",kind:"clear"}},{id:"image",family:"media",disposition:"routed",mutates:!0,docRoute:"create.image",create:{kind:"image"}},{id:"table-of-contents-insert",family:"TOC",disposition:"routed",mutates:!0,docRoute:"create.tableOfContents",create:{kind:"toc"}},{id:"table-insert",family:"tables",disposition:"routed",mutates:!0,docRoute:"create.table",create:{kind:"table"}},{id:"table-add-row-before",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertRow",table:{action:"insert-row-before",op:"insertRow"},reason:_s},{id:"table-add-row-after",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertRow",table:{action:"insert-row-after",op:"insertRow"},reason:_s},{id:"table-delete-row",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.deleteRow",table:{action:"delete-row",op:"deleteRow"},reason:_s},{id:"table-add-column-before",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertColumn",table:{action:"insert-column-before",op:"insertColumn"},reason:_s},{id:"table-add-column-after",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertColumn",table:{action:"insert-column-after",op:"insertColumn"},reason:_s},{id:"table-delete-column",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.deleteColumn",table:{action:"delete-column",op:"deleteColumn"},reason:_s},{id:"table-delete",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.delete",table:{action:"delete-table",op:"delete"},reason:_s},{id:"table-merge-cells",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.mergeCells",table:{action:"merge-cells",op:"mergeCells"},reason:_s},{id:"table-split-cell",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.splitCell",table:{action:"split-cell",op:"splitCell",requiresCell:!0},reason:_s},{id:"table-remove-borders",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.setBorders",table:{action:"remove-borders",op:"setBorders"},reason:_s},{id:"ruler",family:"UI chrome",disposition:"routed",mutates:!1,instanceRoute:"toggleRuler",valueFrom:"ruler"},{id:"formatting-marks",family:"UI chrome",disposition:"routed",mutates:!1,instanceRoute:"toggleFormattingMarks",valueFrom:"formattingMarks"},{id:"copy-format",family:"formatting",disposition:"routed",mutates:!1},{id:"table-fix",family:"tables",disposition:"unsupported",mutates:!0,reason:gN}];var vN=new Map(K4.map(e=>[e.id,e]));const yN=K4.map(e=>e.id);function Su(e){return vN.get(e)??null}var bN=["table-add-row-before","table-add-row-after","table-delete-row","table-add-column-before","table-add-column-after","table-delete-column","table-delete","table-merge-cells","table-split-cell","table-remove-borders"];const q4=[{name:"bold",commandId:"bold",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"italic",commandId:"italic",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"underline",commandId:"underline",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"strike",commandId:"strikethrough",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"clearFormatting",commandId:"clear-formatting",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"copyFormat",commandId:"copy-format",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"fontFamily",commandId:"font-family",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"fontSize",commandId:"font-size",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"color",commandId:"text-color",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"highlight",commandId:"highlight-color",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"textAlign",commandId:"text-align",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"list",commandId:"bullet-list",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"numberedlist",commandId:"numbered-list",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"indentleft",commandId:"indent-decrease",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"indentright",commandId:"indent-increase",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"lineHeight",commandId:"line-height",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"linkedStyles",commandId:"linked-style",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"link",commandId:"link",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"image",commandId:"image",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"table",commandId:"table-insert",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"tableActions",commandId:null,instanceMethod:null,disposition:"shell-owned",group:"center",memberCommandIds:bN,note:"table editing dropdown is shell chrome; its member commands are controller-routed through the shared table-context facade (ui.tables / host.getTableContext()) and fail closed with table-context-unavailable when the caret is not in a table"},{name:"undo",commandId:"undo",instanceMethod:null,disposition:"controller-routed",group:"left"},{name:"redo",commandId:"redo",instanceMethod:null,disposition:"controller-routed",group:"left"},{name:"search",commandId:null,instanceMethod:null,disposition:"shell-owned",group:"right",note:"built-in search button; opens the shared find/replace surface (the same one Cmd/Ctrl+F opens) by emitting a `search:open` event on the SuperDoc instance, which the shell handles. The surface reads/drives the controller search surface (ui.search), backed by the single V2 host search session (host.search) which owns query, navigation, reveal, and replace. Find/navigation are always available when the host exposes search; replace/replaceAll mutate through the host session and fail closed (document-readonly) in viewing/read-only mode. If a runtime cannot expose search, the surface fails closed with search-unavailable"},{name:"zoom",commandId:"zoom",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"measurementUnit",commandId:"measurement-unit",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"ruler",commandId:null,instanceMethod:"toggleRuler",disposition:"host-routed",group:"right",note:"built-in shell toggles ruler visibility through the public SuperDoc.toggleRuler() instance method; the controller also routes the ruler command through it so custom UIs drive the same chrome (active state from config.rulers)"},{name:"formattingMarks",commandId:null,instanceMethod:"toggleFormattingMarks",disposition:"host-routed",group:"right",note:"built-in shell toggles nonprinting marks through the public SuperDoc.toggleFormattingMarks()/setShowFormattingMarks() instance methods (not a controller command)"},{name:"documentMode",commandId:"document-mode",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"acceptTrackedChangeBySelection",commandId:"track-changes-accept-selection",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"rejectTrackedChangeOnSelection",commandId:"track-changes-reject-selection",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"customButtons",commandId:null,instanceMethod:null,disposition:"shell-owned",group:"center",note:"consumer-defined buttons the rendered shell owns; their execution context surface is phase 2"}];var Y4=new Map(q4.map(e=>[e.name,e]));const NU=q4.map(e=>e.name);function Q0(e){return Y4.get(e)??null}function wN(e){const t=Y4.get(e);return t?.disposition==="controller-routed"?t.commandId:null}const CN=".png,.jpg,.jpeg,image/png,image/jpeg";var X4=new Set(["image/png","image/jpeg","image/jpg"]),_N=/\.(png|jpe?g)$/i;function SN(e){if(!e)return!1;const t=typeof e.type=="string"?e.type.toLowerCase():"";return t?X4.has(t):_N.test(String(e.name??""))}function Z4(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(kN(String(r.result),e)),r.onerror=()=>n(r.error??new Error("image-read-failed")),r.readAsDataURL(e)})}function kN(e,t){const n=/^data:([^;,]*);base64,/.exec(e);if(!n)return e;const r=n[1].toLowerCase();if(X4.has(r))return e;const o=String(t?.name??""),i=/\.jpe?g$/i.test(o)?"image/jpeg":/\.png$/i.test(o)?"image/png":null;return i?`data:${i};base64,${e.slice(n[0].length)}`:e}async function AN(e,t){if(typeof t=="function"){const n=await t(e);if(typeof n!="string"||n.trim()==="")throw new Error("handleImageUpload returned an empty result");return n.startsWith("data:")?n:IN(n,e)}return Z4(e)}async function IN(e,t){const n=await fetch(e);if(!n.ok)throw new Error(`image fetch failed: ${n.status}`);const r=await n.blob(),o=(/\.(?:png|jpe?g)(?:$|[?#])/i.test(e)?e.split(/[?#]/)[0]:"")||t?.name||"";return Z4(o?Object.assign(r,{name:o}):r)}function EN({ownerDocument:e=document,onPick:t,onError:n}={}){const r=e.createElement("input");return r.type="file",r.accept=CN,r.hidden=!0,r.tabIndex=-1,r.setAttribute("data-superdoc-image-picker","true"),r.setAttribute("aria-hidden","true"),r.addEventListener("change",()=>{const o=r.files&&r.files[0];if(r.value="",!!o){if(!SN(o)){n?.(new Error(`unsupported image type: ${o.type||o.name}`));return}try{const i=t?.(o);i&&typeof i.then=="function"&&i.catch(s=>n?.(s))}catch(i){n?.(i)}}}),e.body?.appendChild(r),{input:r,open(){r.click()},destroy(){r.remove()}}}var xN=(e,t)=>{let n=e.replace(/[^0-9.]/g,"");return n=parseFloat(n),isNaN(n)&&(n=t),n=parseFloat(n),n},TN=(e,t,n)=>{let r,o,i,s=0;n||(n={});const a=()=>{s=n.leading===!1?0:Date.now(),r=null,i=e(...o),r||(o=null)},l=(...u)=>{const c=Date.now();!s&&n.leading===!1&&(s=c);const d=t-(c-s);return o=u,d<=0||d>t?(r&&(clearTimeout(r),r=null),s=c,i=e(...u),r||(o=null)):!r&&n.trailing!==!1&&(r=setTimeout(a,d)),i};return l.cancel=function(){clearTimeout(r),s=0,r=o=null},l};xt(),gn();var RN={class:"sd-toolbar-icon"},MN=["innerHTML"],LN={__name:"ToolbarButtonIcon",props:{name:{type:String,required:!0},color:{type:String,default:null},icon:{type:String,default:null}},setup(e){const t=e,n=ke(()=>{if(t.name==="color")return{backgroundColor:t.color||"#111111"};if(t.name==="highlight")return{backgroundColor:t.color||"#D6D6D6"}}),r=ke(()=>["color","highlight"].includes(t.name));return(o,i)=>(ge(),Ae("div",RN,[Me("div",{class:rn(["sd-toolbar-icon__icon",[`sd-toolbar-icon__icon--${t.name}`]]),innerHTML:e.icon},null,10,MN),r.value?(ge(),Ae("div",{key:0,class:"color-bar",style:yn(n.value)},null,4)):ht("",!0)]))}},Q4=fn(LN,[["__scopeId","data-v-d7d79424"]]);xt(),gn();var PN=["role","aria-label"],DN=["data-item"],ON=["data-item"],FN={key:1,class:"sd-button-label"},NN=["data-item","aria-label"],BN=["innerHTML"],zN={key:2},VN=["onKeydown","id"],HN=["placeholder","onKeydown","id","data-item"],jN=["data-item","innerHTML"],UN={"aria-live":"polite",class:"sd-visually-hidden"},GN={__name:"ToolbarButton",props:{iconColor:{type:String,default:null},active:{type:Boolean,default:!1},isNarrow:{type:Boolean,default:!1},isWide:{type:Boolean,default:!1},toolbarItem:{type:Object,required:!0},defaultLabel:{type:String,default:null},isOverflowItem:{type:Boolean,default:!1},allowEnterPropagation:{type:Boolean,default:!1}},emits:["buttonClick","textSubmit","mainClick"],setup(e,{emit:t}){const n=t,{proxy:r}=ir(),o=e,{name:i,active:s,icon:a,label:l,hideLabel:u,iconColor:c,hasCaret:d,splitButton:h,disabled:m,expand:p,inlineTextInputVisible:v,hasInlineTextInput:_,minWidth:C,style:k,attributes:y}=o.toolbarItem,b=ke(()=>!!h?.value&&!!d?.value),T=ke(()=>i?.value??""),R=ne(""),P=ne(null),{isHighContrastMode:j}=Hi();Lt(()=>l?.value,Se=>{document.activeElement!==P.value&&(R.value=Se==null?"":String(Se))},{immediate:!0});const O=()=>{_&&_t(()=>{P.value?.focus(),P.value?.select()}),n("buttonClick")},V=Se=>{m?.value||(Se?.stopPropagation(),n("mainClick"))},Q=()=>{b.value||O()},F=Se=>{if(b.value){V(Se);return}O()},N=Se=>{o.allowEnterPropagation||Se.stopPropagation(),F(Se)},x=Se=>{const re=o.toolbarItem?.nestedOptions?.value??[],xe=Se.trim();if(!xe)return"";const $e=re.find(st=>typeof st?.label=="string"&&st.label.toLowerCase()===xe.toLowerCase());return $e?.label?$e.label:re.find(st=>typeof st?.label=="string"&&st.label.toLowerCase().startsWith(xe.toLowerCase()))?.label??xe},z=()=>{const Se=String(R.value??"").trim();let re=Se;if(T.value==="fontSize"){const xe=Number.parseFloat(Se);re=Se.match(/^\d+(\.5)?$/)?Se:Number.isFinite(xe)?Math.floor(xe).toString():""}else T.value==="fontFamily"&&(re=x(Se));return re?(n("textSubmit",re),R.value=re,!0):!1},J=Se=>{const re=Se?.currentTarget;re instanceof HTMLInputElement&&(re.focus({preventScroll:!0}),re.select())},X=Se=>{requestAnimationFrame(()=>{const re=document.getElementById(`inlineTextInput-${Se}`);re instanceof HTMLInputElement&&(re.focus({preventScroll:!0}),re.select())})},ae=()=>{const Se=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');return Se instanceof HTMLElement?(Se.focus({preventScroll:!0}),!0):!1},pe=()=>{const Se=r?.$toolbar?.pendingSelectionCapture,re=()=>{Se&&typeof r?.$toolbar?.ui?.selection?.restore=="function"&&r.$toolbar.ui.selection.restore(Se)};if(ae()){re();return}typeof r?.$toolbar?.superdoc?.focus=="function"&&(r.$toolbar.superdoc.focus(),re())},Fe=()=>{z()&&pe()},fe=Se=>{if(z(),Se.shiftKey){T.value==="fontSize"&&(Se.preventDefault(),_t(()=>X("fontFamily")));return}if(Se.preventDefault(),T.value==="fontFamily"){_t(()=>X("fontSize"));return}T.value==="fontSize"&&_t(pe)},ye=ke(()=>k.value?k.value:{minWidth:o.minWidth}),le=ke(()=>p?.value?er.dropdownCaretUp:er.dropdownCaretDown);return(Se,re)=>(ge(),Ae("div",{class:rn(["sd-toolbar-item",et(y).className]),style:yn(ye.value),role:e.isOverflowItem?"menuitem":"button","aria-label":et(y).ariaLabel,"data-sd-part":"toolbar-item",onClick:Q,onKeydown:re[9]||(re[9]=Yo(xe=>N(xe),["enter"])),tabindex:"0"},[Me("div",{class:rn(["sd-toolbar-button",{"sd-active":et(s),"sd-disabled":et(m),narrow:e.isNarrow,wide:e.isWide,split:b.value,"has-inline-text-input":et(_),"high-contrast":et(j)}]),"data-item":`btn-${et(i)||""}`},[b.value?(ge(),Ae("div",{key:0,class:"sd-toolbar-button__main","data-item":`btn-${et(i)||""}-main`,onClick:re[0]||(re[0]=xe=>V(xe))},[et(a)?(ge(),dn(Q4,{key:0,color:et(c),class:"sd-toolbar-icon",icon:et(a),name:et(i)},null,8,["color","icon","name"])):ht("",!0),et(l)&&!et(u)&&!et(v)?(ge(),Ae("div",FN,Bt(et(l)),1)):ht("",!0)],8,ON)):ht("",!0),b.value?(ge(),Ae("div",{key:1,class:"sd-toolbar-button__caret","data-item":`btn-${et(i)||""}-caret`,"aria-label":`${et(y).ariaLabel} options`,role:"button"},[Me("div",{class:"sd-dropdown-caret",innerHTML:le.value,style:yn({opacity:et(m)?.6:1})},null,12,BN)],8,NN)):(ge(),Ae(Wt,{key:2},[et(a)?(ge(),dn(Q4,{key:0,color:et(c),class:"sd-toolbar-icon",icon:et(a),name:et(i)},null,8,["color","icon","name"])):ht("",!0),et(l)&&!et(u)&&(!et(v)||T.value==="fontFamily")?(ge(),Ae("div",{key:1,class:rn(["sd-button-label",{"sd-visually-hidden":et(v)&&T.value==="fontFamily"}])},Bt(et(l)),3)):ht("",!0),et(v)?(ge(),Ae("span",zN,[et(i)==="fontSize"?Us((ge(),Ae("input",{key:0,"onUpdate:modelValue":re[1]||(re[1]=xe=>R.value=xe),onKeydown:[Yo(tn(Fe,["stop","prevent"]),["enter"]),re[2]||(re[2]=Yo(xe=>fe(xe),["tab"]))],onClick:re[3]||(re[3]=tn(xe=>J(xe),["stop"])),onFocus:re[4]||(re[4]=xe=>J(xe)),type:"text",class:rn(["button-text-input button-text-input--font-size",{"high-contrast":et(j)}]),id:"inlineTextInput-"+et(i),autocomplete:"off",ref_key:"inlineInput",ref:P},null,42,VN)),[[Ai,R.value]]):Us((ge(),Ae("input",{key:1,"onUpdate:modelValue":re[5]||(re[5]=xe=>R.value=xe),placeholder:et(l),onKeydown:[Yo(tn(Fe,["stop","prevent"]),["enter"]),re[6]||(re[6]=Yo(xe=>fe(xe),["tab"]))],onClick:re[7]||(re[7]=tn(xe=>J(xe),["stop"])),onFocus:re[8]||(re[8]=xe=>J(xe)),type:"text",class:rn(["button-text-input",{"button-text-input--font-family":T.value==="fontFamily","high-contrast":et(j)}]),id:"inlineTextInput-"+et(i),"data-item":T.value==="fontFamily"?`btn-${et(i)}-input`:void 0,autocomplete:"off",ref_key:"inlineInput",ref:P},null,42,HN)),[[Ai,R.value]])])):ht("",!0),et(d)?(ge(),Ae("div",{key:3,class:"sd-dropdown-caret","data-item":`btn-${et(i)||""}-toggle`,innerHTML:le.value,style:yn({opacity:et(m)?.6:1})},null,12,jN)):ht("",!0)],64)),Me("div",UN,Bt(`${et(y).ariaLabel} ${et(s)?"selected":"unset"}`),1)],10,DN)],46,PN))}},J0=fn(GN,[["__scopeId","data-v-dbdea151"]]);xt(),gn();var WN={class:"toolbar-separator",role:"separator","aria-label":"Toolbar separator"},KN={__name:"ToolbarSeparator",props:{active:{type:Boolean,default:!1}},emits:["command"],setup(e,{emit:t}){const{isHighContrastMode:n}=Hi(),r=()=>n.value?"#000":"var(--sd-ui-border, #dbdbdb)";return(o,i)=>(ge(),Ae("div",WN,[Me("div",{class:"separator-inner",style:yn({backgroundColor:r()})},null,4)]))}},qN=fn(KN,[["__scopeId","data-v-cb82253a"]]);xt(),gn();var YN={class:"overflow-menu"},XN={class:"overflow-menu-trigger"},ZN={key:0,class:"overflow-menu_items",role:"group"},QN={__name:"OverflowMenu",props:{toolbarItem:{type:Object,required:!0},overflowItems:{type:Array,required:!0}},emits:["buttonClick","close"],setup(e,{emit:t}){const{proxy:n}=ir(),r=t,o=e,i=ke(()=>o.toolbarItem.expand.value),s=ne(!1),a=ke(()=>({...o.toolbarItem,active:i.value})),l=()=>{r("buttonClick",o.toolbarItem)},u=({item:d,argument:h})=>{n.$toolbar.emitCommand({item:d,argument:h})},c=d=>{d.key==="Escape"&&i.value&&!s.value&&(d.preventDefault(),r("close"))};return Nn(()=>{document.addEventListener("keydown",c,!0)}),or(()=>{document.removeEventListener("keydown",c,!0)}),(d,h)=>(ge(),Ae("div",YN,[Me("div",XN,[jt(J0,{"toolbar-item":a.value,onButtonClick:l},null,8,["toolbar-item"])]),i.value?(ge(),Ae("div",ZN,[jt(cm,{class:"superdoc-toolbar-overflow","toolbar-items":e.overflowItems,"from-overflow":"",onCommand:u,onDropdownUpdateShow:h[0]||(h[0]=m=>s.value=m)},null,8,["toolbar-items"])])):ht("",!0)]))}},JN=fn(QN,[["__scopeId","data-v-504ecd05"]]);xt(),gn();var $N={class:"toolbar-dropdown"},eB=["onClick"],tB={key:0,class:"toolbar-dropdown-option__icon"},nB={class:"toolbar-dropdown-option__label"},sm='button, [href], input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])',rB={__name:"ToolbarDropdown",props:{options:{type:Array,default:()=>[]},show:{type:Boolean,required:!0},placement:{type:String,default:"bottom-start"},disabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})},menuProps:{type:Function,default:null},nodeProps:{type:Function,default:null}},emits:["update:show","select"],setup(e,{emit:t}){const n=e,r=t,o=ne(null),i=ne(null),s=ne({top:"0px",left:"0px",maxHeight:"none"}),a=ne([]),l=ne(-1),u=ke(()=>!!n.show),c=ke(()=>n.options.some(re=>re?.type==="render")),d=ke(()=>typeof n.menuProps!="function"?{}:n.menuProps()||{}),h=ke(()=>{const{class:re,style:xe,...$e}=d.value;return $e}),m=ke(()=>{const re=d.value.class,xe=n.options.length>0&&n.options.every($e=>$e&&$e.type==="render");return["toolbar-dropdown-menu",re,{"toolbar-dropdown-menu--render-only":xe}]}),p=ke(()=>{const re=d.value.style||{};return{...n.contentStyle,...re}}),v=ke(()=>({...p.value,position:"fixed",top:s.value.top,left:s.value.left,maxHeight:s.value.maxHeight,zIndex:2e3})),_=re=>{r("update:show",re)},C=()=>{u.value&&_(!1)},k=()=>{if(!o.value)return;const re=o.value.getBoundingClientRect(),xe=i.value,$e=xe?.offsetWidth??0,st=xe?.scrollHeight??xe?.offsetHeight??0,At=window.innerWidth||document.documentElement.clientWidth||0,Ee=window.innerHeight||document.documentElement.clientHeight||0,Ge=8,qe=4,Z=re.bottom+qe,S=re.top-qe,ee=Math.max(0,Ee-Z-Ge),D=Math.max(0,S-Ge),U=ee<st&&D>ee,H=U?D:ee,G=st?Math.min(st,H):H,te=U?Math.max(Ge,S-G):Z;let Y=re.left;n.placement==="bottom-end"&&(Y=re.right-$e);const K=Math.max(Ge,At-$e-Ge);Y=Math.min(Math.max(Ge,Y),K),s.value={top:`${te}px`,left:`${Y}px`,maxHeight:`${H}px`}},y=()=>{n.disabled||_(!u.value)},b=re=>typeof n.nodeProps!="function"?{}:n.nodeProps(re)||{},T=re=>{re?.disabled||re?.type!=="render"&&(r("select",re?.key,re),C())},R=re=>re?.type==="render",P=re=>!re?.disabled&&re?.type!=="render",j=re=>typeof re?.icon=="function"||!!re?.icon,O=re=>typeof re?.icon=="function"?re.icon(re):re?.icon||null,V=re=>re?typeof re=="string"?re.split(/\s+/).includes("sd-selected"):Array.isArray(re)?re.some(V):typeof re=="object"?!!re["sd-selected"]:!1:!1,Q=re=>V(re?.props?.class)||V(re?.class),F=()=>n.options.map((re,xe)=>P(re)?xe:-1).filter(re=>re>=0),N=()=>{const re=n.options.findIndex(xe=>P(xe)&&Q(xe));return re>=0?re:F()[0]??-1},x=(re,xe)=>{if(!re){delete a.value[xe];return}a.value[xe]=re},z=()=>{a.value.forEach((xe,$e)=>{xe&&xe.setAttribute("tabindex",$e===l.value?"0":"-1")});const re=a.value[l.value];re&&typeof re.focus=="function"&&(re.focus(),re.scrollIntoView?.({block:"nearest",inline:"nearest"}))},J=re=>{const xe=F();if(!xe.length){l.value=-1;return}const $e=xe.indexOf(l.value);if($e<0){l.value=re>0?xe[0]:xe[xe.length-1];return}l.value=xe[($e+re+xe.length)%xe.length]},X=()=>{let re=n.options[l.value];if(!P(re)){const xe=F()[0];re=xe===void 0?null:n.options[xe]}re&&T(re)},ae=jl({name:"ToolbarDropdownRenderOption",props:{option:{type:Object,required:!0}},setup(re){return()=>typeof re.option.render!="function"?null:re.option.render()}}),pe=jl({name:"ToolbarDropdownOptionIcon",props:{option:{type:Object,required:!0}},setup(re){return()=>O(re.option)}}),Fe=re=>{if(!u.value)return;const xe=re.target;if(!(xe instanceof Element))return;const $e=o.value?.contains(xe),st=i.value?.contains(xe);$e||st||C()},fe=ne(null),ye=()=>{const re=o.value,xe=document.activeElement;if(re&&xe instanceof HTMLElement&&re.contains(xe)){fe.value=xe;return}fe.value=re?.matches?.(sm)?re:re?.querySelector(sm)},le=()=>{const re=fe.value;if(re instanceof HTMLElement&&document.contains(re)){re.focus();return}const xe=o.value;if(!xe)return;const $e=xe.matches?.(sm)?xe:xe.querySelector(sm);if($e instanceof HTMLElement){$e.focus();return}xe.setAttribute("tabindex","-1"),xe.focus()},Se=re=>{if(!u.value)return;const{key:xe}=re;if(["Escape","ArrowDown","ArrowUp","Enter"].includes(xe)){if(xe==="Escape"){re.preventDefault(),C(),_t(()=>{requestAnimationFrame(le)});return}if(!c.value){if(re.preventDefault(),xe==="ArrowDown"){J(1),z();return}if(xe==="ArrowUp"){J(-1),z();return}xe==="Enter"&&X()}}};return Lt(u,async re=>{if(!re){l.value=-1,a.value=[];return}ye(),await _t(),k(),!c.value&&(l.value=N(),await _t(),z())},{immediate:!0}),Lt(u,re=>{re?(document.addEventListener("pointerdown",Fe,!0),document.addEventListener("keydown",Se,!0),window.addEventListener("resize",k),window.addEventListener("scroll",k,!0)):(document.removeEventListener("pointerdown",Fe,!0),document.removeEventListener("keydown",Se,!0),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0))},{immediate:!0}),or(()=>{document.removeEventListener("pointerdown",Fe,!0),document.removeEventListener("keydown",Se,!0),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0)}),(re,xe)=>(ge(),Ae("div",$N,[Me("div",{ref_key:"triggerRef",ref:o,class:"toolbar-dropdown-trigger","data-sd-part":"dropdown-trigger",onClick:y},[Ad(re.$slots,"trigger",{},void 0,!0)],512),(ge(),dn(Ha,{to:"body"},[jt(Xh,{name:"fade-in-scale-up-transition"},{default:Eo(()=>[u.value?(ge(),Ae("div",fs({key:0,ref_key:"menuRef",ref:i,"data-sd-part":"dropdown-menu",class:m.value,style:v.value},h.value),[(ge(!0),Ae(Wt,null,rr(e.options,($e,st)=>(ge(),Ae("div",fs({key:$e.key,ref_for:!0,ref:At=>x(At,st),class:["toolbar-dropdown-option",[$e.class,$e.props?.class,{"sd-disabled":$e.disabled,"sd-render":R($e)}]],tabindex:"-1",onClick:At=>T($e)},{ref_for:!0},{...$e.props,...b($e)}),[R($e)?(ge(),dn(et(ae),{key:0,option:$e},null,8,["option"])):(ge(),Ae(Wt,{key:1},[j($e)?(ge(),Ae("span",tB,[jt(et(pe),{option:$e},null,8,["option"])])):ht("",!0),Me("span",nB,Bt($e.label),1)],64))],16,eB))),128))],16)):ht("",!0)]),_:1})]))]))}},oB=fn(rB,[["__scopeId","data-v-fef410f7"]]),J4=e=>String(e??"").trim().toLowerCase();const am=(e,t)=>{const n=J4(e);if(!n)return-1;for(let r=0;r<t.length;r+=1)if(J4(t[r]).startsWith(n))return r;return-1},iB=(e,t,{autocomplete:n=!0}={})=>{const r=String(e??""),o=am(r,t),i=o>=0?String(t[o]??""):"";return n&&o>=0&&i.length>r.length?{matchIndex:o,display:i,selectionStart:r.length,selectionEnd:i.length}:{matchIndex:o,display:r,selectionStart:r.length,selectionEnd:r.length}};var sB=e=>{let t=String(e??"").trim();for(;t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"));)t=t.slice(1,-1).trim();return t},aB=e=>e<=31||e===127,lB=e=>e===32||e===160||e===65279,cB=e=>Array.from(String(e)).filter(t=>!aB(t.charCodeAt(0))).join(""),uB=e=>{let t="",n=!1;for(const r of String(e)){if(lB(r.charCodeAt(0))){n=t.length>0;continue}n&&(t+=" "),n=!1,t+=r}return t};const dB=e=>uB(sB(cB(String(e??"").split(",")[0]??""))).trim();var fB=1,hB=1638;const pB=e=>{const t=String(e??"").replace(/[^0-9.-]/g,""),n=Number.parseFloat(t);if(!Number.isFinite(n))return"";const r=Math.round(n*2)/2;return r<fB?"":String(Math.min(r,hB))};xt(),gn();var mB=["data-item"],gB=["id","value","disabled","aria-label","aria-expanded","aria-controls","aria-activedescendant","data-item"],vB=["data-item","aria-label","disabled"],yB=["innerHTML"],bB=["id","aria-label"],wB=["id","aria-selected","aria-label","onMousedown","onMouseenter"],CB={class:"toolbar-dropdown-option__label"},_B={class:"sd-button-label sd-font-combobox__legacy-label","aria-hidden":"true"},SB={__name:"ToolbarComboBox",props:{item:{type:Object,required:!0},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"},showPreview:{type:Boolean,default:!1},normalizeValue:{type:Function,default:e=>String(e??"").trim()}},emits:["command","item-clicked","tab-out","editor-handoff"],setup(e,{emit:t}){const n=e,r=t,{isHighContrastMode:o}=Hi(),i=ne(null),s=ne(null),a=ne(null),l=ne([]),u=ne(!1),c=ne(!1),d=ne(-1),h=ne(""),m=ne(""),p=ne(!1),v=ne({top:"0px",left:"0px",minWidth:"0px",maxHeight:"none"}),_=ke(()=>n.item.nestedOptions?.value??[]),C=ke(()=>_.value.map(Y=>String(Y?.label??""))),k=ke(()=>String(n.item.label?.value??"")),y=ke(()=>!!n.item.disabled?.value),b=ke(()=>String(n.item.name?.value??"")),T=ke(()=>n.item.attributes?.value?.ariaLabel??"Font family"),R=ke(()=>u.value?m.value:k.value),P=ke(()=>`sd-${b.value||"combobox"}-listbox-${n.item.id?.value??"default"}`),j=Y=>`${P.value}-option-${Y}`,O=ke(()=>c.value&&d.value>=0?j(d.value):void 0),V=ke(()=>c.value?er.dropdownCaretUp:er.dropdownCaretDown),Q=Y=>{const K=String(Y??"").trim().toLowerCase();return _.value.find(be=>String(be?.label??"").trim().toLowerCase()===K)?.props?.style?.fontFamily||Y||n.uiFontFamily},F=ke(()=>n.showPreview?{fontFamily:Q(u.value?m.value:k.value)}:{fontFamily:n.uiFontFamily}),N=()=>{const Y=n.item.selectedValue?.value;if(Y){const K=_.value.findIndex(be=>be?.key===Y);if(K>=0)return K}return C.value.findIndex(K=>K.toLowerCase()===k.value.toLowerCase())},x=(Y,K)=>{const be=i.value;if(!(!be||typeof be.setSelectionRange!="function"))try{be.setSelectionRange(Y,K)}catch{}},z=()=>{l.value[d.value]?.scrollIntoView?.({block:"nearest",inline:"nearest"})},J=()=>{l.value[d.value]?.focus?.()},X=()=>{const Y=s.value;if(!Y)return;const K=Y.getBoundingClientRect(),be=a.value,me=be?.scrollHeight??be?.offsetHeight??0,Ce=window.innerHeight||document.documentElement.clientHeight||0,Pe=window.innerWidth||document.documentElement.clientWidth||0,it=8,He=4,Ct=K.bottom+He,Yt=K.top-He,St=Math.max(0,Ce-Ct-it),Ft=Math.max(0,Yt-it),Nt=St<me&&Ft>St,sn=Nt?Ft:St,_n=me?Math.min(me,sn):sn,Qt=Nt?Math.max(it,Yt-_n):Ct,Ye=Math.min(Math.max(it,K.left),Math.max(it,Pe-K.width-it));v.value={top:`${Qt}px`,left:`${Ye}px`,minWidth:`${K.width}px`,maxHeight:`${sn}px`}},ae=ke(()=>({position:"fixed",top:v.value.top,left:v.value.left,minWidth:v.value.minWidth,maxHeight:v.value.maxHeight,fontFamily:n.uiFontFamily,zIndex:2e3})),pe=Y=>{n.item.expand&&typeof n.item.expand=="object"&&"value"in n.item.expand&&(n.item.expand.value=Y)},Fe=(Y,{focusInput:K=!1,focusOption:be=!1}={})=>{if(y.value||!_.value.length){pe(!1);return}c.value=!0,pe(!0),d.value=Y??-1,K&&(u.value=!0,m.value=k.value,i.value?.focus()),_t(()=>{X(),z(),be&&J()})},fe=({syncItem:Y=!0}={})=>{c.value=!1,d.value=-1,Y&&pe(!1)},ye=()=>{fe(),u.value=!1,h.value="",m.value=k.value},le=()=>{y.value||(c.value||r("item-clicked"),u.value=!0,h.value="",m.value=k.value,_t(()=>x(0,m.value.length)))},Se=Y=>{if(y.value)return;const K=document.activeElement===i.value;if(r("item-clicked"),u.value=!0,K||(h.value="",m.value=k.value,Y.preventDefault(),i.value?.focus({preventScroll:!0}),x(0,k.value.length)),!c.value){const be=N();Fe(be>=0?be:0)}},re=Y=>{const K=Y.relatedTarget;K instanceof Node&&s.value?.contains(K)||K instanceof Node&&a.value?.contains(K)||ye()},xe=Y=>{if(p.value)return;const K=Y.target,be=K.value,me=typeof K.selectionStart=="number"?K.selectionStart:be.length,Ce=typeof K.selectionEnd=="number"?K.selectionEnd:me,Pe=typeof Y.inputType=="string"&&Y.inputType.startsWith("delete"),it=me===be.length&&Ce===be.length;h.value=be;const He=iB(be,C.value,{autocomplete:!Pe&&it});m.value=He.display,K.value=He.display,He.display===be&&!it?x(me,Ce):x(He.selectionStart,He.selectionEnd),c.value&&(d.value=He.matchIndex,_t(z))},$e=Y=>{p.value=!1,xe(Y)},st=Y=>{if(!_.value.length)return;const K=_.value.length;d.value=((d.value<0?Y>0?-1:0:d.value)+Y+K)%K,_t(z)},At=(Y,K)=>{r("item-clicked"),r("command",{item:n.item,argument:Y,option:K}),K&&(n.item.selectedValue.value=K.key)},Ee=Y=>{Y&&(At(Y.label,Y),u.value=!1,h.value="",m.value=Y.label,fe())},Ge=()=>{if(c.value&&d.value>=0)return Ee(_.value[d.value]),!0;const Y=am(h.value,C.value);if(Y>=0)return Ee(_.value[Y]),!0;const K=n.normalizeValue(h.value);return K?(At(K,null),u.value=!1,h.value="",m.value=K,fe(),!0):!1},qe=Y=>{if(!(Y.isComposing||p.value||Y.keyCode===229)&&!(Y.ctrlKey||Y.metaKey||Y.altKey))switch(Y.key){case"ArrowDown":if(Y.preventDefault(),c.value)J();else{const K=am(h.value,C.value),be=K>=0?K:N();Fe(be>=0?be:0,{focusOption:!0})}break;case"ArrowUp":if(Y.preventDefault(),c.value)J();else{const K=am(h.value,C.value),be=K>=0?K:N();Fe(be>=0?be:_.value.length-1,{focusOption:!0})}break;case"Enter":Y.preventDefault(),Ge()&&r("editor-handoff"),i.value?.blur();break;case"Tab":Y.preventDefault(),Ge(),fe(),i.value?.blur(),r("tab-out",Y);break;case"Escape":Y.preventDefault(),ye(),_t(()=>i.value?.focus());break;default:break}},Z=Y=>{if(Y.preventDefault(),!y.value)if(r("item-clicked"),c.value)fe(),i.value?.focus();else{const K=N();Fe(K>=0?K:0,{focusOption:!0})}},S=(Y,K)=>{Y.preventDefault(),Ee(K),r("editor-handoff"),i.value?.blur()},ee=Y=>{d.value=Y},D=Y=>{if(!(Y.ctrlKey||Y.metaKey||Y.altKey))switch(Y.key){case"ArrowDown":Y.preventDefault(),st(1),J();break;case"ArrowUp":Y.preventDefault(),st(-1),J();break;case"Enter":Y.preventDefault(),d.value>=0&&(Ee(_.value[d.value]),r("editor-handoff"));break;case"Escape":Y.preventDefault(),ye(),_t(()=>i.value?.focus());break;case"Tab":Y.preventDefault(),d.value>=0?Ee(_.value[d.value]):fe(),r("tab-out",{shiftKey:Y.shiftKey,target:i.value});break;default:break}},U=Y=>{if(!c.value)return;const K=Y.target;K instanceof Element&&(s.value?.contains(K)||a.value?.contains(K)||ye())};Lt(c,Y=>{Y?(document.addEventListener("pointerdown",U,!0),window.addEventListener("resize",X),window.addEventListener("scroll",X,!0)):(document.removeEventListener("pointerdown",U,!0),window.removeEventListener("resize",X),window.removeEventListener("scroll",X,!0),l.value=[])},{immediate:!0}),or(()=>{document.removeEventListener("pointerdown",U,!0),window.removeEventListener("resize",X),window.removeEventListener("scroll",X,!0)});const H=(Y,K)=>{if(!Y){delete l.value[K];return}l.value[K]=Y},G=Y=>Y===d.value,te=Y=>Y?.key&&Y.key===n.item.selectedValue?.value;return Lt(k,Y=>{u.value||(m.value=Y)}),Lt(()=>!!n.item.expand?.value,Y=>{if(Y&&!c.value){const K=N();Fe(K>=0?K:0,{focusInput:!0});return}!Y&&c.value&&fe({syncItem:!1})}),(Y,K)=>(ge(),Ae("div",{ref_key:"rootRef",ref:s,class:rn(["sd-font-combobox sd-toolbar-split-field",{"sd-disabled":y.value,"high-contrast":et(o)}]),style:yn(n.item.style?.value),"data-item":`btn-${b.value}`},[Me("span",{class:"sd-font-combobox__field sd-toolbar-split-field__main",onMousedown:Se},[Me("input",{ref_key:"inputRef",ref:i,id:`inlineTextInput-${b.value}`,class:"button-text-input sd-font-combobox__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:"false",value:R.value,style:yn(F.value),disabled:y.value,"aria-label":T.value,"aria-expanded":c.value?"true":"false","aria-controls":P.value,"aria-activedescendant":O.value,"aria-haspopup":"listbox","aria-autocomplete":"both","data-item":`btn-${b.value}-input`,onFocus:le,onBlur:re,onInput:xe,onKeydown:qe,onCompositionstart:K[0]||(K[0]=be=>p.value=!0),onCompositionend:$e},null,44,gB)],32),Me("button",{type:"button",class:"sd-font-combobox__caret sd-toolbar-split-field__caret","data-item":`btn-${b.value}-toggle`,tabindex:"-1","aria-label":`${T.value} options`,disabled:y.value,onMousedown:Z},[Me("span",{class:"sd-dropdown-caret",innerHTML:V.value},null,8,yB)],40,vB),(ge(),dn(Ha,{to:"body"},[c.value?(ge(),Ae("div",{key:0,ref_key:"popupRef",ref:a,role:"listbox",id:P.value,"aria-label":T.value,class:rn(["sd-font-combobox__listbox",{"high-contrast":et(o)}]),style:yn(ae.value)},[(ge(!0),Ae(Wt,null,rr(_.value,(be,me)=>(ge(),Ae("div",fs({key:be.key,ref_for:!0,ref:Ce=>H(Ce,me),id:j(me),role:"option",tabindex:"-1",class:["toolbar-dropdown-option sd-font-combobox__option",{"sd-active":G(me),"sd-selected":te(be)}],"aria-selected":te(be)?"true":"false","aria-label":`${T.value} - ${be.label}`},{ref_for:!0},be.props,{onMousedown:Ce=>S(Ce,be),onMouseenter:Ce=>ee(me),onKeydown:D}),[Me("span",CB,Bt(be.label),1)],16,wB))),128))],14,bB)):ht("",!0)])),Me("span",_B,Bt(k.value),1)],14,mB))}},$4=fn(SB,[["__scopeId","data-v-99070b63"]]);xt();var kB={__name:"FontFamilyCombobox",props:{item:{type:Object,required:!0},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"}},emits:["command","item-clicked","tab-out","editor-handoff"],setup(e,{emit:t}){const n=e,r=t;return(o,i)=>(ge(),dn($4,{item:n.item,"ui-font-family":n.uiFontFamily,"show-preview":!0,"normalize-value":et(dB),onCommand:i[0]||(i[0]=s=>r("command",s)),onItemClicked:i[1]||(i[1]=s=>r("item-clicked")),onTabOut:i[2]||(i[2]=s=>r("tab-out",s)),onEditorHandoff:i[3]||(i[3]=s=>r("editor-handoff"))},null,8,["item","ui-font-family","normalize-value"]))}},AB=kB;xt();var IB={__name:"FontSizeCombobox",props:{item:{type:Object,required:!0},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"}},emits:["command","item-clicked","tab-out","editor-handoff"],setup(e,{emit:t}){const n=e,r=t;return(o,i)=>(ge(),dn($4,{item:n.item,"ui-font-family":n.uiFontFamily,"show-preview":!1,"normalize-value":et(pB),onCommand:i[0]||(i[0]=s=>r("command",s)),onItemClicked:i[1]||(i[1]=s=>r("item-clicked")),onTabOut:i[2]||(i[2]=s=>r("tab-out",s)),onEditorHandoff:i[3]||(i[3]=s=>r("editor-handoff"))},null,8,["item","ui-font-family","normalize-value"]))}},EB=IB;xt(),gn();var xB=2500,TB=Object.assign({inheritAttrs:!1},{__name:"SdTooltip",props:{trigger:{type:String,default:"hover"},delay:{type:Number,default:100},duration:{type:Number,default:100},disabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})}},setup(e){const t=e,n=Z2(),r=ne(!1),o=ne(null),i=ne(null),s=ne({top:"0px",left:"0px"});let a=null,l=null,u=null;const c=ke(()=>["sd-tooltip-content",n.class]),d=ke(()=>({...t.contentStyle,...n.style||{},position:"fixed",top:s.value.top,left:s.value.left,zIndex:2100})),h=()=>{a&&(window.clearTimeout(a),a=null)},m=()=>{l&&(window.clearTimeout(l),l=null)},p=()=>{u&&(window.clearTimeout(u),u=null)},v=()=>{p(),u=window.setTimeout(()=>{u=null,k()},xB)},_=()=>{if(!o.value||!i.value)return;const V=o.value.getBoundingClientRect(),Q=i.value.offsetWidth,F=i.value.offsetHeight,N=window.innerWidth||document.documentElement.clientWidth||0,x=8;let z=V.left+V.width/2-Q/2;z=Math.max(x,Math.min(z,N-Q-x)),s.value={top:`${V.top-F-10}px`,left:`${z}px`}},C=async()=>{t.disabled||(h(),m(),!r.value&&(r.value=!0,v(),await _t(),_()))},k=()=>{m(),h(),p(),r.value&&(r.value=!1)},y=()=>{if(h(),m(),!r.value){if(t.delay===0){C();return}l=window.setTimeout(()=>{l=null,C()},t.delay)}},b=()=>{if(m(),h(),!!r.value){if(t.duration===0){k();return}a=window.setTimeout(()=>{a=null,k()},t.duration)}},T=()=>{t.trigger==="hover"&&y()},R=()=>{t.trigger==="hover"&&b()},P=()=>{m(),h()},j=()=>{b()},O=V=>{V.key==="Escape"&&k()};return Lt(()=>t.disabled,V=>{V&&k()}),Lt(r,V=>{V?(window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),document.addEventListener("keydown",O,!0)):(window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0),document.removeEventListener("keydown",O,!0))}),or(()=>{m(),h(),p(),window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0),document.removeEventListener("keydown",O,!0)}),(V,Q)=>(ge(),Ae(Wt,null,[Me("span",{ref_key:"triggerRef",ref:o,class:"sd-tooltip-trigger",onMouseenter:T,onMouseleave:R,onFocusin:T,onFocusout:R},[Ad(V.$slots,"trigger",{},void 0,!0)],544),(ge(),dn(Ha,{to:"body"},[jt(Xh,{name:"fade-in-scale-up-transition"},{default:Eo(()=>[r.value&&!e.disabled?(ge(),Ae("div",{key:0,ref_key:"contentRef",ref:i,class:rn(c.value),style:yn(d.value),onMouseenter:P,onMouseleave:j},[Q[0]||(Q[0]=Me("span",{class:"sd-tooltip-arrow","aria-hidden":"true"},null,-1)),Ad(V.$slots,"default",{},void 0,!0)],38)):ht("",!0)]),_:3})]))],64))}}),lm=fn(TB,[["__scopeId","data-v-2a872eae"]]);xt(),gn();var RB=["onKeydown","tabindex","data-item-id"],MB={key:0},LB={key:0},PB={key:0},DB={key:0},OB={key:0},FB={__name:"ButtonGroup",props:{toolbarItems:{type:Array,required:!0},overflowItems:{type:Array,default:()=>[]},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"},position:{type:String,default:"left"},fromOverflow:{type:Boolean,default:!1},compactSideGroups:{type:Boolean,default:!1}},emits:["command","item-clicked","dropdown-update-show"],setup(e,{emit:t}){const n=t,{proxy:r}=ir(),o=ne([]),i=ne(null),s=e,a=ne(null),{isHighContrastMode:l}=Hi(),u=window.matchMedia("(max-width: 768px)").matches,c=ke(()=>s.position==="left"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-start"}:s.position==="right"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-end"}:{flexGrow:u?0:1,justifyContent:"center"}),d=Ee=>Ee.type==="button",h=Ee=>Ee.type==="dropdown",m=Ee=>Ee.type==="dropdown"&&Ee.name?.value==="fontFamily",p=Ee=>Ee.type==="dropdown"&&Ee.name?.value==="fontSize",v=Ee=>Ee.type==="separator",_=Ee=>Ee.type==="overflow",C=Ee=>!!Ee.nestedOptions?.value?.length,k=Ee=>{if(!Ee)return!1;const Ge=Ee.expand;return typeof Ge=="object"&&Ge!==null&&"value"in Ge?!!Ge.value:!!Ge},y=(Ee,Ge)=>{Ee?.expand&&(Ee.expand.value=Ge)},b=(Ee,Ge=void 0)=>{if(Ee.disabled.value)return;if(_(Ee)){const Z=!k(Ee);Z&&P(),y(Ee,Z),a.value=Z?Ee:null,n("item-clicked");return}if(h(Ee))return;a.value&&h(a.value)&&k(a.value)&&P(),n("item-clicked");const qe=Ge!==void 0?Ge:Ee.argument?.value;n("command",qe===void 0?{item:Ee}:{item:Ee,argument:qe})},T=(Ee,Ge)=>{Ee.disabled.value||(a.value=null,n("command",{item:Ee,argument:Ge}))},R=Ee=>{if(Ee.disabled.value)return;P();const Ge=Ee.splitButtonCommand,qe=Ee.command,Z=Ge||qe;if(!Z)return;const S={...Ee,command:Z};n("item-clicked"),n("command",{item:S})},P=()=>{const Ee=r?.$toolbar?.toolbarItems||[],Ge=r?.$toolbar?.overflowItems||[],qe=[...Ee,...Ge];(qe.length?qe:s.toolbarItems).forEach(Z=>{const S=_(Z)&&!s.fromOverflow;(h(Z)||S)&&y(Z,!1)}),a.value=null},j=(Ee,Ge)=>{P(),n("command",{item:Ee,argument:Ee.dropdownValueKey.value?Ge[Ee.dropdownValueKey.value]:Ge.label,option:Ge}),Ee.selectedValue.value=Ge.key},O=Ee=>{n("command",Ee)},V=()=>{P(),n("item-clicked")},Q=()=>{const Ee=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');return Ee instanceof HTMLElement?(Ee.focus({preventScroll:!0}),!0):!1},F=()=>{const Ee=r?.$toolbar?.pendingSelectionCapture,Ge=()=>{Ee&&typeof r?.$toolbar?.ui?.selection?.restore=="function"&&r.$toolbar.ui.selection.restore(Ee)};if(Q()){Ge();return}typeof r?.$toolbar?.superdoc?.focus=="function"&&(r.$toolbar.superdoc.focus(),Ge())},N=Ee=>!(Ee instanceof HTMLElement)||Ee.classList.contains("sd-disabled")?null:Ee.querySelector("input:not([disabled]), textarea:not([disabled]), select:not([disabled])")||Ee.querySelector('button:not([disabled]), [role="button"]:not(.sd-disabled), [tabindex]:not([tabindex="-1"])'),x=(Ee,Ge)=>{const qe=Ee?.target?.closest?.(".sd-toolbar-item-ctn");if(!(qe instanceof HTMLElement))return!1;let Z=Ge>0?qe.nextElementSibling:qe.previousElementSibling;for(;Z;){const S=N(Z);if(S instanceof HTMLElement)return qe.setAttribute("tabindex","-1"),Z.setAttribute("tabindex","0"),S.focus(),!0;Z=Ge>0?Z.nextElementSibling:Z.previousElementSibling}return!1},z=Ee=>{P(),x(Ee,Ee?.shiftKey?-1:1)||F()},J=Ee=>{if(P(),Ee?.shiftKey){x(Ee,-1)||F();return}F()},X=()=>{F()},ae=Ee=>Ee.nestedOptions?.value?.length?Ee.nestedOptions.value.map(Ge=>{const qe=Ge?.type!=="render"&&Ee.selectedValue.value===Ge.key;return{...Ge,props:{...Ge.props,class:qe?"sd-selected":""}}}):[],pe=(Ee,Ge)=>({role:"menuitem",ariaLabel:`${Ge.attributes.value.ariaLabel} - ${Ee.label}`}),Fe=Ee=>{const Ge=Ee.target,qe=Ee.target.closest(".sd-toolbar-item-ctn").nextElementSibling;qe&&(Ge.setAttribute("tabindex","-1"),qe.setAttribute("tabindex","0"),qe.focus())},fe=Ee=>{const Ge=Ee.target,qe=Ee.target.closest(".sd-toolbar-item-ctn").previousElementSibling;qe&&(Ge.setAttribute("tabindex","-1"),qe.setAttribute("tabindex","0"),qe.focus())},ye=Ee=>{const Ge=Ee.target.closest(".button-group").nextElementSibling;if(Ge)Ge.setAttribute("tabindex","0"),Ge.focus();else{const qe=document.querySelector(".ProseMirror");qe&&qe.focus()}},le=Ee=>{const Ge=Ee.target.closest(".button-group").previousElementSibling;Ge&&(Ge.setAttribute("tabindex","0"),Ge.focus())},Se=Ee=>{if(!Ee.disabled.value){if(h(Ee)){$e(!k(Ee),Ee);return}b(Ee)}},re=(Ee,Ge)=>{const qe=Ee.target.nodeName==="INPUT"||Ee.target.nodeName==="TEXTAREA",Z=Ge.name.value==="fontSize"||Ge.name.value==="fontFamily";if(!(qe&&Z)&&["Enter"," ","Spacebar","Escape","ArrowRight","ArrowLeft","Tab"].includes(Ee.key))switch(Ee.preventDefault(),Ee.key){case"Enter":case" ":case"Spacebar":Se(Ge);break;case"Escape":P();break;case"ArrowRight":P(),Fe(Ee);break;case"ArrowLeft":P(),fe(Ee);break;case"Tab":Ee.shiftKey?le(Ee):ye(Ee);break;default:break}},xe=Ee=>{const Ge=o.value.find(qe=>!qe.classList.contains("sd-disabled"));Ge&&(Ge.setAttribute("tabindex","0"),Ge.focus())},$e=(Ee,Ge)=>{if(n("item-clicked"),!Ee){P(),n("dropdown-update-show",!1);return}P(),a.value=Ge,y(Ge,!0),n("dropdown-update-show",!0)},st=Ee=>{if(!a.value)return;const Ge=Ee.target;Ge instanceof Element&&(Ge.closest(".sd-toolbar-dropdown-menu")||i.value?.contains(Ge)||P())};return Lt(()=>k(a.value),Ee=>{Ee?document.addEventListener("pointerdown",st,!0):document.removeEventListener("pointerdown",st,!0)},{immediate:!0}),or(()=>{document.removeEventListener("pointerdown",st,!0)}),(Ee,Ge)=>(ge(),Ae("div",{style:yn(c.value),class:"button-group",role:"group",onFocus:xe,ref_key:"buttonGroupRef",ref:i},[(ge(!0),Ae(Wt,null,rr(e.toolbarItems,(qe,Z)=>(ge(),Ae("div",{key:qe.id.value,class:rn([{narrow:qe.isNarrow.value,wide:qe.isWide.value,"sd-disabled":qe.disabled.value},"sd-toolbar-item-ctn"]),onKeydown:S=>re(S,qe),ref_for:!0,ref_key:"toolbarItemRefs",ref:o,tabindex:Z===0?0:-1,"data-item-id":qe.id.value},[v(qe)?(ge(),dn(qN,{key:0,style:{width:"20px"}})):ht("",!0),m(qe)&&C(qe)?(ge(),dn(lm,{key:1,trigger:"hover",disabled:!qe.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:Eo(()=>[jt(AB,{item:qe,"ui-font-family":s.uiFontFamily,class:"sd-toolbar-button sd-editor-toolbar-dropdown",onCommand:O,onItemClicked:V,onTabOut:Ge[0]||(Ge[0]=S=>z(S)),onEditorHandoff:X},null,8,["item","ui-font-family"])]),default:Eo(()=>[Me("div",null,[Ni(Bt(qe.tooltip)+" ",1),qe.disabled.value?(ge(),Ae("span",MB,"(disabled)")):ht("",!0)])]),_:2},1032,["disabled","content-style"])):p(qe)&&C(qe)?(ge(),dn(lm,{key:2,trigger:"hover",disabled:!qe.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:Eo(()=>[jt(EB,{item:qe,"ui-font-family":s.uiFontFamily,class:"sd-toolbar-button sd-editor-toolbar-dropdown",onCommand:O,onItemClicked:V,onTabOut:Ge[1]||(Ge[1]=S=>J(S)),onEditorHandoff:X},null,8,["item","ui-font-family"])]),default:Eo(()=>[Me("div",null,[Ni(Bt(qe.tooltip)+" ",1),qe.disabled.value?(ge(),Ae("span",LB,"(disabled)")):ht("",!0)])]),_:2},1032,["disabled","content-style"])):h(qe)&&qe.nestedOptions?.value?.length?(ge(),dn(oB,{key:3,options:ae(qe),disabled:qe.disabled.value,show:k(qe),"content-style":{fontFamily:s.uiFontFamily},placement:"bottom-start",class:"sd-toolbar-button sd-editor-toolbar-dropdown",onSelect:(S,ee)=>j(qe,ee),"onUpdate:show":S=>$e(S,qe),style:yn(qe.dropdownStyles.value),"menu-props":()=>({role:"menu",style:{fontFamily:s.uiFontFamily},class:["sd-toolbar-dropdown-menu",{"high-contrast":et(l)}]}),"node-props":S=>pe(S,qe)},{trigger:Eo(()=>[jt(lm,{trigger:"hover",disabled:!qe.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:Eo(()=>[jt(J0,{"toolbar-item":qe,disabled:qe.disabled.value,"allow-enter-propagation":!0,onTextSubmit:S=>T(qe,S),onMainClick:S=>R(qe)},null,8,["toolbar-item","disabled","onTextSubmit","onMainClick"])]),default:Eo(()=>[Me("div",null,[Ni(Bt(qe.tooltip)+" ",1),qe.disabled.value?(ge(),Ae("span",PB,"(disabled)")):ht("",!0)])]),_:2},1032,["disabled","content-style"])]),_:2},1032,["options","disabled","show","content-style","onSelect","onUpdate:show","style","menu-props","node-props"])):d(qe)?(ge(),dn(lm,{key:4,trigger:"hover",class:"sd-editor-toolbar-tooltip","content-style":{fontFamily:s.uiFontFamily}},{trigger:Eo(()=>[jt(J0,{"toolbar-item":qe,"is-overflow-item":e.fromOverflow,onTextSubmit:S=>T(qe,S),onButtonClick:S=>b(qe)},null,8,["toolbar-item","is-overflow-item","onTextSubmit","onButtonClick"])]),default:Eo(()=>[qe.tooltip?(ge(),Ae("div",DB,[Ni(Bt(qe.tooltip)+" ",1),qe.disabled.value?(ge(),Ae("span",OB,"(disabled)")):ht("",!0)])):ht("",!0)]),_:2},1032,["content-style"])):ht("",!0),_(qe)&&e.overflowItems.length?(ge(),dn(JN,{key:5,"toolbar-item":qe,onButtonClick:S=>b(qe),"overflow-items":e.overflowItems,onClose:P},null,8,["toolbar-item","onButtonClick","overflow-items"])):ht("",!0)],42,RB))),128))],36))}},cm=fn(FB,[["__scopeId","data-v-590293ab"]]),NB=[["Arial","sans-serif"],["Arial Black","sans-serif"],["Arial Narrow","sans-serif"],["Baskerville Old Face","serif"],["Bookman Old Style","serif"],["Brush Script MT","cursive"],["Calibri","sans-serif"],["Century","serif"],["Century Gothic","sans-serif"],["Comic Sans MS","sans-serif"],["Cooper Black","serif"],["Courier New","monospace"],["Garamond","serif"],["Georgia","serif"],["Gill Sans MT Condensed","sans-serif"],["Helvetica","sans-serif"],["Lucida Console","monospace"],["Segoe UI","sans-serif"],["Tahoma","sans-serif"],["Times New Roman","serif"],["Trebuchet MS","sans-serif"],["Verdana","sans-serif"]];const BB=NB.map(([e,t])=>({label:e,key:e,props:{style:{fontFamily:`${e}, ${t}`},"data-item":"btn-fontFamily-option"}}));function zB(e){if(e?.length)return e.map(t=>({label:t.label,key:t.value,props:{style:{fontFamily:t.previewFamily||t.label},"data-item":"btn-fontFamily-option"}}))}const VB=[{label:"8",key:"8pt",props:{"data-item":"btn-fontSize-option"}},{label:"9",key:"9pt",props:{"data-item":"btn-fontSize-option"}},{label:"10",key:"10pt",props:{"data-item":"btn-fontSize-option"}},{label:"11",key:"11pt",props:{"data-item":"btn-fontSize-option"}},{label:"12",key:"12pt",props:{"data-item":"btn-fontSize-option"}},{label:"14",key:"14pt",props:{"data-item":"btn-fontSize-option"}},{label:"18",key:"18pt",props:{"data-item":"btn-fontSize-option"}},{label:"24",key:"24pt",props:{"data-item":"btn-fontSize-option"}},{label:"30",key:"30pt",props:{"data-item":"btn-fontSize-option"}},{label:"36",key:"36pt",props:{"data-item":"btn-fontSize-option"}},{label:"48",key:"48pt",props:{"data-item":"btn-fontSize-option"}},{label:"60",key:"60pt",props:{"data-item":"btn-fontSize-option"}},{label:"72",key:"72pt",props:{"data-item":"btn-fontSize-option"}},{label:"96",key:"96pt",props:{"data-item":"btn-fontSize-option"}}],Ff={sm:768,md:1024,lg:1280,xl:1410},$0={undo:"undo",redo:"redo",bold:"bold",italic:"italic",underline:"underline",strike:"strikethrough",acceptTrackedChangeBySelection:"track-changes-accept-selection",rejectTrackedChangeOnSelection:"track-changes-reject-selection",ruler:"ruler",formattingMarks:"formatting-marks",zoom:"zoom",measurementUnit:"measurement-unit",documentMode:"document-mode",link:"link",fontFamily:"font-family",fontSize:"font-size",list:"bullet-list",numberedlist:"numbered-list",table:"table-insert",image:"image",tableOfContents:"table-of-contents-insert",color:"text-color",highlight:"highlight-color",textAlign:"text-align",lineHeight:"line-height",linkedStyles:"linked-style",indentleft:"indent-decrease",indentright:"indent-increase",directionLtr:"direction-ltr",directionRtl:"direction-rtl",clearFormatting:"clear-formatting",copyFormat:"copy-format"},eA={addRowBefore:"table-add-row-before",addRowAfter:"table-add-row-after",deleteRow:"table-delete-row",addColumnBefore:"table-add-column-before",addColumnAfter:"table-add-column-after",deleteColumn:"table-delete-column",deleteTable:"table-delete",deleteCellAndTableBorders:"table-remove-borders",mergeCells:"table-merge-cells",splitCell:"table-split-cell",fixTables:"table-fix"},tA=Object.values(eA),BU=[...new Set([...Object.values($0),...tA])];var HB=new Set(["link"]);const zU=new Set(Object.keys($0).filter(e=>!HB.has(e)));xt(),gn();var jB="Arial, Helvetica, sans-serif",UB={__name:"Toolbar",emits:["command","toggle","select"],setup(e,{emit:t}){const{proxy:n}=ir();let r=ne(1);const o=ne(0),i=ne(!1);let s=null,a=null;const l=ke(()=>{const j=n?.$toolbar?.config?.uiDisplayFallbackFont;return typeof j=="string"&&j.trim()?j.trim():jB}),u=n.$toolbar.config?.toolbarGroups?.includes("left"),c=n.$toolbar.config?.toolbarGroups?.includes("right"),d=n.$toolbar.config?.toolbarButtonsExclude||[],h=j=>(o.value,n.$toolbar.getToolbarItemByGroup(j).filter(O=>!d.includes(O.name.value))),m=()=>{i.value=n.$toolbar.getAvailableWidth()<=Ff.lg},v=TN(async()=>{await n.$toolbar.onToolbarResize(),m(),r.value+=1},300),_=()=>{r.value+=1},C=()=>{o.value+=1};function k(){window.removeEventListener("resize",v),n.$toolbar.off?.("toolbar-items-changed",_),n.$toolbar.off?.("toolbar-state-change",C),s?.disconnect(),s=null}function y(){k(),window.addEventListener("resize",v),n.$toolbar.on?.("toolbar-items-changed",_),n.$toolbar.on?.("toolbar-state-change",C),typeof ResizeObserver<"u"&&n.$toolbar.config?.responsiveToContainer&&n.$toolbar.toolbarContainer&&(s=new ResizeObserver(()=>{v()}),s.observe(n.$toolbar.toolbarContainer)),m()}Nn(y),Rg(y),Mg(k),or(k);const b=()=>{if(!n.$toolbar.activeEditor){a=null,n.$toolbar.pendingSelectionCapture=null;return}a=n.$toolbar.ui?.selection?.capture?.()??null,n.$toolbar.pendingSelectionCapture=a},T=({item:j,argument:O,option:V})=>{R(),n.$toolbar.emitCommand({item:j,argument:O,option:V})},R=()=>{const j=n.$toolbar.activeEditor;if(!j)return;const O=n.$toolbar.pendingSelectionCapture??a;if(O&&typeof n.$toolbar.ui?.selection?.restore=="function"){n.$toolbar.ui.selection.restore(O);return}j.commands?.restoreSelection?.()},P=j=>{b(),!j.target.closest('input, textarea, [contenteditable="true"]')&&j.preventDefault()};return(j,O)=>(ge(),Ae("div",{class:"superdoc-toolbar",key:et(r),role:"toolbar","aria-label":"Toolbar","data-sd-part":"toolbar","data-editor-ui-surface":"",onMousedown:P},[et(u)?(ge(),dn(cm,{key:0,tabindex:"0","toolbar-items":h("left"),"overflow-items":et(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":l.value,position:"left",onCommand:T,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"])):ht("",!0),jt(cm,{tabindex:"0","toolbar-items":h("center"),"overflow-items":et(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":l.value,position:"center",onCommand:T},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"]),et(c)?(ge(),dn(cm,{key:1,tabindex:"0","toolbar-items":h("right"),"overflow-items":et(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":l.value,position:"right",onCommand:T,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"])):ht("",!0)],32))}},GB=fn(UB,[["__scopeId","data-v-55b5af7a"]]);const WB=e=>{if(!e)return e;const t=e.props?.style?.fontFamily??e.label??e.key;return{...e,props:{...e.props,style:{...e.props?.style,fontFamily:t},"data-item":e.props?.["data-item"]??"btn-fontFamily-option"}}};xt();const kn=e=>{if(!["button","options","separator","dropdown","overflow"].includes(e.type))throw new Error("Invalid toolbar item type - "+e.type);if(e.type==="button"&&!e.defaultLabel&&!e.icon)throw new Error("Toolbar button item needs either icon or label - "+e.name);if(!e.name)throw new Error("Invalid toolbar item name - "+e.name);const t=ne(as()),n=e.type,r=ne(e.name),o=e.command,i=e.noArgumentCommand,s=ne(e.icon),a=ne(e.group||"center"),l=ne(e.allowWithoutEditor),u=ne(e.attributes||{}),c=e.disabled||!1,d=ne(e.disabled),h=ne(!1),m=ne(!1),p=ne(e.style),v=ne(e.isNarrow),_=ne(e.isWide),C=ne(e.minWidth),k=ne(e.suppressActiveHighlight||!1),y=ne(e.argument),b=ne(null),T=ne(null),R=ne(e.iconColor),P=ne(e.hasCaret),j=ne(!!e.splitButton),O=e.splitButtonCommand,V=!!e.restoreEditorFocus,Q=ne(e.dropdownStyles),F=ne(e.tooltip),N=ne(e.tooltipVisible),x=ne(e.tooltipTimeout),z=ne(e.defaultLabel),J=ne(e.label),X=ne(e.hideLabel),ae=ne(e.inlineTextInputVisible),pe=ne(e.hasInlineTextInput),Fe=ne(e.markName),fe=ne(e.labelAttr),ye=ne(e.selectedValue),le=ne(e.dropdownValueKey),Se=ne(e.inputRef||null),re=ne([]);if(e.options){if(!Array.isArray(e.options))throw new Error("Invalid toolbar item options - "+e.options);re.value?.push(...e.options)}const xe=(S={},...ee)=>{Ee(S,...ee),!k.value&&(h.value=!0)},$e=()=>{Ge(),h.value=!1},st=S=>{d.value=S},At=()=>{d.value=c},Ee=e.onActivate||(()=>null),Ge=e.onDeactivate||(()=>null),qe=()=>{const S={};return Object.keys(Z).forEach(ee=>{Z[ee].value!==void 0&&(S[ee]=Z[ee].value)}),S},Z={id:t,name:r,type:n,command:o,noArgumentCommand:i,icon:s,tooltip:F,group:a,attributes:u,disabled:d,active:h,expand:m,nestedOptions:re,style:p,isNarrow:v,isWide:_,minWidth:C,argument:y,parentItem:T,iconColor:R,hasCaret:P,splitButton:j,splitButtonCommand:O,dropdownStyles:Q,tooltipVisible:N,tooltipTimeout:x,defaultLabel:z,label:J,hideLabel:X,inlineTextInputVisible:ae,hasInlineTextInput:pe,restoreEditorFocus:V,markName:Fe,labelAttr:fe,childItem:b,allowWithoutEditor:l,dropdownValueKey:le,selectedValue:ye,inputRef:Se};return{...Z,unref:qe,activate:xe,deactivate:$e,setDisabled:st,resetDisabled:At,onActivate:Ee,onDeactivate:Ge}};xt(),gn();var KB=["onClick","innerHTML","aria-label","onKeydown"],qB={__name:"AlignmentButtons",emits:["select"],setup(e,{emit:t}){const{isHighContrastMode:n}=Hi(),r=t,o=ne([]),i=[{key:"left",ariaLabel:"Align left",icon:er.alignLeft},{key:"center",ariaLabel:"Align center",icon:er.alignCenter},{key:"right",ariaLabel:"Align right",icon:er.alignRight},{key:"justify",ariaLabel:"Justify",icon:er.alignJustify}],s=c=>{r("select",c)},a=c=>{if(c===o.value.length-1)return;const d=o.value[c+1];d&&(d.setAttribute("tabindex","0"),d.focus())},l=c=>{if(c===0)return;const d=o.value[c-1];d&&(d.setAttribute("tabindex","0"),d.focus())},u=(c,d)=>{switch(c.key){case"ArrowLeft":l(d);break;case"ArrowRight":a(d);break;case"Enter":s(i[d].key);break;default:break}};return Nn(()=>{const c=o.value[0];c&&(c.setAttribute("tabindex","0"),c.focus())}),(c,d)=>(ge(),Ae("div",{class:rn(["alignment-buttons",{"high-contrast":et(n)}])},[(ge(),Ae(Wt,null,rr(i,(h,m)=>Me("div",{key:h.key,class:"sd-button-icon",onClick:p=>s(h.key),innerHTML:h.icon,"data-item":"btn-textAlign-option",role:"menuitem","aria-label":h.ariaLabel,ref_for:!0,ref_key:"alignmentButtonsRefs",ref:o,onKeydown:tn(p=>u(p,m),["prevent"])},null,40,KB)),64))],2))}},YB=fn(qB,[["__scopeId","data-v-13e5f7a4"]]);xt(),gn();var XB=["onClick","innerHTML","aria-label","onKeydown"],ZB={__name:"StyleButtonsList",props:{buttons:{type:Array,required:!0},selectedStyle:{type:String,default:null},iconSize:{type:Number,default:25}},emits:["select"],setup(e,{emit:t}){const{isHighContrastMode:n}=Hi(),r=t,o=e,i=ne([]),s=ke(()=>({width:`${o.iconSize}px`,height:`${o.iconSize}px`})),a=d=>{r("select",d)},l=d=>{if(d===i.value.length-1)return;const h=i.value[d+1];h&&(h.setAttribute("tabindex","0"),h.focus())},u=d=>{if(d===0)return;const h=i.value[d-1];h&&(h.setAttribute("tabindex","0"),h.focus())},c=(d,h)=>{switch(d.key){case"ArrowLeft":u(h);break;case"ArrowRight":l(h);break;case"Enter":a(o.buttons[h].key);break;default:break}};return Nn(()=>{const d=i.value[0];d&&(d.setAttribute("tabindex","0"),d.focus())}),(d,h)=>(ge(),Ae("div",{class:rn(["style-buttons-list",{"high-contrast":et(n)}])},[(ge(!0),Ae(Wt,null,rr(o.buttons,(m,p)=>(ge(),Ae("div",{key:m.key,class:rn(["sd-button-icon",{"sd-selected":o.selectedStyle===m.key}]),style:yn(s.value),onClick:v=>a(m.key),innerHTML:m.icon,role:"menuitem","aria-label":m.ariaLabel,ref_for:!0,ref_key:"buttonRefs",ref:i,onKeydown:tn(v=>c(v,p),["prevent"])},null,46,XB))),128))],2))}},nA=fn(ZB,[["__scopeId","data-v-44f37ff6"]]);const QB=[{key:"disc",icon:er.bulletListDisc,ariaLabel:"Opaque circle"},{key:"circle",icon:er.bulletListCircle,ariaLabel:"Outline circle"},{key:"square",icon:er.bulletListSquare,ariaLabel:"Opaque square"}],JB=[{key:"decimal",icon:er.numberedListDecimal,ariaLabel:"1. 2. 3."},{key:"decimal-paren",icon:er.numberedListDecimalParen,ariaLabel:"1) 2) 3)"},{key:"upper-roman",icon:er.numberedListUpperRoman,ariaLabel:"I. II. III."},{key:"lower-roman",icon:er.numberedListLowerRoman,ariaLabel:"i. ii. iii."},{key:"upper-alpha",icon:er.numberedListUpperAlpha,ariaLabel:"A. B. C."},{key:"upper-alpha-paren",icon:er.numberedListUpperAlphaParen,ariaLabel:"A) B) C)"},{key:"lower-alpha",icon:er.numberedListLowerAlpha,ariaLabel:"a. b. c."},{key:"lower-alpha-paren",icon:er.numberedListLowerAlphaParen,ariaLabel:"a) b) c)"}];xt(),gn();var $B=["onClick","onKeydown"],ez={class:"document-mode-column icon-column"},tz=["innerHTML"],nz={class:"document-mode-column text-column"},rz={class:"document-mode-type"},oz={class:"document-mode-description"},iz={__name:"DocumentMode",props:{options:{type:Array}},emits:["select"],setup(e,{emit:t}){const n=t,r=ne([]),{isHighContrastMode:o}=Hi(),i=e,s=c=>{n("select",c)},a=c=>{if(c===r.value.length-1)return;const d=r.value[c+1];d&&(d.setAttribute("tabindex","0"),d.focus())},l=c=>{if(c===0)return;const d=r.value[c-1];d&&(d.setAttribute("tabindex","0"),d.focus())},u=(c,d)=>{switch(c.key){case"ArrowDown":a(d);break;case"ArrowUp":l(d);break;case"Enter":s(i.options[d]);break;default:break}};return Nn(()=>{r.value[0].setAttribute("tabindex","0"),r.value[0].focus()}),(c,d)=>(ge(),Ae("div",{class:rn(["document-mode",{"high-contrast":et(o)}])},[(ge(!0),Ae(Wt,null,rr(e.options,(h,m)=>(ge(),Ae("div",{class:rn(["sd-option-item",{"sd-disabled":h.disabled}]),onClick:p=>s(h),"data-item":"btn-documentMode-option",role:"menuitem",ref_for:!0,ref_key:"documentModeRefs",ref:r,onKeydown:tn(p=>u(p,m),["prevent"])},[Me("div",ez,[Me("div",{class:"icon-column__icon",innerHTML:h.icon},null,8,tz)]),Me("div",nz,[Me("div",rz,Bt(h.label),1),Me("div",oz,Bt(h.description),1)])],42,$B))),256))],2))}},sz=fn(iz,[["__scopeId","data-v-bee14d7a"]]);xt(),gn();var az={class:"linked-style-buttons","data-editor-ui-surface":""},lz=["onClick","onKeydown","aria-label"],cz={__name:"LinkedStyle",props:{styles:{type:Array,default:()=>[]},selectedOption:{type:String,default:null}},emits:["select"],setup(e,{emit:t}){const n=t,r=ne([]),o=e,i=d=>{n("select",d)},s=d=>{if(d===r.value.length-1)return;const h=r.value[d+1];h.setAttribute("tabindex","0"),h.focus()},a=d=>{if(d===0)return;const h=r.value[d-1];h.setAttribute("tabindex","0"),h.focus()},l=(d,h,m)=>{switch(d.key){case"ArrowDown":s(h);break;case"ArrowUp":a(h);break;case"Enter":d.preventDefault(),i(m);break;default:break}},u=d=>d?.name??d?.id??"",c=d=>{const h=d?.preview?.css;return h&&typeof h=="object"?h:void 0};return Nn(()=>{r.value[0]&&(r.value[0].setAttribute("tabindex","0"),r.value[0].focus())}),(d,h)=>(ge(),Ae("div",az,[(ge(!0),Ae(Wt,null,rr(o.styles,(m,p)=>(ge(),Ae("div",{key:m.id??p,class:rn(["style-item",{selected:e.selectedOption===m.id}]),onClick:v=>i(m),onKeydown:v=>l(v,p,m),"aria-label":`Linked style - ${m.id??u(m)}`,ref_for:!0,ref_key:"styleRefs",ref:r},[Me("div",{class:"style-name","data-item":"btn-linkedStyles-option",style:yn(c(m))},Bt(u(m)),5)],42,lz))),128))]))}},uz=fn(cz,[["__scopeId","data-v-43b5dcca"]]);xt(),gn();var dz=["placeholder"],fz={class:"sd-ai-writer__footer"},hz={key:0,class:"sd-ai-writer__error",role:"alert"},pz=["disabled"],mz="https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights",gz="You are an expert copywriter and you are immersed in a document editor. Only write what is asked for.",vz={__name:"AIWriter",props:{selectedText:{type:String,default:""},target:{type:Object,default:null},doc:{type:Object,default:null},apiKey:{type:String,default:""},endpoint:{type:String,default:""},restoreSelection:{type:Function,default:null},handleClose:{type:Function,required:!0}},setup(e){const t=e,n=ne(""),r=ne(!1),o=ne(""),i=ne(null),s=ke(()=>t.selectedText?"Insert prompt to update text":"Insert prompt to generate text"),a=ke(()=>n.value.trim().length>0&&!r.value);Nn(()=>{_t(()=>{i.value?.focus()})});function l(p){if(typeof p=="string")return p;if(!p||typeof p!="object")return"";const v=p.custom_prompt;if(Array.isArray(v)){const _=v[0];if(_&&typeof _.value=="string")return _.value}return v&&typeof v=="object"&&typeof v.value=="string"?v.value:typeof p.value=="string"?p.value:typeof p.text=="string"?p.text:""}async function u(p){const v={"Content-Type":"application/json"};t.apiKey&&(v["x-api-key"]=t.apiKey);const _=t.selectedText.trim(),C=_?`Rewrite the following text: "${_}" using these instructions: ${p}`:`Generate text based on the following prompt: ${p}`,k=await fetch(t.endpoint||mz,{method:"POST",headers:v,body:JSON.stringify({stream:!1,context:gz,insights:[{type:"custom_prompt",name:_?"text_rewrite":"text_generation",message:C,format:[{value:""}]}]})});if(!k.ok){const b=await k.text().catch(()=>"");throw new Error(b||`AI request failed with ${k.status}`)}const y=l((k.headers.get("content-type")||"").includes("application/json")?await k.json():await k.text()).trim();if(!y)throw new Error("AI returned no text.");return y}function c(p){return!p||typeof p!="object"?!0:!(p.success===!1||p.ok===!1)}function d(p){const v=t.doc;if(!v)throw new Error("Document API is unavailable.");t.restoreSelection?.();let _=null,C=!1;if(t.selectedText&&t.target&&typeof v.replace=="function"?(_=v.replace({target:t.target,text:p}),C=!0):t.target&&typeof v.insert=="function"?(_=v.insert({target:t.target,value:p,type:"text"}),C=!0):typeof v.insert=="function"&&(_=v.insert({value:p,type:"text"}),C=!0),!C)throw new Error("Document text insertion is unavailable.");if(!c(_))throw new Error("Unable to insert generated text.")}async function h(){if(a.value){o.value="",r.value=!0;try{d(await u(n.value.trim())),t.handleClose()}catch(p){o.value=p instanceof Error?p.message:String(p)}finally{r.value=!1}}}function m(p){p.key!=="Enter"||p.shiftKey||(p.preventDefault(),h())}return(p,v)=>(ge(),Ae("form",{class:"sd-ai-writer","data-item":"ai-writer",onSubmit:tn(h,["prevent"])},[Us(Me("textarea",{ref_key:"textareaRef",ref:i,"onUpdate:modelValue":v[0]||(v[0]=_=>n.value=_),class:"sd-ai-writer__input",placeholder:s.value,rows:"4",onKeydown:m},null,40,dz),[[Ai,n.value]]),Me("div",fz,[o.value?(ge(),Ae("p",hz,Bt(o.value),1)):ht("",!0),Me("button",{class:"sd-ai-writer__submit",type:"submit",disabled:!a.value},Bt(r.value?"Generating":"Generate"),9,pz)])],32))}},yz=fn(vz,[["__scopeId","data-v-67f6c6f7"]]);xt(),gn();var bz=["aria-label","onClick","onKeydown"],wz=["innerHTML"],Cz=["innerHTML"],um=7,_z={__name:"IconGridRow",props:{icons:{type:Array,required:!0},activeColor:{type:Object,required:!1}},emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=e,o=ke(()=>p=>r.activeColor.value?r.activeColor.value.toUpperCase()===p.value:!1),i=(p,v)=>v===5||["#FFFFFF","#FAFF09"].includes(p)?{color:"#000"}:{color:"#FFF"},s=p=>{n("select",p.value)},a=ne([]),l=ne([]);Nn(()=>{if(!r.icons.every(v=>Array.isArray(v)))throw new Error("icon props must be 2d array");const p=l.value[0];p&&(p.setAttribute("tabindex","0"),p.focus({preventScroll:!0}))});const u=(p,v)=>{const _=um*p+v+1,C=l.value[_];C&&(C.setAttribute("tabindex","0"),C.focus({preventScroll:!0}))},c=(p,v)=>{const _=um*p+v-1,C=l.value[_];C&&(C.setAttribute("tabindex","0"),C.focus({preventScroll:!0}))},d=(p,v)=>{const _=v+um*(p+1),C=l.value[_];C&&(C.setAttribute("tabindex","0"),C.focus({preventScroll:!0}))},h=(p,v)=>{const _=v+um*(p-1),C=l.value[_];C&&(C.setAttribute("tabindex","0"),C.focus({preventScroll:!0}))},m=(p,v,_,C)=>{switch(p.key){case"ArrowRight":u(v,_);break;case"ArrowLeft":c(v,_);break;case"ArrowDown":d(v,_);break;case"ArrowUp":h(v,_);break;case"Enter":s(C);break;case"Escape":n("clickoutside");break;default:break}};return(p,v)=>(ge(!0),Ae(Wt,null,rr(e.icons,(_,C)=>(ge(),Ae("div",{class:"sd-option-row",key:C,role:"group",ref_for:!0,ref_key:"rowRefs",ref:a},[(ge(!0),Ae(Wt,null,rr(_,(k,y)=>(ge(),Ae("div",{class:"sd-option",key:y,"aria-label":k.label,role:"menuitem",ref_for:!0,ref_key:"iconRefs",ref:l,onClick:tn(b=>s(k),["stop","prevent"]),onKeydown:tn(b=>m(b,C,y,k),["prevent"])},[Me("div",{class:"sd-option__icon",innerHTML:k.icon,style:yn(k.style)},null,12,wz),o.value(k)?(ge(),Ae("div",{key:0,class:"sd-option__check",innerHTML:et(er).colorOptionCheck,style:yn(i(k.value,y))},null,12,Cz)):ht("",!0)],40,bz))),128))]))),128))}},rA=fn(_z,[["__scopeId","data-v-05eb02fc"]]),Sz=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M320 512c53.2 0 101.4-21.6 136.1-56.6l-298.3-235C140 257.1 128 292.3 128 320c0 106 86 192 192 192zM505.2 370.7c4.4-16.2 6.8-33.1 6.8-50.7c0-91.2-130.2-262.3-166.6-308.3C339.4 4.2 330.5 0 320.9 0l-1.8 0c-9.6 0-18.5 4.2-24.5 11.7C277.8 33 240.7 81.3 205.8 136L38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L505.2 370.7zM224 336c0 44.2 35.8 80 80 80c8.8 0 16 7.2 16 16s-7.2 16-16 16c-61.9 0-112-50.1-112-112c0-8.8 7.2-16 16-16s16 7.2 16 16z"/></svg>
|
|
101
101
|
`;xt(),gn();var kz={class:"options-grid-wrap"},Az=["innerHTML"],Iz={class:"option-grid-ctn"},Ez={__name:"IconGrid",props:{icons:{type:Array,required:!0},customIcons:{type:Array,required:!1},activeColor:{type:Object,required:!1},hasNoneIcon:{type:Boolean,required:!1}},emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=o=>{n("select",o)};return(o,i)=>(ge(),Ae("div",kz,[e.hasNoneIcon?(ge(),Ae("div",{key:0,class:"none-option",role:"menuitem","aria-label":"Clear color selection",onClick:i[0]||(i[0]=s=>r("none"))},[Me("span",{innerHTML:et(Sz),class:"none-icon"},null,8,Az),i[1]||(i[1]=Ni(" None ",-1))])):ht("",!0),Me("div",Iz,[jt(rA,{icons:e.icons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"]),e.customIcons.flat().length?(ge(),Ae(Wt,{key:0},[i[2]||(i[2]=Me("span",{class:"option-grid-ctn__subtitle"},"Custom colors",-1)),jt(rA,{icons:e.customIcons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"])],64)):ht("",!0)])]))}},xz=fn(Ez,[["__scopeId","data-v-52b0283a"]]);const eb=(e,t=null)=>{if(typeof t?.focus=="function"){t.focus();return}const n=e?.superdoc?.focus??e?.activeEditor?.focus;if(typeof n=="function"){n.call(e?.superdoc??e?.activeEditor,{preventScroll:!0});return}const r=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');r instanceof HTMLElement&&r.focus({preventScroll:!0})};xt();var Tz=e=>{e.expand.value=!1};const Vt=(e,t=null)=>({label:t,icon:er.colorOption,value:e,style:{color:e,boxShadow:"0 0 5px 1px rgba(0, 0, 0, 0.1)",borderRadius:"50%"}}),tb=(e,t,n=[],r=!1)=>{const o=i=>{t.iconColor.value=i,e.emitCommand({item:t,argument:i}),Tz(t),eb(e)};return Vr("div",{},[Vr(xz,{icons:Rz,customIcons:n,activeColor:t.iconColor,hasNoneIcon:r,onSelect:o})])},Rz=[[Vt("#111111","black"),Vt("#333333","dark gray"),Vt("#5C5C5C","medium gray"),Vt("#858585","light gray"),Vt("#ADADAD","very light gray"),Vt("#D6D6D6","transparent gray"),Vt("#FFFFFF","white")],[Vt("#860028","dark red"),Vt("#D2003F","red"),Vt("#DB3365","coral red"),Vt("#E4668C","light red"),Vt("#ED99B2","pale pink"),Vt("#F6CCD9","transparent pink"),Vt("#FF004D","bright pink")],[Vt("#83015E","dark purple"),Vt("#CD0194","purple"),Vt("#D734A9","orchid"),Vt("#E167BF","light purple"),Vt("#EB99D4","lavender"),Vt("#F5CCEA","transparent pink"),Vt("#FF00A8","neon pink")],[Vt("#8E220A","maroon"),Vt("#DD340F","red-orange"),Vt("#E45C3F","burnt orange"),Vt("#EB856F","peach"),Vt("#F1AE9F","pale peach"),Vt("#F8D6CF","transparent peach"),Vt("#FF7A00","orange")],[Vt("#947D02","olive"),Vt("#E7C302","mustard yellow"),Vt("#ECCF35","yellow"),Vt("#F1DB67","light yellow"),Vt("#F5E79A","very pale yellow"),Vt("#FAF3CC","transparent yellow"),Vt("#FAFF09","neon yellow")],[Vt("#055432","forest green"),Vt("#07834F","green"),Vt("#399C72","medium green"),Vt("#6AB595","light green"),Vt("#9CCDB9","mint"),Vt("#CDE6DC","transparent mint"),Vt("#05F38F","bright teal")],[Vt("#063E7E","navy blue"),Vt("#0A60C5","blue"),Vt("#3B80D1","sky blue"),Vt("#6CA0DC","cornflower blue"),Vt("#9DBFE8","light blue"),Vt("#CEDFF3","very light blue"),Vt("#21c8ce","cyan")],[Vt("#3E027A","deep purple"),Vt("#6103BF","indigo"),Vt("#8136CC","violet"),Vt("#A068D9","lavender pink"),Vt("#C09AE6","light lilac"),Vt("#DFCDF2","transparent lilac"),Vt("#A91DFF","neon purple")]];xt(),gn();var Mz=["data-cols","data-rows","onKeydown","onClick"],Lz=["aria-valuetext"],dm=5,Pz={__name:"TableGrid",emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=ne(0),o=ne(0),{isHighContrastMode:i}=Hi(),s=ne([]),a=d=>{let h=d.target;h.dataset.grid||l([...h.parentElement.querySelectorAll("[data-item]")],parseInt(h.dataset.cols,10),parseInt(h.dataset.rows,10))},l=(d,h,m)=>{o.value=h,r.value=m;for(let p=0;p<d.length;p++){let v=d[p],_=parseInt(v.dataset.cols,10),C=parseInt(v.dataset.rows,10);_<=h&&C<=m?v.classList.add("sd-selected"):v.classList.remove("sd-selected")}},u=({cols:d,rows:h})=>{n("select",{cols:d,rows:h})},c=(d,h,m)=>{let p=h-1,v=m-1;switch(d.key){case"ArrowRight":{if(p>=4)return;const _=v*dm;s.value[_+p+1].setAttribute("tabindex","0"),s.value[_+p+1].focus(),l(s.value,h+1,m);break}case"ArrowLeft":{if(p<=0)return;const _=v*dm;s.value[_+p-1].setAttribute("tabindex","0"),s.value[_+p-1].focus(),l(s.value,h-1,m);break}case"ArrowDown":{if(v>=4)return;const _=(v+1)*dm;s.value[_+p].setAttribute("tabindex","0"),s.value[_+p].focus(),l(s.value,h,m+1);break}case"ArrowUp":{if(v<=0)return;const _=(v-1)*dm;s.value[_+p].setAttribute("tabindex","0"),s.value[_+p].focus(),l(s.value,h,m-1);break}case"Enter":u({cols:h,rows:m});break;default:break}};return Nn(()=>{s.value[0].setAttribute("tabindex","0"),s.value[0].focus(),l(s.value,1,1)}),(d,h)=>(ge(),Ae("div",{class:rn(["toolbar-table-grid-wrapper",{"high-contrast":et(i)}])},[Me("div",{class:"toolbar-table-grid",onMouseover:a,"data-grid":"true"},[(ge(),Ae(Wt,null,rr(5,m=>(ge(),Ae(Wt,{key:m},[(ge(),Ae(Wt,null,rr(5,p=>Me("div",{class:"toolbar-table-grid__item",key:`${m}_${p}`,"data-cols":p,"data-rows":m,"data-item":"true",ref_for:!0,ref_key:"tableGridItems",ref:s,onKeydown:tn(v=>c(v,p,m),["prevent"]),onClick:tn(v=>u({cols:p,rows:m}),["stop","prevent"])},null,40,Mz)),64))],64))),64))],32),Me("div",{class:"toolbar-table-grid-value","aria-valuetext":`${r.value} x ${o.value}`},Bt(r.value)+" x "+Bt(o.value),9,Lz)],2))}},Dz=fn(Pz,[["__scopeId","data-v-b87d6ca2"]]);xt(),gn();var Oz={class:"toolbar-table-actions"},Fz=["onClick","data-item","ariaLabel"],Nz={class:"toolbar-table-actions__icon"},Bz=["innerHTML"],zz={class:"toolbar-table-actions__label"},Vz={__name:"TableActions",props:{options:{type:Array}},emits:["select"],setup(e,{emit:t}){const n=t,r=o=>{n("select",{command:o.command})};return(o,i)=>(ge(),Ae("div",Oz,[(ge(!0),Ae(Wt,null,rr(e.options,s=>(ge(),Ae("div",{class:rn(["toolbar-table-actions__item",{"toolbar-table-actions__item--border":s.bottomBorder}]),onClick:a=>r(s),"data-item":s.props?.["data-item"]||"",ariaLabel:s.props?.ariaLabel,role:"menuitem"},[Me("div",Nz,[Me("div",{class:"toolbar-table-actions__icon-wrapper",innerHTML:s.icon},null,8,Bz)]),Me("div",zz,Bt(s.label),1)],10,Fz))),256))]))}},Hz=fn(Vz,[["__scopeId","data-v-0cdad084"]]),jz=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>
|
|
102
|
-
`;xt();var Ss=e=>{e.expand.value=!1};function nb(e,t){const n={...e??{}};return t?n.href=t:delete n.href,n}function oA(e){const t=Array.isArray(e?.segments)?e.segments:[];if(e?.kind!=="text"||!t.length)return null;const n=t[0],r=t[t.length-1];if(!n?.blockId||!r?.blockId||!n.range||!r.range)return null;const o=e.story;return{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start??0,...o?{story:o}:{}},end:{kind:"text",blockId:r.blockId,offset:r.range.end??0,...o?{story:o}:{}},...o?{story:o}:{}}}function Uz(e){return typeof e?.quotedText=="string"?e.quotedText:typeof e?.text=="string"?e.text:""}function iA(e){return e.ui?.selection?.get?.()??e.ui?.selection?.current?.()??null}function Gz(e){return!!(e.config?.superdoc?.config?.modules?.ai||e.superdoc?.config?.modules?.ai)}function Wz(e){return e.config?.superdoc?.config?.modules?.ai??e.superdoc?.config?.modules?.ai??{}}const Kz=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:o,availableWidth:i,role:s,isDev:a=!1}={})=>{const l=kn({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),u=(r??BB).map(WB),c=kn({type:"dropdown",name:"fontFamily",tooltip:n.fontFamily,command:"setFontFamily",defaultLabel:"Arial",label:"Arial",markName:"textStyle",labelAttr:"fontFamily",hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,isWide:!0,style:{width:"116px"},suppressActiveHighlight:!0,attributes:{ariaLabel:"Font family"},options:u,onActivate:({fontFamily:Ye}={},Et=!1)=>{if(Et){c.label.value="",c.selectedValue.value="";return}if(!Ye)return;Ye=Ye.split(",")[0],c.label.value=Ye;const Ot=u.find(Kt=>Kt.label===c.defaultLabel.value),wn=u.find(Kt=>Kt.label===Ye);wn?c.selectedValue.value=wn.key:Ot?c.selectedValue.value=Ot.key:c.selectedValue.value=""},onDeactivate:()=>{c.label.value=c.defaultLabel.value;const Ye=u.find(Et=>Et.label===c.defaultLabel.value);Ye?c.selectedValue.value=Ye.key:c.selectedValue.value=""}}),d=kn({type:"dropdown",name:"ai",dropdownStyles:{padding:0,outline:"none"},tooltip:n.ai,icon:t.ai,hideLabel:!0,hasCaret:!1,isWide:!0,suppressActiveHighlight:!0,attributes:{ariaLabel:"AI"},options:[{type:"render",key:"ai",render:()=>h(d)}]});function h(Ye){const Et=iA(e),Ot=Et?.selectionTarget??oA(Et?.target),wn=Et?.empty?"":Uz(Et),Kt=Wz(e),Sn=()=>Ss(Ye),Pt=()=>{const De=e.pendingSelectionCapture;De&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(De)};return Vr("div",{},[Vr(yz,{handleClose:Sn,selectedText:wn,target:Ot,doc:e.superdoc?.activeEditor?.doc??null,apiKey:Kt?.apiKey||e.config?.aiApiKey||"",endpoint:Kt?.endpoint||e.config?.aiEndpoint||"",restoreSelection:Pt})])}const m=VB,p=kn({type:"dropdown",name:"fontSize",defaultLabel:"12",label:"12",style:{width:"56px"},markName:"textStyle",labelAttr:"fontSize",tooltip:n.fontSize,hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,suppressActiveHighlight:!0,isWide:!0,command:"setFontSize",attributes:{ariaLabel:"Font size"},options:m,onActivate:({fontSize:Ye},Et=!1)=>{if(Et){p.label.value="",p.selectedValue.value="";return}const Ot=m.find(Pt=>Pt.label===String(p.defaultLabel.value));if(!Ye){p.label.value=p.defaultLabel.value,Ot?p.selectedValue.value=Ot.key:p.selectedValue.value="";return}let wn=xN(Ye,12);wn<8&&(wn=8),wn>96&&(wn=96);let Kt=String(wn);const Sn=m.find(Pt=>Pt.label===Kt||Pt.key===Kt);Sn?p.selectedValue.value=Sn.key:p.selectedValue.value="",p.label.value=Kt},onDeactivate:()=>{p.label.value=p.defaultLabel.value;const Ye=m.find(Et=>Et.label===String(p.defaultLabel.value));Ye?p.selectedValue.value=Ye.key:p.selectedValue.value=""}}),v=kn({type:"separator",name:"separator",isNarrow:!0}),_=kn({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),C=kn({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),k=kn({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),y=kn({type:"dropdown",name:"highlight",icon:t.highlight,hideLabel:!0,markName:"highlight",labelAttr:"color",active:!1,tooltip:n.highlight,command:"setHighlight",noArgumentCommand:"unsetHighlight",suppressActiveHighlight:!0,attributes:{ariaLabel:"Highlight"},options:[{key:"color",type:"render",render:()=>tb(e,y,[],!0)}],onActivate:({color:Ye})=>{y.iconColor.value=Ye||""},onDeactivate:()=>y.iconColor.value=""}),b=kn({type:"dropdown",name:"color",icon:t.color,hideLabel:!0,markName:"textStyle",labelAttr:"color",active:!1,tooltip:n.color,command:"setColor",suppressActiveHighlight:!0,attributes:{ariaLabel:"Color"},options:[{key:"color",type:"render",render:()=>tb(e,b)}],onActivate:({color:Ye})=>{b.iconColor.value=Ye},onDeactivate:()=>b.iconColor.value="#000"}),T=kn({type:"button",name:"search",allowWithoutEditor:!0,active:!1,icon:t.search,tooltip:n.search,group:"right",attributes:{ariaLabel:"Search"}}),R=kn({type:"dropdown",name:"link",markName:"link",icon:t.link,active:!1,tooltip:n.link,attributes:{ariaLabel:"Link dropdown"},options:[{type:"render",key:"linkDropdown",render:()=>P(R)}],onActivate:({href:Ye})=>{R.attributes.value=nb(R.attributes.value,Ye)},onDeactivate:()=>{R.attributes.value=nb(R.attributes.value,null),R.expand.value=!1}});function P(Ye){const Et=iA(e),Ot=Et?.selectionTarget??oA(Et?.target),wn=()=>{const Kt=e.pendingSelectionCapture;Kt&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Kt)};return Vr("div",{},[Vr(TS,{ui:e.ui,linkItem:Ye,textTarget:Ot,restoreSelection:wn,closePopover:()=>Ss(Ye),goToAnchor:()=>{Ss(Ye);const Kt=Ye.attributes.value?.href;if(!Kt)return;const Sn=Kt.slice(1),Pt=(e.ui?.viewport?.getHost?.()??null)?.querySelector?.(`a[name='${Sn}']`);Pt&&mf(Pt)}})])}const j=kn({type:"options",name:"linkInput",command:"toggleLink",active:!1});R.childItem=j,j.parentItem=R;const O=kn({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),V=kn({type:"button",name:"tableOfContents",command:"insertTableOfContents",icon:t.tableOfContents,active:!1,tooltip:n.tableOfContents,disabled:!1,attributes:{ariaLabel:"Table of contents"}}),Q=kn({type:"dropdown",name:"table",icon:t.table,hideLabel:!0,labelAttr:"table",active:!1,tooltip:n.table,command:"insertTable",suppressActiveHighlight:!0,attributes:{ariaLabel:"Table"},options:[{key:"table",type:"render",render:()=>F(Q)}]});function F(Ye){return Vr("div",{},[Vr(Dz,{onSelect:Ot=>{e.emitCommand({item:Ye,argument:Ot}),Ss(Ye),eb(e)}})])}const N=kn({type:"dropdown",name:"tableActions",command:"executeTableCommand",tooltip:n.tableActions,icon:t.tableActions,hideLabel:!0,disabled:!0,attributes:{ariaLabel:"Table actions"},options:[{type:"render",render:()=>z(N)}]}),x=[{label:n.addRowBefore,command:"addRowBefore",icon:t.addRowBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row before"}},{label:n.addRowAfter,command:"addRowAfter",icon:t.addRowAfter,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row after"}},{label:n.addColumnBefore,command:"addColumnBefore",icon:t.addColumnBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column before"}},{label:n.addColumnAfter,command:"addColumnAfter",icon:t.addColumnAfter,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column after"}},{label:n.deleteRow,command:"deleteRow",icon:t.deleteRow,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete row"}},{label:n.deleteColumn,command:"deleteColumn",icon:t.deleteColumn,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete column"}},{label:n.deleteTable,command:"deleteTable",icon:t.deleteTable,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete table"}},{label:n.removeBorders,command:"deleteCellAndTableBorders",icon:t.deleteBorders,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete cell and table borders"}},{label:n.mergeCells,command:"mergeCells",icon:t.mergeCells,props:{"data-item":"btn-tableActions-option",ariaLabel:"Merge cells"}},{label:n.splitCell,command:"splitCell",icon:t.splitCell,props:{"data-item":"btn-tableActions-option",ariaLabel:"Split cells"}},{label:n.fixTables,command:"fixTables",icon:t.fixTables,props:{"data-item":"btn-tableActions-option",ariaLabel:"Fix tables"}}];function z(Ye){return Vr(Hz,{options:x,onSelect:Et=>{Ss(Ye);const{command:Ot}=Et;e.emitCommand({item:Ye,argument:{command:Ot}})}})}const J=kn({type:"dropdown",name:"textAlign",tooltip:n.textAlign,icon:t.alignLeft,command:"setTextAlign",hasCaret:!0,markName:"textAlign",labelAttr:"textAlign",suppressActiveHighlight:!0,attributes:{ariaLabel:"Text align"},options:[{type:"render",render:()=>Vr("div",{},[Vr(YB,{onSelect:Et=>{Ss(J);const Ot={...J,command:"setTextAlign"};Ot.command="setTextAlign",e.emitCommand({item:Ot,argument:Et}),X(J,Et)}})]),key:"alignment"}],onActivate:({textAlign:Ye})=>{X(J,Ye)},onDeactivate:()=>{X(J,"left")}}),X=(Ye,Et)=>{let Ot=Et==="both"?"justify":Et,wn={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},Kt=wn[Ot]??wn.left;Ye.icon.value=Kt},ae=kn({type:"dropdown",name:"list",command:"toggleBulletListStyle",splitButton:!0,splitButtonCommand:"toggleBulletList",icon:t.bulletList,hasCaret:!0,tooltip:n.bulletList,restoreEditorFocus:!0,attributes:{ariaLabel:"Bullet list"},options:[{type:"render",key:"bullet-style-buttons",render:()=>{const Ye=Et=>{Ss(ae);const Ot={...ae,command:"toggleBulletListStyle"};e.emitCommand({item:Ot,argument:Et})};return Vr(nA,{buttons:QB,iconSize:25,selectedStyle:ae.selectedValue.value,onSelect:Ye})}}]}),pe=kn({type:"dropdown",name:"numberedlist",command:"toggleOrderedListStyle",splitButton:!0,splitButtonCommand:"toggleOrderedList",icon:t.numberedList,hasCaret:!0,tooltip:n.numberedList,restoreEditorFocus:!0,attributes:{ariaLabel:"Numbered list"},options:[{type:"render",key:"numbered-style-buttons",render:()=>{const Ye=Et=>{Ss(pe);const Ot={...pe,command:"toggleOrderedListStyle"};e.emitCommand({item:Ot,argument:Et})};return Vr(nA,{buttons:JB,iconSize:30,selectedStyle:pe.selectedValue.value,onSelect:Ye})}}]}),Fe=kn({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),fe=kn({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),ye=kn({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),le=kn({type:"dropdown",name:"zoom",allowWithoutEditor:!0,tooltip:n.zoom,defaultLabel:"100%",label:"100%",hasCaret:!0,command:"setZoom",isWide:!0,style:{width:"71px",minWidth:"71px"},inlineTextInputVisible:!1,hasInlineTextInput:!0,attributes:{ariaLabel:"Zoom"},options:[{label:"50%",key:.5,props:{"data-item":"btn-zoom-option"}},{label:"75%",key:.75,props:{"data-item":"btn-zoom-option"}},{label:"90%",key:.9,props:{"data-item":"btn-zoom-option"}},{label:"100%",key:1,props:{"data-item":"btn-zoom-option"}},{label:"125%",key:1.25,props:{"data-item":"btn-zoom-option"}},{label:"150%",key:1.5,props:{"data-item":"btn-zoom-option"}},{label:"200%",key:2,props:{"data-item":"btn-zoom-option"}}],onActivate:({zoom:Ye})=>{Ye&&(le.label.value=Ye)}}),Se=kn({type:"dropdown",name:"measurementUnit",allowWithoutEditor:!0,tooltip:n.measurementUnit,defaultLabel:"in",label:"in",hasCaret:!0,command:"setMeasurementUnit",group:"right",style:{width:"52px",minWidth:"52px"},inlineTextInputVisible:!1,hasInlineTextInput:!1,attributes:{ariaLabel:"Measurement unit"},options:[{label:"Inches",key:"in",props:{"data-item":"btn-measurement-unit-option"}},{label:"Centimeters",key:"cm",props:{"data-item":"btn-measurement-unit-option"}}],onActivate:({measurementUnit:Ye})=>{Ye&&(Se.label.value=Ye)}}),re=kn({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),xe=kn({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),$e=kn({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),st=kn({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),At=kn({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),Ee=kn({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),Ge=(Ye,Et)=>Ye==="editor"?Et:Ye==="suggester"?Et.filter(Ot=>Ot.value==="suggesting"):Et.filter(Ot=>Ot.value==="viewing"),qe=Ye=>Ye==="editor"?"Editing":Ye==="suggester"?"Suggesting":"Viewing",Z=kn({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:qe(s),label:qe(s),hasCaret:s==="editor",isWide:!0,style:{display:"flex",justifyContent:"flex-end"},inlineTextInputVisible:!1,hasInlineTextInput:!1,group:"right",disabled:s!=="editor",attributes:{dropdownPosition:"right",className:"sd-toolbar-item--doc-mode",ariaLabel:"Document mode"},options:[{type:"render",render:()=>ee(Z)}]}),S=[{label:n.documentEditingMode,value:"editing",icon:t.documentEditingMode,description:n.documentEditingModeDescription},{label:n.documentSuggestingMode,value:"suggesting",icon:t.documentSuggestingMode,description:n.documentSuggestingModeDescription},{label:n.documentViewingMode,value:"viewing",icon:t.documentViewingMode,description:n.documentViewingModeDescription}];function ee(Ye){return Vr(sz,{options:Ge(s,S),onSelect:Et=>{const Ot=e.superdoc?.activeEditor??e.activeEditor;Ss(Ye);const{label:wn,icon:Kt,value:Sn}=Et;Z.label.value=wn,Z.icon.value=Kt,e.emitCommand({item:Z,argument:Sn}),eb(e,Ot)}})}const D=new Map([["separator",20],["zoom",71],["measurementUnit",52],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["default",32]]),U=["search","ruler","undo","overflow","documentMode"],H=kn({type:"button",name:"ruler",command:"toggleRuler",allowWithoutEditor:!0,icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),G=kn({type:"button",name:"formattingMarks",command:"toggleFormattingMarks",allowWithoutEditor:!0,icon:t.formattingMarks,active:!1,tooltip:n.formattingMarks,attributes:{ariaLabel:"Formatting marks"}}),te=kn({type:"dropdown",name:"linkedStyles",command:"setLinkedStyle",tooltip:n.linkedStyles,icon:t.paintbrush,defaultLabel:n.formatText,label:n.formatText,hasCaret:!0,isWide:!0,style:{width:"140px"},suppressActiveHighlight:!0,disabled:!1,attributes:{className:"sd-toolbar-item--linked-styles",ariaLabel:"Linked styles"},options:[{type:"render",key:"linkedStyle",render:()=>{const Ye=Ot=>{Ss(te);const wn=typeof Ot=="string"?Ot:Ot?.id??null;if(!wn)return;const Kt={...te,command:"setLinkedStyle"};e.emitCommand({item:Kt,argument:wn})},Et=e.getActiveLinkedStyleId?.()??null;return Vr("div",{},[Vr(uz,{styles:e.getLinkedStyleOptions?.()??[],onSelect:Ye,selectedOption:Et})])}}],onActivate:({styleId:Ye,styleName:Et})=>{const Ot=Et||Ye;te.label.value=Ye&&Ye!=="Normal"?String(Ot):n.formatText,te.disabled.value=!1},onDeactivate:()=>{te.disabled.value=!0,te.label.value=n.formatText}}),Y=(Ye,Et)=>{if(Et.value==Ye)return Vr("div",{innerHTML:jz,class:"dropdown-select-icon"})},K=kn({type:"dropdown",name:"lineHeight",tooltip:n.lineHeight,icon:t.lineHeight,hasCaret:!1,hasInlineTextInput:!1,hideLabel:!0,inlineTextInputVisible:!1,suppressActiveHighlight:!0,isWide:!1,command:"setLineHeight",dropdownValueKey:"key",selectedValue:"1",attributes:{ariaLabel:"Line height"},options:[1,1.15,1.5,2,2.5,3].map(Ye=>({label:Ye.toFixed(2),key:Ye,icon:()=>Y(Ye,K.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),be=20,me=32,Ce=U.reduce((Ye,Et)=>Ye+(D.get(Et)||D.get("default")),0),Pe=["linkedStyles","clearFormatting","copyFormat","formattingMarks"],it=["zoom","fontFamily","fontSize","redo"],He=i<=Ff.lg,Ct=e.config?.showFormattingMarksButton===!0,Yt=e.config?.showTableOfContentsButton===!0;He&&(Z.attributes.value={...Z.attributes.value,className:`${Z.attributes.value.className} sd-toolbar-item--doc-mode-compact`}),He&&(te.attributes.value={...te.attributes.value,className:`${te.attributes.value.className} sd-toolbar-item--linked-styles-compact`});let St=[re,xe,$e,st,T,le,c,v,p,v,l,_,C,k,b,y,v,R,O,...Yt?[V]:[],Q,N,v,J,ae,pe,Fe,fe,K,v,te,v,H,Se,...Ct?[G]:[],Ee,At,...Gz(e)?[d]:[],ye,Z];if(i<=Ff.md&&o&&(St=St.filter(Ye=>Ye.type!=="separator")),e.config.mode!=="docx"){const Ye=St.findIndex(Ot=>Ot.name.value==="linkedStyles");St.splice(Ye-1,2);const Et=["ruler","zoom","undo","redo"];St=St.filter(Ot=>!Et.includes(Ot.name.value))}const Ft=[];a||(s==="viewer"&&Ft.push($e,st),St=St.filter(Ye=>!Ft.includes(Ye)));const Nt=Ye=>U.includes(Ye.name.value),sn=[],_n=[];let Qt=me+Ce;return St.forEach(Ye=>{const Et=D.get(Ye.name.value)||D.get("default");if(i<Ff.xl+be&&Pe.includes(Ye.name.value)&&o){if(sn.push(Ye),Ye.name.value==="linkedStyles"){const Ot=St.findIndex(wn=>wn.name.value==="linkedStyles");St.splice(Ot+1,1)}return}if(i<Ff.sm&&it.includes(Ye.name.value)&&o){sn.push(Ye);return}if(Nt(Ye)){_n.push(Ye),Qt+=Et;return}Qt<i||!o?(_n.push(Ye),Qt+=Et):sn.push(Ye)}),{defaultItems:_n,overflowItems:sn.filter(Ye=>Ye.type!=="separator")}},sA={bold:"Bold",fontFamily:"Font family",ai:"AI text generation",fontSize:"Font size",italic:"Italic",underline:"Underline",highlight:"Highlight color",strikethrough:"Strikethrough",color:"Text color",search:"Search",link:"Link",image:"Image",tableOfContents:"Table of contents",table:"Insert table",tableActions:"Table options",addRowBefore:"Insert row above",addRowAfter:"Insert row below",addColumnBefore:"Insert column left",addColumnAfter:"Insert column right",deleteRow:"Delete row",deleteColumn:"Delete column",deleteTable:"Delete table",removeBorders:"Remove borders",mergeCells:"Merge cells",splitCell:"Split cell",fixTables:"Fix tables",textAlign:"Alignment",bulletList:"Bullet list",numberedList:"Numbered list",indentLeft:"Left indent",indentRight:"Right indent",directionLtr:"Left-to-right",directionRtl:"Right-to-left",zoom:"Zoom",measurementUnit:"Measurement unit",undo:"Undo",redo:"Redo",trackChanges:"Track Changes",trackChangesAccept:"Accept changes under selection",trackChangesReject:"Reject changes under selection",trackChangesOriginal:"Toggle Show Original",trackChangesFinal:"Toggle Show Final",clearFormatting:"Clear formatting",copyFormat:"Format painter",lineHeight:"Line height",formatText:"Format text",ruler:"Show or hide ruler",formattingMarks:"Show or hide formatting marks",pageBreak:"Insert page break",documentEditingMode:"Editing",documentSuggestingMode:"Suggesting",documentViewingMode:"Viewing",documentEditingModeDescription:"Edit document directly",documentSuggestingModeDescription:"Edits become suggestions",documentViewingModeDescription:"View clean version of document only",linkedStyles:"Linked styles"},qz=e=>e?typeof e!="string"?e instanceof HTMLElement?e:null:e.startsWith("#")||e.startsWith(".")?document.querySelector(e):document.getElementById(e):null;xt();function aA(e){return wN(e)??$0[e]??null}function fm(e,t,n,r={}){if(!e?.commands||!t||typeof e.commands.has=="function"&&!e.commands.has(t))return!1;const o=typeof e.commands.executeAsync=="function"?e.commands.executeAsync:e.commands.execute;if(typeof o!="function")return!1;const i=n===void 0?o.call(e.commands,t):o.call(e.commands,t,n);return i&&typeof i.then=="function"&&Promise.resolve(i).then(()=>r.onSettled?.(),s=>{r.onError?.(s),r.onSettled?.()}),!0}var Yz=new Set(["bold","italic","underline","strike","color","highlight","link","clearFormatting","textAlign","list","numberedlist","indentleft","indentright","lineHeight","linkedStyles"]),Xz=new Set(["list","numberedlist"]);function Zz(e,t){if(e==="fontFamily"||e==="fontSize"||Xz.has(e)&&t?.disabled&&t?.supported!==!1&&t?.reason==null)return!0;if(!Yz.has(e))return!1;const n=t?.reason;return n==="range-selection-required"||n==="selection-required"}function lA(e){return!!e?.closest?.("[data-editor-ui-surface], .toolbar-dropdown-menu, .sd-toolbar-dropdown-menu, .sd-tooltip-content")}function Qz(e){return["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key)}var Jz=class extends Ym.default{config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...er},texts:{...sA},fonts:null,hideButtons:!0,responsiveToContainer:!1,mode:"docx",excludeItems:[],groups:null,customButtons:[],showFormattingMarksButton:!1,showTableOfContentsButton:!1};toolbarItems=[];overflowItems=[];#t=null;#n=null;isDev=!1;role="editor";superdoc;toolbarContainer=null;toolbar=null;_detachFontsChanged=null;constructor(e={}){if(super(),this.config={...this.config,...e},this.toolbarItems=[],this.overflowItems=[],this.isDev=e.isDev||!1,this.superdoc=e.superdoc,this.role=e.role||"editor",this.toolbarContainer=null,this.config.icons={...er,...e.icons},this.config.texts={...sA,...e.texts},this.config.hideButtons=e.hideButtons??!0,this.config.responsiveToContainer=e.responsiveToContainer??!1,this.activeEditor=e.editor??this.superdoc?.activeEditor??null,this.ui=null,this.snapshot=null,this._unsubscribeController=null,this._detachFormatPainterModeChange=null,this._customCommandRegs=new Map,this._lastFontOptionsSignature="",!this.config.selector&&this.config.element&&(this.config.selector=this.config.element),this.toolbarContainer=qz(this.config.selector),this.toolbarContainer){const t=(this.config?.uiDisplayFallbackFont||"").toString().trim()||"Arial, Helvetica, sans-serif";this.toolbarContainer.style.setProperty("--sd-ui-font-family",t)}try{if(this.#e(),this.#u(),this.#l(),this.#s(),this._lastFontOptionsSignature=this.#o(),!this.toolbarContainer){this.updateToolbarState();return}this.app=Zl(GB),this.app.directive("click-outside",Qv),this.app.config.globalProperties.$toolbar=this,this.toolbar=this.app.mount(this.toolbarContainer),this.updateToolbarState()}catch(t){try{this.destroy()}catch{}throw t}}#e(){this.ui=this.superdoc?.ui??null,this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot(),this._unsubscribeController=this.ui.toolbar.subscribe(()=>{this.snapshot=this.ui.toolbar.getSnapshot(),this.updateToolbarState()}),this._detachFormatPainterModeChange=this.ui.formatPainter.onModeChange(e=>{e==="armed"||e==="persistent"?this.#P():this.#k()}))}#i(){this._unsubscribeController?.(),this._unsubscribeController=null,this._detachFormatPainterModeChange?.(),this._detachFormatPainterModeChange=null,this.#k();for(const e of this._customCommandRegs.values())try{e.unregister?.()}catch{}this._customCommandRegs.clear(),this.ui=null,this.snapshot=null}#s(){if(!this.superdoc||typeof this.superdoc.on!="function"||typeof this.superdoc.off!="function")return;const e=()=>{const t=this.#o();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#m()),this.updateToolbarState()};this.superdoc.on("fonts-changed",e),this._detachFontsChanged=()=>{this.superdoc?.off?.("fonts-changed",e)}}#a(){this._detachFontsChanged?.(),this._detachFontsChanged=null}#u(){if(Array.isArray(this.config.groups)){this.config.toolbarGroups=this.config.groups,this.config.groups=null;return}this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length&&(this.config.toolbarGroups=Object.keys(this.config.groups))}getAvailableWidth(){const e=document.documentElement.clientWidth,t=this.toolbarContainer?.offsetWidth??0;return this.config.responsiveToContainer?t:e}#d(e){return e||zB(this.superdoc?.fonts?.getFontFamilyOptions?.()??[])}#l(){const e=this.getAvailableWidth(),t=this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length>0,{defaultItems:n,overflowItems:r}=Kz({superToolbar:this,toolbarIcons:this.config.icons,toolbarTexts:this.config.texts,toolbarFonts:this.#d(this.config.fonts),hideButtons:this.config.hideButtons,availableWidth:e,role:this.role,isDev:this.isDev}),o=this.config.customButtons||[],i=o.map(l=>this.#f(l));o.length&&n.push(...i);let s=[...n.map(l=>l.name.value),...r.map(l=>l.name.value)];if(t){const l=Object.values(this.config.groups).flatMap(d=>d),u=new Set(Object.keys(this.config.groups)),c=i.filter(d=>u.has(d.group?.value||"center")).map(d=>d.name.value);s=[...new Set([...l,...c])]}const a=n.filter(l=>s.includes(l.name.value)).filter(l=>!this.config.excludeItems.includes(l.name.value));if(t)for(const[l,u]of Object.entries(this.config.groups))for(const c of a)u.includes(c.name.value)&&(c.group.value=l);this.toolbarItems=a,this.overflowItems=r.filter(l=>s.includes(l.name.value))}#f(e){const t=kn({...e});t.isCustomToolbarItem=!0;const n=e.command;if(typeof n=="function"&&this.ui?.commands?.register){const r=`__builtin_toolbar__${e.name}`;if(!this._customCommandRegs.has(r)){const o=this.ui.commands.register({id:r,execute:i=>{const s=i?.payload&&typeof i.payload=="object"?i.payload:{};return n({...i,item:t,argument:s.argument,option:s.option})}});this._customCommandRegs.set(r,o)}}return t}#m(){this.#l(),this.emit("toolbar-items-changed")}#o(){if(this.config.fonts)return"custom-fonts";const e=this.superdoc?.fonts?.getFontFamilyOptions?.()??[];return JSON.stringify(e.map(t=>[t.label,t.value,t.previewFamily]))}getToolbarItemByGroup(e){return this.toolbarItems.filter(t=>(t.group?.value||"center")===e)}getToolbarItemByName(e){return this.#r().find(t=>t.name.value===e)}#r(){return[...this.toolbarItems,...this.overflowItems]}getLinkedStyleOptions(){return this.ui?.styles?.getQuickGallery?.()??[]}getActiveLinkedStyleId(){return this.ui?.styles?.getActiveParagraphStyle?.()?.styleId??null}setActiveEditor(e){this.activeEditor=e;const t=this.#o();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#m()),this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot()),this.updateToolbarState()}onToolbarResize=()=>{this.#l(),this.updateToolbarState()};#p(e){return e==="ruler"?!!this.superdoc?.config?.rulers:e==="formattingMarks"?!!this.superdoc?.config?.layoutEngineOptions?.showFormattingMarks:!1}#y(e){return e==="ruler"?typeof this.superdoc?.toggleRuler=="function":e==="formattingMarks"?typeof this.superdoc?.toggleFormattingMarks=="function"||typeof this.superdoc?.setShowFormattingMarks=="function":!1}#w(){const e=this.getToolbarItemByName("documentMode");if(!e)return;const t=(this.snapshot?.commands?.["document-mode"]?.value||"editing").toLowerCase(),n=this.config.texts||{},r=this.config.icons||{},o={editing:{label:n.documentEditingMode||"Editing",icon:r.documentEditingMode||r.documentMode},suggesting:{label:n.documentSuggestingMode||"Suggesting",icon:r.documentSuggestingMode||r.documentMode},viewing:{label:n.documentViewingMode||"Viewing",icon:r.documentViewingMode||r.documentMode}},i=o[t]||o.editing;e.label?.value!==void 0&&(e.label.value=i.label),e.defaultLabel?.value!==void 0&&(e.defaultLabel.value=i.label),e.icon?.value!==void 0&&i.icon&&(e.icon.value=i.icon)}#_(){const e=this.toolbarItems.find(n=>n.name.value==="highlight");if(!e)return;const t={key:"color",type:"render",render:()=>tb(this,e,[],!0)};e.nestedOptions.value=[t]}#S(e){return!!e?.active&&e?.value==null}#E(e){return!!e&&e.disabled===!1&&e.value==null}#x(e){const t=e.name.value;if(t==="tableActions"){const i=tA.map(s=>this.snapshot?.commands?.[s]).some(s=>s&&!s.disabled);return e.setDisabled(!i),!0}if(t==="search")return e.setDisabled(!1),!0;if(Q0(t)?.disposition==="host-routed")return e.setDisabled(!this.#y(t)),this.#p(t)?e.activate():e.deactivate(),!0;const n=aA(t);if(!n)return!1;const r=this.snapshot?.commands?.[n];Zz(t,r)?e.setDisabled(!1):e.setDisabled(!!r?.disabled);const o={textAlign:()=>{r?.value?e.activate({textAlign:r.value}):e.deactivate()},lineHeight:()=>{e.selectedValue.value=r?.value!=null?r.value:""},zoom:()=>{if(r?.value!=null){const i=typeof r.value=="number"?`${r.value}%`:String(r.value);e.onActivate({zoom:i})}},measurementUnit:()=>{r?.value!=null&&e.onActivate({measurementUnit:String(r.value)})},documentMode:()=>{this.#w()},link:()=>{e.active.value=!!r?.active,e.attributes.value=nb(e.attributes.value,r?.value??null)},fontFamily:()=>{if(r?.value!=null){e.activate({fontFamily:r.value});return}if(this.#E(r)){e.activate({},!0);return}e.deactivate()},fontSize:()=>{if(r?.value!=null){e.activate({fontSize:r.value});return}if(this.#S(r)){e.activate({},!0);return}e.deactivate()},color:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},highlight:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},linkedStyles:()=>{const i=r?.value,s=typeof i=="string"?i:i?.styleId,a=i&&typeof i=="object"?i.styleName:null;s?e.activate({styleId:s,styleName:a}):e.label.value=this.config.texts?.formatText||"Format text"},list:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},numberedlist:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},default:()=>{r?.active?e.activate():e.deactivate()}};return(o[t]??o.default)(),!0}updateToolbarState(){this.#w(),this.#_();const e=this.snapshot?.commands?.["document-mode"]?.value||"editing";!(this.snapshot&&(this.superdoc?.activeEditor??this.activeEditor))||e==="viewing"?(this.#M(),this.#r().forEach(n=>{n.allowWithoutEditor?.value&&this.#x(n)})):this.#r().forEach(n=>{n.resetDisabled(),this.#x(n)});const t=this.getToolbarItemByName("copyFormat");t&&(this.snapshot?.copyFormatActive?t.activate():t.deactivate()),this.emit("toolbar-state-change")}#M(){this.#r().forEach(e=>{const{allowWithoutEditor:t}=e;t?.value||e.setDisabled(!0)})}#c(e,t){const n=this.superdoc;if(e==="ruler")return typeof n?.toggleRuler=="function"?(n.toggleRuler(),!0):!1;if(e==="formattingMarks"){if(typeof t=="boolean"&&typeof n?.setShowFormattingMarks=="function")return n.setShowFormattingMarks(t),!0;if(typeof n?.toggleFormattingMarks=="function")return n.toggleFormattingMarks(),!0}return!1}#L(e,t){const n=e?.name?.value;if(!n)return!1;const r={onSettled:()=>this.updateToolbarState(),onError:i=>this.#g(i,n)};if(n==="image"&&t==null)return this.#T();if(n==="tableActions"){const i=eA[t?.command];return i?fm(this.ui,i,void 0,r):!1}if(Q0(n)?.disposition==="unsupported")return!0;const o=aA(n);return o?fm(this.ui,o,t,r):!1}#T(){return this.snapshot?.commands?.image?.disabled||(this.#t||(this.#t=EN({ownerDocument:this.toolbarContainer?.ownerDocument??document,onPick:async e=>{const t=await AN(e,this.superdoc?.config?.handleImageUpload);fm(this.ui,"image",{src:t},{onSettled:()=>this.updateToolbarState(),onError:n=>this.#g(n,"image")})},onError:e=>this.#g(e,"image")})),this.#t.open()),!0}#P(){if(this.#n)return;const e=this.superdoc?.activeEditor?.container??document,t=i=>{lA(i.target)||this.ui.formatPainter.setPointerSelecting(!0)},n=i=>{this.ui.formatPainter.setPointerSelecting(!1),!lA(i.target)&&this.ui.formatPainter.notifyPointerUp()},r=i=>{if(i.key==="Escape"){this.ui.formatPainter.cancel();return}Qz(i)&&this.ui.formatPainter.setKeyboardSelecting(!0)},o=()=>{this.ui.formatPainter.setKeyboardSelecting(!1),this.ui.formatPainter.notifyKeyUp()};e.addEventListener("pointerdown",t),e.addEventListener("pointerup",n),e.addEventListener("keydown",r),e.addEventListener("keyup",o),this.#n=()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",n),e.removeEventListener("keydown",r),e.removeEventListener("keyup",o)}}#k(){this.#n&&(this.#n(),this.#n=null)}#g(e,t){const n=e instanceof Error?e:new Error(String(e));this.emit("exception",{error:n,originalError:e,itemName:t??null,editor:this.superdoc?.activeEditor??this.activeEditor??null})}emitCommand({item:e,argument:t,option:n}){const r=e?.name?.value,{command:o}=e,i=t!=null;if(!(e?.type==="dropdown"&&!i&&(o==="setFontFamily"||o==="setFontSize"))){if(r==="search"){this.superdoc?.emit?.("search:open");return}try{if(Q0(r)?.disposition==="host-routed"){this.#c(r,t),this.updateToolbarState();return}if(typeof o=="function"){const s=`__builtin_toolbar__${r}`;this._customCommandRegs.has(s)&&this.ui?.commands?.execute?this.ui.commands.execute(s,{argument:t,option:n}):o({item:e,argument:t,option:n,ui:this.ui,superdoc:this.superdoc}),this.updateToolbarState();return}if(e?.isCustomToolbarItem&&typeof o=="string"){if(!fm(this.ui,o,t,{onSettled:()=>this.updateToolbarState(),onError:s=>this.#g(s,r)}))throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState();return}if(!this.#L(e,t)&&o)throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState()}catch(s){this.#g(s,r)}}}destroy(){this.#k(),this.#t?.destroy(),this.#t=null,this.#a(),this.#i(),this.app?.unmount(),this.app=null,this.toolbar=null}};function $z(e){return new Jz(e)}function eV(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null||Array.isArray(e)!==Array.isArray(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function tV(e){if(!e||typeof e!="object")return{};const t={};e.fonts&&(t.rFonts={ascii:e.fonts.ascii,hAnsi:e.fonts.hAnsi,eastAsia:e.fonts.eastAsia,cs:e.fonts.cs,asciiTheme:e.fonts.asciiTheme,hAnsiTheme:e.fonts.hAnsiTheme,eastAsiaTheme:e.fonts.eastAsiaTheme,csTheme:e.fonts.csTheme,hint:e.fonts.hint}),e.fontFamily!=null&&(t.fontFamily=e.fontFamily),e.lang&&(t.lang={val:e.lang.val,eastAsia:e.lang.eastAsia,bidi:e.lang.bidi}),e.fontSize!=null&&(t.fontSize=e.fontSize),e.fontSizeCs!=null&&(t.fontSizeCs=e.fontSizeCs);const n=hm(e.color);n!=null&&(t.color=n),e.highlight!=null&&(t.highlight=e.highlight);const r=rV(e.shading);r&&(t.shading=r),e.cs!=null&&(t.cs=e.cs),e.rtl!=null&&(t.rtl=e.rtl),e.bold!=null&&(t.bold=e.bold),e.boldCs!=null&&(t.bCs=e.boldCs),e.italic!=null&&(t.italic=e.italic),e.italicCs!=null&&(t.iCs=e.italicCs);const o=nV(e.underline);o!==void 0&&(t.underline=o),e.strikethrough!=null&&(t.strike=e.strikethrough),e.doubleStrikethrough!=null&&(t.dstrike=e.doubleStrikethrough),e.caps!=null&&(t.caps=e.caps),e.smallCaps!=null&&(t.smallCaps=e.smallCaps),e.outline!=null&&(t.outline=e.outline),e.shadow!=null&&(t.shadow=e.shadow),e.emboss!=null&&(t.emboss=e.emboss),e.imprint!=null&&(t.imprint=e.imprint),e.verticalAlign!=null&&(t.vertAlign=e.verticalAlign),e.characterSpacing!=null&&(t.letterSpacing=e.characterSpacing),e.characterScale!=null&&(t.charScale=e.characterScale),e.kern!=null&&(t.kerning=e.kern),e.baselineShift!=null&&(t.position=e.baselineShift),e.fitTextWidth!=null&&(t.fitText={val:e.fitTextWidth}),e.vanish!=null&&(t.vanish=e.vanish),e.webHidden!=null&&(t.webHidden=e.webHidden),e.specVanish!=null&&(t.specVanish=e.specVanish);const i=oV(e.border);return i&&(t.border=i),t}function hm(e){if(e){if(typeof e=="string")return e;if(e.model==="rgb")return e.value;if(e.model==="auto")return"auto"}}function nV(e){if(e==null)return;const t={};return e.style!=null&&(t.style=e.style),e.color?.model==="rgb"&&(t.color=e.color.value),e.color?.model==="theme"&&(t.themeColor=e.color.theme),Object.keys(t).length>0?t:!0}function rV(e){if(!e)return;const t={},n=hm(e.fill);n!=null&&(t.fill=n);const r=hm(e.color);return r!=null&&(t.color=r),e.pattern!=null&&(t.val=e.pattern),Object.keys(t).length>0?t:void 0}function oV(e){if(!e)return;const t={};e.style!=null&&(t.val=e.style),e.width!=null&&(t.sz=e.width),e.space!=null&&(t.space=e.space);const n=hm(e.color);return n!=null&&(t.color=n),Object.keys(t).length>0?t:void 0}function uc(e){const t=e?.selectionTarget??e?.target;if(!e||!t)return"";try{return JSON.stringify(t)}catch{return String(t)}}function cA(e){return e.split(",").map(t=>t.trim()).filter(Boolean)}function iV(e){const t=[],n=o=>{o&&!t.includes(o)&&t.push(o)};n(e.getAttribute("data-track-change-preferred-target-id"));const r=e.getAttribute("data-track-change-ids");if(r)for(const o of cA(r))n(o);return n(e.getAttribute("data-track-change-id")),t}function uA(e,t){if(!e||typeof e.getAttribute!="function")return[];const n=[],r=new Set;let o=[],i=e;for(;i;){const s=i,a=iV(s),l=a.length>0?s.getAttribute("data-story-key"):null;for(const m of a){const p=`trackedChange:${m}`;if(!r.has(p)){r.add(p);const v={type:"trackedChange",id:m};l&&(v.storyKey=l),n.push(v),o.push(v)}}const u=s.getAttribute("data-layout-story");if(u&&o.length>0){for(const m of o)m.story=u;o=[]}const c=s.getAttribute("data-comment-ids");if(c)for(const m of cA(c)){const p=`comment:${m}`;r.has(p)||(r.add(p),n.push({type:"comment",id:m}))}const d=s.getAttribute("data-sdt-type"),h=s.getAttribute("data-sdt-id");if(h&&d==="structuredContent"){const m=`contentControl:${h}`;if(!r.has(m)){r.add(m);const p=s.getAttribute("data-sdt-scope"),v=s.getAttribute("data-sdt-tag"),_={type:"contentControl",id:h};(p==="block"||p==="inline")&&(_.scope=p),v&&(_.tag=v),n.push(_)}}if(t&&i===t)break;i=i.parentElement}return n}const rb={PAGE:"superdoc-page",FRAGMENT:"superdoc-fragment",LINE:"superdoc-line",INLINE_SDT_WRAPPER:"superdoc-structured-content-inline",INLINE_SDT_LABEL:"superdoc-structured-content-inline__label",BLOCK_SDT:"superdoc-structured-content-block",BLOCK_SDT_LABEL:"superdoc-structured-content__label",TABLE_FRAGMENT:"superdoc-table-fragment",DOCUMENT_SECTION:"superdoc-document-section",SDT_GROUP_HOVER:"sdt-group-hover",TOC_ENTRY:"superdoc-toc-entry",TOC_GROUP_HOVER:"toc-group-hover",IMAGE_FRAGMENT:"superdoc-image-fragment",INLINE_IMAGE:"superdoc-inline-image",LIST_MARKER:"superdoc-list-marker",INLINE_IMAGE_CLIP_WRAPPER:"superdoc-inline-image-clip-wrapper",ANNOTATION:"annotation",ANNOTATION_CONTENT:"annotation-content",ANNOTATION_CARET_ANCHOR:"annotation-caret-anchor"},VU=[rb.INLINE_SDT_LABEL,rb.BLOCK_SDT_LABEL],dA={PM_START:"data-pm-start",PM_END:"data-pm-end",LAYOUT_EPOCH:"data-layout-epoch",TABLE_BOUNDARIES:"data-table-boundaries",SDT_ID:"data-sdt-id",SDT_TYPE:"data-sdt-type",FIELD_ID:"data-field-id",FIELD_TYPE:"data-field-type",DRAGGABLE:"data-draggable",DISPLAY_LABEL:"data-display-label",VARIANT:"data-variant",TYPE:"data-type",LAYOUT_BOUNDARY_SCHEMA:"data-layout-boundary-schema",LAYOUT_FRAGMENT_ID:"data-layout-fragment-id",LAYOUT_STORY:"data-layout-story",LAYOUT_BLOCK_REF:"data-layout-block-ref"},sV=e=>{if(!e)return{kind:"unknown"};if(e==="body")return{kind:"body"};const t=e.indexOf(":"),n=t===-1?e:e.slice(0,t),r=t===-1?void 0:e.slice(t+1);switch(n){case"body":case"header":case"footer":case"footnote":case"endnote":case"textbox":return r?{kind:n,id:r}:{kind:n};default:return{kind:"unknown"}}},HU=`.${rb.BLOCK_SDT}[${dA.SDT_ID}]`,jU=`[${dA.DRAGGABLE}="true"]`;var ro=()=>({oneOf:[{type:"boolean"},{type:"null"}]}),cl=()=>({oneOf:[{type:"string",minLength:1},{type:"null"}]}),ku=()=>({oneOf:[{type:"number"},{type:"null"}]}),Au=e=>({oneOf:[{type:"object",properties:e,additionalProperties:!1,minProperties:1},{type:"null"}]}),aV={type:"object",properties:{style:{oneOf:[{type:"string",minLength:1},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},themeColor:{oneOf:[{type:"string",minLength:1},{type:"null"}]}},additionalProperties:!1,minProperties:1},lV={type:"object",properties:{id:{type:"number"},val:{type:"boolean"}},required:["id"],additionalProperties:!1},cV=()=>({oneOf:[{type:"boolean"},{type:"null"},aV]}),uV=()=>({oneOf:[{type:"array",items:lV,minItems:1},{type:"null"}]});function pm(e,t){return{storage:"mark",markName:e,textStyleAttr:t}}function dV(e){return{storage:"runAttribute",nodeName:"run",runPropertyKey:e}}var ob=(e,t,n)=>({key:e,type:"boolean",ooxmlElement:t,storage:"mark",tracked:!0,carrier:pm(n),schema:ro()}),dc=(e,t,n,r,o)=>({key:e,type:t,ooxmlElement:n,storage:"mark",tracked:!0,carrier:pm("textStyle",o??e),schema:r}),zn=(e,t,n,r,o)=>({key:e,type:t,ooxmlElement:n,storage:"runAttribute",tracked:!1,carrier:dV(o??e),schema:r});const mm=[ob("bold","w:b","bold"),ob("italic","w:i","italic"),ob("strike","w:strike","strike"),{key:"underline",type:"object",ooxmlElement:"w:u",storage:"mark",tracked:!0,carrier:pm("underline"),schema:cV()},{key:"highlight",type:"string",ooxmlElement:"w:highlight",storage:"mark",tracked:!0,carrier:pm("highlight"),schema:cl()},dc("color","string","w:color",cl()),dc("fontSize","number","w:sz",ku()),dc("fontFamily","string","w:rFonts",cl()),dc("letterSpacing","number","w:spacing",ku()),dc("vertAlign","string","w:vertAlign",{oneOf:[{enum:["superscript","subscript","baseline"]},{type:"null"}]}),dc("position","number","w:position",ku()),zn("dstrike","boolean","w:dstrike",ro()),zn("smallCaps","boolean","w:smallCaps",ro()),dc("caps","boolean","w:caps",ro(),"textTransform"),zn("shading","object","w:shd",Au({fill:{oneOf:[{type:"string",minLength:1},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},val:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),zn("border","object","w:bdr",Au({val:{oneOf:[{type:"string",minLength:1},{type:"null"}]},sz:{oneOf:[{type:"number"},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},space:{oneOf:[{type:"number"},{type:"null"}]}}),"borders"),zn("outline","boolean","w:outline",ro()),zn("shadow","boolean","w:shadow",ro()),zn("emboss","boolean","w:emboss",ro()),zn("imprint","boolean","w:imprint",ro()),zn("charScale","number","w:w",ku(),"w"),zn("kerning","number","w:kern",ku(),"kern"),zn("vanish","boolean","w:vanish",ro()),zn("webHidden","boolean","w:webHidden",ro()),zn("specVanish","boolean","w:specVanish",ro()),zn("rtl","boolean","w:rtl",ro()),zn("cs","boolean","w:cs",ro()),zn("bCs","boolean","w:bCs",ro(),"boldCs"),zn("iCs","boolean","w:iCs",ro(),"italicCs"),zn("eastAsianLayout","object","w:eastAsianLayout",Au({id:{oneOf:[{type:"string",minLength:1},{type:"null"}]},combine:{oneOf:[{type:"boolean"},{type:"null"}]},combineBrackets:{oneOf:[{type:"string",minLength:1},{type:"null"}]},vert:{oneOf:[{type:"boolean"},{type:"null"}]},vertCompress:{oneOf:[{type:"boolean"},{type:"null"}]}})),zn("em","string","w:em",cl()),zn("fitText","object","w:fitText",Au({val:{oneOf:[{type:"number"},{type:"null"}]},id:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),zn("snapToGrid","boolean","w:snapToGrid",ro()),zn("lang","object","w:lang",Au({val:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsia:{oneOf:[{type:"string",minLength:1},{type:"null"}]},bidi:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),zn("oMath","boolean","w:oMath",ro()),zn("rStyle","string","w:rStyle",cl(),"styleId"),zn("rFonts","object","w:rFonts",Au({ascii:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hAnsi:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsia:{oneOf:[{type:"string",minLength:1},{type:"null"}]},cs:{oneOf:[{type:"string",minLength:1},{type:"null"}]},asciiTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hAnsiTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsiaTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},csTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hint:{oneOf:[{type:"string",minLength:1},{type:"null"}]}}),"fontFamily"),zn("fontSizeCs","number","w:szCs",ku()),zn("ligatures","string","w14:ligatures",cl()),zn("numForm","string","w14:numForm",cl()),zn("numSpacing","string","w14:numSpacing",cl()),zn("stylisticSets","array","w14:stylisticSets",uV()),zn("contextualAlternates","boolean","w14:cntxtAlts",ro())],UU=new Set(mm.map(e=>e.key)),fV=Object.fromEntries(mm.map(e=>[e.key,e])),GU={mark:mm.filter(e=>e.storage==="mark").map(e=>e.key),runAttribute:mm.filter(e=>e.storage==="runAttribute").map(e=>e.key)};var hV=new Set(Object.values(lt));function ib(e,t){return typeof e=="string"&&hV.has(e)?e:t}function fA(e){if(e&&typeof e=="object"&&e.ok===!1){const t=e.reason;return t==="host-not-ready"||t==="host-disposed"||t==="editing-mount-required"?{ok:!1,reason:lt.notReady}:{ok:!1,reason:ib(t,lt.targetUnresolved)}}return{ok:!0}}var pV=["document-replaced","editorCreate","active-editor-change","document-mode-change","zoomChange","measurement-unit-change","viewport-change","fonts-changed"],mV={[U4.bulletList]:"bullet",[U4.numberedList]:"ordered"};function hA(e){return mV[e]??null}var gV={disc:"disc",circle:"circle",square:"square",decimal:"decimal","decimal-paren":"decimalParenthesis","upper-roman":"upperRoman","lower-roman":"lowerRoman","upper-alpha":"upperLetter","upper-alpha-paren":"upperLetterParenthesis","lower-alpha":"lowerLetter","lower-alpha-paren":"lowerLetterParenthesis"};function vV(e){const t=gV[e];return t?{preset:t,behavior:"toggleStyle"}:{}}var yV={status:"ready",empty:!0,target:null,selectionTarget:null,activeMarks:[],activeCommentIds:[],activeChangeIds:[],quotedText:""};const bV=[{key:"contentControls",match:"exact",note:"full-document SDT catalog parse (the measured during-load cliff)"},{key:"contentControls:inRange:",match:"prefix",note:"same adapter load() as the catalog, issued per settled selection"},{key:"hyperlinks:",match:"prefix",note:"per-block hyperlink list over the loading story"},{key:"styles:catalog:",match:"prefix",note:"WordStyleModel recompile from package bytes"},{key:"comments",match:"exact",note:"audited: full comments list; stale-served during load"},{key:"trackChanges",match:"exact",note:"audited: all-story tracked-changes list; stale-served during load"},{key:"trackChanges:all",match:"exact",note:"audited: all-story tracked-changes list; consumers already fail closed on non-ready"},{key:"tables",match:"exact",note:"reserved: full tables catalog"},{key:"sections",match:"exact",note:"reserved: full sections list"}];var wV=new Set(["/word/comments.xml","/word/commentsExtended.xml","/word/commentsIds.xml"]);function CV(e){return bV.some(t=>t.match==="exact"?t.key===e:e.startsWith(t.key))}var pA={ready:0,stale:1,pending:2};function Iu(...e){let t="ready";for(const n of e)pA[n]>pA[t]&&(t=n);return t}function Tt(e,t){if(typeof e!="function")return t;try{const n=e();return n===void 0?t:n}catch{return t}}function Tr(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function vr(e,t){if(!e)return null;const n=t.split(".");let r=e;for(const o of n){if(r==null)return null;r=r[o]}return typeof r=="function"?r:null}function lr(e,t="CAPABILITY_UNAVAILABLE"){return{success:!1,failure:{code:t,message:e}}}function Nf(e,t){return{success:!1,failure:{code:"PARTIAL_LINK_EDIT",message:"Hyperlink target was updated, but display text replacement failed."},applied:{href:!0,text:!1},hyperlinkResult:e,textResult:t}}function Bf(e){if(!e||typeof e!="object")return null;const t=e.target;return t&&typeof t=="object"?t:null}function sb(e){if(!e||typeof e!="object")return!1;const t=e,n=i=>{if(!i||typeof i!="object")return!1;const s=i;return s.kind==="text"&&typeof s.blockId=="string"&&typeof s.offset=="number"},r=i=>{if(!i||typeof i!="object")return!1;const s=i,a=s.range;return typeof s.blockId=="string"&&typeof a?.start=="number"&&typeof a.end=="number"};if(Array.isArray(t.segments)){const i=t.segments[0],s=t.segments[t.segments.length-1];return r(i)&&r(s)}if(t.kind==="selection")return n(t.start)&&n(t.end);if(t.kind!=="text"||typeof t.blockId!="string")return!1;const o=t.range;return typeof o?.start=="number"&&typeof o.end=="number"}function _V(e){if(!e||typeof e!="object")return null;const t=Bf(e);if(sb(t))return t;const n=e,r=n.navigationTarget&&typeof n.navigationTarget=="object"?n.navigationTarget:null;return r?.kind==="block"&&typeof r.blockId=="string"&&r.blockId.length>0?{kind:"text",blockId:r.blockId,range:{start:0,end:0},...r.story&&typeof r.story=="object"?{story:r.story}:{},...n.address&&typeof n.address=="object"?{address:n.address}:{}}:t}function Cr(e){if(!e||typeof e!="object")return"story:body";const t=e,n=typeof t.storyType=="string"?t.storyType:"body";switch(n){case"body":return"story:body";case"headerFooterPart":return`story:headerFooterPart:${typeof t.refId=="string"?t.refId:""}`;case"headerFooterSlot":return JSON.stringify({storyType:n,section:t.section??null,headerFooterKind:t.headerFooterKind??null,variant:t.variant??null,resolution:t.resolution??"effective",onWrite:t.onWrite??"materializeIfInherited"});case"footnote":return`story:footnote:${typeof t.noteId=="string"?t.noteId:""}`;case"endnote":return`story:endnote:${typeof t.noteId=="string"?t.noteId:""}`;case"textbox":return`story:textbox:${typeof t.textboxId=="string"?t.textboxId:""}`;default:return JSON.stringify(t)}}function zf(e){if(!e||typeof e!="object")return null;const t=e,n=t.address&&typeof t.address=="object"?t.address:null;if(n?.story&&typeof n.story=="object")return n.story;if(t.storyLocator&&typeof t.storyLocator=="object")return t.storyLocator;if(t.trackedChangeStory&&typeof t.trackedChangeStory=="object")return t.trackedChangeStory;const r=Bf(e);if(!r||typeof r!="object")return null;const o=r;if(o.story&&typeof o.story=="object")return o.story;const i=o.address&&typeof o.address=="object"?o.address:null;return i?.story&&typeof i.story=="object"?i.story:null}function Ki(e,t,n){return Gn(e)!==t?!1:n?Cr(zf(e))===Cr(n):!0}function gm(e){const t=zf(e);if(!(!t||Cr(t)===Cr(null)))return t}function SV(e){if(typeof e!="string"||e.length===0)return;const t=sV(e);switch(t.kind){case"body":return;case"footnote":return t.id?{kind:"story",storyType:"footnote",noteId:t.id}:void 0;case"endnote":return t.id?{kind:"story",storyType:"endnote",noteId:t.id}:void 0;case"header":case"footer":return t.id?{kind:"story",storyType:"headerFooterPart",refId:t.id}:void 0;default:return}}function kV(e){if(!(typeof e!="string"||e.length===0||e==="body")){if(e.startsWith("hf:part:")){const t=e.slice(8);return t?{kind:"story",storyType:"headerFooterPart",refId:t}:void 0}if(e.startsWith("fn:")){const t=e.slice(3);return t?{kind:"story",storyType:"footnote",noteId:t}:void 0}if(e.startsWith("en:")){const t=e.slice(3);return t?{kind:"story",storyType:"endnote",noteId:t}:void 0}}}function ab(e){if(!e||typeof e!="object")return null;const t=e.selectionTarget;return t&&typeof t=="object"?t:null}function vm(e){if(!e||typeof e!="object")return null;const t=e.id;return typeof t=="string"&&t.length>0?t:null}function AV(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="selection")return e;const n=t.start;return!n||typeof n!="object"?null:{...t,end:n}}function Gn(e){if(!e||typeof e!="object")return null;const t=e,n=t.id??t.commentId??t.changeId;return typeof n=="string"&&n.length>0?n:null}function IV(e){if(!e||typeof e!="object")return null;const t=e,n=t.anchor,r=t.focus,o=n?.visualCaret,i=r?.visualCaret,s=o?.trackChangeId,a=i?.trackChangeId;return typeof s=="string"&&s.length>0&&s===a?s:null}var mA=new WeakMap;function gA(e){const t=[],n=i=>{typeof i=="string"&&i.length>0&&!t.includes(i)&&t.push(i)},r=i=>{if(!i||typeof i!="object")return;const s=i,a=s.sourceIds;if(a&&typeof a=="object"&&(n(a.wordIdInsert),n(a.wordIdDelete),Array.isArray(a.wordIdOther)))for(const d of a.wordIdOther)n(d);const l=s.wordRevisionIds;l&&typeof l=="object"&&(n(l.insert),n(l.delete),n(l.format));const u=s.replacement;if(u&&typeof u=="object")for(const d of[u.inserted,u.deleted])d&&typeof d=="object"&&(n(d.id),n(d.wordId));const c=s.move;if(c&&typeof c=="object")for(const d of[c.source,c.destination])d&&typeof d=="object"&&(n(d.id),n(d.wordId))};r(e);const o=e?.change;return o&&o!==e&&r(o),t}function pa(e){const t=mA.get(e);if(t)return t;const n=new Set,r=new Map;for(const i of e){const s=Gn(i);if(s){n.add(s);for(const a of gA(i)){r.has(a)||r.set(a,s);const l=`imported:${a}`;r.has(l)||r.set(l,s)}}}const o={toPublicId(i){if(n.has(i))return i;const s=r.get(i);return s!=null&&n.has(s)?s:null},aliasesFor(i){const s=[i];for(const[a,l]of r)l===i&&!s.includes(a)&&s.push(a);return s}};return mA.set(e,o),o}var vA=new WeakMap,yA=new WeakMap;function Eu(e,t){const n=Cr(t);let r=vA.get(e);r||(r=new Map,vA.set(e,r));const o=r.get(n);if(o)return o;const i=pa(e.filter(s=>Cr(zf(s))===n));return r.set(n,i),i}function EV(e){return!!e&&typeof e=="object"&&e.storyType==="textbox"}function xV(e,t){const n=t.filter(o=>e.some(i=>Gn(i)===o&&zf(i)==null));if(n.length===0)return null;if(n.length===1)return n[0];const r=new Set;for(const o of n){const i=e.find(s=>Gn(s)===o);if(i)for(const s of gA(i)){if(r.has(s))return null;r.add(s)}}return n[0]}function TV(e){const t=yA.get(e);if(t)return t;const n=e.filter(o=>zf(o)!=null),r=n.length===e.length?e:n;return yA.set(e,r),r}function RV(e){const{selectionIds:t,publicIds:n,selection:r,bodyItems:o,allStoryItems:i}=e;if(t.length===0)return null;const s=u=>{for(const c of t){const d=u.toPublicId(c);if(d)return d}return null},a=qi(r),l=Cr(a)===Cr(null);if(i){const u=l?TV(i):i,c=s(Eu(u,a));if(c)return c;const d=n?.find(h=>u.some(m=>Ki(m,h,a)));return d||(l?s(pa(o)):EV(a)?xV(i,t):null)}return l?s(pa(o))??t[0]??null:null}function MV(e,t){const n=e.find(r=>Gn(r)===t||r.importedId===t);return n?n.rootCommentId??n.parentCommentId??Gn(n)??t:null}function LV(e){const t=e.selectionTarget;if(t){const s=t.start,a=t.end,l=typeof s?.blockId=="string"?s.blockId:void 0,u=typeof a?.blockId=="string"?a.blockId:l;if(l)return{startBlockId:l,endBlockId:u??l}}const n=e.target,r=n&&Array.isArray(n.segments)?n.segments:[],o=r[0]?.blockId,i=r[r.length-1]?.blockId;return typeof o=="string"?{startBlockId:o,endBlockId:typeof i=="string"?i:o}:null}function Fr(e){const t=[],n=s=>{typeof s=="string"&&s.length>0&&!t.includes(s)&&t.push(s)},r=e.target,o=r&&Array.isArray(r.segments)?r.segments:[];for(const s of o)n(s?.blockId);const i=e.selectionTarget;return i&&(n(i.start?.blockId),n(i.end?.blockId)),t}var PV=64;function fc(e){return e.length<=PV}function qi(e){const t=e.target,n=e.selectionTarget,r=n?.start,o=n?.end,i=t?.story??n?.story??r?.story??o?.story;return i&&typeof i=="object"?i:{kind:"story",storyType:"body"}}function mo(e,t){return{kind:"block",nodeType:"paragraph",nodeId:e,...t&&typeof t=="object"?{story:t}:{}}}function ma(e){return{kind:"block",nodeType:"paragraph",nodeId:e}}function bA(e,t){return{kind:"block",nodeType:"listItem",nodeId:e,...t&&typeof t=="object"?{story:t}:{}}}var wA=720;function ks(e){return Math.round(e*20)}function xu(e){return typeof e=="number"&&Number.isFinite(e)}function DV(e){if(!e||typeof e!="object")return null;const t=e.node;if(!t||typeof t!="object")return null;const n=t.kind==="heading"?t.heading??null:t.kind==="paragraph"?t.paragraph??null:null;if(!n)return null;const r=n.resolved,o=n.props,i=r?.indent??o?.indent;if(!i||typeof i!="object")return null;const s=xu(i.left)?ks(i.left):xu(i.start)?ks(i.start):void 0,a=xu(i.right)?ks(i.right):xu(i.end)?ks(i.end):void 0,l=xu(i.firstLine)?ks(i.firstLine):void 0,u=xu(i.hanging)?ks(i.hanging):void 0;return s==null&&a==null&&l==null&&u==null?null:{...s!=null?{left:s}:{},...a!=null?{right:a}:{},...l!=null?{firstLine:l}:{},...u!=null?{hanging:u}:{}}}function lb(e){const t=e.target,n=t&&Array.isArray(t.segments)?t.segments:[],r=t?.story,o=[];for(const i of n){if(!i||typeof i.blockId!="string")continue;const s=i.range;!s||typeof s.start!="number"||typeof s.end!="number"||s.start===s.end||o.push({kind:"text",blockId:i.blockId,range:{start:s.start,end:s.end},...r?{story:r}:{}})}return o}function OV(e){if(!e||typeof e!="object")return[];const t=e,n=t.story,r=[];if(t.kind==="text"&&t.range&&typeof t.blockId=="string"){const o=t.range;return typeof o.start=="number"&&typeof o.end=="number"&&o.start!==o.end&&r.push({kind:"text",blockId:t.blockId,range:{start:Math.min(o.start,o.end),end:Math.max(o.start,o.end)},...n?{story:n}:{}}),r}if(t.kind==="text"&&Array.isArray(t.segments)){for(const o of t.segments){const i=o?.range;typeof o?.blockId=="string"&&typeof i?.start=="number"&&typeof i?.end=="number"&&i.start!==i.end&&r.push({kind:"text",blockId:o.blockId,range:{start:Math.min(i.start,i.end),end:Math.max(i.start,i.end)},...n?{story:n}:{}})}return r}if(t.kind==="selection"){const o=t.start,i=t.end,s=typeof o?.blockId=="string"&&i?.blockId===o.blockId?o.blockId:null;o?.kind==="text"&&i?.kind==="text"&&s&&typeof o.offset=="number"&&typeof i.offset=="number"&&o.offset!==i.offset&&r.push({kind:"text",blockId:s,range:{start:Math.min(o.offset,i.offset),end:Math.max(o.offset,i.offset)},...t.story??o.story?{story:t.story??o.story}:{}})}return r}function Vf(e){if(!e||typeof e!="object")return null;const t=e,n=t.story;if(t.kind==="text"&&t.range&&typeof t.blockId=="string"){const r=t.range;if(typeof r.start=="number"&&typeof r.end=="number"&&r.start===r.end)return{kind:"text",blockId:t.blockId,range:{start:r.start,end:r.end},...n?{story:n}:{}}}if(t.kind==="text"&&Array.isArray(t.segments)){const r=t.segments[0],o=r?.range;if(typeof r?.blockId=="string"&&typeof o?.start=="number"&&typeof o?.end=="number"&&o.start===o.end)return{kind:"text",blockId:r.blockId,range:{start:o.start,end:o.end},...n?{story:n}:{}}}if(t.kind==="selection"){const r=t.start,o=t.end,i=typeof r?.blockId=="string"&&o?.blockId===r.blockId?r.blockId:null;if(r?.kind==="text"&&o?.kind==="text"&&i&&typeof r.offset=="number"&&typeof o.offset=="number"&&r.offset===o.offset)return{kind:"text",blockId:i,range:{start:r.offset,end:r.offset},...t.story??r.story?{story:t.story??r.story}:{}}}return null}function ul(e){return Vf(e.target)??Vf(e.selectionTarget)}var CA=["fontFamily","fontSize","color","highlight"],FV={undo:"history.undo",redo:"history.redo"},Hf=["bold","italic","underline","strikethrough"];function cb(e){return CA.includes(e)}function Tu(e){const t=e.target,n=t&&Array.isArray(t.segments)?t.segments:[],r=[],o=(l,u,c)=>{typeof l!="string"||typeof u!="number"||typeof c!="number"||r.push({blockId:l,start:Math.min(u,c),end:Math.max(u,c)})};for(const l of n){const u=l?.range;o(l?.blockId,u?.start,u?.end)}if(r.length>0)return r;const i=e.selectionTarget,s=i?.start,a=i?.end;return!s||!a||s.blockId!==a.blockId||o(s.blockId,s.offset,a.offset),r}function Yi(e){const t=e.target,n=e.selectionTarget,r=n?.start,o=n?.end,i=t?.story??n?.story??r?.story??o?.story;return i&&typeof i=="object"?i:void 0}function NV(e){const t=Yi(e);if(!t||typeof t!="object")return"body";const n=t;return JSON.stringify({storyType:typeof n.storyType=="string"?n.storyType:"body",refId:typeof n.refId=="string"?n.refId:null,noteId:typeof n.noteId=="string"?n.noteId:null,textboxId:typeof n.textboxId=="string"?n.textboxId:null})}function ga(e){const t=Tu(e);return t.length===0?null:[NV(e),...t.map(n=>`${n.blockId}:${n.start}-${n.end}`)].join("|")}function _A(e){const t=e.selectionTarget;return!t||typeof t!="object"?null:uc({selectionTarget:t})}function BV(e,t){if(e==="fontSize"){const r=typeof t=="number"?t:Number(t);return Number.isFinite(r)&&r>0?String(r):null}if(typeof t!="string")return null;const n=t.trim();return n.length===0?null:e==="color"||e==="highlight"?n.toUpperCase():n}function zV(e,t){return Math.max(e.start,t.start)<Math.min(e.end,t.end)}function VV(e){if(!e)return[];const t=Array.isArray(e.blocks)?e.blocks:[],n=[];for(const r of t){const o=r?.range,i=r?.blockId;typeof i!="string"||typeof o?.start!="number"||typeof o?.end!="number"||n.push({blockId:i,start:Math.min(o.start,o.end),end:Math.max(o.start,o.end)})}return n}function HV(e,t){return e.length!==t.length?!1:e.every((n,r)=>{const o=t[r];return o?.blockId===n.blockId&&o?.start===n.start&&o?.end===n.end})}function SA(e,t){const n=Tu(t);if(n.length===0)return null;const r=e&&Array.isArray(e.items)?e.items:[];if(r.length===0)return null;const o=r.find(i=>HV(n,VV(i)));if(o)return o;if(n.length===1){const i=r.find(s=>{const a=s?.address;return a?.kind==="block"&&a.nodeId===n[0].blockId});if(i)return i}return r[0]??null}function jV(e,t){const n=t==="fontSize"?e?.fontSizePt??e?.fontSize:t==="highlight"?e?.highlight??e?.backgroundColor:e?.[t];if(typeof n=="number")return Number.isFinite(n)?String(n):void 0;if(typeof n!="string")return;const r=n.trim();if(r.length!==0)return t==="color"||t==="highlight"?r.toUpperCase():r}function ub(e){if(typeof e!="string")return;const t=e.split(",")[0]?.trim().replace(/^['"]+|['"]+$/g,"").trim();if(!t)return;const n=t.toLowerCase();if(!(n==="serif"||n==="sans-serif"||n==="monospace"||n==="cursive"||n==="fantasy"))return t}function UV(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return;const t=Math.round(e*.75*2)/2;if(!(t<=0))return String(t)}function GV(e,t){return e==="fontFamily"?t.toLowerCase():e==="color"||e==="highlight"?t.toUpperCase():t}function kA(e,t){if(!e)return{};const n=new Map;for(const i of Tu(t)){const s=n.get(i.blockId)??[];s.push({start:i.start,end:i.end}),n.set(i.blockId,s)}if(n.size===0)return{};const r=Array.isArray(e.blocks)?e.blocks:[],o={};for(const i of CA){const s=new Map;let a=!1,l=!1;for(const u of r){const c=typeof u?.blockId=="string"?u.blockId:null;if(!c)continue;const d=n.get(c);if(!d?.length)continue;const h=Array.isArray(u?.runs)?u.runs:[];for(const m of h){const p=m?.range,v=typeof p?.start=="number"?p.start:null,_=typeof p?.end=="number"?p.end:null;if(v==null||_==null||!d.some(y=>zV(y,{start:v,end:_})))continue;a=!0;const C=jV(m?.styles,i);if(C===void 0){l=!0;continue}const k=GV(i,C);if(s.has(k)||s.set(k,C),s.size>1)break}if(s.size>1)break}a&&!l&&s.size===1&&(o[i]=[...s.values()][0])}return o}function db(e,t){const n=Fr(e)[0];return n?t==="nodeId"?{kind:"after",nodeId:n}:{kind:"after",target:mo(n)}:{kind:"documentEnd"}}function on(e,t){const n=e.supported??t!=="unsupported",r=e.enabled??(e.disabled!==void 0?!e.disabled:n);return{enabled:r,disabled:!r,active:e.active??!1,supported:n,value:e.value,source:t,reason:r?void 0:e.reason}}function dl(e){if(!e||typeof e!="object")return null;const t=e,n=t.change,r=n&&typeof n=="object"?n:t;return{...t,id:t.id??r.id,change:r}}function ym(e){const t=e,n=t.change;return n&&typeof n=="object"?n:t}function As(e){if(Tr(e))return!0;if(e===!1)return!1;if(e===!0||e==null||typeof e!="object")return!0;const t=e;return"success"in t||"failure"in t||"effects"in t?e:t.status!=="rejected"}function bm(e){return!!e&&typeof e=="object"&&e.success===!0}function go(e){return!(e===!1||e&&typeof e=="object"&&e.success===!1)}function Ru(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function fb(e){const t=[],n=r=>{if(!r||typeof r!="object")return;const o=r;if(Array.isArray(o.runs)&&t.push(o),Array.isArray(o.rows))for(const i of o.rows){const s=i?.cells;if(Array.isArray(s))for(const a of s){const l=a;if(Array.isArray(l?.blocks))for(const u of l.blocks)n(u);l?.paragraph&&n(l.paragraph)}}};if(Array.isArray(e))for(const r of e)n(r);return t}function hc(e,t){return e.sourceAnchor?.sourceNodeId===t?!0:e.id===t}function mi(e){let t=!1,n=null,r=null,o=null;for(const i of e)t=i,!go(i)&&n===null&&(n=i),bm(i)&&(o=i),i!==!1&&(r=i);return n??o??r??t}function WV(e){const t=e?.anchor,n=t?.start,r=t?.end;return typeof n?.blockId!="string"||typeof r?.blockId!="string"||n.blockId!==r.blockId||typeof n.offset!="number"||typeof r.offset!="number"?null:{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.offset},end:{kind:"text",blockId:r.blockId,offset:r.offset}}}function KV(e){return e.startsWith("#")?{kind:"anchor",anchor:e.slice(1)}:{kind:"external",url:e}}function wm(e){return Su(e)?.trackDecision??null}function qV(e){return{found:e.length>0,success:e.length>0,rects:e,rect:e[0]}}function fl(e){return{found:!1,success:!1,rects:[],reason:e}}function YV(e,t){if(!t||typeof t.getBoundingClientRect!="function"||e.rects.length===0)return e;let n;try{const o=t.getBoundingClientRect();n={left:o.left,top:o.top}}catch{return e}const r=e.rects.map(o=>({...o,left:o.left-n.left,right:o.right-n.left,top:o.top-n.top,bottom:o.bottom-n.top}));return{...e,rects:r,rect:r[0]}}function XV(e){if(!e||typeof e!="object")return!1;const t=e;if(typeof t.blockId!="string"||!t.range||typeof t.range!="object")return!1;const n=t.range;return Number.isInteger(n.start)&&Number.isInteger(n.end)&&n.start>=0&&n.start<=n.end}function AA(e){if(!e||e.kind!=="text"||!Array.isArray(e.segments)||e.segments.length===0)return null;const t=Array.from(e.segments);if(!t.every(XV))return null;const n=t[0],r=t[t.length-1],o=e.story;return{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start,...o?{story:o}:{}},end:{kind:"text",blockId:r.blockId,offset:r.range.end,...o?{story:o}:{}},...o?{story:o}:{}}}function ZV(e){return e.selectionTarget?e.selectionTarget:AA(e.target)}function Mu(e){if(e.empty)return null;if(e.selectionTarget)return e.selectionTarget;const t=AA(e.target);return t&&t.start.kind==="text"&&t.end.kind==="text"&&t.start.blockId!==t.end.blockId?null:t}function hb(e){return!e.inline||typeof e.docRoute!="string"?null:e.docRoute.startsWith("format.")?e.docRoute.slice(7):null}var pb={bold:null,italic:null,underline:null,strike:null,color:null,highlight:null,fontFamily:null,fontSize:null,vertAlign:null,smallCaps:null,caps:null,letterSpacing:null,dstrike:null},QV=Object.fromEntries(Object.entries(pb).filter(([e])=>fV[e]?.tracked===!0));function JV(e,t,n,r){switch(e.kind){case"toggle":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n;return typeof o=="boolean"||o===null?{target:t,value:o}:{target:t,value:!r}}case"value-string":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n;return o===null?{target:t,value:null}:typeof o!="string"||o.trim()===""?null:{target:t,value:o}}case"value-number":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n,i=typeof o=="number"?o:Number(o);return!Number.isFinite(i)||i<=0?null:{target:t,value:i}}case"clear":return{target:t,inline:{...pb}};default:return null}}function $V(e){const t=o=>{if(!o||typeof o!="object")return null;const i=o,s=i.rowIndex,a=i.columnIndex;return typeof s!="number"||!Number.isInteger(s)||typeof a!="number"||!Number.isInteger(a)?null:{rowIndex:s,columnIndex:a}};if(!e)return null;const n=t(e.start),r=t(e.end);return!n||!r?null:{start:n,end:r}}function eH(e,t){const{tableNodeId:n,rowIndex:r,columnIndex:o,cellNodeId:i,mergeRange:s}=t;switch(e){case"insert-row-before":return{nodeId:n,rowIndex:r,position:"above"};case"insert-row-after":return{nodeId:n,rowIndex:r,position:"below"};case"delete-row":return{nodeId:n,rowIndex:r};case"insert-column-before":return{nodeId:n,columnIndex:o,position:"left"};case"insert-column-after":return{nodeId:n,columnIndex:o,position:"right"};case"delete-column":return{nodeId:n,columnIndex:o};case"delete-table":return{nodeId:n};case"merge-cells":{const a=s??{start:{rowIndex:r,columnIndex:o},end:{rowIndex:r,columnIndex:o}};return{nodeId:n,start:a.start,end:a.end}}case"split-cell":return i?{nodeId:i,rows:1,columns:2}:null;case"remove-borders":return{nodeId:n,mode:"applyTo",applyTo:"all",border:null};default:return null}}function tH(e){const t=e.superdoc,n=new Map,r=new Map;let o=null,i=0;const s=[];let a=null,l=0,u=!1,c=Promise.resolve(),d=null,h={mode:"idle",snapshot:null,sourceSelectionKey:null,lastClickAt:0,pointerSelecting:!1,keyboardSelecting:!1},m=0;const p=new Set;let v={},_="",C=null;const k=()=>{const f=t?.activeEditor;return f&&typeof f=="object"?f:null},y=()=>{const f=k()?.doc;return f&&typeof f=="object"?f:null},b=()=>{const f=k()?.v2TrackedChanges;return f&&typeof f=="object"?f:null},T=()=>{const f=k()?.host;return f&&typeof f=="object"?f:null},R=f=>{if(f.storyType!=="headerFooterPart"||typeof f.refId!="string")return null;const g=k(),w=T(),A=g?.pageLayout??w?.pageLayout;if(!A||typeof A!="object")return null;const E=A.getActiveRulerContext,B=w?.resolveHeaderFooterEditTarget;if(typeof E!="function"||typeof B!="function")return null;const q=Tt(()=>E.call(A),null);if(!q||typeof q.pageIndex!="number")return null;for(const oe of["header","footer"]){const ve=Tt(()=>B.call(w,{pageIndex:q.pageIndex,kind:oe}),null);if(!(ve?.status!=="ready"||ve.refId!==f.refId||typeof ve.sectionId!="string"||!["default","first","even"].includes(String(ve.slotVariant))))return{kind:"story",storyType:"headerFooterSlot",section:{kind:"section",sectionId:ve.sectionId},headerFooterKind:oe,variant:ve.slotVariant}}return null},P=()=>{const f=T(),g=f?.getPendingInlineFormat;if(typeof g!="function")return null;const w=Tt(()=>g.call(f),null);return w&&typeof w=="object"?w:null},j=f=>{const g=hb(f);if(!g)return null;const w=P();if(!w||!(g in w))return null;const A=w[g];return f.inline?.kind==="toggle"?A===!0:A!=null&&A!==""},O=f=>{const g=hb(f);if(!g)return;const w=P();if(!w||!(g in w))return;const A=w[g];if(typeof A=="string"&&A!=="")return A;if(typeof A=="number"&&Number.isFinite(A))return String(A)},V=(f,g)=>{const w=T(),A=w?.setPendingInlineFormat;typeof A=="function"&&Tt(()=>A.call(w,f,g),void 0)},Q=f=>{const g=T(),w=g?.clearPendingInlineFormat;typeof w=="function"&&Tt(()=>w.call(g,f),void 0)},F=new Set(["bold","italic","underline","strikethrough"]),N=f=>{const g=P();if(!g)return;const w=Array.isArray(f.activeMarks)?f.activeMarks:[];let A=null;for(const E of Object.keys(g)){const B=g[E];let q;if(F.has(E))q=w.includes(E)===(B===!0);else if(cb(E)){if(B==null)continue;A||(A=ni(f)),q=A[E]===B}else q=!1;q&&Q(E)}},x=()=>{const f=k()?.editCommands;return f&&typeof f=="object"?f:null},z=f=>{const g=x();if(!g||typeof g.getSnapshot!="function")return null;const w=Tt(()=>g.getSnapshot(),null)?.commands?.[f];return w&&typeof w=="object"?w:null},J=()=>z("lists.apply"),X=f=>{const g=f?.value?.seed;return g==="bullet"||g==="ordered"?g:null},ae=f=>{const g=FV[f];return g?z(g):null},pe=()=>{const f=T();if(!f||typeof f.getTableContext!="function")return null;const g=Tt(()=>f.getTableContext(),null);return g&&typeof g=="object"?g:null},Fe=()=>{const f=pe();if(!f||f.inTable!==!0)return null;const g=f.table,w=typeof g?.nodeId=="string"&&g.nodeId.length>0?g.nodeId:null;if(!w)return null;const A=f.row,E=f.column,B=f.cell,q=typeof A?.index=="number"&&Number.isInteger(A.index)?A.index:null,oe=typeof E?.index=="number"&&Number.isInteger(E.index)?E.index:null;if(q==null||oe==null)return null;const ve=typeof B?.nodeId=="string"&&B.nodeId.length>0?B.nodeId:null,Re=f.cellRange;return{tableNodeId:w,rowIndex:q,columnIndex:oe,cellNodeId:ve,mergeRange:$V(Re)}},fe=new Map;let ye=null,le=null,Se=0,re=0,xe=0;const $e=new Set,st=(f,g)=>f===g?!0:!f||!g?!1:f.id===g.id&&f.paintedEntityId===g.paintedEntityId&&Cr(f.story)===Cr(g.story),At=f=>Array.from($e).some(g=>st(g,f)),Ee=f=>{const g=T();if(typeof g?.getHandles!="function")return;const w=Tt(()=>g.getHandles(),null),A=w?.review;if(A){if(f){if(typeof A.setActiveReviewTarget!="function")return;const E=w?.layout;Tt(()=>A.setActiveReviewTarget({entityType:"trackedChange",entityId:f.id,...f.paintedEntityId?{paintedEntityId:f.paintedEntityId}:{},origin:"panel",layoutEpoch:typeof E?.generation=="number"?E.generation:0,story:f.story??{kind:"story",storyType:"body"}}),null);return}typeof A.getActiveReviewTarget!="function"||typeof A.clearActiveReviewTarget!="function"||Tt(()=>A.getActiveReviewTarget(),null)?.entityType==="trackedChange"&&Tt(()=>A.clearActiveReviewTarget(),void 0)}},Ge=(f,g)=>{le=f,Se+=1,xe+=1,g?.invalidateQueuedNavigation!==!1&&(re+=1)},qe=new Set;let Z=!1,S=null;const ee=new Map,D=new Set;let U=null,H=null,G=!1,te=null,Y=0,K=null,be=null,me=null;const Ce=()=>{if(G||Z)return;G=!0;const f=()=>{G=!1,Z||Dt()};typeof queueMicrotask=="function"?queueMicrotask(f):Promise.resolve().then(f)},Pe=250,it=5e3,He=f=>{Z||te&&Y<=f||(te&&clearTimeout(te),Y=f,te=setTimeout(()=>{te=null,Y=0,Z||Dt()},Math.max(0,f-Date.now())))},Ct=new WeakMap;let Yt=0;const St=f=>{if(!f)return"none";let g=Ct.get(f);return g==null&&(g=Yt+=1,Ct.set(f,g)),`e${g}`};let Ft=0,Nt={},sn=null,_n=null,Qt=0;const Ye=()=>{_n&&clearTimeout(_n),_n=null,Qt=0};let Et=f=>{},Ot=null,wn=new Set,Kt=0,Sn=null;const Pt=()=>`${St(k())}|m${Ft}`,De=()=>{Ot=null,wn=new Set},je=f=>{for(const g of["trackChanges","trackChanges:all"]){const w=ee.get(g);if(!w?.hasSettled||!Array.isArray(w.value))continue;const A=w.value.filter(E=>{const B=Gn(E);return!B||!f.has(B)});A.length!==w.value.length&&ee.set(g,{...w,value:A})}},Ke=f=>{const g=()=>{if(!Z)for(const B of[...qe])B(ut)},w=Ru(f)?f:null,A=k()?.documentMutationReadiness,E=()=>{const B=globalThis.requestAnimationFrame;return typeof B!="function"?Promise.resolve():new Promise(q=>{let oe=!1;const ve=()=>{oe||(oe=!0,clearTimeout(Re),q())},Re=setTimeout(ve,250);B(()=>B(()=>setTimeout(ve,0)))})};if(w?.success===!0&&typeof w.txId=="string"&&w.txId.length>0&&typeof A?.whenPainted=="function")try{Promise.resolve(A.whenPainted.call(A,w)).then(E,()=>{}).then(g,g);return}catch{}g()},pt=(f,g)=>{const w=ut.trackChanges,A=w.items.filter(q=>{const oe=Gn(q);return!oe||!f.has(oe)});if(A.length===w.items.length)return;le&&f.has(le.id)&&Ge(null);const E=new Set;for(const q of A){const oe=ym(q),ve=q,Re=oe.author??oe.authorEmail??ve.author??ve.authorEmail;typeof Re=="string"&&E.add(Re)}const B=w.items.length-A.length;ut={...ut,trackChanges:{...w,items:A,total:Math.max(A.length,w.total-B),activeId:w.activeId&&f.has(w.activeId)?null:w.activeId,authors:[...E]}},Ke(g)},kt=(f,g)=>{if(f.size===0)return;const w=Pt(),A=Ot===w?wn:new Set,E=new Set([...f].filter(B=>!A.has(B)));E.size!==0&&(Ot=w,wn=new Set([...A,...E]),je(wn),pt(E,g))},ft=f=>Ot===f&&wn.size>0?wn:null,an=(f,g=[])=>{const w=f.map(dl).filter(E=>E!=null&&Gn(E)!=null);if(w.length===0)return;const A=g.map(dl).map(E=>E==null?null:Gn(E)).filter(E=>E!=null);for(const E of["trackChanges","trackChanges:all"]){const B=ee.get(E),q=B?.hasSettled&&Array.isArray(B.value)?[...B.value]:[],oe=new Set;let ve=!1;for(const Re of w){const Ue=Gn(Re);if(!Ue)continue;const We=q.findIndex(Le=>Gn(Le)===Ue);if(We<0)q.push(Re),oe.add(Ue);else{const Le=q[We];q[We]=Ru(Le)?{...Le,...Re}:Re}ve=!0}if(E==="trackChanges"&&oe.size>0&&A.length>0){const Re=new Set(A.filter(Le=>oe.has(Le))),Ue=new Map(q.filter(Le=>Re.has(Gn(Le)??"")).map(Le=>[Gn(Le),Le])),We=q.filter(Le=>!Re.has(Gn(Le)??""));for(const[Le,Xe]of A.entries()){if(!Re.has(Xe))continue;const Ve=Ue.get(Xe);if(!Ve)continue;const Ze=A.slice(Le+1).map(rt=>We.findIndex(tt=>Gn(tt)===rt)).find(rt=>rt>=0);if(Ze!=null){We.splice(Ze,0,Ve);continue}const Je=A.slice(0,Le).reverse().map(rt=>We.findIndex(tt=>Gn(tt)===rt)).find(rt=>rt>=0);We.splice(Je==null?We.length:Je+1,0,Ve)}q.splice(0,q.length,...We)}ve&&ee.set(E,{token:B?.token??null,value:q,hasSettled:!0,inflightToken:null})}},qt=f=>{const g=Pt(),w=ft(g),A=f.map(dl).filter(E=>{if(E==null)return!1;const B=Gn(E);return B!=null&&!w?.has(B)});for(const E of["trackChanges","trackChanges:all"])ee.set(E,{token:g,value:[...A],hasSettled:!0,inflightToken:null})},cn=async(f,g)=>{try{const w=f.v2TrackedChanges?.listTrackedChanges;if(typeof w=="function"){const B=await Promise.resolve(w.call(f.v2TrackedChanges,{mode:g.trackedChangesListMode,refreshReason:g.refreshReason,blocking:g.blocking,...g.targetIds?.length?{targetIds:g.targetIds}:{}})),q=g.trackedChangesListMode==="all"&&g.refreshReason==="mutation-history-render-reconcile"?B?.ok===!0:B?.ok!==!1;return{ok:q,items:q&&Array.isArray(B?.items)?B.items:[],...typeof B?.complete=="boolean"?{complete:B.complete}:{},...typeof B?.sourceCoverageComplete=="boolean"?{sourceCoverageComplete:B.sourceCoverageComplete}:{}}}const A=f.docTrackChanges?.list;if(typeof A!="function")return{ok:!1,items:[]};const E=await Promise.resolve(A.call(f.docTrackChanges));return{ok:!0,items:Array.isArray(E?.items)?E.items:[]}}catch(w){return{ok:!1,items:[],failures:[w]}}},hn=z_({getContext:()=>{const f=k();if(!f)return null;const g=b(),w=y()?.trackChanges??null,A=g??w;if(!A)return null;const E=f.documentId??g?.documentId;return{editor:f,adapter:A,documentId:E==null?null:String(E),reconcileToken:Nt,v2TrackedChanges:g,docTrackChanges:w}},reconcile:async(f,g)=>{g.removedIds.size>0&&kt(new Set(g.removedIds));const w=[...new Set(g.upsertIds)];if(w.length===0)return{ok:!0,items:[],resolvedIds:[],unresolvedIds:[]};const A=ee.get("trackChanges"),E=A?.hasSettled&&Array.isArray(A.value)?A.value:null,B=new Set(E?E.map(Gn).filter(Je=>Je!=null):[]),q=E?.length===0&&vo()==="complete",oe=new Set(w.filter(Je=>!B.has(Je))),ve=f.v2TrackedChanges?.getTrackedChange,Re=f.docTrackChanges?.get;if(typeof ve!="function"&&typeof Re!="function")return{ok:!1,items:[],resolvedIds:[],unresolvedIds:w};const Ue=await Promise.all(w.map(async Je=>{try{if(typeof ve=="function"){const tt=await Promise.resolve(ve.call(f.v2TrackedChanges,Je));return{id:Je,ok:tt?.ok!==!1,items:tt?.ok!==!1&&Array.isArray(tt?.items)?tt.items:[],result:tt}}const rt=await Promise.resolve(Re.call(f.docTrackChanges,{id:Je}));return{id:Je,ok:!0,items:rt&&typeof rt=="object"?[rt]:[],result:rt}}catch(rt){return{id:Je,ok:!1,items:[],result:rt}}})),We=[],Le=[],Xe=[];for(const Je of Ue){const rt=Je.items.filter(tt=>{const Rt=dl(tt);return Rt!=null&&Gn(Rt)===Je.id});Je.ok&&rt.length>0?(We.push(...rt),Le.push(Je.id)):Xe.push(Je.id)}let Ve;const Ze=Le.filter(Je=>oe.has(Je));if(Ze.length>0&&!q){const Je=await cn(f,{trackedChangesListMode:"interaction-prime",refreshReason:"mutation-render-reconcile",blocking:!1,targetIds:Ze});Je.ok&&(Ve=Je.items)}return{ok:Xe.length===0,items:We,orderedItems:Ve,resolvedIds:Le,unresolvedIds:Xe,failures:Ue.filter(Je=>!Je.ok).map(Je=>Je.result)}},hydrate:cn,onReconciled:(f,g,w)=>{if(w?.reconcileMode==="authoritative"){if(f.reconcileToken!==Nt)return;w.ok===!0&&w.complete===!0&&w.sourceCoverageComplete===!0?(Ye(),qt(w.items??[]),sn=null):w.ok===!0?(Ye(),an(w.items??[])):Et(f.reconcileToken),Dt();return}an((w?.items??[]).filter(A=>{const E=dl(A),B=E==null?null:Gn(E);return B!=null&&g.has(B)}),w?.orderedItems??w?.items??[]),Dt()}});Et=f=>{if(Z||_n)return;const g=Math.min(Pe*2**Qt,it);Qt+=1,_n=setTimeout(()=>{_n=null,!(Z||sn===null||f!==Nt)&&hn.onRender(!0)},g)};const oo=()=>`${Pt()}|m${Wn()}|s${Kt}`,Jt=f=>JSON.stringify({t:f.target??null,s:f.selectionTarget??null}),Yn=["contentControls:inRange:","query:","effInline:"],Nr=120,io=180,vo=()=>{const f=T(),g=f?.getDocumentLoadingSnapshot;if(typeof g!="function")return"unknown";const w=Tt(()=>g.call(f),null)?.sourceStage;return w==="opening"||w==="bootstrap-ready"||w==="source-loading"?"loading":w==="source-complete"||w==="source-failed"||w==="source-cancelled"?"complete":"unknown"},$t=new Map,Bn=f=>{const g=Pt();$t.get(f)!==g&&($t.set(f,g),Ce())},xi=()=>{const f=ee.get("comments");return f?.hasSettled?Array.isArray(f.value)&&f.value.length>0:f?.inflightToken!=null},Is=(f,g)=>$t.get(f)===g,so=f=>{Bn("contentControls")},cr=()=>{const f=ee.get("trackChanges");f?.hasSettled||f?.inflightToken!=null||Bn("trackChanges")},Qo=6500,Zi=8e3,va=250;let Qi=0,hl=0,Ti=!1,ao=0,Ri=!1,_e=null;const ze=()=>{if(Z||_e)return;const f=ao||Date.now(),g=()=>{if(_e=null,Z)return;const w=Date.now()-Qi,A=_r()||w<Qo;if(A&&Date.now()-f<Zi){_e=setTimeout(g,va);return}Ti=!1,Ri=A;try{Dt()}finally{Ri=!1,ao=0}};_e=setTimeout(g,0)};let vt=null,ot=null;const xn=()=>{const f=T();if(!f||vt===f)return;ot&&(ot(),ot=null),vt=f;const g=f.subscribeDocumentLoading;if(typeof g!="function"){vt=null,jr(Qo);return}try{const w=B=>{const q=B?.sourceStage;(q==="source-complete"||q==="source-failed"||q==="source-cancelled")&&ze()},A=g.call(f,w);typeof A=="function"&&(ot=A);const E=f.getDocumentLoadingSnapshot;typeof E=="function"&&w(Tt(()=>E.call(f),null))}catch{vt=null,jr(Qo)}},Tn=()=>{const f=k()?.host,g=f?.getForegroundMutationState;if(typeof g!="function")return null;const w=Tt(()=>g.call(f),null);return{active:typeof w?.active=="number"?w.active:0,pending:typeof w?.pending=="number"?w.pending:0}},_r=()=>{const f=Tn();return!!(f&&(f.active>0||f.pending>0))},jr=(f=Nr)=>{Z||K||(K=setTimeout(()=>{if(K=null,Z)return;if(be&&_r()){jr(),Dt();return}const g=be;be=null,g===oo()&&Xr("selection",g,ml,vi),Dt()},f))},gi=(f,g)=>{if(!Tn())return!1;const w=`${f}\0${g}`;return D.has(w)?!1:(D.add(w),jr(io),!0)},Ji=f=>{if(U==null||f===U)return H?.timer&&clearTimeout(H.timer),H=null,U=f,!1;if(H?.key===f)return H.ready?(H=null,U=f,!1):!0;H?.timer&&clearTimeout(H.timer);const g={key:f,ready:!1,timer:null};return g.timer=setTimeout(()=>{Z||H!==g||(g.timer=null,g.ready=!0,Dt())},io),H=g,!0},Es=f=>V_(f),No=()=>{Mo(),Dt()};let Yr=null,Jo=!1,$i=0;const Mi=()=>{Yr=null,Jo=!1,$i+=1},lo=()=>{const f=k(),g=f?.documentMutationReadiness;if(!f||typeof g?.whenPainted!="function"||(Yr={editor:f,readiness:g,afterEpoch:typeof g.getRenderEpoch=="function"?Tt(()=>g.getRenderEpoch.call(g),null):null},Jo))return;Jo=!0;const w=$i;(async()=>{for(;!Z&&w===$i;){const E=Yr;if(Yr=null,!E){Jo=!1;return}let B=!1;try{await E.readiness.whenPainted.call(E.readiness,typeof E.afterEpoch=="number"?{afterEpoch:E.afterEpoch}:void 0),B=!0}catch{}if(Z||w!==$i)return;if(k()!==E.editor){Mi();return}B&&No()}})()},$o=()=>{me&&clearTimeout(me),me=setTimeout(()=>{me=null,Z||No()},500)},Xr=(f,g,w,A)=>{let E;try{E=w()}catch{E=void 0}if(!Tr(E)){const oe={token:g,value:A(E),hasSettled:!0,inflightToken:null,failedToken:null,failureCount:0,retryAtMs:0};return ee.set(f,oe),oe}const B=ee.get(f),q=B?.failedToken===g;return ee.set(f,{token:B?.token??null,value:B?.value??null,hasSettled:B?.hasSettled??!1,inflightToken:g,failedToken:q?g:null,failureCount:q?B.failureCount??0:0,retryAtMs:0}),Promise.resolve(E).then(oe=>{const ve=ee.get(f);!ve||ve.inflightToken!==g||(ee.set(f,{token:g,value:A(oe),hasSettled:!0,inflightToken:null,failedToken:null,failureCount:0,retryAtMs:0}),Ce())},()=>{const oe=ee.get(f);if(!oe||oe.inflightToken!==g)return;const ve=oe.failedToken===g?(oe.failureCount??0)+1:1,Re=Math.min(it,Pe*2**Math.min(ve-1,8)),Ue=Date.now()+Re;ee.set(f,{...oe,inflightToken:null,failedToken:g,failureCount:ve,retryAtMs:Ue}),He(Ue)}),null},ur=(f,g,w,A)=>{const E=ee.get(f);if(E&&E.token===g&&E.hasSettled)return{value:E.value,status:"ready"};if(CV(f)&&!Is(f,g)){if(vo()==="loading")return Ti=!0,xn(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(Ti&&!Ri)return ze(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(!Ri){const q=Date.now();if(q-hl<Qo&&(!ao||q-ao<Zi))return ao||(ao=q),Ti=!0,ze(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};ao=0}}if(_r())return jr(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(E?.failedToken===g&&E.inflightToken==null&&(E.retryAtMs??0)>Date.now())return He(E.retryAtMs),E.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(!E&&f.startsWith("effInline:")&&Ji(f))return{value:null,status:"pending"};if(!E&&gi(f,g))return{value:null,status:"pending"};if(!E||E.inflightToken!==g){const q=Xr(f,g,w,A);if(q)return{value:q.value,status:"ready"}}const B=ee.get(f);return B?.hasSettled?{value:B.value,status:"stale"}:{value:null,status:"pending"}},Li=f=>{for(const g of ee.keys())f(g)&&ee.delete(g)},pc=f=>{const g=Jt(f),w=_A(f);return new Set([`contentControls:inRange:${g}`,`query:${g}`,...w?[`effInline:${w}`]:[]])},Lu=f=>{const g=pc(f);Li(w=>Yn.some(A=>w.startsWith(A))&&!g.has(w));for(const w of D){const A=w.split("\0",1)[0];Yn.some(E=>A.startsWith(E))&&!g.has(A)&&D.delete(w)}},xs=()=>{const f=k();f!==Sn&&(Mi(),hn.reset(),Nt={},Sn=f,ee.clear(),sn=null,Ye(),te&&clearTimeout(te),te=null,Y=0,H?.timer&&clearTimeout(H.timer),H=null,U=null,C=null,o=null,be=null,D.clear(),$t.clear(),Ti=!1,ao=0,ot&&ot(),ot=null,vt=null,De())},Mo=()=>{const f=sn!==null;Ft+=1,f&&(sn=Pt()),De()},mc=f=>{if(typeof f!="string"||f.length===0)return lr("insertText requires a non-empty string.","INVALID_INPUT");if(Wn()==="viewing")return lr("The document is read-only.","DOCUMENT_READONLY");const g=y(),w=g?.insert;if(!g||typeof w!="function")return lr("insert is unavailable.");const A=g.selection?.current;if(typeof A!="function")return lr("selection.current is unavailable.");const E=q=>{const oe=q&&typeof q=="object"?q:null,ve=oe?.selectionTarget??oe?.target??null;return!ve||typeof ve!="object"?lr("insertText requires a live selection target.","PRECONDITION_FAILED"):Tt(()=>Ma(w.call(g,{type:"text",value:f,target:ve}),lr("insert failed.")),lr("insert failed."))};let B;try{B=A.call(g.selection)}catch{return lr("insertText could not resolve the live selection.","PRECONDITION_FAILED")}return Tr(B)?Promise.resolve(B).then(E,()=>lr("insertText could not resolve the live selection.","PRECONDITION_FAILED")):E(B)},ya=(f,g)=>({payload:f,state:ut,editor:k(),superdoc:t,context:g,ui:S,execute:(w,A)=>qn(w,A),executeAsync:(w,A)=>Rm(w,A),doc:y(),selection:ut.selection,documentMode:Wn(),insertText:mc}),ei=f=>f==="editing"||f==="suggesting"||f==="viewing"?f:null,Wn=()=>{const f=k(),g=t&&typeof t=="object"?t:null,w=ei(g?.config?.documentMode),A=ei(Tt(typeof g?.getActiveRuntime=="function"?()=>{const B=g.getActiveRuntime();return typeof B?.getSnapshot=="function"?B.getSnapshot():null}:void 0,null)?.documentMode),E=ei(f?.options?.documentMode);return w&&A&&w!==A?w:A??w??E},jf=()=>{const f=t&&typeof t=="object"?t:null,g=f?.interactionConfig?.comments;if(g&&typeof g.readOnly=="boolean")return g.readOnly===!0;const w=f?.config?.modules?.comments;return!!w&&typeof w=="object"&&w.readOnly===!0},Ts=()=>{const f=t&&typeof t=="object"?t:null,g=f?.interactionConfig?.comments;if(g&&typeof g.allowResolve=="boolean")return g.allowResolve===!1;const w=f?.config?.modules?.comments;return!!w&&typeof w=="object"&&w.allowResolve===!1},ti=()=>Wn()==="viewing"||jf(),vi=f=>f&&typeof f=="object"?f:null,pl=(f,g)=>{if(!f)return{...yV,status:g};const w=f.target??null,A=typeof f.text=="string"?f.text:"";return{status:g,empty:f.empty===!0,target:w,selectionTarget:f.selectionTarget??null,activeMarks:Array.isArray(f.activeMarks)?f.activeMarks:[],activeCommentIds:Array.isArray(f.activeCommentIds)?f.activeCommentIds:[],activeChangeIds:Array.isArray(f.activeChangeIds)?f.activeChangeIds:[],quotedText:A}},es=()=>{const f=y()?.selection;return ur("selection",oo(),()=>f?.current?f.current({includeText:!0}):void 0,vi)},Pu=()=>{const{value:f,status:g}=es();return pl(f,g)},ml=()=>{const f=y()?.selection;return f?.current?f.current({includeText:!0}):void 0},gl=f=>{if(f.empty!==!0)return!1;const g=f.selectionTarget,w=g?.start,A=g?.end;return w?.kind==="text"&&A?.kind==="text"&&typeof w.blockId=="string"&&w.blockId===A.blockId&&typeof w.offset=="number"&&w.offset===A.offset},Uf=f=>{const g=T(),w=g?.readLiveSelectionSyncSnapshot;if(typeof w!="function")return;const A=vi(Tt(()=>w.call(g),null));if(!A||!gl(A))return;const E=oo(),B=Tn(),q=!!(B&&(B.active>0||B.pending>0));if(q)be=E,jr();else if(be=null,Xr("selection",E,ml,vi))return;const oe=ee.get("selection"),ve=Array.isArray(A.activeMarks)&&A.activeMarks.length>0?A.activeMarks:Array.isArray(ut.selection.activeMarks)?ut.selection.activeMarks:[],Re=Array.isArray(A.activeCommentIds)?A.activeCommentIds:[],Ue=IV(f),We=ul(ut.selection),Le=Vf(A.selectionTarget)??Vf(A.target),Xe=We?.range,Ve=Le?.range,Ze=!!(B&&B.active>0&&We&&Le&&We.blockId===Le.blockId&&Cr(We.story)===Cr(Le.story)&&typeof Xe?.start=="number"&&typeof Ve?.start=="number"&&Math.abs(Ve.start-Xe.start)<=2),Je=Ue!=null||Ze?ut.selection.activeChangeIds.filter(tt=>Ue==null||pa(ut.trackChanges.items).aliasesFor(tt).includes(Ue)):[],rt=Array.isArray(A.activeChangeIds)&&A.activeChangeIds.length>0?A.activeChangeIds:Je;ee.set("selection",{token:E,value:{...A,activeMarks:ve,activeCommentIds:Re,activeChangeIds:rt},hasSettled:!0,inflightToken:q?null:oe?.inflightToken??null})},ba=async(f=0)=>{const g=y()?.selection,w=g?.current,A=oo();if(typeof w!="function")return ee.set("selection",{token:A,value:null,hasSettled:!0,inflightToken:null}),Dt(),ut.selection;let E;try{E=w.call(g,{includeText:!0}),Tr(E)&&(E=await Promise.resolve(E))}catch{E=null}return Z?pl(null,"pending"):oo()!==A?f<1?ba(f+1):ut.selection:(ee.set("selection",{token:A,value:vi(E),hasSettled:!0,inflightToken:null}),Dt(),ut.selection)},vl=f=>{const g=y()?.comments,{value:w,status:A}=ur("comments",Pt(),()=>g?.list?g.list():void 0,oe=>oe&&Array.isArray(oe.items)?oe.items:[]),E=w??[],B=f.activeCommentIds;ye&&!E.some(oe=>Gn(oe)===ye)&&(ye=null);const q=ye??B[0]??null;return{status:Iu(A,f.status),listStatus:A,items:E,total:E.length,activeIds:B,activeId:q}},ts=()=>{const f=y()?.trackChanges,g=Pt(),w=ee.get("trackChanges:all"),{value:A,status:E}=sn===g?{value:w?.hasSettled?w.value:null,status:w?.hasSettled?"stale":"pending"}:ur("trackChanges:all",g,()=>f?.list?f.list({in:"all"}):void 0,B=>(B&&Array.isArray(B.items)?B.items:[]).map(dl).filter(q=>q!=null));return E==="ready"?A:null},yi=f=>{const g=y()?.trackChanges,w=b(),A=typeof w?.listTrackedChanges=="function"?w.listTrackedChanges:null,E=Pt(),B=ft(E),q=ee.get("trackChanges"),{value:oe,status:ve}=sn===E?{value:q?.hasSettled?q.value:null,status:q?.hasSettled?"stale":"pending"}:ur("trackChanges",E,()=>A?A.call(w):g?.list?g.list({in:"all"}):void 0,en=>en&&Array.isArray(en.items)?en.items:[]),Re=(oe??[]).map(dl).filter(en=>en!=null).filter(en=>{const Mn=Gn(en);return!Mn||!B?.has(Mn)}),Ue=new Set;for(const en of Re){const Mn=ym(en),Rr=en,Ar=Mn.author??Mn.authorEmail??Rr.author??Rr.authorEmail;typeof Ar=="string"&&Ue.add(Ar)}const We=g?.list?ts():null,Le=le;Le&&(Le.story?We&&!We.some(en=>Ki(en,Le.id,Le.story))&&Ge(null):Re.some(en=>Gn(en)===Le.id)||Ge(null));const Xe=We??Re,Ve=Eu(Xe,qi(f)),Ze=B?f.activeChangeIds.filter(en=>!B.has(en)):f.activeChangeIds,Je=Ze.map(en=>Ve.toPublicId(en)??en),rt=le?.story?Eu(Xe,le.story):pa(Xe),tt=le?rt.toPublicId(le.id)??le.id:null,Rt=RV({selectionIds:Ze,publicIds:Je,selection:f,bodyItems:Re,allStoryItems:We}),Gt=tt??Rt;return{status:Iu(ve,f.status),items:Re,total:Re.length,activeId:Gt,authors:[...Ue]}},Gf=f=>{const g=y()?.contentControls,{value:w,status:A}=ur("contentControls",Pt(),()=>g?.list?g.list():void 0,oe=>oe&&Array.isArray(oe.items)?oe.items:[]),E=w??[],{ids:B,status:q}=Du(g,f);return{status:Iu(A,q,f.status),items:E,total:E.length,activeId:B[0]??null,activeIds:B}},wa=(f,g)=>{if(!f||typeof f.listInRange!="function")return{lockModesById:new Map,status:"ready"};const w=LV(g);if(!w)return{lockModesById:new Map,status:"ready"};const{value:A,status:E}=ur(`contentControls:inRange:${Jt(g)}`,Pt(),()=>f.listInRange(w),oe=>oe&&Array.isArray(oe.items)?oe.items:[]),B=A??[],q=new Map;for(const oe of B)typeof oe?.id=="string"&&q.set(oe.id,typeof oe.lockMode=="string"?oe.lockMode:"unlocked");return{lockModesById:q,status:E}},Du=(f,g)=>{const{lockModesById:w,status:A}=wa(f,g);return{ids:[...w.keys()],status:A}},Wf=()=>{const f=t?.fonts;return{options:sH(oH(Tt(f?.getDocumentFontOptions?()=>f.getDocumentFontOptions():void 0,[])),iH(Tt(f?.getFontFamilyOptions?()=>f.getFontFamilyOptions():void 0,[]))),sizeOptions:aH}},yl=()=>{const f=Tt(t?.getZoomState?()=>t.getZoomState():void 0,null),g=typeof f?.value=="number"?f.value:100,w=f?.mode;return{mode:w==="manual"||w==="fit-width"?w:w==="fixed"?"manual":null,value:g,min:typeof f?.min=="number"?f.min:10,max:typeof f?.max=="number"?f.max:100}},gc=()=>Tt(t?.getMeasurementUnit?()=>t.getMeasurementUnit():void 0,"in")==="cm"?"cm":"in",Ou=()=>{const f=k();return{ready:f!=null,mode:Wn(),dirty:f?!!f.isDirty:!1}},Ca=f=>{const g=f.quotedText;if(typeof g!="string"||g.length===0)return null;const w=Tu(f);if(w.length===0||!fc(w.map(B=>B.blockId)))return null;const A=f.target,E=w.length===1?mo(w[0].blockId,A?.story):void 0;return{select:{type:"text",pattern:g,mode:"contains",caseSensitive:!0},...E?{within:E}:{},require:"any"}},yo=f=>{const g=y()?.query;if(typeof g?.match!="function")return null;const w=Ca(f);if(!w)return null;const{value:A}=ur(`query:${Jt(f)}`,Pt(),()=>g.match(w),E=>E&&typeof E=="object"?E:null);return SA(A,f)},bl=f=>{const g=T(),w=new Set(Fr(f));if(w.size===0)return{};const A=g?.readMountedProjectionBlocksByIds,E=g?.readMountedProjectionBlocks;if(typeof A!="function"&&typeof E!="function")return{};const B=Tt(()=>{if(typeof A!="function")return E.call(g);const Ze=Yi(f);return Ze?A.call(g,[...w],Ze):A.call(g,[...w])},null);if(!Array.isArray(B))return{};const q=fb(B),oe=Ze=>{const Je={},rt=ub(Ze.fontFamily);rt&&(Je.fontFamily=rt);const tt=UV(Ze.fontSize);return tt&&(Je.fontSize=tt),typeof Ze.color=="string"&&Ze.color.trim()!==""&&(Je.color=Ze.color.trim().toUpperCase()),typeof Ze.highlight=="string"&&Ze.highlight.trim()!==""&&(Je.highlight=Ze.highlight.trim().toUpperCase()),Je},ve=ul(f),Re=ve&&typeof ve.range?.start=="number"?ve.range.start:null;if(ve&&Re!==null&&w.has(ve.blockId)){const Ze=q.find(rt=>hc(rt,ve.blockId)),Je=Ze&&Array.isArray(Ze.runs)?Ze.runs:null;if(Je&&Je.length>0&&Je.every(rt=>rt?.kind==="text"||rt?.kind==="tab")){let rt=0,tt=null;for(const Rt of Je){const Gt=typeof Rt.text=="string"?Rt.text.length:0;if(Re>=rt&&Re<rt+Gt){tt=Rt;break}rt+=Gt}if(!tt){for(let Rt=Je.length-1;Rt>=0&&!tt;Rt-=1)Je[Rt]?.kind==="text"&&(tt=Je[Rt]);tt??=Je[Je.length-1]??null}return tt?oe(tt):{}}}const Ue=Tu(f);if(Ue.length>0){const Ze=new Set,Je=new Set;let rt=!1,tt=!0;for(const Rt of Ue){const Gt=q.find(Rr=>hc(Rr,Rt.blockId));if(!Gt)return{};const en=Array.isArray(Gt.runs)?Gt.runs:[];if(en.length===0)continue;if(!en.every(Rr=>Rr?.kind==="text"||Rr?.kind==="tab")){tt=!1;break}let Mn=0;for(const Rr of en){const Ar=typeof Rr.text=="string"?Rr.text.length:0,zr=Mn,Mr=Mn+Ar;if(zr<Rt.end&&Mr>Rt.start){rt=!0;const Uo=oe(Rr);Uo.fontFamily&&Ze.add(Uo.fontFamily),Uo.fontSize&&Je.add(Uo.fontSize)}Mn=Mr}}if(tt&&rt){const Rt={};return Ze.size===1&&(Rt.fontFamily=[...Ze][0]),Je.size===1&&(Rt.fontSize=[...Je][0]),Rt}}const We=new Set,Le=new Set;let Xe=!1;for(const Ze of q){if(![...w].some(rt=>hc(Ze,rt)))continue;const Je=Array.isArray(Ze.runs)?Ze.runs:[];for(const rt of Je){if(rt?.kind!=="text")continue;Xe=!0;const tt=oe(rt);tt.fontFamily&&We.add(tt.fontFamily),tt.fontSize&&Le.add(tt.fontSize)}}if(!Xe)return{};const Ve={};return We.size===1&&(Ve.fontFamily=[...We][0]),Le.size===1&&(Ve.fontSize=[...Le][0]),Ve},Rs=f=>{const g=T(),w=new Set(Fr(f));if(w.size===0)return{};const A=g?.readMountedProjectionBlocksByIds,E=g?.readMountedProjectionBlocks;if(typeof A!="function"&&typeof E!="function")return{};const B=Tt(()=>{if(typeof A!="function")return E.call(g);const Ve=Yi(f);return Ve?A.call(g,[...w],Ve):A.call(g,[...w])},null);if(!Array.isArray(B))return{};const q=fb(B),oe=Ve=>({bold:Ve.bold===!0,italic:Ve.italic===!0,underline:Ve.underline!=null,strikethrough:Ve.strike===!0}),ve=Ve=>{const Ze={};for(const Je of Hf){const rt=Ve[Je];rt.size===1&&(Ze[Je]=[...rt][0])}return Ze},Re=ul(f),Ue=Re&&typeof Re.range?.start=="number"?Re.range.start:null;if(Re&&Ue!==null&&w.has(Re.blockId)){const Ve=q.find(Je=>hc(Je,Re.blockId)),Ze=Ve&&Array.isArray(Ve.runs)?Ve.runs:null;if(Ze&&Ze.length>0&&Ze.every(Je=>Je?.kind==="text"||Je?.kind==="tab")){let Je=0,rt=null;for(const tt of Ze){const Rt=typeof tt.text=="string"?tt.text.length:0;if(Ue>=Je&&Ue<Je+Rt){rt=tt;break}Je+=Rt}if(!rt){for(let tt=Ze.length-1;tt>=0&&!rt;tt-=1)Ze[tt]?.kind==="text"&&(rt=Ze[tt]);rt??=Ze[Ze.length-1]??null}return rt?oe(rt):{}}}const We=Tu(f);if(We.length>0){const Ve={bold:new Set,italic:new Set,underline:new Set,strikethrough:new Set};let Ze=!1,Je=!0;for(const rt of We){const tt=q.find(en=>hc(en,rt.blockId));if(!tt)return{};const Rt=Array.isArray(tt.runs)?tt.runs:[];if(Rt.length===0)continue;if(!Rt.every(en=>en?.kind==="text"||en?.kind==="tab")){Je=!1;break}let Gt=0;for(const en of Rt){const Mn=typeof en.text=="string"?en.text.length:0,Rr=Gt,Ar=Gt+Mn;if(Rr<rt.end&&Ar>rt.start){Ze=!0;const zr=oe(en);for(const Mr of Hf)Ve[Mr].add(zr[Mr])}Gt=Ar}}if(Je&&Ze)return ve(Ve)}const Le={bold:new Set,italic:new Set,underline:new Set,strikethrough:new Set};let Xe=!1;for(const Ve of q){if(![...w].some(Je=>hc(Ve,Je)))continue;const Ze=Array.isArray(Ve.runs)?Ve.runs:[];for(const Je of Ze){if(Je?.kind!=="text")continue;Xe=!0;const rt=oe(Je);for(const tt of Hf)Le[tt].add(rt[tt])}}return Xe?ve(Le):{}},vc=(f,g)=>{if(g.fontFamily!==void 0&&g.fontSize!==void 0&&g.color!==void 0&&g.highlight!==void 0)return{values:g,effectiveUniformityStatus:"ready"};const w=bl(f),A={...w.fontFamily!==void 0?{fontFamily:w.fontFamily}:{},...w.fontSize!==void 0?{fontSize:w.fontSize}:{},...w.color!==void 0?{color:w.color}:{},...w.highlight!==void 0?{highlight:w.highlight}:{},...g};if(!f.empty&&(A.fontFamily===void 0||A.fontSize===void 0)){const E=ns(f);return E.values&&(A.fontFamily===void 0&&E.values.fontFamily!==void 0&&(A.fontFamily=E.values.fontFamily),A.fontSize===void 0&&E.values.fontSize!==void 0&&(A.fontSize=E.values.fontSize)),{values:A,effectiveUniformityStatus:E.status}}return{values:A,effectiveUniformityStatus:"ready"}},Fu=["fontFamily","fontSize","bold","italic","underline","strikethrough"],bo=f=>{const g=f.selectionTarget;if(!g)return{value:null,status:"ready"};const w=vr(y(),"format.readEffectiveInlineUniformity");return w?ur(`effInline:${_A(f)??Jt(f)}`,Pt(),()=>w({target:g,offsetSpace:"selection",keys:Fu}),A=>A&&typeof A=="object"?A:null):{value:null,status:"ready"}},ns=f=>{const{value:g,status:w}=bo(f);if(!g||g.success!==!0)return{values:null,status:w};const A=g.values,E=B=>{const q=A?.[B];if(!(!q||q.state!=="uniform"||typeof q.value!="string"))return B==="fontFamily"?ub(q.value):q.value};return{values:{fontFamily:E("fontFamily"),fontSize:E("fontSize")},status:w}},Nu=f=>{const{value:g,status:w}=bo(f);if(!g||g.success!==!0)return{values:null,status:w};const A=g.values,E={};for(const B of Hf){const q=A?.[B];q?.state==="uniform"&&(q.value==="true"||q.value==="false")&&(E[B]=q.value==="true")}return{values:E,status:w}},yc=(f,g)=>{const w=f.activeMark;if(!w||!Hf.includes(w))return null;const A=w,E=Rs(g)[A];if(E!==void 0)return E;const{values:B}=Nu(g),q=B?.[A];return q!==void 0?q:null},Bu=async f=>{const g=f.selectionTarget;if(!g)return null;const w=vr(y(),"format.readEffectiveInlineUniformity");if(!w)return null;try{const A=await Promise.resolve(w({target:g,offsetSpace:"selection"}));return A&&typeof A=="object"&&A.success===!0?A:null}catch{return null}},bc=(f,g,w)=>{const A=w.values;for(const E of["fontFamily","fontSize"]){if(g[E]!==void 0)continue;const B=A?.[E];B?.state==="uniform"&&typeof B.value=="string"?f[E]=E==="fontFamily"?ub(B.value):B.value:delete f[E]}},Ms=f=>vc(f,kA(yo(f),f)),ni=f=>Ms(f).values,zu=async f=>{const g=y()?.query,w=Ca(f);if(typeof g?.match!="function"||!w)return ni(f);try{const A=await Promise.resolve(g.match(w)),E=kA(SA(A&&typeof A=="object"?A:null,f),f),B=vc(f,E);if(B.effectiveUniformityStatus!=="ready"&&(E.fontFamily===void 0||E.fontSize===void 0)){const q=await Bu(f);q&&bc(B.values,E,q)}return B.values}catch{return ni(f)}},wl=async f=>{const g=y();if(g)return typeof g.getNode=="function"?await Promise.resolve(g.getNode(f)):await Promise.resolve(g.getNodeById?.({nodeId:f.nodeId,nodeType:f.nodeType}))},Vu=f=>{const g=y()?.query;if(typeof g?.match!="function")return"ready";const w=Ca(f);if(!w)return"ready";const{status:A}=ur(`query:${Jt(f)}`,Pt(),()=>g.match(w),E=>E&&typeof E=="object"?E:null);return A},wc=f=>{const g=Ms(f),w=g.values;if(f.empty)return g;const A=ga(f);return A?f.status==="ready"&&Vu(f)==="ready"&&g.effectiveUniformityStatus==="ready"?(C={key:A,values:w},g):C&&C.key===A?{...g,values:{...C.values,...w}}:g:g},_a=f=>{const g=y(),w=wc(f),A=w.values;f.status==="ready"&&!f.empty&&Vu(f)==="ready"&&w.effectiveUniformityStatus==="ready"&&(v=A,_=`${uc(f)}:${Pt()}`);const E=g?.contentControls,{lockModesById:B}=wa(E,f),q={};for(const oe of Te())q[oe]=_l(oe,g,f,A,B);return q},rs=f=>f?lt.operationUnavailable:k()?lt.documentApiUnavailable:lt.notReady,Cl=f=>f==="contentLocked"||f==="sdtContentLocked",Pi=f=>{for(const g of f.values())if(Cl(g))return lt.contentControlLocked},Kf=(f,g,w,A,E)=>{if(!g)return f.scope==="all"?lt.bulkDecisionsDisabled:rs(E);if(w)return lt.documentReadonly;if(f.scope!=="all"&&A.activeChangeIds.length===0)return lt.selectionRequired},qf=f=>{const g=T(),w=Tt(typeof g?.getCapabilities=="function"?()=>g.getCapabilities():void 0,null)?.editableSubset?.commands;if(Array.isArray(w))return w.find(A=>A?.command===f||A?.id===f)??null;if(w&&typeof w=="object"){const A=w[f];return A&&typeof A=="object"?A:null}return null},Cc=(f,g)=>{if(f.scope!=="all"||typeof g?.[`${f.kind}All`]=="function")return;const w=qf(`trackedChanges.${f.kind}All`);if(!(w&&(w.status==="supported"||w.enabled===!0)))return lt.bulkDecisionsDisabled},_l=(f,g,w,A,E=new Map)=>{if(fe.has(f))return on({supported:!0,enabled:!0,...Tt(fe.get(f).getState?()=>fe.get(f).getState(ya(void 0)):void 0,{})},"custom");const B=Wn()==="viewing",q=hA(f);if(q&&typeof x()?.lists?.apply=="function"){const Xe=J(),Ve=typeof Xe?.shippedStatus=="string"?Xe.shippedStatus:null,Ze=Ve!=="not-shipped"&&Ve!=="disabled";return on({enabled:Ze&&(typeof Xe?.enabled=="boolean"?Xe.enabled:!0),active:(Ze?X(Xe):null)===q,supported:Ze,value:Xe?.value},"builtin")}const oe=wm(f);if(oe){const Xe=g?.trackChanges,Ve=typeof Xe?.decide=="function"||typeof Xe?.[oe.kind]=="function",Ze=typeof Xe?.decide=="function"||typeof Xe?.[`${oe.kind}All`]=="function",Je=oe.scope==="all"?Ze:Ve,rt=Cc(oe,Xe)??Kf(oe,Je,ti(),w,g);return on({enabled:rt==null,active:!1,supported:Je,reason:rt},"builtin")}if(f==="copy-format")return Wn()==="viewing"?on({supported:!0,enabled:!1,active:!1},"builtin"):k()?on({supported:!0,enabled:!0,active:h.mode!=="idle"},"builtin"):on({supported:!0,enabled:!1,active:!1,reason:lt.notReady},"builtin");const ve=Su(f);if(!ve)return on({enabled:!1,active:!1,supported:!1,reason:lt.commandUnsupported},"unsupported");if(ve.disposition!=="routed")return on({enabled:!1,active:!1,supported:!1,reason:ve.reason??lt.commandUnsupported},ve.disposition==="unsupported"?"unsupported":"builtin");if(ve.instanceRoute)return ie(ve);if(ve.table)return de(ve,g,B);if(ve.inline?.kind==="clear"){if(ve.mutates&&B)return on({enabled:!1,active:!1,supported:!0,reason:lt.documentReadonly},"builtin");const Xe=Pi(E);if(Xe)return on({enabled:!1,active:!1,supported:!0,reason:Xe},"builtin");const Ve=Fr(w).length>0||Mu(w)!=null;return on({enabled:Ve,active:!1,supported:!0,reason:Ve?void 0:lt.selectionRequired},"builtin")}const Re=ve.docRoute;if(!Re)return on({enabled:!1,active:!1,supported:!1,reason:lt.commandUnsupported},"unsupported");if(vr(g,Re)==null)return on({enabled:!1,active:!1,supported:!1,reason:rs(g)},"builtin");const Ue=ae(f);if(Ue){const Xe=Ue.shippedStatus,Ve=Xe!=="not-shipped"&&Xe!=="disabled",Ze=typeof Ue.enabled=="boolean"?Ue.enabled:!0,Je=f==="undo"||f==="redo",rt=Je&&Ue.historyResolved===!1,tt=Je&&Ve&&Ze===!1&&Ue.reason===null&&!rt,Rt=Ue.reason===void 0?void 0:tt?lt.historyEmpty:rt?lt.notReady:ib(Ue.reason,lt.commandUnsupported);return ve.mutates&&B?on({enabled:!1,active:!1,supported:Ve,reason:lt.documentReadonly},"builtin"):on({enabled:Ve&&Ze,active:!1,supported:Ve,reason:Rt},"builtin")}const We=Sa(ve,g,w),Le=ju(ve,g,w,A);if(ve.list?.mode==="indent"||ve.list?.mode==="outdent")return I(ve,g,B,w,We,Le);if(ve.list?.mode==="toggle-seed")return M(ve,g,B,w,We,Le);if(ve.mutates&&B)return on({enabled:!1,active:We,supported:!0,value:Le,reason:lt.documentReadonly},"builtin");if(ve.inline&&!Mu(w)){const Xe=Pi(E);return on(Xe?{enabled:!1,active:We,supported:!0,value:Le,reason:Xe}:Fr(w).length>0&&typeof T()?.setPendingInlineFormat=="function"?{enabled:!0,active:We,supported:!0,value:Le}:{enabled:!1,active:We,supported:!0,value:Le,reason:lt.rangeSelectionRequired},"builtin")}if((ve.blockParagraph||ve.list)&&Fr(w).length===0)return on({enabled:!1,active:We,supported:!0,value:Le,reason:lt.selectionRequired},"builtin");if(ve.link&&!We&&lb(w).length===0&&!ul(w))return on({enabled:!1,active:We,supported:!0,reason:lt.rangeSelectionRequired},"builtin");if(ve.inline){const Xe=Pi(E);if(Xe)return on({enabled:!1,active:We,supported:!0,value:Le,reason:Xe},"builtin")}return on({enabled:!0,active:We,supported:!0,value:Le},"builtin")};function Hu(f,g){const w=f.address?.anchor,A=w?.start,E=w?.end,B=typeof A?.blockId=="string"?A.blockId:null,q=typeof E?.blockId=="string"?E.blockId:null;if(!B||!q)return!1;const oe=typeof A?.offset=="number"?A.offset:null,ve=typeof E?.offset=="number"?E.offset:null;if(oe==null||ve==null)return!1;const Re=g.target,Ue=Re&&Array.isArray(Re.segments)?Re.segments:[];for(const We of Ue){const Le=typeof We?.blockId=="string"?We.blockId:null;if(!Le)continue;const Xe=We.range,Ve=typeof Xe?.start=="number"?Xe.start:null,Ze=typeof Xe?.end=="number"?Xe.end:null;if(!(Ve==null||Ze==null)){if(B!==q){if(Le===B&&Ze>oe||Le===q&&Ve<ve)return!0;continue}if(Le===B){if(Ve===Ze){if(Ve>=oe&&Ve<=ve)return!0;continue}if(Math.max(Ve,oe)<Math.min(Ze,ve))return!0}}}return!1}const Sl=(f,g)=>{const w=f?.hyperlinks;if(!w||typeof w.list!="function")return null;const A=Fr(g);if(!fc(A))return null;for(const E of A){const B={kind:"block",nodeType:"paragraph",nodeId:E},{value:q}=ur(`hyperlinks:${E}`,Pt(),()=>w.list({within:B}),ve=>ve&&typeof ve=="object"?ve:null),oe=(q&&Array.isArray(q.items)?q.items:[]).find(ve=>Hu(ve,g));if(oe)return oe}return null},Sa=(f,g,w)=>{if(f.link)return Sl(g,w)!=null;if(f.list?.mode==="toggle-seed"&&f.list.seed)return Uu(g,w)===f.list.seed;const A=j(f);if(A!==null)return A;const E=r.get(f.id),B=ga(w);if(B&&E?.selectionSignature===B)return E.active;const q=yc(f,w);return q!==null?q:lH(f,w)},ju=(f,g,w,A)=>{if(f.inline&&cb(f.inline.key)){const E=O(f);if(E!==void 0)return E;const B=A[f.inline.key];if(B!==void 0)return B;const q=ga(w),oe=q?n.get(f.inline.key):void 0;if(q&&oe?.selectionSignature===q)return oe.value}if(f.id==="linked-style"){const{style:E}=nt(w,ct().cache);return!E.styleId||E.mixed?void 0:{styleId:E.styleId,styleName:E.styleName}}if(f.id==="text-align")return Lo(g,w);if(f.id==="link")return $(g,w)??void 0},kl=(f,g,w)=>{const A=f?.lists;if(!A)return{value:null,status:"ready"};const E=w.storyType==="body",B=typeof A.getStateInStory=="function"?()=>A.getStateInStory({target:ma(g),story:w}):E&&typeof A.getState=="function"?()=>A.getState({target:ma(g)}):null;if(!B)return{value:null,status:"ready"};const{value:q,status:oe}=ur(`lists:${Cr(w)}:${g}`,Pt(),B,ve=>ve&&typeof ve=="object"?ve:null);return{value:q?.success===!0?q:null,status:oe}},Yf=(f,g,w)=>kl(f,g,w).value,Al=(f,g,w)=>{const A=Yf(f,g,w);return!A||A.isListItem!==!0?null:A.seed==="bullet"||A.seed==="ordered"?A.seed:null},Il=(f,g,w)=>{const A=kl(f,g,w),E=A.value;return{value:E&&typeof E.isListItem=="boolean"?E.isListItem:null,status:A.status}},Uu=(f,g)=>{const w=Fr(g);if(w.length===0||!fc(w))return null;const A=qi(g),E=Al(f,w[0],A);if(E!=="bullet"&&E!=="ordered")return null;for(const B of w.slice(1))if(Al(f,B,A)!==E)return null;return E},Gu=(f,g,w)=>{if(!f)return{value:null,status:"ready",refreshing:!1};const A=Cr(w),E=A==="story:body";if(E&&typeof f.getNodeById!="function")return{value:null,status:"ready",refreshing:!1};if(!E&&typeof f.getNode!="function")return{value:null,status:"ready",refreshing:!1};const B=`node:${A}:${g}`,q=Pt(),oe=ur(B,q,()=>E?f.getNodeById({nodeId:g,nodeType:"paragraph"}):f.getNode(mo(g,w)),Re=>Re&&typeof Re=="object"?Re:null),ve=ee.get(B);return{...oe,refreshing:oe.status==="stale"&&ve?.inflightToken===q&&ve.failedToken!==q}},El=f=>f==="left"||f==="center"||f==="right"||f==="justify"?f:void 0,Xf=f=>f==="start"||f==="end"||f==="distributed"||f==="numTab"||f==="lowKashida"||f==="mediumKashida"||f==="highKashida"||f==="thaiDistribute",_c=(f,g)=>{const w=T(),A=w?.readMountedProjectionBlocksByIds;if(typeof A!="function")return null;const E=Yi(f),B=Tt(()=>E?A.call(w,[...g],E):A.call(w,[...g]),null);if(!Array.isArray(B))return new Map;const q=fb(B),oe=new Map;for(const ve of g){const Re=q.find(Xe=>hc(Xe,ve));if(!Re)continue;const Ue=Re.attrs,We=El(Ue?.alignment),Le=_9(Ue);oe.set(ve,We??(Le==="rtl"?"right":"left"))}return oe},xl=(f,g,w,A)=>{const{value:E,status:B,refreshing:q}=Gu(f,g,w),oe=A?.get(g);if(B==="pending")return oe?{status:"uniform",value:oe}:{status:"pending"};if(B==="stale"&&!q)return{status:"pending"};if(B==="stale"&&oe)return{status:"uniform",value:oe};if(B==="stale"&&A&&!oe)return{status:"unavailable"};if(!E)return{status:"unavailable"};const ve=E.node;if(!ve)return{status:"unavailable"};const Re=ve.kind;if(Re!=="paragraph"&&Re!=="heading")return{status:"unavailable"};const Ue=ve[Re];if(!Ue||typeof Ue!="object")return{status:"unavailable"};const We=Ue.props?.alignment;if(We==null)return oe?{status:"uniform",value:oe}:{status:"unavailable"};const Le=El(We);return Le?{status:"uniform",value:Le}:Xf(We)&&oe?{status:"uniform",value:oe}:{status:"unavailable"}},Zf=(f,g)=>{const w=Fr(g);if(w.length===0||!fc(w))return{status:"unavailable"};const A=qi(g),E=_c(g,w),B=xl(f,w[0],A,E);if(B.status!=="uniform")return B;for(const q of w.slice(1)){const oe=xl(f,q,A,E);if(oe.status!=="uniform")return oe;if(oe.value!==B.value)return{status:"mixed"}}return B},Ls=f=>{const g=Fr(f);return g.length===0?null:`${Cr(qi(f))}:${g.join(",")}`},Lo=(f,g)=>{const w=Zf(f,g),A=w.status==="uniform"?w.value:void 0,E=o;if(!E)return A;const B=Ls(g);return B&&B!==E.selectionSignature?(o=null,A):!B||!E.settled?E.value:w.status!=="pending"?(o=null,A):E.value},ri=(f,g)=>{const w=El(g),A=Ls(f),E=Fr(f);if(!w||!A||E.length===0)return null;const B=++i;return o={selectionSignature:A,value:w,generation:B,settled:!1,canReconcile:fc(E)},Dt(),B},Wu=(f,g)=>{if(f==null)return;const w=o;if(!(!w||w.generation!==f)){if(!go(g)){o=null;return}if(!w.canReconcile){o=null;return}w.settled=!0}},Sc=async(f,g,w)=>{const A=f?.lists;if(!A)return null;try{const E=w.storyType==="body",B=typeof A.getStateInStory=="function"?await A.getStateInStory({target:ma(g),story:w}):E&&typeof A.getState=="function"?await A.getState({target:ma(g)}):null,q=B&&typeof B=="object"?B:null;return!q||q.success!==!0||typeof q.isListItem!="boolean"?null:q.isListItem}catch{return null}},kc=(f,g,w)=>{const A={resolved:!1,seed:null},E=f?.lists;if(!E)return A;const B=w.storyType==="body",q=typeof E.getStateInStory=="function"?()=>E.getStateInStory({target:ma(g),story:w}):B&&typeof E.getState=="function"?()=>E.getState({target:ma(g)}):null;if(!q)return A;const oe=ve=>{const Re=ve&&typeof ve=="object"?ve:null;return!Re||Re.success!==!0||typeof Re.isListItem!="boolean"?A:{resolved:!0,seed:Re.isListItem===!0&&(Re.seed==="bullet"||Re.seed==="ordered")?Re.seed:null}};try{const ve=q();return Tr(ve)?Promise.resolve(ve).then(oe,()=>A):oe(ve)}catch{return A}},Qf=async(f,g,w)=>{if(!f)return null;try{const A=!w||w.storyType==="body",E=w&&typeof f.getNode=="function"?await f.getNode(mo(g,w)):A&&typeof f.getNodeById=="function"?await f.getNodeById({nodeId:g,nodeType:"paragraph"}):null;return DV(E&&typeof E=="object"?E:null)}catch{return null}},I=(f,g,w,A,E,B)=>{if(f.mutates&&w)return on({enabled:!1,active:E,supported:!0,value:B,reason:lt.documentReadonly},"builtin");const q=Fr(A);if(q.length===0)return on({enabled:!1,active:E,supported:!0,value:B,reason:lt.selectionRequired},"builtin");const oe=f.docRoute?vr(g,f.docRoute):null,ve=vr(g,"format.paragraph.setIndentation"),Re=vr(g,"format.paragraph.clearIndentation"),Ue=f.list?.mode,We=Ue==="indent"?ve!=null:ve!=null||Re!=null,Le=qi(A);let Xe=null;if(Le.storyType!=="body"){Xe=[];for(const Ve of q){const{value:Ze,status:Je}=Il(g,Ve,Le);if(Ze===null)return Je!=="ready"&&(oe!=null||We)?on({enabled:!0,active:E,supported:!0,value:B},"builtin"):on({enabled:!1,active:E,supported:!1,value:B,reason:rs(g)},"builtin");Xe.push(Ze)}}if(Xe?.some(Ve=>Ve===!0)){const Ve=Ue==="indent"?"lists.indentRange":"lists.outdentRange",Ze=Wn()!=="suggesting"&&Xe.every(rt=>rt===!0)&&vr(g,Ve)!=null,Je=Ue==="outdent"&&vr(g,"lists.outdentInStory")!=null;if(!Ze&&!Je)return on({enabled:!1,active:E,supported:!1,value:B,reason:rs(g)},"builtin")}for(const[Ve,Ze]of q.entries()){const Je=Xe?{value:Xe[Ve]??null,status:"ready"}:Il(g,Ze,Le),rt=Je.value;if(rt===!0){if(oe!=null)return on({enabled:!0,active:E,supported:!0,value:B},"builtin");continue}if(rt===!1&&We){if(Le.storyType!=="body"&&typeof g?.getNode!="function")continue;return on({enabled:!0,active:E,supported:!0,value:B},"builtin")}if(rt===null)return Je.status!=="ready"&&(oe!=null||We)?on({enabled:!0,active:E,supported:!0,value:B},"builtin"):on({enabled:!1,active:E,supported:!1,value:B,reason:rs(g)},"builtin")}return on({enabled:!1,active:E,supported:!1,value:B,reason:rs(g)},"builtin")},M=(f,g,w,A,E,B)=>{if(f.mutates&&w)return on({enabled:!1,active:E,supported:!0,value:B,reason:lt.documentReadonly},"builtin");const q=Fr(A);if(q.length===0)return on({enabled:!1,active:E,supported:!0,value:B,reason:lt.selectionRequired},"builtin");const oe=qi(A),ve=g?.lists;if(!(typeof ve?.getStateInStory=="function"||oe.storyType==="body"&&typeof ve?.getState=="function"))return on({enabled:!1,active:E,supported:!1,value:B,reason:lt.operationUnavailable},"builtin");if(!fc(q))return on(oe.storyType==="body"&&vr(g,"lists.remove")!=null?{enabled:!0,active:E,supported:!0,value:B}:{enabled:!1,active:E,supported:!1,value:B,reason:lt.operationUnavailable},"builtin");const Re=q.map(Xe=>kl(g,Xe,oe));if(Re.some(({status:Xe})=>Xe!=="ready"))return on({enabled:!0,active:E,supported:!0,value:B},"builtin");if(Re.some(({value:Xe})=>Xe===null))return on({enabled:!1,active:E,supported:!1,value:B,reason:lt.operationUnavailable},"builtin");const Ue=f.list?.seed,We=Re.every(({value:Xe})=>Xe?.isListItem===!0&&Xe.seed===Ue);if(oe.storyType==="body")return on(!We||vr(g,"lists.remove")!=null?{enabled:!0,active:E,supported:!0,value:B}:{enabled:!1,active:E,supported:!1,value:B,reason:lt.operationUnavailable},"builtin");const Le=vr(g,"lists.removeInStory");return on(We&&Le?{enabled:!0,active:E,supported:!0,value:B}:{enabled:!1,active:E,supported:!1,value:B,reason:lt.operationUnavailable},"builtin")},$=(f,g)=>{const w=Sl(f,g)?.properties?.href;return typeof w=="string"?w:null},ie=f=>{if(!k())return on({enabled:!1,active:!1,supported:!1,reason:lt.notReady},"builtin");const g=f.instanceRoute;return typeof t?.[g]!="function"?on({enabled:!1,active:!1,supported:!1,reason:lt.operationUnavailable},"builtin"):on({enabled:!0,active:se(f),supported:!0,value:he(f)},"builtin")},se=f=>{const g=t?.config??void 0;return f.valueFrom==="ruler"?!!g?.rulers:f.valueFrom==="formattingMarks"?!!g?.layoutEngineOptions?.showFormattingMarks:!1},de=(f,g,w)=>{if(w)return on({enabled:!1,active:!1,supported:!0,reason:lt.documentReadonly},"builtin");const A=Fe();return A!=null&&(!f.table.requiresCell||A.cellNodeId!=null)?(f.docRoute?vr(g,f.docRoute):null)==null?on({enabled:!1,active:!1,supported:!1,reason:rs(g)},"builtin"):on({enabled:!0,active:!1,supported:!0},"builtin"):on({enabled:!1,active:!1,supported:!0,reason:lt.tableContextUnavailable},"builtin")},he=f=>{if(f.valueFrom==="zoom")return yl().value;if(f.valueFrom==="documentMode")return Wn();if(f.valueFrom==="measurementUnit")return gc();if(f.valueFrom==="ruler"||f.valueFrom==="formattingMarks")return se(f)},ue=(f,g)=>f.id==="zoom"?typeof g=="number"&&Number.isFinite(g)&&g>0:f.id==="document-mode"?g==="editing"||g==="suggesting"||g==="viewing":f.id==="measurement-unit"?g==="in"||g==="cm":!0,Te=()=>[...new Set([...yN,...fe.keys()])],Ne="Normal",Oe={ready:!1,status:"ready",catalogRevision:null,quickGallery:[],activeParagraphStyleId:null,activeParagraphStyleName:null,mixedSelection:!1,sourceStatus:null,diagnostics:[]},Qe=f=>{const g=y()?.styles;return!g||typeof g.getCatalog!="function"?{value:null,status:"ready"}:ur(`styles:catalog:${JSON.stringify(f??{})}`,Pt(),()=>g.getCatalog(f),w=>w&&typeof w=="object"?w:null)},ct=()=>{const f=Qe({includePreview:!0});if(!f.value)return{cache:null,status:f.status};const g=Qe({view:"quickGallery",includePreview:!0}),w=g.value?g.value.items:f.value.styles.filter(E=>E.visibility.quickGallery),A=new Map;for(const E of f.value.styles)A.set(E.id,E);return{cache:{full:f.value,quickGallery:w,byId:A},status:Iu(f.status,g.status)}},yt=(f,g,w)=>{const{value:A,status:E}=Gu(f,g,w);if(!A)return{ok:!1,styleRef:null,status:E};const B=A.node;if(!B||typeof B!="object")return{ok:!1,styleRef:null,status:E};const q=B.kind,oe=typeof q=="string"?B[q]:void 0,ve=oe&&typeof oe=="object"?oe.styleRef:void 0;return{ok:!0,styleRef:typeof ve=="string"&&ve.length>0?ve:null,status:E}},nt=(f,g)=>{const w=[],A=y();if(!A)return w.push({severity:"warning",code:"active-style-unavailable",message:"Active paragraph style is unavailable: the Document API is not reachable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:w},status:"ready"};const E=Fr(f);if(E.length===0)return w.push({severity:"info",code:"active-style-no-selection",message:"No paragraph block is resolvable from the current selection; active paragraph style is unavailable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:w},status:"ready"};if(!fc(E))return w.push({severity:"info",code:"active-style-selection-too-large",message:"Active paragraph style is unavailable for a large multi-paragraph selection."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:w},status:"ready"};const B=g?.full.defaults.paragraphStyleId??(g?Ne:null),q=new Set;let oe=0,ve=0,Re=0,Ue="ready";const We=qi(f);for(const Ve of E){const Ze=yt(A,Ve,We);if(Ue=Iu(Ue,Ze.status),!Ze.ok){ve+=1;continue}if(!Ze.styleRef&&!B){Re+=1;continue}const Je=Ze.styleRef??B;if(!Je){Re+=1;continue}oe+=1,q.add(Je)}if(oe===0){const Ve=Re>0&&ve===0;return w.push({severity:"warning",code:Ve?"active-style-default-unavailable":"active-style-read-failed",message:Ve?"Selected paragraphs have no explicit style and the style catalogue is unavailable, so the document default cannot be resolved.":"Could not read the paragraph style of any selected block; active paragraph style is unavailable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:w},status:Ue}}const Le=ve+Re;if(Le>0)return w.push({severity:"warning",code:"active-style-partial",message:`Active paragraph style resolved from ${oe} of ${oe+Le} selected blocks; ${Le} could not be read, so the active style is unavailable.`}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:w},status:Ue};if(q.size>1)return{style:{styleId:null,styleName:null,mixed:!0,diagnostics:w},status:Ue};const Xe=[...q][0];return{style:{styleId:Xe,styleName:g?.byId.get(Xe)?.name??null,mixed:!1,diagnostics:w},status:Ue}},ln=f=>{if(!k())return Oe;const{cache:g,status:w}=ct(),{style:A,status:E}=nt(f,g);let B;return g?B=A.diagnostics.length===0?g.full.diagnostics:[...g.full.diagnostics,...A.diagnostics]:B=[{severity:"warning",code:"catalog-unavailable",message:"The style catalogue is unavailable: the Document API styles surface is not reachable (e.g. viewing mode or a worker-backed editor)."},...A.diagnostics],{ready:!0,status:Iu(w,E,f.status),catalogRevision:g?.full.revision??null,quickGallery:g?.quickGallery??[],activeParagraphStyleId:A.styleId,activeParagraphStyleName:A.styleName,mixedSelection:A.mixed,sourceStatus:g?.full.sourceStatus??null,diagnostics:B}},nn=()=>{const f=Wn(),g=Pu();g.status==="ready"&&Lu(g),N(g);const w=ga(g);for(const[A,E]of r)(!w||E.selectionSignature!==w||E.settled&&g.status==="ready")&&r.delete(A);return{ready:k()!=null,documentMode:f,document:Ou(),selection:g,toolbar:{context:f,commands:_a(g),copyFormatActive:h.mode!=="idle"},comments:vl(g),trackChanges:yi(g),contentControls:Gf(g),zoom:yl(),fonts:Wf(),styles:ln(g)}},Vn=f=>{const g=ga(f);g&&a&&g!==a&&(n.clear(),r.clear()),g&&(a=g)};let Ut=null,Cn=null,Sr=null,Kn=null,dr=!1;const yr=()=>{if(Z||dr)return;dr=!0;const f=()=>{dr&&(dr=!1,!Z&&Dt())};typeof queueMicrotask=="function"?queueMicrotask(f):Promise.resolve().then(f)},Bo=()=>{const f=x();if(f!==Sr&&(Kn&&(Kn(),Kn=null),Sr=f,!(!f||typeof f.subscribe!="function")))try{const g=f.subscribe(()=>yr());typeof g=="function"&&(Kn=g)}catch{Sr=null}};let Rn=null,at=null,pn=null,An=null,Ur=null,oi=null;const zo=()=>{const f=k()?.host,g=Tt(f?.getHandles?()=>f.getHandles():void 0,null)?.editing?.selection;return g&&typeof g.subscribe=="function"?g:null},Ps=()=>{const f=zo();if(f!==Ut&&(Cn&&(Cn(),Cn=null),Ut=f,!!f))try{const g=f.subscribe(w=>{Kt+=1,Uf(w),Dt()});typeof g=="function"&&(Cn=g)}catch{Ut=null}},ka=()=>{const f=k()?.host,g=Tt(f?.getHandles?()=>f.getHandles():void 0,null)?.review;return g&&typeof g.subscribe=="function"?g:null},bi=f=>f?typeof f.getActiveReviewTarget=="function"?Tt(()=>f.getActiveReviewTarget(),null):typeof f.getSnapshot=="function"?Tt(()=>f.getSnapshot(),null)?.activeReviewTarget??null:null:null;let Vo=0;const Po=(f,g)=>{const w=(g&&typeof g=="object"?g:null)?.lastInteractionRejection;if(Vo>0&&f==null&&w&&typeof w=="object"&&w.code==="review-target-invalidated"&&w.detail==="not-painted")return!1;const A=f&&typeof f=="object"?f:null;let E=null;if(A?.entityType==="trackedChange"&&typeof A.entityId=="string"&&A.entityId.length>0){const B=A.entityId,q=A.story&&typeof A.story=="object"?A.story:void 0,oe=ts(),ve=(oe?q?Eu(oe,q).toPublicId(B):pa(oe).toPublicId(B):null)??B,Re=q&&Cr(q)!==Cr(null)?q:void 0;E={id:ve,...Re?{story:Re}:{},...typeof A.paintedEntityId=="string"&&A.paintedEntityId.length>0?{paintedEntityId:A.paintedEntityId}:ve!==B?{paintedEntityId:B}:{}}}return f==null&&E==null&&le!=null&&At(le)||st(le,E)?!1:(Ge(E),!0)},Aa=()=>{const f=ka();if(f===Rn)return;if(at&&(at(),at=null),Rn=f,!f){Po(null);return}let g=!0;try{const w=f.subscribe(A=>{const E=A&&typeof A=="object"?A:null;!Po(E&&Object.prototype.hasOwnProperty.call(E,"activeReviewTarget")?E.activeReviewTarget:bi(f),A)||g||Dt()});typeof w=="function"&&(at=w),Po(bi(f))}catch{Rn=null}finally{g=!1}},Tl=()=>{if(Ut||Wn()!=="viewing")return null;const f=k()?.mount?.container,g=(f&&typeof f=="object"&&"ownerDocument"in f?f.ownerDocument??null:null)??globalThis.document??null;return g&&typeof g.addEventListener=="function"?g:null},Ho=()=>{const f=Tl();if(f===Ur||(oi&&(oi(),oi=null),Ur=f,!f))return;const g=()=>{Kt+=1,Dt()};f.addEventListener("selectionchange",g),f.addEventListener("pointerup",g,!0),f.addEventListener("mouseup",g,!0),oi=()=>{f.removeEventListener("selectionchange",g),f.removeEventListener("pointerup",g,!0),f.removeEventListener("mouseup",g,!0)}};xs(),Po(bi(ka()));let ut=nn();a=ga(ut.selection);const Di=()=>{const f=k()?.host?.events,g=f&&typeof f.subscribe=="function"?f:null;if(g!==pn&&(An&&(An(),An=null),pn=g,!!g))try{const w=g.subscribe(A=>{const E=A?.type;if(E==="source:complete"||E==="source:signals-complete"){sn!==null&&(Ye(),hn.onRender(!0));return}if((E==="mutation:committed"||E==="collaboration:remote-changed")&&(Qi=Date.now()),E==="mutation:committed"&&(Ye(),Nt={}),E==="mutation:committed"||E==="save:completed"||E==="collaboration:remote-changed"){const B=E==="mutation:committed"?B_(A):null,q=E==="mutation:committed"&&hn.getPendingIds().size>0;B?.removedIds.size&&kt(new Set(B.removedIds),A.receipt);const oe=B?.reconcileMode==="authoritative"&&B.upsertIds.size>0;if(oe&&(Mo(),Ye(),sn=Pt(),Dt()),B?.upsertIds.size||q){const We=A.origin==="history"?null:A.receipt,Le=k()?.documentMutationReadiness,Xe=typeof We?.txId=="string"&&We.txId.length>0&&typeof Le?.whenPainted=="function",Ve=A.origin==="history"&&typeof Le?.getRenderEpoch=="function"?Tt(()=>Le.getRenderEpoch.call(Le),null):null,Ze=A.origin==="history"&&typeof Le?.whenPainted=="function",Je={upsertIds:B?.upsertIds??new Set,removedIds:new Set,reconcileMode:B?.reconcileMode==="authoritative"?"authoritative":"targeted"};Xe?hn.enqueueAfterPaint(Je,()=>Le.whenPainted.call(Le,We)):Ze?hn.enqueueAfterPaint(Je,()=>Le.whenPainted.call(Le,typeof Ve=="number"?{afterEpoch:Ve}:void 0)):(hn.enqueue(Je),hn.onRender(q))}if(oe)return;const ve=E==="mutation:committed"&&Es(A)||E==="collaboration:remote-changed"&&Array.isArray(A.changedStoryIds)&&A.changedStoryIds.length>0;if(ve&&(hl=Date.now()),E==="mutation:committed"&&ve){$o();return}if(B?.removedIds.size&&B.upsertIds.size===0)return;(E==="collaboration:remote-changed"||E==="mutation:committed"&&!ve)&&lo();const Re=E==="collaboration:remote-changed"&&Array.isArray(A.changedPartUris)&&A.changedPartUris.some(We=>typeof We=="string"&&wV.has(We)),Ue=E==="collaboration:remote-changed"&&Array.isArray(A.changedStoryIds)&&A.changedStoryIds.length>0&&xi();Re&&!ve&&(Ti=!0),Mo(),(Re||Ue)&&Bn("comments"),Dt()}});typeof w=="function"&&(An=w)}catch{pn=null}},Dt=()=>{if(Z)return;dr=!1,xs(),Ps(),Bo(),Aa(),Ho(),Di();const f=nn();Vn(f.selection),ut=f;for(const g of[...qe])g(ut)},Rl=[],Ia=[],Ea=f=>{for(const g of f)try{g()}catch{}},Ac=()=>Ea(Rl),Ml=()=>Ea(Ia),Ll=[];((f,g)=>{if(!(!f||typeof f.on!="function"))for(const w of g){const A=w==="active-editor-change"?()=>{Ac(),Ml(),Dt()}:w==="document-replaced"?E=>{const B=E&&typeof E=="object"?E:null,q=B?.editor,oe=B?.host,ve=!!q&&q===k(),Re=!!oe&&oe===T();!ve&&!Re||(Ml(),ee.clear(),Mo(),Dt())}:()=>Dt();try{f.on(w,A),Ll.push(()=>{try{typeof f.off=="function"&&f.off(w,A)}catch{}})}catch{}}})(t,pV),Ps(),Bo(),Aa(),Ho(),Di();const xa=(f,g=eV)=>({get:()=>f(ut),subscribe:w=>{let A=f(ut);const E=B=>{const q=f(B);g(A,q)||(A=q,w(q))};return qe.add(E),()=>qe.delete(E)}}),ii=f=>xa(f),wo=f=>{const g=w=>{const A=B=>{try{w(B)}catch{}},E=f.subscribe(A);return A(f.get()),E};return{get:()=>f.get(),getSnapshot:()=>f.get(),observe:g,subscribe:w=>g(A=>w({snapshot:A}))}};function zt(f){return f&&typeof f=="object"&&typeof f.id=="string"?String(f.id):null}function Hn(f){const g=Yi(f);return g&&Cr(g)!==Cr(null)?g:void 0}function Br(f,g){return{kind:"id",id:f,...g?{story:g}:{}}}function fr(f){if(f.empty)return null;const g=f.selectionTarget,w=g?.start,A=g?.end;if(g?.kind!=="selection"||w?.kind!=="text"||A?.kind!=="text"||typeof w.blockId!="string"||w.blockId!==A.blockId||!Number.isInteger(w.offset)||!Number.isInteger(A.offset)||w.offset<0||A.offset<0||w.offset===A.offset)return null;const E=Math.min(w.offset,A.offset),B=Math.max(w.offset,A.offset),q=Yi(f);return{kind:"range",coordinateSpace:g.coordinateSpace==="tracked"?"tracked":"visible",range:{kind:"text",...q?{story:q}:{},segments:[{blockId:w.blockId,range:{start:E,end:B}}]}}}function jo(f,g){if(Cr(g)!==Cr(null))return;const w=y()?.trackChanges,A=w?.list;if(typeof A!="function")return;const E=Tt(()=>A.call(w),null);if(Tr(E)||!E||typeof E!="object")return;const B=E.items;if(Array.isArray(B))return B.map(dl).find(q=>q!=null&&Ki(q,f,g))}function os(f,g){const w=is(f.quotedText);if(!w)return!1;const A=ym(g);return[A.insertedText,A.deletedText,A.excerpt].some(E=>is(E)===w)}function is(f){return typeof f=="string"?f.replace(/\s+/g," ").trim():""}function Ta(){const f=ut.selection.activeChangeIds[0];if(!f)return"unavailable";const g=Yi(ut.selection),w=(ut.trackChanges.status==="ready"?ut.trackChanges.items.find(q=>Ki(q,f,g)):void 0)??jo(f,g)??ts()?.find(q=>Ki(q,f,g));if(!w)return"unavailable";const A=ym(w),E=A.type,B=A.grouping;return os(ut.selection,w)?"id":E==="replacement"&&B==="replacement-pair"||(E==="insertion"||E==="deletion"||E==="insert"||E==="delete")&&B==="standalone"?"range":"id"}function Ku(f,g,w,A){const E=()=>Sb(f,Br(w,A),w,A);try{const B=Sb(f,g,null);return Tr(B)?br(Promise.resolve(B).then(q=>go(As(q))?q:E())):br(go(As(B))?B:E())}catch{return!1}}function qu(f,g){if(f.scope==="all")return{target:{scope:"all"},changeId:null};if(typeof g=="string"&&g.length>0)return{target:{kind:"id",id:g},changeId:g};if(g&&typeof g=="object"){const E=g;if(E.target&&typeof E.target=="object"){const q=E.target;return{target:q,changeId:zt(q),story:q.story}}const B=typeof E.changeId=="string"?E.changeId:E.id;if(typeof B=="string"&&B.length>0)return{target:Br(B,E.story),changeId:B,story:E.story}}const w=ut.selection.activeChangeIds[0],A=Hn(ut.selection);return w?{target:Br(w,A),changeId:w,story:A}:null}function Yu(f,g){if(f.scope==="id"&&g==null){if(ut.selection.activeChangeIds.length>1)return nh(f.kind,{kind:"ids",ids:ut.selection.activeChangeIds},null);if(ut.selection.activeChangeIds.length===1&&!ut.selection.empty&&ut.selection.selectionTarget){const A=Ta();if(A==="unavailable")return!1;if(A==="range"){const E=fr(ut.selection),B=Hn(ut.selection);return E?Ku(f.kind,E,ut.selection.activeChangeIds[0],B):!1}if(A==="id"){const E=ut.selection.activeChangeIds[0],B=Yi(ut.selection),q=B&&Cr(B)!==Cr(null)?B:void 0;return _b(f.kind,q?{id:E,story:q}:E)}}}const w=qu(f,g);return w?nh(f.kind,w.target,w.changeId,w.story):!1}function Xu(f,g){const w=x()?.lists,A=w?.apply;if(typeof A!="function")return!1;const{behavior:E,preset:B,continuity:q}=typeof g=="string"?vV(g):g&&typeof g=="object"?g:{},oe={kind:f,behavior:E??"toggle"};B!==void 0&&(oe.preset=B),q!==void 0&&(oe.continuity=q);try{return br(A.call(w,oe))}catch{return!1}}let Oi=Promise.resolve(!1),si=null,L=Promise.resolve(!1);const W=async f=>{if(!bm(f))return f;const g=k()?.documentMutationReadiness,w=g?.whenPainted;if(typeof w!="function")return f;const A=typeof f.txId=="string"?f.txId:void 0;try{await w.call(g,A?{txId:A}:void 0)}catch{}return f},we=f=>{if(Tr(f)){const w=Promise.resolve(f);return{immediate:!0,committed:w.then(A=>As(A),()=>!1),settled:w.then(A=>W(As(A)),()=>!1)}}const g=As(f);return{immediate:g,committed:Promise.resolve(g),settled:W(g)}},Be=()=>{const f=s.shift();if(!f){u=!1,d?.(),d=null;return}try{f.resolve(Z?!1:f.mutate())}catch{f.resolve(!1)}},gt=()=>{let f=!1;return()=>{f||(f=!0,Be())}},vn=(f,g)=>{if(!u){u=!0,c=new Promise(B=>{d=B});try{return{result:g(),release:gt()}}catch(B){throw u=!1,d?.(),d=null,B}}const w=s.find(B=>B.key===f);if(w)return w.mutate=g,{result:w.result,release:()=>{}};let A;const E=new Promise(B=>{A=B});return s.push({key:f,mutate:g,result:E,resolve:A}),{result:E,release:gt()}},Dn=new Set(["create.tableOfContents"]),hr=f=>lr(`Tracked authoring is not supported for ${f}.`),jn=f=>{if(Wn()==="suggesting")return Dn.has(f)?hr(f):{changeMode:"tracked"}},pr=()=>Wn()==="suggesting"?QV:pb,Xt=(f,g,w)=>{const A=jn(f);return A&&A.success===!1?A:A?g(w,A):g(w)},Co=(f,g,w,A)=>{const E=f.inline;if(!E)return;const B=As(A);if(B===!1||typeof B=="object"&&B&&B.success===!1)return;if(E.kind==="clear"){n.clear();return}if(E.kind==="toggle"||!cb(E.key))return;const q=ga(g);if(!q)return;const oe=BV(E.key,w.value);if(oe==null){n.delete(E.key);return}n.set(E.key,{selectionSignature:q,value:oe})},co=(f,g,w,A)=>!f.inline||f.inline.kind==="toggle"?A:Tr(A)?Promise.resolve(A).then(E=>(Co(f,g,w,E),E)):A,Ra=(f,g,w,A)=>{if(f.inline?.kind!=="toggle"||!go(As(A))||typeof w.value!="boolean"&&w.value!==null)return null;const E=ga(g);if(!E)return null;const B=++l;return r.set(f.id,{selectionSignature:E,active:w.value===!0,generation:B,settled:!1}),Dt(),B},Dl=(f,g,w)=>{if(g==null)return;const A=r.get(f.id);if(!(!A||A.generation!==g)){if(!go(w)){r.delete(f.id);return}A.settled=!0}},_o=(f,g)=>f.then(w=>(g?.(w),Mo(),Dt(),w),()=>(g?.(!1),Mo(),Dt(),!1)),br=(f,g)=>{const w=si;if(si=null,w)return Oi=_o(w,g),As(f);if(Tr(f))return Oi=_o(we(f).settled,g),!0;const A=As(f);return bm(A)&&typeof k()?.documentMutationReadiness?.whenPainted=="function"?(Oi=_o(W(A),g),A):(g?.(A),Oi=Promise.resolve(A),Mo(),Dt(),A)},Ol=(f,g)=>!f||typeof f!="object"?g:f,Ma=(f,g=lr("Document API operation failed."))=>{if(Tr(f))return Promise.resolve(f).then(A=>Ma(A,g),()=>g);const w=Ol(f,g);return Mo(),bm(w)&&typeof k()?.documentMutationReadiness?.whenPainted=="function"?(_o(W(w)),Dt(),w):(Dt(),w)},Sm=(f,g,w,A)=>{const E=[],B=[];for(const q of w){const oe=A(q);if(oe)try{const ve=we(Xt(f,g,oe));E.push(ve.immediate),B.push(ve.settled)}catch{E.push(!1),B.push(Promise.resolve(!1))}}return si=B.length?Promise.all(B).then(q=>mi(q)):null,mi(E)},km=(f,g,w,A)=>{const E=[],B=[];for(const q of w){const oe=A(q);if(oe)try{const ve=we(Xt(f,g,oe));E.push(ve.immediate),B.push(ve.settled)}catch{E.push(!1),B.push(Promise.resolve(!1))}}return si=B.length?Promise.all(B).then(q=>mi(q)):null,mi(E)},Jf=(f,g,w,A=ut.selection)=>{const E=jn(f);return E&&E.success===!1?E:A.selectionTarget?g(w,{...E??{},offsetSpace:"selection"}):E?g(w,E):g(w)},vb=(f,g,w,A)=>{const E=mo(g,A);switch(f.kind){case"alignment":{const B=w;return B!=="left"&&B!=="center"&&B!=="right"&&B!=="justify"?null:{target:E,alignment:B}}case"spacing-line":{const B=typeof w=="number"?w:Number(w);return!Number.isFinite(B)||B<=0?null:{target:E,line:B,lineRule:"auto"}}case"style":if(w&&typeof w=="object"){const B=w.role;if(B&&typeof B=="object")return{target:E,role:B}}return typeof w!="string"||w.trim()===""?null:{target:E,styleId:w};case"direction":{const B=f.fixedValue;return B!=="ltr"&&B!=="rtl"?null:{target:E,direction:B}}default:return null}},$f=(f,g)=>{const w=f.inline,A=hb(f),E=T();if(!w||typeof E?.setPendingInlineFormat!="function")return!1;if(w.kind==="clear")return Q(),!0;if(!A)return!1;let B;if(w.kind==="toggle")B=!Sa(f,y(),ut.selection);else{const q=g&&typeof g=="object"&&"value"in g?g.value:g;if(w.kind==="value-number"){const oe=typeof q=="number"?q:Number(q);B=Number.isFinite(oe)&&oe>0?oe:null}else B=typeof q=="string"&&q.trim()!==""?q:null;if(B===null)return V(A,null),!0}return V(A,B),!0},Jn=()=>{const f=y(),{lockModesById:g}=wa(f?.contentControls,ut.selection);if(Pi(g))return!1;const w=[],A=[],E=Xe=>{const Ve=we(Xe);w.push(Ve.immediate),A.push(Ve.settled)},B=(Xe,Ve,Ze)=>{try{E(Ze?Xe(Ve,Ze):Xe(Ve))}catch{w.push(!1),A.push(Promise.resolve(!1))}},q=ct().cache?.full.defaults.paragraphStyleId??Ne,oe=Mu(ut.selection);if(oe){const Xe=vr(f,"format.apply");if(Xe)try{E(Jf("format.apply",Xe,{target:oe,inline:{...pr()}}))}catch{w.push(!1),A.push(Promise.resolve(!1))}}const ve=vr(f,"format.paragraph.resetDirectFormatting"),Re=vr(f,"styles.paragraph.setStyleRef"),Ue=Yi(ut.selection),We=!Ue||Ue.storyType==="body",Le=vr(f,We?"lists.remove":"lists.removeInStory");for(const Xe of Fr(ut.selection)){const Ve=mo(Xe,Ue);if(ve&&B(ve,{target:Ve}),Le)try{const Ze=ma(Xe),Je=we(Le(We?{target:Ze}:{target:Ze,story:Ue}));A.push(Je.settled.then(rt=>go(rt)?rt:!0))}catch{}Re&&B(Re,{target:Ve,styleId:q})}if(!oe&&Wn()!=="suggesting"){const Xe=vr(f,"format.paragraph.setMarkRunProps");if(Xe)for(const Ve of Fr(ut.selection))B(Xe,{target:mo(Ve,Ue),markRunProps:{bold:!1,italic:!1,strikethrough:!1,doubleStrikethrough:!1,smallCaps:!1,caps:!1,verticalAlign:"baseline"}})}return si=A.length?Promise.all(A).then(Xe=>mi(Xe)):null,mi(w.length?w:[!1])},yb=(f,g,w)=>{const A=Fr(ut.selection);if(A.length===0)return!1;const E=Yi(ut.selection);return Sm(f.docRoute,g,A,B=>vb(f.blockParagraph,B,w,E))},Am=(f,g,w)=>{const A=y(),E=vr(A,"format.paragraph.setIndentation"),B=vr(A,"format.paragraph.clearIndentation"),q=f.list?.mode,oe=qi(ut.selection),ve=Yi(ut.selection),Re=async Ue=>{const We=await Sc(A,Ue,oe);if(We===!0)return{kind:"list",routeToCall:f.docRoute,opToCall:g,input:{target:bA(Ue)}};if(We===null||ve&&ve.storyType!=="body"&&typeof A?.getNode!="function")return null;const Le=await Qf(A,Ue,ve),Xe={};if(Le?.right!=null&&(Xe.right=Le.right),Le?.firstLine!=null&&(Xe.firstLine=Le.firstLine),Le?.hanging!=null&&(Xe.hanging=Le.hanging),q==="indent")return E?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:E,input:{target:mo(Ue,ve),left:Math.max(0,Le?.left??0)+wA,...Xe}}:null;const Ve=Math.max(0,(Le?.left??0)-wA);return Ve>0&&(Xe.left=Ve),Object.keys(Xe).length===0?B?{kind:"paragraph",routeToCall:"format.paragraph.clearIndentation",opToCall:B,input:{target:mo(Ue,ve)}}:E?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:E,input:{target:mo(Ue,ve),left:0}}:null:E?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:E,input:{target:mo(Ue,ve),...Xe}}:null};return si=(async()=>{const Ue=await Promise.all(w.map(Ve=>Re(Ve).catch(()=>null)));if(Ue.length===w.length&&Ue.every(Ve=>Ve?.kind==="list")&&Wn()!=="suggesting"){const Ve=q==="indent"?"lists.indentRange":"lists.outdentRange",Ze=vr(A,Ve);if(Ze)try{return await we(Xt(Ve,Ze,{paraIds:w,story:oe})).settled}catch{return!1}}const We=oe.storyType!=="body"&&Ue.some(Ve=>Ve?.kind==="list"),Le=We&&q==="outdent"?vr(A,"lists.outdentInStory"):null;if(We&&!Le)return!1;const Xe=Ue.map(Ve=>{if(!Ve)return Promise.resolve(!1);try{return Ve.kind==="list"&&Le?we(Xt("lists.outdentInStory",Le,{target:Ve.input.target,story:oe})).settled:we(Xt(Ve.routeToCall,Ve.opToCall,Ve.input)).settled}catch{return Promise.resolve(!1)}});return mi(await Promise.all(Xe))})(),!0},Im=(f,g)=>{const w=f.list,A=y(),E=Fr(ut.selection);if(E.length===0)return!1;const B=qi(ut.selection),q=B.storyType==="body";if(w.mode==="indent"||w.mode==="outdent")return Am(f,g,E);const oe=w.seed,ve=We=>{if(We.some(rt=>!rt.resolved))return{immediate:!1,settled:null};const Le=We.every(rt=>rt.seed===oe);if(!Le&&!q)return{immediate:!1,settled:null};const Xe=Le?q?"lists.remove":"lists.removeInStory":f.docRoute,Ve=Le?vr(A,Xe):g;if(!Ve)return{immediate:!1,settled:null};const Ze=[],Je=[];return E.forEach((rt,tt)=>{if(!Le&&We[tt]?.seed===oe)return;const Rt=Le?{target:ma(rt),...q?{}:{story:B}}:{target:ma(rt),seed:oe};try{const Gt=we(Xt(Xe,Ve,Rt));Ze.push(Gt.immediate),Je.push(Gt.settled)}catch{Ze.push(!1),Je.push(Promise.resolve(!1))}}),{immediate:mi(Ze),settled:Je.length?Promise.all(Je).then(rt=>mi(rt)):null}},Re=E.map(We=>kc(A,We,B));if(Re.some(Tr))return si=Promise.all(Re).then(async We=>{const Le=ve(We);return Le.settled?await Le.settled:Le.immediate}),!0;const Ue=ve(Re);return si=Ue.settled,Ue.immediate};function Ic(f){return f&&typeof f=="object"?f:{}}function Em(f){if(typeof f=="string")return f;const g=Ic(f);if(Object.prototype.hasOwnProperty.call(g,"href"))return g.href;if(Object.prototype.hasOwnProperty.call(g,"value"))return g.value}function xm(f,g){const w=Ic(f).text;return typeof w=="string"&&w.trim()!==""?w:g}function eh(f){const g=Ic(f),w=g.capture&&typeof g.capture=="object"?g.capture:null;return g.target??w?.target??w?.selectionTarget??g.selectionTarget??g.textTarget??null}const bb=f=>{const g=y(),w=g?.hyperlinks;if(!w)return!1;const A=Ic(f),E=Em(f),B=eh(f),q=typeof A.text=="string"?A.text:void 0,oe=typeof A.currentText=="string"?A.currentText:void 0,ve=Ru(A.hyperlinkTarget)?A.hyperlinkTarget:null,Re=Ru(A.textTarget)?A.textTarget:null,Ue=Sl(g,ut.selection),We=typeof ve?.storyId=="string"&&typeof ve?.hyperlinkNodeId=="string";if(We&&E===null){const Le=w.remove;if(typeof Le!="function")return!1;try{return Xt("hyperlinks.remove",Le,{storyId:ve.storyId,hyperlinkNodeId:ve.hyperlinkNodeId,keepText:!0})}catch{return!1}}if(Ue&&E===null){const Le=w.remove;if(typeof Le!="function")return!1;try{return Xt("hyperlinks.remove",Le,{target:Ue.address,mode:"unwrap"})}catch{return!1}}if((Ue||ve)&&typeof E=="string"&&E.trim()!==""){const Le=w.patch,Xe=w.updateTarget;if(!(!We&&Ue&&typeof Le=="function")&&!(We&&typeof Xe=="function"))return!1;const Ve=typeof q=="string"&&q!==(We?oe:Ue?.text??oe),Ze=g?.text?.replace,Je=Ve?We?Re:WV(Ue?.address):null,rt=Ve&&!!Je&&typeof Ze=="function";if(Ve&&!rt)return!1;const tt=[],Rt=[];let Gt=null,en=null,Mn=null,Rr=!1;try{if(We){if(typeof Xe!="function")return!1;const Ar=Xt("hyperlinks.updateTarget",Xe,{storyId:ve.storyId,hyperlinkNodeId:ve.hyperlinkNodeId,newTarget:KV(E)});Rr=Tr(Ar);const zr=we(Ar);if(!go(zr.immediate))return!1;tt.push(zr.immediate),Rt.push(zr.settled),Gt=zr.immediate,en=zr.committed,Mn=zr.settled}else if(Ue){if(typeof Le!="function")return!1;const Ar=Xt("hyperlinks.patch",Le,{target:Ue.address,patch:{href:E}});Rr=Tr(Ar);const zr=we(Ar);if(!go(zr.immediate))return!1;tt.push(zr.immediate),Rt.push(zr.settled),Gt=zr.immediate,en=zr.committed,Mn=zr.settled}}catch{return!1}if(rt){const Ar=(Mr,Uo)=>go(Uo)?mi([Mr,Uo]):go(Mr)?Nf(Mr,Uo):Uo,zr=Mr=>{if(!go(Mr))return Mr;try{const Uo=we(Xt("text.replace",Ze,{target:Je,text:q}));return go(Uo.immediate)?Promise.all([Mn??Promise.resolve(Mr),Uo.settled]).then(([xb,ej])=>Ar(xb,ej)):Nf(Mr,Uo.immediate)}catch{return Nf(Mr,!1)}};if(Rr)return si=(en??Promise.resolve(Gt??!1)).then(zr),mi(tt);try{const Mr=we(Xt("text.replace",Ze,{target:Je,text:q}));if(!go(Mr.immediate))return Gt?Nf(Gt,Mr.immediate):Mr.immediate;tt.push(Mr.immediate),Rt.push(Mr.settled),si=Promise.all([Mn??Promise.resolve(Gt??!1),Mr.settled]).then(([Uo,xb])=>Ar(Uo,xb))}catch{return Gt?Nf(Gt,!1):!1}}return!rt&&Rt.length>0&&(si=Promise.all(Rt).then(Ar=>mi(Ar))),mi(tt)}if(typeof E=="string"&&E.trim()!==""){const Le=E.trim(),Xe=w.wrap,Ve=OV(B),Ze=Ve.length>0?Ve:lb(ut.selection);if(Ze.length>0){if(typeof Xe!="function")return!1;try{return km("hyperlinks.wrap",Xe,Ze,Rt=>({target:Rt,link:{destination:{href:Le}}}))}catch{return!1}}const Je=w.insert,rt=xm(f,Le);if(typeof Je!="function"||rt.trim()==="")return!1;const tt=Vf(B)??ul(ut.selection);if(!tt)return!1;try{return Xt("hyperlinks.insert",Je,{target:tt,text:rt,link:{destination:{href:Le}}})}catch{return!1}}return!1},Tm=(f,g,w)=>{const A=f.create.kind,E=w&&typeof w=="object"?w:{};if(A==="table"){const q=Number(E.rows??E.rowCount),oe=Number(E.columns??E.cols??E.colCount);if(!Number.isInteger(q)||q<1||!Number.isInteger(oe)||oe<1)return!1;const ve=ul(ut.selection),Re=ve&&typeof ve.blockId=="string"?{kind:"inParagraph",target:mo(ve.blockId),offset:ve.range?.start??0}:db(ut.selection,"nodeId");try{return Xt(f.docRoute,g,{rows:q,columns:oe,at:Re})}catch{return!1}}if(A==="image"){const q=E.src??E.value;if(typeof q!="string"||q.trim()==="")return!1;const oe=ul(ut.selection),ve=qi(ut.selection),Re=ve.storyType==="body"?null:ve;let Ue;oe&&typeof oe.blockId=="string"?Ue={kind:"inParagraph",target:mo(oe.blockId,Re),offset:oe.range?.start??0}:(Ue=db(ut.selection,"target"),Re&&Ue.kind==="after"&&(Ue={...Ue,target:{...Ue.target,story:Re}}));const We={src:q,at:Ue};Re&&(We.in=Ue.kind==="inParagraph"?R(Re)??Re:Re),typeof E.alt=="string"&&(We.alt=E.alt),typeof E.title=="string"&&(We.title=E.title),E.size&&typeof E.size=="object"&&(We.size=E.size);try{return Xt(f.docRoute,g,We)}catch{return!1}}const B={at:db(ut.selection,"target")};typeof E.instruction=="string"&&(B.instruction=E.instruction),E.config&&typeof E.config=="object"&&(B.config=E.config);try{return Xt(f.docRoute,g,B)}catch{return!1}},Ec=(f,g)=>{const w=f.table,A=Fe();if(!A||w.requiresCell&&!A.cellNodeId)return!1;const E=eH(w.action,A);if(!E)return!1;try{if(w.action==="insert-row-before"||w.action==="insert-row-after"){const B=T(),q=(typeof B?.getHandles=="function"?B.getHandles():null)?.editing?.tables;if(typeof q?.insertRow!="function")return!1;const oe=jn(f.docRoute);return oe&&oe.success===!1?oe:oe?q.insertRow(E,oe):q.insertRow(E)}return Xt(f.docRoute,g,E)}catch{return!1}},Zu=f=>!f||f.disposition!=="routed"?!1:!!(f.inline||f.blockParagraph||f.list||f.link||f.create),th=f=>{const g=Ic(f);return!!(eh(f)||Ru(g.hyperlinkTarget)||Ru(g.textTarget))},It=(f,g,w)=>ut.selection.status!=="ready"?!1:wm(f)?.scope==="id"||!g||g.disposition!=="routed"?!0:g.inline?.kind==="clear"?Fr(ut.selection).length>0||Mu(ut.selection)!=null:g.inline?Mu(ut.selection)!=null||Fr(ut.selection).length>0:g.blockParagraph||g.list?Fr(ut.selection).length>0:g.link?th(w)||lb(ut.selection).length>0||ul(ut.selection)!=null||Sa(g,y(),ut.selection):!0,Ht=(f,g)=>{const w=wm(f),A=Su(f);return w?.scope!=="id"&&!Zu(A)?!1:!It(f,A,g)},bn=(f,g)=>Ht(f,g)?ba().then(()=>{}):null,qn=(f,g,w)=>{if(si=null,Oi=Promise.resolve(!1),Z)return!1;const A=fe.get(f);if(A)try{return br(A.execute(ya(g,w)))}catch{return!1}const E=hA(f);if(E&&typeof x()?.lists?.apply=="function")return Xu(E,g);const B=wm(f);if(B)return Yu(B,g);if(f==="copy-format")return br(uo());const q=Su(f);if(!q||q.disposition!=="routed")return!1;const oe=q.normalizePayload?q.normalizePayload(g):g;if(q.instanceRoute){if(!k()||!ue(q,oe))return!1;const We=t?.[q.instanceRoute];if(typeof We!="function")return!1;try{const Le=q.fixedArg!==void 0?q.fixedArg:oe;return br(We.call(t,Le))}catch{return!1}}if(q.inline?.kind==="clear")return q.mutates&&Wn()==="viewing"?!1:br(Jn());const ve=q.docRoute;if(!ve||q.mutates&&Wn()==="viewing")return!1;const Re=y(),Ue=vr(Re,ve);if(!Ue)return!1;if(q.inline){const{lockModesById:We}=wa(Re?.contentControls,ut.selection);if(Pi(We))return!1;const Le=Mu(ut.selection);if(!Le)return ut.selection.empty===!1?br(!1):br($f(q,oe));const Xe=Sa(q,Re,ut.selection),Ve=JV(q.inline,Le,oe,Xe);if(!Ve)return!1;let Ze=null;try{const Je=k(),rt=Wn(),tt=()=>k()!==Je||y()!==Re||Wn()!==rt?!1:Jf(ve,Ue,Ve),Rt=ga(ut.selection)??uc(ut.selection),Gt=q.inline.kind==="toggle"?vn(`${q.id}:${Rt}`,tt):null;Ze=Gt?.release??null;const en=Gt?Gt.result:tt(),Mn=Ra(q,ut.selection,Ve,en),Rr=br(co(q,ut.selection,Ve,en),Ar=>{Dl(q,Mn,Ar),Ze?.(),Ze=null});return q.inline.kind==="toggle"&&(L=Oi),Rr}catch{return Ze?.(),!1}}if(q.blockParagraph){const We=yb(q,Ue,oe),Le=q.blockParagraph.kind==="alignment"&&go(We)?ri(ut.selection,oe):null;return br(We,Xe=>{Wu(Le,Xe)})}if(q.list)return br(Im(q,Ue));if(q.link)return br(bb(oe));if(q.create)return br(Tm(q,Ue,oe));if(q.table)return br(Ec(q,Ue));try{return br(q.mutates?Xt(ve,Ue,oe):Ue(oe))}catch{return!1}},kr=()=>{m+=1,h={mode:"idle",snapshot:null,sourceSelectionKey:null,lastClickAt:h.lastClickAt,pointerSelecting:!1,keyboardSelecting:!1};for(const f of p)f("idle");Dt()},uo=async()=>{const f=["bold","italic","underline","strikethrough"].filter(Ue=>ut.toolbar.commands[Ue]?.active===!0),g=await L;await c;const w=go(g)?f:[],A=500,E=Date.now();if(h.mode!=="idle"){if(h.mode==="armed"&&E-h.lastClickAt<A){h={...h,mode:"persistent",lastClickAt:E};for(const Ue of p)Ue("persistent");return Dt(),!0}return kr(),!1}const B=E-h.lastClickAt<A,q=++m;h={...h,lastClickAt:E};const oe=await ba(),ve=`${uc(oe)}:${Pt()}`,Re=await wi(null,oe,ve&&ve===_?v:void 0,w);if(q!==m)return!0;h={...h,mode:B?"persistent":"armed",snapshot:Re,sourceSelectionKey:uc(oe),lastClickAt:E};for(const Ue of p)Ue(h.mode);return Dt(),!0},wi=async(f,g,w,A=[])=>{const E=g?.target??f?.target;if(!E||E.kind!=="text")return null;const B=Array.isArray(E.segments)?E.segments:[];if(B.length===0)return null;const q=y();if(!q)return null;const oe=E.story;let ve=null;for(const Ve of B){const Ze=(await wl(mo(Ve.blockId,oe)))?.node??null;if(!Ze)continue;const Je=Ds(Ze),rt=Qu(Array.isArray(Je?.inlines)?Je.inlines:[],Ve.range);ve?ve=MA(ve,rt):ve=rt}const Re=ve?tV(ve):{},Ue={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike"},We=new Set([...g?.activeMarks??(Array.isArray(f?.activeMarks)?f.activeMarks:[]),...A]);for(const[Ve,Ze]of Object.entries(Ue))We.has(Ve)&&(Re[Ze]=!0);const Le=w??await zu(g??pl(f,"ready"));if(Le.fontFamily&&(Re.fontFamily=Le.fontFamily),Le.color&&(Re.color=Le.color),Le.highlight&&(Re.highlight=Le.highlight),Le.fontSize){const Ve=Number.parseFloat(Le.fontSize);Number.isNaN(Ve)||(Re.fontSize=Ve)}let Xe=null;if(B.length===1){const Ve=B[0],Ze=(await wl(mo(Ve.blockId,oe)))?.node??null;Ze&&Ds(Ze)&&(Xe=await TH(Ze,Ve.blockId,q,oe))}return{story:oe??null,inline:Re,paragraph:Xe}},Ds=f=>f?f.kind==="paragraph"?f.paragraph??null:f.kind==="heading"?f.heading??null:null:null,Qu=(f,g)=>{const w=q=>{const oe=q.run;return typeof oe?.text=="string"?oe.text:""},A=q=>q.run?.props;if(g.start===g.end){let q=0;for(const oe of f){const ve=w(oe),Re=q,Ue=q+ve.length;if(q=Ue,g.start>=Re&&g.start<=Ue){const We=A(oe);return We?{...We}:{}}}return{}}let E=0;const B=[];for(const q of f){const oe=w(q),ve=E,Re=E+oe.length;if(E=Re,Re<=g.start||ve>=g.end)continue;const Ue=A(q);Ue&&B.push(Ue)}return B.length===0?{}:B.length===1?{...B[0]}:MA(B[0],...B.slice(1))},MA=(f,...g)=>{const w={...f};for(const A of g)for(const E of Object.keys(w)){if(!(E in A)){delete w[E];continue}const B=w[E],q=A[E];(typeof B!=typeof q||JSON.stringify(B)!==JSON.stringify(q))&&delete w[E]}return w},TH=async(f,g,w,A)=>{const E=Ds(f),B=E.props??{},q=E.styleRef??null,oe=B.alignment??null,ve=B.spacing??null,Re=B.indent??null,Ue=Re?{...Re.left!=null?{left:Re.left}:{},...Re.right!=null?{right:Re.right}:{},...Re.firstLine!=null?{firstLine:Re.firstLine}:{},...Re.hanging!=null?{hanging:Re.hanging}:{}}:null,We=B.markRunProps??null,Le=B.numbering?.numId,Xe=typeof Le=="string"?parseInt(Le,10):typeof Le=="number"?Le:NaN,Ve=B.numbering?.level,Ze=isNaN(Xe)?null:{numId:Xe,...Ve!=null?{level:Ve}:{}};let Je=null;if(Ze&&typeof w.lists?.getState=="function")try{const rt=await w.lists.getState({target:mo(g,A)});rt&&typeof w.lists?.getStyle=="function"&&(Je=await w.lists.getStyle(rt)??null)}catch{}return{styleId:q,alignment:oe,spacing:ve,indentation:Ue,markRunProps:We,numbering:Ze,listStyle:Je}},LA=async()=>{if(h.mode==="idle"||h.pointerSelecting||h.keyboardSelecting)return;const f=y()?.selection,g=async()=>vi(typeof f?.current=="function"?await Promise.resolve(f.current({includeText:!0})):es().value),w=()=>new Promise(q=>setTimeout(q,16)),A=8;let E=null,B="";for(let q=0;q<A;q+=1){if(q>0&&await w(),h.mode==="idle"||h.pointerSelecting||h.keyboardSelecting)return;if(E=await g(),!(!E||E.empty)&&(B=uc(E),B!==h.sourceSelectionKey))break}if(E&&!E.empty&&B!==h.sourceSelectionKey){await PA(E);return}if(h.snapshot?.paragraph){const q=await g();if(!q||uc(q)===h.sourceSelectionKey)return;await PA(q)}},PA=async f=>{const g=h.snapshot;if(!g){h.mode==="armed"&&kr();return}const w=y();if(!w)return;const A=pl(f,"ready"),{lockModesById:E}=wa(w.contentControls,A);if(Pi(E)){Dt();return}const B=f.target,q=f.selectionTarget;if(f.empty!==!0&&Object.keys(g.inline).length>0){const oe=vr(w,"format.apply");if(oe&&q)try{if(!go(As(await Promise.resolve(Jf("format.apply",oe,{target:q,inline:g.inline},f))))){Dt();return}}catch{Dt();return}}if(g.paragraph){const oe=Array.isArray(B?.segments)?B.segments:[],ve=B?.story;for(const Re of oe){const Ue=mo(Re.blockId,ve),We=await wl(Ue),Le=We?.node??null,Xe=We?.address??null;if(!Le)continue;const Ve={kind:"block",nodeType:Xe?.nodeType??Le.kind??"paragraph",nodeId:Re.blockId,...ve&&typeof ve=="object"?{story:ve}:{}},{styleId:Ze,alignment:Je,spacing:rt,indentation:tt,markRunProps:Rt,numbering:Gt,listStyle:en}=g.paragraph;if(Ze&&await w.styles?.paragraph?.setStyle?.({target:Ve,styleId:Ze}),Je&&await w.format?.paragraph?.setAlignment?.({target:Ve,alignment:Je}),rt){const Mn=rt,Rr=Mn.lineRule??"auto",Ar=new Set(["auto","exact","atLeast"]).has(Rr)?Rr:"auto",zr={...Mn.before!=null?{before:Math.round(Mn.before*20)}:{},...Mn.after!=null?{after:Math.round(Mn.after*20)}:{},...Mn.line!=null?{line:Math.round(Ar==="auto"?Mn.line*240:Mn.line*20),lineRule:Ar}:{}};await w.format?.paragraph?.setSpacing?.({target:Ve,...zr})}if(tt){const Mn={...tt.left!=null?{left:ks(tt.left)}:{},...tt.right!=null?{right:ks(tt.right)}:{},...tt.firstLine!=null?{firstLine:ks(tt.firstLine)}:{},...tt.hanging!=null?{hanging:ks(tt.hanging)}:{}};await w.format?.paragraph?.setIndentation?.({target:Ve,...Mn})}Rt&&await w.format?.paragraph?.setMarkRunProps?.({target:Ve,markRunProps:Rt}),Gt&&await w.format?.paragraph?.setNumbering?.({target:Ve,...Gt}),en&&((await wl(Ue))?.address?.nodeType==="listItem"?await w.lists?.applyStyle?.({target:bA(Re.blockId,ve),style:en}):Gt&&await w.format?.paragraph?.setNumbering?.({target:Ve,...Gt}))}}h.mode==="armed"&&kr(),Dt()},Rm=(f,g,w)=>{const A=bn(f,g),E=A?A.then(()=>(qn(f,g,w),Oi)):(qn(f,g,w),Oi);return Su(f)?.inline?.kind==="toggle"&&(L=E),E},DA=f=>({id:f,getState:()=>ut.toolbar.commands[f]??_l(f,y(),ut.selection,ni(ut.selection)),observe:g=>xa(w=>w.toolbar.commands[f]??{enabled:!1,active:!1,supported:!1,source:"unsupported",reason:lt.commandUnsupported}).subscribe(g),execute:g=>qn(f,g),executeAsync:g=>Rm(f,g)}),RH=f=>{fe.set(f.id,f),Dt();const g=()=>{fe.delete(f.id),Dt()};return Object.assign(g,{handle:DA(f.id),unregister:g})},Mm=ii(f=>f.selection),Lm=wo(Mm),OA=()=>{const f=T();if(typeof f?.getHandles!="function")return{reason:lt.hostCapabilityUnavailable};let g=null;try{g=f.getHandles()}catch(A){const E=A?.reason;return{reason:E==="host-not-ready"||E==="host-disposed"||E==="editing-mount-required"?lt.notReady:lt.hostCapabilityUnavailable}}const w=g?.editing?.selectionTargets;return typeof w?.apply!="function"?{reason:lt.hostCapabilityUnavailable}:{helper:w}},FA={get:Lm.get,getSnapshot:Lm.getSnapshot,subscribe:Lm.subscribe,observe:Lm.observe,current:()=>es().value,capture:()=>{const f=Mm.get();return f.empty||!f.target&&!f.selectionTarget?null:{...f,capturedAt:Date.now()}},restore:f=>{const g=E=>(Dt(),{...E,success:E.ok});if(!f||typeof f!="object")return g({ok:!1,reason:lt.targetUnresolved});if(!k())return g({ok:!1,reason:lt.notReady});const w=ZV(f);if(!w)return g({ok:!1,reason:lt.targetUnresolved});const A=OA();if(!("helper"in A))return g({ok:!1,reason:A.reason});try{return g(fA(A.helper.apply(w)))}catch{return g({ok:!1,reason:lt.hostCapabilityUnavailable})}},apply:f=>{if(!k())return{ok:!1,reason:lt.notReady};const g=OA();if(!("helper"in g))return{ok:!1,reason:g.reason};try{const w=g.helper.apply(f);return Dt(),fA(w)}catch{return{ok:!1,reason:lt.hostCapabilityUnavailable}}},getAnchorRect:f=>{const g=T();if(typeof g?.getSelectionAnchorRect=="function"){const w=Tt(()=>g.getSelectionAnchorRect(f),null);return w&&typeof w=="object"&&(Number(w.width)>0||Number(w.height)>0)?w:null}return null},getRects:f=>{const g=Mm.get(),w=g.selectionTarget??g.target;if(g.empty||!w)return[];const A=jm.getRect({target:w,relativeTo:f?.relativeTo});return A.found?A.rects:[]}},MH={get ids(){return Te()},has:f=>Su(f)!=null||fe.has(f),get:f=>DA(f),execute:qn,executeAsync:Rm,register:RH,getContextMenuItems:f=>{const g=[];for(const w of fe.values()){const A=w.contextMenu;A&&Tt(A.when?()=>A.when(f):void 0,!0)&&g.push({id:w.id,label:A.label,group:A.group,order:A.order,invoke:()=>qn(w.id,void 0,f)})}return g.sort((w,A)=>(w.order??0)-(A.order??0)||w.label.localeCompare(A.label))}},wb=wo(ii(f=>f.toolbar)),LH={get:wb.get,getSnapshot:()=>ut.toolbar,subscribe:wb.subscribe,observe:wb.observe,execute:qn,executeAsync:Rm},xc=async(f,g)=>{if(!k())return{success:!1,ok:!1,reason:lt.notReady};if(!f)return{success:!1,ok:!1,reason:lt.targetUnresolved};const w=T(),A=w?.scrollTargetIntoView;if(typeof A!="function")return{success:!1,ok:!1,reason:lt.hostCapabilityUnavailable};try{const E={target:f,block:g?.block??"center",behavior:g?.behavior??"smooth"},B=await Promise.resolve(g?.shouldContinue?A.call(w,E,g.shouldContinue):A.call(w,E));return B&&typeof B=="object"&&B.success===!1?{success:!1,ok:!1,reason:ib(B.reason,lt.targetUnresolved)}:{success:!0,ok:!0}}catch{return{success:!1,ok:!1,reason:lt.hostCapabilityUnavailable}}},Pm=async(f,g,w,A)=>{const E=f==="trackChanges"?A?.story:void 0,B=rt=>{if(!E||!rt||typeof rt!="object")return rt;const tt=rt,Rt=tt.address&&typeof tt.address=="object"?tt.address:null;return tt.story||Rt?.story?rt:{...tt,story:E}},q=f==="trackChanges"?_V:Bf,oe=w.find(rt=>Ki(rt,g,E)),ve=oe&&typeof oe=="object"?oe:null,Re=f==="trackChanges"&&ve?.type==="move"&&(ve.subtype==="move-to"||ve.subtype==="move-from")?ve.subtype:null,Ue=Re&&typeof ve?.trackedChangeCanonicalId=="string"?ve.trackedChangeCanonicalId:g,We=rt=>{if(!Re)return q(rt);const tt=Bf(rt);if(tt?.kind!=="move")return null;const Rt=Re==="move-to"?tt.destination:tt.source;return sb(Rt)?Rt:null},Le=q(oe),Xe=f!=="trackChanges"||!Re&&sb(Bf(oe));if(Le&&Xe)return B(Le);const Ve=y()?.[f],Ze=f==="comments"?{commentId:g}:{id:Ue,...E?{story:E}:{}},Je=Ve?.get;if(typeof Je!="function")return B(Le);try{return B(We(await Promise.resolve(Je.call(Ve,Ze)))??Le)}catch{return B(Le)}};function NA(f,g){if(ti())return lr("Comments are read-only.","DOCUMENT_READONLY");if(Ts())return lr("Resolving comments is disabled.","DOCUMENT_READONLY");const w=y()?.comments,A=w?.patch;if(typeof A!="function")return lr("comments.patch is unavailable.");const E=lr("comments.patch failed.");return Tt(()=>Ma(A.call(w,{commentId:f,status:g}),E),E)}const Dm=()=>ti()?lr("Comments are read-only.","DOCUMENT_READONLY"):null,BA=(f,g)=>{const w=g&&typeof g=="object"?g:null;let A=Array.from(f);w?.includeResolved===!1&&(A=A.filter(ve=>ve.status!=="resolved"));const E=Number(w?.offset),B=Number.isInteger(E)&&E>0?E:0,q=Number(w?.limit),oe=Number.isInteger(q)&&q>=0?B+q:void 0;return A.slice(B,oe)},Ju=ii(f=>f.comments),Om=wo(Ju),PH={get:Om.get,getSnapshot:Om.getSnapshot,subscribe:Om.subscribe,observe:Om.observe,list:f=>{const g=Ju.get();if(g.status!=="pending")return BA(g.items,f);const w=y()?.comments,A=Tt(w?.list?()=>w.list(f):void 0,null);return Tr(A)?[]:BA(Array.isArray(A?.items)?A.items:[],f)},getById:f=>{const g=Ju.get().items.find(E=>Gn(E)===f)??null;if(g)return g;const w=y()?.comments,A=Tt(w?.get?()=>w.get({commentId:f}):void 0,null);return Tr(A)?null:A},createFromCapture:(f,g)=>{const w=Dm();if(w)return w;const A=y()?.comments,E=A?.create;if(typeof E!="function")return lr("comments.create is unavailable.");const B=lr("comments.create failed.");return Tt(()=>Ma(E.call(A,{target:f.target??f.selectionTarget,text:g.text}),B),B)},createFromSelection:f=>{const g=Dm();if(g)return g;const w=y()?.comments,A=w?.create;if(typeof A!="function")return lr("comments.create is unavailable.");const E=Mm.get(),B=E.target??E.selectionTarget;if(E.empty||!B)return lr("A range selection is required to comment.","NO_SELECTION");const q=lr("comments.create failed.");return Tt(()=>Ma(A.call(w,{target:B,text:f.text}),q),q)},reply:(f,g)=>{const w=Dm();if(w)return w;const A=y()?.comments,E=A?.reply??A?.create;if(typeof E!="function")return lr("comments.reply is unavailable.");const B=lr("comments.reply failed.");return Tt(()=>Ma(E===A?.reply?E.call(A,{parentCommentId:f,text:g.text}):E.call(A,{parentCommentId:f,text:g.text}),B),B)},resolve:f=>NA(f,"resolved"),reopen:f=>NA(f,"active"),delete:f=>{const g=Dm();if(g)return g;const w=y()?.comments,A=w?.delete??w?.remove;if(typeof A!="function")return lr("comments.delete is unavailable.");const E=lr("comments.delete failed.");return Tt(()=>Ma(A.call(w,{commentId:f}),E),E)},setActive:f=>{if(f==null)return ye=null,Dt(),!0;if(!k())return!1;const g=Ju.get();if(g.listStatus!=="ready")return!1;const w=MV(g.items,f);return!w||!g.items.some(A=>Gn(A)===w)?!1:(ye=w,Dt(),!0)},scrollTo:async f=>{if(!y())return{success:!1,ok:!1,reason:k()?lt.documentApiUnavailable:lt.notReady};const g=await Pm("comments",f,Ju.get().items);return g?xc(g):{success:!1,ok:!1,reason:lt.targetUnresolved}}},La=ii(f=>f.trackChanges),Cb=(f,g)=>{const w=La.get().items.filter(We=>Gn(We)!==null);if(w.length===0)return null;const A=ut.trackChanges.activeId,E=le?.id===A?le.story:void 0,B=w.filter(We=>gm(We)==null),q=E||B.length===0?w:B;let oe=A?q.findIndex(We=>Ki(We,A,E)):-1;oe===-1&&A&&E&&(oe=q.findIndex(We=>Ki(We,A)));const ve=q[oe===-1?f>0?0:q.length-1:(oe+f+q.length)%q.length],Re=Gn(ve),Ue=gm(ve);return Ge(Ue?{id:Re,story:Ue}:{id:Re},g),Dt(),Re};let zA=Promise.resolve();const DH=f=>{const g=re;return zA.catch(()=>{}).then(()=>OH(f,g))},OH=async(f,g)=>{if(re!==g)return{success:!1};const w=le,A=Cb(f,{invalidateQueuedNavigation:!1});if(A==null)return{success:!1};const E=le,B=Se,q=()=>re===g&&le===E&&Se===B,oe=()=>{q()&&(Ge(w,{invalidateQueuedNavigation:!1}),Dt())};E&&$e.add(E);try{const ve=await Pm("trackChanges",A,La.get().items,E?.story?{story:E.story}:void 0);if(!q())return{success:!1};if(!ve)return oe(),{success:!1};Vo+=1;try{const Re=await xc(ve,{behavior:"auto",shouldContinue:q});return q()?(!Re.ok&&Re.reason!==lt.targetNotVisible?(oe(),Ee(w)):Ee(E),{success:Re.ok}):{success:!1}}finally{Vo=Math.max(0,Vo-1),Vo===0&&(q()?Rn&&Po(bi(Rn)):Ee(le))}}finally{E&&$e.delete(E)}},VA=f=>{const g=DH(f);return zA=g.then(()=>{},()=>{}),g},Fm=wo(La),FH={get:()=>(cr(),Fm.get()),getSnapshot:()=>(cr(),Fm.getSnapshot()),subscribe:f=>(cr(),Fm.subscribe(f)),observe:f=>(cr(),Fm.observe(f)),list:()=>(cr(),La.get().items),accept:f=>_b("accept",f),reject:f=>_b("reject",f),acceptAll:()=>nh("accept",{scope:"all"},null),rejectAll:()=>nh("reject",{scope:"all"},null),next:()=>Cb(1),previous:()=>Cb(-1),navigateNext:()=>VA(1),navigatePrevious:()=>VA(-1),getAt:f=>{if(!f||typeof f!="object"||typeof f.x!="number"||typeof f.y!="number")return null;const g=Ab(f);if(g.length===0)return null;const w=La.get().items;let A;for(const E of g){if(E.type!=="trackedChange")continue;let B;if(E.story){if(A===void 0&&(A=ts()),!A)continue;B=A}else B=w;const q=B.find(oe=>Ki(oe,E.id,E.story));if(q)return E.story?{id:q.id,item:q,story:E.story}:{id:q.id,item:q}}return null},setActive:f=>{if(f==null)return Ge(null),Ee(null),Dt(),!0;if(!k())return!1;const g=typeof f=="string"?{id:f}:{id:f.id,story:f.story};if(typeof g.id!="string"||g.id.length===0)return!1;const w=g.id;if(g.story){const A=ts();if(!A)return!1;const E=Eu(A,g.story).toPublicId(g.id)??g.id;if(!A.some(B=>Ki(B,E,g.story)))return!1;g.id=E}else{const A=La.get().items,E=pa(A).toPublicId(g.id)??g.id,B=A.find(q=>Gn(q)===E);if(!B)return!1;g.id=E,g.story=gm(B)}return w!==g.id&&(g.paintedEntityId=w),Ge(g),Ee(g),Dt(),!0},scrollTo:async f=>{if(!y())return{success:!1,ok:!1,reason:k()?lt.documentApiUnavailable:lt.notReady};re+=1,xe+=1;const g=xe,w=La.get().items,A=pa(w).toPublicId(f)??f,E=gm(w.find(oe=>Gn(oe)===A)),B=le,q={id:A,...E?{story:E}:{},...A!==f?{paintedEntityId:f}:{}};$e.add(q);try{const oe=await Pm("trackChanges",A,w,E?{story:E}:void 0);if(xe!==g)return{success:!1,ok:!1};if(!oe)return{success:!1,ok:!1,reason:lt.targetUnresolved};Ge(q);const ve=xe,Re=le,Ue=Se,We=()=>xe===ve&&le===Re&&Se===Ue,Le=()=>{We()&&(Ge(B,{invalidateQueuedNavigation:!1}),Dt())};Dt(),Vo+=1;try{const Xe=await xc(oe,{behavior:"auto",shouldContinue:We});return We()?(!Xe.ok&&Xe.reason!==lt.targetNotVisible?(Le(),Ee(B)):Ee(q),Xe):{success:!1,ok:!1}}finally{Vo=Math.max(0,Vo-1),Vo===0&&(We()?Rn&&Po(bi(Rn)):Ee(le))}}finally{$e.delete(q)}}},_b=(f,g)=>{const{id:w,story:A}=typeof g=="string"?{id:g,story:void 0}:g;return nh(f,{kind:"id",id:w,...A?{story:A}:{}},w,A)},nh=(f,g,w,A)=>{try{return br(Sb(f,g,w,A))}catch{return!1}},Sb=(f,g,w,A)=>{if(ti())return!1;const E=y()?.trackChanges,B=g.scope==="all",q=g.kind==="range",oe=g.kind==="ids";if(Cc({kind:f,scope:B?"all":"id"},E))return!1;const ve=B?`${f}All`:f,Re=!q&&!oe&&!A&&E&&typeof E[ve]=="function"?E[ve]:null,Ue=E&&typeof E.decide=="function"?E.decide:null;return!Re&&!Ue?!1:Re?Re.call(E,w??{}):Ue.call(E,{decision:f,target:g})},kb=ii(f=>f.contentControls),rh=f=>kb.get().items.find(g=>g?.id===f)??null,Nm=wo(kb),NH=(f=>{if(f===void 0)return Nm.get();const g=vm(f);return g?rh(g):null}),BH={get:(f=>(f!==void 0&&so("api"),NH(f))),getSnapshot:Nm.getSnapshot,subscribe:Nm.subscribe,observe:Nm.observe,list:()=>(so("api"),kb.get().items),getById:f=>(so("api"),rh(f)),getRect:f=>{const g=vm(f);if(!g)return fl("unresolved");so("panel");const w=rh(g);if(!w)return fl("unresolved");const A=ab(w);return A?jm.getRect({target:A}):fl("unavailable")},scrollIntoView:async f=>{const g=vm(f);if(!g)return{success:!1};so("panel");const w=rh(g);if(!w)return{success:!1};const A=ab(w);return A?{success:(await xc(A,{block:f.block,behavior:f.behavior})).ok}:{success:!1}},focus:async f=>{const g=vm(f);if(!g)return{success:!1,reason:"invalid-id"};if(!k())return{success:!1,reason:"not-ready"};so("panel");const w=rh(g);if(!w)return{success:!1,reason:"not-found"};const A=ab(w);if(!A)return{success:!1,reason:"not-reachable"};if(!(await xc(A,{block:f.block,behavior:f.behavior})).ok)return{success:!1,reason:"not-reachable"};const E=AV(A);if(!E)return{success:!1,reason:"not-reachable"};const B=FA.apply(E);return!B.ok&&B.reason!==lt.hostCapabilityUnavailable?{success:!1,reason:"not-reachable"}:{success:!0}}},Bm=wo(ii(f=>f.fonts)),zH={get:Bm.get,getSnapshot:Bm.getSnapshot,subscribe:Bm.subscribe,observe:Bm.observe,getFamilyOptions:()=>ut.fonts.options,getSizeOptions:()=>ut.fonts.sizeOptions},zm=wo(ii(f=>f.zoom)),VH={get:zm.get,getSnapshot:zm.getSnapshot,subscribe:zm.subscribe,observe:zm.observe,set:f=>{if(typeof t?.setZoom=="function")try{t.setZoom(f),Dt()}catch{}},setMode:f=>{if(typeof t?.setZoomMode=="function")try{t.setZoomMode(f),Dt()}catch{}}},Vm=wo(ii(f=>f.document)),HH={get:Vm.get,getSnapshot:Vm.getSnapshot,subscribe:Vm.subscribe,observe:Vm.observe,setMode:f=>{if(typeof t?.setDocumentMode=="function")try{t.setDocumentMode(f),Dt()}catch{}},export:f=>{if(typeof t?.export=="function")try{return Promise.resolve(t.export(f))}catch{return}},getText:()=>{const f=y(),g=Tt(f?.getText?()=>f.getText({}):void 0,null);return typeof g=="string"?g:g&&typeof g=="object"&&typeof g.text=="string"?g.text:null},replaceFile:f=>{const g=t?.replaceFile??t?.loadDocument??t?.reload;if(typeof g=="function")try{return Promise.resolve(g.call(t,f))}catch{return}}},HA=()=>{if(typeof HTMLElement>"u")return null;const f=k()?.mount?.container;if(f instanceof HTMLElement)return f;const g=t?.element;return g instanceof HTMLElement?g:null},jH=(f,g)=>{if(typeof f!="number"||typeof g!="number"||!Number.isFinite(f)||!Number.isFinite(g))return[];const w=globalThis.document;if(!w||typeof w.elementFromPoint!="function")return[];const A=HA();if(!A)return[];const E=w.elementFromPoint(f,g);if(!E||!A.contains(E))return[];const B=[E],q=tt=>{tt&&A.contains(tt)&&!B.includes(tt)&&B.push(tt)},oe=w.elementsFromPoint;if(typeof oe=="function"){let tt=[];try{tt=oe.call(w,f,g)??[]}catch{tt=[]}for(const Rt of tt)q(Rt)}const ve=[],Re=tt=>{tt&&A.contains(tt)&&!ve.includes(tt)&&!B.includes(tt)&&ve.push(tt)},Ue=tt=>{const Rt=tt.getBoundingClientRect;if(typeof Rt!="function")return!1;let Gt;try{Gt=Rt.call(tt)}catch{return!1}return Gt!=null&&f>=Gt.left&&f<=Gt.right&&g>=Gt.top&&g<=Gt.bottom};for(const tt of B){const Rt=tt.querySelectorAll;if(typeof Rt!="function")continue;let Gt;try{Gt=Rt.call(tt,"[data-track-change-marker]")}catch{continue}for(let en=0;en<Gt.length;en+=1)Ue(Gt[en])&&Re(Gt[en])}ve.reverse();const We=[...ve,...B],Le=uA(We[0],A);for(let tt=1;tt<We.length;tt+=1)for(const Rt of uA(We[tt],A))Le.push(Rt);if(Le.length===0)return Le;const Xe=La.get().items,Ve=pa(Xe);let Ze;const Je=new Set,rt=[];for(const tt of Le){if(tt.type!=="trackedChange"){const Mn=`${tt.type}:${tt.id}`;if(Je.has(Mn))continue;Je.add(Mn),rt.push(tt);continue}const Rt=kV(tt.storyKey)??SV(tt.story);let Gt;if(Rt){if(Ze===void 0&&(Ze=ts()),!Ze||(Gt=Eu(Ze,Rt).toPublicId(tt.id),!Gt||!Ze.some(Mn=>Ki(Mn,Gt,Rt))))continue}else if(Gt=Ve.toPublicId(tt.id),!Gt)continue;const en=`trackedChange:${Gt}`;Je.has(en)||(Je.add(en),rt.push(Rt?{type:"trackedChange",id:Gt,story:Rt}:{type:"trackedChange",id:Gt}))}return rt};function Ab(f,g){return typeof f=="object"?jH(f?.x,f?.y):null}const $u=new Set;let Ib=!1;const jA=f=>{const g=T();if(typeof g?.observeGeometry!="function")return;let w=!1;const A=Tt(()=>{const E=g.observeGeometry(()=>f.schedule());return w=!0,E},null);f.detach=typeof A=="function"?A:null,f.boundHost=w?g:null},Hm=f=>{if(f.detach){try{f.detach()}catch{}f.detach=null}f.boundHost=null},UA=()=>{if(Ib=!1,!(Z||T()))for(const f of $u)Hm(f)},UH=()=>{if(!Ib){if(Ib=!0,typeof queueMicrotask=="function"){queueMicrotask(UA);return}Promise.resolve().then(UA)}},GH=()=>{const f=T();if(!f){UH();return}for(const g of $u)g.boundHost&&g.boundHost===f||(Hm(g),jA(g),g.schedule())};Rl.push(GH);const jm={getRect:f=>{const g=T(),w=g?.getTargetRects;if(typeof w=="function"){const A=Tt(()=>w.call(g,{target:f.target}),null);return A&&typeof A=="object"?A.success===!0&&Array.isArray(A.rects)?YV(qV(A.rects.filter(E=>E!=null&&typeof E=="object")),f.relativeTo):fl(typeof A.reason=="string"?A.reason:"unresolved"):fl("unresolved")}return fl("unavailable")},observe:f=>{const g=[];let w=0;const A=typeof requestAnimationFrame=="function",E=()=>{if(!A){f();return}w||(w=requestAnimationFrame(()=>{w=0,f()}))},B=xa(oe=>({ready:oe.ready,selection:oe.selection,zoom:oe.zoom}));g.push(B.subscribe(()=>E()));const q={schedule:E,detach:null,boundHost:null};return jA(q),$u.add(q),()=>{$u.delete(q),Hm(q),w&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(w);for(const oe of g.splice(0))try{oe()}catch{}}},getHost:()=>HA(),entityAt:Ab,contextAt:f=>{const g=!!f&&typeof f.x=="number"&&typeof f.y=="number",w=g?f.x:0,A=g?f.y:0;return{point:{x:w,y:A},entities:g?Ab({x:w,y:A}):[],selection:ut.selection,position:null,insideSelection:!1}},scrollIntoView:async f=>{const g=f?.target;if(!g)return{success:!1};let w=null;if(g.kind==="entity"){const A=g.entityType==="comment"?"comments":"trackChanges",E=A==="comments"?Ju.get().items:La.get().items,B=g.entityType==="trackedChange"&&g.story?{story:g.story}:void 0;w=await Pm(A,g.entityId,E,B)}else{const A=g,E=g,B=Array.isArray(A.segments)&&A.segments.length>0?A.segments:E.blockId&&E.range?[{blockId:E.blockId,range:E.range}]:null;if(B){const q=g.story;w={kind:"text",segments:B,...q?{story:q}:{}}}}return w?{success:(await xc(w,{block:f.block??"center",behavior:f.behavior??"smooth"})).ok}:{success:!1}}},GA=f=>{const g=(f&&typeof f=="object"?f:null)?.target;return g&&typeof g=="object"?g:null},WA=f=>`metadata:resolve:${f}`,WH=f=>{const g=y()?.metadata;if(!g||typeof g.resolve!="function")return null;const{value:w}=ur(WA(f),Pt(),()=>g.resolve({id:f}),GA);return w},KH=async f=>{const g=y()?.metadata;if(!g||typeof g.resolve!="function")return null;try{const w=Pt(),A=await Promise.resolve(g.resolve({id:f}));if(w!==Pt())return null;const E=GA(A);return ee.set(WA(f),{token:w,value:E,hasSettled:!0,inflightToken:null}),E}catch{return null}},qH={getRect:f=>{const g=y()?.metadata;if(!g||typeof g.resolve!="function")return fl("unavailable");const w=WH(f.id);return w?jm.getRect({target:w}):fl("unresolved")},scrollIntoView:async f=>{const g=await KH(f.id);return g?{success:(await xc(g,{block:f.block,behavior:f.behavior})).ok}:{success:!1}}},YH={inTable:!1,tableNodeId:null,rowIndex:null,columnIndex:null,cellNodeId:null,rows:null,columns:null},XH={getContext:()=>{const f=Fe();if(!f)return{...YH};const g=pe()?.table;return{inTable:!0,tableNodeId:f.tableNodeId,rowIndex:f.rowIndex,columnIndex:f.columnIndex,cellNodeId:f.cellNodeId,rows:typeof g?.rows=="number"?g.rows:null,columns:typeof g?.columns=="number"?g.columns:null}},isInTable:()=>Fe()!=null},Um={query:"",total:0,activeIndex:-1,open:!1,available:!1,caseSensitive:!1,includeDeletedText:!1,regex:!1,canReplace:!1,reason:lt.searchUnavailable};let On={...Um};const Gm=new Set,Pa=()=>{const f=T()?.search;return f&&typeof f=="object"?f:null},Os=()=>{const f=x()?.search;return f&&typeof f=="object"?f:null},oh=()=>{const f=Pa();if(f&&typeof f.setSession=="function")return!0;const g=Os();return!!g&&typeof g.query=="function"&&typeof g.getState=="function"},ss=()=>{for(const f of[...Gm])try{f(On)}catch{}},ai=f=>(On={...On,...f},ss(),On);let Zr=0,Tc=null;const KA=()=>{const f=Tc;Tc=null,f&&Tt(()=>(f(),null),null)},ZH=()=>{Zr+=1,KA();const f=oh();On={...Um,available:f,reason:f?void 0:lt.searchUnavailable},ss()};Ia.push(ZH);const QH=f=>{if(!f)return!1;const g=f.queryError;if(g&&typeof g=="object"&&g.code==="invalid-pattern")return!0;const w=f.rejection;return f.status==="rejected"&&!!w&&typeof w=="object"&&w.code==="invalid-pattern"},Eb=(f,g=!1)=>{const w=f&&typeof f=="object"?f:null;if(!w)return null;const A=Array.isArray(w.matches)?w.matches:[],E=typeof w.total=="number"&&Number.isFinite(w.total)?w.total:A.length,B=typeof w.activeMatchIndex=="number"?w.activeMatchIndex:typeof w.activeIndex=="number"?w.activeIndex:-1;return{...typeof w.query=="string"?{query:w.query}:{},total:E,activeIndex:B,canReplace:w.canReplace===!0||g,...w.includeDeletedText===!0?{includeDeletedText:!0}:{},...w.regex===!0?{regex:!0}:{},...QH(w)?{invalidPattern:!0}:{}}},So=()=>{const f=z("find.replace"),g=z("find.replaceAll");return f?.enabled===!0||g?.enabled===!0},ko=(f,g=!1)=>{const w=Eb(f,g);if(!w){ai({total:0,activeIndex:-1,canReplace:!1,reason:void 0});return}ai({...w.query!==void 0?{query:w.query}:{},total:w.total,activeIndex:w.activeIndex,canReplace:w.canReplace,...w.includeDeletedText!==void 0?{includeDeletedText:w.includeDeletedText}:{},...w.regex!==void 0?{regex:w.regex}:{},reason:w.invalidPattern?lt.searchInvalidPattern:void 0})},Da=()=>{const f=Pa();if(f&&typeof f.getState!="function")return On={...On,available:oh(),reason:oh()?void 0:lt.searchUnavailable},On;if(!f){const w=Os();if(w&&typeof w.getState=="function"){const A=Eb(Tt(()=>w.getState(),null),So());if(A)return On={...On,...A.query!==void 0?{query:A.query}:{},total:A.total,activeIndex:A.activeIndex,canReplace:A.canReplace,available:!0,reason:A.invalidPattern?lt.searchInvalidPattern:void 0,open:On.open||!!A.query},On}return On={...Um,query:On.query,caseSensitive:On.caseSensitive,includeDeletedText:On.includeDeletedText},On}const g=Eb(Tt(()=>f.getState(),null));return g&&(On={...On,...g.query!==void 0?{query:g.query}:{},total:g.total,activeIndex:g.activeIndex,canReplace:g.canReplace,...g.includeDeletedText!==void 0?{includeDeletedText:g.includeDeletedText}:{},...g.regex!==void 0?{regex:g.regex}:{},available:!0,reason:g.invalidPattern?lt.searchInvalidPattern:void 0,open:On.open||!!g.query}),On},ed=f=>{const g=f&&typeof f=="object"?f:null;if(g?.status==="committed")return{ok:!0};if(g?.status==="rejected"&&g.reason==="read-only")return{ok:!1,reason:lt.documentReadonly};const w=g?.rejection;return g?.status==="rejected"&&w&&typeof w=="object"&&w.code==="read-only-document"?{ok:!1,reason:lt.documentReadonly}:{ok:!1,reason:lt.operationUnavailable}},Wm=wo({get:()=>Da(),subscribe:f=>(Gm.add(f),()=>Gm.delete(f))}),JH={get:Wm.get,getSnapshot:Wm.getSnapshot,subscribe:Wm.subscribe,observe:Wm.observe,open:()=>oh()?(ai({available:!0,open:!0,reason:void 0}),{ok:!0}):(ai({available:!1,open:!1,reason:lt.searchUnavailable}),{ok:!1,reason:lt.searchUnavailable}),close:()=>{if(Zr+=1,Tc)KA();else{const f=Pa();if(f&&typeof f.clear=="function")Tt(()=>f.clear(),null);else{const g=Os();g&&typeof g.query=="function"&&Tt(()=>g.query({query:""}),null)}}On={...Um,available:oh(),reason:void 0},On.available||(On.reason=lt.searchUnavailable),ss()},search:(f,g)=>{const w=Pa(),A=!!g?.caseSensitive,E=g?.includeDeletedText===!0,B=g?.regex===!0,q=++Zr;if(!w||typeof w.setSession!="function"){const oe=Os();if(oe&&typeof oe.query=="function"&&typeof oe.getState=="function"){ai({query:f,caseSensitive:A,includeDeletedText:E,regex:B,available:!0,open:!0,reason:void 0}),Tc=()=>{oe.query({query:""})};const ve=Tt(()=>oe.query({query:f,caseSensitive:A,includeDeletedText:E,regex:B}),null);return Tr(ve)?Promise.resolve(ve).then(Re=>{q===Zr&&ko(Re,So())},()=>{q===Zr&&ai({available:!1,reason:lt.searchUnavailable})}):ko(ve,So()),ko(Tt(()=>oe.getState(),null),So()),On}return ai({query:f,total:0,activeIndex:-1,available:!1,caseSensitive:A,includeDeletedText:E,regex:B,reason:lt.searchUnavailable})}if(ai({query:f,caseSensitive:A,includeDeletedText:E,regex:B,available:!0,open:!0,reason:void 0}),Tc=()=>{typeof w.clear=="function"&&w.clear()},ko(Tt(()=>w.setSession(f,{caseSensitive:A,includeDeletedText:E,...B?{regex:!0}:{},highlight:!0}),null)),f.length>0&&On.total===0&&On.reason!==lt.searchInvalidPattern){const oe=Os();if(oe&&typeof oe.query=="function"&&typeof oe.getState=="function"){const ve=Tc;Tc=()=>{ve?.(),oe.query({query:""})};const Re=Tt(()=>oe.query({query:f,caseSensitive:A,includeDeletedText:E,regex:B}),null);Tr(Re)?Promise.resolve(Re).then(Ue=>{q===Zr&&ko(Ue,So())},()=>{q===Zr&&ai({available:!1,reason:lt.searchUnavailable})}):ko(Re,So()),ko(Tt(()=>oe.getState(),null),So())}}return On},next:()=>{const f=Pa();if(!f||typeof f.next!="function"){const g=Os();if(!g||typeof g.next!="function"||typeof g.getState!="function")return{ok:!1,reason:lt.searchUnavailable};if(On.total===0)return{ok:!1,reason:lt.operationUnavailable};const w=Tt(()=>g.next(),null);if(Tr(w)){const A=Zr;Promise.resolve(w).then(E=>{A===Zr&&ko(E,So())}).catch(()=>{A===Zr&&ai({available:!1,reason:lt.searchUnavailable})})}else ko(w,So());return ko(Tt(()=>g.getState(),null),So()),{ok:!0}}return On.total===0?{ok:!1,reason:lt.operationUnavailable}:(ko(Tt(()=>f.next(),null)),{ok:!0})},previous:()=>{const f=Pa();if(!f||typeof f.previous!="function"){const g=Os();if(!g||typeof g.previous!="function"||typeof g.getState!="function")return{ok:!1,reason:lt.searchUnavailable};if(On.total===0)return{ok:!1,reason:lt.operationUnavailable};const w=Tt(()=>g.previous(),null);if(Tr(w)){const A=Zr;Promise.resolve(w).then(E=>{A===Zr&&ko(E,So())}).catch(()=>{A===Zr&&ai({available:!1,reason:lt.searchUnavailable})})}else ko(w,So());return ko(Tt(()=>g.getState(),null),So()),{ok:!0}}return On.total===0?{ok:!1,reason:lt.operationUnavailable}:(ko(Tt(()=>f.previous(),null)),{ok:!0})},clear:()=>{Zr+=1;const f=Pa();if(f&&typeof f.clear=="function"&&Tt(()=>f.clear(),null),!f||typeof f.clear!="function"){const g=Os();g&&typeof g.query=="function"&&Tt(()=>g.query({query:""}),null)}ai({query:"",total:0,activeIndex:-1,canReplace:!1})},replace:f=>{const g=Pa();if(!g){const A=Os();if(!A||typeof A.replace!="function"||typeof A.getState!="function")return{ok:!1,reason:lt.searchUnavailable};if(!So())return{ok:!1,reason:lt.operationUnavailable};const E=Tt(()=>A.replace({replacement:typeof f=="string"?f:""}),null);if(Tr(E)){const B=Zr;Da(),ss();const q=()=>B===Zr;return Promise.resolve(E).then(oe=>(q()&&(ko(oe,So()),Da(),ss()),ed(oe)),()=>(q()&&ai({available:!1,reason:lt.searchUnavailable}),{ok:!1,reason:lt.searchUnavailable}))}return Da(),ss(),ed(E)}if(typeof g.replaceCurrent!="function")return{ok:!1,reason:lt.operationUnavailable};const w=Tt(()=>g.replaceCurrent(typeof f=="string"?f:""),null);return Da(),ss(),ed(w)},replaceAll:f=>{const g=Pa();if(!g){const A=Os();if(!A||typeof A.replaceAll!="function"||typeof A.getState!="function")return{ok:!1,reason:lt.searchUnavailable};if(!So())return{ok:!1,reason:lt.operationUnavailable};const E=Tt(()=>A.replaceAll({replacement:typeof f=="string"?f:""}),null);if(Tr(E)){const B=Zr;Da(),ss();const q=()=>B===Zr;return Promise.resolve(E).then(oe=>(q()&&(ko(oe,So()),Da(),ss()),ed(oe)),()=>(q()&&ai({available:!1,reason:lt.searchUnavailable}),{ok:!1,reason:lt.searchUnavailable}))}return Da(),ss(),ed(E)}if(typeof g.replaceAll!="function")return{ok:!1,reason:lt.operationUnavailable};const w=Tt(()=>g.replaceAll(typeof f=="string"?f:""),null);return Da(),ss(),ed(w)}},qA=ii(f=>f.styles),Km=wo(qA),$H={get:Km.get,getSnapshot:Km.getSnapshot,subscribe:Km.subscribe,observe:Km.observe,getCatalog:f=>Qe(f).value,getQuickGallery:()=>qA.get().quickGallery,getActiveParagraphStyle:()=>nt(ut.selection,ct().cache).style},YA={select:xa,get state(){return ut},selection:FA,commands:MH,toolbar:LH,comments:PH,trackChanges:FH,contentControls:BH,fonts:zH,zoom:VH,document:HH,viewport:jm,metadata:qH,tables:XH,search:JH,styles:$H,formatPainter:{setPointerSelecting(f){Z||(h={...h,pointerSelecting:f})},notifyPointerUp(){Z||(h={...h,pointerSelecting:!1},LA())},setKeyboardSelecting(f){Z||(h={...h,keyboardSelecting:f})},notifyKeyUp(){Z||(h={...h,keyboardSelecting:!1},LA())},cancel(){Z||kr()},onModeChange(f){return Z?()=>{}:(p.add(f),()=>p.delete(f))}},createScope:()=>{const f=[];return{select:(g,w)=>{const A=xa(g,w);return{get:A.get,subscribe:E=>{const B=A.subscribe(E);return f.push(B),B}}},dispose:()=>{for(const g of f.splice(0))g()}}},destroy:()=>{if(!Z){Z=!0,hn.reset(),Ye(),K&&(clearTimeout(K),K=null),te&&(clearTimeout(te),te=null,Y=0),H?.timer&&(clearTimeout(H.timer),H.timer=null),H=null,me&&(clearTimeout(me),me=null),_e&&(clearTimeout(_e),_e=null),ot&&ot(),ot=null,vt=null,$t.clear(),D.clear();for(const f of Ll.splice(0))f();Cn&&Cn(),Cn=null,Ut=null,Kn&&Kn(),Kn=null,Sr=null,at&&at(),at=null,Rn=null,An&&An(),An=null,pn=null,oi&&oi(),oi=null,Ur=null;for(const f of $u)Hm(f);$u.clear(),qe.clear(),Gm.clear(),m+=1,p.clear(),Zr+=1,fe.clear()}}};return S=YA,YA}var nH=[{value:"Arial",label:"Arial",previewFamily:"Arial, sans-serif"},{value:"Calibri",label:"Calibri",previewFamily:"Calibri, sans-serif"},{value:"Courier New",label:"Courier New",previewFamily:'"Courier New", monospace'},{value:"Georgia",label:"Georgia",previewFamily:"Georgia, serif"},{value:"Times New Roman",label:"Times New Roman",previewFamily:'"Times New Roman", serif'},{value:"Verdana",label:"Verdana",previewFamily:"Verdana, sans-serif"}];function rH(e){const t=e.trim(),n=t[0];if(n==='"'||n==="'"){const o=t.indexOf(n,1);if(o>0)return t.slice(1,o).trim()}const r=t.indexOf(",");return(r===-1?t:t.slice(0,r)).trim().replace(/^["']|["']$/g,"")}function oH(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n,o=typeof r.logicalFamily=="string"?rH(r.logicalFamily):"";if(!o)continue;const i=typeof r.previewFamily=="string"&&r.previewFamily.trim()?r.previewFamily.trim():o;t.push({value:o,label:o,previewFamily:i})}return t}function iH(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n,o=typeof r.value=="string"?r.value.trim():"";if(!o)continue;const i=typeof r.label=="string"&&r.label.trim()?r.label.trim():o,s=typeof r.previewFamily=="string"&&r.previewFamily.trim()?r.previewFamily.trim():o;t.push({value:o,label:i,previewFamily:s})}return t}function sH(e,t=[]){const n=[],r=new Set,o=s=>{const a=String(s.value).trim().toLowerCase();!a||r.has(a)||(r.add(a),n.push(s))};for(const s of e)o(s);const i=t.length?t:nH;for(const s of i)o(s);return n}var aH=[{value:"8",label:"8"},{value:"9",label:"9"},{value:"10",label:"10"},{value:"11",label:"11"},{value:"12",label:"12"},{value:"14",label:"14"},{value:"16",label:"16"},{value:"18",label:"18"},{value:"24",label:"24"},{value:"36",label:"36"}];function lH(e,t){return e.activeMark?t.activeMarks.includes(e.activeMark):!1}xt();var cH=Object.freeze(["#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F","#BB8FCE","#85C1E2","#F1948A","#82E0AA","#F8C471","#AED6F1","#D7BDE2","#A3E4D7","#F0B27A","#AEB6BF","#E74C3C","#2ECC71","#3498DB","#E67E22","#1ABC9C","#9B59B6","#34495E","#F39C12"]);async function uH(e,t){const n=new m6.default;return e.forEach((r,o)=>{n.file(t[o],r)}),n.generateAsync({type:"blob",compression:"DEFLATE"})}function mb(e){return!!(e&&(e.synced===!0||e.isSynced===!0))}function IA(e){try{e.synced=!0}catch{}try{e.isSynced=!0}catch{}}function dH(e,t){if(!e)return()=>{};if(mb(e))return t(),()=>{};const n=typeof e.on=="function"?e.on.bind(e):null,r=typeof e.off=="function"?e.off.bind(e):null;if(!n)return t(),()=>{};let o=!1;const i=()=>{o||(o=!0,r?.("synced",a),r?.("sync",l))},s=()=>{o||(i(),t())},a=()=>{IA(e),s()},l=u=>{u!==!1&&(u===!0||mb(e))&&(IA(e),s())};return n("synced",a),n("sync",l),mb(e)&&s(),i}function Zo(e){return!!(e&&typeof e=="object"&&e.editorVersion===2)}function fH(e){const t=e&&typeof e=="object"?e.code:null;return t==="comment-export-missing-story-reference"||t==="v2-worker-comment-export-mode-unsupported"}function EA(e){return typeof e=="string"&&e.length>0?e:null}function gb(e){return e?Zo(e)?EA(e.documentId??e.options?.documentId??null):EA(typeof e.getDocumentId=="function"?e.getDocumentId():e.options?.documentId):null}function hH(e){if(!e||Zo(e))return null;const t=e;return t.documentRenderer??t.presentationEditor??null}function Xi(e){if(!e)return null;if(Zo(e))return e.fonts??null;const t=hH(e);return t?{getReport:()=>t.getFontReport?.()??[],getMissingFonts:()=>t.getMissingFonts?.()??[],getDocumentFonts:()=>[...new Set((t.getFontReport?.()??[]).map(n=>n.logicalFamily))],getDocumentFontOptions:()=>t.getDocumentFontOptions?.()??[],getFontFamilyOptions:()=>t.getFontFamilyOptions?.()??[],getLastFontsChangedPayload:()=>t.getLastFontsChangedPayload?.()??null,map:n=>t.mapFonts(n),unmap:n=>t.unmapFonts(n),add:n=>t.addFonts(Array.isArray(n)?n:[n]),preload:n=>t.preloadFonts(n)}:null}var Cm=class extends Ym.default{static{this.allowedTypes=[Or,Ql,ep]}#t=!1;#n=!1;#e=null;#i=null;#s=null;#a=null;#u=null;#d=null;#l=z4({});get uiConfig(){return this.#l}#f=V4({});get interactionConfig(){return this.#f}#m=j4({});get surfacesConfig(){return this.#m}#o;#r=new cN;#p=null;#y=!1;constructor(e){if(super(),this.version="0.0.0",this.users=[],this.whiteboard=null,this.colors=[],this.readyEditors=0,this.pendingCollaborationSaves=0,this.config={selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",document:{},documents:[],editorExtensions:[],colors:[],users:[],user:{...Y0},layoutEngineOptions:{},modules:{},licenseKey:void 0,telemetry:{enabled:!0},title:"SuperDoc",conversations:[],isInternal:!1,comments:{visible:!1},toolbarGroups:["left","center","right"],toolbarIcons:{},toolbarTexts:{},uiDisplayFallbackFont:"Arial, Helvetica, sans-serif",isDev:!1,disablePiniaDevtools:!1,onEditorBeforeCreate:()=>null,onEditorCreate:()=>null,onEditorDestroy:()=>null,onSourceComplete:()=>null,onSourceSignalsComplete:()=>null,onContentError:()=>null,onReady:()=>null,onCommentsUpdate:()=>null,onContentControlActiveChange:()=>null,onContentControlClick:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onPaginationUpdate:()=>null,onTransaction:()=>null,disableContextMenu:!1,viewOptions:{layout:"print"},useLayoutEngine:!0},!e.selector)throw new Error("SuperDoc: selector is required");const t=typeof e.selector=="string"?document.querySelector(e.selector):e.selector;if(!(t instanceof HTMLElement))throw new Error("SuperDoc: selector must be a valid CSS selector string or DOM element");this.#o=new QF({getModuleConfig:()=>this.#m}),this.#w(e,t)}async#w(e,t){this.config={...this.config,...e},!this.config.comments||typeof this.config.comments!="object"?this.config.comments={visible:!1}:typeof this.config.comments.visible!="boolean"&&(this.config.comments.visible=!1),oN(this.config),this.config.documents=this.config.documents||[],this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};const n=this.config.viewOptions?.layout==="web",r=this.config.layoutEngineOptions?.flowMode==="semantic";if(n&&this.config.useLayoutEngine&&!r&&(console.warn("[SuperDoc] Web layout uses PM fallback unless layoutEngineOptions.flowMode is set to 'semantic'. Automatically disabling layout engine."),this.config.useLayoutEngine=!1),!n&&r&&(console.warn("[SuperDoc] flowMode 'semantic' is only valid with web layout. Coercing to 'paginated'."),this.config.layoutEngineOptions.flowMode="paginated"),this.editorVersion=2,this.#ve(),this.config.user=iN(this.config.user),this.config.layoutEngineOptions.virtualization||(this.config.layoutEngineOptions.virtualization={enabled:!0,window:5,overscan:1}),this.config.modules=this.config.modules||{},Object.prototype.hasOwnProperty.call(this.config.modules,"comments")||(this.config.modules.comments={}),this.config.modules.comments=L_(this.config.modules.comments),this.#l=z4(this.config),this.#f=V4(this.config),this.#m=j4(this.config),this.config.disableContextMenu=!this.#l.contextMenu.enabled,this.config.rulers=this.#l.ruler.enabled,this.#l.comments.enabled?this.config.modules.comments===!1&&(this.config.modules.comments={}):this.config.modules.comments=!1,this.#l.comments.enabled){this.config.modules.comments===!0&&(this.config.modules.comments={});const i=this.config.modules.comments;i&&Object.assign(i,this.#f.comments)}if(this.config.colors=S6(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="2.4.0-next.1",this.#b("π¦ [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||as(),this.colors=this.config.colors??[],this.#x(),await x8(),this.#t)return;if(await this.#T(this.config.modules),this.#t){this.#le();return}this.config.cspNonce&&this.#E(),this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.#p||(this.#p=this.#r.subscribe(i=>{this.#be(i.nextRuntimeId,i.legacyEditorProjection)})),this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null;const o=document.createElement("div");o.style.display="contents",t.appendChild(o),this.#u=o,this.#L(),this.#S(),this.#we(),this.#_()}#_(){if(this.#M(),this.readyEditors=0,!this.app)throw new Error("SuperDoc: #startRuntime called before #initVueApp populated this.app");this.app.mount(this.#u)}#S(){const e=this.config.modules?.whiteboard,t=e!==!1&&(e?.enabled??!1);this.whiteboard=new kD({Renderer:YF,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#h("requiredNumberOfEditors").documents.filter(e=>e.type===Or).length}get ui(){return this.#d||(this.#d=tH({superdoc:this}),this.#t&&this.#d.destroy()),this.#d}get state(){return{documents:this.#h("state").documents,users:this.users}}getDocumentRuntimeForDocument(e){return typeof e!="string"||e.length===0?null:(this.superdocStore?.documents??[]).find(t=>t?.getEditor?.()?.options?.documentId===e)?.getDocumentRuntime?.()??null}getComment(e){return typeof e!="string"||e.length===0?null:this.commentsStore?.getComment?.(e)??null}get element(){return typeof this.config.selector=="string"?document.querySelector(this.config.selector):this.config.selector}#E(){const e=this.config.cspNonce,t=document.createElement;document.createElement=function(n){const r=t.call(this,n);return n.toLowerCase()==="style"&&r.setAttribute("nonce",e),r}}#x(){const e=this.config.document,t=!!e&&typeof e=="object"&&Object.keys(e)?.length,n=!!e&&typeof e=="string"&&e.length>0,r=!!e&&typeof File=="function"&&e instanceof File,o=!!e&&e instanceof Blob&&!(e instanceof File),i=this.config.documents&&this.config.documents?.length;if(t&&i&&console.warn("π¦ [superdoc] You can only provide one of document or documents"),t){const s=Yd(this.config.document);this.config.documents=[{id:as(),...s}]}else if(n)this.config.documents=[{id:as(),type:Or,url:this.config.document,name:"document.docx"}];else if(r){const s=Yd(this.config.document);this.config.documents=[{id:as(),...s}]}else if(o){const s=Yd(this.config.document);this.config.documents=[{id:as(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=Yd(s);if(!a||typeof a!="object")return a;const l=typeof a=="object"&&"id"in a&&a.id||s&&typeof s=="object"&&"id"in s&&s.id;return{...a,id:l||as()}}))}#M(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=fD({disablePiniaDevtools:!!this.config.disablePiniaDevtools});this.app=e,this.pinia=t,this.app.config.globalProperties.$config=this.config,this.app.config.globalProperties.$documentMode=this.config.documentMode,this.app.config.globalProperties.$superdoc=this,this.app.provide("surfaceManager",this.#o),this.superdocStore=n,this.commentsStore=r,this.highContrastModeStore=o,typeof this.superdocStore.setExceptionHandler=="function"&&this.superdocStore.setExceptionHandler(s=>this.emit("exception",s)),this.superdocStore.init(this.config);const i=this.config.modules.comments;this.commentsStore.init(i||{}),this.isCollaborative&&h8(this),this.#ae()}#c(e,t){t&&this.on(e,t)}#L(){this.#c("editorBeforeCreate",this.config.onEditorBeforeCreate),this.#c("editorCreate",this.config.onEditorCreate),this.#c("editorDestroy",this.config.onEditorDestroy),this.#c("source:complete",this.config.onSourceComplete),this.#c("source:signals-complete",this.config.onSourceSignalsComplete),this.#c("ready",this.config.onReady),this.#c("comments-update",this.config.onCommentsUpdate),this.#c("content-control:active-change",this.config.onContentControlActiveChange),this.#c("content-control:click",this.config.onContentControlClick),this.#c("awareness-update",this.config.onAwarenessUpdate),this.#c("locked",this.config.onLocked),this.#c("pdf:document-ready",this.config.onPdfDocumentReady),this.#c("sidebar-toggle",this.config.onSidebarToggle),this.#c("collaboration-ready",this.config.onCollaborationReady),this.on("collaboration-ready",e=>this.#U(e?.editor??null)),this.#c("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.#c("exception",this.config.onException),this.#c("list-definitions-change",this.config.onListDefinitionsChange),this.#c("pagination-update",this.config.onPaginationUpdate),this.#c("fonts-resolved",this.config.onFontsResolved),this.#c("fonts-changed",this.config.onFontsChanged),this.#c("zoomChange",this.config.onZoomChange),this.#c("viewport-change",this.config.onViewportChange)}async#T({collaboration:e}={}){return e?(this.isCollaborative=!1,this.config.documents.length===0&&(this.config.documents=[{id:as(),type:Or,name:"document.docx"}]),this.config.v2CollaborationPreflightFailure={code:"collaboration-v1-config-unsupported",message:"SuperDoc v2 cannot use modules.collaboration because it is the SuperDoc v1 collaboration API. SuperDoc did not attach the provider or change the document. Configure Document.v2Collaboration with a v2 room instead."},this.config.documents):this.config.documents}#P(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=Wr(e),this.provider=Wr(t),this.#W();const n=this.config;this._cleanupAwareness=l8(t,this,n.user),n.documents.forEach(r=>{r.ydoc=e,r.provider=t,r.role=this.config.role})}#k(){this.#a=null,this.#g(),typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null),this.isCollaborative=!1,this._commentsCollabInitialized=!1,this.ydoc=void 0,this.provider=void 0;const e=this.config;delete e.modules.collaboration,e.documents.forEach(t=>{delete t.ydoc,delete t.provider})}#g(){if(this.#i){try{this.#i()}catch{}this.#i=null}if(this.#s){try{this.#s()}catch{}this.#s=null}}#U(e){this.#g(),Zo(e)&&(this.#G(e),this.#D(e))}#G(e){const t=e.presence;if(!t||typeof t.subscribe!="function")return;const n=wD(()=>this.user),r=o=>{if(this.#t)return;const i=n.next(o);this.emit("awareness-update",{...i,superdoc:this})};try{const o=t.getSnapshot?.();o&&r(o),this.#i=t.subscribe(r)}catch(o){console.warn("[SuperDoc] v2 awareness bridge failed to subscribe",o)}}#D(e){const t=e.lock;if(!t||typeof t.subscribe!="function")return;const n=r=>{this.#t||this.#C(!!r.isLocked,this.#O(r.lockedBy??null))};try{if(this.#a&&typeof t.setLocked=="function"){const o=this.#a;t.setLocked(o.isLocked,o.isLocked?o.lockedBy:null),this.#a=null}const r=t.getSnapshot?.();r&&n(r),this.#s=t.subscribe(n)}catch(r){console.warn("[SuperDoc] v2 lock bridge failed to subscribe",r)}}#O(e){return!e||typeof e!="object"||Array.isArray(e)?null:{...e}}#F(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}#C(e,t){this.isLocked===e&&this.#F(this.lockedBy,t)||(this.isLocked=e,this.lockedBy=t,this.#b("π¦ [superdoc] Locking superdoc:",e,t,`
|
|
102
|
+
`;xt();var Ss=e=>{e.expand.value=!1};function nb(e,t){const n={...e??{}};return t?n.href=t:delete n.href,n}function oA(e){const t=Array.isArray(e?.segments)?e.segments:[];if(e?.kind!=="text"||!t.length)return null;const n=t[0],r=t[t.length-1];if(!n?.blockId||!r?.blockId||!n.range||!r.range)return null;const o=e.story;return{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start??0,...o?{story:o}:{}},end:{kind:"text",blockId:r.blockId,offset:r.range.end??0,...o?{story:o}:{}},...o?{story:o}:{}}}function Uz(e){return typeof e?.quotedText=="string"?e.quotedText:typeof e?.text=="string"?e.text:""}function iA(e){return e.ui?.selection?.get?.()??e.ui?.selection?.current?.()??null}function Gz(e){return!!(e.config?.superdoc?.config?.modules?.ai||e.superdoc?.config?.modules?.ai)}function Wz(e){return e.config?.superdoc?.config?.modules?.ai??e.superdoc?.config?.modules?.ai??{}}const Kz=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:o,availableWidth:i,role:s,isDev:a=!1}={})=>{const l=kn({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),u=(r??BB).map(WB),c=kn({type:"dropdown",name:"fontFamily",tooltip:n.fontFamily,command:"setFontFamily",defaultLabel:"Arial",label:"Arial",markName:"textStyle",labelAttr:"fontFamily",hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,isWide:!0,style:{width:"116px"},suppressActiveHighlight:!0,attributes:{ariaLabel:"Font family"},options:u,onActivate:({fontFamily:Ye}={},Et=!1)=>{if(Et){c.label.value="",c.selectedValue.value="";return}if(!Ye)return;Ye=Ye.split(",")[0],c.label.value=Ye;const Ot=u.find(Kt=>Kt.label===c.defaultLabel.value),wn=u.find(Kt=>Kt.label===Ye);wn?c.selectedValue.value=wn.key:Ot?c.selectedValue.value=Ot.key:c.selectedValue.value=""},onDeactivate:()=>{c.label.value=c.defaultLabel.value;const Ye=u.find(Et=>Et.label===c.defaultLabel.value);Ye?c.selectedValue.value=Ye.key:c.selectedValue.value=""}}),d=kn({type:"dropdown",name:"ai",dropdownStyles:{padding:0,outline:"none"},tooltip:n.ai,icon:t.ai,hideLabel:!0,hasCaret:!1,isWide:!0,suppressActiveHighlight:!0,attributes:{ariaLabel:"AI"},options:[{type:"render",key:"ai",render:()=>h(d)}]});function h(Ye){const Et=iA(e),Ot=Et?.selectionTarget??oA(Et?.target),wn=Et?.empty?"":Uz(Et),Kt=Wz(e),Sn=()=>Ss(Ye),Pt=()=>{const De=e.pendingSelectionCapture;De&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(De)};return Vr("div",{},[Vr(yz,{handleClose:Sn,selectedText:wn,target:Ot,doc:e.superdoc?.activeEditor?.doc??null,apiKey:Kt?.apiKey||e.config?.aiApiKey||"",endpoint:Kt?.endpoint||e.config?.aiEndpoint||"",restoreSelection:Pt})])}const m=VB,p=kn({type:"dropdown",name:"fontSize",defaultLabel:"12",label:"12",style:{width:"56px"},markName:"textStyle",labelAttr:"fontSize",tooltip:n.fontSize,hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,suppressActiveHighlight:!0,isWide:!0,command:"setFontSize",attributes:{ariaLabel:"Font size"},options:m,onActivate:({fontSize:Ye},Et=!1)=>{if(Et){p.label.value="",p.selectedValue.value="";return}const Ot=m.find(Pt=>Pt.label===String(p.defaultLabel.value));if(!Ye){p.label.value=p.defaultLabel.value,Ot?p.selectedValue.value=Ot.key:p.selectedValue.value="";return}let wn=xN(Ye,12);wn<8&&(wn=8),wn>96&&(wn=96);let Kt=String(wn);const Sn=m.find(Pt=>Pt.label===Kt||Pt.key===Kt);Sn?p.selectedValue.value=Sn.key:p.selectedValue.value="",p.label.value=Kt},onDeactivate:()=>{p.label.value=p.defaultLabel.value;const Ye=m.find(Et=>Et.label===String(p.defaultLabel.value));Ye?p.selectedValue.value=Ye.key:p.selectedValue.value=""}}),v=kn({type:"separator",name:"separator",isNarrow:!0}),_=kn({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),C=kn({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),k=kn({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),y=kn({type:"dropdown",name:"highlight",icon:t.highlight,hideLabel:!0,markName:"highlight",labelAttr:"color",active:!1,tooltip:n.highlight,command:"setHighlight",noArgumentCommand:"unsetHighlight",suppressActiveHighlight:!0,attributes:{ariaLabel:"Highlight"},options:[{key:"color",type:"render",render:()=>tb(e,y,[],!0)}],onActivate:({color:Ye})=>{y.iconColor.value=Ye||""},onDeactivate:()=>y.iconColor.value=""}),b=kn({type:"dropdown",name:"color",icon:t.color,hideLabel:!0,markName:"textStyle",labelAttr:"color",active:!1,tooltip:n.color,command:"setColor",suppressActiveHighlight:!0,attributes:{ariaLabel:"Color"},options:[{key:"color",type:"render",render:()=>tb(e,b)}],onActivate:({color:Ye})=>{b.iconColor.value=Ye},onDeactivate:()=>b.iconColor.value="#000"}),T=kn({type:"button",name:"search",allowWithoutEditor:!0,active:!1,icon:t.search,tooltip:n.search,group:"right",attributes:{ariaLabel:"Search"}}),R=kn({type:"dropdown",name:"link",markName:"link",icon:t.link,active:!1,tooltip:n.link,attributes:{ariaLabel:"Link dropdown"},options:[{type:"render",key:"linkDropdown",render:()=>P(R)}],onActivate:({href:Ye})=>{R.attributes.value=nb(R.attributes.value,Ye)},onDeactivate:()=>{R.attributes.value=nb(R.attributes.value,null),R.expand.value=!1}});function P(Ye){const Et=iA(e),Ot=Et?.selectionTarget??oA(Et?.target),wn=()=>{const Kt=e.pendingSelectionCapture;Kt&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Kt)};return Vr("div",{},[Vr(TS,{ui:e.ui,linkItem:Ye,textTarget:Ot,restoreSelection:wn,closePopover:()=>Ss(Ye),goToAnchor:()=>{Ss(Ye);const Kt=Ye.attributes.value?.href;if(!Kt)return;const Sn=Kt.slice(1),Pt=(e.ui?.viewport?.getHost?.()??null)?.querySelector?.(`a[name='${Sn}']`);Pt&&mf(Pt)}})])}const j=kn({type:"options",name:"linkInput",command:"toggleLink",active:!1});R.childItem=j,j.parentItem=R;const O=kn({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),V=kn({type:"button",name:"tableOfContents",command:"insertTableOfContents",icon:t.tableOfContents,active:!1,tooltip:n.tableOfContents,disabled:!1,attributes:{ariaLabel:"Table of contents"}}),Q=kn({type:"dropdown",name:"table",icon:t.table,hideLabel:!0,labelAttr:"table",active:!1,tooltip:n.table,command:"insertTable",suppressActiveHighlight:!0,attributes:{ariaLabel:"Table"},options:[{key:"table",type:"render",render:()=>F(Q)}]});function F(Ye){return Vr("div",{},[Vr(Dz,{onSelect:Ot=>{e.emitCommand({item:Ye,argument:Ot}),Ss(Ye),eb(e)}})])}const N=kn({type:"dropdown",name:"tableActions",command:"executeTableCommand",tooltip:n.tableActions,icon:t.tableActions,hideLabel:!0,disabled:!0,attributes:{ariaLabel:"Table actions"},options:[{type:"render",render:()=>z(N)}]}),x=[{label:n.addRowBefore,command:"addRowBefore",icon:t.addRowBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row before"}},{label:n.addRowAfter,command:"addRowAfter",icon:t.addRowAfter,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row after"}},{label:n.addColumnBefore,command:"addColumnBefore",icon:t.addColumnBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column before"}},{label:n.addColumnAfter,command:"addColumnAfter",icon:t.addColumnAfter,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column after"}},{label:n.deleteRow,command:"deleteRow",icon:t.deleteRow,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete row"}},{label:n.deleteColumn,command:"deleteColumn",icon:t.deleteColumn,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete column"}},{label:n.deleteTable,command:"deleteTable",icon:t.deleteTable,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete table"}},{label:n.removeBorders,command:"deleteCellAndTableBorders",icon:t.deleteBorders,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete cell and table borders"}},{label:n.mergeCells,command:"mergeCells",icon:t.mergeCells,props:{"data-item":"btn-tableActions-option",ariaLabel:"Merge cells"}},{label:n.splitCell,command:"splitCell",icon:t.splitCell,props:{"data-item":"btn-tableActions-option",ariaLabel:"Split cells"}},{label:n.fixTables,command:"fixTables",icon:t.fixTables,props:{"data-item":"btn-tableActions-option",ariaLabel:"Fix tables"}}];function z(Ye){return Vr(Hz,{options:x,onSelect:Et=>{Ss(Ye);const{command:Ot}=Et;e.emitCommand({item:Ye,argument:{command:Ot}})}})}const J=kn({type:"dropdown",name:"textAlign",tooltip:n.textAlign,icon:t.alignLeft,command:"setTextAlign",hasCaret:!0,markName:"textAlign",labelAttr:"textAlign",suppressActiveHighlight:!0,attributes:{ariaLabel:"Text align"},options:[{type:"render",render:()=>Vr("div",{},[Vr(YB,{onSelect:Et=>{Ss(J);const Ot={...J,command:"setTextAlign"};Ot.command="setTextAlign",e.emitCommand({item:Ot,argument:Et}),X(J,Et)}})]),key:"alignment"}],onActivate:({textAlign:Ye})=>{X(J,Ye)},onDeactivate:()=>{X(J,"left")}}),X=(Ye,Et)=>{let Ot=Et==="both"?"justify":Et,wn={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},Kt=wn[Ot]??wn.left;Ye.icon.value=Kt},ae=kn({type:"dropdown",name:"list",command:"toggleBulletListStyle",splitButton:!0,splitButtonCommand:"toggleBulletList",icon:t.bulletList,hasCaret:!0,tooltip:n.bulletList,restoreEditorFocus:!0,attributes:{ariaLabel:"Bullet list"},options:[{type:"render",key:"bullet-style-buttons",render:()=>{const Ye=Et=>{Ss(ae);const Ot={...ae,command:"toggleBulletListStyle"};e.emitCommand({item:Ot,argument:Et})};return Vr(nA,{buttons:QB,iconSize:25,selectedStyle:ae.selectedValue.value,onSelect:Ye})}}]}),pe=kn({type:"dropdown",name:"numberedlist",command:"toggleOrderedListStyle",splitButton:!0,splitButtonCommand:"toggleOrderedList",icon:t.numberedList,hasCaret:!0,tooltip:n.numberedList,restoreEditorFocus:!0,attributes:{ariaLabel:"Numbered list"},options:[{type:"render",key:"numbered-style-buttons",render:()=>{const Ye=Et=>{Ss(pe);const Ot={...pe,command:"toggleOrderedListStyle"};e.emitCommand({item:Ot,argument:Et})};return Vr(nA,{buttons:JB,iconSize:30,selectedStyle:pe.selectedValue.value,onSelect:Ye})}}]}),Fe=kn({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),fe=kn({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),ye=kn({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),le=kn({type:"dropdown",name:"zoom",allowWithoutEditor:!0,tooltip:n.zoom,defaultLabel:"100%",label:"100%",hasCaret:!0,command:"setZoom",isWide:!0,style:{width:"71px",minWidth:"71px"},inlineTextInputVisible:!1,hasInlineTextInput:!0,attributes:{ariaLabel:"Zoom"},options:[{label:"50%",key:.5,props:{"data-item":"btn-zoom-option"}},{label:"75%",key:.75,props:{"data-item":"btn-zoom-option"}},{label:"90%",key:.9,props:{"data-item":"btn-zoom-option"}},{label:"100%",key:1,props:{"data-item":"btn-zoom-option"}},{label:"125%",key:1.25,props:{"data-item":"btn-zoom-option"}},{label:"150%",key:1.5,props:{"data-item":"btn-zoom-option"}},{label:"200%",key:2,props:{"data-item":"btn-zoom-option"}}],onActivate:({zoom:Ye})=>{Ye&&(le.label.value=Ye)}}),Se=kn({type:"dropdown",name:"measurementUnit",allowWithoutEditor:!0,tooltip:n.measurementUnit,defaultLabel:"in",label:"in",hasCaret:!0,command:"setMeasurementUnit",group:"right",style:{width:"52px",minWidth:"52px"},inlineTextInputVisible:!1,hasInlineTextInput:!1,attributes:{ariaLabel:"Measurement unit"},options:[{label:"Inches",key:"in",props:{"data-item":"btn-measurement-unit-option"}},{label:"Centimeters",key:"cm",props:{"data-item":"btn-measurement-unit-option"}}],onActivate:({measurementUnit:Ye})=>{Ye&&(Se.label.value=Ye)}}),re=kn({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),xe=kn({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),$e=kn({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),st=kn({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),At=kn({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),Ee=kn({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),Ge=(Ye,Et)=>Ye==="editor"?Et:Ye==="suggester"?Et.filter(Ot=>Ot.value==="suggesting"):Et.filter(Ot=>Ot.value==="viewing"),qe=Ye=>Ye==="editor"?"Editing":Ye==="suggester"?"Suggesting":"Viewing",Z=kn({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:qe(s),label:qe(s),hasCaret:s==="editor",isWide:!0,style:{display:"flex",justifyContent:"flex-end"},inlineTextInputVisible:!1,hasInlineTextInput:!1,group:"right",disabled:s!=="editor",attributes:{dropdownPosition:"right",className:"sd-toolbar-item--doc-mode",ariaLabel:"Document mode"},options:[{type:"render",render:()=>ee(Z)}]}),S=[{label:n.documentEditingMode,value:"editing",icon:t.documentEditingMode,description:n.documentEditingModeDescription},{label:n.documentSuggestingMode,value:"suggesting",icon:t.documentSuggestingMode,description:n.documentSuggestingModeDescription},{label:n.documentViewingMode,value:"viewing",icon:t.documentViewingMode,description:n.documentViewingModeDescription}];function ee(Ye){return Vr(sz,{options:Ge(s,S),onSelect:Et=>{const Ot=e.superdoc?.activeEditor??e.activeEditor;Ss(Ye);const{label:wn,icon:Kt,value:Sn}=Et;Z.label.value=wn,Z.icon.value=Kt,e.emitCommand({item:Z,argument:Sn}),eb(e,Ot)}})}const D=new Map([["separator",20],["zoom",71],["measurementUnit",52],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["default",32]]),U=["search","ruler","undo","overflow","documentMode"],H=kn({type:"button",name:"ruler",command:"toggleRuler",allowWithoutEditor:!0,icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),G=kn({type:"button",name:"formattingMarks",command:"toggleFormattingMarks",allowWithoutEditor:!0,icon:t.formattingMarks,active:!1,tooltip:n.formattingMarks,attributes:{ariaLabel:"Formatting marks"}}),te=kn({type:"dropdown",name:"linkedStyles",command:"setLinkedStyle",tooltip:n.linkedStyles,icon:t.paintbrush,defaultLabel:n.formatText,label:n.formatText,hasCaret:!0,isWide:!0,style:{width:"140px"},suppressActiveHighlight:!0,disabled:!1,attributes:{className:"sd-toolbar-item--linked-styles",ariaLabel:"Linked styles"},options:[{type:"render",key:"linkedStyle",render:()=>{const Ye=Ot=>{Ss(te);const wn=typeof Ot=="string"?Ot:Ot?.id??null;if(!wn)return;const Kt={...te,command:"setLinkedStyle"};e.emitCommand({item:Kt,argument:wn})},Et=e.getActiveLinkedStyleId?.()??null;return Vr("div",{},[Vr(uz,{styles:e.getLinkedStyleOptions?.()??[],onSelect:Ye,selectedOption:Et})])}}],onActivate:({styleId:Ye,styleName:Et})=>{const Ot=Et||Ye;te.label.value=Ye&&Ye!=="Normal"?String(Ot):n.formatText,te.disabled.value=!1},onDeactivate:()=>{te.disabled.value=!0,te.label.value=n.formatText}}),Y=(Ye,Et)=>{if(Et.value==Ye)return Vr("div",{innerHTML:jz,class:"dropdown-select-icon"})},K=kn({type:"dropdown",name:"lineHeight",tooltip:n.lineHeight,icon:t.lineHeight,hasCaret:!1,hasInlineTextInput:!1,hideLabel:!0,inlineTextInputVisible:!1,suppressActiveHighlight:!0,isWide:!1,command:"setLineHeight",dropdownValueKey:"key",selectedValue:"1",attributes:{ariaLabel:"Line height"},options:[1,1.15,1.5,2,2.5,3].map(Ye=>({label:Ye.toFixed(2),key:Ye,icon:()=>Y(Ye,K.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),be=20,me=32,Ce=U.reduce((Ye,Et)=>Ye+(D.get(Et)||D.get("default")),0),Pe=["linkedStyles","clearFormatting","copyFormat","formattingMarks"],it=["zoom","fontFamily","fontSize","redo"],He=i<=Ff.lg,Ct=e.config?.showFormattingMarksButton===!0,Yt=e.config?.showTableOfContentsButton===!0;He&&(Z.attributes.value={...Z.attributes.value,className:`${Z.attributes.value.className} sd-toolbar-item--doc-mode-compact`}),He&&(te.attributes.value={...te.attributes.value,className:`${te.attributes.value.className} sd-toolbar-item--linked-styles-compact`});let St=[re,xe,$e,st,T,le,c,v,p,v,l,_,C,k,b,y,v,R,O,...Yt?[V]:[],Q,N,v,J,ae,pe,Fe,fe,K,v,te,v,H,Se,...Ct?[G]:[],Ee,At,...Gz(e)?[d]:[],ye,Z];if(i<=Ff.md&&o&&(St=St.filter(Ye=>Ye.type!=="separator")),e.config.mode!=="docx"){const Ye=St.findIndex(Ot=>Ot.name.value==="linkedStyles");St.splice(Ye-1,2);const Et=["ruler","zoom","undo","redo"];St=St.filter(Ot=>!Et.includes(Ot.name.value))}const Ft=[];a||(s==="viewer"&&Ft.push($e,st),St=St.filter(Ye=>!Ft.includes(Ye)));const Nt=Ye=>U.includes(Ye.name.value),sn=[],_n=[];let Qt=me+Ce;return St.forEach(Ye=>{const Et=D.get(Ye.name.value)||D.get("default");if(i<Ff.xl+be&&Pe.includes(Ye.name.value)&&o){if(sn.push(Ye),Ye.name.value==="linkedStyles"){const Ot=St.findIndex(wn=>wn.name.value==="linkedStyles");St.splice(Ot+1,1)}return}if(i<Ff.sm&&it.includes(Ye.name.value)&&o){sn.push(Ye);return}if(Nt(Ye)){_n.push(Ye),Qt+=Et;return}Qt<i||!o?(_n.push(Ye),Qt+=Et):sn.push(Ye)}),{defaultItems:_n,overflowItems:sn.filter(Ye=>Ye.type!=="separator")}},sA={bold:"Bold",fontFamily:"Font family",ai:"AI text generation",fontSize:"Font size",italic:"Italic",underline:"Underline",highlight:"Highlight color",strikethrough:"Strikethrough",color:"Text color",search:"Search",link:"Link",image:"Image",tableOfContents:"Table of contents",table:"Insert table",tableActions:"Table options",addRowBefore:"Insert row above",addRowAfter:"Insert row below",addColumnBefore:"Insert column left",addColumnAfter:"Insert column right",deleteRow:"Delete row",deleteColumn:"Delete column",deleteTable:"Delete table",removeBorders:"Remove borders",mergeCells:"Merge cells",splitCell:"Split cell",fixTables:"Fix tables",textAlign:"Alignment",bulletList:"Bullet list",numberedList:"Numbered list",indentLeft:"Left indent",indentRight:"Right indent",directionLtr:"Left-to-right",directionRtl:"Right-to-left",zoom:"Zoom",measurementUnit:"Measurement unit",undo:"Undo",redo:"Redo",trackChanges:"Track Changes",trackChangesAccept:"Accept changes under selection",trackChangesReject:"Reject changes under selection",trackChangesOriginal:"Toggle Show Original",trackChangesFinal:"Toggle Show Final",clearFormatting:"Clear formatting",copyFormat:"Format painter",lineHeight:"Line height",formatText:"Format text",ruler:"Show or hide ruler",formattingMarks:"Show or hide formatting marks",pageBreak:"Insert page break",documentEditingMode:"Editing",documentSuggestingMode:"Suggesting",documentViewingMode:"Viewing",documentEditingModeDescription:"Edit document directly",documentSuggestingModeDescription:"Edits become suggestions",documentViewingModeDescription:"View clean version of document only",linkedStyles:"Linked styles"},qz=e=>e?typeof e!="string"?e instanceof HTMLElement?e:null:e.startsWith("#")||e.startsWith(".")?document.querySelector(e):document.getElementById(e):null;xt();function aA(e){return wN(e)??$0[e]??null}function fm(e,t,n,r={}){if(!e?.commands||!t||typeof e.commands.has=="function"&&!e.commands.has(t))return!1;const o=typeof e.commands.executeAsync=="function"?e.commands.executeAsync:e.commands.execute;if(typeof o!="function")return!1;const i=n===void 0?o.call(e.commands,t):o.call(e.commands,t,n);return i&&typeof i.then=="function"&&Promise.resolve(i).then(()=>r.onSettled?.(),s=>{r.onError?.(s),r.onSettled?.()}),!0}var Yz=new Set(["bold","italic","underline","strike","color","highlight","link","clearFormatting","textAlign","list","numberedlist","indentleft","indentright","lineHeight","linkedStyles"]),Xz=new Set(["list","numberedlist"]);function Zz(e,t){if(e==="fontFamily"||e==="fontSize"||Xz.has(e)&&t?.disabled&&t?.supported!==!1&&t?.reason==null)return!0;if(!Yz.has(e))return!1;const n=t?.reason;return n==="range-selection-required"||n==="selection-required"}function lA(e){return!!e?.closest?.("[data-editor-ui-surface], .toolbar-dropdown-menu, .sd-toolbar-dropdown-menu, .sd-tooltip-content")}function Qz(e){return["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key)}var Jz=class extends Ym.default{config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...er},texts:{...sA},fonts:null,hideButtons:!0,responsiveToContainer:!1,mode:"docx",excludeItems:[],groups:null,customButtons:[],showFormattingMarksButton:!1,showTableOfContentsButton:!1};toolbarItems=[];overflowItems=[];#t=null;#n=null;isDev=!1;role="editor";superdoc;toolbarContainer=null;toolbar=null;_detachFontsChanged=null;constructor(e={}){if(super(),this.config={...this.config,...e},this.toolbarItems=[],this.overflowItems=[],this.isDev=e.isDev||!1,this.superdoc=e.superdoc,this.role=e.role||"editor",this.toolbarContainer=null,this.config.icons={...er,...e.icons},this.config.texts={...sA,...e.texts},this.config.hideButtons=e.hideButtons??!0,this.config.responsiveToContainer=e.responsiveToContainer??!1,this.activeEditor=e.editor??this.superdoc?.activeEditor??null,this.ui=null,this.snapshot=null,this._unsubscribeController=null,this._detachFormatPainterModeChange=null,this._customCommandRegs=new Map,this._lastFontOptionsSignature="",!this.config.selector&&this.config.element&&(this.config.selector=this.config.element),this.toolbarContainer=qz(this.config.selector),this.toolbarContainer){const t=(this.config?.uiDisplayFallbackFont||"").toString().trim()||"Arial, Helvetica, sans-serif";this.toolbarContainer.style.setProperty("--sd-ui-font-family",t)}try{if(this.#e(),this.#u(),this.#l(),this.#s(),this._lastFontOptionsSignature=this.#o(),!this.toolbarContainer){this.updateToolbarState();return}this.app=Zl(GB),this.app.directive("click-outside",Qv),this.app.config.globalProperties.$toolbar=this,this.toolbar=this.app.mount(this.toolbarContainer),this.updateToolbarState()}catch(t){try{this.destroy()}catch{}throw t}}#e(){this.ui=this.superdoc?.ui??null,this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot(),this._unsubscribeController=this.ui.toolbar.subscribe(()=>{this.snapshot=this.ui.toolbar.getSnapshot(),this.updateToolbarState()}),this._detachFormatPainterModeChange=this.ui.formatPainter.onModeChange(e=>{e==="armed"||e==="persistent"?this.#P():this.#k()}))}#i(){this._unsubscribeController?.(),this._unsubscribeController=null,this._detachFormatPainterModeChange?.(),this._detachFormatPainterModeChange=null,this.#k();for(const e of this._customCommandRegs.values())try{e.unregister?.()}catch{}this._customCommandRegs.clear(),this.ui=null,this.snapshot=null}#s(){if(!this.superdoc||typeof this.superdoc.on!="function"||typeof this.superdoc.off!="function")return;const e=()=>{const t=this.#o();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#m()),this.updateToolbarState()};this.superdoc.on("fonts-changed",e),this._detachFontsChanged=()=>{this.superdoc?.off?.("fonts-changed",e)}}#a(){this._detachFontsChanged?.(),this._detachFontsChanged=null}#u(){if(Array.isArray(this.config.groups)){this.config.toolbarGroups=this.config.groups,this.config.groups=null;return}this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length&&(this.config.toolbarGroups=Object.keys(this.config.groups))}getAvailableWidth(){const e=document.documentElement.clientWidth,t=this.toolbarContainer?.offsetWidth??0;return this.config.responsiveToContainer?t:e}#d(e){return e||zB(this.superdoc?.fonts?.getFontFamilyOptions?.()??[])}#l(){const e=this.getAvailableWidth(),t=this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length>0,{defaultItems:n,overflowItems:r}=Kz({superToolbar:this,toolbarIcons:this.config.icons,toolbarTexts:this.config.texts,toolbarFonts:this.#d(this.config.fonts),hideButtons:this.config.hideButtons,availableWidth:e,role:this.role,isDev:this.isDev}),o=this.config.customButtons||[],i=o.map(l=>this.#f(l));o.length&&n.push(...i);let s=[...n.map(l=>l.name.value),...r.map(l=>l.name.value)];if(t){const l=Object.values(this.config.groups).flatMap(d=>d),u=new Set(Object.keys(this.config.groups)),c=i.filter(d=>u.has(d.group?.value||"center")).map(d=>d.name.value);s=[...new Set([...l,...c])]}const a=n.filter(l=>s.includes(l.name.value)).filter(l=>!this.config.excludeItems.includes(l.name.value));if(t)for(const[l,u]of Object.entries(this.config.groups))for(const c of a)u.includes(c.name.value)&&(c.group.value=l);this.toolbarItems=a,this.overflowItems=r.filter(l=>s.includes(l.name.value))}#f(e){const t=kn({...e});t.isCustomToolbarItem=!0;const n=e.command;if(typeof n=="function"&&this.ui?.commands?.register){const r=`__builtin_toolbar__${e.name}`;if(!this._customCommandRegs.has(r)){const o=this.ui.commands.register({id:r,execute:i=>{const s=i?.payload&&typeof i.payload=="object"?i.payload:{};return n({...i,item:t,argument:s.argument,option:s.option})}});this._customCommandRegs.set(r,o)}}return t}#m(){this.#l(),this.emit("toolbar-items-changed")}#o(){if(this.config.fonts)return"custom-fonts";const e=this.superdoc?.fonts?.getFontFamilyOptions?.()??[];return JSON.stringify(e.map(t=>[t.label,t.value,t.previewFamily]))}getToolbarItemByGroup(e){return this.toolbarItems.filter(t=>(t.group?.value||"center")===e)}getToolbarItemByName(e){return this.#r().find(t=>t.name.value===e)}#r(){return[...this.toolbarItems,...this.overflowItems]}getLinkedStyleOptions(){return this.ui?.styles?.getQuickGallery?.()??[]}getActiveLinkedStyleId(){return this.ui?.styles?.getActiveParagraphStyle?.()?.styleId??null}setActiveEditor(e){this.activeEditor=e;const t=this.#o();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#m()),this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot()),this.updateToolbarState()}onToolbarResize=()=>{this.#l(),this.updateToolbarState()};#p(e){return e==="ruler"?!!this.superdoc?.config?.rulers:e==="formattingMarks"?!!this.superdoc?.config?.layoutEngineOptions?.showFormattingMarks:!1}#y(e){return e==="ruler"?typeof this.superdoc?.toggleRuler=="function":e==="formattingMarks"?typeof this.superdoc?.toggleFormattingMarks=="function"||typeof this.superdoc?.setShowFormattingMarks=="function":!1}#w(){const e=this.getToolbarItemByName("documentMode");if(!e)return;const t=(this.snapshot?.commands?.["document-mode"]?.value||"editing").toLowerCase(),n=this.config.texts||{},r=this.config.icons||{},o={editing:{label:n.documentEditingMode||"Editing",icon:r.documentEditingMode||r.documentMode},suggesting:{label:n.documentSuggestingMode||"Suggesting",icon:r.documentSuggestingMode||r.documentMode},viewing:{label:n.documentViewingMode||"Viewing",icon:r.documentViewingMode||r.documentMode}},i=o[t]||o.editing;e.label?.value!==void 0&&(e.label.value=i.label),e.defaultLabel?.value!==void 0&&(e.defaultLabel.value=i.label),e.icon?.value!==void 0&&i.icon&&(e.icon.value=i.icon)}#_(){const e=this.toolbarItems.find(n=>n.name.value==="highlight");if(!e)return;const t={key:"color",type:"render",render:()=>tb(this,e,[],!0)};e.nestedOptions.value=[t]}#S(e){return!!e?.active&&e?.value==null}#E(e){return!!e&&e.disabled===!1&&e.value==null}#x(e){const t=e.name.value;if(t==="tableActions"){const i=tA.map(s=>this.snapshot?.commands?.[s]).some(s=>s&&!s.disabled);return e.setDisabled(!i),!0}if(t==="search")return e.setDisabled(!1),!0;if(Q0(t)?.disposition==="host-routed")return e.setDisabled(!this.#y(t)),this.#p(t)?e.activate():e.deactivate(),!0;const n=aA(t);if(!n)return!1;const r=this.snapshot?.commands?.[n];Zz(t,r)?e.setDisabled(!1):e.setDisabled(!!r?.disabled);const o={textAlign:()=>{r?.value?e.activate({textAlign:r.value}):e.deactivate()},lineHeight:()=>{e.selectedValue.value=r?.value!=null?r.value:""},zoom:()=>{if(r?.value!=null){const i=typeof r.value=="number"?`${r.value}%`:String(r.value);e.onActivate({zoom:i})}},measurementUnit:()=>{r?.value!=null&&e.onActivate({measurementUnit:String(r.value)})},documentMode:()=>{this.#w()},link:()=>{e.active.value=!!r?.active,e.attributes.value=nb(e.attributes.value,r?.value??null)},fontFamily:()=>{if(r?.value!=null){e.activate({fontFamily:r.value});return}if(this.#E(r)){e.activate({},!0);return}e.deactivate()},fontSize:()=>{if(r?.value!=null){e.activate({fontSize:r.value});return}if(this.#S(r)){e.activate({},!0);return}e.deactivate()},color:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},highlight:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},linkedStyles:()=>{const i=r?.value,s=typeof i=="string"?i:i?.styleId,a=i&&typeof i=="object"?i.styleName:null;s?e.activate({styleId:s,styleName:a}):e.label.value=this.config.texts?.formatText||"Format text"},list:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},numberedlist:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},default:()=>{r?.active?e.activate():e.deactivate()}};return(o[t]??o.default)(),!0}updateToolbarState(){this.#w(),this.#_();const e=this.snapshot?.commands?.["document-mode"]?.value||"editing";!(this.snapshot&&(this.superdoc?.activeEditor??this.activeEditor))||e==="viewing"?(this.#M(),this.#r().forEach(n=>{n.allowWithoutEditor?.value&&this.#x(n)})):this.#r().forEach(n=>{n.resetDisabled(),this.#x(n)});const t=this.getToolbarItemByName("copyFormat");t&&(this.snapshot?.copyFormatActive?t.activate():t.deactivate()),this.emit("toolbar-state-change")}#M(){this.#r().forEach(e=>{const{allowWithoutEditor:t}=e;t?.value||e.setDisabled(!0)})}#c(e,t){const n=this.superdoc;if(e==="ruler")return typeof n?.toggleRuler=="function"?(n.toggleRuler(),!0):!1;if(e==="formattingMarks"){if(typeof t=="boolean"&&typeof n?.setShowFormattingMarks=="function")return n.setShowFormattingMarks(t),!0;if(typeof n?.toggleFormattingMarks=="function")return n.toggleFormattingMarks(),!0}return!1}#L(e,t){const n=e?.name?.value;if(!n)return!1;const r={onSettled:()=>this.updateToolbarState(),onError:i=>this.#g(i,n)};if(n==="image"&&t==null)return this.#T();if(n==="tableActions"){const i=eA[t?.command];return i?fm(this.ui,i,void 0,r):!1}if(Q0(n)?.disposition==="unsupported")return!0;const o=aA(n);return o?fm(this.ui,o,t,r):!1}#T(){return this.snapshot?.commands?.image?.disabled||(this.#t||(this.#t=EN({ownerDocument:this.toolbarContainer?.ownerDocument??document,onPick:async e=>{const t=await AN(e,this.superdoc?.config?.handleImageUpload);fm(this.ui,"image",{src:t},{onSettled:()=>this.updateToolbarState(),onError:n=>this.#g(n,"image")})},onError:e=>this.#g(e,"image")})),this.#t.open()),!0}#P(){if(this.#n)return;const e=this.superdoc?.activeEditor?.container??document,t=i=>{lA(i.target)||this.ui.formatPainter.setPointerSelecting(!0)},n=i=>{this.ui.formatPainter.setPointerSelecting(!1),!lA(i.target)&&this.ui.formatPainter.notifyPointerUp()},r=i=>{if(i.key==="Escape"){this.ui.formatPainter.cancel();return}Qz(i)&&this.ui.formatPainter.setKeyboardSelecting(!0)},o=()=>{this.ui.formatPainter.setKeyboardSelecting(!1),this.ui.formatPainter.notifyKeyUp()};e.addEventListener("pointerdown",t),e.addEventListener("pointerup",n),e.addEventListener("keydown",r),e.addEventListener("keyup",o),this.#n=()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",n),e.removeEventListener("keydown",r),e.removeEventListener("keyup",o)}}#k(){this.#n&&(this.#n(),this.#n=null)}#g(e,t){const n=e instanceof Error?e:new Error(String(e));this.emit("exception",{error:n,originalError:e,itemName:t??null,editor:this.superdoc?.activeEditor??this.activeEditor??null})}emitCommand({item:e,argument:t,option:n}){const r=e?.name?.value,{command:o}=e,i=t!=null;if(!(e?.type==="dropdown"&&!i&&(o==="setFontFamily"||o==="setFontSize"))){if(r==="search"){this.superdoc?.emit?.("search:open");return}try{if(Q0(r)?.disposition==="host-routed"){this.#c(r,t),this.updateToolbarState();return}if(typeof o=="function"){const s=`__builtin_toolbar__${r}`;this._customCommandRegs.has(s)&&this.ui?.commands?.execute?this.ui.commands.execute(s,{argument:t,option:n}):o({item:e,argument:t,option:n,ui:this.ui,superdoc:this.superdoc}),this.updateToolbarState();return}if(e?.isCustomToolbarItem&&typeof o=="string"){if(!fm(this.ui,o,t,{onSettled:()=>this.updateToolbarState(),onError:s=>this.#g(s,r)}))throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState();return}if(!this.#L(e,t)&&o)throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState()}catch(s){this.#g(s,r)}}}destroy(){this.#k(),this.#t?.destroy(),this.#t=null,this.#a(),this.#i(),this.app?.unmount(),this.app=null,this.toolbar=null}};function $z(e){return new Jz(e)}function eV(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null||Array.isArray(e)!==Array.isArray(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function tV(e){if(!e||typeof e!="object")return{};const t={};e.fonts&&(t.rFonts={ascii:e.fonts.ascii,hAnsi:e.fonts.hAnsi,eastAsia:e.fonts.eastAsia,cs:e.fonts.cs,asciiTheme:e.fonts.asciiTheme,hAnsiTheme:e.fonts.hAnsiTheme,eastAsiaTheme:e.fonts.eastAsiaTheme,csTheme:e.fonts.csTheme,hint:e.fonts.hint}),e.fontFamily!=null&&(t.fontFamily=e.fontFamily),e.lang&&(t.lang={val:e.lang.val,eastAsia:e.lang.eastAsia,bidi:e.lang.bidi}),e.fontSize!=null&&(t.fontSize=e.fontSize),e.fontSizeCs!=null&&(t.fontSizeCs=e.fontSizeCs);const n=hm(e.color);n!=null&&(t.color=n),e.highlight!=null&&(t.highlight=e.highlight);const r=rV(e.shading);r&&(t.shading=r),e.cs!=null&&(t.cs=e.cs),e.rtl!=null&&(t.rtl=e.rtl),e.bold!=null&&(t.bold=e.bold),e.boldCs!=null&&(t.bCs=e.boldCs),e.italic!=null&&(t.italic=e.italic),e.italicCs!=null&&(t.iCs=e.italicCs);const o=nV(e.underline);o!==void 0&&(t.underline=o),e.strikethrough!=null&&(t.strike=e.strikethrough),e.doubleStrikethrough!=null&&(t.dstrike=e.doubleStrikethrough),e.caps!=null&&(t.caps=e.caps),e.smallCaps!=null&&(t.smallCaps=e.smallCaps),e.outline!=null&&(t.outline=e.outline),e.shadow!=null&&(t.shadow=e.shadow),e.emboss!=null&&(t.emboss=e.emboss),e.imprint!=null&&(t.imprint=e.imprint),e.verticalAlign!=null&&(t.vertAlign=e.verticalAlign),e.characterSpacing!=null&&(t.letterSpacing=e.characterSpacing),e.characterScale!=null&&(t.charScale=e.characterScale),e.kern!=null&&(t.kerning=e.kern),e.baselineShift!=null&&(t.position=e.baselineShift),e.fitTextWidth!=null&&(t.fitText={val:e.fitTextWidth}),e.vanish!=null&&(t.vanish=e.vanish),e.webHidden!=null&&(t.webHidden=e.webHidden),e.specVanish!=null&&(t.specVanish=e.specVanish);const i=oV(e.border);return i&&(t.border=i),t}function hm(e){if(e){if(typeof e=="string")return e;if(e.model==="rgb")return e.value;if(e.model==="auto")return"auto"}}function nV(e){if(e==null)return;const t={};return e.style!=null&&(t.style=e.style),e.color?.model==="rgb"&&(t.color=e.color.value),e.color?.model==="theme"&&(t.themeColor=e.color.theme),Object.keys(t).length>0?t:!0}function rV(e){if(!e)return;const t={},n=hm(e.fill);n!=null&&(t.fill=n);const r=hm(e.color);return r!=null&&(t.color=r),e.pattern!=null&&(t.val=e.pattern),Object.keys(t).length>0?t:void 0}function oV(e){if(!e)return;const t={};e.style!=null&&(t.val=e.style),e.width!=null&&(t.sz=e.width),e.space!=null&&(t.space=e.space);const n=hm(e.color);return n!=null&&(t.color=n),Object.keys(t).length>0?t:void 0}function uc(e){const t=e?.selectionTarget??e?.target;if(!e||!t)return"";try{return JSON.stringify(t)}catch{return String(t)}}function cA(e){return e.split(",").map(t=>t.trim()).filter(Boolean)}function iV(e){const t=[],n=o=>{o&&!t.includes(o)&&t.push(o)};n(e.getAttribute("data-track-change-preferred-target-id"));const r=e.getAttribute("data-track-change-ids");if(r)for(const o of cA(r))n(o);return n(e.getAttribute("data-track-change-id")),t}function uA(e,t){if(!e||typeof e.getAttribute!="function")return[];const n=[],r=new Set;let o=[],i=e;for(;i;){const s=i,a=iV(s),l=a.length>0?s.getAttribute("data-story-key"):null;for(const m of a){const p=`trackedChange:${m}`;if(!r.has(p)){r.add(p);const v={type:"trackedChange",id:m};l&&(v.storyKey=l),n.push(v),o.push(v)}}const u=s.getAttribute("data-layout-story");if(u&&o.length>0){for(const m of o)m.story=u;o=[]}const c=s.getAttribute("data-comment-ids");if(c)for(const m of cA(c)){const p=`comment:${m}`;r.has(p)||(r.add(p),n.push({type:"comment",id:m}))}const d=s.getAttribute("data-sdt-type"),h=s.getAttribute("data-sdt-id");if(h&&d==="structuredContent"){const m=`contentControl:${h}`;if(!r.has(m)){r.add(m);const p=s.getAttribute("data-sdt-scope"),v=s.getAttribute("data-sdt-tag"),_={type:"contentControl",id:h};(p==="block"||p==="inline")&&(_.scope=p),v&&(_.tag=v),n.push(_)}}if(t&&i===t)break;i=i.parentElement}return n}const rb={PAGE:"superdoc-page",FRAGMENT:"superdoc-fragment",LINE:"superdoc-line",INLINE_SDT_WRAPPER:"superdoc-structured-content-inline",INLINE_SDT_LABEL:"superdoc-structured-content-inline__label",BLOCK_SDT:"superdoc-structured-content-block",BLOCK_SDT_LABEL:"superdoc-structured-content__label",TABLE_FRAGMENT:"superdoc-table-fragment",DOCUMENT_SECTION:"superdoc-document-section",SDT_GROUP_HOVER:"sdt-group-hover",TOC_ENTRY:"superdoc-toc-entry",TOC_GROUP_HOVER:"toc-group-hover",IMAGE_FRAGMENT:"superdoc-image-fragment",INLINE_IMAGE:"superdoc-inline-image",LIST_MARKER:"superdoc-list-marker",INLINE_IMAGE_CLIP_WRAPPER:"superdoc-inline-image-clip-wrapper",ANNOTATION:"annotation",ANNOTATION_CONTENT:"annotation-content",ANNOTATION_CARET_ANCHOR:"annotation-caret-anchor"},VU=[rb.INLINE_SDT_LABEL,rb.BLOCK_SDT_LABEL],dA={PM_START:"data-pm-start",PM_END:"data-pm-end",LAYOUT_EPOCH:"data-layout-epoch",TABLE_BOUNDARIES:"data-table-boundaries",SDT_ID:"data-sdt-id",SDT_TYPE:"data-sdt-type",FIELD_ID:"data-field-id",FIELD_TYPE:"data-field-type",DRAGGABLE:"data-draggable",DISPLAY_LABEL:"data-display-label",VARIANT:"data-variant",TYPE:"data-type",LAYOUT_BOUNDARY_SCHEMA:"data-layout-boundary-schema",LAYOUT_FRAGMENT_ID:"data-layout-fragment-id",LAYOUT_STORY:"data-layout-story",LAYOUT_BLOCK_REF:"data-layout-block-ref"},sV=e=>{if(!e)return{kind:"unknown"};if(e==="body")return{kind:"body"};const t=e.indexOf(":"),n=t===-1?e:e.slice(0,t),r=t===-1?void 0:e.slice(t+1);switch(n){case"body":case"header":case"footer":case"footnote":case"endnote":case"textbox":return r?{kind:n,id:r}:{kind:n};default:return{kind:"unknown"}}},HU=`.${rb.BLOCK_SDT}[${dA.SDT_ID}]`,jU=`[${dA.DRAGGABLE}="true"]`;var ro=()=>({oneOf:[{type:"boolean"},{type:"null"}]}),cl=()=>({oneOf:[{type:"string",minLength:1},{type:"null"}]}),ku=()=>({oneOf:[{type:"number"},{type:"null"}]}),Au=e=>({oneOf:[{type:"object",properties:e,additionalProperties:!1,minProperties:1},{type:"null"}]}),aV={type:"object",properties:{style:{oneOf:[{type:"string",minLength:1},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},themeColor:{oneOf:[{type:"string",minLength:1},{type:"null"}]}},additionalProperties:!1,minProperties:1},lV={type:"object",properties:{id:{type:"number"},val:{type:"boolean"}},required:["id"],additionalProperties:!1},cV=()=>({oneOf:[{type:"boolean"},{type:"null"},aV]}),uV=()=>({oneOf:[{type:"array",items:lV,minItems:1},{type:"null"}]});function pm(e,t){return{storage:"mark",markName:e,textStyleAttr:t}}function dV(e){return{storage:"runAttribute",nodeName:"run",runPropertyKey:e}}var ob=(e,t,n)=>({key:e,type:"boolean",ooxmlElement:t,storage:"mark",tracked:!0,carrier:pm(n),schema:ro()}),dc=(e,t,n,r,o)=>({key:e,type:t,ooxmlElement:n,storage:"mark",tracked:!0,carrier:pm("textStyle",o??e),schema:r}),zn=(e,t,n,r,o)=>({key:e,type:t,ooxmlElement:n,storage:"runAttribute",tracked:!1,carrier:dV(o??e),schema:r});const mm=[ob("bold","w:b","bold"),ob("italic","w:i","italic"),ob("strike","w:strike","strike"),{key:"underline",type:"object",ooxmlElement:"w:u",storage:"mark",tracked:!0,carrier:pm("underline"),schema:cV()},{key:"highlight",type:"string",ooxmlElement:"w:highlight",storage:"mark",tracked:!0,carrier:pm("highlight"),schema:cl()},dc("color","string","w:color",cl()),dc("fontSize","number","w:sz",ku()),dc("fontFamily","string","w:rFonts",cl()),dc("letterSpacing","number","w:spacing",ku()),dc("vertAlign","string","w:vertAlign",{oneOf:[{enum:["superscript","subscript","baseline"]},{type:"null"}]}),dc("position","number","w:position",ku()),zn("dstrike","boolean","w:dstrike",ro()),zn("smallCaps","boolean","w:smallCaps",ro()),dc("caps","boolean","w:caps",ro(),"textTransform"),zn("shading","object","w:shd",Au({fill:{oneOf:[{type:"string",minLength:1},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},val:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),zn("border","object","w:bdr",Au({val:{oneOf:[{type:"string",minLength:1},{type:"null"}]},sz:{oneOf:[{type:"number"},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},space:{oneOf:[{type:"number"},{type:"null"}]}}),"borders"),zn("outline","boolean","w:outline",ro()),zn("shadow","boolean","w:shadow",ro()),zn("emboss","boolean","w:emboss",ro()),zn("imprint","boolean","w:imprint",ro()),zn("charScale","number","w:w",ku(),"w"),zn("kerning","number","w:kern",ku(),"kern"),zn("vanish","boolean","w:vanish",ro()),zn("webHidden","boolean","w:webHidden",ro()),zn("specVanish","boolean","w:specVanish",ro()),zn("rtl","boolean","w:rtl",ro()),zn("cs","boolean","w:cs",ro()),zn("bCs","boolean","w:bCs",ro(),"boldCs"),zn("iCs","boolean","w:iCs",ro(),"italicCs"),zn("eastAsianLayout","object","w:eastAsianLayout",Au({id:{oneOf:[{type:"string",minLength:1},{type:"null"}]},combine:{oneOf:[{type:"boolean"},{type:"null"}]},combineBrackets:{oneOf:[{type:"string",minLength:1},{type:"null"}]},vert:{oneOf:[{type:"boolean"},{type:"null"}]},vertCompress:{oneOf:[{type:"boolean"},{type:"null"}]}})),zn("em","string","w:em",cl()),zn("fitText","object","w:fitText",Au({val:{oneOf:[{type:"number"},{type:"null"}]},id:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),zn("snapToGrid","boolean","w:snapToGrid",ro()),zn("lang","object","w:lang",Au({val:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsia:{oneOf:[{type:"string",minLength:1},{type:"null"}]},bidi:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),zn("oMath","boolean","w:oMath",ro()),zn("rStyle","string","w:rStyle",cl(),"styleId"),zn("rFonts","object","w:rFonts",Au({ascii:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hAnsi:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsia:{oneOf:[{type:"string",minLength:1},{type:"null"}]},cs:{oneOf:[{type:"string",minLength:1},{type:"null"}]},asciiTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hAnsiTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsiaTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},csTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hint:{oneOf:[{type:"string",minLength:1},{type:"null"}]}}),"fontFamily"),zn("fontSizeCs","number","w:szCs",ku()),zn("ligatures","string","w14:ligatures",cl()),zn("numForm","string","w14:numForm",cl()),zn("numSpacing","string","w14:numSpacing",cl()),zn("stylisticSets","array","w14:stylisticSets",uV()),zn("contextualAlternates","boolean","w14:cntxtAlts",ro())],UU=new Set(mm.map(e=>e.key)),fV=Object.fromEntries(mm.map(e=>[e.key,e])),GU={mark:mm.filter(e=>e.storage==="mark").map(e=>e.key),runAttribute:mm.filter(e=>e.storage==="runAttribute").map(e=>e.key)};var hV=new Set(Object.values(lt));function ib(e,t){return typeof e=="string"&&hV.has(e)?e:t}function fA(e){if(e&&typeof e=="object"&&e.ok===!1){const t=e.reason;return t==="host-not-ready"||t==="host-disposed"||t==="editing-mount-required"?{ok:!1,reason:lt.notReady}:{ok:!1,reason:ib(t,lt.targetUnresolved)}}return{ok:!0}}var pV=["document-replaced","editorCreate","active-editor-change","document-mode-change","zoomChange","measurement-unit-change","viewport-change","fonts-changed"],mV={[U4.bulletList]:"bullet",[U4.numberedList]:"ordered"};function hA(e){return mV[e]??null}var gV={disc:"disc",circle:"circle",square:"square",decimal:"decimal","decimal-paren":"decimalParenthesis","upper-roman":"upperRoman","lower-roman":"lowerRoman","upper-alpha":"upperLetter","upper-alpha-paren":"upperLetterParenthesis","lower-alpha":"lowerLetter","lower-alpha-paren":"lowerLetterParenthesis"};function vV(e){const t=gV[e];return t?{preset:t,behavior:"toggleStyle"}:{}}var yV={status:"ready",empty:!0,target:null,selectionTarget:null,activeMarks:[],activeCommentIds:[],activeChangeIds:[],quotedText:""};const bV=[{key:"contentControls",match:"exact",note:"full-document SDT catalog parse (the measured during-load cliff)"},{key:"contentControls:inRange:",match:"prefix",note:"same adapter load() as the catalog, issued per settled selection"},{key:"hyperlinks:",match:"prefix",note:"per-block hyperlink list over the loading story"},{key:"styles:catalog:",match:"prefix",note:"WordStyleModel recompile from package bytes"},{key:"comments",match:"exact",note:"audited: full comments list; stale-served during load"},{key:"trackChanges",match:"exact",note:"audited: all-story tracked-changes list; stale-served during load"},{key:"trackChanges:all",match:"exact",note:"audited: all-story tracked-changes list; consumers already fail closed on non-ready"},{key:"tables",match:"exact",note:"reserved: full tables catalog"},{key:"sections",match:"exact",note:"reserved: full sections list"}];var wV=new Set(["/word/comments.xml","/word/commentsExtended.xml","/word/commentsIds.xml"]);function CV(e){return bV.some(t=>t.match==="exact"?t.key===e:e.startsWith(t.key))}var pA={ready:0,stale:1,pending:2};function Iu(...e){let t="ready";for(const n of e)pA[n]>pA[t]&&(t=n);return t}function Tt(e,t){if(typeof e!="function")return t;try{const n=e();return n===void 0?t:n}catch{return t}}function Tr(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function vr(e,t){if(!e)return null;const n=t.split(".");let r=e;for(const o of n){if(r==null)return null;r=r[o]}return typeof r=="function"?r:null}function lr(e,t="CAPABILITY_UNAVAILABLE"){return{success:!1,failure:{code:t,message:e}}}function Nf(e,t){return{success:!1,failure:{code:"PARTIAL_LINK_EDIT",message:"Hyperlink target was updated, but display text replacement failed."},applied:{href:!0,text:!1},hyperlinkResult:e,textResult:t}}function Bf(e){if(!e||typeof e!="object")return null;const t=e.target;return t&&typeof t=="object"?t:null}function sb(e){if(!e||typeof e!="object")return!1;const t=e,n=i=>{if(!i||typeof i!="object")return!1;const s=i;return s.kind==="text"&&typeof s.blockId=="string"&&typeof s.offset=="number"},r=i=>{if(!i||typeof i!="object")return!1;const s=i,a=s.range;return typeof s.blockId=="string"&&typeof a?.start=="number"&&typeof a.end=="number"};if(Array.isArray(t.segments)){const i=t.segments[0],s=t.segments[t.segments.length-1];return r(i)&&r(s)}if(t.kind==="selection")return n(t.start)&&n(t.end);if(t.kind!=="text"||typeof t.blockId!="string")return!1;const o=t.range;return typeof o?.start=="number"&&typeof o.end=="number"}function _V(e){if(!e||typeof e!="object")return null;const t=Bf(e);if(sb(t))return t;const n=e,r=n.navigationTarget&&typeof n.navigationTarget=="object"?n.navigationTarget:null;return r?.kind==="block"&&typeof r.blockId=="string"&&r.blockId.length>0?{kind:"text",blockId:r.blockId,range:{start:0,end:0},...r.story&&typeof r.story=="object"?{story:r.story}:{},...n.address&&typeof n.address=="object"?{address:n.address}:{}}:t}function Cr(e){if(!e||typeof e!="object")return"story:body";const t=e,n=typeof t.storyType=="string"?t.storyType:"body";switch(n){case"body":return"story:body";case"headerFooterPart":return`story:headerFooterPart:${typeof t.refId=="string"?t.refId:""}`;case"headerFooterSlot":return JSON.stringify({storyType:n,section:t.section??null,headerFooterKind:t.headerFooterKind??null,variant:t.variant??null,resolution:t.resolution??"effective",onWrite:t.onWrite??"materializeIfInherited"});case"footnote":return`story:footnote:${typeof t.noteId=="string"?t.noteId:""}`;case"endnote":return`story:endnote:${typeof t.noteId=="string"?t.noteId:""}`;case"textbox":return`story:textbox:${typeof t.textboxId=="string"?t.textboxId:""}`;default:return JSON.stringify(t)}}function zf(e){if(!e||typeof e!="object")return null;const t=e,n=t.address&&typeof t.address=="object"?t.address:null;if(n?.story&&typeof n.story=="object")return n.story;if(t.storyLocator&&typeof t.storyLocator=="object")return t.storyLocator;if(t.trackedChangeStory&&typeof t.trackedChangeStory=="object")return t.trackedChangeStory;const r=Bf(e);if(!r||typeof r!="object")return null;const o=r;if(o.story&&typeof o.story=="object")return o.story;const i=o.address&&typeof o.address=="object"?o.address:null;return i?.story&&typeof i.story=="object"?i.story:null}function Ki(e,t,n){return Gn(e)!==t?!1:n?Cr(zf(e))===Cr(n):!0}function gm(e){const t=zf(e);if(!(!t||Cr(t)===Cr(null)))return t}function SV(e){if(typeof e!="string"||e.length===0)return;const t=sV(e);switch(t.kind){case"body":return;case"footnote":return t.id?{kind:"story",storyType:"footnote",noteId:t.id}:void 0;case"endnote":return t.id?{kind:"story",storyType:"endnote",noteId:t.id}:void 0;case"header":case"footer":return t.id?{kind:"story",storyType:"headerFooterPart",refId:t.id}:void 0;default:return}}function kV(e){if(!(typeof e!="string"||e.length===0||e==="body")){if(e.startsWith("hf:part:")){const t=e.slice(8);return t?{kind:"story",storyType:"headerFooterPart",refId:t}:void 0}if(e.startsWith("fn:")){const t=e.slice(3);return t?{kind:"story",storyType:"footnote",noteId:t}:void 0}if(e.startsWith("en:")){const t=e.slice(3);return t?{kind:"story",storyType:"endnote",noteId:t}:void 0}}}function ab(e){if(!e||typeof e!="object")return null;const t=e.selectionTarget;return t&&typeof t=="object"?t:null}function vm(e){if(!e||typeof e!="object")return null;const t=e.id;return typeof t=="string"&&t.length>0?t:null}function AV(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="selection")return e;const n=t.start;return!n||typeof n!="object"?null:{...t,end:n}}function Gn(e){if(!e||typeof e!="object")return null;const t=e,n=t.id??t.commentId??t.changeId;return typeof n=="string"&&n.length>0?n:null}function IV(e){if(!e||typeof e!="object")return null;const t=e,n=t.anchor,r=t.focus,o=n?.visualCaret,i=r?.visualCaret,s=o?.trackChangeId,a=i?.trackChangeId;return typeof s=="string"&&s.length>0&&s===a?s:null}var mA=new WeakMap;function gA(e){const t=[],n=i=>{typeof i=="string"&&i.length>0&&!t.includes(i)&&t.push(i)},r=i=>{if(!i||typeof i!="object")return;const s=i,a=s.sourceIds;if(a&&typeof a=="object"&&(n(a.wordIdInsert),n(a.wordIdDelete),Array.isArray(a.wordIdOther)))for(const d of a.wordIdOther)n(d);const l=s.wordRevisionIds;l&&typeof l=="object"&&(n(l.insert),n(l.delete),n(l.format));const u=s.replacement;if(u&&typeof u=="object")for(const d of[u.inserted,u.deleted])d&&typeof d=="object"&&(n(d.id),n(d.wordId));const c=s.move;if(c&&typeof c=="object")for(const d of[c.source,c.destination])d&&typeof d=="object"&&(n(d.id),n(d.wordId))};r(e);const o=e?.change;return o&&o!==e&&r(o),t}function pa(e){const t=mA.get(e);if(t)return t;const n=new Set,r=new Map;for(const i of e){const s=Gn(i);if(s){n.add(s);for(const a of gA(i)){r.has(a)||r.set(a,s);const l=`imported:${a}`;r.has(l)||r.set(l,s)}}}const o={toPublicId(i){if(n.has(i))return i;const s=r.get(i);return s!=null&&n.has(s)?s:null},aliasesFor(i){const s=[i];for(const[a,l]of r)l===i&&!s.includes(a)&&s.push(a);return s}};return mA.set(e,o),o}var vA=new WeakMap,yA=new WeakMap;function Eu(e,t){const n=Cr(t);let r=vA.get(e);r||(r=new Map,vA.set(e,r));const o=r.get(n);if(o)return o;const i=pa(e.filter(s=>Cr(zf(s))===n));return r.set(n,i),i}function EV(e){return!!e&&typeof e=="object"&&e.storyType==="textbox"}function xV(e,t){const n=t.filter(o=>e.some(i=>Gn(i)===o&&zf(i)==null));if(n.length===0)return null;if(n.length===1)return n[0];const r=new Set;for(const o of n){const i=e.find(s=>Gn(s)===o);if(i)for(const s of gA(i)){if(r.has(s))return null;r.add(s)}}return n[0]}function TV(e){const t=yA.get(e);if(t)return t;const n=e.filter(o=>zf(o)!=null),r=n.length===e.length?e:n;return yA.set(e,r),r}function RV(e){const{selectionIds:t,publicIds:n,selection:r,bodyItems:o,allStoryItems:i}=e;if(t.length===0)return null;const s=u=>{for(const c of t){const d=u.toPublicId(c);if(d)return d}return null},a=qi(r),l=Cr(a)===Cr(null);if(i){const u=l?TV(i):i,c=s(Eu(u,a));if(c)return c;const d=n?.find(h=>u.some(m=>Ki(m,h,a)));return d||(l?s(pa(o)):EV(a)?xV(i,t):null)}return l?s(pa(o))??t[0]??null:null}function MV(e,t){const n=e.find(r=>Gn(r)===t||r.importedId===t);return n?n.rootCommentId??n.parentCommentId??Gn(n)??t:null}function LV(e){const t=e.selectionTarget;if(t){const s=t.start,a=t.end,l=typeof s?.blockId=="string"?s.blockId:void 0,u=typeof a?.blockId=="string"?a.blockId:l;if(l)return{startBlockId:l,endBlockId:u??l}}const n=e.target,r=n&&Array.isArray(n.segments)?n.segments:[],o=r[0]?.blockId,i=r[r.length-1]?.blockId;return typeof o=="string"?{startBlockId:o,endBlockId:typeof i=="string"?i:o}:null}function Fr(e){const t=[],n=s=>{typeof s=="string"&&s.length>0&&!t.includes(s)&&t.push(s)},r=e.target,o=r&&Array.isArray(r.segments)?r.segments:[];for(const s of o)n(s?.blockId);const i=e.selectionTarget;return i&&(n(i.start?.blockId),n(i.end?.blockId)),t}var PV=64;function fc(e){return e.length<=PV}function qi(e){const t=e.target,n=e.selectionTarget,r=n?.start,o=n?.end,i=t?.story??n?.story??r?.story??o?.story;return i&&typeof i=="object"?i:{kind:"story",storyType:"body"}}function mo(e,t){return{kind:"block",nodeType:"paragraph",nodeId:e,...t&&typeof t=="object"?{story:t}:{}}}function ma(e){return{kind:"block",nodeType:"paragraph",nodeId:e}}function bA(e,t){return{kind:"block",nodeType:"listItem",nodeId:e,...t&&typeof t=="object"?{story:t}:{}}}var wA=720;function ks(e){return Math.round(e*20)}function xu(e){return typeof e=="number"&&Number.isFinite(e)}function DV(e){if(!e||typeof e!="object")return null;const t=e.node;if(!t||typeof t!="object")return null;const n=t.kind==="heading"?t.heading??null:t.kind==="paragraph"?t.paragraph??null:null;if(!n)return null;const r=n.resolved,o=n.props,i=r?.indent??o?.indent;if(!i||typeof i!="object")return null;const s=xu(i.left)?ks(i.left):xu(i.start)?ks(i.start):void 0,a=xu(i.right)?ks(i.right):xu(i.end)?ks(i.end):void 0,l=xu(i.firstLine)?ks(i.firstLine):void 0,u=xu(i.hanging)?ks(i.hanging):void 0;return s==null&&a==null&&l==null&&u==null?null:{...s!=null?{left:s}:{},...a!=null?{right:a}:{},...l!=null?{firstLine:l}:{},...u!=null?{hanging:u}:{}}}function lb(e){const t=e.target,n=t&&Array.isArray(t.segments)?t.segments:[],r=t?.story,o=[];for(const i of n){if(!i||typeof i.blockId!="string")continue;const s=i.range;!s||typeof s.start!="number"||typeof s.end!="number"||s.start===s.end||o.push({kind:"text",blockId:i.blockId,range:{start:s.start,end:s.end},...r?{story:r}:{}})}return o}function OV(e){if(!e||typeof e!="object")return[];const t=e,n=t.story,r=[];if(t.kind==="text"&&t.range&&typeof t.blockId=="string"){const o=t.range;return typeof o.start=="number"&&typeof o.end=="number"&&o.start!==o.end&&r.push({kind:"text",blockId:t.blockId,range:{start:Math.min(o.start,o.end),end:Math.max(o.start,o.end)},...n?{story:n}:{}}),r}if(t.kind==="text"&&Array.isArray(t.segments)){for(const o of t.segments){const i=o?.range;typeof o?.blockId=="string"&&typeof i?.start=="number"&&typeof i?.end=="number"&&i.start!==i.end&&r.push({kind:"text",blockId:o.blockId,range:{start:Math.min(i.start,i.end),end:Math.max(i.start,i.end)},...n?{story:n}:{}})}return r}if(t.kind==="selection"){const o=t.start,i=t.end,s=typeof o?.blockId=="string"&&i?.blockId===o.blockId?o.blockId:null;o?.kind==="text"&&i?.kind==="text"&&s&&typeof o.offset=="number"&&typeof i.offset=="number"&&o.offset!==i.offset&&r.push({kind:"text",blockId:s,range:{start:Math.min(o.offset,i.offset),end:Math.max(o.offset,i.offset)},...t.story??o.story?{story:t.story??o.story}:{}})}return r}function Vf(e){if(!e||typeof e!="object")return null;const t=e,n=t.story;if(t.kind==="text"&&t.range&&typeof t.blockId=="string"){const r=t.range;if(typeof r.start=="number"&&typeof r.end=="number"&&r.start===r.end)return{kind:"text",blockId:t.blockId,range:{start:r.start,end:r.end},...n?{story:n}:{}}}if(t.kind==="text"&&Array.isArray(t.segments)){const r=t.segments[0],o=r?.range;if(typeof r?.blockId=="string"&&typeof o?.start=="number"&&typeof o?.end=="number"&&o.start===o.end)return{kind:"text",blockId:r.blockId,range:{start:o.start,end:o.end},...n?{story:n}:{}}}if(t.kind==="selection"){const r=t.start,o=t.end,i=typeof r?.blockId=="string"&&o?.blockId===r.blockId?r.blockId:null;if(r?.kind==="text"&&o?.kind==="text"&&i&&typeof r.offset=="number"&&typeof o.offset=="number"&&r.offset===o.offset)return{kind:"text",blockId:i,range:{start:r.offset,end:r.offset},...t.story??r.story?{story:t.story??r.story}:{}}}return null}function ul(e){return Vf(e.target)??Vf(e.selectionTarget)}var CA=["fontFamily","fontSize","color","highlight"],FV={undo:"history.undo",redo:"history.redo"},Hf=["bold","italic","underline","strikethrough"];function cb(e){return CA.includes(e)}function Tu(e){const t=e.target,n=t&&Array.isArray(t.segments)?t.segments:[],r=[],o=(l,u,c)=>{typeof l!="string"||typeof u!="number"||typeof c!="number"||r.push({blockId:l,start:Math.min(u,c),end:Math.max(u,c)})};for(const l of n){const u=l?.range;o(l?.blockId,u?.start,u?.end)}if(r.length>0)return r;const i=e.selectionTarget,s=i?.start,a=i?.end;return!s||!a||s.blockId!==a.blockId||o(s.blockId,s.offset,a.offset),r}function Yi(e){const t=e.target,n=e.selectionTarget,r=n?.start,o=n?.end,i=t?.story??n?.story??r?.story??o?.story;return i&&typeof i=="object"?i:void 0}function NV(e){const t=Yi(e);if(!t||typeof t!="object")return"body";const n=t;return JSON.stringify({storyType:typeof n.storyType=="string"?n.storyType:"body",refId:typeof n.refId=="string"?n.refId:null,noteId:typeof n.noteId=="string"?n.noteId:null,textboxId:typeof n.textboxId=="string"?n.textboxId:null})}function ga(e){const t=Tu(e);return t.length===0?null:[NV(e),...t.map(n=>`${n.blockId}:${n.start}-${n.end}`)].join("|")}function _A(e){const t=e.selectionTarget;return!t||typeof t!="object"?null:uc({selectionTarget:t})}function BV(e,t){if(e==="fontSize"){const r=typeof t=="number"?t:Number(t);return Number.isFinite(r)&&r>0?String(r):null}if(typeof t!="string")return null;const n=t.trim();return n.length===0?null:e==="color"||e==="highlight"?n.toUpperCase():n}function zV(e,t){return Math.max(e.start,t.start)<Math.min(e.end,t.end)}function VV(e){if(!e)return[];const t=Array.isArray(e.blocks)?e.blocks:[],n=[];for(const r of t){const o=r?.range,i=r?.blockId;typeof i!="string"||typeof o?.start!="number"||typeof o?.end!="number"||n.push({blockId:i,start:Math.min(o.start,o.end),end:Math.max(o.start,o.end)})}return n}function HV(e,t){return e.length!==t.length?!1:e.every((n,r)=>{const o=t[r];return o?.blockId===n.blockId&&o?.start===n.start&&o?.end===n.end})}function SA(e,t){const n=Tu(t);if(n.length===0)return null;const r=e&&Array.isArray(e.items)?e.items:[];if(r.length===0)return null;const o=r.find(i=>HV(n,VV(i)));if(o)return o;if(n.length===1){const i=r.find(s=>{const a=s?.address;return a?.kind==="block"&&a.nodeId===n[0].blockId});if(i)return i}return r[0]??null}function jV(e,t){const n=t==="fontSize"?e?.fontSizePt??e?.fontSize:t==="highlight"?e?.highlight??e?.backgroundColor:e?.[t];if(typeof n=="number")return Number.isFinite(n)?String(n):void 0;if(typeof n!="string")return;const r=n.trim();if(r.length!==0)return t==="color"||t==="highlight"?r.toUpperCase():r}function ub(e){if(typeof e!="string")return;const t=e.split(",")[0]?.trim().replace(/^['"]+|['"]+$/g,"").trim();if(!t)return;const n=t.toLowerCase();if(!(n==="serif"||n==="sans-serif"||n==="monospace"||n==="cursive"||n==="fantasy"))return t}function UV(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return;const t=Math.round(e*.75*2)/2;if(!(t<=0))return String(t)}function GV(e,t){return e==="fontFamily"?t.toLowerCase():e==="color"||e==="highlight"?t.toUpperCase():t}function kA(e,t){if(!e)return{};const n=new Map;for(const i of Tu(t)){const s=n.get(i.blockId)??[];s.push({start:i.start,end:i.end}),n.set(i.blockId,s)}if(n.size===0)return{};const r=Array.isArray(e.blocks)?e.blocks:[],o={};for(const i of CA){const s=new Map;let a=!1,l=!1;for(const u of r){const c=typeof u?.blockId=="string"?u.blockId:null;if(!c)continue;const d=n.get(c);if(!d?.length)continue;const h=Array.isArray(u?.runs)?u.runs:[];for(const m of h){const p=m?.range,v=typeof p?.start=="number"?p.start:null,_=typeof p?.end=="number"?p.end:null;if(v==null||_==null||!d.some(y=>zV(y,{start:v,end:_})))continue;a=!0;const C=jV(m?.styles,i);if(C===void 0){l=!0;continue}const k=GV(i,C);if(s.has(k)||s.set(k,C),s.size>1)break}if(s.size>1)break}a&&!l&&s.size===1&&(o[i]=[...s.values()][0])}return o}function db(e,t){const n=Fr(e)[0];return n?t==="nodeId"?{kind:"after",nodeId:n}:{kind:"after",target:mo(n)}:{kind:"documentEnd"}}function on(e,t){const n=e.supported??t!=="unsupported",r=e.enabled??(e.disabled!==void 0?!e.disabled:n);return{enabled:r,disabled:!r,active:e.active??!1,supported:n,value:e.value,source:t,reason:r?void 0:e.reason}}function dl(e){if(!e||typeof e!="object")return null;const t=e,n=t.change,r=n&&typeof n=="object"?n:t;return{...t,id:t.id??r.id,change:r}}function ym(e){const t=e,n=t.change;return n&&typeof n=="object"?n:t}function As(e){if(Tr(e))return!0;if(e===!1)return!1;if(e===!0||e==null||typeof e!="object")return!0;const t=e;return"success"in t||"failure"in t||"effects"in t?e:t.status!=="rejected"}function bm(e){return!!e&&typeof e=="object"&&e.success===!0}function go(e){return!(e===!1||e&&typeof e=="object"&&e.success===!1)}function Ru(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function fb(e){const t=[],n=r=>{if(!r||typeof r!="object")return;const o=r;if(Array.isArray(o.runs)&&t.push(o),Array.isArray(o.rows))for(const i of o.rows){const s=i?.cells;if(Array.isArray(s))for(const a of s){const l=a;if(Array.isArray(l?.blocks))for(const u of l.blocks)n(u);l?.paragraph&&n(l.paragraph)}}};if(Array.isArray(e))for(const r of e)n(r);return t}function hc(e,t){return e.sourceAnchor?.sourceNodeId===t?!0:e.id===t}function mi(e){let t=!1,n=null,r=null,o=null;for(const i of e)t=i,!go(i)&&n===null&&(n=i),bm(i)&&(o=i),i!==!1&&(r=i);return n??o??r??t}function WV(e){const t=e?.anchor,n=t?.start,r=t?.end;return typeof n?.blockId!="string"||typeof r?.blockId!="string"||n.blockId!==r.blockId||typeof n.offset!="number"||typeof r.offset!="number"?null:{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.offset},end:{kind:"text",blockId:r.blockId,offset:r.offset}}}function KV(e){return e.startsWith("#")?{kind:"anchor",anchor:e.slice(1)}:{kind:"external",url:e}}function wm(e){return Su(e)?.trackDecision??null}function qV(e){return{found:e.length>0,success:e.length>0,rects:e,rect:e[0]}}function fl(e){return{found:!1,success:!1,rects:[],reason:e}}function YV(e,t){if(!t||typeof t.getBoundingClientRect!="function"||e.rects.length===0)return e;let n;try{const o=t.getBoundingClientRect();n={left:o.left,top:o.top}}catch{return e}const r=e.rects.map(o=>({...o,left:o.left-n.left,right:o.right-n.left,top:o.top-n.top,bottom:o.bottom-n.top}));return{...e,rects:r,rect:r[0]}}function XV(e){if(!e||typeof e!="object")return!1;const t=e;if(typeof t.blockId!="string"||!t.range||typeof t.range!="object")return!1;const n=t.range;return Number.isInteger(n.start)&&Number.isInteger(n.end)&&n.start>=0&&n.start<=n.end}function AA(e){if(!e||e.kind!=="text"||!Array.isArray(e.segments)||e.segments.length===0)return null;const t=Array.from(e.segments);if(!t.every(XV))return null;const n=t[0],r=t[t.length-1],o=e.story;return{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start,...o?{story:o}:{}},end:{kind:"text",blockId:r.blockId,offset:r.range.end,...o?{story:o}:{}},...o?{story:o}:{}}}function ZV(e){return e.selectionTarget?e.selectionTarget:AA(e.target)}function Mu(e){if(e.empty)return null;if(e.selectionTarget)return e.selectionTarget;const t=AA(e.target);return t&&t.start.kind==="text"&&t.end.kind==="text"&&t.start.blockId!==t.end.blockId?null:t}function hb(e){return!e.inline||typeof e.docRoute!="string"?null:e.docRoute.startsWith("format.")?e.docRoute.slice(7):null}var pb={bold:null,italic:null,underline:null,strike:null,color:null,highlight:null,fontFamily:null,fontSize:null,vertAlign:null,smallCaps:null,caps:null,letterSpacing:null,dstrike:null},QV=Object.fromEntries(Object.entries(pb).filter(([e])=>fV[e]?.tracked===!0));function JV(e,t,n,r){switch(e.kind){case"toggle":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n;return typeof o=="boolean"||o===null?{target:t,value:o}:{target:t,value:!r}}case"value-string":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n;return o===null?{target:t,value:null}:typeof o!="string"||o.trim()===""?null:{target:t,value:o}}case"value-number":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n,i=typeof o=="number"?o:Number(o);return!Number.isFinite(i)||i<=0?null:{target:t,value:i}}case"clear":return{target:t,inline:{...pb}};default:return null}}function $V(e){const t=o=>{if(!o||typeof o!="object")return null;const i=o,s=i.rowIndex,a=i.columnIndex;return typeof s!="number"||!Number.isInteger(s)||typeof a!="number"||!Number.isInteger(a)?null:{rowIndex:s,columnIndex:a}};if(!e)return null;const n=t(e.start),r=t(e.end);return!n||!r?null:{start:n,end:r}}function eH(e,t){const{tableNodeId:n,rowIndex:r,columnIndex:o,cellNodeId:i,mergeRange:s}=t;switch(e){case"insert-row-before":return{nodeId:n,rowIndex:r,position:"above"};case"insert-row-after":return{nodeId:n,rowIndex:r,position:"below"};case"delete-row":return{nodeId:n,rowIndex:r};case"insert-column-before":return{nodeId:n,columnIndex:o,position:"left"};case"insert-column-after":return{nodeId:n,columnIndex:o,position:"right"};case"delete-column":return{nodeId:n,columnIndex:o};case"delete-table":return{nodeId:n};case"merge-cells":{const a=s??{start:{rowIndex:r,columnIndex:o},end:{rowIndex:r,columnIndex:o}};return{nodeId:n,start:a.start,end:a.end}}case"split-cell":return i?{nodeId:i,rows:1,columns:2}:null;case"remove-borders":return{nodeId:n,mode:"applyTo",applyTo:"all",border:null};default:return null}}function tH(e){const t=e.superdoc,n=new Map,r=new Map;let o=null,i=0;const s=[];let a=null,l=0,u=!1,c=Promise.resolve(),d=null,h={mode:"idle",snapshot:null,sourceSelectionKey:null,lastClickAt:0,pointerSelecting:!1,keyboardSelecting:!1},m=0;const p=new Set;let v={},_="",C=null;const k=()=>{const f=t?.activeEditor;return f&&typeof f=="object"?f:null},y=()=>{const f=k()?.doc;return f&&typeof f=="object"?f:null},b=()=>{const f=k()?.v2TrackedChanges;return f&&typeof f=="object"?f:null},T=()=>{const f=k()?.host;return f&&typeof f=="object"?f:null},R=f=>{if(f.storyType!=="headerFooterPart"||typeof f.refId!="string")return null;const g=k(),w=T(),A=g?.pageLayout??w?.pageLayout;if(!A||typeof A!="object")return null;const E=A.getActiveRulerContext,B=w?.resolveHeaderFooterEditTarget;if(typeof E!="function"||typeof B!="function")return null;const q=Tt(()=>E.call(A),null);if(!q||typeof q.pageIndex!="number")return null;for(const oe of["header","footer"]){const ve=Tt(()=>B.call(w,{pageIndex:q.pageIndex,kind:oe}),null);if(!(ve?.status!=="ready"||ve.refId!==f.refId||typeof ve.sectionId!="string"||!["default","first","even"].includes(String(ve.slotVariant))))return{kind:"story",storyType:"headerFooterSlot",section:{kind:"section",sectionId:ve.sectionId},headerFooterKind:oe,variant:ve.slotVariant}}return null},P=()=>{const f=T(),g=f?.getPendingInlineFormat;if(typeof g!="function")return null;const w=Tt(()=>g.call(f),null);return w&&typeof w=="object"?w:null},j=f=>{const g=hb(f);if(!g)return null;const w=P();if(!w||!(g in w))return null;const A=w[g];return f.inline?.kind==="toggle"?A===!0:A!=null&&A!==""},O=f=>{const g=hb(f);if(!g)return;const w=P();if(!w||!(g in w))return;const A=w[g];if(typeof A=="string"&&A!=="")return A;if(typeof A=="number"&&Number.isFinite(A))return String(A)},V=(f,g)=>{const w=T(),A=w?.setPendingInlineFormat;typeof A=="function"&&Tt(()=>A.call(w,f,g),void 0)},Q=f=>{const g=T(),w=g?.clearPendingInlineFormat;typeof w=="function"&&Tt(()=>w.call(g,f),void 0)},F=new Set(["bold","italic","underline","strikethrough"]),N=f=>{const g=P();if(!g)return;const w=Array.isArray(f.activeMarks)?f.activeMarks:[];let A=null;for(const E of Object.keys(g)){const B=g[E];let q;if(F.has(E))q=w.includes(E)===(B===!0);else if(cb(E)){if(B==null)continue;A||(A=ni(f)),q=A[E]===B}else q=!1;q&&Q(E)}},x=()=>{const f=k()?.editCommands;return f&&typeof f=="object"?f:null},z=f=>{const g=x();if(!g||typeof g.getSnapshot!="function")return null;const w=Tt(()=>g.getSnapshot(),null)?.commands?.[f];return w&&typeof w=="object"?w:null},J=()=>z("lists.apply"),X=f=>{const g=f?.value?.seed;return g==="bullet"||g==="ordered"?g:null},ae=f=>{const g=FV[f];return g?z(g):null},pe=()=>{const f=T();if(!f||typeof f.getTableContext!="function")return null;const g=Tt(()=>f.getTableContext(),null);return g&&typeof g=="object"?g:null},Fe=()=>{const f=pe();if(!f||f.inTable!==!0)return null;const g=f.table,w=typeof g?.nodeId=="string"&&g.nodeId.length>0?g.nodeId:null;if(!w)return null;const A=f.row,E=f.column,B=f.cell,q=typeof A?.index=="number"&&Number.isInteger(A.index)?A.index:null,oe=typeof E?.index=="number"&&Number.isInteger(E.index)?E.index:null;if(q==null||oe==null)return null;const ve=typeof B?.nodeId=="string"&&B.nodeId.length>0?B.nodeId:null,Re=f.cellRange;return{tableNodeId:w,rowIndex:q,columnIndex:oe,cellNodeId:ve,mergeRange:$V(Re)}},fe=new Map;let ye=null,le=null,Se=0,re=0,xe=0;const $e=new Set,st=(f,g)=>f===g?!0:!f||!g?!1:f.id===g.id&&f.paintedEntityId===g.paintedEntityId&&Cr(f.story)===Cr(g.story),At=f=>Array.from($e).some(g=>st(g,f)),Ee=f=>{const g=T();if(typeof g?.getHandles!="function")return;const w=Tt(()=>g.getHandles(),null),A=w?.review;if(A){if(f){if(typeof A.setActiveReviewTarget!="function")return;const E=w?.layout;Tt(()=>A.setActiveReviewTarget({entityType:"trackedChange",entityId:f.id,...f.paintedEntityId?{paintedEntityId:f.paintedEntityId}:{},origin:"panel",layoutEpoch:typeof E?.generation=="number"?E.generation:0,story:f.story??{kind:"story",storyType:"body"}}),null);return}typeof A.getActiveReviewTarget!="function"||typeof A.clearActiveReviewTarget!="function"||Tt(()=>A.getActiveReviewTarget(),null)?.entityType==="trackedChange"&&Tt(()=>A.clearActiveReviewTarget(),void 0)}},Ge=(f,g)=>{le=f,Se+=1,xe+=1,g?.invalidateQueuedNavigation!==!1&&(re+=1)},qe=new Set;let Z=!1,S=null;const ee=new Map,D=new Set;let U=null,H=null,G=!1,te=null,Y=0,K=null,be=null,me=null;const Ce=()=>{if(G||Z)return;G=!0;const f=()=>{G=!1,Z||Dt()};typeof queueMicrotask=="function"?queueMicrotask(f):Promise.resolve().then(f)},Pe=250,it=5e3,He=f=>{Z||te&&Y<=f||(te&&clearTimeout(te),Y=f,te=setTimeout(()=>{te=null,Y=0,Z||Dt()},Math.max(0,f-Date.now())))},Ct=new WeakMap;let Yt=0;const St=f=>{if(!f)return"none";let g=Ct.get(f);return g==null&&(g=Yt+=1,Ct.set(f,g)),`e${g}`};let Ft=0,Nt={},sn=null,_n=null,Qt=0;const Ye=()=>{_n&&clearTimeout(_n),_n=null,Qt=0};let Et=f=>{},Ot=null,wn=new Set,Kt=0,Sn=null;const Pt=()=>`${St(k())}|m${Ft}`,De=()=>{Ot=null,wn=new Set},je=f=>{for(const g of["trackChanges","trackChanges:all"]){const w=ee.get(g);if(!w?.hasSettled||!Array.isArray(w.value))continue;const A=w.value.filter(E=>{const B=Gn(E);return!B||!f.has(B)});A.length!==w.value.length&&ee.set(g,{...w,value:A})}},Ke=f=>{const g=()=>{if(!Z)for(const B of[...qe])B(ut)},w=Ru(f)?f:null,A=k()?.documentMutationReadiness,E=()=>{const B=globalThis.requestAnimationFrame;return typeof B!="function"?Promise.resolve():new Promise(q=>{let oe=!1;const ve=()=>{oe||(oe=!0,clearTimeout(Re),q())},Re=setTimeout(ve,250);B(()=>B(()=>setTimeout(ve,0)))})};if(w?.success===!0&&typeof w.txId=="string"&&w.txId.length>0&&typeof A?.whenPainted=="function")try{Promise.resolve(A.whenPainted.call(A,w)).then(E,()=>{}).then(g,g);return}catch{}g()},pt=(f,g)=>{const w=ut.trackChanges,A=w.items.filter(q=>{const oe=Gn(q);return!oe||!f.has(oe)});if(A.length===w.items.length)return;le&&f.has(le.id)&&Ge(null);const E=new Set;for(const q of A){const oe=ym(q),ve=q,Re=oe.author??oe.authorEmail??ve.author??ve.authorEmail;typeof Re=="string"&&E.add(Re)}const B=w.items.length-A.length;ut={...ut,trackChanges:{...w,items:A,total:Math.max(A.length,w.total-B),activeId:w.activeId&&f.has(w.activeId)?null:w.activeId,authors:[...E]}},Ke(g)},kt=(f,g)=>{if(f.size===0)return;const w=Pt(),A=Ot===w?wn:new Set,E=new Set([...f].filter(B=>!A.has(B)));E.size!==0&&(Ot=w,wn=new Set([...A,...E]),je(wn),pt(E,g))},ft=f=>Ot===f&&wn.size>0?wn:null,an=(f,g=[])=>{const w=f.map(dl).filter(E=>E!=null&&Gn(E)!=null);if(w.length===0)return;const A=g.map(dl).map(E=>E==null?null:Gn(E)).filter(E=>E!=null);for(const E of["trackChanges","trackChanges:all"]){const B=ee.get(E),q=B?.hasSettled&&Array.isArray(B.value)?[...B.value]:[],oe=new Set;let ve=!1;for(const Re of w){const Ue=Gn(Re);if(!Ue)continue;const We=q.findIndex(Le=>Gn(Le)===Ue);if(We<0)q.push(Re),oe.add(Ue);else{const Le=q[We];q[We]=Ru(Le)?{...Le,...Re}:Re}ve=!0}if(E==="trackChanges"&&oe.size>0&&A.length>0){const Re=new Set(A.filter(Le=>oe.has(Le))),Ue=new Map(q.filter(Le=>Re.has(Gn(Le)??"")).map(Le=>[Gn(Le),Le])),We=q.filter(Le=>!Re.has(Gn(Le)??""));for(const[Le,Xe]of A.entries()){if(!Re.has(Xe))continue;const Ve=Ue.get(Xe);if(!Ve)continue;const Ze=A.slice(Le+1).map(rt=>We.findIndex(tt=>Gn(tt)===rt)).find(rt=>rt>=0);if(Ze!=null){We.splice(Ze,0,Ve);continue}const Je=A.slice(0,Le).reverse().map(rt=>We.findIndex(tt=>Gn(tt)===rt)).find(rt=>rt>=0);We.splice(Je==null?We.length:Je+1,0,Ve)}q.splice(0,q.length,...We)}ve&&ee.set(E,{token:B?.token??null,value:q,hasSettled:!0,inflightToken:null})}},qt=f=>{const g=Pt(),w=ft(g),A=f.map(dl).filter(E=>{if(E==null)return!1;const B=Gn(E);return B!=null&&!w?.has(B)});for(const E of["trackChanges","trackChanges:all"])ee.set(E,{token:g,value:[...A],hasSettled:!0,inflightToken:null})},cn=async(f,g)=>{try{const w=f.v2TrackedChanges?.listTrackedChanges;if(typeof w=="function"){const B=await Promise.resolve(w.call(f.v2TrackedChanges,{mode:g.trackedChangesListMode,refreshReason:g.refreshReason,blocking:g.blocking,...g.targetIds?.length?{targetIds:g.targetIds}:{}})),q=g.trackedChangesListMode==="all"&&g.refreshReason==="mutation-history-render-reconcile"?B?.ok===!0:B?.ok!==!1;return{ok:q,items:q&&Array.isArray(B?.items)?B.items:[],...typeof B?.complete=="boolean"?{complete:B.complete}:{},...typeof B?.sourceCoverageComplete=="boolean"?{sourceCoverageComplete:B.sourceCoverageComplete}:{}}}const A=f.docTrackChanges?.list;if(typeof A!="function")return{ok:!1,items:[]};const E=await Promise.resolve(A.call(f.docTrackChanges));return{ok:!0,items:Array.isArray(E?.items)?E.items:[]}}catch(w){return{ok:!1,items:[],failures:[w]}}},hn=z_({getContext:()=>{const f=k();if(!f)return null;const g=b(),w=y()?.trackChanges??null,A=g??w;if(!A)return null;const E=f.documentId??g?.documentId;return{editor:f,adapter:A,documentId:E==null?null:String(E),reconcileToken:Nt,v2TrackedChanges:g,docTrackChanges:w}},reconcile:async(f,g)=>{g.removedIds.size>0&&kt(new Set(g.removedIds));const w=[...new Set(g.upsertIds)];if(w.length===0)return{ok:!0,items:[],resolvedIds:[],unresolvedIds:[]};const A=ee.get("trackChanges"),E=A?.hasSettled&&Array.isArray(A.value)?A.value:null,B=new Set(E?E.map(Gn).filter(Je=>Je!=null):[]),q=E?.length===0&&vo()==="complete",oe=new Set(w.filter(Je=>!B.has(Je))),ve=f.v2TrackedChanges?.getTrackedChange,Re=f.docTrackChanges?.get;if(typeof ve!="function"&&typeof Re!="function")return{ok:!1,items:[],resolvedIds:[],unresolvedIds:w};const Ue=await Promise.all(w.map(async Je=>{try{if(typeof ve=="function"){const tt=await Promise.resolve(ve.call(f.v2TrackedChanges,Je));return{id:Je,ok:tt?.ok!==!1,items:tt?.ok!==!1&&Array.isArray(tt?.items)?tt.items:[],result:tt}}const rt=await Promise.resolve(Re.call(f.docTrackChanges,{id:Je}));return{id:Je,ok:!0,items:rt&&typeof rt=="object"?[rt]:[],result:rt}}catch(rt){return{id:Je,ok:!1,items:[],result:rt}}})),We=[],Le=[],Xe=[];for(const Je of Ue){const rt=Je.items.filter(tt=>{const Rt=dl(tt);return Rt!=null&&Gn(Rt)===Je.id});Je.ok&&rt.length>0?(We.push(...rt),Le.push(Je.id)):Xe.push(Je.id)}let Ve;const Ze=Le.filter(Je=>oe.has(Je));if(Ze.length>0&&!q){const Je=await cn(f,{trackedChangesListMode:"interaction-prime",refreshReason:"mutation-render-reconcile",blocking:!1,targetIds:Ze});Je.ok&&(Ve=Je.items)}return{ok:Xe.length===0,items:We,orderedItems:Ve,resolvedIds:Le,unresolvedIds:Xe,failures:Ue.filter(Je=>!Je.ok).map(Je=>Je.result)}},hydrate:cn,onReconciled:(f,g,w)=>{if(w?.reconcileMode==="authoritative"){if(f.reconcileToken!==Nt)return;w.ok===!0&&w.complete===!0&&w.sourceCoverageComplete===!0?(Ye(),qt(w.items??[]),sn=null):w.ok===!0?(Ye(),an(w.items??[])):Et(f.reconcileToken),Dt();return}an((w?.items??[]).filter(A=>{const E=dl(A),B=E==null?null:Gn(E);return B!=null&&g.has(B)}),w?.orderedItems??w?.items??[]),Dt()}});Et=f=>{if(Z||_n)return;const g=Math.min(Pe*2**Qt,it);Qt+=1,_n=setTimeout(()=>{_n=null,!(Z||sn===null||f!==Nt)&&hn.onRender(!0)},g)};const oo=()=>`${Pt()}|m${Wn()}|s${Kt}`,Jt=f=>JSON.stringify({t:f.target??null,s:f.selectionTarget??null}),Yn=["contentControls:inRange:","query:","effInline:"],Nr=120,io=180,vo=()=>{const f=T(),g=f?.getDocumentLoadingSnapshot;if(typeof g!="function")return"unknown";const w=Tt(()=>g.call(f),null)?.sourceStage;return w==="opening"||w==="bootstrap-ready"||w==="source-loading"?"loading":w==="source-complete"||w==="source-failed"||w==="source-cancelled"?"complete":"unknown"},$t=new Map,Bn=f=>{const g=Pt();$t.get(f)!==g&&($t.set(f,g),Ce())},xi=()=>{const f=ee.get("comments");return f?.hasSettled?Array.isArray(f.value)&&f.value.length>0:f?.inflightToken!=null},Is=(f,g)=>$t.get(f)===g,so=f=>{Bn("contentControls")},cr=()=>{const f=ee.get("trackChanges");f?.hasSettled||f?.inflightToken!=null||Bn("trackChanges")},Qo=6500,Zi=8e3,va=250;let Qi=0,hl=0,Ti=!1,ao=0,Ri=!1,_e=null;const ze=()=>{if(Z||_e)return;const f=ao||Date.now(),g=()=>{if(_e=null,Z)return;const w=Date.now()-Qi,A=_r()||w<Qo;if(A&&Date.now()-f<Zi){_e=setTimeout(g,va);return}Ti=!1,Ri=A;try{Dt()}finally{Ri=!1,ao=0}};_e=setTimeout(g,0)};let vt=null,ot=null;const xn=()=>{const f=T();if(!f||vt===f)return;ot&&(ot(),ot=null),vt=f;const g=f.subscribeDocumentLoading;if(typeof g!="function"){vt=null,jr(Qo);return}try{const w=B=>{const q=B?.sourceStage;(q==="source-complete"||q==="source-failed"||q==="source-cancelled")&&ze()},A=g.call(f,w);typeof A=="function"&&(ot=A);const E=f.getDocumentLoadingSnapshot;typeof E=="function"&&w(Tt(()=>E.call(f),null))}catch{vt=null,jr(Qo)}},Tn=()=>{const f=k()?.host,g=f?.getForegroundMutationState;if(typeof g!="function")return null;const w=Tt(()=>g.call(f),null);return{active:typeof w?.active=="number"?w.active:0,pending:typeof w?.pending=="number"?w.pending:0}},_r=()=>{const f=Tn();return!!(f&&(f.active>0||f.pending>0))},jr=(f=Nr)=>{Z||K||(K=setTimeout(()=>{if(K=null,Z)return;if(be&&_r()){jr(),Dt();return}const g=be;be=null,g===oo()&&Xr("selection",g,ml,vi),Dt()},f))},gi=(f,g)=>{if(!Tn())return!1;const w=`${f}\0${g}`;return D.has(w)?!1:(D.add(w),jr(io),!0)},Ji=f=>{if(U==null||f===U)return H?.timer&&clearTimeout(H.timer),H=null,U=f,!1;if(H?.key===f)return H.ready?(H=null,U=f,!1):!0;H?.timer&&clearTimeout(H.timer);const g={key:f,ready:!1,timer:null};return g.timer=setTimeout(()=>{Z||H!==g||(g.timer=null,g.ready=!0,Dt())},io),H=g,!0},Es=f=>V_(f),No=()=>{Mo(),Dt()};let Yr=null,Jo=!1,$i=0;const Mi=()=>{Yr=null,Jo=!1,$i+=1},lo=()=>{const f=k(),g=f?.documentMutationReadiness;if(!f||typeof g?.whenPainted!="function"||(Yr={editor:f,readiness:g,afterEpoch:typeof g.getRenderEpoch=="function"?Tt(()=>g.getRenderEpoch.call(g),null):null},Jo))return;Jo=!0;const w=$i;(async()=>{for(;!Z&&w===$i;){const E=Yr;if(Yr=null,!E){Jo=!1;return}let B=!1;try{await E.readiness.whenPainted.call(E.readiness,typeof E.afterEpoch=="number"?{afterEpoch:E.afterEpoch}:void 0),B=!0}catch{}if(Z||w!==$i)return;if(k()!==E.editor){Mi();return}B&&No()}})()},$o=()=>{me&&clearTimeout(me),me=setTimeout(()=>{me=null,Z||No()},500)},Xr=(f,g,w,A)=>{let E;try{E=w()}catch{E=void 0}if(!Tr(E)){const oe={token:g,value:A(E),hasSettled:!0,inflightToken:null,failedToken:null,failureCount:0,retryAtMs:0};return ee.set(f,oe),oe}const B=ee.get(f),q=B?.failedToken===g;return ee.set(f,{token:B?.token??null,value:B?.value??null,hasSettled:B?.hasSettled??!1,inflightToken:g,failedToken:q?g:null,failureCount:q?B.failureCount??0:0,retryAtMs:0}),Promise.resolve(E).then(oe=>{const ve=ee.get(f);!ve||ve.inflightToken!==g||(ee.set(f,{token:g,value:A(oe),hasSettled:!0,inflightToken:null,failedToken:null,failureCount:0,retryAtMs:0}),Ce())},()=>{const oe=ee.get(f);if(!oe||oe.inflightToken!==g)return;const ve=oe.failedToken===g?(oe.failureCount??0)+1:1,Re=Math.min(it,Pe*2**Math.min(ve-1,8)),Ue=Date.now()+Re;ee.set(f,{...oe,inflightToken:null,failedToken:g,failureCount:ve,retryAtMs:Ue}),He(Ue)}),null},ur=(f,g,w,A)=>{const E=ee.get(f);if(E&&E.token===g&&E.hasSettled)return{value:E.value,status:"ready"};if(CV(f)&&!Is(f,g)){if(vo()==="loading")return Ti=!0,xn(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(Ti&&!Ri)return ze(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(!Ri){const q=Date.now();if(q-hl<Qo&&(!ao||q-ao<Zi))return ao||(ao=q),Ti=!0,ze(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};ao=0}}if(_r())return jr(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(E?.failedToken===g&&E.inflightToken==null&&(E.retryAtMs??0)>Date.now())return He(E.retryAtMs),E.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(!E&&f.startsWith("effInline:")&&Ji(f))return{value:null,status:"pending"};if(!E&&gi(f,g))return{value:null,status:"pending"};if(!E||E.inflightToken!==g){const q=Xr(f,g,w,A);if(q)return{value:q.value,status:"ready"}}const B=ee.get(f);return B?.hasSettled?{value:B.value,status:"stale"}:{value:null,status:"pending"}},Li=f=>{for(const g of ee.keys())f(g)&&ee.delete(g)},pc=f=>{const g=Jt(f),w=_A(f);return new Set([`contentControls:inRange:${g}`,`query:${g}`,...w?[`effInline:${w}`]:[]])},Lu=f=>{const g=pc(f);Li(w=>Yn.some(A=>w.startsWith(A))&&!g.has(w));for(const w of D){const A=w.split("\0",1)[0];Yn.some(E=>A.startsWith(E))&&!g.has(A)&&D.delete(w)}},xs=()=>{const f=k();f!==Sn&&(Mi(),hn.reset(),Nt={},Sn=f,ee.clear(),sn=null,Ye(),te&&clearTimeout(te),te=null,Y=0,H?.timer&&clearTimeout(H.timer),H=null,U=null,C=null,o=null,be=null,D.clear(),$t.clear(),Ti=!1,ao=0,ot&&ot(),ot=null,vt=null,De())},Mo=()=>{const f=sn!==null;Ft+=1,f&&(sn=Pt()),De()},mc=f=>{if(typeof f!="string"||f.length===0)return lr("insertText requires a non-empty string.","INVALID_INPUT");if(Wn()==="viewing")return lr("The document is read-only.","DOCUMENT_READONLY");const g=y(),w=g?.insert;if(!g||typeof w!="function")return lr("insert is unavailable.");const A=g.selection?.current;if(typeof A!="function")return lr("selection.current is unavailable.");const E=q=>{const oe=q&&typeof q=="object"?q:null,ve=oe?.selectionTarget??oe?.target??null;return!ve||typeof ve!="object"?lr("insertText requires a live selection target.","PRECONDITION_FAILED"):Tt(()=>Ma(w.call(g,{type:"text",value:f,target:ve}),lr("insert failed.")),lr("insert failed."))};let B;try{B=A.call(g.selection)}catch{return lr("insertText could not resolve the live selection.","PRECONDITION_FAILED")}return Tr(B)?Promise.resolve(B).then(E,()=>lr("insertText could not resolve the live selection.","PRECONDITION_FAILED")):E(B)},ya=(f,g)=>({payload:f,state:ut,editor:k(),superdoc:t,context:g,ui:S,execute:(w,A)=>qn(w,A),executeAsync:(w,A)=>Rm(w,A),doc:y(),selection:ut.selection,documentMode:Wn(),insertText:mc}),ei=f=>f==="editing"||f==="suggesting"||f==="viewing"?f:null,Wn=()=>{const f=k(),g=t&&typeof t=="object"?t:null,w=ei(g?.config?.documentMode),A=ei(Tt(typeof g?.getActiveRuntime=="function"?()=>{const B=g.getActiveRuntime();return typeof B?.getSnapshot=="function"?B.getSnapshot():null}:void 0,null)?.documentMode),E=ei(f?.options?.documentMode);return w&&A&&w!==A?w:A??w??E},jf=()=>{const f=t&&typeof t=="object"?t:null,g=f?.interactionConfig?.comments;if(g&&typeof g.readOnly=="boolean")return g.readOnly===!0;const w=f?.config?.modules?.comments;return!!w&&typeof w=="object"&&w.readOnly===!0},Ts=()=>{const f=t&&typeof t=="object"?t:null,g=f?.interactionConfig?.comments;if(g&&typeof g.allowResolve=="boolean")return g.allowResolve===!1;const w=f?.config?.modules?.comments;return!!w&&typeof w=="object"&&w.allowResolve===!1},ti=()=>Wn()==="viewing"||jf(),vi=f=>f&&typeof f=="object"?f:null,pl=(f,g)=>{if(!f)return{...yV,status:g};const w=f.target??null,A=typeof f.text=="string"?f.text:"";return{status:g,empty:f.empty===!0,target:w,selectionTarget:f.selectionTarget??null,activeMarks:Array.isArray(f.activeMarks)?f.activeMarks:[],activeCommentIds:Array.isArray(f.activeCommentIds)?f.activeCommentIds:[],activeChangeIds:Array.isArray(f.activeChangeIds)?f.activeChangeIds:[],quotedText:A}},es=()=>{const f=y()?.selection;return ur("selection",oo(),()=>f?.current?f.current({includeText:!0}):void 0,vi)},Pu=()=>{const{value:f,status:g}=es();return pl(f,g)},ml=()=>{const f=y()?.selection;return f?.current?f.current({includeText:!0}):void 0},gl=f=>{if(f.empty!==!0)return!1;const g=f.selectionTarget,w=g?.start,A=g?.end;return w?.kind==="text"&&A?.kind==="text"&&typeof w.blockId=="string"&&w.blockId===A.blockId&&typeof w.offset=="number"&&w.offset===A.offset},Uf=f=>{const g=T(),w=g?.readLiveSelectionSyncSnapshot;if(typeof w!="function")return;const A=vi(Tt(()=>w.call(g),null));if(!A||!gl(A))return;const E=oo(),B=Tn(),q=!!(B&&(B.active>0||B.pending>0));if(q)be=E,jr();else if(be=null,Xr("selection",E,ml,vi))return;const oe=ee.get("selection"),ve=Array.isArray(A.activeMarks)&&A.activeMarks.length>0?A.activeMarks:Array.isArray(ut.selection.activeMarks)?ut.selection.activeMarks:[],Re=Array.isArray(A.activeCommentIds)?A.activeCommentIds:[],Ue=IV(f),We=ul(ut.selection),Le=Vf(A.selectionTarget)??Vf(A.target),Xe=We?.range,Ve=Le?.range,Ze=!!(B&&B.active>0&&We&&Le&&We.blockId===Le.blockId&&Cr(We.story)===Cr(Le.story)&&typeof Xe?.start=="number"&&typeof Ve?.start=="number"&&Math.abs(Ve.start-Xe.start)<=2),Je=Ue!=null||Ze?ut.selection.activeChangeIds.filter(tt=>Ue==null||pa(ut.trackChanges.items).aliasesFor(tt).includes(Ue)):[],rt=Array.isArray(A.activeChangeIds)&&A.activeChangeIds.length>0?A.activeChangeIds:Je;ee.set("selection",{token:E,value:{...A,activeMarks:ve,activeCommentIds:Re,activeChangeIds:rt},hasSettled:!0,inflightToken:q?null:oe?.inflightToken??null})},ba=async(f=0)=>{const g=y()?.selection,w=g?.current,A=oo();if(typeof w!="function")return ee.set("selection",{token:A,value:null,hasSettled:!0,inflightToken:null}),Dt(),ut.selection;let E;try{E=w.call(g,{includeText:!0}),Tr(E)&&(E=await Promise.resolve(E))}catch{E=null}return Z?pl(null,"pending"):oo()!==A?f<1?ba(f+1):ut.selection:(ee.set("selection",{token:A,value:vi(E),hasSettled:!0,inflightToken:null}),Dt(),ut.selection)},vl=f=>{const g=y()?.comments,{value:w,status:A}=ur("comments",Pt(),()=>g?.list?g.list():void 0,oe=>oe&&Array.isArray(oe.items)?oe.items:[]),E=w??[],B=f.activeCommentIds;ye&&!E.some(oe=>Gn(oe)===ye)&&(ye=null);const q=ye??B[0]??null;return{status:Iu(A,f.status),listStatus:A,items:E,total:E.length,activeIds:B,activeId:q}},ts=()=>{const f=y()?.trackChanges,g=Pt(),w=ee.get("trackChanges:all"),{value:A,status:E}=sn===g?{value:w?.hasSettled?w.value:null,status:w?.hasSettled?"stale":"pending"}:ur("trackChanges:all",g,()=>f?.list?f.list({in:"all"}):void 0,B=>(B&&Array.isArray(B.items)?B.items:[]).map(dl).filter(q=>q!=null));return E==="ready"?A:null},yi=f=>{const g=y()?.trackChanges,w=b(),A=typeof w?.listTrackedChanges=="function"?w.listTrackedChanges:null,E=Pt(),B=ft(E),q=ee.get("trackChanges"),{value:oe,status:ve}=sn===E?{value:q?.hasSettled?q.value:null,status:q?.hasSettled?"stale":"pending"}:ur("trackChanges",E,()=>A?A.call(w):g?.list?g.list({in:"all"}):void 0,en=>en&&Array.isArray(en.items)?en.items:[]),Re=(oe??[]).map(dl).filter(en=>en!=null).filter(en=>{const Mn=Gn(en);return!Mn||!B?.has(Mn)}),Ue=new Set;for(const en of Re){const Mn=ym(en),Rr=en,Ar=Mn.author??Mn.authorEmail??Rr.author??Rr.authorEmail;typeof Ar=="string"&&Ue.add(Ar)}const We=g?.list?ts():null,Le=le;Le&&(Le.story?We&&!We.some(en=>Ki(en,Le.id,Le.story))&&Ge(null):Re.some(en=>Gn(en)===Le.id)||Ge(null));const Xe=We??Re,Ve=Eu(Xe,qi(f)),Ze=B?f.activeChangeIds.filter(en=>!B.has(en)):f.activeChangeIds,Je=Ze.map(en=>Ve.toPublicId(en)??en),rt=le?.story?Eu(Xe,le.story):pa(Xe),tt=le?rt.toPublicId(le.id)??le.id:null,Rt=RV({selectionIds:Ze,publicIds:Je,selection:f,bodyItems:Re,allStoryItems:We}),Gt=tt??Rt;return{status:Iu(ve,f.status),items:Re,total:Re.length,activeId:Gt,authors:[...Ue]}},Gf=f=>{const g=y()?.contentControls,{value:w,status:A}=ur("contentControls",Pt(),()=>g?.list?g.list():void 0,oe=>oe&&Array.isArray(oe.items)?oe.items:[]),E=w??[],{ids:B,status:q}=Du(g,f);return{status:Iu(A,q,f.status),items:E,total:E.length,activeId:B[0]??null,activeIds:B}},wa=(f,g)=>{if(!f||typeof f.listInRange!="function")return{lockModesById:new Map,status:"ready"};const w=LV(g);if(!w)return{lockModesById:new Map,status:"ready"};const{value:A,status:E}=ur(`contentControls:inRange:${Jt(g)}`,Pt(),()=>f.listInRange(w),oe=>oe&&Array.isArray(oe.items)?oe.items:[]),B=A??[],q=new Map;for(const oe of B)typeof oe?.id=="string"&&q.set(oe.id,typeof oe.lockMode=="string"?oe.lockMode:"unlocked");return{lockModesById:q,status:E}},Du=(f,g)=>{const{lockModesById:w,status:A}=wa(f,g);return{ids:[...w.keys()],status:A}},Wf=()=>{const f=t?.fonts;return{options:sH(oH(Tt(f?.getDocumentFontOptions?()=>f.getDocumentFontOptions():void 0,[])),iH(Tt(f?.getFontFamilyOptions?()=>f.getFontFamilyOptions():void 0,[]))),sizeOptions:aH}},yl=()=>{const f=Tt(t?.getZoomState?()=>t.getZoomState():void 0,null),g=typeof f?.value=="number"?f.value:100,w=f?.mode;return{mode:w==="manual"||w==="fit-width"?w:w==="fixed"?"manual":null,value:g,min:typeof f?.min=="number"?f.min:10,max:typeof f?.max=="number"?f.max:100}},gc=()=>Tt(t?.getMeasurementUnit?()=>t.getMeasurementUnit():void 0,"in")==="cm"?"cm":"in",Ou=()=>{const f=k();return{ready:f!=null,mode:Wn(),dirty:f?!!f.isDirty:!1}},Ca=f=>{const g=f.quotedText;if(typeof g!="string"||g.length===0)return null;const w=Tu(f);if(w.length===0||!fc(w.map(B=>B.blockId)))return null;const A=f.target,E=w.length===1?mo(w[0].blockId,A?.story):void 0;return{select:{type:"text",pattern:g,mode:"contains",caseSensitive:!0},...E?{within:E}:{},require:"any"}},yo=f=>{const g=y()?.query;if(typeof g?.match!="function")return null;const w=Ca(f);if(!w)return null;const{value:A}=ur(`query:${Jt(f)}`,Pt(),()=>g.match(w),E=>E&&typeof E=="object"?E:null);return SA(A,f)},bl=f=>{const g=T(),w=new Set(Fr(f));if(w.size===0)return{};const A=g?.readMountedProjectionBlocksByIds,E=g?.readMountedProjectionBlocks;if(typeof A!="function"&&typeof E!="function")return{};const B=Tt(()=>{if(typeof A!="function")return E.call(g);const Ze=Yi(f);return Ze?A.call(g,[...w],Ze):A.call(g,[...w])},null);if(!Array.isArray(B))return{};const q=fb(B),oe=Ze=>{const Je={},rt=ub(Ze.fontFamily);rt&&(Je.fontFamily=rt);const tt=UV(Ze.fontSize);return tt&&(Je.fontSize=tt),typeof Ze.color=="string"&&Ze.color.trim()!==""&&(Je.color=Ze.color.trim().toUpperCase()),typeof Ze.highlight=="string"&&Ze.highlight.trim()!==""&&(Je.highlight=Ze.highlight.trim().toUpperCase()),Je},ve=ul(f),Re=ve&&typeof ve.range?.start=="number"?ve.range.start:null;if(ve&&Re!==null&&w.has(ve.blockId)){const Ze=q.find(rt=>hc(rt,ve.blockId)),Je=Ze&&Array.isArray(Ze.runs)?Ze.runs:null;if(Je&&Je.length>0&&Je.every(rt=>rt?.kind==="text"||rt?.kind==="tab")){let rt=0,tt=null;for(const Rt of Je){const Gt=typeof Rt.text=="string"?Rt.text.length:0;if(Re>=rt&&Re<rt+Gt){tt=Rt;break}rt+=Gt}if(!tt){for(let Rt=Je.length-1;Rt>=0&&!tt;Rt-=1)Je[Rt]?.kind==="text"&&(tt=Je[Rt]);tt??=Je[Je.length-1]??null}return tt?oe(tt):{}}}const Ue=Tu(f);if(Ue.length>0){const Ze=new Set,Je=new Set;let rt=!1,tt=!0;for(const Rt of Ue){const Gt=q.find(Rr=>hc(Rr,Rt.blockId));if(!Gt)return{};const en=Array.isArray(Gt.runs)?Gt.runs:[];if(en.length===0)continue;if(!en.every(Rr=>Rr?.kind==="text"||Rr?.kind==="tab")){tt=!1;break}let Mn=0;for(const Rr of en){const Ar=typeof Rr.text=="string"?Rr.text.length:0,zr=Mn,Mr=Mn+Ar;if(zr<Rt.end&&Mr>Rt.start){rt=!0;const Uo=oe(Rr);Uo.fontFamily&&Ze.add(Uo.fontFamily),Uo.fontSize&&Je.add(Uo.fontSize)}Mn=Mr}}if(tt&&rt){const Rt={};return Ze.size===1&&(Rt.fontFamily=[...Ze][0]),Je.size===1&&(Rt.fontSize=[...Je][0]),Rt}}const We=new Set,Le=new Set;let Xe=!1;for(const Ze of q){if(![...w].some(rt=>hc(Ze,rt)))continue;const Je=Array.isArray(Ze.runs)?Ze.runs:[];for(const rt of Je){if(rt?.kind!=="text")continue;Xe=!0;const tt=oe(rt);tt.fontFamily&&We.add(tt.fontFamily),tt.fontSize&&Le.add(tt.fontSize)}}if(!Xe)return{};const Ve={};return We.size===1&&(Ve.fontFamily=[...We][0]),Le.size===1&&(Ve.fontSize=[...Le][0]),Ve},Rs=f=>{const g=T(),w=new Set(Fr(f));if(w.size===0)return{};const A=g?.readMountedProjectionBlocksByIds,E=g?.readMountedProjectionBlocks;if(typeof A!="function"&&typeof E!="function")return{};const B=Tt(()=>{if(typeof A!="function")return E.call(g);const Ve=Yi(f);return Ve?A.call(g,[...w],Ve):A.call(g,[...w])},null);if(!Array.isArray(B))return{};const q=fb(B),oe=Ve=>({bold:Ve.bold===!0,italic:Ve.italic===!0,underline:Ve.underline!=null,strikethrough:Ve.strike===!0}),ve=Ve=>{const Ze={};for(const Je of Hf){const rt=Ve[Je];rt.size===1&&(Ze[Je]=[...rt][0])}return Ze},Re=ul(f),Ue=Re&&typeof Re.range?.start=="number"?Re.range.start:null;if(Re&&Ue!==null&&w.has(Re.blockId)){const Ve=q.find(Je=>hc(Je,Re.blockId)),Ze=Ve&&Array.isArray(Ve.runs)?Ve.runs:null;if(Ze&&Ze.length>0&&Ze.every(Je=>Je?.kind==="text"||Je?.kind==="tab")){let Je=0,rt=null;for(const tt of Ze){const Rt=typeof tt.text=="string"?tt.text.length:0;if(Ue>=Je&&Ue<Je+Rt){rt=tt;break}Je+=Rt}if(!rt){for(let tt=Ze.length-1;tt>=0&&!rt;tt-=1)Ze[tt]?.kind==="text"&&(rt=Ze[tt]);rt??=Ze[Ze.length-1]??null}return rt?oe(rt):{}}}const We=Tu(f);if(We.length>0){const Ve={bold:new Set,italic:new Set,underline:new Set,strikethrough:new Set};let Ze=!1,Je=!0;for(const rt of We){const tt=q.find(en=>hc(en,rt.blockId));if(!tt)return{};const Rt=Array.isArray(tt.runs)?tt.runs:[];if(Rt.length===0)continue;if(!Rt.every(en=>en?.kind==="text"||en?.kind==="tab")){Je=!1;break}let Gt=0;for(const en of Rt){const Mn=typeof en.text=="string"?en.text.length:0,Rr=Gt,Ar=Gt+Mn;if(Rr<rt.end&&Ar>rt.start){Ze=!0;const zr=oe(en);for(const Mr of Hf)Ve[Mr].add(zr[Mr])}Gt=Ar}}if(Je&&Ze)return ve(Ve)}const Le={bold:new Set,italic:new Set,underline:new Set,strikethrough:new Set};let Xe=!1;for(const Ve of q){if(![...w].some(Je=>hc(Ve,Je)))continue;const Ze=Array.isArray(Ve.runs)?Ve.runs:[];for(const Je of Ze){if(Je?.kind!=="text")continue;Xe=!0;const rt=oe(Je);for(const tt of Hf)Le[tt].add(rt[tt])}}return Xe?ve(Le):{}},vc=(f,g)=>{if(g.fontFamily!==void 0&&g.fontSize!==void 0&&g.color!==void 0&&g.highlight!==void 0)return{values:g,effectiveUniformityStatus:"ready"};const w=bl(f),A={...w.fontFamily!==void 0?{fontFamily:w.fontFamily}:{},...w.fontSize!==void 0?{fontSize:w.fontSize}:{},...w.color!==void 0?{color:w.color}:{},...w.highlight!==void 0?{highlight:w.highlight}:{},...g};if(!f.empty&&(A.fontFamily===void 0||A.fontSize===void 0)){const E=ns(f);return E.values&&(A.fontFamily===void 0&&E.values.fontFamily!==void 0&&(A.fontFamily=E.values.fontFamily),A.fontSize===void 0&&E.values.fontSize!==void 0&&(A.fontSize=E.values.fontSize)),{values:A,effectiveUniformityStatus:E.status}}return{values:A,effectiveUniformityStatus:"ready"}},Fu=["fontFamily","fontSize","bold","italic","underline","strikethrough"],bo=f=>{const g=f.selectionTarget;if(!g)return{value:null,status:"ready"};const w=vr(y(),"format.readEffectiveInlineUniformity");return w?ur(`effInline:${_A(f)??Jt(f)}`,Pt(),()=>w({target:g,offsetSpace:"selection",keys:Fu}),A=>A&&typeof A=="object"?A:null):{value:null,status:"ready"}},ns=f=>{const{value:g,status:w}=bo(f);if(!g||g.success!==!0)return{values:null,status:w};const A=g.values,E=B=>{const q=A?.[B];if(!(!q||q.state!=="uniform"||typeof q.value!="string"))return B==="fontFamily"?ub(q.value):q.value};return{values:{fontFamily:E("fontFamily"),fontSize:E("fontSize")},status:w}},Nu=f=>{const{value:g,status:w}=bo(f);if(!g||g.success!==!0)return{values:null,status:w};const A=g.values,E={};for(const B of Hf){const q=A?.[B];q?.state==="uniform"&&(q.value==="true"||q.value==="false")&&(E[B]=q.value==="true")}return{values:E,status:w}},yc=(f,g)=>{const w=f.activeMark;if(!w||!Hf.includes(w))return null;const A=w,E=Rs(g)[A];if(E!==void 0)return E;const{values:B}=Nu(g),q=B?.[A];return q!==void 0?q:null},Bu=async f=>{const g=f.selectionTarget;if(!g)return null;const w=vr(y(),"format.readEffectiveInlineUniformity");if(!w)return null;try{const A=await Promise.resolve(w({target:g,offsetSpace:"selection"}));return A&&typeof A=="object"&&A.success===!0?A:null}catch{return null}},bc=(f,g,w)=>{const A=w.values;for(const E of["fontFamily","fontSize"]){if(g[E]!==void 0)continue;const B=A?.[E];B?.state==="uniform"&&typeof B.value=="string"?f[E]=E==="fontFamily"?ub(B.value):B.value:delete f[E]}},Ms=f=>vc(f,kA(yo(f),f)),ni=f=>Ms(f).values,zu=async f=>{const g=y()?.query,w=Ca(f);if(typeof g?.match!="function"||!w)return ni(f);try{const A=await Promise.resolve(g.match(w)),E=kA(SA(A&&typeof A=="object"?A:null,f),f),B=vc(f,E);if(B.effectiveUniformityStatus!=="ready"&&(E.fontFamily===void 0||E.fontSize===void 0)){const q=await Bu(f);q&&bc(B.values,E,q)}return B.values}catch{return ni(f)}},wl=async f=>{const g=y();if(g)return typeof g.getNode=="function"?await Promise.resolve(g.getNode(f)):await Promise.resolve(g.getNodeById?.({nodeId:f.nodeId,nodeType:f.nodeType}))},Vu=f=>{const g=y()?.query;if(typeof g?.match!="function")return"ready";const w=Ca(f);if(!w)return"ready";const{status:A}=ur(`query:${Jt(f)}`,Pt(),()=>g.match(w),E=>E&&typeof E=="object"?E:null);return A},wc=f=>{const g=Ms(f),w=g.values;if(f.empty)return g;const A=ga(f);return A?f.status==="ready"&&Vu(f)==="ready"&&g.effectiveUniformityStatus==="ready"?(C={key:A,values:w},g):C&&C.key===A?{...g,values:{...C.values,...w}}:g:g},_a=f=>{const g=y(),w=wc(f),A=w.values;f.status==="ready"&&!f.empty&&Vu(f)==="ready"&&w.effectiveUniformityStatus==="ready"&&(v=A,_=`${uc(f)}:${Pt()}`);const E=g?.contentControls,{lockModesById:B}=wa(E,f),q={};for(const oe of Te())q[oe]=_l(oe,g,f,A,B);return q},rs=f=>f?lt.operationUnavailable:k()?lt.documentApiUnavailable:lt.notReady,Cl=f=>f==="contentLocked"||f==="sdtContentLocked",Pi=f=>{for(const g of f.values())if(Cl(g))return lt.contentControlLocked},Kf=(f,g,w,A,E)=>{if(!g)return f.scope==="all"?lt.bulkDecisionsDisabled:rs(E);if(w)return lt.documentReadonly;if(f.scope!=="all"&&A.activeChangeIds.length===0)return lt.selectionRequired},qf=f=>{const g=T(),w=Tt(typeof g?.getCapabilities=="function"?()=>g.getCapabilities():void 0,null)?.editableSubset?.commands;if(Array.isArray(w))return w.find(A=>A?.command===f||A?.id===f)??null;if(w&&typeof w=="object"){const A=w[f];return A&&typeof A=="object"?A:null}return null},Cc=(f,g)=>{if(f.scope!=="all"||typeof g?.[`${f.kind}All`]=="function")return;const w=qf(`trackedChanges.${f.kind}All`);if(!(w&&(w.status==="supported"||w.enabled===!0)))return lt.bulkDecisionsDisabled},_l=(f,g,w,A,E=new Map)=>{if(fe.has(f))return on({supported:!0,enabled:!0,...Tt(fe.get(f).getState?()=>fe.get(f).getState(ya(void 0)):void 0,{})},"custom");const B=Wn()==="viewing",q=hA(f);if(q&&typeof x()?.lists?.apply=="function"){const Xe=J(),Ve=typeof Xe?.shippedStatus=="string"?Xe.shippedStatus:null,Ze=Ve!=="not-shipped"&&Ve!=="disabled";return on({enabled:Ze&&(typeof Xe?.enabled=="boolean"?Xe.enabled:!0),active:(Ze?X(Xe):null)===q,supported:Ze,value:Xe?.value},"builtin")}const oe=wm(f);if(oe){const Xe=g?.trackChanges,Ve=typeof Xe?.decide=="function"||typeof Xe?.[oe.kind]=="function",Ze=typeof Xe?.decide=="function"||typeof Xe?.[`${oe.kind}All`]=="function",Je=oe.scope==="all"?Ze:Ve,rt=Cc(oe,Xe)??Kf(oe,Je,ti(),w,g);return on({enabled:rt==null,active:!1,supported:Je,reason:rt},"builtin")}if(f==="copy-format")return Wn()==="viewing"?on({supported:!0,enabled:!1,active:!1},"builtin"):k()?on({supported:!0,enabled:!0,active:h.mode!=="idle"},"builtin"):on({supported:!0,enabled:!1,active:!1,reason:lt.notReady},"builtin");const ve=Su(f);if(!ve)return on({enabled:!1,active:!1,supported:!1,reason:lt.commandUnsupported},"unsupported");if(ve.disposition!=="routed")return on({enabled:!1,active:!1,supported:!1,reason:ve.reason??lt.commandUnsupported},ve.disposition==="unsupported"?"unsupported":"builtin");if(ve.instanceRoute)return ie(ve);if(ve.table)return de(ve,g,B);if(ve.inline?.kind==="clear"){if(ve.mutates&&B)return on({enabled:!1,active:!1,supported:!0,reason:lt.documentReadonly},"builtin");const Xe=Pi(E);if(Xe)return on({enabled:!1,active:!1,supported:!0,reason:Xe},"builtin");const Ve=Fr(w).length>0||Mu(w)!=null;return on({enabled:Ve,active:!1,supported:!0,reason:Ve?void 0:lt.selectionRequired},"builtin")}const Re=ve.docRoute;if(!Re)return on({enabled:!1,active:!1,supported:!1,reason:lt.commandUnsupported},"unsupported");if(vr(g,Re)==null)return on({enabled:!1,active:!1,supported:!1,reason:rs(g)},"builtin");const Ue=ae(f);if(Ue){const Xe=Ue.shippedStatus,Ve=Xe!=="not-shipped"&&Xe!=="disabled",Ze=typeof Ue.enabled=="boolean"?Ue.enabled:!0,Je=f==="undo"||f==="redo",rt=Je&&Ue.historyResolved===!1,tt=Je&&Ve&&Ze===!1&&Ue.reason===null&&!rt,Rt=Ue.reason===void 0?void 0:tt?lt.historyEmpty:rt?lt.notReady:ib(Ue.reason,lt.commandUnsupported);return ve.mutates&&B?on({enabled:!1,active:!1,supported:Ve,reason:lt.documentReadonly},"builtin"):on({enabled:Ve&&Ze,active:!1,supported:Ve,reason:Rt},"builtin")}const We=Sa(ve,g,w),Le=ju(ve,g,w,A);if(ve.list?.mode==="indent"||ve.list?.mode==="outdent")return I(ve,g,B,w,We,Le);if(ve.list?.mode==="toggle-seed")return M(ve,g,B,w,We,Le);if(ve.mutates&&B)return on({enabled:!1,active:We,supported:!0,value:Le,reason:lt.documentReadonly},"builtin");if(ve.inline&&!Mu(w)){const Xe=Pi(E);return on(Xe?{enabled:!1,active:We,supported:!0,value:Le,reason:Xe}:Fr(w).length>0&&typeof T()?.setPendingInlineFormat=="function"?{enabled:!0,active:We,supported:!0,value:Le}:{enabled:!1,active:We,supported:!0,value:Le,reason:lt.rangeSelectionRequired},"builtin")}if((ve.blockParagraph||ve.list)&&Fr(w).length===0)return on({enabled:!1,active:We,supported:!0,value:Le,reason:lt.selectionRequired},"builtin");if(ve.link&&!We&&lb(w).length===0&&!ul(w))return on({enabled:!1,active:We,supported:!0,reason:lt.rangeSelectionRequired},"builtin");if(ve.inline){const Xe=Pi(E);if(Xe)return on({enabled:!1,active:We,supported:!0,value:Le,reason:Xe},"builtin")}return on({enabled:!0,active:We,supported:!0,value:Le},"builtin")};function Hu(f,g){const w=f.address?.anchor,A=w?.start,E=w?.end,B=typeof A?.blockId=="string"?A.blockId:null,q=typeof E?.blockId=="string"?E.blockId:null;if(!B||!q)return!1;const oe=typeof A?.offset=="number"?A.offset:null,ve=typeof E?.offset=="number"?E.offset:null;if(oe==null||ve==null)return!1;const Re=g.target,Ue=Re&&Array.isArray(Re.segments)?Re.segments:[];for(const We of Ue){const Le=typeof We?.blockId=="string"?We.blockId:null;if(!Le)continue;const Xe=We.range,Ve=typeof Xe?.start=="number"?Xe.start:null,Ze=typeof Xe?.end=="number"?Xe.end:null;if(!(Ve==null||Ze==null)){if(B!==q){if(Le===B&&Ze>oe||Le===q&&Ve<ve)return!0;continue}if(Le===B){if(Ve===Ze){if(Ve>=oe&&Ve<=ve)return!0;continue}if(Math.max(Ve,oe)<Math.min(Ze,ve))return!0}}}return!1}const Sl=(f,g)=>{const w=f?.hyperlinks;if(!w||typeof w.list!="function")return null;const A=Fr(g);if(!fc(A))return null;for(const E of A){const B={kind:"block",nodeType:"paragraph",nodeId:E},{value:q}=ur(`hyperlinks:${E}`,Pt(),()=>w.list({within:B}),ve=>ve&&typeof ve=="object"?ve:null),oe=(q&&Array.isArray(q.items)?q.items:[]).find(ve=>Hu(ve,g));if(oe)return oe}return null},Sa=(f,g,w)=>{if(f.link)return Sl(g,w)!=null;if(f.list?.mode==="toggle-seed"&&f.list.seed)return Uu(g,w)===f.list.seed;const A=j(f);if(A!==null)return A;const E=r.get(f.id),B=ga(w);if(B&&E?.selectionSignature===B)return E.active;const q=yc(f,w);return q!==null?q:lH(f,w)},ju=(f,g,w,A)=>{if(f.inline&&cb(f.inline.key)){const E=O(f);if(E!==void 0)return E;const B=A[f.inline.key];if(B!==void 0)return B;const q=ga(w),oe=q?n.get(f.inline.key):void 0;if(q&&oe?.selectionSignature===q)return oe.value}if(f.id==="linked-style"){const{style:E}=nt(w,ct().cache);return!E.styleId||E.mixed?void 0:{styleId:E.styleId,styleName:E.styleName}}if(f.id==="text-align")return Lo(g,w);if(f.id==="link")return $(g,w)??void 0},kl=(f,g,w)=>{const A=f?.lists;if(!A)return{value:null,status:"ready"};const E=w.storyType==="body",B=typeof A.getStateInStory=="function"?()=>A.getStateInStory({target:ma(g),story:w}):E&&typeof A.getState=="function"?()=>A.getState({target:ma(g)}):null;if(!B)return{value:null,status:"ready"};const{value:q,status:oe}=ur(`lists:${Cr(w)}:${g}`,Pt(),B,ve=>ve&&typeof ve=="object"?ve:null);return{value:q?.success===!0?q:null,status:oe}},Yf=(f,g,w)=>kl(f,g,w).value,Al=(f,g,w)=>{const A=Yf(f,g,w);return!A||A.isListItem!==!0?null:A.seed==="bullet"||A.seed==="ordered"?A.seed:null},Il=(f,g,w)=>{const A=kl(f,g,w),E=A.value;return{value:E&&typeof E.isListItem=="boolean"?E.isListItem:null,status:A.status}},Uu=(f,g)=>{const w=Fr(g);if(w.length===0||!fc(w))return null;const A=qi(g),E=Al(f,w[0],A);if(E!=="bullet"&&E!=="ordered")return null;for(const B of w.slice(1))if(Al(f,B,A)!==E)return null;return E},Gu=(f,g,w)=>{if(!f)return{value:null,status:"ready",refreshing:!1};const A=Cr(w),E=A==="story:body";if(E&&typeof f.getNodeById!="function")return{value:null,status:"ready",refreshing:!1};if(!E&&typeof f.getNode!="function")return{value:null,status:"ready",refreshing:!1};const B=`node:${A}:${g}`,q=Pt(),oe=ur(B,q,()=>E?f.getNodeById({nodeId:g,nodeType:"paragraph"}):f.getNode(mo(g,w)),Re=>Re&&typeof Re=="object"?Re:null),ve=ee.get(B);return{...oe,refreshing:oe.status==="stale"&&ve?.inflightToken===q&&ve.failedToken!==q}},El=f=>f==="left"||f==="center"||f==="right"||f==="justify"?f:void 0,Xf=f=>f==="start"||f==="end"||f==="distributed"||f==="numTab"||f==="lowKashida"||f==="mediumKashida"||f==="highKashida"||f==="thaiDistribute",_c=(f,g)=>{const w=T(),A=w?.readMountedProjectionBlocksByIds;if(typeof A!="function")return null;const E=Yi(f),B=Tt(()=>E?A.call(w,[...g],E):A.call(w,[...g]),null);if(!Array.isArray(B))return new Map;const q=fb(B),oe=new Map;for(const ve of g){const Re=q.find(Xe=>hc(Xe,ve));if(!Re)continue;const Ue=Re.attrs,We=El(Ue?.alignment),Le=_9(Ue);oe.set(ve,We??(Le==="rtl"?"right":"left"))}return oe},xl=(f,g,w,A)=>{const{value:E,status:B,refreshing:q}=Gu(f,g,w),oe=A?.get(g);if(B==="pending")return oe?{status:"uniform",value:oe}:{status:"pending"};if(B==="stale"&&!q)return{status:"pending"};if(B==="stale"&&oe)return{status:"uniform",value:oe};if(B==="stale"&&A&&!oe)return{status:"unavailable"};if(!E)return{status:"unavailable"};const ve=E.node;if(!ve)return{status:"unavailable"};const Re=ve.kind;if(Re!=="paragraph"&&Re!=="heading")return{status:"unavailable"};const Ue=ve[Re];if(!Ue||typeof Ue!="object")return{status:"unavailable"};const We=Ue.props?.alignment;if(We==null)return oe?{status:"uniform",value:oe}:{status:"unavailable"};const Le=El(We);return Le?{status:"uniform",value:Le}:Xf(We)&&oe?{status:"uniform",value:oe}:{status:"unavailable"}},Zf=(f,g)=>{const w=Fr(g);if(w.length===0||!fc(w))return{status:"unavailable"};const A=qi(g),E=_c(g,w),B=xl(f,w[0],A,E);if(B.status!=="uniform")return B;for(const q of w.slice(1)){const oe=xl(f,q,A,E);if(oe.status!=="uniform")return oe;if(oe.value!==B.value)return{status:"mixed"}}return B},Ls=f=>{const g=Fr(f);return g.length===0?null:`${Cr(qi(f))}:${g.join(",")}`},Lo=(f,g)=>{const w=Zf(f,g),A=w.status==="uniform"?w.value:void 0,E=o;if(!E)return A;const B=Ls(g);return B&&B!==E.selectionSignature?(o=null,A):!B||!E.settled?E.value:w.status!=="pending"?(o=null,A):E.value},ri=(f,g)=>{const w=El(g),A=Ls(f),E=Fr(f);if(!w||!A||E.length===0)return null;const B=++i;return o={selectionSignature:A,value:w,generation:B,settled:!1,canReconcile:fc(E)},Dt(),B},Wu=(f,g)=>{if(f==null)return;const w=o;if(!(!w||w.generation!==f)){if(!go(g)){o=null;return}if(!w.canReconcile){o=null;return}w.settled=!0}},Sc=async(f,g,w)=>{const A=f?.lists;if(!A)return null;try{const E=w.storyType==="body",B=typeof A.getStateInStory=="function"?await A.getStateInStory({target:ma(g),story:w}):E&&typeof A.getState=="function"?await A.getState({target:ma(g)}):null,q=B&&typeof B=="object"?B:null;return!q||q.success!==!0||typeof q.isListItem!="boolean"?null:q.isListItem}catch{return null}},kc=(f,g,w)=>{const A={resolved:!1,seed:null},E=f?.lists;if(!E)return A;const B=w.storyType==="body",q=typeof E.getStateInStory=="function"?()=>E.getStateInStory({target:ma(g),story:w}):B&&typeof E.getState=="function"?()=>E.getState({target:ma(g)}):null;if(!q)return A;const oe=ve=>{const Re=ve&&typeof ve=="object"?ve:null;return!Re||Re.success!==!0||typeof Re.isListItem!="boolean"?A:{resolved:!0,seed:Re.isListItem===!0&&(Re.seed==="bullet"||Re.seed==="ordered")?Re.seed:null}};try{const ve=q();return Tr(ve)?Promise.resolve(ve).then(oe,()=>A):oe(ve)}catch{return A}},Qf=async(f,g,w)=>{if(!f)return null;try{const A=!w||w.storyType==="body",E=w&&typeof f.getNode=="function"?await f.getNode(mo(g,w)):A&&typeof f.getNodeById=="function"?await f.getNodeById({nodeId:g,nodeType:"paragraph"}):null;return DV(E&&typeof E=="object"?E:null)}catch{return null}},I=(f,g,w,A,E,B)=>{if(f.mutates&&w)return on({enabled:!1,active:E,supported:!0,value:B,reason:lt.documentReadonly},"builtin");const q=Fr(A);if(q.length===0)return on({enabled:!1,active:E,supported:!0,value:B,reason:lt.selectionRequired},"builtin");const oe=f.docRoute?vr(g,f.docRoute):null,ve=vr(g,"format.paragraph.setIndentation"),Re=vr(g,"format.paragraph.clearIndentation"),Ue=f.list?.mode,We=Ue==="indent"?ve!=null:ve!=null||Re!=null,Le=qi(A);let Xe=null;if(Le.storyType!=="body"){Xe=[];for(const Ve of q){const{value:Ze,status:Je}=Il(g,Ve,Le);if(Ze===null)return Je!=="ready"&&(oe!=null||We)?on({enabled:!0,active:E,supported:!0,value:B},"builtin"):on({enabled:!1,active:E,supported:!1,value:B,reason:rs(g)},"builtin");Xe.push(Ze)}}if(Xe?.some(Ve=>Ve===!0)){const Ve=Ue==="indent"?"lists.indentRange":"lists.outdentRange",Ze=Wn()!=="suggesting"&&Xe.every(rt=>rt===!0)&&vr(g,Ve)!=null,Je=Ue==="outdent"&&vr(g,"lists.outdentInStory")!=null;if(!Ze&&!Je)return on({enabled:!1,active:E,supported:!1,value:B,reason:rs(g)},"builtin")}for(const[Ve,Ze]of q.entries()){const Je=Xe?{value:Xe[Ve]??null,status:"ready"}:Il(g,Ze,Le),rt=Je.value;if(rt===!0){if(oe!=null)return on({enabled:!0,active:E,supported:!0,value:B},"builtin");continue}if(rt===!1&&We){if(Le.storyType!=="body"&&typeof g?.getNode!="function")continue;return on({enabled:!0,active:E,supported:!0,value:B},"builtin")}if(rt===null)return Je.status!=="ready"&&(oe!=null||We)?on({enabled:!0,active:E,supported:!0,value:B},"builtin"):on({enabled:!1,active:E,supported:!1,value:B,reason:rs(g)},"builtin")}return on({enabled:!1,active:E,supported:!1,value:B,reason:rs(g)},"builtin")},M=(f,g,w,A,E,B)=>{if(f.mutates&&w)return on({enabled:!1,active:E,supported:!0,value:B,reason:lt.documentReadonly},"builtin");const q=Fr(A);if(q.length===0)return on({enabled:!1,active:E,supported:!0,value:B,reason:lt.selectionRequired},"builtin");const oe=qi(A),ve=g?.lists;if(!(typeof ve?.getStateInStory=="function"||oe.storyType==="body"&&typeof ve?.getState=="function"))return on({enabled:!1,active:E,supported:!1,value:B,reason:lt.operationUnavailable},"builtin");if(!fc(q))return on(oe.storyType==="body"&&vr(g,"lists.remove")!=null?{enabled:!0,active:E,supported:!0,value:B}:{enabled:!1,active:E,supported:!1,value:B,reason:lt.operationUnavailable},"builtin");const Re=q.map(Xe=>kl(g,Xe,oe));if(Re.some(({status:Xe})=>Xe!=="ready"))return on({enabled:!0,active:E,supported:!0,value:B},"builtin");if(Re.some(({value:Xe})=>Xe===null))return on({enabled:!1,active:E,supported:!1,value:B,reason:lt.operationUnavailable},"builtin");const Ue=f.list?.seed,We=Re.every(({value:Xe})=>Xe?.isListItem===!0&&Xe.seed===Ue);if(oe.storyType==="body")return on(!We||vr(g,"lists.remove")!=null?{enabled:!0,active:E,supported:!0,value:B}:{enabled:!1,active:E,supported:!1,value:B,reason:lt.operationUnavailable},"builtin");const Le=vr(g,"lists.removeInStory");return on(We&&Le?{enabled:!0,active:E,supported:!0,value:B}:{enabled:!1,active:E,supported:!1,value:B,reason:lt.operationUnavailable},"builtin")},$=(f,g)=>{const w=Sl(f,g)?.properties?.href;return typeof w=="string"?w:null},ie=f=>{if(!k())return on({enabled:!1,active:!1,supported:!1,reason:lt.notReady},"builtin");const g=f.instanceRoute;return typeof t?.[g]!="function"?on({enabled:!1,active:!1,supported:!1,reason:lt.operationUnavailable},"builtin"):on({enabled:!0,active:se(f),supported:!0,value:he(f)},"builtin")},se=f=>{const g=t?.config??void 0;return f.valueFrom==="ruler"?!!g?.rulers:f.valueFrom==="formattingMarks"?!!g?.layoutEngineOptions?.showFormattingMarks:!1},de=(f,g,w)=>{if(w)return on({enabled:!1,active:!1,supported:!0,reason:lt.documentReadonly},"builtin");const A=Fe();return A!=null&&(!f.table.requiresCell||A.cellNodeId!=null)?(f.docRoute?vr(g,f.docRoute):null)==null?on({enabled:!1,active:!1,supported:!1,reason:rs(g)},"builtin"):on({enabled:!0,active:!1,supported:!0},"builtin"):on({enabled:!1,active:!1,supported:!0,reason:lt.tableContextUnavailable},"builtin")},he=f=>{if(f.valueFrom==="zoom")return yl().value;if(f.valueFrom==="documentMode")return Wn();if(f.valueFrom==="measurementUnit")return gc();if(f.valueFrom==="ruler"||f.valueFrom==="formattingMarks")return se(f)},ue=(f,g)=>f.id==="zoom"?typeof g=="number"&&Number.isFinite(g)&&g>0:f.id==="document-mode"?g==="editing"||g==="suggesting"||g==="viewing":f.id==="measurement-unit"?g==="in"||g==="cm":!0,Te=()=>[...new Set([...yN,...fe.keys()])],Ne="Normal",Oe={ready:!1,status:"ready",catalogRevision:null,quickGallery:[],activeParagraphStyleId:null,activeParagraphStyleName:null,mixedSelection:!1,sourceStatus:null,diagnostics:[]},Qe=f=>{const g=y()?.styles;return!g||typeof g.getCatalog!="function"?{value:null,status:"ready"}:ur(`styles:catalog:${JSON.stringify(f??{})}`,Pt(),()=>g.getCatalog(f),w=>w&&typeof w=="object"?w:null)},ct=()=>{const f=Qe({includePreview:!0});if(!f.value)return{cache:null,status:f.status};const g=Qe({view:"quickGallery",includePreview:!0}),w=g.value?g.value.items:f.value.styles.filter(E=>E.visibility.quickGallery),A=new Map;for(const E of f.value.styles)A.set(E.id,E);return{cache:{full:f.value,quickGallery:w,byId:A},status:Iu(f.status,g.status)}},yt=(f,g,w)=>{const{value:A,status:E}=Gu(f,g,w);if(!A)return{ok:!1,styleRef:null,status:E};const B=A.node;if(!B||typeof B!="object")return{ok:!1,styleRef:null,status:E};const q=B.kind,oe=typeof q=="string"?B[q]:void 0,ve=oe&&typeof oe=="object"?oe.styleRef:void 0;return{ok:!0,styleRef:typeof ve=="string"&&ve.length>0?ve:null,status:E}},nt=(f,g)=>{const w=[],A=y();if(!A)return w.push({severity:"warning",code:"active-style-unavailable",message:"Active paragraph style is unavailable: the Document API is not reachable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:w},status:"ready"};const E=Fr(f);if(E.length===0)return w.push({severity:"info",code:"active-style-no-selection",message:"No paragraph block is resolvable from the current selection; active paragraph style is unavailable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:w},status:"ready"};if(!fc(E))return w.push({severity:"info",code:"active-style-selection-too-large",message:"Active paragraph style is unavailable for a large multi-paragraph selection."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:w},status:"ready"};const B=g?.full.defaults.paragraphStyleId??(g?Ne:null),q=new Set;let oe=0,ve=0,Re=0,Ue="ready";const We=qi(f);for(const Ve of E){const Ze=yt(A,Ve,We);if(Ue=Iu(Ue,Ze.status),!Ze.ok){ve+=1;continue}if(!Ze.styleRef&&!B){Re+=1;continue}const Je=Ze.styleRef??B;if(!Je){Re+=1;continue}oe+=1,q.add(Je)}if(oe===0){const Ve=Re>0&&ve===0;return w.push({severity:"warning",code:Ve?"active-style-default-unavailable":"active-style-read-failed",message:Ve?"Selected paragraphs have no explicit style and the style catalogue is unavailable, so the document default cannot be resolved.":"Could not read the paragraph style of any selected block; active paragraph style is unavailable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:w},status:Ue}}const Le=ve+Re;if(Le>0)return w.push({severity:"warning",code:"active-style-partial",message:`Active paragraph style resolved from ${oe} of ${oe+Le} selected blocks; ${Le} could not be read, so the active style is unavailable.`}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:w},status:Ue};if(q.size>1)return{style:{styleId:null,styleName:null,mixed:!0,diagnostics:w},status:Ue};const Xe=[...q][0];return{style:{styleId:Xe,styleName:g?.byId.get(Xe)?.name??null,mixed:!1,diagnostics:w},status:Ue}},ln=f=>{if(!k())return Oe;const{cache:g,status:w}=ct(),{style:A,status:E}=nt(f,g);let B;return g?B=A.diagnostics.length===0?g.full.diagnostics:[...g.full.diagnostics,...A.diagnostics]:B=[{severity:"warning",code:"catalog-unavailable",message:"The style catalogue is unavailable: the Document API styles surface is not reachable (e.g. viewing mode or a worker-backed editor)."},...A.diagnostics],{ready:!0,status:Iu(w,E,f.status),catalogRevision:g?.full.revision??null,quickGallery:g?.quickGallery??[],activeParagraphStyleId:A.styleId,activeParagraphStyleName:A.styleName,mixedSelection:A.mixed,sourceStatus:g?.full.sourceStatus??null,diagnostics:B}},nn=()=>{const f=Wn(),g=Pu();g.status==="ready"&&Lu(g),N(g);const w=ga(g);for(const[A,E]of r)(!w||E.selectionSignature!==w||E.settled&&g.status==="ready")&&r.delete(A);return{ready:k()!=null,documentMode:f,document:Ou(),selection:g,toolbar:{context:f,commands:_a(g),copyFormatActive:h.mode!=="idle"},comments:vl(g),trackChanges:yi(g),contentControls:Gf(g),zoom:yl(),fonts:Wf(),styles:ln(g)}},Vn=f=>{const g=ga(f);g&&a&&g!==a&&(n.clear(),r.clear()),g&&(a=g)};let Ut=null,Cn=null,Sr=null,Kn=null,dr=!1;const yr=()=>{if(Z||dr)return;dr=!0;const f=()=>{dr&&(dr=!1,!Z&&Dt())};typeof queueMicrotask=="function"?queueMicrotask(f):Promise.resolve().then(f)},Bo=()=>{const f=x();if(f!==Sr&&(Kn&&(Kn(),Kn=null),Sr=f,!(!f||typeof f.subscribe!="function")))try{const g=f.subscribe(()=>yr());typeof g=="function"&&(Kn=g)}catch{Sr=null}};let Rn=null,at=null,pn=null,An=null,Ur=null,oi=null;const zo=()=>{const f=k()?.host,g=Tt(f?.getHandles?()=>f.getHandles():void 0,null)?.editing?.selection;return g&&typeof g.subscribe=="function"?g:null},Ps=()=>{const f=zo();if(f!==Ut&&(Cn&&(Cn(),Cn=null),Ut=f,!!f))try{const g=f.subscribe(w=>{Kt+=1,Uf(w),Dt()});typeof g=="function"&&(Cn=g)}catch{Ut=null}},ka=()=>{const f=k()?.host,g=Tt(f?.getHandles?()=>f.getHandles():void 0,null)?.review;return g&&typeof g.subscribe=="function"?g:null},bi=f=>f?typeof f.getActiveReviewTarget=="function"?Tt(()=>f.getActiveReviewTarget(),null):typeof f.getSnapshot=="function"?Tt(()=>f.getSnapshot(),null)?.activeReviewTarget??null:null:null;let Vo=0;const Po=(f,g)=>{const w=(g&&typeof g=="object"?g:null)?.lastInteractionRejection;if(Vo>0&&f==null&&w&&typeof w=="object"&&w.code==="review-target-invalidated"&&w.detail==="not-painted")return!1;const A=f&&typeof f=="object"?f:null;let E=null;if(A?.entityType==="trackedChange"&&typeof A.entityId=="string"&&A.entityId.length>0){const B=A.entityId,q=A.story&&typeof A.story=="object"?A.story:void 0,oe=ts(),ve=(oe?q?Eu(oe,q).toPublicId(B):pa(oe).toPublicId(B):null)??B,Re=q&&Cr(q)!==Cr(null)?q:void 0;E={id:ve,...Re?{story:Re}:{},...typeof A.paintedEntityId=="string"&&A.paintedEntityId.length>0?{paintedEntityId:A.paintedEntityId}:ve!==B?{paintedEntityId:B}:{}}}return f==null&&E==null&&le!=null&&At(le)||st(le,E)?!1:(Ge(E),!0)},Aa=()=>{const f=ka();if(f===Rn)return;if(at&&(at(),at=null),Rn=f,!f){Po(null);return}let g=!0;try{const w=f.subscribe(A=>{const E=A&&typeof A=="object"?A:null;!Po(E&&Object.prototype.hasOwnProperty.call(E,"activeReviewTarget")?E.activeReviewTarget:bi(f),A)||g||Dt()});typeof w=="function"&&(at=w),Po(bi(f))}catch{Rn=null}finally{g=!1}},Tl=()=>{if(Ut||Wn()!=="viewing")return null;const f=k()?.mount?.container,g=(f&&typeof f=="object"&&"ownerDocument"in f?f.ownerDocument??null:null)??globalThis.document??null;return g&&typeof g.addEventListener=="function"?g:null},Ho=()=>{const f=Tl();if(f===Ur||(oi&&(oi(),oi=null),Ur=f,!f))return;const g=()=>{Kt+=1,Dt()};f.addEventListener("selectionchange",g),f.addEventListener("pointerup",g,!0),f.addEventListener("mouseup",g,!0),oi=()=>{f.removeEventListener("selectionchange",g),f.removeEventListener("pointerup",g,!0),f.removeEventListener("mouseup",g,!0)}};xs(),Po(bi(ka()));let ut=nn();a=ga(ut.selection);const Di=()=>{const f=k()?.host?.events,g=f&&typeof f.subscribe=="function"?f:null;if(g!==pn&&(An&&(An(),An=null),pn=g,!!g))try{const w=g.subscribe(A=>{const E=A?.type;if(E==="source:complete"||E==="source:signals-complete"){sn!==null&&(Ye(),hn.onRender(!0));return}if((E==="mutation:committed"||E==="collaboration:remote-changed")&&(Qi=Date.now()),E==="mutation:committed"&&(Ye(),Nt={}),E==="mutation:committed"||E==="save:completed"||E==="collaboration:remote-changed"){const B=E==="mutation:committed"?B_(A):null,q=E==="mutation:committed"&&hn.getPendingIds().size>0;B?.removedIds.size&&kt(new Set(B.removedIds),A.receipt);const oe=B?.reconcileMode==="authoritative"&&B.upsertIds.size>0;if(oe&&(Mo(),Ye(),sn=Pt(),Dt()),B?.upsertIds.size||q){const We=A.origin==="history"?null:A.receipt,Le=k()?.documentMutationReadiness,Xe=typeof We?.txId=="string"&&We.txId.length>0&&typeof Le?.whenPainted=="function",Ve=A.origin==="history"&&typeof Le?.getRenderEpoch=="function"?Tt(()=>Le.getRenderEpoch.call(Le),null):null,Ze=A.origin==="history"&&typeof Le?.whenPainted=="function",Je={upsertIds:B?.upsertIds??new Set,removedIds:new Set,reconcileMode:B?.reconcileMode==="authoritative"?"authoritative":"targeted"};Xe?hn.enqueueAfterPaint(Je,()=>Le.whenPainted.call(Le,We)):Ze?hn.enqueueAfterPaint(Je,()=>Le.whenPainted.call(Le,typeof Ve=="number"?{afterEpoch:Ve}:void 0)):(hn.enqueue(Je),hn.onRender(q))}if(oe)return;const ve=E==="mutation:committed"&&Es(A)||E==="collaboration:remote-changed"&&Array.isArray(A.changedStoryIds)&&A.changedStoryIds.length>0;if(ve&&(hl=Date.now()),E==="mutation:committed"&&ve){$o();return}if(B?.removedIds.size&&B.upsertIds.size===0)return;(E==="collaboration:remote-changed"||E==="mutation:committed"&&!ve)&&lo();const Re=E==="collaboration:remote-changed"&&Array.isArray(A.changedPartUris)&&A.changedPartUris.some(We=>typeof We=="string"&&wV.has(We)),Ue=E==="collaboration:remote-changed"&&Array.isArray(A.changedStoryIds)&&A.changedStoryIds.length>0&&xi();Re&&!ve&&(Ti=!0),Mo(),(Re||Ue)&&Bn("comments"),Dt()}});typeof w=="function"&&(An=w)}catch{pn=null}},Dt=()=>{if(Z)return;dr=!1,xs(),Ps(),Bo(),Aa(),Ho(),Di();const f=nn();Vn(f.selection),ut=f;for(const g of[...qe])g(ut)},Rl=[],Ia=[],Ea=f=>{for(const g of f)try{g()}catch{}},Ac=()=>Ea(Rl),Ml=()=>Ea(Ia),Ll=[];((f,g)=>{if(!(!f||typeof f.on!="function"))for(const w of g){const A=w==="active-editor-change"?()=>{Ac(),Ml(),Dt()}:w==="document-replaced"?E=>{const B=E&&typeof E=="object"?E:null,q=B?.editor,oe=B?.host,ve=!!q&&q===k(),Re=!!oe&&oe===T();!ve&&!Re||(Ml(),ee.clear(),Mo(),Dt())}:()=>Dt();try{f.on(w,A),Ll.push(()=>{try{typeof f.off=="function"&&f.off(w,A)}catch{}})}catch{}}})(t,pV),Ps(),Bo(),Aa(),Ho(),Di();const xa=(f,g=eV)=>({get:()=>f(ut),subscribe:w=>{let A=f(ut);const E=B=>{const q=f(B);g(A,q)||(A=q,w(q))};return qe.add(E),()=>qe.delete(E)}}),ii=f=>xa(f),wo=f=>{const g=w=>{const A=B=>{try{w(B)}catch{}},E=f.subscribe(A);return A(f.get()),E};return{get:()=>f.get(),getSnapshot:()=>f.get(),observe:g,subscribe:w=>g(A=>w({snapshot:A}))}};function zt(f){return f&&typeof f=="object"&&typeof f.id=="string"?String(f.id):null}function Hn(f){const g=Yi(f);return g&&Cr(g)!==Cr(null)?g:void 0}function Br(f,g){return{kind:"id",id:f,...g?{story:g}:{}}}function fr(f){if(f.empty)return null;const g=f.selectionTarget,w=g?.start,A=g?.end;if(g?.kind!=="selection"||w?.kind!=="text"||A?.kind!=="text"||typeof w.blockId!="string"||w.blockId!==A.blockId||!Number.isInteger(w.offset)||!Number.isInteger(A.offset)||w.offset<0||A.offset<0||w.offset===A.offset)return null;const E=Math.min(w.offset,A.offset),B=Math.max(w.offset,A.offset),q=Yi(f);return{kind:"range",coordinateSpace:g.coordinateSpace==="tracked"?"tracked":"visible",range:{kind:"text",...q?{story:q}:{},segments:[{blockId:w.blockId,range:{start:E,end:B}}]}}}function jo(f,g){if(Cr(g)!==Cr(null))return;const w=y()?.trackChanges,A=w?.list;if(typeof A!="function")return;const E=Tt(()=>A.call(w),null);if(Tr(E)||!E||typeof E!="object")return;const B=E.items;if(Array.isArray(B))return B.map(dl).find(q=>q!=null&&Ki(q,f,g))}function os(f,g){const w=is(f.quotedText);if(!w)return!1;const A=ym(g);return[A.insertedText,A.deletedText,A.excerpt].some(E=>is(E)===w)}function is(f){return typeof f=="string"?f.replace(/\s+/g," ").trim():""}function Ta(){const f=ut.selection.activeChangeIds[0];if(!f)return"unavailable";const g=Yi(ut.selection),w=(ut.trackChanges.status==="ready"?ut.trackChanges.items.find(q=>Ki(q,f,g)):void 0)??jo(f,g)??ts()?.find(q=>Ki(q,f,g));if(!w)return"unavailable";const A=ym(w),E=A.type,B=A.grouping;return os(ut.selection,w)?"id":E==="replacement"&&B==="replacement-pair"||(E==="insertion"||E==="deletion"||E==="insert"||E==="delete")&&B==="standalone"?"range":"id"}function Ku(f,g,w,A){const E=()=>Sb(f,Br(w,A),w,A);try{const B=Sb(f,g,null);return Tr(B)?br(Promise.resolve(B).then(q=>go(As(q))?q:E())):br(go(As(B))?B:E())}catch{return!1}}function qu(f,g){if(f.scope==="all")return{target:{scope:"all"},changeId:null};if(typeof g=="string"&&g.length>0)return{target:{kind:"id",id:g},changeId:g};if(g&&typeof g=="object"){const E=g;if(E.target&&typeof E.target=="object"){const q=E.target;return{target:q,changeId:zt(q),story:q.story}}const B=typeof E.changeId=="string"?E.changeId:E.id;if(typeof B=="string"&&B.length>0)return{target:Br(B,E.story),changeId:B,story:E.story}}const w=ut.selection.activeChangeIds[0],A=Hn(ut.selection);return w?{target:Br(w,A),changeId:w,story:A}:null}function Yu(f,g){if(f.scope==="id"&&g==null){if(ut.selection.activeChangeIds.length>1)return nh(f.kind,{kind:"ids",ids:ut.selection.activeChangeIds},null);if(ut.selection.activeChangeIds.length===1&&!ut.selection.empty&&ut.selection.selectionTarget){const A=Ta();if(A==="unavailable")return!1;if(A==="range"){const E=fr(ut.selection),B=Hn(ut.selection);return E?Ku(f.kind,E,ut.selection.activeChangeIds[0],B):!1}if(A==="id"){const E=ut.selection.activeChangeIds[0],B=Yi(ut.selection),q=B&&Cr(B)!==Cr(null)?B:void 0;return _b(f.kind,q?{id:E,story:q}:E)}}}const w=qu(f,g);return w?nh(f.kind,w.target,w.changeId,w.story):!1}function Xu(f,g){const w=x()?.lists,A=w?.apply;if(typeof A!="function")return!1;const{behavior:E,preset:B,continuity:q}=typeof g=="string"?vV(g):g&&typeof g=="object"?g:{},oe={kind:f,behavior:E??"toggle"};B!==void 0&&(oe.preset=B),q!==void 0&&(oe.continuity=q);try{return br(A.call(w,oe))}catch{return!1}}let Oi=Promise.resolve(!1),si=null,L=Promise.resolve(!1);const W=async f=>{if(!bm(f))return f;const g=k()?.documentMutationReadiness,w=g?.whenPainted;if(typeof w!="function")return f;const A=typeof f.txId=="string"?f.txId:void 0;try{await w.call(g,A?{txId:A}:void 0)}catch{}return f},we=f=>{if(Tr(f)){const w=Promise.resolve(f);return{immediate:!0,committed:w.then(A=>As(A),()=>!1),settled:w.then(A=>W(As(A)),()=>!1)}}const g=As(f);return{immediate:g,committed:Promise.resolve(g),settled:W(g)}},Be=()=>{const f=s.shift();if(!f){u=!1,d?.(),d=null;return}try{f.resolve(Z?!1:f.mutate())}catch{f.resolve(!1)}},gt=()=>{let f=!1;return()=>{f||(f=!0,Be())}},vn=(f,g)=>{if(!u){u=!0,c=new Promise(B=>{d=B});try{return{result:g(),release:gt()}}catch(B){throw u=!1,d?.(),d=null,B}}const w=s.find(B=>B.key===f);if(w)return w.mutate=g,{result:w.result,release:()=>{}};let A;const E=new Promise(B=>{A=B});return s.push({key:f,mutate:g,result:E,resolve:A}),{result:E,release:gt()}},Dn=new Set(["create.tableOfContents"]),hr=f=>lr(`Tracked authoring is not supported for ${f}.`),jn=f=>{if(Wn()==="suggesting")return Dn.has(f)?hr(f):{changeMode:"tracked"}},pr=()=>Wn()==="suggesting"?QV:pb,Xt=(f,g,w)=>{const A=jn(f);return A&&A.success===!1?A:A?g(w,A):g(w)},Co=(f,g,w,A)=>{const E=f.inline;if(!E)return;const B=As(A);if(B===!1||typeof B=="object"&&B&&B.success===!1)return;if(E.kind==="clear"){n.clear();return}if(E.kind==="toggle"||!cb(E.key))return;const q=ga(g);if(!q)return;const oe=BV(E.key,w.value);if(oe==null){n.delete(E.key);return}n.set(E.key,{selectionSignature:q,value:oe})},co=(f,g,w,A)=>!f.inline||f.inline.kind==="toggle"?A:Tr(A)?Promise.resolve(A).then(E=>(Co(f,g,w,E),E)):A,Ra=(f,g,w,A)=>{if(f.inline?.kind!=="toggle"||!go(As(A))||typeof w.value!="boolean"&&w.value!==null)return null;const E=ga(g);if(!E)return null;const B=++l;return r.set(f.id,{selectionSignature:E,active:w.value===!0,generation:B,settled:!1}),Dt(),B},Dl=(f,g,w)=>{if(g==null)return;const A=r.get(f.id);if(!(!A||A.generation!==g)){if(!go(w)){r.delete(f.id);return}A.settled=!0}},_o=(f,g)=>f.then(w=>(g?.(w),Mo(),Dt(),w),()=>(g?.(!1),Mo(),Dt(),!1)),br=(f,g)=>{const w=si;if(si=null,w)return Oi=_o(w,g),As(f);if(Tr(f))return Oi=_o(we(f).settled,g),!0;const A=As(f);return bm(A)&&typeof k()?.documentMutationReadiness?.whenPainted=="function"?(Oi=_o(W(A),g),A):(g?.(A),Oi=Promise.resolve(A),Mo(),Dt(),A)},Ol=(f,g)=>!f||typeof f!="object"?g:f,Ma=(f,g=lr("Document API operation failed."))=>{if(Tr(f))return Promise.resolve(f).then(A=>Ma(A,g),()=>g);const w=Ol(f,g);return Mo(),bm(w)&&typeof k()?.documentMutationReadiness?.whenPainted=="function"?(_o(W(w)),Dt(),w):(Dt(),w)},Sm=(f,g,w,A)=>{const E=[],B=[];for(const q of w){const oe=A(q);if(oe)try{const ve=we(Xt(f,g,oe));E.push(ve.immediate),B.push(ve.settled)}catch{E.push(!1),B.push(Promise.resolve(!1))}}return si=B.length?Promise.all(B).then(q=>mi(q)):null,mi(E)},km=(f,g,w,A)=>{const E=[],B=[];for(const q of w){const oe=A(q);if(oe)try{const ve=we(Xt(f,g,oe));E.push(ve.immediate),B.push(ve.settled)}catch{E.push(!1),B.push(Promise.resolve(!1))}}return si=B.length?Promise.all(B).then(q=>mi(q)):null,mi(E)},Jf=(f,g,w,A=ut.selection)=>{const E=jn(f);return E&&E.success===!1?E:A.selectionTarget?g(w,{...E??{},offsetSpace:"selection"}):E?g(w,E):g(w)},vb=(f,g,w,A)=>{const E=mo(g,A);switch(f.kind){case"alignment":{const B=w;return B!=="left"&&B!=="center"&&B!=="right"&&B!=="justify"?null:{target:E,alignment:B}}case"spacing-line":{const B=typeof w=="number"?w:Number(w);return!Number.isFinite(B)||B<=0?null:{target:E,line:B,lineRule:"auto"}}case"style":if(w&&typeof w=="object"){const B=w.role;if(B&&typeof B=="object")return{target:E,role:B}}return typeof w!="string"||w.trim()===""?null:{target:E,styleId:w};case"direction":{const B=f.fixedValue;return B!=="ltr"&&B!=="rtl"?null:{target:E,direction:B}}default:return null}},$f=(f,g)=>{const w=f.inline,A=hb(f),E=T();if(!w||typeof E?.setPendingInlineFormat!="function")return!1;if(w.kind==="clear")return Q(),!0;if(!A)return!1;let B;if(w.kind==="toggle")B=!Sa(f,y(),ut.selection);else{const q=g&&typeof g=="object"&&"value"in g?g.value:g;if(w.kind==="value-number"){const oe=typeof q=="number"?q:Number(q);B=Number.isFinite(oe)&&oe>0?oe:null}else B=typeof q=="string"&&q.trim()!==""?q:null;if(B===null)return V(A,null),!0}return V(A,B),!0},Jn=()=>{const f=y(),{lockModesById:g}=wa(f?.contentControls,ut.selection);if(Pi(g))return!1;const w=[],A=[],E=Xe=>{const Ve=we(Xe);w.push(Ve.immediate),A.push(Ve.settled)},B=(Xe,Ve,Ze)=>{try{E(Ze?Xe(Ve,Ze):Xe(Ve))}catch{w.push(!1),A.push(Promise.resolve(!1))}},q=ct().cache?.full.defaults.paragraphStyleId??Ne,oe=Mu(ut.selection);if(oe){const Xe=vr(f,"format.apply");if(Xe)try{E(Jf("format.apply",Xe,{target:oe,inline:{...pr()}}))}catch{w.push(!1),A.push(Promise.resolve(!1))}}const ve=vr(f,"format.paragraph.resetDirectFormatting"),Re=vr(f,"styles.paragraph.setStyleRef"),Ue=Yi(ut.selection),We=!Ue||Ue.storyType==="body",Le=vr(f,We?"lists.remove":"lists.removeInStory");for(const Xe of Fr(ut.selection)){const Ve=mo(Xe,Ue);if(ve&&B(ve,{target:Ve}),Le)try{const Ze=ma(Xe),Je=we(Le(We?{target:Ze}:{target:Ze,story:Ue}));A.push(Je.settled.then(rt=>go(rt)?rt:!0))}catch{}Re&&B(Re,{target:Ve,styleId:q})}if(!oe&&Wn()!=="suggesting"){const Xe=vr(f,"format.paragraph.setMarkRunProps");if(Xe)for(const Ve of Fr(ut.selection))B(Xe,{target:mo(Ve,Ue),markRunProps:{bold:!1,italic:!1,strikethrough:!1,doubleStrikethrough:!1,smallCaps:!1,caps:!1,verticalAlign:"baseline"}})}return si=A.length?Promise.all(A).then(Xe=>mi(Xe)):null,mi(w.length?w:[!1])},yb=(f,g,w)=>{const A=Fr(ut.selection);if(A.length===0)return!1;const E=Yi(ut.selection);return Sm(f.docRoute,g,A,B=>vb(f.blockParagraph,B,w,E))},Am=(f,g,w)=>{const A=y(),E=vr(A,"format.paragraph.setIndentation"),B=vr(A,"format.paragraph.clearIndentation"),q=f.list?.mode,oe=qi(ut.selection),ve=Yi(ut.selection),Re=async Ue=>{const We=await Sc(A,Ue,oe);if(We===!0)return{kind:"list",routeToCall:f.docRoute,opToCall:g,input:{target:bA(Ue)}};if(We===null||ve&&ve.storyType!=="body"&&typeof A?.getNode!="function")return null;const Le=await Qf(A,Ue,ve),Xe={};if(Le?.right!=null&&(Xe.right=Le.right),Le?.firstLine!=null&&(Xe.firstLine=Le.firstLine),Le?.hanging!=null&&(Xe.hanging=Le.hanging),q==="indent")return E?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:E,input:{target:mo(Ue,ve),left:Math.max(0,Le?.left??0)+wA,...Xe}}:null;const Ve=Math.max(0,(Le?.left??0)-wA);return Ve>0&&(Xe.left=Ve),Object.keys(Xe).length===0?B?{kind:"paragraph",routeToCall:"format.paragraph.clearIndentation",opToCall:B,input:{target:mo(Ue,ve)}}:E?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:E,input:{target:mo(Ue,ve),left:0}}:null:E?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:E,input:{target:mo(Ue,ve),...Xe}}:null};return si=(async()=>{const Ue=await Promise.all(w.map(Ve=>Re(Ve).catch(()=>null)));if(Ue.length===w.length&&Ue.every(Ve=>Ve?.kind==="list")&&Wn()!=="suggesting"){const Ve=q==="indent"?"lists.indentRange":"lists.outdentRange",Ze=vr(A,Ve);if(Ze)try{return await we(Xt(Ve,Ze,{paraIds:w,story:oe})).settled}catch{return!1}}const We=oe.storyType!=="body"&&Ue.some(Ve=>Ve?.kind==="list"),Le=We&&q==="outdent"?vr(A,"lists.outdentInStory"):null;if(We&&!Le)return!1;const Xe=Ue.map(Ve=>{if(!Ve)return Promise.resolve(!1);try{return Ve.kind==="list"&&Le?we(Xt("lists.outdentInStory",Le,{target:Ve.input.target,story:oe})).settled:we(Xt(Ve.routeToCall,Ve.opToCall,Ve.input)).settled}catch{return Promise.resolve(!1)}});return mi(await Promise.all(Xe))})(),!0},Im=(f,g)=>{const w=f.list,A=y(),E=Fr(ut.selection);if(E.length===0)return!1;const B=qi(ut.selection),q=B.storyType==="body";if(w.mode==="indent"||w.mode==="outdent")return Am(f,g,E);const oe=w.seed,ve=We=>{if(We.some(rt=>!rt.resolved))return{immediate:!1,settled:null};const Le=We.every(rt=>rt.seed===oe);if(!Le&&!q)return{immediate:!1,settled:null};const Xe=Le?q?"lists.remove":"lists.removeInStory":f.docRoute,Ve=Le?vr(A,Xe):g;if(!Ve)return{immediate:!1,settled:null};const Ze=[],Je=[];return E.forEach((rt,tt)=>{if(!Le&&We[tt]?.seed===oe)return;const Rt=Le?{target:ma(rt),...q?{}:{story:B}}:{target:ma(rt),seed:oe};try{const Gt=we(Xt(Xe,Ve,Rt));Ze.push(Gt.immediate),Je.push(Gt.settled)}catch{Ze.push(!1),Je.push(Promise.resolve(!1))}}),{immediate:mi(Ze),settled:Je.length?Promise.all(Je).then(rt=>mi(rt)):null}},Re=E.map(We=>kc(A,We,B));if(Re.some(Tr))return si=Promise.all(Re).then(async We=>{const Le=ve(We);return Le.settled?await Le.settled:Le.immediate}),!0;const Ue=ve(Re);return si=Ue.settled,Ue.immediate};function Ic(f){return f&&typeof f=="object"?f:{}}function Em(f){if(typeof f=="string")return f;const g=Ic(f);if(Object.prototype.hasOwnProperty.call(g,"href"))return g.href;if(Object.prototype.hasOwnProperty.call(g,"value"))return g.value}function xm(f,g){const w=Ic(f).text;return typeof w=="string"&&w.trim()!==""?w:g}function eh(f){const g=Ic(f),w=g.capture&&typeof g.capture=="object"?g.capture:null;return g.target??w?.target??w?.selectionTarget??g.selectionTarget??g.textTarget??null}const bb=f=>{const g=y(),w=g?.hyperlinks;if(!w)return!1;const A=Ic(f),E=Em(f),B=eh(f),q=typeof A.text=="string"?A.text:void 0,oe=typeof A.currentText=="string"?A.currentText:void 0,ve=Ru(A.hyperlinkTarget)?A.hyperlinkTarget:null,Re=Ru(A.textTarget)?A.textTarget:null,Ue=Sl(g,ut.selection),We=typeof ve?.storyId=="string"&&typeof ve?.hyperlinkNodeId=="string";if(We&&E===null){const Le=w.remove;if(typeof Le!="function")return!1;try{return Xt("hyperlinks.remove",Le,{storyId:ve.storyId,hyperlinkNodeId:ve.hyperlinkNodeId,keepText:!0})}catch{return!1}}if(Ue&&E===null){const Le=w.remove;if(typeof Le!="function")return!1;try{return Xt("hyperlinks.remove",Le,{target:Ue.address,mode:"unwrap"})}catch{return!1}}if((Ue||ve)&&typeof E=="string"&&E.trim()!==""){const Le=w.patch,Xe=w.updateTarget;if(!(!We&&Ue&&typeof Le=="function")&&!(We&&typeof Xe=="function"))return!1;const Ve=typeof q=="string"&&q!==(We?oe:Ue?.text??oe),Ze=g?.text?.replace,Je=Ve?We?Re:WV(Ue?.address):null,rt=Ve&&!!Je&&typeof Ze=="function";if(Ve&&!rt)return!1;const tt=[],Rt=[];let Gt=null,en=null,Mn=null,Rr=!1;try{if(We){if(typeof Xe!="function")return!1;const Ar=Xt("hyperlinks.updateTarget",Xe,{storyId:ve.storyId,hyperlinkNodeId:ve.hyperlinkNodeId,newTarget:KV(E)});Rr=Tr(Ar);const zr=we(Ar);if(!go(zr.immediate))return!1;tt.push(zr.immediate),Rt.push(zr.settled),Gt=zr.immediate,en=zr.committed,Mn=zr.settled}else if(Ue){if(typeof Le!="function")return!1;const Ar=Xt("hyperlinks.patch",Le,{target:Ue.address,patch:{href:E}});Rr=Tr(Ar);const zr=we(Ar);if(!go(zr.immediate))return!1;tt.push(zr.immediate),Rt.push(zr.settled),Gt=zr.immediate,en=zr.committed,Mn=zr.settled}}catch{return!1}if(rt){const Ar=(Mr,Uo)=>go(Uo)?mi([Mr,Uo]):go(Mr)?Nf(Mr,Uo):Uo,zr=Mr=>{if(!go(Mr))return Mr;try{const Uo=we(Xt("text.replace",Ze,{target:Je,text:q}));return go(Uo.immediate)?Promise.all([Mn??Promise.resolve(Mr),Uo.settled]).then(([xb,ej])=>Ar(xb,ej)):Nf(Mr,Uo.immediate)}catch{return Nf(Mr,!1)}};if(Rr)return si=(en??Promise.resolve(Gt??!1)).then(zr),mi(tt);try{const Mr=we(Xt("text.replace",Ze,{target:Je,text:q}));if(!go(Mr.immediate))return Gt?Nf(Gt,Mr.immediate):Mr.immediate;tt.push(Mr.immediate),Rt.push(Mr.settled),si=Promise.all([Mn??Promise.resolve(Gt??!1),Mr.settled]).then(([Uo,xb])=>Ar(Uo,xb))}catch{return Gt?Nf(Gt,!1):!1}}return!rt&&Rt.length>0&&(si=Promise.all(Rt).then(Ar=>mi(Ar))),mi(tt)}if(typeof E=="string"&&E.trim()!==""){const Le=E.trim(),Xe=w.wrap,Ve=OV(B),Ze=Ve.length>0?Ve:lb(ut.selection);if(Ze.length>0){if(typeof Xe!="function")return!1;try{return km("hyperlinks.wrap",Xe,Ze,Rt=>({target:Rt,link:{destination:{href:Le}}}))}catch{return!1}}const Je=w.insert,rt=xm(f,Le);if(typeof Je!="function"||rt.trim()==="")return!1;const tt=Vf(B)??ul(ut.selection);if(!tt)return!1;try{return Xt("hyperlinks.insert",Je,{target:tt,text:rt,link:{destination:{href:Le}}})}catch{return!1}}return!1},Tm=(f,g,w)=>{const A=f.create.kind,E=w&&typeof w=="object"?w:{};if(A==="table"){const q=Number(E.rows??E.rowCount),oe=Number(E.columns??E.cols??E.colCount);if(!Number.isInteger(q)||q<1||!Number.isInteger(oe)||oe<1)return!1;const ve=ul(ut.selection),Re=ve&&typeof ve.blockId=="string"?{kind:"inParagraph",target:mo(ve.blockId),offset:ve.range?.start??0}:db(ut.selection,"nodeId");try{return Xt(f.docRoute,g,{rows:q,columns:oe,at:Re})}catch{return!1}}if(A==="image"){const q=E.src??E.value;if(typeof q!="string"||q.trim()==="")return!1;const oe=ul(ut.selection),ve=qi(ut.selection),Re=ve.storyType==="body"?null:ve;let Ue;oe&&typeof oe.blockId=="string"?Ue={kind:"inParagraph",target:mo(oe.blockId,Re),offset:oe.range?.start??0}:(Ue=db(ut.selection,"target"),Re&&Ue.kind==="after"&&(Ue={...Ue,target:{...Ue.target,story:Re}}));const We={src:q,at:Ue};Re&&(We.in=Ue.kind==="inParagraph"?R(Re)??Re:Re),typeof E.alt=="string"&&(We.alt=E.alt),typeof E.title=="string"&&(We.title=E.title),E.size&&typeof E.size=="object"&&(We.size=E.size);try{return Xt(f.docRoute,g,We)}catch{return!1}}const B={at:db(ut.selection,"target")};typeof E.instruction=="string"&&(B.instruction=E.instruction),E.config&&typeof E.config=="object"&&(B.config=E.config);try{return Xt(f.docRoute,g,B)}catch{return!1}},Ec=(f,g)=>{const w=f.table,A=Fe();if(!A||w.requiresCell&&!A.cellNodeId)return!1;const E=eH(w.action,A);if(!E)return!1;try{if(w.action==="insert-row-before"||w.action==="insert-row-after"){const B=T(),q=(typeof B?.getHandles=="function"?B.getHandles():null)?.editing?.tables;if(typeof q?.insertRow!="function")return!1;const oe=jn(f.docRoute);return oe&&oe.success===!1?oe:oe?q.insertRow(E,oe):q.insertRow(E)}return Xt(f.docRoute,g,E)}catch{return!1}},Zu=f=>!f||f.disposition!=="routed"?!1:!!(f.inline||f.blockParagraph||f.list||f.link||f.create),th=f=>{const g=Ic(f);return!!(eh(f)||Ru(g.hyperlinkTarget)||Ru(g.textTarget))},It=(f,g,w)=>ut.selection.status!=="ready"?!1:wm(f)?.scope==="id"||!g||g.disposition!=="routed"?!0:g.inline?.kind==="clear"?Fr(ut.selection).length>0||Mu(ut.selection)!=null:g.inline?Mu(ut.selection)!=null||Fr(ut.selection).length>0:g.blockParagraph||g.list?Fr(ut.selection).length>0:g.link?th(w)||lb(ut.selection).length>0||ul(ut.selection)!=null||Sa(g,y(),ut.selection):!0,Ht=(f,g)=>{const w=wm(f),A=Su(f);return w?.scope!=="id"&&!Zu(A)?!1:!It(f,A,g)},bn=(f,g)=>Ht(f,g)?ba().then(()=>{}):null,qn=(f,g,w)=>{if(si=null,Oi=Promise.resolve(!1),Z)return!1;const A=fe.get(f);if(A)try{return br(A.execute(ya(g,w)))}catch{return!1}const E=hA(f);if(E&&typeof x()?.lists?.apply=="function")return Xu(E,g);const B=wm(f);if(B)return Yu(B,g);if(f==="copy-format")return br(uo());const q=Su(f);if(!q||q.disposition!=="routed")return!1;const oe=q.normalizePayload?q.normalizePayload(g):g;if(q.instanceRoute){if(!k()||!ue(q,oe))return!1;const We=t?.[q.instanceRoute];if(typeof We!="function")return!1;try{const Le=q.fixedArg!==void 0?q.fixedArg:oe;return br(We.call(t,Le))}catch{return!1}}if(q.inline?.kind==="clear")return q.mutates&&Wn()==="viewing"?!1:br(Jn());const ve=q.docRoute;if(!ve||q.mutates&&Wn()==="viewing")return!1;const Re=y(),Ue=vr(Re,ve);if(!Ue)return!1;if(q.inline){const{lockModesById:We}=wa(Re?.contentControls,ut.selection);if(Pi(We))return!1;const Le=Mu(ut.selection);if(!Le)return ut.selection.empty===!1?br(!1):br($f(q,oe));const Xe=Sa(q,Re,ut.selection),Ve=JV(q.inline,Le,oe,Xe);if(!Ve)return!1;let Ze=null;try{const Je=k(),rt=Wn(),tt=()=>k()!==Je||y()!==Re||Wn()!==rt?!1:Jf(ve,Ue,Ve),Rt=ga(ut.selection)??uc(ut.selection),Gt=q.inline.kind==="toggle"?vn(`${q.id}:${Rt}`,tt):null;Ze=Gt?.release??null;const en=Gt?Gt.result:tt(),Mn=Ra(q,ut.selection,Ve,en),Rr=br(co(q,ut.selection,Ve,en),Ar=>{Dl(q,Mn,Ar),Ze?.(),Ze=null});return q.inline.kind==="toggle"&&(L=Oi),Rr}catch{return Ze?.(),!1}}if(q.blockParagraph){const We=yb(q,Ue,oe),Le=q.blockParagraph.kind==="alignment"&&go(We)?ri(ut.selection,oe):null;return br(We,Xe=>{Wu(Le,Xe)})}if(q.list)return br(Im(q,Ue));if(q.link)return br(bb(oe));if(q.create)return br(Tm(q,Ue,oe));if(q.table)return br(Ec(q,Ue));try{return br(q.mutates?Xt(ve,Ue,oe):Ue(oe))}catch{return!1}},kr=()=>{m+=1,h={mode:"idle",snapshot:null,sourceSelectionKey:null,lastClickAt:h.lastClickAt,pointerSelecting:!1,keyboardSelecting:!1};for(const f of p)f("idle");Dt()},uo=async()=>{const f=["bold","italic","underline","strikethrough"].filter(Ue=>ut.toolbar.commands[Ue]?.active===!0),g=await L;await c;const w=go(g)?f:[],A=500,E=Date.now();if(h.mode!=="idle"){if(h.mode==="armed"&&E-h.lastClickAt<A){h={...h,mode:"persistent",lastClickAt:E};for(const Ue of p)Ue("persistent");return Dt(),!0}return kr(),!1}const B=E-h.lastClickAt<A,q=++m;h={...h,lastClickAt:E};const oe=await ba(),ve=`${uc(oe)}:${Pt()}`,Re=await wi(null,oe,ve&&ve===_?v:void 0,w);if(q!==m)return!0;h={...h,mode:B?"persistent":"armed",snapshot:Re,sourceSelectionKey:uc(oe),lastClickAt:E};for(const Ue of p)Ue(h.mode);return Dt(),!0},wi=async(f,g,w,A=[])=>{const E=g?.target??f?.target;if(!E||E.kind!=="text")return null;const B=Array.isArray(E.segments)?E.segments:[];if(B.length===0)return null;const q=y();if(!q)return null;const oe=E.story;let ve=null;for(const Ve of B){const Ze=(await wl(mo(Ve.blockId,oe)))?.node??null;if(!Ze)continue;const Je=Ds(Ze),rt=Qu(Array.isArray(Je?.inlines)?Je.inlines:[],Ve.range);ve?ve=MA(ve,rt):ve=rt}const Re=ve?tV(ve):{},Ue={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike"},We=new Set([...g?.activeMarks??(Array.isArray(f?.activeMarks)?f.activeMarks:[]),...A]);for(const[Ve,Ze]of Object.entries(Ue))We.has(Ve)&&(Re[Ze]=!0);const Le=w??await zu(g??pl(f,"ready"));if(Le.fontFamily&&(Re.fontFamily=Le.fontFamily),Le.color&&(Re.color=Le.color),Le.highlight&&(Re.highlight=Le.highlight),Le.fontSize){const Ve=Number.parseFloat(Le.fontSize);Number.isNaN(Ve)||(Re.fontSize=Ve)}let Xe=null;if(B.length===1){const Ve=B[0],Ze=(await wl(mo(Ve.blockId,oe)))?.node??null;Ze&&Ds(Ze)&&(Xe=await TH(Ze,Ve.blockId,q,oe))}return{story:oe??null,inline:Re,paragraph:Xe}},Ds=f=>f?f.kind==="paragraph"?f.paragraph??null:f.kind==="heading"?f.heading??null:null:null,Qu=(f,g)=>{const w=q=>{const oe=q.run;return typeof oe?.text=="string"?oe.text:""},A=q=>q.run?.props;if(g.start===g.end){let q=0;for(const oe of f){const ve=w(oe),Re=q,Ue=q+ve.length;if(q=Ue,g.start>=Re&&g.start<=Ue){const We=A(oe);return We?{...We}:{}}}return{}}let E=0;const B=[];for(const q of f){const oe=w(q),ve=E,Re=E+oe.length;if(E=Re,Re<=g.start||ve>=g.end)continue;const Ue=A(q);Ue&&B.push(Ue)}return B.length===0?{}:B.length===1?{...B[0]}:MA(B[0],...B.slice(1))},MA=(f,...g)=>{const w={...f};for(const A of g)for(const E of Object.keys(w)){if(!(E in A)){delete w[E];continue}const B=w[E],q=A[E];(typeof B!=typeof q||JSON.stringify(B)!==JSON.stringify(q))&&delete w[E]}return w},TH=async(f,g,w,A)=>{const E=Ds(f),B=E.props??{},q=E.styleRef??null,oe=B.alignment??null,ve=B.spacing??null,Re=B.indent??null,Ue=Re?{...Re.left!=null?{left:Re.left}:{},...Re.right!=null?{right:Re.right}:{},...Re.firstLine!=null?{firstLine:Re.firstLine}:{},...Re.hanging!=null?{hanging:Re.hanging}:{}}:null,We=B.markRunProps??null,Le=B.numbering?.numId,Xe=typeof Le=="string"?parseInt(Le,10):typeof Le=="number"?Le:NaN,Ve=B.numbering?.level,Ze=isNaN(Xe)?null:{numId:Xe,...Ve!=null?{level:Ve}:{}};let Je=null;if(Ze&&typeof w.lists?.getState=="function")try{const rt=await w.lists.getState({target:mo(g,A)});rt&&typeof w.lists?.getStyle=="function"&&(Je=await w.lists.getStyle(rt)??null)}catch{}return{styleId:q,alignment:oe,spacing:ve,indentation:Ue,markRunProps:We,numbering:Ze,listStyle:Je}},LA=async()=>{if(h.mode==="idle"||h.pointerSelecting||h.keyboardSelecting)return;const f=y()?.selection,g=async()=>vi(typeof f?.current=="function"?await Promise.resolve(f.current({includeText:!0})):es().value),w=()=>new Promise(q=>setTimeout(q,16)),A=8;let E=null,B="";for(let q=0;q<A;q+=1){if(q>0&&await w(),h.mode==="idle"||h.pointerSelecting||h.keyboardSelecting)return;if(E=await g(),!(!E||E.empty)&&(B=uc(E),B!==h.sourceSelectionKey))break}if(E&&!E.empty&&B!==h.sourceSelectionKey){await PA(E);return}if(h.snapshot?.paragraph){const q=await g();if(!q||uc(q)===h.sourceSelectionKey)return;await PA(q)}},PA=async f=>{const g=h.snapshot;if(!g){h.mode==="armed"&&kr();return}const w=y();if(!w)return;const A=pl(f,"ready"),{lockModesById:E}=wa(w.contentControls,A);if(Pi(E)){Dt();return}const B=f.target,q=f.selectionTarget;if(f.empty!==!0&&Object.keys(g.inline).length>0){const oe=vr(w,"format.apply");if(oe&&q)try{if(!go(As(await Promise.resolve(Jf("format.apply",oe,{target:q,inline:g.inline},f))))){Dt();return}}catch{Dt();return}}if(g.paragraph){const oe=Array.isArray(B?.segments)?B.segments:[],ve=B?.story;for(const Re of oe){const Ue=mo(Re.blockId,ve),We=await wl(Ue),Le=We?.node??null,Xe=We?.address??null;if(!Le)continue;const Ve={kind:"block",nodeType:Xe?.nodeType??Le.kind??"paragraph",nodeId:Re.blockId,...ve&&typeof ve=="object"?{story:ve}:{}},{styleId:Ze,alignment:Je,spacing:rt,indentation:tt,markRunProps:Rt,numbering:Gt,listStyle:en}=g.paragraph;if(Ze&&await w.styles?.paragraph?.setStyle?.({target:Ve,styleId:Ze}),Je&&await w.format?.paragraph?.setAlignment?.({target:Ve,alignment:Je}),rt){const Mn=rt,Rr=Mn.lineRule??"auto",Ar=new Set(["auto","exact","atLeast"]).has(Rr)?Rr:"auto",zr={...Mn.before!=null?{before:Math.round(Mn.before*20)}:{},...Mn.after!=null?{after:Math.round(Mn.after*20)}:{},...Mn.line!=null?{line:Math.round(Ar==="auto"?Mn.line*240:Mn.line*20),lineRule:Ar}:{}};await w.format?.paragraph?.setSpacing?.({target:Ve,...zr})}if(tt){const Mn={...tt.left!=null?{left:ks(tt.left)}:{},...tt.right!=null?{right:ks(tt.right)}:{},...tt.firstLine!=null?{firstLine:ks(tt.firstLine)}:{},...tt.hanging!=null?{hanging:ks(tt.hanging)}:{}};await w.format?.paragraph?.setIndentation?.({target:Ve,...Mn})}Rt&&await w.format?.paragraph?.setMarkRunProps?.({target:Ve,markRunProps:Rt}),Gt&&await w.format?.paragraph?.setNumbering?.({target:Ve,...Gt}),en&&((await wl(Ue))?.address?.nodeType==="listItem"?await w.lists?.applyStyle?.({target:bA(Re.blockId,ve),style:en}):Gt&&await w.format?.paragraph?.setNumbering?.({target:Ve,...Gt}))}}h.mode==="armed"&&kr(),Dt()},Rm=(f,g,w)=>{const A=bn(f,g),E=A?A.then(()=>(qn(f,g,w),Oi)):(qn(f,g,w),Oi);return Su(f)?.inline?.kind==="toggle"&&(L=E),E},DA=f=>({id:f,getState:()=>ut.toolbar.commands[f]??_l(f,y(),ut.selection,ni(ut.selection)),observe:g=>xa(w=>w.toolbar.commands[f]??{enabled:!1,active:!1,supported:!1,source:"unsupported",reason:lt.commandUnsupported}).subscribe(g),execute:g=>qn(f,g),executeAsync:g=>Rm(f,g)}),RH=f=>{fe.set(f.id,f),Dt();const g=()=>{fe.delete(f.id),Dt()};return Object.assign(g,{handle:DA(f.id),unregister:g})},Mm=ii(f=>f.selection),Lm=wo(Mm),OA=()=>{const f=T();if(typeof f?.getHandles!="function")return{reason:lt.hostCapabilityUnavailable};let g=null;try{g=f.getHandles()}catch(A){const E=A?.reason;return{reason:E==="host-not-ready"||E==="host-disposed"||E==="editing-mount-required"?lt.notReady:lt.hostCapabilityUnavailable}}const w=g?.editing?.selectionTargets;return typeof w?.apply!="function"?{reason:lt.hostCapabilityUnavailable}:{helper:w}},FA={get:Lm.get,getSnapshot:Lm.getSnapshot,subscribe:Lm.subscribe,observe:Lm.observe,current:()=>es().value,capture:()=>{const f=Mm.get();return f.empty||!f.target&&!f.selectionTarget?null:{...f,capturedAt:Date.now()}},restore:f=>{const g=E=>(Dt(),{...E,success:E.ok});if(!f||typeof f!="object")return g({ok:!1,reason:lt.targetUnresolved});if(!k())return g({ok:!1,reason:lt.notReady});const w=ZV(f);if(!w)return g({ok:!1,reason:lt.targetUnresolved});const A=OA();if(!("helper"in A))return g({ok:!1,reason:A.reason});try{return g(fA(A.helper.apply(w)))}catch{return g({ok:!1,reason:lt.hostCapabilityUnavailable})}},apply:f=>{if(!k())return{ok:!1,reason:lt.notReady};const g=OA();if(!("helper"in g))return{ok:!1,reason:g.reason};try{const w=g.helper.apply(f);return Dt(),fA(w)}catch{return{ok:!1,reason:lt.hostCapabilityUnavailable}}},getAnchorRect:f=>{const g=T();if(typeof g?.getSelectionAnchorRect=="function"){const w=Tt(()=>g.getSelectionAnchorRect(f),null);return w&&typeof w=="object"&&(Number(w.width)>0||Number(w.height)>0)?w:null}return null},getRects:f=>{const g=Mm.get(),w=g.selectionTarget??g.target;if(g.empty||!w)return[];const A=jm.getRect({target:w,relativeTo:f?.relativeTo});return A.found?A.rects:[]}},MH={get ids(){return Te()},has:f=>Su(f)!=null||fe.has(f),get:f=>DA(f),execute:qn,executeAsync:Rm,register:RH,getContextMenuItems:f=>{const g=[];for(const w of fe.values()){const A=w.contextMenu;A&&Tt(A.when?()=>A.when(f):void 0,!0)&&g.push({id:w.id,label:A.label,group:A.group,order:A.order,invoke:()=>qn(w.id,void 0,f)})}return g.sort((w,A)=>(w.order??0)-(A.order??0)||w.label.localeCompare(A.label))}},wb=wo(ii(f=>f.toolbar)),LH={get:wb.get,getSnapshot:()=>ut.toolbar,subscribe:wb.subscribe,observe:wb.observe,execute:qn,executeAsync:Rm},xc=async(f,g)=>{if(!k())return{success:!1,ok:!1,reason:lt.notReady};if(!f)return{success:!1,ok:!1,reason:lt.targetUnresolved};const w=T(),A=w?.scrollTargetIntoView;if(typeof A!="function")return{success:!1,ok:!1,reason:lt.hostCapabilityUnavailable};try{const E={target:f,block:g?.block??"center",behavior:g?.behavior??"smooth"},B=await Promise.resolve(g?.shouldContinue?A.call(w,E,g.shouldContinue):A.call(w,E));return B&&typeof B=="object"&&B.success===!1?{success:!1,ok:!1,reason:ib(B.reason,lt.targetUnresolved)}:{success:!0,ok:!0}}catch{return{success:!1,ok:!1,reason:lt.hostCapabilityUnavailable}}},Pm=async(f,g,w,A)=>{const E=f==="trackChanges"?A?.story:void 0,B=rt=>{if(!E||!rt||typeof rt!="object")return rt;const tt=rt,Rt=tt.address&&typeof tt.address=="object"?tt.address:null;return tt.story||Rt?.story?rt:{...tt,story:E}},q=f==="trackChanges"?_V:Bf,oe=w.find(rt=>Ki(rt,g,E)),ve=oe&&typeof oe=="object"?oe:null,Re=f==="trackChanges"&&ve?.type==="move"&&(ve.subtype==="move-to"||ve.subtype==="move-from")?ve.subtype:null,Ue=Re&&typeof ve?.trackedChangeCanonicalId=="string"?ve.trackedChangeCanonicalId:g,We=rt=>{if(!Re)return q(rt);const tt=Bf(rt);if(tt?.kind!=="move")return null;const Rt=Re==="move-to"?tt.destination:tt.source;return sb(Rt)?Rt:null},Le=q(oe),Xe=f!=="trackChanges"||!Re&&sb(Bf(oe));if(Le&&Xe)return B(Le);const Ve=y()?.[f],Ze=f==="comments"?{commentId:g}:{id:Ue,...E?{story:E}:{}},Je=Ve?.get;if(typeof Je!="function")return B(Le);try{return B(We(await Promise.resolve(Je.call(Ve,Ze)))??Le)}catch{return B(Le)}};function NA(f,g){if(ti())return lr("Comments are read-only.","DOCUMENT_READONLY");if(Ts())return lr("Resolving comments is disabled.","DOCUMENT_READONLY");const w=y()?.comments,A=w?.patch;if(typeof A!="function")return lr("comments.patch is unavailable.");const E=lr("comments.patch failed.");return Tt(()=>Ma(A.call(w,{commentId:f,status:g}),E),E)}const Dm=()=>ti()?lr("Comments are read-only.","DOCUMENT_READONLY"):null,BA=(f,g)=>{const w=g&&typeof g=="object"?g:null;let A=Array.from(f);w?.includeResolved===!1&&(A=A.filter(ve=>ve.status!=="resolved"));const E=Number(w?.offset),B=Number.isInteger(E)&&E>0?E:0,q=Number(w?.limit),oe=Number.isInteger(q)&&q>=0?B+q:void 0;return A.slice(B,oe)},Ju=ii(f=>f.comments),Om=wo(Ju),PH={get:Om.get,getSnapshot:Om.getSnapshot,subscribe:Om.subscribe,observe:Om.observe,list:f=>{const g=Ju.get();if(g.status!=="pending")return BA(g.items,f);const w=y()?.comments,A=Tt(w?.list?()=>w.list(f):void 0,null);return Tr(A)?[]:BA(Array.isArray(A?.items)?A.items:[],f)},getById:f=>{const g=Ju.get().items.find(E=>Gn(E)===f)??null;if(g)return g;const w=y()?.comments,A=Tt(w?.get?()=>w.get({commentId:f}):void 0,null);return Tr(A)?null:A},createFromCapture:(f,g)=>{const w=Dm();if(w)return w;const A=y()?.comments,E=A?.create;if(typeof E!="function")return lr("comments.create is unavailable.");const B=lr("comments.create failed.");return Tt(()=>Ma(E.call(A,{target:f.target??f.selectionTarget,text:g.text}),B),B)},createFromSelection:f=>{const g=Dm();if(g)return g;const w=y()?.comments,A=w?.create;if(typeof A!="function")return lr("comments.create is unavailable.");const E=Mm.get(),B=E.target??E.selectionTarget;if(E.empty||!B)return lr("A range selection is required to comment.","NO_SELECTION");const q=lr("comments.create failed.");return Tt(()=>Ma(A.call(w,{target:B,text:f.text}),q),q)},reply:(f,g)=>{const w=Dm();if(w)return w;const A=y()?.comments,E=A?.reply??A?.create;if(typeof E!="function")return lr("comments.reply is unavailable.");const B=lr("comments.reply failed.");return Tt(()=>Ma(E===A?.reply?E.call(A,{parentCommentId:f,text:g.text}):E.call(A,{parentCommentId:f,text:g.text}),B),B)},resolve:f=>NA(f,"resolved"),reopen:f=>NA(f,"active"),delete:f=>{const g=Dm();if(g)return g;const w=y()?.comments,A=w?.delete??w?.remove;if(typeof A!="function")return lr("comments.delete is unavailable.");const E=lr("comments.delete failed.");return Tt(()=>Ma(A.call(w,{commentId:f}),E),E)},setActive:f=>{if(f==null)return ye=null,Dt(),!0;if(!k())return!1;const g=Ju.get();if(g.listStatus!=="ready")return!1;const w=MV(g.items,f);return!w||!g.items.some(A=>Gn(A)===w)?!1:(ye=w,Dt(),!0)},scrollTo:async f=>{if(!y())return{success:!1,ok:!1,reason:k()?lt.documentApiUnavailable:lt.notReady};const g=await Pm("comments",f,Ju.get().items);return g?xc(g):{success:!1,ok:!1,reason:lt.targetUnresolved}}},La=ii(f=>f.trackChanges),Cb=(f,g)=>{const w=La.get().items.filter(We=>Gn(We)!==null);if(w.length===0)return null;const A=ut.trackChanges.activeId,E=le?.id===A?le.story:void 0,B=w.filter(We=>gm(We)==null),q=E||B.length===0?w:B;let oe=A?q.findIndex(We=>Ki(We,A,E)):-1;oe===-1&&A&&E&&(oe=q.findIndex(We=>Ki(We,A)));const ve=q[oe===-1?f>0?0:q.length-1:(oe+f+q.length)%q.length],Re=Gn(ve),Ue=gm(ve);return Ge(Ue?{id:Re,story:Ue}:{id:Re},g),Dt(),Re};let zA=Promise.resolve();const DH=f=>{const g=re;return zA.catch(()=>{}).then(()=>OH(f,g))},OH=async(f,g)=>{if(re!==g)return{success:!1};const w=le,A=Cb(f,{invalidateQueuedNavigation:!1});if(A==null)return{success:!1};const E=le,B=Se,q=()=>re===g&&le===E&&Se===B,oe=()=>{q()&&(Ge(w,{invalidateQueuedNavigation:!1}),Dt())};E&&$e.add(E);try{const ve=await Pm("trackChanges",A,La.get().items,E?.story?{story:E.story}:void 0);if(!q())return{success:!1};if(!ve)return oe(),{success:!1};Vo+=1;try{const Re=await xc(ve,{behavior:"auto",shouldContinue:q});return q()?(!Re.ok&&Re.reason!==lt.targetNotVisible?(oe(),Ee(w)):Ee(E),{success:Re.ok}):{success:!1}}finally{Vo=Math.max(0,Vo-1),Vo===0&&(q()?Rn&&Po(bi(Rn)):Ee(le))}}finally{E&&$e.delete(E)}},VA=f=>{const g=DH(f);return zA=g.then(()=>{},()=>{}),g},Fm=wo(La),FH={get:()=>(cr(),Fm.get()),getSnapshot:()=>(cr(),Fm.getSnapshot()),subscribe:f=>(cr(),Fm.subscribe(f)),observe:f=>(cr(),Fm.observe(f)),list:()=>(cr(),La.get().items),accept:f=>_b("accept",f),reject:f=>_b("reject",f),acceptAll:()=>nh("accept",{scope:"all"},null),rejectAll:()=>nh("reject",{scope:"all"},null),next:()=>Cb(1),previous:()=>Cb(-1),navigateNext:()=>VA(1),navigatePrevious:()=>VA(-1),getAt:f=>{if(!f||typeof f!="object"||typeof f.x!="number"||typeof f.y!="number")return null;const g=Ab(f);if(g.length===0)return null;const w=La.get().items;let A;for(const E of g){if(E.type!=="trackedChange")continue;let B;if(E.story){if(A===void 0&&(A=ts()),!A)continue;B=A}else B=w;const q=B.find(oe=>Ki(oe,E.id,E.story));if(q)return E.story?{id:q.id,item:q,story:E.story}:{id:q.id,item:q}}return null},setActive:f=>{if(f==null)return Ge(null),Ee(null),Dt(),!0;if(!k())return!1;const g=typeof f=="string"?{id:f}:{id:f.id,story:f.story};if(typeof g.id!="string"||g.id.length===0)return!1;const w=g.id;if(g.story){const A=ts();if(!A)return!1;const E=Eu(A,g.story).toPublicId(g.id)??g.id;if(!A.some(B=>Ki(B,E,g.story)))return!1;g.id=E}else{const A=La.get().items,E=pa(A).toPublicId(g.id)??g.id,B=A.find(q=>Gn(q)===E);if(!B)return!1;g.id=E,g.story=gm(B)}return w!==g.id&&(g.paintedEntityId=w),Ge(g),Ee(g),Dt(),!0},scrollTo:async f=>{if(!y())return{success:!1,ok:!1,reason:k()?lt.documentApiUnavailable:lt.notReady};re+=1,xe+=1;const g=xe,w=La.get().items,A=pa(w).toPublicId(f)??f,E=gm(w.find(oe=>Gn(oe)===A)),B=le,q={id:A,...E?{story:E}:{},...A!==f?{paintedEntityId:f}:{}};$e.add(q);try{const oe=await Pm("trackChanges",A,w,E?{story:E}:void 0);if(xe!==g)return{success:!1,ok:!1};if(!oe)return{success:!1,ok:!1,reason:lt.targetUnresolved};Ge(q);const ve=xe,Re=le,Ue=Se,We=()=>xe===ve&&le===Re&&Se===Ue,Le=()=>{We()&&(Ge(B,{invalidateQueuedNavigation:!1}),Dt())};Dt(),Vo+=1;try{const Xe=await xc(oe,{behavior:"auto",shouldContinue:We});return We()?(!Xe.ok&&Xe.reason!==lt.targetNotVisible?(Le(),Ee(B)):Ee(q),Xe):{success:!1,ok:!1}}finally{Vo=Math.max(0,Vo-1),Vo===0&&(We()?Rn&&Po(bi(Rn)):Ee(le))}}finally{$e.delete(q)}}},_b=(f,g)=>{const{id:w,story:A}=typeof g=="string"?{id:g,story:void 0}:g;return nh(f,{kind:"id",id:w,...A?{story:A}:{}},w,A)},nh=(f,g,w,A)=>{try{return br(Sb(f,g,w,A))}catch{return!1}},Sb=(f,g,w,A)=>{if(ti())return!1;const E=y()?.trackChanges,B=g.scope==="all",q=g.kind==="range",oe=g.kind==="ids";if(Cc({kind:f,scope:B?"all":"id"},E))return!1;const ve=B?`${f}All`:f,Re=!q&&!oe&&!A&&E&&typeof E[ve]=="function"?E[ve]:null,Ue=E&&typeof E.decide=="function"?E.decide:null;return!Re&&!Ue?!1:Re?Re.call(E,w??{}):Ue.call(E,{decision:f,target:g})},kb=ii(f=>f.contentControls),rh=f=>kb.get().items.find(g=>g?.id===f)??null,Nm=wo(kb),NH=(f=>{if(f===void 0)return Nm.get();const g=vm(f);return g?rh(g):null}),BH={get:(f=>(f!==void 0&&so("api"),NH(f))),getSnapshot:Nm.getSnapshot,subscribe:Nm.subscribe,observe:Nm.observe,list:()=>(so("api"),kb.get().items),getById:f=>(so("api"),rh(f)),getRect:f=>{const g=vm(f);if(!g)return fl("unresolved");so("panel");const w=rh(g);if(!w)return fl("unresolved");const A=ab(w);return A?jm.getRect({target:A}):fl("unavailable")},scrollIntoView:async f=>{const g=vm(f);if(!g)return{success:!1};so("panel");const w=rh(g);if(!w)return{success:!1};const A=ab(w);return A?{success:(await xc(A,{block:f.block,behavior:f.behavior})).ok}:{success:!1}},focus:async f=>{const g=vm(f);if(!g)return{success:!1,reason:"invalid-id"};if(!k())return{success:!1,reason:"not-ready"};so("panel");const w=rh(g);if(!w)return{success:!1,reason:"not-found"};const A=ab(w);if(!A)return{success:!1,reason:"not-reachable"};if(!(await xc(A,{block:f.block,behavior:f.behavior})).ok)return{success:!1,reason:"not-reachable"};const E=AV(A);if(!E)return{success:!1,reason:"not-reachable"};const B=FA.apply(E);return!B.ok&&B.reason!==lt.hostCapabilityUnavailable?{success:!1,reason:"not-reachable"}:{success:!0}}},Bm=wo(ii(f=>f.fonts)),zH={get:Bm.get,getSnapshot:Bm.getSnapshot,subscribe:Bm.subscribe,observe:Bm.observe,getFamilyOptions:()=>ut.fonts.options,getSizeOptions:()=>ut.fonts.sizeOptions},zm=wo(ii(f=>f.zoom)),VH={get:zm.get,getSnapshot:zm.getSnapshot,subscribe:zm.subscribe,observe:zm.observe,set:f=>{if(typeof t?.setZoom=="function")try{t.setZoom(f),Dt()}catch{}},setMode:f=>{if(typeof t?.setZoomMode=="function")try{t.setZoomMode(f),Dt()}catch{}}},Vm=wo(ii(f=>f.document)),HH={get:Vm.get,getSnapshot:Vm.getSnapshot,subscribe:Vm.subscribe,observe:Vm.observe,setMode:f=>{if(typeof t?.setDocumentMode=="function")try{t.setDocumentMode(f),Dt()}catch{}},export:f=>{if(typeof t?.export=="function")try{return Promise.resolve(t.export(f))}catch{return}},getText:()=>{const f=y(),g=Tt(f?.getText?()=>f.getText({}):void 0,null);return typeof g=="string"?g:g&&typeof g=="object"&&typeof g.text=="string"?g.text:null},replaceFile:f=>{const g=t?.replaceFile??t?.loadDocument??t?.reload;if(typeof g=="function")try{return Promise.resolve(g.call(t,f))}catch{return}}},HA=()=>{if(typeof HTMLElement>"u")return null;const f=k()?.mount?.container;if(f instanceof HTMLElement)return f;const g=t?.element;return g instanceof HTMLElement?g:null},jH=(f,g)=>{if(typeof f!="number"||typeof g!="number"||!Number.isFinite(f)||!Number.isFinite(g))return[];const w=globalThis.document;if(!w||typeof w.elementFromPoint!="function")return[];const A=HA();if(!A)return[];const E=w.elementFromPoint(f,g);if(!E||!A.contains(E))return[];const B=[E],q=tt=>{tt&&A.contains(tt)&&!B.includes(tt)&&B.push(tt)},oe=w.elementsFromPoint;if(typeof oe=="function"){let tt=[];try{tt=oe.call(w,f,g)??[]}catch{tt=[]}for(const Rt of tt)q(Rt)}const ve=[],Re=tt=>{tt&&A.contains(tt)&&!ve.includes(tt)&&!B.includes(tt)&&ve.push(tt)},Ue=tt=>{const Rt=tt.getBoundingClientRect;if(typeof Rt!="function")return!1;let Gt;try{Gt=Rt.call(tt)}catch{return!1}return Gt!=null&&f>=Gt.left&&f<=Gt.right&&g>=Gt.top&&g<=Gt.bottom};for(const tt of B){const Rt=tt.querySelectorAll;if(typeof Rt!="function")continue;let Gt;try{Gt=Rt.call(tt,"[data-track-change-marker]")}catch{continue}for(let en=0;en<Gt.length;en+=1)Ue(Gt[en])&&Re(Gt[en])}ve.reverse();const We=[...ve,...B],Le=uA(We[0],A);for(let tt=1;tt<We.length;tt+=1)for(const Rt of uA(We[tt],A))Le.push(Rt);if(Le.length===0)return Le;const Xe=La.get().items,Ve=pa(Xe);let Ze;const Je=new Set,rt=[];for(const tt of Le){if(tt.type!=="trackedChange"){const Mn=`${tt.type}:${tt.id}`;if(Je.has(Mn))continue;Je.add(Mn),rt.push(tt);continue}const Rt=kV(tt.storyKey)??SV(tt.story);let Gt;if(Rt){if(Ze===void 0&&(Ze=ts()),!Ze||(Gt=Eu(Ze,Rt).toPublicId(tt.id),!Gt||!Ze.some(Mn=>Ki(Mn,Gt,Rt))))continue}else if(Gt=Ve.toPublicId(tt.id),!Gt)continue;const en=`trackedChange:${Gt}`;Je.has(en)||(Je.add(en),rt.push(Rt?{type:"trackedChange",id:Gt,story:Rt}:{type:"trackedChange",id:Gt}))}return rt};function Ab(f,g){return typeof f=="object"?jH(f?.x,f?.y):null}const $u=new Set;let Ib=!1;const jA=f=>{const g=T();if(typeof g?.observeGeometry!="function")return;let w=!1;const A=Tt(()=>{const E=g.observeGeometry(()=>f.schedule());return w=!0,E},null);f.detach=typeof A=="function"?A:null,f.boundHost=w?g:null},Hm=f=>{if(f.detach){try{f.detach()}catch{}f.detach=null}f.boundHost=null},UA=()=>{if(Ib=!1,!(Z||T()))for(const f of $u)Hm(f)},UH=()=>{if(!Ib){if(Ib=!0,typeof queueMicrotask=="function"){queueMicrotask(UA);return}Promise.resolve().then(UA)}},GH=()=>{const f=T();if(!f){UH();return}for(const g of $u)g.boundHost&&g.boundHost===f||(Hm(g),jA(g),g.schedule())};Rl.push(GH);const jm={getRect:f=>{const g=T(),w=g?.getTargetRects;if(typeof w=="function"){const A=Tt(()=>w.call(g,{target:f.target}),null);return A&&typeof A=="object"?A.success===!0&&Array.isArray(A.rects)?YV(qV(A.rects.filter(E=>E!=null&&typeof E=="object")),f.relativeTo):fl(typeof A.reason=="string"?A.reason:"unresolved"):fl("unresolved")}return fl("unavailable")},observe:f=>{const g=[];let w=0;const A=typeof requestAnimationFrame=="function",E=()=>{if(!A){f();return}w||(w=requestAnimationFrame(()=>{w=0,f()}))},B=xa(oe=>({ready:oe.ready,selection:oe.selection,zoom:oe.zoom}));g.push(B.subscribe(()=>E()));const q={schedule:E,detach:null,boundHost:null};return jA(q),$u.add(q),()=>{$u.delete(q),Hm(q),w&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(w);for(const oe of g.splice(0))try{oe()}catch{}}},getHost:()=>HA(),entityAt:Ab,contextAt:f=>{const g=!!f&&typeof f.x=="number"&&typeof f.y=="number",w=g?f.x:0,A=g?f.y:0;return{point:{x:w,y:A},entities:g?Ab({x:w,y:A}):[],selection:ut.selection,position:null,insideSelection:!1}},scrollIntoView:async f=>{const g=f?.target;if(!g)return{success:!1};let w=null;if(g.kind==="entity"){const A=g.entityType==="comment"?"comments":"trackChanges",E=A==="comments"?Ju.get().items:La.get().items,B=g.entityType==="trackedChange"&&g.story?{story:g.story}:void 0;w=await Pm(A,g.entityId,E,B)}else{const A=g,E=g,B=Array.isArray(A.segments)&&A.segments.length>0?A.segments:E.blockId&&E.range?[{blockId:E.blockId,range:E.range}]:null;if(B){const q=g.story;w={kind:"text",segments:B,...q?{story:q}:{}}}}return w?{success:(await xc(w,{block:f.block??"center",behavior:f.behavior??"smooth"})).ok}:{success:!1}}},GA=f=>{const g=(f&&typeof f=="object"?f:null)?.target;return g&&typeof g=="object"?g:null},WA=f=>`metadata:resolve:${f}`,WH=f=>{const g=y()?.metadata;if(!g||typeof g.resolve!="function")return null;const{value:w}=ur(WA(f),Pt(),()=>g.resolve({id:f}),GA);return w},KH=async f=>{const g=y()?.metadata;if(!g||typeof g.resolve!="function")return null;try{const w=Pt(),A=await Promise.resolve(g.resolve({id:f}));if(w!==Pt())return null;const E=GA(A);return ee.set(WA(f),{token:w,value:E,hasSettled:!0,inflightToken:null}),E}catch{return null}},qH={getRect:f=>{const g=y()?.metadata;if(!g||typeof g.resolve!="function")return fl("unavailable");const w=WH(f.id);return w?jm.getRect({target:w}):fl("unresolved")},scrollIntoView:async f=>{const g=await KH(f.id);return g?{success:(await xc(g,{block:f.block,behavior:f.behavior})).ok}:{success:!1}}},YH={inTable:!1,tableNodeId:null,rowIndex:null,columnIndex:null,cellNodeId:null,rows:null,columns:null},XH={getContext:()=>{const f=Fe();if(!f)return{...YH};const g=pe()?.table;return{inTable:!0,tableNodeId:f.tableNodeId,rowIndex:f.rowIndex,columnIndex:f.columnIndex,cellNodeId:f.cellNodeId,rows:typeof g?.rows=="number"?g.rows:null,columns:typeof g?.columns=="number"?g.columns:null}},isInTable:()=>Fe()!=null},Um={query:"",total:0,activeIndex:-1,open:!1,available:!1,caseSensitive:!1,includeDeletedText:!1,regex:!1,canReplace:!1,reason:lt.searchUnavailable};let On={...Um};const Gm=new Set,Pa=()=>{const f=T()?.search;return f&&typeof f=="object"?f:null},Os=()=>{const f=x()?.search;return f&&typeof f=="object"?f:null},oh=()=>{const f=Pa();if(f&&typeof f.setSession=="function")return!0;const g=Os();return!!g&&typeof g.query=="function"&&typeof g.getState=="function"},ss=()=>{for(const f of[...Gm])try{f(On)}catch{}},ai=f=>(On={...On,...f},ss(),On);let Zr=0,Tc=null;const KA=()=>{const f=Tc;Tc=null,f&&Tt(()=>(f(),null),null)},ZH=()=>{Zr+=1,KA();const f=oh();On={...Um,available:f,reason:f?void 0:lt.searchUnavailable},ss()};Ia.push(ZH);const QH=f=>{if(!f)return!1;const g=f.queryError;if(g&&typeof g=="object"&&g.code==="invalid-pattern")return!0;const w=f.rejection;return f.status==="rejected"&&!!w&&typeof w=="object"&&w.code==="invalid-pattern"},Eb=(f,g=!1)=>{const w=f&&typeof f=="object"?f:null;if(!w)return null;const A=Array.isArray(w.matches)?w.matches:[],E=typeof w.total=="number"&&Number.isFinite(w.total)?w.total:A.length,B=typeof w.activeMatchIndex=="number"?w.activeMatchIndex:typeof w.activeIndex=="number"?w.activeIndex:-1;return{...typeof w.query=="string"?{query:w.query}:{},total:E,activeIndex:B,canReplace:w.canReplace===!0||g,...w.includeDeletedText===!0?{includeDeletedText:!0}:{},...w.regex===!0?{regex:!0}:{},...QH(w)?{invalidPattern:!0}:{}}},So=()=>{const f=z("find.replace"),g=z("find.replaceAll");return f?.enabled===!0||g?.enabled===!0},ko=(f,g=!1)=>{const w=Eb(f,g);if(!w){ai({total:0,activeIndex:-1,canReplace:!1,reason:void 0});return}ai({...w.query!==void 0?{query:w.query}:{},total:w.total,activeIndex:w.activeIndex,canReplace:w.canReplace,...w.includeDeletedText!==void 0?{includeDeletedText:w.includeDeletedText}:{},...w.regex!==void 0?{regex:w.regex}:{},reason:w.invalidPattern?lt.searchInvalidPattern:void 0})},Da=()=>{const f=Pa();if(f&&typeof f.getState!="function")return On={...On,available:oh(),reason:oh()?void 0:lt.searchUnavailable},On;if(!f){const w=Os();if(w&&typeof w.getState=="function"){const A=Eb(Tt(()=>w.getState(),null),So());if(A)return On={...On,...A.query!==void 0?{query:A.query}:{},total:A.total,activeIndex:A.activeIndex,canReplace:A.canReplace,available:!0,reason:A.invalidPattern?lt.searchInvalidPattern:void 0,open:On.open||!!A.query},On}return On={...Um,query:On.query,caseSensitive:On.caseSensitive,includeDeletedText:On.includeDeletedText},On}const g=Eb(Tt(()=>f.getState(),null));return g&&(On={...On,...g.query!==void 0?{query:g.query}:{},total:g.total,activeIndex:g.activeIndex,canReplace:g.canReplace,...g.includeDeletedText!==void 0?{includeDeletedText:g.includeDeletedText}:{},...g.regex!==void 0?{regex:g.regex}:{},available:!0,reason:g.invalidPattern?lt.searchInvalidPattern:void 0,open:On.open||!!g.query}),On},ed=f=>{const g=f&&typeof f=="object"?f:null;if(g?.status==="committed")return{ok:!0};if(g?.status==="rejected"&&g.reason==="read-only")return{ok:!1,reason:lt.documentReadonly};const w=g?.rejection;return g?.status==="rejected"&&w&&typeof w=="object"&&w.code==="read-only-document"?{ok:!1,reason:lt.documentReadonly}:{ok:!1,reason:lt.operationUnavailable}},Wm=wo({get:()=>Da(),subscribe:f=>(Gm.add(f),()=>Gm.delete(f))}),JH={get:Wm.get,getSnapshot:Wm.getSnapshot,subscribe:Wm.subscribe,observe:Wm.observe,open:()=>oh()?(ai({available:!0,open:!0,reason:void 0}),{ok:!0}):(ai({available:!1,open:!1,reason:lt.searchUnavailable}),{ok:!1,reason:lt.searchUnavailable}),close:()=>{if(Zr+=1,Tc)KA();else{const f=Pa();if(f&&typeof f.clear=="function")Tt(()=>f.clear(),null);else{const g=Os();g&&typeof g.query=="function"&&Tt(()=>g.query({query:""}),null)}}On={...Um,available:oh(),reason:void 0},On.available||(On.reason=lt.searchUnavailable),ss()},search:(f,g)=>{const w=Pa(),A=!!g?.caseSensitive,E=g?.includeDeletedText===!0,B=g?.regex===!0,q=++Zr;if(!w||typeof w.setSession!="function"){const oe=Os();if(oe&&typeof oe.query=="function"&&typeof oe.getState=="function"){ai({query:f,caseSensitive:A,includeDeletedText:E,regex:B,available:!0,open:!0,reason:void 0}),Tc=()=>{oe.query({query:""})};const ve=Tt(()=>oe.query({query:f,caseSensitive:A,includeDeletedText:E,regex:B}),null);return Tr(ve)?Promise.resolve(ve).then(Re=>{q===Zr&&ko(Re,So())},()=>{q===Zr&&ai({available:!1,reason:lt.searchUnavailable})}):ko(ve,So()),ko(Tt(()=>oe.getState(),null),So()),On}return ai({query:f,total:0,activeIndex:-1,available:!1,caseSensitive:A,includeDeletedText:E,regex:B,reason:lt.searchUnavailable})}if(ai({query:f,caseSensitive:A,includeDeletedText:E,regex:B,available:!0,open:!0,reason:void 0}),Tc=()=>{typeof w.clear=="function"&&w.clear()},ko(Tt(()=>w.setSession(f,{caseSensitive:A,includeDeletedText:E,...B?{regex:!0}:{},highlight:!0}),null)),f.length>0&&On.total===0&&On.reason!==lt.searchInvalidPattern){const oe=Os();if(oe&&typeof oe.query=="function"&&typeof oe.getState=="function"){const ve=Tc;Tc=()=>{ve?.(),oe.query({query:""})};const Re=Tt(()=>oe.query({query:f,caseSensitive:A,includeDeletedText:E,regex:B}),null);Tr(Re)?Promise.resolve(Re).then(Ue=>{q===Zr&&ko(Ue,So())},()=>{q===Zr&&ai({available:!1,reason:lt.searchUnavailable})}):ko(Re,So()),ko(Tt(()=>oe.getState(),null),So())}}return On},next:()=>{const f=Pa();if(!f||typeof f.next!="function"){const g=Os();if(!g||typeof g.next!="function"||typeof g.getState!="function")return{ok:!1,reason:lt.searchUnavailable};if(On.total===0)return{ok:!1,reason:lt.operationUnavailable};const w=Tt(()=>g.next(),null);if(Tr(w)){const A=Zr;Promise.resolve(w).then(E=>{A===Zr&&ko(E,So())}).catch(()=>{A===Zr&&ai({available:!1,reason:lt.searchUnavailable})})}else ko(w,So());return ko(Tt(()=>g.getState(),null),So()),{ok:!0}}return On.total===0?{ok:!1,reason:lt.operationUnavailable}:(ko(Tt(()=>f.next(),null)),{ok:!0})},previous:()=>{const f=Pa();if(!f||typeof f.previous!="function"){const g=Os();if(!g||typeof g.previous!="function"||typeof g.getState!="function")return{ok:!1,reason:lt.searchUnavailable};if(On.total===0)return{ok:!1,reason:lt.operationUnavailable};const w=Tt(()=>g.previous(),null);if(Tr(w)){const A=Zr;Promise.resolve(w).then(E=>{A===Zr&&ko(E,So())}).catch(()=>{A===Zr&&ai({available:!1,reason:lt.searchUnavailable})})}else ko(w,So());return ko(Tt(()=>g.getState(),null),So()),{ok:!0}}return On.total===0?{ok:!1,reason:lt.operationUnavailable}:(ko(Tt(()=>f.previous(),null)),{ok:!0})},clear:()=>{Zr+=1;const f=Pa();if(f&&typeof f.clear=="function"&&Tt(()=>f.clear(),null),!f||typeof f.clear!="function"){const g=Os();g&&typeof g.query=="function"&&Tt(()=>g.query({query:""}),null)}ai({query:"",total:0,activeIndex:-1,canReplace:!1})},replace:f=>{const g=Pa();if(!g){const A=Os();if(!A||typeof A.replace!="function"||typeof A.getState!="function")return{ok:!1,reason:lt.searchUnavailable};if(!So())return{ok:!1,reason:lt.operationUnavailable};const E=Tt(()=>A.replace({replacement:typeof f=="string"?f:""}),null);if(Tr(E)){const B=Zr;Da(),ss();const q=()=>B===Zr;return Promise.resolve(E).then(oe=>(q()&&(ko(oe,So()),Da(),ss()),ed(oe)),()=>(q()&&ai({available:!1,reason:lt.searchUnavailable}),{ok:!1,reason:lt.searchUnavailable}))}return Da(),ss(),ed(E)}if(typeof g.replaceCurrent!="function")return{ok:!1,reason:lt.operationUnavailable};const w=Tt(()=>g.replaceCurrent(typeof f=="string"?f:""),null);return Da(),ss(),ed(w)},replaceAll:f=>{const g=Pa();if(!g){const A=Os();if(!A||typeof A.replaceAll!="function"||typeof A.getState!="function")return{ok:!1,reason:lt.searchUnavailable};if(!So())return{ok:!1,reason:lt.operationUnavailable};const E=Tt(()=>A.replaceAll({replacement:typeof f=="string"?f:""}),null);if(Tr(E)){const B=Zr;Da(),ss();const q=()=>B===Zr;return Promise.resolve(E).then(oe=>(q()&&(ko(oe,So()),Da(),ss()),ed(oe)),()=>(q()&&ai({available:!1,reason:lt.searchUnavailable}),{ok:!1,reason:lt.searchUnavailable}))}return Da(),ss(),ed(E)}if(typeof g.replaceAll!="function")return{ok:!1,reason:lt.operationUnavailable};const w=Tt(()=>g.replaceAll(typeof f=="string"?f:""),null);return Da(),ss(),ed(w)}},qA=ii(f=>f.styles),Km=wo(qA),$H={get:Km.get,getSnapshot:Km.getSnapshot,subscribe:Km.subscribe,observe:Km.observe,getCatalog:f=>Qe(f).value,getQuickGallery:()=>qA.get().quickGallery,getActiveParagraphStyle:()=>nt(ut.selection,ct().cache).style},YA={select:xa,get state(){return ut},selection:FA,commands:MH,toolbar:LH,comments:PH,trackChanges:FH,contentControls:BH,fonts:zH,zoom:VH,document:HH,viewport:jm,metadata:qH,tables:XH,search:JH,styles:$H,formatPainter:{setPointerSelecting(f){Z||(h={...h,pointerSelecting:f})},notifyPointerUp(){Z||(h={...h,pointerSelecting:!1},LA())},setKeyboardSelecting(f){Z||(h={...h,keyboardSelecting:f})},notifyKeyUp(){Z||(h={...h,keyboardSelecting:!1},LA())},cancel(){Z||kr()},onModeChange(f){return Z?()=>{}:(p.add(f),()=>p.delete(f))}},createScope:()=>{const f=[];return{select:(g,w)=>{const A=xa(g,w);return{get:A.get,subscribe:E=>{const B=A.subscribe(E);return f.push(B),B}}},dispose:()=>{for(const g of f.splice(0))g()}}},destroy:()=>{if(!Z){Z=!0,hn.reset(),Ye(),K&&(clearTimeout(K),K=null),te&&(clearTimeout(te),te=null,Y=0),H?.timer&&(clearTimeout(H.timer),H.timer=null),H=null,me&&(clearTimeout(me),me=null),_e&&(clearTimeout(_e),_e=null),ot&&ot(),ot=null,vt=null,$t.clear(),D.clear();for(const f of Ll.splice(0))f();Cn&&Cn(),Cn=null,Ut=null,Kn&&Kn(),Kn=null,Sr=null,at&&at(),at=null,Rn=null,An&&An(),An=null,pn=null,oi&&oi(),oi=null,Ur=null;for(const f of $u)Hm(f);$u.clear(),qe.clear(),Gm.clear(),m+=1,p.clear(),Zr+=1,fe.clear()}}};return S=YA,YA}var nH=[{value:"Arial",label:"Arial",previewFamily:"Arial, sans-serif"},{value:"Calibri",label:"Calibri",previewFamily:"Calibri, sans-serif"},{value:"Courier New",label:"Courier New",previewFamily:'"Courier New", monospace'},{value:"Georgia",label:"Georgia",previewFamily:"Georgia, serif"},{value:"Times New Roman",label:"Times New Roman",previewFamily:'"Times New Roman", serif'},{value:"Verdana",label:"Verdana",previewFamily:"Verdana, sans-serif"}];function rH(e){const t=e.trim(),n=t[0];if(n==='"'||n==="'"){const o=t.indexOf(n,1);if(o>0)return t.slice(1,o).trim()}const r=t.indexOf(",");return(r===-1?t:t.slice(0,r)).trim().replace(/^["']|["']$/g,"")}function oH(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n,o=typeof r.logicalFamily=="string"?rH(r.logicalFamily):"";if(!o)continue;const i=typeof r.previewFamily=="string"&&r.previewFamily.trim()?r.previewFamily.trim():o;t.push({value:o,label:o,previewFamily:i})}return t}function iH(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n,o=typeof r.value=="string"?r.value.trim():"";if(!o)continue;const i=typeof r.label=="string"&&r.label.trim()?r.label.trim():o,s=typeof r.previewFamily=="string"&&r.previewFamily.trim()?r.previewFamily.trim():o;t.push({value:o,label:i,previewFamily:s})}return t}function sH(e,t=[]){const n=[],r=new Set,o=s=>{const a=String(s.value).trim().toLowerCase();!a||r.has(a)||(r.add(a),n.push(s))};for(const s of e)o(s);const i=t.length?t:nH;for(const s of i)o(s);return n}var aH=[{value:"8",label:"8"},{value:"9",label:"9"},{value:"10",label:"10"},{value:"11",label:"11"},{value:"12",label:"12"},{value:"14",label:"14"},{value:"16",label:"16"},{value:"18",label:"18"},{value:"24",label:"24"},{value:"36",label:"36"}];function lH(e,t){return e.activeMark?t.activeMarks.includes(e.activeMark):!1}xt();var cH=Object.freeze(["#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F","#BB8FCE","#85C1E2","#F1948A","#82E0AA","#F8C471","#AED6F1","#D7BDE2","#A3E4D7","#F0B27A","#AEB6BF","#E74C3C","#2ECC71","#3498DB","#E67E22","#1ABC9C","#9B59B6","#34495E","#F39C12"]);async function uH(e,t){const n=new m6.default;return e.forEach((r,o)=>{n.file(t[o],r)}),n.generateAsync({type:"blob",compression:"DEFLATE"})}function mb(e){return!!(e&&(e.synced===!0||e.isSynced===!0))}function IA(e){try{e.synced=!0}catch{}try{e.isSynced=!0}catch{}}function dH(e,t){if(!e)return()=>{};if(mb(e))return t(),()=>{};const n=typeof e.on=="function"?e.on.bind(e):null,r=typeof e.off=="function"?e.off.bind(e):null;if(!n)return t(),()=>{};let o=!1;const i=()=>{o||(o=!0,r?.("synced",a),r?.("sync",l))},s=()=>{o||(i(),t())},a=()=>{IA(e),s()},l=u=>{u!==!1&&(u===!0||mb(e))&&(IA(e),s())};return n("synced",a),n("sync",l),mb(e)&&s(),i}function Zo(e){return!!(e&&typeof e=="object"&&e.editorVersion===2)}function fH(e){const t=e&&typeof e=="object"?e.code:null;return t==="comment-export-missing-story-reference"||t==="v2-worker-comment-export-mode-unsupported"}function EA(e){return typeof e=="string"&&e.length>0?e:null}function gb(e){return e?Zo(e)?EA(e.documentId??e.options?.documentId??null):EA(typeof e.getDocumentId=="function"?e.getDocumentId():e.options?.documentId):null}function hH(e){if(!e||Zo(e))return null;const t=e;return t.documentRenderer??t.presentationEditor??null}function Xi(e){if(!e)return null;if(Zo(e))return e.fonts??null;const t=hH(e);return t?{getReport:()=>t.getFontReport?.()??[],getMissingFonts:()=>t.getMissingFonts?.()??[],getDocumentFonts:()=>[...new Set((t.getFontReport?.()??[]).map(n=>n.logicalFamily))],getDocumentFontOptions:()=>t.getDocumentFontOptions?.()??[],getFontFamilyOptions:()=>t.getFontFamilyOptions?.()??[],getLastFontsChangedPayload:()=>t.getLastFontsChangedPayload?.()??null,map:n=>t.mapFonts(n),unmap:n=>t.unmapFonts(n),add:n=>t.addFonts(Array.isArray(n)?n:[n]),preload:n=>t.preloadFonts(n)}:null}var Cm=class extends Ym.default{static{this.allowedTypes=[Or,Ql,ep]}#t=!1;#n=!1;#e=null;#i=null;#s=null;#a=null;#u=null;#d=null;#l=z4({});get uiConfig(){return this.#l}#f=V4({});get interactionConfig(){return this.#f}#m=j4({});get surfacesConfig(){return this.#m}#o;#r=new cN;#p=null;#y=!1;constructor(e){if(super(),this.version="0.0.0",this.users=[],this.whiteboard=null,this.colors=[],this.readyEditors=0,this.pendingCollaborationSaves=0,this.config={selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",document:{},documents:[],editorExtensions:[],colors:[],users:[],user:{...Y0},layoutEngineOptions:{},modules:{},licenseKey:void 0,telemetry:{enabled:!0},title:"SuperDoc",conversations:[],isInternal:!1,comments:{visible:!1},toolbarGroups:["left","center","right"],toolbarIcons:{},toolbarTexts:{},uiDisplayFallbackFont:"Arial, Helvetica, sans-serif",isDev:!1,disablePiniaDevtools:!1,onEditorBeforeCreate:()=>null,onEditorCreate:()=>null,onEditorDestroy:()=>null,onSourceComplete:()=>null,onSourceSignalsComplete:()=>null,onContentError:()=>null,onReady:()=>null,onCommentsUpdate:()=>null,onContentControlActiveChange:()=>null,onContentControlClick:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onPaginationUpdate:()=>null,onTransaction:()=>null,disableContextMenu:!1,viewOptions:{layout:"print"},useLayoutEngine:!0},!e.selector)throw new Error("SuperDoc: selector is required");const t=typeof e.selector=="string"?document.querySelector(e.selector):e.selector;if(!(t instanceof HTMLElement))throw new Error("SuperDoc: selector must be a valid CSS selector string or DOM element");this.#o=new QF({getModuleConfig:()=>this.#m}),this.#w(e,t)}async#w(e,t){this.config={...this.config,...e},!this.config.comments||typeof this.config.comments!="object"?this.config.comments={visible:!1}:typeof this.config.comments.visible!="boolean"&&(this.config.comments.visible=!1),oN(this.config),this.config.documents=this.config.documents||[],this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};const n=this.config.viewOptions?.layout==="web",r=this.config.layoutEngineOptions?.flowMode==="semantic";if(n&&this.config.useLayoutEngine&&!r&&(console.warn("[SuperDoc] Web layout uses PM fallback unless layoutEngineOptions.flowMode is set to 'semantic'. Automatically disabling layout engine."),this.config.useLayoutEngine=!1),!n&&r&&(console.warn("[SuperDoc] flowMode 'semantic' is only valid with web layout. Coercing to 'paginated'."),this.config.layoutEngineOptions.flowMode="paginated"),this.editorVersion=2,this.#ve(),this.config.user=iN(this.config.user),this.config.layoutEngineOptions.virtualization||(this.config.layoutEngineOptions.virtualization={enabled:!0,window:5,overscan:1}),this.config.modules=this.config.modules||{},Object.prototype.hasOwnProperty.call(this.config.modules,"comments")||(this.config.modules.comments={}),this.config.modules.comments=L_(this.config.modules.comments),this.#l=z4(this.config),this.#f=V4(this.config),this.#m=j4(this.config),this.config.disableContextMenu=!this.#l.contextMenu.enabled,this.config.rulers=this.#l.ruler.enabled,this.#l.comments.enabled?this.config.modules.comments===!1&&(this.config.modules.comments={}):this.config.modules.comments=!1,this.#l.comments.enabled){this.config.modules.comments===!0&&(this.config.modules.comments={});const i=this.config.modules.comments;i&&Object.assign(i,this.#f.comments)}if(this.config.colors=S6(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="2.4.0-next.2",this.#b("π¦ [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||as(),this.colors=this.config.colors??[],this.#x(),await x8(),this.#t)return;if(await this.#T(this.config.modules),this.#t){this.#le();return}this.config.cspNonce&&this.#E(),this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.#p||(this.#p=this.#r.subscribe(i=>{this.#be(i.nextRuntimeId,i.legacyEditorProjection)})),this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null;const o=document.createElement("div");o.style.display="contents",t.appendChild(o),this.#u=o,this.#L(),this.#S(),this.#we(),this.#_()}#_(){if(this.#M(),this.readyEditors=0,!this.app)throw new Error("SuperDoc: #startRuntime called before #initVueApp populated this.app");this.app.mount(this.#u)}#S(){const e=this.config.modules?.whiteboard,t=e!==!1&&(e?.enabled??!1);this.whiteboard=new kD({Renderer:YF,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#h("requiredNumberOfEditors").documents.filter(e=>e.type===Or).length}get ui(){return this.#d||(this.#d=tH({superdoc:this}),this.#t&&this.#d.destroy()),this.#d}get state(){return{documents:this.#h("state").documents,users:this.users}}getDocumentRuntimeForDocument(e){return typeof e!="string"||e.length===0?null:(this.superdocStore?.documents??[]).find(t=>t?.getEditor?.()?.options?.documentId===e)?.getDocumentRuntime?.()??null}getComment(e){return typeof e!="string"||e.length===0?null:this.commentsStore?.getComment?.(e)??null}get element(){return typeof this.config.selector=="string"?document.querySelector(this.config.selector):this.config.selector}#E(){const e=this.config.cspNonce,t=document.createElement;document.createElement=function(n){const r=t.call(this,n);return n.toLowerCase()==="style"&&r.setAttribute("nonce",e),r}}#x(){const e=this.config.document,t=!!e&&typeof e=="object"&&Object.keys(e)?.length,n=!!e&&typeof e=="string"&&e.length>0,r=!!e&&typeof File=="function"&&e instanceof File,o=!!e&&e instanceof Blob&&!(e instanceof File),i=this.config.documents&&this.config.documents?.length;if(t&&i&&console.warn("π¦ [superdoc] You can only provide one of document or documents"),t){const s=Yd(this.config.document);this.config.documents=[{id:as(),...s}]}else if(n)this.config.documents=[{id:as(),type:Or,url:this.config.document,name:"document.docx"}];else if(r){const s=Yd(this.config.document);this.config.documents=[{id:as(),...s}]}else if(o){const s=Yd(this.config.document);this.config.documents=[{id:as(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=Yd(s);if(!a||typeof a!="object")return a;const l=typeof a=="object"&&"id"in a&&a.id||s&&typeof s=="object"&&"id"in s&&s.id;return{...a,id:l||as()}}))}#M(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=fD({disablePiniaDevtools:!!this.config.disablePiniaDevtools});this.app=e,this.pinia=t,this.app.config.globalProperties.$config=this.config,this.app.config.globalProperties.$documentMode=this.config.documentMode,this.app.config.globalProperties.$superdoc=this,this.app.provide("surfaceManager",this.#o),this.superdocStore=n,this.commentsStore=r,this.highContrastModeStore=o,typeof this.superdocStore.setExceptionHandler=="function"&&this.superdocStore.setExceptionHandler(s=>this.emit("exception",s)),this.superdocStore.init(this.config);const i=this.config.modules.comments;this.commentsStore.init(i||{}),this.isCollaborative&&h8(this),this.#ae()}#c(e,t){t&&this.on(e,t)}#L(){this.#c("editorBeforeCreate",this.config.onEditorBeforeCreate),this.#c("editorCreate",this.config.onEditorCreate),this.#c("editorDestroy",this.config.onEditorDestroy),this.#c("source:complete",this.config.onSourceComplete),this.#c("source:signals-complete",this.config.onSourceSignalsComplete),this.#c("ready",this.config.onReady),this.#c("comments-update",this.config.onCommentsUpdate),this.#c("content-control:active-change",this.config.onContentControlActiveChange),this.#c("content-control:click",this.config.onContentControlClick),this.#c("awareness-update",this.config.onAwarenessUpdate),this.#c("locked",this.config.onLocked),this.#c("pdf:document-ready",this.config.onPdfDocumentReady),this.#c("sidebar-toggle",this.config.onSidebarToggle),this.#c("collaboration-ready",this.config.onCollaborationReady),this.on("collaboration-ready",e=>this.#U(e?.editor??null)),this.#c("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.#c("exception",this.config.onException),this.#c("list-definitions-change",this.config.onListDefinitionsChange),this.#c("pagination-update",this.config.onPaginationUpdate),this.#c("fonts-resolved",this.config.onFontsResolved),this.#c("fonts-changed",this.config.onFontsChanged),this.#c("zoomChange",this.config.onZoomChange),this.#c("viewport-change",this.config.onViewportChange)}async#T({collaboration:e}={}){return e?(this.isCollaborative=!1,this.config.documents.length===0&&(this.config.documents=[{id:as(),type:Or,name:"document.docx"}]),this.config.v2CollaborationPreflightFailure={code:"collaboration-v1-config-unsupported",message:"SuperDoc v2 cannot use modules.collaboration because it is the SuperDoc v1 collaboration API. SuperDoc did not attach the provider or change the document. Configure Document.v2Collaboration with a v2 room instead."},this.config.documents):this.config.documents}#P(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=Wr(e),this.provider=Wr(t),this.#W();const n=this.config;this._cleanupAwareness=l8(t,this,n.user),n.documents.forEach(r=>{r.ydoc=e,r.provider=t,r.role=this.config.role})}#k(){this.#a=null,this.#g(),typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null),this.isCollaborative=!1,this._commentsCollabInitialized=!1,this.ydoc=void 0,this.provider=void 0;const e=this.config;delete e.modules.collaboration,e.documents.forEach(t=>{delete t.ydoc,delete t.provider})}#g(){if(this.#i){try{this.#i()}catch{}this.#i=null}if(this.#s){try{this.#s()}catch{}this.#s=null}}#U(e){this.#g(),Zo(e)&&(this.#G(e),this.#D(e))}#G(e){const t=e.presence;if(!t||typeof t.subscribe!="function")return;const n=wD(()=>this.user),r=o=>{if(this.#t)return;const i=n.next(o);this.emit("awareness-update",{...i,superdoc:this})};try{const o=t.getSnapshot?.();o&&r(o),this.#i=t.subscribe(r)}catch(o){console.warn("[SuperDoc] v2 awareness bridge failed to subscribe",o)}}#D(e){const t=e.lock;if(!t||typeof t.subscribe!="function")return;const n=r=>{this.#t||this.#C(!!r.isLocked,this.#O(r.lockedBy??null))};try{if(this.#a&&typeof t.setLocked=="function"){const o=this.#a;t.setLocked(o.isLocked,o.isLocked?o.lockedBy:null),this.#a=null}const r=t.getSnapshot?.();r&&n(r),this.#s=t.subscribe(n)}catch(r){console.warn("[SuperDoc] v2 lock bridge failed to subscribe",r)}}#O(e){return!e||typeof e!="object"||Array.isArray(e)?null:{...e}}#F(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}#C(e,t){this.isLocked===e&&this.#F(this.lockedBy,t)||(this.isLocked=e,this.lockedBy=t,this.#b("π¦ [superdoc] Locking superdoc:",e,t,`
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
`),this.emit("locked",{isLocked:e,lockedBy:t}))}#W(){const e=this.config.user;if(!e||e.color)return;const t=this.colors.length>0?this.colors:cH,n=e.id||e.email||e.name||"";let r=5381;for(let o=0;o<n.length;o++)r=(r<<5)+r^n.charCodeAt(o);e.color=t[Math.abs(r)%t.length]}async upgradeToCollaboration(e){const{target:t,mountedDocumentId:n}=this.#he(e);this.#n=!0;try{const r=await this.#de(),o=this.#v(),i=this.#K();this.#N();let s=null;try{this.#a=i,s=this.#fe(n);const a=this.#ce(t,r);await s,this.#ue(a,t),this.#a=null}catch(a){if(s&&this.#e){const l=this.#e;this.#e=null,l(),await s.catch(()=>{})}throw this.#A(o),a}}finally{this.#e=null,this.#n=!1}}#K(){return{isLocked:this.isLocked,lockedBy:this.lockedBy?{...this.lockedBy}:null}}#v(){const e=this.config.documents.find(r=>r.type===Or),t=this.superdocStore?.documents.find(r=>r.id===e.id)??null,n=t?mn(t):null;return{isCollaborative:this.isCollaborative,configV2Collaboration:e.v2Collaboration??null,configData:e.data,storeDoc:t,storeV2Collaboration:this.#X(n),storeData:t?.data}}#A(e){this.#a=null;const t=this.config.documents.find(n=>n.type===Or);t.v2Collaboration=e.configV2Collaboration,t.data=e.configData,this.isCollaborative=e.isCollaborative,e.storeDoc&&(e.storeDoc.data=e.storeData,this.#I(e.storeDoc,e.storeV2Collaboration),this.#B(e.storeDoc))}#N(){if(this.#t)throw new Error("SuperDoc: instance was destroyed during upgrade")}#h(e){if(!this.superdocStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`);return this.superdocStore}#q(e){if(!this.commentsStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`);return this.commentsStore}#R(e){if(!this.superdocStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`)}#Y(e,t){const n=this.superdocStore?.documents;if(Array.isArray(n))for(const r of n){const o=mn(r);o.ydoc&&typeof o.ydoc=="object"&&"value"in o.ydoc&&(o.ydoc.value=e),o.provider&&typeof o.provider=="object"&&"value"in o.provider&&(o.provider.value=t)}}#X(e){if(!e)return null;const t=e.v2Collaboration;return t&&typeof t=="object"&&"value"in t?t.value:t??null}#I(e,t){const n=mn(e).v2Collaboration;if(n&&typeof n=="object"&&"value"in n){n.value=t;return}e.v2Collaboration=t}#B(e){const t=mn(e).editorMountNonce;if(t&&typeof t=="object"&&"value"in t&&typeof t.value=="number"){t.value+=1;return}const n=e;n.editorMountNonce=(typeof n.editorMountNonce=="number"?n.editorMountNonce:0)+1}#z(e){return e.providerFamily==="liveblocks"?{providerType:"liveblocks",documentId:e.documentId,roomMode:e.roomMode,...e.publicApiKey?{publicApiKey:e.publicApiKey}:{},...e.authEndpoint?{authEndpoint:e.authEndpoint}:{}}:e.providerFamily==="hocuspocus"?{providerType:"hocuspocus",documentId:e.documentId,roomMode:e.roomMode,...e.serverUrl?{serverUrl:e.serverUrl}:{},...e.params?{params:e.params}:{},...e.token?{token:e.token}:{}}:{providerType:"y-websocket",documentId:e.documentId,roomMode:e.roomMode,...e.serverUrl?{serverUrl:e.serverUrl}:{},...e.params?{params:e.params}:{}}}#ce(e,t){const n=this.config.documents.find(i=>i.type===Or),r=this.#h("upgradeToCollaboration").documents.find(i=>i.id===n.id);if(!r)throw new Error("SuperDoc: source document store entry is not available for upgrade");const o=this.#z({...e,roomMode:"create"});return n.data=t,n.v2Collaboration=o,r.data=t,this.#I(r,o),this.isCollaborative=!0,this.readyEditors=0,this.#B(r),{configDoc:n,storeDoc:r}}#ue(e,t){const n=this.#z({...t,roomMode:"join"});e.configDoc.v2Collaboration=n,this.#I(e.storeDoc,n)}async#de(){const e=this.activeEditor;if(Zo(e)&&typeof e.save=="function"){const r=await e.save();return this.#Z(r)}const t=this.config.documents.find(r=>r.type===Or),n=(this.superdocStore?.documents.find(r=>r.id===t.id)??null)?.data??t.data;if(n instanceof Blob)return n;if(n instanceof Uint8Array||n instanceof ArrayBuffer)return this.#Z(n);throw new Error("SuperDoc: upgradeToCollaboration() requires a live v2 editor save or DOCX Blob source")}#Z(e){if(e instanceof Blob)return e;if(e instanceof Uint8Array){const t=new Uint8Array(e.byteLength);return t.set(e),new Blob([t],{type:Or})}if(e instanceof ArrayBuffer)return new Blob([e],{type:Or});throw new Error("SuperDoc: active v2 editor returned an unsupported DOCX save payload")}#$(e,t){const n=gb(e),r=(n?this.config.documents.find(a=>a.id===n):null)??this.config.documents.find(a=>a.type==="application/vnd.openxmlformats-officedocument.wordprocessingml.document");if(!r)return;const o=this.#Z(t),i=r.v2Collaboration&&typeof r.v2Collaboration=="object"&&r.v2Collaboration.roomMode==="create"?{...r.v2Collaboration,roomMode:"join"}:null;r.data=o,i&&(r.v2Collaboration=i);const s=this.superdocStore?.documents.find(a=>a.id===r.id)??null;s&&(s.data=o,i&&this.#I(s,i))}#ke(){const e=this.superdocStore?.documents;if(!e?.length)throw new Error("SuperDoc: no store documents available for upgrade");const t=e[0].getDocumentRuntime?.()||e[0].getEditor?.();if(!t?.attachCollaboration)throw new Error("SuperDoc: editor does not support attachCollaboration");return t}#Ae(){this.#k(),this.#Y(null,null)}#Ie(e){const n=e.editor??e;return n.options?.collaborationIsReady?Promise.resolve():new Promise(r=>{let o=!1;const i=()=>{o||(o=!0,clearTimeout(s),typeof n.off=="function"&&n.off("collaborationReady",a))},s=setTimeout(()=>{i(),console.warn("[SuperDoc] collaborationReady did not fire within 10 s after collaboration attach. Continuing β collaboration is active but cursor/presence setup may be delayed."),r(void 0)},1e4),a=()=>{i(),r(void 0)};this.#e=()=>{i(),r(void 0)},typeof n.on=="function"?n.on("collaborationReady",a):(i(),r(void 0))})}#fe(e){return new Promise((n,r)=>{let o=!1;const i=()=>{o||(o=!0,clearTimeout(a),this.off("collaboration-ready",s))},s=l=>{const u=l?.editor;Zo(u)&&gb(u)===e&&(!u.presence&&!u.lock||(i(),n()))},a=setTimeout(()=>{i(),r(new Error(`SuperDoc: v2 collaboration runtime did not become ready within 20000 ms for mounted document "${e}".`))},2e4);this.on("collaboration-ready",s),this.#e=()=>{i(),r(new Error("SuperDoc: instance was destroyed during upgrade"))}})}#Ee(e){return new Promise((n,r)=>{let o,i=!1,s=()=>{};const a=()=>{i=!0,clearTimeout(o),s()};s=dH(e,()=>{i||(a(),n())}),i||(o=setTimeout(()=>{a(),r(new Error("SuperDoc: collaboration provider did not sync within 10000 ms. The provider exposes on/off but never emitted sync(true) or synced."))},1e4)),this.#e=()=>{i||(a(),r(new Error("SuperDoc: instance was destroyed during upgrade")))}})}#he(e){if(this.#t)throw new Error("SuperDoc: cannot upgrade a destroyed instance");if(this.#n)throw new Error("SuperDoc: upgrade already in progress");if(this.isCollaborative)throw new Error("SuperDoc: instance is already collaborative");const t=this.config,n=t.documents.filter(l=>l.type===Or);if(n.length===0)throw new Error("SuperDoc: no DOCX document found for upgrade");if(n.length>1)throw new Error("SuperDoc: upgradeToCollaboration() only supports a single DOCX document");if(t.documents.length!==n.length)throw new Error("SuperDoc: upgradeToCollaboration() only supports single-DOCX instances");if(!Zo(this.#me()))throw new Error("SuperDoc: upgradeToCollaboration() requires a ready v2 DOCX editor");const r=n[0],o=r.id;if(typeof o!="string"||o.length===0)throw new Error("SuperDoc: source document is missing its mounted document identity");const i=t.modules?.collaboration,s=e.ydoc||e.provider?{ydoc:e.ydoc,provider:e.provider}:i?{...i}:null,a=YS({v2Collaboration:e.v2Collaboration??this.#pe(r.v2Collaboration)??i?.v2Collaboration??i?.v2??null,legacyCollaboration:s,documentType:Or,documentCount:t.documents.length,...typeof window<"u"?{authEndpointBaseUrl:window.location.href}:{}});if(!a.ok)throw new Error(`SuperDoc: upgradeToCollaboration() ${a.reason}: ${a.message}`);return{target:a.target,mountedDocumentId:o}}#pe(e){return e&&typeof e=="object"&&"value"in e?e.value:e}#me(){const e=this.config.documents.find(n=>n.type===Or),t=this.#h("upgradeToCollaboration").documents.find(n=>n.id===e.id)?.getEditor?.();if(!t)throw new Error("SuperDoc: source editor not yet created β wait for the ready event before upgrading");return t}addSharedUser(e){this.#R("addSharedUser");const t=Qc({actor:e});t&&this.users.some(n=>Qc({actor:n})===t)||this.users.push(e)}removeSharedUser(e){this.#R("removeSharedUser");const t=typeof e=="string"?Xv(e):"",n=typeof e=="string"?`email:${t}`:Qc({actor:e});this.users=this.users.filter(r=>{const o=Qc({actor:r});return n?o!==n:t?Xv(r.email)!==t:!0})}onContentError({error:e,editor:t}){const n=t.options?.documentId,r=this.#h("onContentError").documents.find(i=>i.id===n),o=typeof r?.id=="string"?r.id:typeof n=="string"?n:"";this.config.onContentError?.({error:e,editor:t,documentId:o,file:r?.data})}broadcastPdfDocumentReady(){this.emit("pdf:document-ready")}broadcastReady(){this.readyEditors===this.requiredNumberOfEditors&&this.emit("ready",{superdoc:this})}broadcastEditorBeforeCreate(e){this.emit("editorBeforeCreate",{editor:R4(e)})}broadcastEditorCreate(e){this.readyEditors++,this.broadcastReady(),this.#ge(e),this.emit("editorCreate",{editor:R4(e)})}broadcastSourceComplete(){this.emit("source:complete")}broadcastSourceSignalsComplete(){this.emit("source:signals-complete")}#ee=new WeakSet;#ge(e){if(!e||typeof e.on!="function"||this.#ee.has(e))return;this.#ee.add(e),e.on("fonts-changed",n=>{this.#te(e)&&this.#V(n)});const t=(e.documentRenderer??e.presentationEditor)?.getLastFontsChangedPayload?.();t&&this.#te(e)&&this.#V(t)}#te(e){return!this.activeEditor||e===this.activeEditor}#ne=null;#V(e){this.#ne=e,this.emit("fonts-changed",e)}broadcastEditorDestroy(){this.emit("editorDestroy")}broadcastSidebarToggle(e){this.emit("sidebar-toggle",e)}#ve(){Array.isArray(this.config.editorExtensions)&&this.config.editorExtensions.length>0&&console.warn("[SuperDoc] `editorExtensions` is a legacy ProseMirror concept and is ignored by superdoc@2. Use `extensions` with `defineSuperDocExtension`; legacy ProseMirror extensions (Node.create, Mark.create, addPmPlugins, custom schema) do not run in v2.")}#b(...e){(console.debug?console.debug:console.log)("π¦ π¦ΈββοΈ [superdoc]",...e)}#Q=null;get fonts(){return this.#Q||(this.#Q={getReport:()=>Xi(this.activeEditor)?.getReport()??[],getMissingFonts:()=>Xi(this.activeEditor)?.getMissingFonts()??[],getDocumentFontOptions:()=>Xi(this.activeEditor)?.getDocumentFontOptions()??[],getFontFamilyOptions:()=>Xi(this.activeEditor)?.getFontFamilyOptions()??[],getDocumentFonts:()=>Xi(this.activeEditor)?.getDocumentFonts()??[],onReport:e=>{const t=this.activeEditor,n=t?Xi(t)?.getLastFontsChangedPayload?.()??null:this.#ne??null;return n&&e(n),this.on("fonts-changed",e),()=>this.off("fonts-changed",e)},map:e=>{const t=Xi(this.activeEditor);if(!t)throw new Error("superdoc.fonts.map requires an active editor");t.map(e)},unmap:e=>{const t=Xi(this.activeEditor);if(!t)throw new Error("superdoc.fonts.unmap requires an active editor");t.unmap(e)},add:e=>{const t=Xi(this.activeEditor);if(!t)throw new Error("superdoc.fonts.add requires an active editor");t.add(e)},preload:e=>{const t=Xi(this.activeEditor);if(!t)throw new Error("superdoc.fonts.preload requires an active editor");return t.preload(e)}}),this.#Q}#H(){const e=this.activeEditor!==null;this.#re(),this.activeEditor=null,this.toolbar?.setActiveEditor?this.toolbar.setActiveEditor(null):this.toolbar&&(this.toolbar.activeEditor=null),e&&this.emit("active-editor-change")}#j=null;#re(){if(this.#j){try{this.#j()}catch{}this.#j=null}}#ye(e){this.#re();const t=Xi(e);if(!t?.onChanged)return;const n=t.getLastFontsChangedPayload?.();n&&this.#V(n),this.#j=t.onChanged(r=>this.#V(r))}#be(e,t){this.#y=!0;try{if(e===null){this.#H();return}this.#r.get(e)?.kind==="v2"&&Zo(t)?this.#oe(t):this.#H()}finally{this.#y=!1}}#oe(e){if(Zo(e)){!this.#y&&this.#r.getActive()&&this.#r.setActive(null,"set-active-v2-facade");const t=this.activeEditor;this.activeEditor=e,this.#ye(e),this.toolbar?.setActiveEditor?.(e),t!==this.activeEditor&&this.emit("active-editor-change");return}this.#H()}setActiveEditor(e){this.#oe(e)}getV2FeatureMatrix(){return[{feature:"source.docx-bytes",status:"supported",reason:"SuperDoc normalizes File/Blob/ArrayBuffer/Uint8Array DOCX inputs for the separate DOCX Engine dependency"},{feature:"source.url",status:"supported",reason:"shell-owned source normalization resolves URL-backed DOCX inputs before opening the injected v2 editor"},{feature:"source.blank",status:"supported",reason:"shell-owned blank-document seeding resolves to DOCX bytes before mounting the injected v2 editor"},{feature:"execution.browser-worker",status:"supported",reason:"the shipped public v2 shell opens DOCX documents through the browser-worker path by default when collaboration is not active"},{feature:"distribution.cdn-iife",status:"supported",reason:"the CDN/IIFE distribution ships the public bundle plus the emitted v2 browser-worker asset and opens DOCX documents through the worker-backed v2 runtime"},{feature:"docx.open-render",status:"supported",reason:"superdoc@2 opens and renders DOCX documents through its DOCX Engine dependency"},{feature:"docx.review-handles",status:"supported",reason:"Comment/tracked-change list + decide via v2 host handles"},{feature:"shell.toolbar",status:"supported",reason:"new SuperDoc({ toolbar }) mounts the rendered built-in toolbar shell and the superdoc.toolbar handle, both backed by the V2 command controller and the internal compatibility catalog. Explicit item-level limits stay fail-closed in the shared command matrix (for example search replace and copyFormat)."},{feature:"shell.rich-formatting",status:"supported",reason:"Rich inline, paragraph, and list formatting route through the V2 command controller and public Document API (format.* / styles.* / lists.*): bold, italic, underline, strikethrough, font family/size, text/highlight color, alignment, line spacing, linked styles, bullet/numbered lists, indent, and clear formatting."},{feature:"shell.comments-sidebar",status:"supported",reason:"ui-phase3-002: v2 comments adapter routes create/reply/edit/resolve/delete through V2EditorHost.dispatch"},{feature:"shell.comments-sidebar.reopen",status:"supported",reason:'ui-phase3-002: v2 comments sidebar reopens resolved threads through the v2 comments adapter (activeEditor.doc.comments.patch({ status: "active" }))'},{feature:"shell.tracked-change-sidebar",status:"supported",reason:"SD-3722: v2 tracked-change adapter lists and decides exact body, header/footer-part, and note targets"},{feature:"shell.tracked-change-sidebar.bulk",status:"not-shipped",reason:"bulk-tracked-change-decisions-omitted: acceptAll/rejectAll are matrix-disabled by default in the v2 host"},{feature:"shell.tracked-change-sidebar.non-body",status:"supported",reason:"SD-3722: public v2 shell hydrates and targets header/footer-part and note tracked changes"},{feature:"shell.comments-sidebar.persistence",status:"supported",reason:"ui-phase3-004: comment create/reply/edit/resolve/delete persist through SuperDoc.export() β re-mount via the v2 host save bridge"},{feature:"shell.tracked-change-sidebar.persistence",status:"supported",reason:"ui-phase3-004: tracked-change accept/reject persist through SuperDoc.export() β re-mount via the v2 host save bridge"},{feature:"shell.comments-sidebar.author-required",status:"supported",reason:"ui-phase3-004: v2 comments adapter surfaces commentCommandsReason=author-required from the host capability matrix; write controls disable and forced dispatch reports ok:false"},{feature:"shell.find-replace",status:"supported",reason:"Ctrl/Cmd+F opens the SuperDoc find/replace surface in v2; find/navigation/replace/replaceAll route through the single host search session (host.search) via ui.search, with replace failing closed in viewing/read-only mode"},{feature:"shell.ai-writer",status:"supported",reason:"built-in toolbar renders the modules.ai-gated AI writer and applies generated text through the public Document API facade"},{feature:"shell.collaboration",status:"supported",reason:"v2 single-doc y-websocket collaboration is wired through document.v2Collaboration, including collaboration-ready, awareness-update, and locked event bridges; arbitrary external { ydoc, provider } adapters remain unsupported"},{feature:"shell.context-menu",status:"not-shipped",reason:"context-menu-omitted: public v2 shell disables the legacy context menu"},{feature:"shell.page-metrics",status:"supported",reason:"ui-phase4-001: v2 page metrics snapshot (editorVersion: 2, documentId, renderEpoch, layoutGeneration, zoom, pages[], capabilities) available via superdoc.activeEditor.pageMetrics.{ getSnapshot, subscribe, setZoom, scrollToPage, revealBodyTarget, pageIndexForBodyTarget }"},{feature:"shell.zoom",status:"supported",reason:"ui-phase4-001: SuperDoc.setZoom routes to V2EditorHost.setZoom in v2 mode; single CSS-transform wrapper applies scale to the painted document, page metrics viewport coords scale with the same zoom value"},{feature:"shell.ruler-page-margins",status:"supported",reason:"ui-phase4-002: v2 ruler renders against the V2PageMetricsSnapshot and dispatches margin drags through a narrow v2 page-layout bridge (`activeEditor.pageLayout.setMargins(...)`) backed by `doc.sections.setPageMargins(...)`. The v2 page metrics snapshot now reports `capabilities.marginEdit = { supported: true }`"},{feature:"shell.custom-extensions",status:"supported",reason:"superdoc@2 supports customer extensions through `extensions` + `defineSuperDocExtension`; command execution and diagnostics are exposed through the narrow `activeEditor.extensions` facet. Legacy ProseMirror `editorExtensions` are ignored in v2."},{feature:"pdf.viewer",status:"supported",reason:"editorVersion ignored for PDF documents"},{feature:"html.viewer",status:"supported",reason:"editorVersion ignored for HTML documents"}]}get v2(){return this.editorVersion!==2?null:{version:2,featureMatrix:this.getV2FeatureMatrix()}}registerEditorRuntime(e){this.#r.register(e)}unregisterEditorRuntime(e){return this.#r.unregister(e)}getActiveRuntime(){return this.#r.getActive()}setActiveRuntime(e,t){this.#r.setActive(e,t)}resolveRuntimeFromEventTarget(e){return this.#r.resolveFromEventTarget(e)}activateRuntimeFromEventTarget(e,t){const n=this.#r.resolveFromEventTarget(e);return n?(this.#r.setActive(n.id,t),!0):!1}toggleRuler(){const e=this.#h("toggleRuler");this.config.rulers=!this.config.rulers,e.documents.forEach(t=>{t.rulers=this.config.rulers}),this.toolbar?.updateToolbarState?.()}canPerformPermission({permission:e,role:t=this.config.role,isInternal:n=this.config.isInternal,comment:r=null,trackedChange:o=null}={}){if(!e)return!1;let i=r??o?.comment??null;const s=o?.commentId||o?.id;if(!i&&s&&this.commentsStore?.getComment){const a=this.commentsStore.getComment(s),l=a?.getValues;i=typeof l=="function"?l.call(a):a}return ca(e,t,n,{superdoc:this,currentUser:this.config.user,comment:i??null,trackedChange:o??null})}#we(){const e=this.config.modules?.toolbar,t=e&&typeof e=="object"?e:{},n=this.#l.toolbar;this.toolbarElement=n.container??void 0;const r=this.config.ui,o=typeof r=="object"&&r!==null&&r.toolbar!==void 0;if(!(n.enabled&&(n.container||e===!0||e!=null&&typeof e=="object"||o))){this.toolbar=null;return}try{this.toolbar=$z({...t,...n.options,selector:this.toolbarElement,superdoc:this,editor:this.activeEditor,role:this.config.role,isDev:this.isDev,documentMode:this.config.documentMode,groups:n.options.groups,toolbarGroups:n.options.toolbarGroups,icons:n.options.icons,texts:n.options.texts,uiDisplayFallbackFont:this.config.uiDisplayFallbackFont})}catch(i){console.warn("[SuperDoc] built-in toolbar mount failed",i),this.toolbar=null}}addCommentsList(e){!this.config?.modules?.comments||this.config.role==="viewer"||(e&&(this.config.modules.comments.element=e),this.commentsList=new KR(this.config.modules?.comments,this),this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!0}))}removeCommentsList(){this.commentsList&&(this.commentsList.close(),this.commentsList=null,this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!1}))}scrollToComment(e,t={}){if(!this.config?.modules?.comments||!e||typeof e!="string")return!1;const n=this.element||document,r=globalThis.CSS?.escape?globalThis.CSS.escape(e):e.replace(/"/g,'\\"'),o=n.querySelector(`[data-comment-ids*="${r}"]`);if(!o)return!1;const{behavior:i="smooth",block:s="start"}=t??{};return o.scrollIntoView({behavior:i,block:s}),this.commentsStore?.setActiveComment?.(this,e),!0}async navigateTo(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getDocumentRuntime?.();return n?.navigateTo?n.navigateTo(e):!1}async scrollToElement(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getDocumentRuntime?.();return n?.scrollToElement?n.scrollToElement(e):!1}setDisableContextMenu(e=!0){if(!e&&this.#l.contextMenu.suppressed)return;const t=!!e;this.config.disableContextMenu!==t&&(this.config.disableContextMenu=t,this.superdocStore?.documents?.forEach(n=>{const r=n.getDocumentRuntime?.();r?.setContextMenuDisabled&&r.setContextMenuDisabled(t);const o=n.getEditor?.();o?.setOptions&&o.setOptions({disableContextMenu:t})}))}setShowBookmarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showBookmarks!==t&&(n.showBookmarks=t,this.superdocStore?.documents?.forEach(r=>{r.getDocumentRuntime?.()?.setShowBookmarks?.(t)}))}setShowFormattingMarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showFormattingMarks!==t&&(n.showFormattingMarks=t,this.superdocStore?.documents?.forEach(r=>{r.getDocumentRuntime?.()?.setShowFormattingMarks?.(t)}),this.emit("formatting-marks-change",{showFormattingMarks:t,superdoc:this}),this.toolbar?.updateToolbarState?.())}toggleFormattingMarks(){const e=!!this.config.layoutEngineOptions?.showFormattingMarks;this.setShowFormattingMarks(!e)}setDocumentMode(e){if(!e)return;this.#R("setDocumentMode"),e=e.toLowerCase(),this.config.documentMode=e,this.#ae();const t={viewing:()=>this.#se(),editing:()=>this.#Ce(),suggesting:()=>this.#ie()};t[e]&&(t[e](),this.emit("document-mode-change",{documentMode:e}))}#J(e,t){const n=typeof e.id=="string"&&e.id.length>0?e.id:null;if(n){const i=this.#r.getAllByDocumentId(n);if(i.length>0){for(const s of i)s.setDocumentMode(t);return}}const r=typeof e.getDocumentRuntime=="function"?e.getDocumentRuntime():null;if(typeof r?.setDocumentMode=="function"){r.setDocumentMode(t);return}const o=typeof e.getEditor=="function"?e.getEditor():null;o&&typeof o.setDocumentMode=="function"&&o.setDocumentMode(t)}setTrackedChangesPreferences(e){const t=e&&Object.keys(e).length?{...e}:void 0;this.config.layoutEngineOptions||(this.config.layoutEngineOptions={}),this.config.layoutEngineOptions.trackedChanges=t,this.superdocStore?.documents?.forEach(n=>{const r=typeof n.getDocumentRuntime=="function"?n.getDocumentRuntime():null;r?.setTrackedChangesOverrides&&r.setTrackedChangesOverrides(t)})}#Ce(){if(this.config.role!=="editor")return this.#ie();const e=this.#h("setDocumentMode");if(e.documents.length>0){const t=e.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),e.documents.forEach(t=>{t.restoreComments?.(),this.#J(t,"editing")})}#ie(){if(!["editor","suggester"].includes(this.config.role??""))return this.#se();const e=this.#h("setDocumentMode");if(e.documents.length>0){const t=e.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),e.documents.forEach(t=>{t.restoreComments?.(),this.#J(t,"suggesting")})}#se(){const e=this.#h("setDocumentMode");this.toolbar?.setActiveEditor?this.toolbar.setActiveEditor(null):this.toolbar&&(this.toolbar.activeEditor=null);const t=this.config.comments?.visible===!0,n=this.config.trackChanges?.visible===!0;this.setTrackedChangesPreferences(n?{mode:"review",enabled:!0}:{mode:"original",enabled:!0}),!t&&!n&&this.commentsStore?.clearEditorCommentPositions?.(),e.documents.forEach(r=>{t||n?r.restoreComments?.():r.removeComments?.(),this.#J(r,"viewing")})}#ae(){const e=this.config.comments?.visible===!0,t=this.config.trackChanges?.visible===!0,n=this.config.documentMode==="viewing",r=e||t;this.commentsStore?.setViewingVisibility&&this.commentsStore.setViewingVisibility({documentMode:this.config.documentMode,commentsVisible:e,trackChangesVisible:t});const o=this.superdocStore?.documents;Array.isArray(o)&&o.length>0&&o.forEach(i=>{const s=typeof i.getDocumentRuntime=="function"?i.getDocumentRuntime():null;s?.setViewingCommentOptions&&s.setViewingCommentOptions({emitCommentPositionsInViewing:n&&r,enableCommentsInViewing:n&&e})})}search(e){const t=this.activeEditor?.commands,n=t?.search;if(typeof n=="function")return n.call(t,e,{searchModel:"visible"})}goToSearchResult(e){const t=this.activeEditor?.commands,n=t?.goToSearchResult;if(typeof n=="function")return!!n.call(t,e)}getZoom(){return this.superdocStore?.activeZoom??100}setZoom(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0){console.warn("[SuperDoc] setZoom expects a positive number representing percentage");return}if(!this.superdocStore){console.warn("[SuperDoc] setZoom called before initialization; use config.zoom.initial for the starting zoom");return}this.superdocStore.activeZoom=e,this.superdocStore.zoomMode="manual",this.emit("zoomChange",{zoom:e,mode:"manual"})}setZoomMode(e){if(e!=="manual"&&e!=="fit-width"){console.warn("[SuperDoc] setZoomMode expects 'manual' or 'fit-width'");return}if(!this.superdocStore){console.warn("[SuperDoc] setZoomMode called before initialization; use config.zoom.mode for the starting mode");return}this.superdocStore.zoomMode!==e&&(this.superdocStore.zoomMode=e,this.emit("zoomChange",{zoom:this.getZoom(),mode:e}))}getZoomState(){const e=I_(this.config.zoom?.fitWidth);return{mode:this.superdocStore?.zoomMode??"manual",value:this.superdocStore?.activeZoom??100,fitZoom:this.superdocStore?.viewportMetrics?.fitZoom??null,min:e.min,max:e.max}}getViewportMetrics(){return this.superdocStore?.viewportMetrics??null}getMeasurementUnit(){return this.superdocStore?.measurementUnit??"in"}setMeasurementUnit(e){if(e!=="in"&&e!=="cm"){console.warn("[SuperDoc] setMeasurementUnit expects 'in' or 'cm'");return}if(!this.superdocStore){console.warn("[SuperDoc] setMeasurementUnit called before initialization; use config.measurementUnit for the starting unit");return}this.superdocStore.measurementUnit!==e&&(this.superdocStore.measurementUnit=e,this.emit("measurement-unit-change",{unit:e}))}setLocked(e=!0){const t=this.activeEditor;if(Zo(t)&&typeof t.lock?.setLocked=="function"){t.lock.setLocked(e,e?{...this.user}:null);const n=t.lock.getSnapshot?.();n&&this.#C(!!n.isLocked,this.#O(n.lockedBy??null));return}this.config.documents.forEach(n=>{const r=n.ydoc;if(!r)return;const o=r.getMap("meta");r.transact(()=>{o.set("locked",e),e?o.set("lockedBy",this.user):o.delete("lockedBy")})}),this.#C(e,e?this.user:null)}getHTML(e={}){const t=[];return this.#h("getHTML").documents.forEach(n=>{const r=n.getEditor?.();r&&t.push(r)}),t.map(n=>n.getHTML(e))}lockSuperdoc(e=!1,t=null){this.#C(e,t)}async export({exportType:e=["docx"],commentsType:t="external",exportedName:n,additionalFiles:r=[],additionalFileNames:o=[],isFinalDoc:i=!1,triggerDownload:s=!0,fieldsHighlightColor:a=null}={}){const l=vk(n||this.config.title),u=await this.exportEditorsToDOCX({commentsType:t,isFinalDoc:i,fieldsHighlightColor:a}),c=[...r],d=[...o];if(e.includes("docx")&&u.forEach(m=>{c.push(m),d.push(`${l}.docx`)}),c.length===1)return s?gk(c[0],l,e[0]):c[0];const h=await uH(c,d);return s?gk(h,l,"zip"):h}async replaceFile(e){const t=this.activeEditor;if(Zo(t)&&typeof t.replaceFile=="function"){const r=await t.replaceFile(e),o=r&&typeof r=="object"?r.state:null;return(o===null||o==="review-ready"||o==="editing-ready")&&(this.#$(t,e),this.emit("document-replaced",{editor:t,host:t?.host})),r}const n=t&&!Zo(t)?t.replaceFile:null;if(typeof n=="function"){const r=await n.call(t,e),o=r&&typeof r=="object"?r.state:void 0;return(o==null||o==="review-ready"||o==="editing-ready")&&(this.#$(t,e),this.emit("document-replaced",{editor:t,host:t?.host})),r}throw new Error("SuperDoc: replaceFile is unavailable for the active editor")}async exportEditorsToDOCX({commentsType:e,isFinalDoc:t,fieldsHighlightColor:n}={}){const r=this.config?.modules?.comments!==!1;let o,i=!1;const s=()=>(i||(i=!0,e==="clean"?o=[]:r&&this.commentsStore&&typeof this.commentsStore.translateCommentsForExport=="function"&&(o=this.commentsStore.translateCommentsForExport(),Array.isArray(o)||(o=[]))),o),a=new WeakSet,l=u=>{"editor"in u&&u.error&&typeof u.error=="object"&&a.add(u.error)};this.on("exception",l);try{const u=this.#h("exportEditorsToDOCX").documents.map(async c=>{if(!c||c.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")return null;const d=typeof c.getEditor=="function"?c.getEditor():null,h=()=>!c.data||c.data.type&&c.data.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?null:c.data;if(!d||typeof d.exportDocx!="function")return h();const m=d.editorVersion===2;try{const p=await d.exportDocx(m?{isFinalDoc:t,commentsType:e,fieldsHighlightColor:n}:{isFinalDoc:t,comments:s(),commentsType:e,fieldsHighlightColor:n});if(p)return p}catch(p){if((!p||typeof p!="object"||!a.has(p))&&this.emit("exception",{error:p,document:c}),m&&(e==="clean"||fH(p)))throw p}return h()});return(await Promise.all(u)).filter(c=>c!=null)}finally{this.off("exception",l)}}async#_e(){this.#b("π¦ [superdoc] Triggering collaboration saves");const e=this.#h("save");return new Promise(t=>{e.documents.forEach((n,r)=>{if(this.#b(`Before reset - Doc ${r}: pending = ${this.pendingCollaborationSaves}`),this.pendingCollaborationSaves=0,n.ydoc){this.pendingCollaborationSaves++,this.#b(`After increment - Doc ${r}: pending = ${this.pendingCollaborationSaves}`);const o=n.ydoc.getMap("meta");o.observe(i=>{i.changes.keys.has("immediate-save-finished")&&(this.pendingCollaborationSaves--,this.pendingCollaborationSaves<=0&&t())}),o.set("immediate-save",!0)}}),this.#b(`FINAL pending = ${this.pendingCollaborationSaves}, but we have ${e.documents.filter(n=>n.ydoc).length} docs!`)})}async save(){const e=[this.#_e()];this.#b("π¦ [superdoc] Saving superdoc"),await Promise.all(e),this.#b("π¦ [superdoc] Save complete")}#Se(e,t){const n=e.provider;n&&n!==this.provider&&!t.some(o=>o.provider===n)&&(n.disconnect?.(),n.destroy?.());const r=e.ydoc;r&&r!==this.ydoc&&!t.some(o=>o.ydoc===r)&&r.destroy?.()}#le(){this.#a=null,this.#g(),typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null);const e=this.config;e.socket?.cancelWebsocketRetry?.(),e.socket?.disconnect(),e.socket?.destroy(),this.ydoc?.destroy(),this.provider?.disconnect?.(),this.provider?.destroy?.(),e.documents.forEach(t=>{t.provider?.disconnect?.(),t.provider?.destroy?.(),t.ydoc?.destroy()})}openSurface(e){return this.#o.open(e)}closeSurface(e){this.#o.close(e)}async removeDocument(e){const t=typeof e=="string"?e:String(e??"");if(!t)return!1;const n=this.#h("removeDocument"),r=this.activeEditor,o=gb(r);for(const s of this.#r.getAllByDocumentId(t))this.#r.unregister(s.id);o===t&&r!==null&&this.#H();const i=n.removeDocument(t);return i?(this.#Se(i,n.documents),await _t(),!0):!1}destroy(){this.#t=!0,this.#e&&(this.#e(),this.#e=null),this.#o&&this.#o.destroy(),this.toolbar?.destroy?.(),this.app&&(this.#b("[superdoc] Unmounting app"),this.superdocStore?.reset(),this.app.unmount(),this.removeAllListeners(),delete this.app.config.globalProperties.$config,delete this.app.config.globalProperties.$superdoc),this.#d?.destroy(),this.#le(),this.#p?.(),this.#p=null,this.#r.clear(),this.#u&&(this.#u.remove(),this.#u=null)}focus(e={}){const t=this.getActiveRuntime();if(t?.getCapabilities().lifecycle.canFocus){t.focus(e).catch(n=>{console.warn("[SuperDoc] active editor runtime focus failed",n)});return}this.activeEditor?Zo(this.activeEditor)?this.activeEditor.focus?.(e):this.activeEditor.focus?.():this.#h("focus").documents.find(n=>{const r=n.getEditor?.();return r?(Zo(r)?r.focus?.(e):r.focus?.(),!0):!1})}setHighContrastMode(e){this.activeEditor&&(this.activeEditor.setHighContrastMode?.(e),this.highContrastModeStore?.setHighContrastMode(e))}};xt();const xA="__SUPERDOC_V2_BROWSER_RUNTIME__";function pH(e=globalThis){const t=e[xA];return t&&typeof t=="object"?t:null}function mH(e={},t=globalThis){const n=pH(t)??{},r={...n,...e,vue:e.vue??n.vue??f6};return t[xA]=r,r}mH();var gH={action:"--sd-ui-action",actionHover:"--sd-ui-action-hover",actionText:"--sd-ui-action-text",bg:"--sd-ui-bg",hoverBg:"--sd-ui-hover-bg",activeBg:"--sd-ui-active-bg",disabledBg:"--sd-ui-disabled-bg",text:"--sd-ui-text",textMuted:"--sd-ui-text-muted",textDisabled:"--sd-ui-text-disabled",border:"--sd-ui-border"},vH=0;function TA(e){const{name:t,font:n,radius:r,shadow:o,colors:i,vars:s}=e,a=`sd-theme-${(t?t.replace(/[^a-zA-Z0-9-_]/g,"-"):null)||`custom-${++vH}`}`,l=[];if(i)for(const[u,c]of Object.entries(i)){if(c==null)continue;const d=gH[u];d&&l.push(` ${d}: ${c};`)}if(n!=null&&l.push(` --sd-ui-font-family: ${n};`),r!=null&&l.push(` --sd-ui-radius: ${r};`),o!=null&&l.push(` --sd-ui-shadow: ${o};`),s)for(const[u,c]of Object.entries(s))c!=null&&l.push(` ${u}: ${c};`);return{className:a,css:l.length>0?`.${a} {
|
|
106
106
|
${l.join(`
|
|
107
107
|
`)}
|
|
108
|
-
}`:""}}function yH(e,t){if(typeof document>"u"||!t)return;let n=document.querySelector(`[data-sd-theme="${e}"]`);n||(n=document.createElement("style"),n.setAttribute("data-sd-theme",e),document.head.appendChild(n)),n.textContent=t}function bH(e){const{className:t,css:n}=TA(e);return yH(t,n),t}function wH(e){return TA(e)}function CH(e){if(!e||typeof e!="object")throw new Error("defineSuperDocExtension requires an extension object.");if(typeof e.id!="string"||e.id.length===0)throw new Error("defineSuperDocExtension requires a non-empty string `id`.");if(typeof e.activate!="function")throw new Error(`defineSuperDocExtension("${e.id}") requires an \`activate(ctx)\` function.`);if(e.storage!==void 0&&typeof e.storage!="function")throw new Error(`defineSuperDocExtension("${e.id}") \`storage\` must be a function returning the initial storage object.`);return e}var _H=nd({BlankDOCX:()=>i_,DOCX:()=>Or,HTML:()=>ep,PDF:()=>Ql,SuperDoc:()=>Cm,buildTheme:()=>wH,compareVersions:()=>w6,createTheme:()=>bH,defineSuperDocExtension:()=>CH,getFileObject:()=>Zv},1),SH="SUPERDOC_ENGINE_CDN_BASE_URL",RA=Symbol.for("superdoc.docx-engine.cdn-load-state"),_m="superdocDocxEngineStatus";function kH(e,t,n=null){const r=e?.[SH],o=typeof r=="string"&&r.trim()?r:n;if(typeof o=="string"&&o.trim())return AH(o);if(!t)throw new Error("SuperDoc: the CDN build is missing its exact DOCX Engine version");return`https://cdn.jsdelivr.net/npm/@superdoc/docx-engine@${t}`}function AH(e){const t=e.trim().replace(/\/+$/,""),n=t.match(/^([a-z][a-z\d+.-]*):/iu)?.[1]?.toLowerCase();if(n&&n!=="http"&&n!=="https")throw new TypeError(`SuperDoc: unsupported DOCX Engine CDN URL scheme ${n}:`);return t}function IH({engineVersion:e,buildBaseUrl:t}){I8(()=>{const n=kH(globalThis,e,t),r=globalThis[RA],o=r instanceof Map?r:new Map;if(globalThis[RA]=o,!o.has(n)){const i=Promise.all([import(`${n}/dist-cdn/docx-engine.es.js`),EH(`${n}/dist-cdn/style.css`)]).then(([s])=>s);o.set(n,i),i.catch(()=>{o.get(n)===i&&o.delete(n)})}return o.get(n)})}function EH(e){if(typeof document>"u")return Promise.resolve();const t=new URL(e,document.baseURI).href,n=Array.from(document.querySelectorAll('link[rel~="stylesheet"]')).find(o=>o.href===t);if(n?.sheet||n?.dataset[_m]==="loaded")return Promise.resolve();const r=n?.dataset[_m]==="loading";return n&&!r&&n.remove(),new Promise((o,i)=>{const s=r?n:document.createElement("link");let a=!1,l;const u=(m,p)=>{a||(a=!0,l?.disconnect(),s.dataset[_m]=m,p())},c=()=>u("loaded",o),d=()=>u("error",()=>i(new Error(`SuperDoc: failed to load DOCX Engine styles from ${t}`))),h=()=>{s.isConnected||u("error",()=>i(new Error(`SuperDoc: DOCX Engine stylesheet was removed while loading from ${t}`)))};s.addEventListener("load",c,{once:!0}),s.addEventListener("error",d,{once:!0}),typeof globalThis.MutationObserver=="function"&&(l=new globalThis.MutationObserver(h),l.observe(document.head,{childList:!0})),r||(s.rel="stylesheet",s.href=t,s.dataset.superdocDocxEngine="true",s.dataset[_m]="loading",document.head.appendChild(s))})}IH({engineVersion:"0.3.0-next.
|
|
108
|
+
}`:""}}function yH(e,t){if(typeof document>"u"||!t)return;let n=document.querySelector(`[data-sd-theme="${e}"]`);n||(n=document.createElement("style"),n.setAttribute("data-sd-theme",e),document.head.appendChild(n)),n.textContent=t}function bH(e){const{className:t,css:n}=TA(e);return yH(t,n),t}function wH(e){return TA(e)}function CH(e){if(!e||typeof e!="object")throw new Error("defineSuperDocExtension requires an extension object.");if(typeof e.id!="string"||e.id.length===0)throw new Error("defineSuperDocExtension requires a non-empty string `id`.");if(typeof e.activate!="function")throw new Error(`defineSuperDocExtension("${e.id}") requires an \`activate(ctx)\` function.`);if(e.storage!==void 0&&typeof e.storage!="function")throw new Error(`defineSuperDocExtension("${e.id}") \`storage\` must be a function returning the initial storage object.`);return e}var _H=nd({BlankDOCX:()=>i_,DOCX:()=>Or,HTML:()=>ep,PDF:()=>Ql,SuperDoc:()=>Cm,buildTheme:()=>wH,compareVersions:()=>w6,createTheme:()=>bH,defineSuperDocExtension:()=>CH,getFileObject:()=>Zv},1),SH="SUPERDOC_ENGINE_CDN_BASE_URL",RA=Symbol.for("superdoc.docx-engine.cdn-load-state"),_m="superdocDocxEngineStatus";function kH(e,t,n=null){const r=e?.[SH],o=typeof r=="string"&&r.trim()?r:n;if(typeof o=="string"&&o.trim())return AH(o);if(!t)throw new Error("SuperDoc: the CDN build is missing its exact DOCX Engine version");return`https://cdn.jsdelivr.net/npm/@superdoc/docx-engine@${t}`}function AH(e){const t=e.trim().replace(/\/+$/,""),n=t.match(/^([a-z][a-z\d+.-]*):/iu)?.[1]?.toLowerCase();if(n&&n!=="http"&&n!=="https")throw new TypeError(`SuperDoc: unsupported DOCX Engine CDN URL scheme ${n}:`);return t}function IH({engineVersion:e,buildBaseUrl:t}){I8(()=>{const n=kH(globalThis,e,t),r=globalThis[RA],o=r instanceof Map?r:new Map;if(globalThis[RA]=o,!o.has(n)){const i=Promise.all([import(`${n}/dist-cdn/docx-engine.es.js`),EH(`${n}/dist-cdn/style.css`)]).then(([s])=>s);o.set(n,i),i.catch(()=>{o.get(n)===i&&o.delete(n)})}return o.get(n)})}function EH(e){if(typeof document>"u")return Promise.resolve();const t=new URL(e,document.baseURI).href,n=Array.from(document.querySelectorAll('link[rel~="stylesheet"]')).find(o=>o.href===t);if(n?.sheet||n?.dataset[_m]==="loaded")return Promise.resolve();const r=n?.dataset[_m]==="loading";return n&&!r&&n.remove(),new Promise((o,i)=>{const s=r?n:document.createElement("link");let a=!1,l;const u=(m,p)=>{a||(a=!0,l?.disconnect(),s.dataset[_m]=m,p())},c=()=>u("loaded",o),d=()=>u("error",()=>i(new Error(`SuperDoc: failed to load DOCX Engine styles from ${t}`))),h=()=>{s.isConnected||u("error",()=>i(new Error(`SuperDoc: DOCX Engine stylesheet was removed while loading from ${t}`)))};s.addEventListener("load",c,{once:!0}),s.addEventListener("error",d,{once:!0}),typeof globalThis.MutationObserver=="function"&&(l=new globalThis.MutationObserver(h),l.observe(document.head,{childList:!0})),r||(s.rel="stylesheet",s.href=t,s.dataset.superdocDocxEngine="true",s.dataset[_m]="loading",document.head.appendChild(s))})}IH({engineVersion:"0.3.0-next.2",buildBaseUrl:null});for(const[e,t]of Object.entries(_H))e==="SuperDoc"||e==="default"||Object.prototype.hasOwnProperty.call(Cm,e)||(Cm[e]=t);var xH=Cm;return xH})();
|