@inkeep/open-knowledge 0.88.9-beta.5 → 0.88.11-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cli-BWG-Aq4r.mjs → cli-CKiNxYDi.mjs} +57 -57
- package/dist/cli.mjs +1 -1
- package/dist/config-schema.json +25 -0
- package/dist/config.user.schema.json +25 -0
- package/dist/constants-COUZx5WC.mjs +1 -0
- package/dist/dist-BSNy29T3.mjs +2326 -0
- package/dist/dist-Bfg_JABr.mjs +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +343 -245
- package/dist/init-D4jlORuT.mjs +1 -0
- package/dist/{init-DgagwO3Q.mjs → init-DZf66ZMB.mjs} +8 -8
- package/dist/{launch-json-removal-RTdY_4MQ.mjs → launch-json-removal-Bnn4Q8Q5.mjs} +1 -1
- package/dist/{loader-bqg6WDaz.mjs → loader-CQWLo5wb.mjs} +1 -1
- package/dist/loader-CYqRMGXq.mjs +1 -0
- package/dist/{lzma-B6QS2aZK.mjs → lzma-Ciwelb1t.mjs} +2 -2
- package/dist/{md-manager-BGnqyqi1-B5Gyjk_N.mjs → md-manager-BGnqyqi1-DCCfgLfC.mjs} +142 -143
- package/dist/{open-browser-kL892VYi.mjs → open-browser-Bb2-wy79.mjs} +1 -1
- package/dist/parse-worker.mjs +1 -1
- package/dist/preview-CMjmNRLt.mjs +1 -0
- package/dist/{preview-CpwcPVCo.mjs → preview-UtmI_Kbo.mjs} +1 -1
- package/dist/public/assets/{AccountSection-OC5q0omm.js → AccountSection-92kzeYSz.js} +1 -1
- package/dist/public/assets/{ActivityModeContent-BrTDTihv.js → ActivityModeContent-c0yIlei6.js} +1 -1
- package/dist/public/assets/{AddPropertiesButton-DzmO7lPO.js → AddPropertiesButton-CD7DFmk4.js} +1 -1
- package/dist/public/assets/{AgentDiffPane-D3NHWroZ.js → AgentDiffPane-Qdw4whsW.js} +1 -1
- package/dist/public/assets/{AttachmentsSection-BRw5iHsN.js → AttachmentsSection-DkrZOM4_.js} +1 -1
- package/dist/public/assets/{CodeMirrorPropInput-_xlIZfnP.js → CodeMirrorPropInput-BGz-GQYy.js} +1 -1
- package/dist/public/assets/{ContentRulesSection-C3zJL3XT.js → ContentRulesSection-Cp7WxUGq.js} +1 -1
- package/dist/public/assets/{DocumentContext-DudOKaBE.js → DocumentContext-Oflbu4n0.js} +1 -1
- package/dist/public/assets/{EditorModeToggle-C6XVQvNH.js → EditorModeToggle-DbRqwAo8.js} +1 -1
- package/dist/public/assets/{ExcalidrawDocEditor-CNbYH26b.js → ExcalidrawDocEditor-BB3VQ-A5.js} +1 -1
- package/dist/public/assets/FeedbackForm-BE3p6ea8.js +1 -0
- package/dist/public/assets/{ImportSkillDialog-BvMF42t1.js → ImportSkillDialog-CgLt_Ckj.js} +1 -1
- package/dist/public/assets/{LinkPreviewsSection-CfBE3a3F.js → LinkPreviewsSection-Ba0s74kx.js} +1 -1
- package/dist/public/assets/{LintConfigEditor-C5OeqI_-.js → LintConfigEditor-BtsBpxqx.js} +1 -1
- package/dist/public/assets/{LintingSection-CA0Fab7L.js → LintingSection-BWGxasTk.js} +1 -1
- package/dist/public/assets/ManagedArtifactProperties-DEfWLrVU.js +1 -0
- package/dist/public/assets/{ManagedArtifactProperties-9GJ7LIgQ.js → ManagedArtifactProperties-FdKNrPr-.js} +1 -1
- package/dist/public/assets/{MermaidDocEditor-BkAp4SwO.js → MermaidDocEditor-D_MVfawW.js} +1 -1
- package/dist/public/assets/{NetworkAccessSection-5853q-6H.js → NetworkAccessSection-x1p6MRDS.js} +1 -1
- package/dist/public/assets/{PropertyDisplayRow-BfPIxbJe.js → PropertyDisplayRow-hkfIbJsU.js} +1 -1
- package/dist/public/assets/{PublishToGitHubDialog-D-DLQtYQ.js → PublishToGitHubDialog-CWp9_6sQ.js} +1 -1
- package/dist/public/assets/{SchemaConfigEditor-CCWn7X-u.js → SchemaConfigEditor-DES1MqTn.js} +1 -1
- package/dist/public/assets/{SearchSection-2KCDB2VA.js → SearchSection-DaAoqTaY.js} +1 -1
- package/dist/public/assets/{SessionsHost-CRPnzYN1.js → SessionsHost-BWqLoT8o.js} +2 -2
- package/dist/public/assets/{SettingsDialogBody-1yLR-GsZ.js → SettingsDialogBody-_2UYxQzL.js} +2 -2
- package/dist/public/assets/{ShareReceiveMissDialog-BXKUoF1i.js → ShareReceiveMissDialog-DsAhOXOf.js} +1 -1
- package/dist/public/assets/{SkillToolbarControls-B6E5iiKJ.js → SkillToolbarControls-CxIhFxut.js} +1 -1
- package/dist/public/assets/{SourceEditor-BLtDTcHX.js → SourceEditor-CmyXOjyo.js} +1 -1
- package/dist/public/assets/{SpellingSettings-BnekUXi0.js → SpellingSettings-aGM4YFpK.js} +1 -1
- package/dist/public/assets/{SyncSection-BsLX6-vW.js → SyncSection-DKwcggD4.js} +1 -1
- package/dist/public/assets/{SyncStatusBadge-C36jYktv.js → SyncStatusBadge-C3yXqn1g.js} +1 -1
- package/dist/public/assets/{TerminalSection-DZKCNM7y.js → TerminalSection-Df2_OUq4.js} +1 -1
- package/dist/public/assets/{TerminalWindowApp-CmU1Cb8o.js → TerminalWindowApp-BsaMrWLk.js} +1 -1
- package/dist/public/assets/{TextDocEditor-BabRgTt7.js → TextDocEditor-lseiNuoW.js} +1 -1
- package/dist/public/assets/{ThemePluginSection-htJshVsF.js → ThemePluginSection-DdSQUUtI.js} +1 -1
- package/dist/public/assets/{ThreadView-C_zy2m7k.js → ThreadView-OZ2uZOIE.js} +1 -1
- package/dist/public/assets/{TimelineDiffPane-DYpDj0gb.js → TimelineDiffPane-WxFbMDQS.js} +1 -1
- package/dist/public/assets/{client-version-C1mluhO6.js → client-version-CY6vMdzi.js} +1 -1
- package/dist/public/assets/{comment-chips-Bg_fHZit.js → comment-chips-CGZDgzW5.js} +1 -1
- package/dist/public/assets/config-provider-pJEK9WCI.js +4 -0
- package/dist/public/assets/config-schema-DM88r6Wp.js +1 -0
- package/dist/public/assets/{doc-undo-manager-BeKYlR4y.js → doc-undo-manager-BJwKYuHY.js} +1 -1
- package/dist/public/assets/{field-controls-uK27_e3u.js → field-controls-C_sis3h8.js} +1 -1
- package/dist/public/assets/field-controls-Cl0fMM5C.js +1 -0
- package/dist/public/assets/{index-CcicSOZg.js → index-CUM2b-vl.js} +107 -107
- package/dist/public/assets/{lint-config-client-D7WzQSDg.js → lint-config-client-CZ22hfd5.js} +1 -1
- package/dist/public/assets/{lint-plugins-C777a3Eb.js → lint-plugins-C3d0yJ4F.js} +1 -1
- package/dist/public/assets/{markdown-lint-DwFRnZJ_.js → markdown-lint-D13AGXjm.js} +2 -2
- package/dist/public/assets/{markdownlint-rule-browser-DBy2EH_P.js → markdownlint-rule-browser-mf_8la30.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-CV2evy8J.js → pending-receive-nav-store-CqX4bHwr.js} +1 -1
- package/dist/public/assets/{preferred-session-events-_cY_seNN.js → preferred-session-events-BYPsTTfd.js} +1 -1
- package/dist/public/assets/{progress-Bq_b5Dwi.js → progress-ChjxM4dF.js} +1 -1
- package/dist/public/assets/saved-themes-client-B4QZmuf_.js +1 -0
- package/dist/public/assets/{schema-section-Cp00yQR2.js → schema-section-BaOibm8x.js} +1 -1
- package/dist/public/assets/{selection-context-DsN_o-oO.js → selection-context-Cub1fE1T.js} +1 -1
- package/dist/public/assets/{src-MfTCWnJS.js → src-DewQmhy5.js} +1 -1
- package/dist/public/assets/{telemetry-impl-DoFXV7zT.js → telemetry-impl-CaqdOBmg.js} +1 -1
- package/dist/public/assets/{telemetry-startup-Dh6dlltT.js → telemetry-startup-DNHafhpO.js} +1 -1
- package/dist/public/assets/{typing-burst-detector-CQpkMJPV.js → typing-burst-detector-C0UhTw8o.js} +1 -1
- package/dist/public/assets/{use-activity-panel-DK_CY04P.js → use-activity-panel-BHSrXZXF.js} +1 -1
- package/dist/public/assets/{use-open-skill-B0yLjGNV.js → use-open-skill-DrtR4XOY.js} +1 -1
- package/dist/public/assets/{use-terminal-enabled-x6P_EH4P.js → use-terminal-enabled-CSFlSWPT.js} +1 -1
- package/dist/public/assets/{use-timeline-entry-diff-BAgwVMRs.js → use-timeline-entry-diff-VsPbMLbd.js} +1 -1
- package/dist/public/index.html +22 -22
- package/dist/{registry-probes-B2fn4XJx.mjs → registry-probes-DIqlo9h8.mjs} +2 -2
- package/dist/{removal-file-path-HAS5JVGt.mjs → removal-file-path-wBKXFJo1.mjs} +1 -1
- package/dist/{repair-launch-json-Crbpi7Jj.mjs → repair-launch-json-24ZgLMF1.mjs} +1 -1
- package/dist/{repair-mcp-configs-CV-7zYuV.mjs → repair-mcp-configs-euqladvH.mjs} +1 -1
- package/dist/schemas/v0/config.user.schema.json +25 -0
- package/dist/src-DEXULBC-.mjs +1 -0
- package/dist/src-DKsIGYJ_.mjs +16 -0
- package/dist/{start-BjstUFs5.mjs → start-9N2SMPQM.mjs} +3 -3
- package/dist/start-CJj6tAZ-.mjs +1 -0
- package/dist/{tar-MZQD7NO4-ljX84Spn.mjs → tar-MZQD7NO4-D-JBnhvQ.mjs} +2 -2
- package/package.json +4 -4
- package/dist/constants-DqD-WwtH.mjs +0 -1
- package/dist/dist-By4Q8HCV.mjs +0 -2227
- package/dist/dist-Ttulen40.mjs +0 -1
- package/dist/init-CMXr3PqV.mjs +0 -1
- package/dist/loader-B_W8tqBx.mjs +0 -1
- package/dist/preview-uakaw7R6.mjs +0 -1
- package/dist/public/assets/FeedbackForm-JqmULtp1.js +0 -1
- package/dist/public/assets/ManagedArtifactProperties-CiPHTfJ5.js +0 -1
- package/dist/public/assets/config-provider-rlX-hNO5.js +0 -4
- package/dist/public/assets/config-schema-BFeDYLCd.js +0 -1
- package/dist/public/assets/field-controls-lq4qcuvr.js +0 -1
- package/dist/public/assets/saved-themes-client-DX5dCXi5.js +0 -1
- package/dist/src-B_q1_C1R.mjs +0 -16
- package/dist/src-BjiiSghS.mjs +0 -1
- package/dist/start-MRWYWYqt.mjs +0 -1
package/dist/dist-Ttulen40.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Cc as e,Et as t,Ot as n,Pc as r,S as i,X as a,_c as o,no as s,v as c}from"./md-manager-BGnqyqi1-B5Gyjk_N.mjs";import{$ as l,$a as u,$i as d,$n as f,$r as p,$t as m,A as h,Aa as g,Ai as _,An as v,Ao as y,Ar as b,At as x,B as S,Ba as C,Bi as w,Bn as T,Bo as E,Br as D,Bs as O,Bt as k,C as A,Ca as j,Ci as M,Cn as N,Co as P,Cr as F,Cs as I,Ct as L,D as R,Da as z,Di as B,Dn as V,Do as H,Dr as U,Dt as W,E as G,Ea as K,Ei as q,En as J,Eo as Y,Er as X,Et as Z,F as Q,Fa as $,Fi as ee,Fn as te,Fo as ne,Fr as re,Ft as ie,G as ae,Ga as oe,Gi as se,Gn as ce,Go as le,Gr as ue,Gt as de,H as fe,Ha as pe,Hi as me,Hn as he,Ho as ge,Hr as _e,Ht as ve,I as ye,Ia as be,Ii as xe,In as Se,Io as Ce,Ir as we,It as Te,J as Ee,Ja as De,Ji as Oe,Jn as ke,Jo as Ae,Jr as je,Jt as Me,K as Ne,Ka as Pe,Ki as Fe,Kn as Ie,Ko as Le,Kr as Re,Kt as ze,L as Be,La as Ve,Li as He,Ln as Ue,Lo as We,Lr as Ge,Ls as Ke,Lt as qe,M as Je,Ma as Ye,Mi as Xe,Mn as Ze,Mo as Qe,Mr as $e,Mt as et,N as tt,Na as nt,Ni as rt,Nn as it,No as at,Nr as ot,Nt as st,O as ct,Oa as lt,Oi as ut,On as dt,Oo as ft,Or as pt,Ot as mt,P as ht,Pa as gt,Pi as _t,Pn as vt,Po as yt,Pr as bt,Pt as xt,Q as St,Qa as Ct,Qi as wt,Qn as Tt,Qr as Et,Qt as Dt,R as Ot,Ra as kt,Ri as At,Rn as jt,Ro as Mt,Rr as Nt,Rs as Pt,Rt as Ft,S as It,Sa as Lt,Si as Rt,Sn as zt,So as Bt,Sr as Vt,Ss as Ht,St as Ut,T as Wt,Ta as Gt,Ti as Kt,Tn as qt,To as Jt,Tr as Yt,Tt as Xt,U as Zt,Ua as Qt,Ui as $t,Un as en,Uo as tn,Ur as nn,Ut as rn,V as an,Va as on,Vi as sn,Vn as cn,Vo as ln,Vr as un,Vt as dn,W as fn,Wa as pn,Wi as mn,Wn as hn,Wo as gn,Wr as _n,Wt as vn,X as yn,Xa as bn,Xi as xn,Xn as Sn,Xr as Cn,Xt as wn,Y as Tn,Ya as En,Yi as Dn,Yn as On,Yo as kn,Yr as An,Yt as jn,Z as Mn,Za as Nn,Zi as Pn,Zn as Fn,Zr as In,Zt as Ln,_ as Rn,_a as zn,_i as Bn,_n as Vn,_o as Hn,_r as Un,_s as Wn,_t as Gn,a as Kn,aa as qn,ai as Jn,an as Yn,ao as Xn,ar as Zn,at as Qn,b as $n,ba as er,bi as tr,bn as nr,bo as rr,br as ir,bs as ar,bt as or,c as sr,ca as cr,ci as lr,cn as ur,co as dr,cr as fr,ct as pr,d as mr,da as hr,di as gr,dn as _r,do as vr,dr as yr,ds as br,dt as xr,ea as Sr,ei as Cr,en as wr,eo as Tr,er as Er,et as Dr,f as Or,fa as kr,fi as Ar,fn as jr,fo as Mr,fr as Nr,fs as Pr,ft as Fr,g as Ir,ga as Lr,gi as Rr,gn as zr,go as Br,gr as Vr,gs as Hr,gt as Ur,h as Wr,ha as Gr,hi as Kr,hn as qr,ho as Jr,hr as Yr,ht as Xr,i as Zr,ia as Qr,ii as $r,in as ei,io as ti,ir as ni,it as ri,j as ii,ja as ai,ji as oi,jn as si,jo as ci,jr as li,jt as ui,k as di,ka as fi,ki as pi,kn as mi,ko as hi,kr as gi,kt as _i,l as vi,la as yi,li as bi,ln as xi,lo as Si,lr as Ci,lt as wi,m as Ti,ma as Ei,mi as Di,mn as Oi,mo as ki,mr as Ai,mt as ji,n as Mi,na as Ni,ni as Pi,nn as Fi,no as Ii,nr as Li,nt as Ri,o as zi,oa as Bi,oi as Vi,on as Hi,oo as Ui,or as Wi,ot as Gi,p as Ki,pa as qi,pi as Ji,pn as Yi,po as Xi,pr as Zi,pt as Qi,q as $i,qa as ea,qi as ta,qn as na,qo as ra,qr as ia,qt as aa,r as oa,ra as sa,ri as ca,rn as la,ro as ua,rr as da,rt as fa,s as pa,sa as ma,si as ha,sn as ga,so as _a,sr as va,st as ya,t as ba,ta as xa,ti as Sa,tn as Ca,to as wa,tr as Ta,tt as Ea,u as Da,ua as Oa,ui as ka,un as Aa,uo as ja,ur as Ma,ut as Na,v as Pa,va as Fa,vi as Ia,vn as La,vo as Ra,vr as za,vs as Ba,vt as Va,w as Ha,wa as Ua,wi as Wa,wn as Ga,wo as Ka,wr as qa,ws as Ja,wt as Ya,x as Xa,xa as Za,xi as Qa,xn as $a,xo as eo,xr as to,xs as no,xt as ro,y as io,ya as ao,yi as oo,yn as so,yo as co,yr as lo,ys as uo,yt as fo,z as po,za as mo,zi as ho,zn as go,zo as _o,zr as vo,zs as yo,zt as bo}from"./dist-By4Q8HCV.mjs";import{f as xo,h as So,m as Co,n as wo,p as To,t as Eo}from"./fs-find-project-root-BYV07wjn.mjs";export{ba as AGENT_ID_MAX_LEN,Mi as AGENT_ID_RE,oa as AGENT_WRITE_ORIGIN,s as AUDIT_EMPTY_SCOPE_WARNING,Zr as AcpPermissionStore,Kn as AcpRegistry,zi as AcpThreadManager,pa as AgentFocusBroadcaster,sr as AgentPresenceBroadcaster,vi as AgentSessionCapacityError,Da as AgentSessionManager,mr as AutoStartDisabledError,Or as BUNDLE_IDS,Ki as BUNDLE_SCOPE,Ti as BUNDLE_SKILL_NAME,Wr as BacklinkIndex,Ir as CC1Broadcaster,e as CC1_CONTRACT_VERSION,Rn as CONCURRENT_REPLACE_WINDOW_MS,Pa as CONFIG_FILENAME,io as CONFLICT_MARKER_RE,$n as CURSOR_BUNDLE_PATHS_BY_PLATFORM,Xa as ConfigSchema,It as ConflictAuthority,A as DEFAULT_CHECKPOINT_RETENTION,Ha as DEFAULT_EMBEDDINGS_DIMENSIONS,Wt as DEFAULT_PACK_ID,G as DocumentDurabilityState,R as DocumentDurabilityStateError,ct as EMBEDDINGS_API_KEY_ENV,di as EPHEMERAL_PROJECT_DIR_PREFIX,h as ExposureConsentError,ii as FEATURED_AGENT_IDS,Je as FILE_SYSTEM_WRITER,tt as FILE_WATCHER_ORIGIN,ht as FileEmbeddingsBackend,Q as FilesystemRootProjectError,ye as GIT_PREFLIGHT_FAIL_SPAN_NAME,Be as GIT_UPSTREAM_WRITER,br as GitDirAccessError,Ot as GitNotAvailableError,po as GitProbeTimeoutError,S as GitTooOldError,an as HOCUSPOCUS_AUTH_REJECTION_REASONS,fe as HocuspocusAuthRejection,Zt as HocuspocusAuthTokenSchema,fn as HomeProjectRootError,ae as INSTALLED_AGENTS_SCHEMES,Ne as JSON_SCHEMA_DIALECT_2020_12,yo as LINEAGE_EPOCH_KEY,$i as LIVE_DERIVED_INDEX_DEBOUNCE_MS,Ee as LOCK_FILE_ACCESS_REMEDY,Tn as MANAGED_RENAME_ORIGIN,yn as MAX_ACP_THREADS,Mn as MAX_AGENT_SESSIONS,St as MCP_CONNECTION_ID_HEADER,o as MCP_SERVER_NAME,l as MIN_EVICTABLE_IDLE_MS,Dr as MIN_GIT_VERSION,Pr as MalformedGitPointerError,Ea as McpLogger,Ri as MissingOkConfigError,fa as OBSERVER_SYNC_ORIGIN,ri as OK_OKIGNORE_TEMPLATE,Qn as ONBOARDING_BUNDLE_IDS,Ke as ORPHAN_MODES,O as PROTOCOL_VERSION,Hr as PinoLogger,Gi as ProcessLockCollisionError,ya as ProcessLockFileError,pr as ProjectGitInitError,wi as ROLLBACK_ORIGIN,Na as ROOT_GITIGNORE_TEMPLATE,xr as RUNTIME_VERSION,Fr as SERVICE_WRITER,Qi as SKILL_INSTALL_EVENTS_FILENAME,c as SKILL_STATE_TARGETS,ji as STARTER_FOLDER_FRONTMATTER_FILENAME,Xr as STARTER_PACKS,Ur as STARTER_PACK_IDS,Gn as STATE_MANIFEST_FILENAME,Va as STATE_SCHEMA_VERSION,fo as SYMLINK_MERGE_MIN_GIT_LABEL,or as SYMLINK_MERGE_MIN_GIT_VERSION,r as SYSTEM_DOC_NAME,ro as SeedPrerequisiteError,Ut as SeedRootDirError,L as ServerAuthorityCollisionError,Ya as ServerAuthorityRegistryError,Xt as ServerLockCollisionError,Z as SingleFileNotAFileError,W as SingleFileNotFoundError,mt as SingleFileNotMarkdownError,_i as SingleFileProjectOverrideError,x as StateManifestError,i as TEST_LOOP_CORE_MARKER,ui as TEST_LOOP_SERVER_MARKER,et as TagIndex,st as USER_GLOBAL_BUNDLE_IDS,xt as UnsafeIncomingSymlinkError,ie as __getShowAllWalkStatsForTesting,Te as __resetShowAllWalkStatsForTesting,qe as acpThreadStoreRoots,Ft as acpThreadsDir,bo as acquireProcessLock,k as acquireServerLock,dn as applyAgentMarkdownWrite,ve as applyExternalChange,rn as applySeed,vn as assertCheckoutSymlinksSafe,de as assertCompatibleStateManifest,ze as assertGitAvailable,aa as assertIncomingSymlinksSafe,Me as assertMergeNameResolvesTo,jn as assertNeverDiskEvent,wn as assertRepoCheckoutSymlinksSafe,Ln as assertSafeProjectRoot,Dt as assessLockHolder,m as attachAcpThreadSocket,wr as attachCollabClientCounter,Ca as attachIdleShutdown,Fi as auditScopeNotFoundTitle,la as bindConflictAuthority,ei as bootServer,Yn as buildAndOpenSkill,Hi as buildConfigYmlContent,ga as buildExecResult,ur as buildIngressPolicy,xi as buildOkMcpStdioCommand,Aa as buildSkillZip,_r as buildStarterFolderFrontmatterYaml,jr as buildWipTree,Yi as bundleSkillMdPath,Oi as canonicalProjectKey,qr as canonicalizeForCompare,zr as classifyEvents,Vn as classifyFsPath,La as classifyLockHolder,so as clearAllEmbeddingsKeys,nr as coercePackId,$a as collectServerHostSnapshot,t as colorFromSeed,zt as commitUpstreamImport,N as commitWip,Ga as commitWipFromTree,qt as compareSemver,J as composeEffectiveLinterConfig,V as composeFrontmatterSchemasConfig,dt as containsConflictMarkers,mi as contentHash,v as contributorCount,si as countShadowObjects,Ze as countStaleAgentWipRefs,it as countWipRefs,vt as createApiExtension,te as createAssetServeMiddleware,Se as createCollaborationHost,Ue as createContentFilter,jt as createContentFilterAsync,go as createEmbeddingsSecretStore,T as createEphemeralProjectDir,cn as createExternalChangeHandler,xo as createFileLogger,he as createLiveDerivedIndexExtension,en as createMcpHttpHandler,hn as createOsProbe,ce as createPersistenceExtension,Ie as createProbeFailureReporter,na as createServer,ke as createServerObserverExtension,On as createServerProbeResolver,Sn as createStreamingErrorWriter,Wn as createTestLogger,Fn as describeStoredEmbeddingsKey,Tt as detectClaudeDesktopPresence,f as detectGit,Er as detectProjectShape,Ta as detectUserSkillHosts,Li as discoverLockDirs,da as discoverMarkdownlintConfig,ni as emitPreflightFailureSpan,Zn as encodeDocName,Wi as encodeFolderRoute,va as encodeSkillRoute,fr as ensureProjectGit,Ci as errorResponse,Ma as evictStaleTrackerEntries,yr as extractHeadings,Nr as extractOkBinaryPath,Zi as extractWikiLinksFromMarkdown,Ai as fallbackPaths,Yr as findEnclosingGitRoot,Eo as findEnclosingProjectRoot,Vr as findNativeMarkdownlintFile,To as flushFileLogger,Un as formatAuditBrokenLinkSuppressionLine,za as formatAuthRejectionWire,lo as formatContributorsFrom,ir as formatPackRationale,to as gcCheckpointRefs,Vt as getCurrentMcpLogger,F as getIngressContext,qa as getLocalDir,Co as getLogFilePath,Ba as getLogger,So as getLogsDir,Yt as getMachineId,X as getMeter,U as getMetrics,pt as getTracer,gi as handleCollabSocketError,b as handleSpawnCursor,li as hasForwardingHeaders,$e as hasGcLogLatch,n as iconFromClientName,ot as incrementCollabSocketFilteredError,bt as incrementServerObserverFire,re as initContent,we as initShadowRepo,Ge as initTelemetry,Nt as initToleranceTelemetryWriter,vo as installJsonSchemaDialect,D as installPrettyZodErrors,uo as installTestLoggers,un as installUserSkill,_e as isAllowedApiOrigin,nn as isAllowedWorkspaceHostHeader,_n as isConfigDoc,ue as isDefunctProcess,Re as isDocInConflict,ia as isFilesystemRoot,je as isHocuspocusAuthRejectionReason,An as isHomeDir,Cn as isHostAdmitted,In as isKnownPackId,Et as isLinkIndexExcludedDoc,p as isLockFromThisMachine,Cr as isLockProcessRunning,Sa as isLoopbackAddress,Pi as isManagedArtifactDoc,ca as isMintedThreadId,$r as isOriginAdmitted,Pt as isOrphanMode,Jn as isPairedWriteOrigin,Vi as isPathWithinDir,ha as isPeerAdmitted,lr as isProcessAlive,wo as isProjectRoot,bi as isReservedForUserTree,ka as isSelfWrite,gr as isSkillInstallReportEnvOptOut,Ar as isSystemDoc,Ji as isToleranceTelemetryEnabled,Di as isValidLockPid,Kr as lastKnownHash,Rr as listRescueCheckpoints,Bn as listStarterPacks,Ia as loadCustomAgents,oo as loadPrincipal,tr as lockAdvertisesUi,Qa as lockBaseUrl,Rt as lockFilePath,ar as loggerFactory,M as loginShapedUserinfoUser,no as logsCurrentPath,Ht as logsPreviousPath,Wa as machineIdFilePath,Kt as makeLazyEmbeddingsKeyStore,q as markServerLockDraining,B as missingOkConfigMessage,ut as mountMcpAndApi,pi as normalizeFsPath,_ as observeReadiness,oi as packageVersionMajorMinor,Xe as parseAuthRejectionWire,rt as parseGitVersion,_t as parseHocuspocusAuthToken,ee as parseKeepaliveConnectionId,xe as parseProcessStartToken,He as pathToDocName,At as planSeed,ho as prepareProjectLogsDir,w as prepareSingleFileOpen,sn as prepareSpawnProjectLogsDir,me as processCommand,$t as processStartToken,mn as processUsage,se as readAgentBrowserTools,Fe as readAllTargets,ta as readBootStartedAtMs,Oe as readBundleDecision,Dn as readDeclaredGitHubHosts,xn as readOriginCredentialHost,Pn as readOriginGitHubRepo,wt as readOwnNativeRules,d as readProcessLock,Sr as readProcessLockDetailed,xa as readProcessStart,Ni as readProcessState,sa as readProjectHeadState,Qr as readProjectLocalSemanticConfig,qn as readServerLock,Bi as readServerPackageVersion,ma as readSkillInstallStateSnapshot,cr as readStateManifest,yi as readTargetRecordedAt,Oa as readTargetVersion,hr as reconcile,kr as recordContributor,qi as recordSkillInstallEvent,Ei as recordsLockOwner,Gr as redactShareSubprocessStderr,Lr as registerAllTools,zn as registerNativeProcessStartReader,Fa as registerWrite,ao as releaseProcessLock,er as releaseServerLock,Za as removeLastKnownHash,Lt as removeLockIfUnchanged,j as removeProjectSkillGitignoreBlock,Ua as reportSkillInstall,Gt as resetMetrics,K as resolveAuditScope,z as resolveBuiltinSkillHosts,a as resolveBundleEnabled,lt as resolveBundledSkillDir,fi as resolveContentDir,g as resolveCursorBinaryDefault,ai as resolveCursorSpawnInvocation,Ye as resolveEffectiveLinterConfig,nt as resolveEmbeddingsCredential,gt as resolveGitHubAccountFromUrl,$ as resolveGitHubAuthHost,be as resolveLockDir,Ve as resolveNativeConfigForDoc,kt as resolveNativeMarkdownlintConfig,mo as resolvePack,C as resolvePackageVersion,on as resolveSkillInstallReportSettings,pe as resolveUiInfo,Qt as restoreContributors,pn as rewriteMarkdownLinksForDocumentRename,oe as rewriteWikiLinksForDocumentRename,Pe as runAuthReposSubprocess,ea as runAuthStatusSubprocess,De as runCloneSubprocess,En as runDeviceFlowSubprocess,bn as runWithMcpLogger,Nn as safeContentPath,Ct as safeSubdir,u as safetyCheckpoint,Tr as sameGitHubLogin,wa as sanitizeClientName,Ii as saveInMemoryCheckpoint,ua as saveVersion,ti as scanLockProcesses,Xn as seedBasenameIndex,Ui as seedEphemeralProjectDir,_a as serializeError,dr as setActiveSpanAttributes,Si as setupServerObservers,ja as shadowGit,vr as shutdownTelemetry,I as spansCurrentPath,Ja as spansPreviousPath,Mr as spawnDetached,Xi as splitMarkdownBlocks,ki as startWatcher,Jr as strategiesFor,Br as streamedChunkOf,Hn as streamingProblemEvent,Ra as swapContributors,co as teardownToleranceTelemetryWriter,rr as toBroadcasterKey,eo as toProcessLockMetadata,Bt as tracedAppendFileSync,P as tracedLinkSync,Ka as tracedMkdir,Jt as tracedMkdirSync,Y as tracedRename,H as tracedRenameSync,ft as tracedRmSync,hi as tracedRmdirSync,y as tracedUnlinkSync,ci as tracedWriteFile,Qe as tracedWriteFileSync,at as trustSystemCertificates,yt as updateLastKnownHash,ne as updateProcessLockPort,Ce as updateServerLockPort,We as validateAgentId,Mt as validateCloneInputs,_o as validateSkillZip,E as waitForServerLockDrain,ln as withHiddenWindowsConsole,ge as withSpan,tn as withSpanSync,gn as writeBundleDecision,le as writeMarkdownlintRule,Le as writeRootGitignoreForNewRepo,ra as writeStateManifest,Ae as writeTargetVersion,kn as writeTracker};
|
package/dist/init-CMXr3PqV.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./dist-By4Q8HCV.mjs";import{v as e}from"./init-DgagwO3Q.mjs";export{e as runInit};
|
package/dist/loader-B_W8tqBx.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./loader-bqg6WDaz.mjs";export{e as loadConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./preview-CpwcPVCo.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./index-CcicSOZg.js";export{e as FeedbackForm};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./ManagedArtifactProperties-9GJ7LIgQ.js";export{e as ManagedArtifactProperties};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{n as r}from"./dist-PQ5KMVDh.js";import{t as i}from"./compiler-runtime-BfE3aGVn.js";import{a,i as o,n as s,r as c}from"./constants-cc1-Bt4QPTUe.js";import{Nt as l,jt as u}from"./schemas-api-WgoIuF0H.js";import{n as d,r as f}from"./use-apply-config-theme-CYFG76sS.js";import{a as p,b as m,c as ee,p as te,r as ne,x as re}from"./use-apply-config-color-theme-CTtLraO9.js";import{C as ie,_ as ae,a as h,c as oe,i as se,n as ce,t as le,w as g}from"./saved-themes-client-DX5dCXi5.js";import{i as ue}from"./use-apply-config-language-9fLQZCsK.js";import{t as de}from"./trace-api-nQInEDYS.js";import{t as fe}from"./status-CUwkWWLj.js";import{a as pe,i as me,n as he,t as ge}from"./css-color-to-hex-pv-EKOQu.js";import{i as _e}from"./client-version-C1mluhO6.js";var ve=i(),_=Math.floor,ye=Math.abs,be=(e,t)=>e<t?e:t,v=(e,t)=>e>t?e:t;Number.isNaN;var xe=e=>e===0?1/e<0:e<0,Se=1<<17,Ce=1<<18,we=1<<19,Te=1<<20,Ee=1<<21,De=1<<22,Oe=1<<23,ke=1<<24,Ae=1<<25,je=1<<26,Me=1<<27,Ne=1<<28,Pe=1<<29;Se-1,Ce-1,we-1,Te-1,Ee-1,De-1,Oe-1,ke-1,Ae-1,je-1,Me-1,Ne-1,Pe-1;var Fe=2**53-1,Ie=-(2**53-1),Le=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&_(e)===e);Number.isNaN,Number.parseInt;var y=()=>new Set,Re=e=>e[e.length-1],ze=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},b=Array.from,Be=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Ve=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},He=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},x=Array.isArray,Ue=String.fromCharCode;String.fromCodePoint,Ue(65535);var We=e=>e.toLowerCase(),Ge=/^\s*/g,Ke=e=>e.replace(Ge,``),qe=/([A-Z])/g,Je=(e,t)=>Ke(e.replace(qe,e=>`${t}${We(e)}`)),Ye=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},Xe=typeof TextEncoder<`u`?new TextEncoder:null,Ze=Xe?e=>Xe.encode(e):Ye,Qe=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Qe&&Qe.decode(new Uint8Array).length===1&&(Qe=null);var $e=(e,t)=>He(t,()=>e).join(``),et=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},tt=()=>new et,nt=e=>{let t=tt();return e(t),S(t)},rt=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},S=e=>{let t=new Uint8Array(rt(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},it=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(v(n,t)*2),e.cpos=0)},C=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},at=C,w=(e,t)=>{for(;t>127;)C(e,128|127&t),t=_(t/128);C(e,127&t)},ot=(e,t)=>{let n=xe(t);for(n&&(t=-t),C(e,(t>63?128:0)|(n?64:0)|63&t),t=_(t/64);t>0;)C(e,(t>127?128:0)|127&t),t=_(t/128)},st=new Uint8Array(3e4),ct=st.length/3,lt=Xe&&Xe.encodeInto?(e,t)=>{if(t.length<ct){let n=Xe.encodeInto(t,st).written||0;w(e,n);for(let t=0;t<n;t++)C(e,st[t])}else T(e,Ze(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;w(e,r);for(let t=0;t<r;t++)C(e,n.codePointAt(t))},ut=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=be(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(v(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},T=(e,t)=>{w(e,t.byteLength),ut(e,t)},dt=(e,t)=>{it(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},ft=(e,t)=>dt(e,4).setFloat32(0,t,!1),pt=(e,t)=>dt(e,8).setFloat64(0,t,!1),mt=(e,t)=>dt(e,8).setBigInt64(0,t,!1),ht=new DataView(new ArrayBuffer(4)),gt=e=>(ht.setFloat32(0,e),ht.getFloat32(0)===e),_t=(e,t)=>{switch(typeof t){case`string`:C(e,119),lt(e,t);break;case`number`:Le(t)&&ye(t)<=2147483647?(C(e,125),ot(e,t)):gt(t)?(C(e,124),ft(e,t)):(C(e,123),pt(e,t));break;case`bigint`:C(e,122),mt(e,t);break;case`object`:if(t===null)C(e,126);else if(x(t)){C(e,117),w(e,t.length);for(let n=0;n<t.length;n++)_t(e,t[n])}else if(t instanceof Uint8Array)C(e,116),T(e,t);else{C(e,118);let n=Object.keys(t);w(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];lt(e,i),_t(e,t[i])}}break;case`boolean`:C(e,t?120:121);break;default:C(e,127)}},vt=class extends et{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&w(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},yt=e=>{e.count>0&&(ot(e.encoder,e.count===1?e.s:-e.s),e.count>1&&w(e.encoder,e.count-2))},bt=class{constructor(){this.encoder=new et,this.s=0,this.count=0}write(e){this.s===e?this.count++:(yt(this),this.count=1,this.s=e)}toUint8Array(){return yt(this),S(this.encoder)}},xt=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);ot(e.encoder,t),e.count>1&&w(e.encoder,e.count-2)}},St=class{constructor(){this.encoder=new et,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(xt(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return xt(this),S(this.encoder)}},Ct=class{constructor(){this.sarr=[],this.s=``,this.lensE=new bt}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new et;return this.sarr.push(this.s),this.s=``,lt(e,this.sarr.join(``)),ut(e,this.lensE.toUint8Array()),S(e)}},E=e=>Error(e),D=()=>{throw E(`Method unimplemented`)},O=()=>{throw E(`Unexpected case`)},wt=E(`Unexpected end of array`),Tt=E(`Integer out of Range`),Et=class{constructor(e){this.arr=e,this.pos=0}},Dt=e=>new Et(e),Ot=e=>e.pos!==e.arr.length,kt=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},k=e=>kt(e,A(e)),At=e=>e.arr[e.pos++],A=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>Fe)throw Tt}throw wt},jt=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>Fe)throw Tt}throw wt},Mt=Qe?e=>Qe.decode(k(e)):e=>{let t=A(e);if(t===0)return``;{let n=String.fromCodePoint(At(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(At(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},Nt=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Pt=[e=>void 0,e=>null,jt,e=>Nt(e,4).getFloat32(0,!1),e=>Nt(e,8).getFloat64(0,!1),e=>Nt(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Mt,e=>{let t=A(e),n={};for(let r=0;r<t;r++){let t=Mt(e);n[t]=Ft(e)}return n},e=>{let t=A(e),n=[];for(let r=0;r<t;r++)n.push(Ft(e));return n},k],Ft=e=>Pt[127-At(e)](e),It=class extends Et{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Ot(this)?this.count=A(this)+1:this.count=-1),this.count--,this.s}},Lt=class extends Et{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=jt(this);let e=xe(this.s);this.count=1,e&&(this.s=-this.s,this.count=A(this)+2)}return this.count--,this.s}},Rt=class extends Et{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=jt(this),t=e&1;this.diff=_(e/2),this.count=1,t&&(this.count=A(this)+2)}return this.s+=this.diff,this.count--,this.s}},zt=class{constructor(e){this.decoder=new Lt(e),this.str=Mt(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}},Bt=function(e){return e[e.Token=0]=`Token`,e[e.PermissionDenied=1]=`PermissionDenied`,e[e.Authenticated=2]=`Authenticated`,e}({}),Vt=(e,t)=>{w(e,Bt.Token),lt(e,t)},Ht=(e,t,n,r)=>{switch(A(e)){case Bt.Token:t();break;case Bt.PermissionDenied:n(Mt(e));break;case Bt.Authenticated:r(Mt(e));break;default:}},Ut=e=>Array.from(e.entries()).map(([e,t])=>({clientId:e,...t})),Wt=`\0`;function Gt(e,t){return e+Wt+t}function Kt(e){let t=e.indexOf(Wt);return t===-1?{documentName:e,sessionId:null}:{documentName:e.substring(0,t),sessionId:e.substring(t+1)}}var qt=function(e){return e[e.Connecting=0]=`Connecting`,e[e.Open=1]=`Open`,e[e.Closing=2]=`Closing`,e[e.Closed=3]=`Closed`,e}({}),j=()=>new Map,Jt=e=>{let t=j();return e.forEach((e,n)=>{t.set(n,e)}),t},M=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Yt=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Xt=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},Zt=class{constructor(){this._observers=j()}on(e,t){return M(this._observers,e,y).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return b((this._observers.get(e)||j()).values()).forEach(e=>e(...t))}destroy(){this._observers=j()}},Qt=class{constructor(){this._observers=j()}on(e,t){M(this._observers,e,y).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return b((this._observers.get(e)||j()).values()).forEach(e=>e(...t))}destroy(){this._observers=j()}};crypto.subtle;var $t=crypto.getRandomValues.bind(crypto),en=Math.random,tn=()=>$t(new Uint32Array(1))[0],nn=e=>e[_(en()*e.length)],rn=`10000000-1000-4000-8000-100000000000`,an=()=>rn.replace(/[018]/g,e=>(e^tn()&15>>e/4).toString(16)),on=Date.now,sn=e=>new Promise(e);Promise.all.bind(Promise);var cn=e=>e===void 0?null:e,ln=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{typeof localStorage<`u`&&localStorage&&(ln=localStorage)}catch{}var un=ln,dn=Symbol(`Equality`),fn=(e,t)=>e===t||!!e?.[dn]?.(t)||!1,pn=e=>typeof e==`object`,mn=Object.assign,hn=Object.keys,gn=(e,t)=>{for(let n in e)t(e[n],n)},_n=e=>hn(e).length,vn=e=>{for(let t in e)return!1;return!0},yn=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},bn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),xn=(e,t)=>e===t||_n(e)===_n(t)&&yn(e,(e,n)=>(e!==void 0||bn(t,n))&&fn(t[n],e)),Sn=Object.freeze,Cn=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&Cn(e[t])}return Sn(e)},wn=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&wn(e,t,n+1)}},Tn=e=>e,En=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[dn]!=null)return e[dn](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!En(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(_n(e)!==_n(t))return!1;for(let n in e)if(!bn(e,n)||!En(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!En(e[n],t[n]))return!1;break;default:return!1}return!0},Dn=(e,t)=>t.includes(e),On=typeof process<`u`&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<`u`?process:0)===`[object process]`,kn=typeof window<`u`&&typeof document<`u`&&!On;typeof navigator<`u`&&/Mac/.test(navigator.platform);var N,An=[],jn=()=>{if(N===void 0)if(On){N=j();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&N.set(t,``),t=r):t===null?An.push(r):(N.set(t,r),t=null)}t!==null&&N.set(t,``)}else typeof location==`object`?(N=j(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);N.set(`--${Je(t,`-`)}`,n),N.set(`-${Je(t,`-`)}`,n)}})):N=j();return N},Mn=e=>jn().has(e),Nn=e=>cn(On?{}[e.toUpperCase().replaceAll(`-`,`_`)]:un.getItem(e)),Pn=e=>Mn(`--`+e)||Nn(e)!==null,Fn=Pn(`production`),In=On&&Dn({}.FORCE_COLOR,[`true`,`1`,`2`])||!Mn(`--no-colors`)&&!Pn(`no-color`)&&(!On||process.stdout.isTTY)&&(!On||Mn(`--color`)||Nn(`COLORTERM`)!==null||(Nn(`TERM`)||``).includes(`color`)),Ln=e=>new Uint8Array(e),Rn=kn?e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=Ue(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),zn=e=>{let t=Ln(e.byteLength);return t.set(e),t},Bn=e=>nt(t=>_t(t,e)),Vn=class{constructor(e,t){this.left=e,this.right=t}},P=(e,t)=>new Vn(e,t),Hn=(e,t)=>e.forEach(e=>t(e.left,e.right)),Un=e=>e.next()>=.5,Wn=(e,t,n)=>_(e.next()*(n+1-t)+t),Gn=(e,t,n)=>_(e.next()*(n+1-t)+t),Kn=(e,t,n)=>Gn(e,t,n),qn=e=>Ue(Kn(e,97,122)),Jn=(e,t=0,n=20)=>{let r=Kn(e,t,n),i=``;for(let t=0;t<r;t++)i+=qn(e);return i},Yn=(e,t)=>t[Kn(e,0,t.length-1)],Xn=Symbol(`0schema`),Zn=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push($e(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
2
|
-
`)}},Qn=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[dn]?fn(e,t):x(e)?Be(e,e=>Ve(t,t=>Qn(e,t))):pn(e)?yn(e,(e,n)=>Qn(e,t[n])):!1,F=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Qn(t,n)}equals(e){return this.constructor===e.constructor&&En(this.shape,e.shape)}[Xn](){return!0}[dn](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){D()}get nullable(){return kr(this,Wr)}get optional(){return new sr(this)}cast(e){return Jr(e,this),e}expect(e){return Jr(e,this),e}},$n=class extends F{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},I=(e,t=null)=>new $n(e,t);I($n);var er=class extends F{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},L=e=>new er(e);I(er);var tr=class extends F{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},nr=(...e)=>new tr(e),rr=I(tr),ir=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),ar=e=>{if(zr.check(e))return[ir(e)];if(rr.check(e))return e.shape.map(e=>e+``);if(Rr.check(e))return[`[+-]?\\d+.?\\d*`];if(Br.check(e))return[`.*`];if(Ar.check(e))return e.shape.map(ar).flat(1);O()};I(class extends F{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(ar).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var or=Symbol(`optional`),sr=class extends F{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[or](){return!0}},cr=I(sr),lr=class extends F{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new lr,I(lr);var ur=class e extends F{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):yn(this.shape,(n,r)=>{let i=this._isPartial&&!bn(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},dr=e=>new ur(e),fr=I(ur),pr=L(e=>e!=null&&(e.constructor===Object||e.constructor==null)),mr=class extends F{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&yn(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},hr=(e,t)=>new mr(e,t),gr=I(mr),_r=class extends F{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&yn(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},vr=(...e)=>new _r(e);I(_r);var yr=class extends F{constructor(e){super(),this.shape=e.length===1?e[0]:new Or(e)}check(e,t){let n=x(e)&&Be(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},br=(...e)=>new yr(e),xr=I(yr),Sr=L(e=>x(e)),Cr=class extends F{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},wr=(e,t=null)=>new Cr(e,t);I(Cr);var Tr=wr(F),Er=I(class extends F{constructor(e){super(),this.len=e.length-1,this.args=vr(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),Dr=L(e=>typeof e==`function`);I(class extends F{constructor(e){super(),this.shape=e}check(e,t){let n=Be(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var Or=class extends F{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=Ve(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},kr=(...e)=>e.findIndex(e=>Ar.check(e))>=0?kr(...e.map(e=>qr(e)).map(e=>Ar.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new Or(e),Ar=I(Or),jr=()=>!0,Mr=L(jr),Nr=I(er,e=>e.shape===jr),Pr=L(e=>typeof e==`bigint`),Fr=L(e=>e===Pr),Ir=L(e=>typeof e==`symbol`);L(e=>e===Ir);var Lr=L(e=>typeof e==`number`),Rr=L(e=>e===Lr),zr=L(e=>typeof e==`string`),Br=L(e=>e===zr),Vr=L(e=>typeof e==`boolean`),Hr=L(e=>e===Vr),Ur=nr(void 0);I(tr,e=>e.shape.length===1&&e.shape[0]===void 0),nr(void 0);var Wr=nr(null),Gr=I(tr,e=>e.shape.length===1&&e.shape[0]===null);I(Uint8Array),I($n,e=>e.shape===Uint8Array);var Kr=kr(Lr,zr,Wr,Ur,Pr,Vr,Ir);(()=>{let e=br(Mr),t=hr(zr,Mr),n=kr(Lr,zr,Wr,Vr,e,t);return e.shape=n,t.shape.values=n,n})();var qr=e=>{if(Tr.check(e))return e;if(pr.check(e)){let t={};for(let n in e)t[n]=qr(e[n]);return dr(t)}else if(Sr.check(e))return kr(...e.map(qr));else if(Kr.check(e))return nr(e);else if(Dr.check(e))return I(e);O()},Jr=Fn?()=>{}:(e,t)=>{let n=new Zn;if(!t.check(e,n))throw E(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},Yr=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:qr(e),h:t}),this}else(e){return this.if(Mr,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw E(`Unhandled pattern`)}}},Xr=(e=>new Yr(e))(Mr).if(Rr,(e,t)=>Wn(t,Ie,Fe)).if(Br,(e,t)=>Jn(t)).if(Hr,(e,t)=>Un(t)).if(Fr,(e,t)=>BigInt(Wn(t,Ie,Fe))).if(Ar,(e,t)=>Zr(t,Yn(t,e.shape))).if(fr,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(cr.check(i)){if(Un(t))continue;i=i.shape}n[r]=Xr(i,t)}return n}).if(xr,(e,t)=>{let n=[],r=Gn(t,0,42);for(let i=0;i<r;i++)n.push(Zr(t,e.shape));return n}).if(rr,(e,t)=>Yn(t,e.shape)).if(Gr,(e,t)=>null).if(Er,(e,t)=>{let n=Zr(t,e.res);return()=>n}).if(Nr,(e,t)=>Zr(t,Yn(t,[Lr,zr,Wr,Ur,Pr,Vr,br(Lr),hr(kr(`a`,`b`,`c`),Lr)]))).if(gr,(e,t)=>{let n={},r=Wn(t,0,3);for(let i=0;i<r;i++){let r=Zr(t,e.shape.keys);n[r]=Zr(t,e.shape.values)}return n}).done(),Zr=(e,t)=>Xr(qr(t),e),R=typeof document<`u`?document:{},Qr=e=>R.createElement(e),$r=()=>R.createDocumentFragment();L(e=>e.nodeType===di);var ei=e=>R.createTextNode(e);typeof DOMParser<`u`&&new DOMParser;var ti=(e,t)=>(Hn(t,(t,n)=>{n===!1?e.removeAttribute(t):n===!0?e.setAttribute(t,``):e.setAttribute(t,n)}),e),ni=e=>{let t=$r();for(let n=0;n<e.length;n++)si(t,e[n]);return t},ri=(e,t)=>(si(e,ni(t)),e),ii=(e,t=[],n=[])=>ri(ti(Qr(e),t),n);L(e=>e.nodeType===ci);var ai=ei;L(e=>e.nodeType===li);var oi=e=>Yt(e,(e,t)=>`${t}:${e};`).join(``),si=(e,t)=>e.appendChild(t),ci=R.ELEMENT_NODE,li=R.TEXT_NODE;R.CDATA_SECTION_NODE,R.COMMENT_NODE;var ui=R.DOCUMENT_NODE;R.DOCUMENT_TYPE_NODE;var di=R.DOCUMENT_FRAGMENT_NODE;L(e=>e.nodeType===ui);var fi=(e=>class{constructor(e){this._=e}destroy(){e(this._)}})(clearTimeout),pi=(e,t)=>new fi(setTimeout(t,e)),mi=Symbol,hi=mi(),gi=mi(),_i=mi(),vi=mi(),yi=mi(),bi=mi(),xi=mi(),Si=mi(),Ci=mi(),wi=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(n===void 0)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(``));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n};on();var Ti={[hi]:P(`font-weight`,`bold`),[gi]:P(`font-weight`,`normal`),[_i]:P(`color`,`blue`),[yi]:P(`color`,`green`),[vi]:P(`color`,`grey`),[bi]:P(`color`,`red`),[xi]:P(`color`,`purple`),[Si]:P(`color`,`orange`),[Ci]:P(`color`,`black`)},Ei=In?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=j(),i=[],a=0;for(;a<e.length;a++){let i=e[a],o=Ti[i];if(o!==void 0)r.set(o.left,o.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let e=oi(r);a>0||e.length>0?(t.push(`%c`+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n,i.unshift(t.join(``)));a<e.length;a++){let t=e[a];t instanceof Symbol||i.push(t)}return i}:wi,Di=(...e)=>{console.log(...Ei(e)),ki.forEach(t=>t.print(e))},Oi=(...e)=>{console.warn(...Ei(e)),e.unshift(Si),ki.forEach(t=>t.print(e))},ki=y(),Ai=e=>({[Symbol.iterator](){return this},next:e}),ji=(e,t)=>Ai(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),Mi=(e,t)=>Ai(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),Ni=class{constructor(e,t){this.clock=e,this.len=t}},Pi=class{constructor(){this.clients=new Map}},Fi=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])Xa(e,i,o.clock,o.len,n)}}),Ii=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=_((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},Li=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&Ii(n,t.clock)!==null},Ri=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new Ni(r.clock,v(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},zi=e=>{let t=new Pi;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)ze(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return Ri(t),t},Bi=(e,t,n,r)=>{M(e.clients,t,()=>[]).push(new Ni(n,r))},Vi=()=>new Pi,Hi=e=>{let t=Vi();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new Ni(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Ui=(e,t)=>{w(e.restEncoder,t.clients.size),b(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),w(e.restEncoder,t);let r=n.length;w(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Wi=e=>{let t=new Pi,n=A(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=A(e.restDecoder),r=A(e.restDecoder);if(r>0){let i=M(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new Ni(e.readDsClock(),e.readDsLen()))}}return t},Gi=(e,t,n)=>{let r=new Pi,i=A(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=A(e.restDecoder),a=A(e.restDecoder),o=n.clients.get(i)||[],s=B(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&Bi(r,i,s,a-s);let e=V(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,lc(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,lc(t,c,a-c.id.clock)),c.delete(t))}else Bi(r,i,n,a-n)}}if(r.clients.size>0){let e=new ta;return w(e.restEncoder,0),Ui(e,r),e.toUint8Array()}return null},Ki=tn,qi=class e extends Zt{constructor({guid:e=an(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=Ki(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Ua,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=sn(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>sn(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&U(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(b(this.subdocs).map(e=>e.guid))}transact(e,t=null){return U(this,e,t)}get(e,t=G){let n=M(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==G&&r!==t)if(r===G){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=``){return this.get(e,$o)}getText(e=``){return this.get(e,bs)}getMap(e=``){return this.get(e,ns)}getXmlElement(e=``){return this.get(e,Ts)}getXmlFragment(e=``){return this.get(e,Cs)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,b(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,U(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},Ji=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return A(this.restDecoder)}readDsLen(){return A(this.restDecoder)}},Yi=class extends Ji{readLeftID(){return z(A(this.restDecoder),A(this.restDecoder))}readRightID(){return z(A(this.restDecoder),A(this.restDecoder))}readClient(){return A(this.restDecoder)}readInfo(){return At(this.restDecoder)}readString(){return Mt(this.restDecoder)}readParentInfo(){return A(this.restDecoder)===1}readTypeRef(){return A(this.restDecoder)}readLen(){return A(this.restDecoder)}readAny(){return Ft(this.restDecoder)}readBuf(){return zn(k(this.restDecoder))}readJSON(){return JSON.parse(Mt(this.restDecoder))}readKey(){return Mt(this.restDecoder)}},Xi=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=A(this.restDecoder),this.dsCurrVal}readDsLen(){let e=A(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Zi=class extends Xi{constructor(e){super(e),this.keys=[],A(e),this.keyClockDecoder=new Rt(k(e)),this.clientDecoder=new Lt(k(e)),this.leftClockDecoder=new Rt(k(e)),this.rightClockDecoder=new Rt(k(e)),this.infoDecoder=new It(k(e),At),this.stringDecoder=new zt(k(e)),this.parentInfoDecoder=new It(k(e),At),this.typeRefDecoder=new Lt(k(e)),this.lenDecoder=new Lt(k(e))}readLeftID(){return new wa(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new wa(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Ft(this.restDecoder)}readBuf(){return k(this.restDecoder)}readJSON(){return Ft(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},Qi=class{constructor(){this.restEncoder=tt()}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){w(this.restEncoder,e)}writeDsLen(e){w(this.restEncoder,e)}},$i=class extends Qi{writeLeftID(e){w(this.restEncoder,e.client),w(this.restEncoder,e.clock)}writeRightID(e){w(this.restEncoder,e.client),w(this.restEncoder,e.clock)}writeClient(e){w(this.restEncoder,e)}writeInfo(e){at(this.restEncoder,e)}writeString(e){lt(this.restEncoder,e)}writeParentInfo(e){w(this.restEncoder,+!!e)}writeTypeRef(e){w(this.restEncoder,e)}writeLen(e){w(this.restEncoder,e)}writeAny(e){_t(this.restEncoder,e)}writeBuf(e){T(this.restEncoder,e)}writeJSON(e){lt(this.restEncoder,JSON.stringify(e))}writeKey(e){lt(this.restEncoder,e)}},ea=class{constructor(){this.restEncoder=tt(),this.dsCurrVal=0}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,w(this.restEncoder,t)}writeDsLen(e){e===0&&O(),w(this.restEncoder,e-1),this.dsCurrVal+=e}},ta=class extends ea{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new St,this.clientEncoder=new bt,this.leftClockEncoder=new St,this.rightClockEncoder=new St,this.infoEncoder=new vt(at),this.stringEncoder=new Ct,this.parentInfoEncoder=new vt(at),this.typeRefEncoder=new bt,this.lenEncoder=new bt}toUint8Array(){let e=tt();return w(e,0),T(e,this.keyClockEncoder.toUint8Array()),T(e,this.clientEncoder.toUint8Array()),T(e,this.leftClockEncoder.toUint8Array()),T(e,this.rightClockEncoder.toUint8Array()),T(e,S(this.infoEncoder)),T(e,this.stringEncoder.toUint8Array()),T(e,S(this.parentInfoEncoder)),T(e,this.typeRefEncoder.toUint8Array()),T(e,this.lenEncoder.toUint8Array()),ut(e,S(this.restEncoder)),S(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(+!!e)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){_t(this.restEncoder,e)}writeBuf(e){T(this.restEncoder,e)}writeJSON(e){_t(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},na=(e,t,n,r)=>{r=v(r,t[0].id.clock);let i=V(t,r);w(e.restEncoder,t.length-i),e.writeClient(n),w(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},ra=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{B(t,n)>e&&r.set(n,e)}),Wa(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),w(e.restEncoder,r.size),b(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{na(e,t.clients.get(n),n,r)})},ia=(e,t)=>{let n=j(),r=A(e.restDecoder);for(let i=0;i<r;i++){let r=A(e.restDecoder),i=Array(r),a=e.readClient(),o=A(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new K(z(a,o),t),o+=t;break}case 10:{let t=A(e.restDecoder);i[n]=new Y(z(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new J(z(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,fc(e,r));i[n]=c,o+=c.length}}}}return n},aa=(e,t,n)=>{let r=[],i=b(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new Ua,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==Y){let i=M(d,u.id.client,()=>B(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,B(t,a)),f();else{u=e.refs[e.i++];continue}}else (i===0||i<u.length)&&(u.integrate(e,i),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new ta;return ra(e,s,new Map),w(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},oa=(e,t)=>ra(e,t.doc.store,t.beforeState),sa=(e,t,n,r=new Zi(e))=>U(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=aa(e,i,ia(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<B(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=o.missing.get(e);(n==null||n>t)&&o.missing.set(e,t)}o.update=mo([o.update,a.update])}}else i.pendingStructs=a;let s=Gi(r,e,i);if(i.pendingDs){let t=new Zi(Dt(i.pendingDs));A(t.restDecoder);let n=Gi(t,e,i);s&&n?i.pendingDs=mo([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,ca(e.doc,t)}},n,!1),ca=(e,t,n,r=Zi)=>{let i=Dt(t);sa(i,e,n,new r(i))},la=(e,t,n)=>ca(e,t,n,Yi),ua=(e,t,n=new Map)=>{ra(e,t.store,n),Ui(e,Hi(t.store))},da=(e,t=new Uint8Array([0]),n=new ta)=>{ua(n,e,ma(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(ho(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===$i)return fo(r.map((e,t)=>t===0?e:bo(e)));if(n.constructor===ta)return mo(r)}return r[0]},fa=(e,t)=>da(e,t,new $i),pa=e=>{let t=new Map,n=A(e.restDecoder);for(let r=0;r<n;r++){let n=A(e.restDecoder),r=A(e.restDecoder);t.set(n,r)}return t},ma=e=>pa(new Ji(Dt(e))),ha=(e,t)=>(w(e.restEncoder,t.size),b(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{w(e.restEncoder,t),w(e.restEncoder,n)}),e),ga=(e,t)=>ha(e,Wa(t.store)),_a=(e,t=new ea)=>(e instanceof Map?ha(t,e):ga(t,e),t.toUint8Array()),va=e=>_a(e,new Qi),ya=class{constructor(){this.l=[]}},ba=()=>new ya,xa=(e,t)=>e.l.push(t),Sa=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error(`[yjs] Tried to remove event handler that doesn't exist.`)},Ca=(e,t,n)=>wn(e.l,[t,n]),wa=class{constructor(e,t){this.client=e,this.clock=t}},Ta=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,z=(e,t)=>new wa(e,t),Ea=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw O()},Da=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},Oa=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},ka=e=>{let t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},Aa=e=>new Oa(e.type==null?null:z(e.type.client,e.type.clock),e.tname??null,e.item==null?null:z(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),ja=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},Ma=(e,t,n=0)=>new ja(e,t,n),Na=(e,t,n)=>{let r=null,i=null;return e._item===null?i=Ea(e):r=z(e._item.id.client,e._item.id.clock),new Oa(r,i,t,n)},Pa=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Na(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return Na(e,z(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Na(e,r.lastId,n);r=r.right}return Na(e,null,n)},Fa=(e,t)=>{let n=Ka(e,t);return{item:n,diff:t.clock-n.id.clock}},Ia=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(B(r,i.client)<=i.clock)return null;let e=n?sc(r,i):Fa(r,i),t=e.item;if(!(t instanceof J))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(B(r,a.client)<=a.clock)return null;let{item:e}=n?sc(r,a):{item:Ka(r,a)};if(e instanceof J&&e.content instanceof ac)c=e.content.type;else return null}else throw O();l=s>=0?c._length:0}return Ma(c,l,e.assoc)},La=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Ta(e.item,t.item)&&Ta(e.type,t.type)&&e.assoc===t.assoc,Ra=class{constructor(e,t){this.ds=e,this.sv=t}},za=(e,t)=>new Ra(e,t);za(Vi(),new Map);var Ba=e=>za(Hi(e.store),Wa(e.store)),Va=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Li(t.ds,e.id),Ha=(e,t)=>{let n=M(e.meta,Ha,y),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<B(r,n)&&H(e,z(n,t))}),Fi(e,t.ds,e=>{}),n.add(t))},Ua=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Wa=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},B=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},Ga=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw O()}n.push(t)},V=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=_(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=_((n+r)/2)}throw O()},Ka=(e,t)=>{let n=e.clients.get(t.client);return n[V(n,t.clock)]},qa=(e,t,n)=>{let r=V(t,n),i=t[r];return i.id.clock<n&&i instanceof J?(t.splice(r+1,0,lc(e,i,n-i.id.clock)),r+1):r},H=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[qa(e,n,t.clock)]},Ja=(e,t,n)=>{let r=t.clients.get(n.client),i=V(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==K&&r.splice(i+1,0,lc(e,a,n.clock-a.id.clock+1)),a},Ya=(e,t,n)=>{let r=e.clients.get(t.id.client);r[V(r,t.id.clock)]=n},Xa=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=qa(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&qa(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Za=class{constructor(e,t,n){this.doc=e,this.deleteSet=new Pi,this.beforeState=Wa(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},Qa=(e,t)=>t.deleteSet.clients.size===0&&!Xt(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(Ri(t.deleteSet),oa(e,t),Ui(e,t.deleteSet),!0),$a=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&M(e.changed,t,y).add(n)},eo=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof J&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},to=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=V(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof J&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},no=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=be(r.length-1,1+V(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+eo(r,e)}})},ro=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{Ri(a),n.afterState=Wa(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{Ca(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&_s(n)})}),wn(e,[])}finally{r.gc&&to(a,i,r.gcFilter),no(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=v(V(e,r),1);for(let t=e.length-1;t>=n;)t-=1+eo(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=V(r,n);a+1<r.length&&eo(r,a+1)>1||a>0&&eo(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(Di(Si,hi,`[yjs] `,gi,bi,`Changed the client-id because another client seems to be using it.`),r.clientID=Ki()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new $i;Qa(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new ta;Qa(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):ro(e,t+1)}}},U=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Za(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&ro(i,0)}}return o},io=class{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}},ao=(e,t,n)=>{Fi(e,n.deletions,n=>{n instanceof J&&t.scope.some(t=>t===e.doc||Da(t,n))&&cc(n,!1)})},oo=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;U(i,n=>{for(;t.length>0&&e.currStackItem===null;){let r=i.store,o=t.pop(),s=new Set,c=[],l=!1;Fi(n,o.insertions,e=>{if(e instanceof J){if(e.redone!==null){let{item:t,diff:i}=sc(r,e.id);i>0&&(t=H(n,z(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||Da(t,e))&&c.push(e)}}),Fi(n,o.deletions,e=>{e instanceof J&&a.some(t=>t===n.doc||Da(t,e))&&!Li(o.insertions,e.id)&&s.add(e)}),s.forEach(t=>{l=dc(n,t,s,o.insertions,e.ignoreRemoteMapChanges,e)!==null||l});for(let t=c.length-1;t>=0;t--){let r=c[t];e.deleteFilter(r)&&(r.delete(n),l=!0)}e.currStackItem=l?o:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let o=e.currStackItem;if(o!=null){let t=r.changedParentTypes;e.emit(`stack-item-popped`,[{stackItem:o,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return o},so=class extends Zt{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:o=x(e)?e[0].doc:e instanceof qi?e:e.doc}={}){super(),this.scope=[],this.doc=o,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new Pi;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&Bi(i,n,r,a)});let a=on(),o=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=zi([t.deletions,e.deleteSet]),t.insertions=zi([t.insertions,i])}else r.push(new io(e.deleteSet,i)),o=!0;!t&&!n&&(this.lastChange=a),Fi(e,e.deleteSet,t=>{t instanceof J&&this.scope.some(n=>n===e.doc||Da(n,t))&&cc(t,!0)});let s=[{stackItem:r[r.length-1],origin:e.origin,type:t?`redo`:`undo`,changedParentTypes:e.changedParentTypes},this];o?this.emit(`stack-item-added`,s):this.emit(`stack-item-updated`,s)},this.doc.on(`afterTransaction`,this.afterTransactionHandler),this.doc.on(`destroy`,()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);e=x(e)?e:[e],e.forEach(e=>{t.has(e)||(t.add(e),(e instanceof G?e.doc!==this.doc:e!==this.doc)&&Oi(`[yjs#509] Not same Y.Doc`),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>ao(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>ao(n,this,e)),this.redoStack=[]),this.emit(`stack-cleared`,[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=oo(this,this.undoStack,`undo`)}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=oo(this,this.redoStack,`redo`)}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off(`afterTransaction`,this.afterTransactionHandler),super.destroy()}};function*co(e){let t=A(e.restDecoder);for(let n=0;n<t;n++){let t=A(e.restDecoder),n=e.readClient(),r=A(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=A(e.restDecoder);yield new Y(z(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new J(z(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,fc(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new K(z(n,r),t),r+=t}}}}var lo=class{constructor(e,t){this.gen=co(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Y);return this.curr}},uo=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},fo=e=>mo(e,Yi,$i),po=(e,t)=>{if(e.constructor===K){let{client:n,clock:r}=e.id;return new K(z(n,r+t),e.length-t)}else if(e.constructor===Y){let{client:n,clock:r}=e.id;return new Y(z(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new J(z(r,i+t),null,z(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},mo=(e,t=Zi,n=ta)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(Dt(e))),i=r.map(e=>new lo(e,!0)),a=null,o=new n,s=new uo(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===Y?1:-1:n}else return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)_o(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===Y)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{_o(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new Y(z(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===Y?a.struct.length-=t:n=po(n,t)),a.struct.mergeWith(n)||(_o(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==Y;n=e.next())_o(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(_o(s,a.struct,a.offset),a=null),vo(s),Ui(o,zi(r.map(e=>Wi(e)))),o.toUint8Array()},ho=(e,t,n=Zi,r=ta)=>{let i=ma(t),a=new r,o=new uo(a),s=new n(Dt(e)),c=new lo(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===Y){c.next();continue}if(e.id.clock+e.length>n)for(_o(o,e,v(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)_o(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return vo(o),Ui(a,Wi(s)),a.toUint8Array()},go=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:S(e.encoder.restEncoder)}),e.encoder.restEncoder=tt(),e.written=0)},_o=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&go(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),w(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},vo=e=>{go(e);let t=e.encoder.restEncoder;w(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];w(t,r.written),ut(t,r.restEncoder)}},yo=(e,t,n,r)=>{let i=new n(Dt(e)),a=new lo(i,!1),o=new r,s=new uo(o);for(let e=a.curr;e!==null;e=a.next())_o(s,t(e),0);return vo(s),Ui(o,Wi(i)),o.toUint8Array()},bo=e=>yo(e,Tn,Zi,$i),xo=`You must not compute changes after the event-handler fired.`,So=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||=Co(this.currentTarget,this.target)}deletes(e){return Li(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw E(xo);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r))if(e!==null&&this.deletes(e))i=`delete`,a=Re(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=Re(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=Re(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw E(xo);let t=this.target,n=y(),r=y(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},Co=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},W=()=>{Oi(`Invalid access: Add Yjs type to a document before reading data.`)},wo=80,To=0,Eo=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=To++}},Do=e=>{e.timestamp=To++},Oo=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=To++},ko=(e,t,n)=>{if(e.length>=wo){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return Oo(r,t,n),r}else{let r=new Eo(t,n);return e.push(r),r}},Ao=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>ye(t-e.index)<ye(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,Do(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&ye(n.index-i)<r.parent.length/wo?(Oo(n,r,i),n):ko(e._searchMarker,r,i)},jo=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=v(t,i.index+n))}},Mo=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;M(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Ca(r._eH,n,t)},G=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=ba(),this._dEH=ba(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw D()}clone(){throw D()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){xa(this._eH,e)}observeDeep(e){xa(this._dEH,e)}unobserve(e){Sa(this._eH,e)}unobserveDeep(e){Sa(this._dEH,e)}toJSON(){}},No=(e,t,n)=>{e.doc??W(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},Po=e=>{e.doc??W();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},Fo=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&Va(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},Io=(e,t)=>{let n=0,r=e._start;for(e.doc??W();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},Lo=(e,t)=>{let n=[];return Io(e,(r,i)=>{n.push(t(r,i,e))}),n},Ro=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},zo=(e,t)=>{e.doc??W();let n=Ao(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},Bo=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new J(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new qs(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new J(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Ps(new Uint8Array(n))),i.integrate(e,0);break;case qi:i=new J(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new zs(n)),i.integrate(e,0);break;default:if(n instanceof G)i=new J(z(o,B(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new ac(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},Vo=()=>E(`Length exceeded!`),Ho=(e,t,n,r)=>{if(n>t._length)throw Vo();if(n===0)return t._searchMarker&&jo(t._searchMarker,n,r.length),Bo(e,t,null,r);let i=n,a=Ao(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&H(e,z(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&jo(t._searchMarker,i,r.length),Bo(e,t,o,r)},Uo=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return Bo(e,t,r,n)},Wo=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=Ao(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&H(e,z(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&H(e,z(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw Vo();t._searchMarker&&jo(t._searchMarker,i,-a+r)},Go=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Ko=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new qs([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new qs([r]);break;case Uint8Array:s=new Ps(r);break;case qi:s=new zs(r);break;default:if(r instanceof G)s=new ac(r);else throw Error(`Unexpected content type`)}new J(z(o,B(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},qo=(e,t)=>{e.doc??W();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Jo=e=>{let t={};return e.doc??W(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},Yo=(e,t)=>{e.doc??W();let n=e._map.get(t);return n!==void 0&&!n.deleted},Xo=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&Va(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},Zo=e=>(e.doc??W(),ji(e._map.entries(),e=>!e[1].deleted)),Qo=class extends So{},$o=class e extends G{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof G?e.clone():e)),t}get length(){return this.doc??W(),this._length}_callObserver(e,t){super._callObserver(e,t),Mo(this,e,new Qo(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):U(this.doc,n=>{Ho(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):U(this.doc,t=>{Uo(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):U(this.doc,n=>{Wo(n,this,e,t)})}get(e){return zo(this,e)}toArray(){return Po(this)}slice(e=0,t=this.length){return No(this,e,t)}toJSON(){return this.map(e=>e instanceof G?e.toJSON():e)}map(e){return Lo(this,e)}forEach(e){Io(this,e)}[Symbol.iterator](){return Ro(this)}_write(e){e.writeTypeRef(Qs)}},es=e=>new $o,ts=class extends So{constructor(e,t,n){super(e,t),this.keysChanged=n}},ns=class e extends G{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof G?e.clone():e)}),t}_callObserver(e,t){Mo(this,e,new ts(this,e,t))}toJSON(){this.doc??W();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof G?r.toJSON():r}}),e}get size(){return[...Zo(this)].length}keys(){return Mi(Zo(this),e=>e[0])}values(){return Mi(Zo(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Mi(Zo(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??W(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):U(this.doc,t=>{Go(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):U(this.doc,n=>{Ko(n,this,e,t)}),t}get(e){return qo(this,e)}has(e){return Yo(this,e)}clear(){this.doc===null?this._prelimContent.clear():U(this.doc,e=>{this.forEach(function(t,n,r){Go(e,r,n)})})}_write(e){e.writeTypeRef($s)}},rs=e=>new ns,is=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&xn(e,t),as=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&O(),this.right.content.constructor){case q:this.right.deleted||ls(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}},os=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case q:t.right.deleted||ls(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&H(e,z(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},ss=(e,t,n,r)=>{let i=new Map,a=r?Ao(t,n):null;return a?os(e,new as(a.p.left,a.p,a.index,i),n-a.index):os(e,new as(null,t._start,0,i),n)},cs=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===q&&is(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new J(z(a,B(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new q(o,r));l.integrate(e,0),n.right=l,n.forward()})},ls=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},us=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===q&&is(t[e.right.content.key]??null,e.right.content.value));)e.forward()},ds=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!is(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new J(z(a,B(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new q(s,c)),n.right.integrate(e,0),n.forward()}}return o},fs=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;us(n,i);let s=ds(e,t,n,i),c=r.constructor===String?new Ys(r):r instanceof G?new ac(r):new Vs(r),{left:l,right:u,index:d}=n;t._searchMarker&&jo(t._searchMarker,n.index,c.getLength()),u=new J(z(o,B(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),cs(e,t,n,s)},ps=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;us(n,i);let s=ds(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===q));){if(!n.right.deleted)switch(n.right.content.constructor){case q:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(is(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&H(e,z(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
|
|
3
|
-
`;n.right=new J(z(o,B(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Ys(i)),n.right.integrate(e,0),n.forward()}cs(e,t,n,s)},ms=(e,t,n,r,i)=>{let a=t,o=j();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===q){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case q:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&ls(i,n);break}}}t=t.right}return s},hs=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===q){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},gs=e=>{let t=0;return U(e.doc,n=>{let r=e._start,i=e._start,a=j(),o=Jt(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case q:ls(o,i.content);break;default:t+=ms(n,r,i,a,o),a=Jt(o),r=i;break}i=i.right}}),t},_s=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&Xa(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===q&&e.constructor!==K&&t.add(e.parent)})}U(n,n=>{Fi(e,e.deleteSet,e=>{if(e instanceof K||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===q?t.add(r):hs(n,e)});for(let e of t)gs(e)})},vs=(e,t,n)=>{let r=n,i=Jt(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case ac:case Vs:case Ys:n<t.right.length&&H(e,z(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&ms(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&jo(o._searchMarker,t.index,-r+n),t},ys=class extends So{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){return this._changes===null&&(this._changes={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set}),this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];U(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},vn(o)||(e.attributes=mn({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case ac:case Vs:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case Ys:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case q:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(is(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),is(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;is(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(is(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),ls(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},bs=class e extends G{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??W(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new ys(this,e,t);Mo(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??W();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Ys&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):U(this.doc,n=>{let r=new as(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
|
|
4
|
-
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&fs(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&vs(n,r,a.delete):ps(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??W();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(Va(s,e)||t!==void 0&&Va(s,t))switch(s.content.constructor){case Ys:{let r=i.get(`ychange`);e!==void 0&&!Va(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!Va(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case ac:case Vs:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case q:Va(s,e)&&(c(),ls(i,s.content));break}s=s.right}c()};return e||t?U(a,n=>{e&&Ha(n,e),t&&Ha(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):U(r,r=>{let i=ss(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),fs(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):U(r,r=>{let i=ss(r,this,e,!n);fs(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):U(n,n=>{vs(n,ss(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):U(r,r=>{let i=ss(r,this,e,!1);i.right!==null&&ps(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):U(this.doc,t=>{Go(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):U(this.doc,n=>{Ko(n,this,e,t)})}getAttribute(e){return qo(this,e)}getAttributes(){return Jo(this)}_write(e){e.writeTypeRef(ec)}},xs=e=>new bs,Ss=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??W()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===Ts||t.constructor===Cs)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}else e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},Cs=class e extends G{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof G?e.clone():e)),t}get length(){return this.doc??W(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Ss(this,e)}querySelector(e){e=e.toUpperCase();let t=new Ss(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),b(new Ss(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Mo(this,e,new Ds(this,t,e))}toString(){return Lo(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),Io(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):U(this.doc,n=>{Ho(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)U(this.doc,n=>{let r=e&&e instanceof G?e._item:e;Bo(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw E(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):U(this.doc,n=>{Wo(n,this,e,t)})}toArray(){return Po(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return zo(this,e)}slice(e=0,t=this.length){return No(this,e,t)}forEach(e){Io(this,e)}_write(e){e.writeTypeRef(nc)}},ws=e=>new Cs,Ts=class e extends Cs{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return gn(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof G?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):U(this.doc,t=>{Go(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):U(this.doc,n=>{Ko(n,this,e,t)})}getAttribute(e){return qo(this,e)}hasAttribute(e){return Yo(this,e)}getAttributes(e){return e?Xo(this,e):Jo(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return Io(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(tc),e.writeKey(this.nodeName)}},Es=e=>new Ts(e.readKey()),Ds=class extends So{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},Os=class e extends ns{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(rc),e.writeKey(this.hookName)}},ks=e=>new Os(e.readKey()),As=class e extends bs{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(ic)}},js=e=>new As,Ms=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw D()}mergeWith(e){return!1}write(e,t,n){throw D()}integrate(e,t){throw D()}},Ns=0,K=class extends Ms{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Ga(e.doc.store,this)}write(e,t){e.writeInfo(Ns),e.writeLen(this.length-t)}getMissing(e,t){return null}},Ps=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw D()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},Fs=e=>new Ps(e.readBuf()),Is=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Bi(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}},Ls=e=>new Is(e.readLen()),Rs=(e,t)=>new qi({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),zs=class e{constructor(e){e._item&&console.error(`This document was already integrated as a sub-document. You should create a second instance instead with the same guid.`),this.doc=e;let t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(Rs(this.doc.guid,this.opts))}splice(e){throw D()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},Bs=e=>new zs(Rs(e.readString(),e.readAny())),Vs=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw D()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},Hs=e=>new Vs(e.readJSON()),q=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw D()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},Us=e=>new q(e.readKey(),e.readJSON()),Ws=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}},Gs=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new Ws(n)},Ks=Nn(`node_env`)===`development`,qs=class e{constructor(e){this.arr=e,Ks&&Cn(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},Js=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new qs(n)},Ys=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}},Xs=e=>new Ys(e.readString()),Zs=[es,rs,xs,Es,ws,ks,js],Qs=0,$s=1,ec=2,tc=3,nc=4,rc=5,ic=6,ac=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw D()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},oc=e=>new ac(Zs[e.readTypeRef()](e)),sc=(e,t)=>{let n=t,r=0,i;do r>0&&(n=z(n.client,n.clock+r)),i=Ka(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof J);return{item:i,diff:r}},cc=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},lc=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new J(z(r,i+n),t,z(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=z(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},uc=(e,t)=>Ve(e,e=>Li(e.deletions,t)),dc=(e,t,n,r,i,a)=>{let o=e.doc,s=o.store,c=o.clientID,l=t.redone;if(l!==null)return H(e,l);let u=t.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||dc(e,u,n,r,i,a)===null))return null;for(;u.redone!==null;)u=H(e,u.redone)}let p=u===null?t.parent:u.content.type;if(t.parentSub===null){for(d=t.left,f=t;d!==null;){let t=d;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:H(e,t.redone);if(t!==null&&t.parent._item===u){d=t;break}d=d.left}for(;f!==null;){let t=f;for(;t!==null&&t.parent._item!==u;)t=t.redone===null?null:H(e,t.redone);if(t!==null&&t.parent._item===u){f=t;break}f=f.right}}else{if(f=null,t.right&&!i){for(d=t;d!==null&&d.right!==null&&(d.right.redone||Li(r,d.right.id)||uc(a.undoStack,d.right.id)||uc(a.redoStack,d.right.id));)for(d=d.right;d.redone;)d=H(e,d.redone);if(d&&d.right!==null)return null}else d=p._map.get(t.parentSub)||null;d!==null&&d.parent._item!==u&&(d=p._map.get(t.parentSub)||null)}let m=z(c,B(s,c)),ee=new J(m,d,d&&d.lastId,f,f&&f.id,p,t.parentSub,t.content.copy());return t.redone=m,cc(ee,!0),ee.integrate(e,0),ee},J=class e extends Ms{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=B(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=B(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===wa&&this.id.client!==this.parent.client&&this.parent.clock>=B(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Ja(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=H(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===K||this.right&&this.right.constructor===K)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===wa){let e=Ka(n,this.parent);e.constructor===K?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Ja(e,e.doc.store,z(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),Ta(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(Ta(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Ka(e.doc.store,n.origin)))r.has(Ka(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null)this.right=this.left.right,this.left.right=this;else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Ga(e.doc.store,this),this.content.integrate(e,this),$a(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new K(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:z(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Ta(e.origin,this.lastId)&&this.right===e&&Ta(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),Bi(e.deleteSet,this.id.client,this.id.clock,this.length),$a(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw O();this.content.gc(e),t?Ya(e,this,new K(this.id,this.length)):this.content=new Is(this.length)}write(e,t){let n=t>0?z(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=Ea(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===wa?(e.writeParentInfo(!1),e.writeLeftID(t)):O();i!==null&&e.writeString(i)}this.content.write(e,t)}},fc=(e,t)=>pc[t&31](e),pc=[()=>{O()},Ls,Gs,Fs,Xs,Hs,Us,oc,Js,Bs,()=>{O()}],mc=10,Y=class extends Ms{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){O()}write(e,t){e.writeInfo(mc),w(e.restEncoder,this.length-t)}getMissing(e,t){return null}},hc=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:{},gc=`__ $YJS$ __`;hc[gc]===!0&&console.error(`Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438`),hc[gc]=!0;function _c(e){return e||={},{delay:e.delay===void 0?200:e.delay,initialDelay:e.initialDelay===void 0?0:e.initialDelay,minDelay:e.minDelay===void 0?0:e.minDelay,maxDelay:e.maxDelay===void 0?0:e.maxDelay,factor:e.factor===void 0?0:e.factor,maxAttempts:e.maxAttempts===void 0?3:e.maxAttempts,timeout:e.timeout===void 0?0:e.timeout,jitter:e.jitter===!0,initialJitter:e.initialJitter===!0,handleError:e.handleError===void 0?null:e.handleError,handleTimeout:e.handleTimeout===void 0?null:e.handleTimeout,beforeAttempt:e.beforeAttempt===void 0?null:e.beforeAttempt,calculateDelay:e.calculateDelay===void 0?null:e.calculateDelay}}async function vc(e){return new Promise(t=>setTimeout(t,e))}function yc(e,t){let n=t.delay;if(n===0)return 0;if(t.factor&&(n*=t.factor**(e.attemptNum-1),t.maxDelay!==0&&(n=Math.min(n,t.maxDelay))),t.jitter){let e=Math.ceil(t.minDelay);n=Math.floor(Math.random()*(Math.floor(n)-e+1))+e}return Math.round(n)}async function bc(e,t){let n=_c(t);for(let e of[`delay`,`initialDelay`,`minDelay`,`maxDelay`,`maxAttempts`,`timeout`]){let t=n[e];if(!Number.isInteger(t)||t<0)throw Error(`Value for ${e} must be an integer greater than or equal to 0`)}if(n.factor.constructor!==Number||n.factor<0)throw Error(`Value for factor must be a number greater than or equal to 0`);if(n.delay<n.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${n.delay}, minDelay: ${n.minDelay}`);let r={attemptNum:0,attemptsRemaining:n.maxAttempts?n.maxAttempts:-1,aborted:!1,abort(){r.aborted=!0}},i=n.calculateDelay||yc;async function a(){if(n.beforeAttempt&&n.beforeAttempt(r,n),r.aborted){let e=Error(`Attempt aborted`);throw e.code=`ATTEMPT_ABORTED`,e}let t=async e=>{if(n.handleError&&await n.handleError(e,r,n),r.aborted||r.attemptsRemaining===0)throw e;r.attemptNum++;let t=i(r,n);return t&&await vc(t),a()};return r.attemptsRemaining>0&&r.attemptsRemaining--,n.timeout?new Promise((i,a)=>{let o=setTimeout(()=>{if(n.handleTimeout)try{i(n.handleTimeout(r,n))}catch(e){a(e)}else{let e=Error(`Retry timeout (attemptNum: ${r.attemptNum}, timeout: ${n.timeout})`);e.code=`ATTEMPT_TIMEOUT`,a(e)}},n.timeout);e(r,n).then(e=>{clearTimeout(o),i(e)}).catch(e=>{clearTimeout(o),t(e).then(i).catch(a)})}):e(r,n).catch(t)}let o=n.calculateDelay?n.calculateDelay(r,n):n.initialDelay;if(o&&await vc(o),r.attemptNum<1&&n.initialJitter){let e=i(r,n);e&&await vc(e)}return a()}var xc=Math.floor,Sc=(e,t)=>e<t?e:t,Cc=(e,t)=>e>t?e:t;Number.isNaN;var wc=64,Tc=128,Ec=1<<17,Dc=1<<18,Oc=1<<19,kc=1<<20,Ac=1<<21,jc=1<<22,Mc=1<<23,Nc=1<<24,Pc=1<<25,Fc=1<<26,Ic=1<<27,Lc=1<<28,Rc=1<<29,zc=1<<30,Bc=63,Vc=127;Ec-1,Dc-1,Oc-1,kc-1,Ac-1,jc-1,Mc-1,Nc-1,Pc-1,Fc-1,Ic-1,Lc-1,Rc-1,zc-1;var Hc=2**53-1;Number.isInteger,Number.isNaN,Number.parseInt;var Uc=()=>new Set,Wc=Array.from;Array.isArray;var Gc=String.fromCharCode;String.fromCodePoint,Gc(65535);var Kc=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},qc=typeof TextEncoder<`u`?new TextEncoder:null,Jc=qc?e=>qc.encode(e):Kc,Yc=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});Yc&&Yc.decode(new Uint8Array).length===1&&(Yc=null);var Xc=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Zc=()=>new Xc,Qc=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},$c=e=>{let t=new Uint8Array(Qc(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},el=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},X=(e,t)=>{for(;t>Vc;)el(e,Tc|Vc&t),t=xc(t/128);el(e,Vc&t)},tl=new Uint8Array(3e4),nl=tl.length/3,Z=qc&&qc.encodeInto?(e,t)=>{if(t.length<nl){let n=qc.encodeInto(t,tl).written||0;X(e,n);for(let t=0;t<n;t++)el(e,tl[t])}else il(e,Jc(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;X(e,r);for(let t=0;t<r;t++)el(e,n.codePointAt(t))},rl=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=Sc(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Cc(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},il=(e,t)=>{X(e,t.byteLength),rl(e,t)},al=e=>Error(e),ol=al(`Unexpected end of array`),sl=al(`Integer out of Range`),cl=class{constructor(e){this.arr=e,this.pos=0}},ll=e=>new cl(e),ul=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},dl=e=>ul(e,pl(e)),fl=e=>e.arr[e.pos++],pl=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&Vc)*n,n*=128,r<Tc)return t;if(t>Hc)throw sl}throw ol},ml=e=>{let t=e.arr[e.pos++],n=t&Bc,r=64,i=(t&wc)>0?-1:1;if((t&Tc)===0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&Vc)*r,r*=128,t<Tc)return i*n;if(n>Hc)throw sl}throw ol},hl=Yc?e=>Yc.decode(dl(e)):e=>{let t=pl(e);if(t===0)return``;{let n=String.fromCodePoint(fl(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(fl(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},gl=e=>{let t=e.pos,n=hl(e);return e.pos=t,n},_l=Date.now,vl=()=>new Map,yl=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},bl=class{constructor(){this._observers=vl()}on(e,t){yl(this._observers,e,Uc).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return Wc((this._observers.get(e)||vl()).values()).forEach(e=>e(...t))}destroy(){this._observers=vl()}},xl=Symbol(`Equality`),Sl=Object.keys,Cl=e=>Sl(e).length,wl=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Tl=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[xl]!=null)return e[xl](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!Tl(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Cl(e)!==Cl(t))return!1;for(let n in e)if(!wl(e,n)||!Tl(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Tl(e[n],t[n]))return!1;break;default:return!1}return!0},El=3e4,Dl=class extends bl{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=_l();this.getLocalState()!==null&&El/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&El<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&Ol(this,t,`timeout`)},xc(El/10)),e.on(`destroy`,()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit(`destroy`,[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:_l()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),Tl(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},Ol=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:_l()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},kl=(e,t,n=e.states)=>{let r=t.length,i=Zc();X(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;X(i,r),X(i,s),Z(i,JSON.stringify(o))}return $c(i)},Al=(e,t,n)=>{let r=ll(t),i=_l(),a=[],o=[],s=[],c=[],l=pl(r);for(let t=0;t<l;t++){let t=pl(r),n=pl(r),l=JSON.parse(hl(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(Tl(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},jl=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}},Ml=class{constructor(e){this.data=e,this.encoder=Zc(),this.decoder=ll(new Uint8Array(this.data))}peekVarString(){return gl(this.decoder)}readVarUint(){return pl(this.decoder)}readVarString(){return hl(this.decoder)}readVarUint8Array(){return dl(this.decoder)}writeVarUint(e){return X(this.encoder,e)}writeVarString(e){return Z(this.encoder,e)}writeVarUint8Array(e){return il(this.encoder,e)}length(){return Qc(this.encoder)}},Q=function(e){return e[e.Sync=0]=`Sync`,e[e.Awareness=1]=`Awareness`,e[e.Auth=2]=`Auth`,e[e.QueryAwareness=3]=`QueryAwareness`,e[e.Stateless=5]=`Stateless`,e[e.CLOSE=7]=`CLOSE`,e[e.SyncStatus=8]=`SyncStatus`,e[e.Ping=9]=`Ping`,e[e.Pong=10]=`Pong`,e}({}),$=function(e){return e.Connecting=`connecting`,e.Connected=`connected`,e.Disconnected=`disconnected`,e}({}),Nl=class{constructor(){this.encoder=Zc()}get(e){return e.encoder}toUint8Array(){return $c(this.encoder)}},Pl=class extends Nl{constructor(...e){super(...e),this.type=Q.CLOSE,this.description=`Ask the server to close the connection`}get(e){return Z(this.encoder,e.documentName),X(this.encoder,this.type),this.encoder}},Fl=class e extends jl{static{this.DEDUPLICATABLE_TYPES=new Set([Q.Awareness,Q.QueryAwareness])}constructor(e){super(),this.messageQueue=[],this.configuration={url:``,autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=$.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,this.reconnectTimeout=null,this.setConfiguration(e),this.configuration.WebSocketPolyfill=e.WebSocketPolyfill?e.WebSocketPolyfill:WebSocket,this.on(`open`,this.configuration.onOpen),this.on(`open`,this.onOpen.bind(this)),this.on(`connect`,this.configuration.onConnect),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`status`,this.configuration.onStatus),this.on(`disconnect`,this.configuration.onDisconnect),this.on(`close`,this.configuration.onClose),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`close`,this.onClose.bind(this)),this.on(`message`,this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),this.shouldConnect&&this.connect()}async onOpen(e){this.status=$.Connected,this.emit(`status`,{status:$.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=e}attach(e){let t=e.effectiveName,n=this.configuration.providerMap.get(t);if(n&&n!==e&&n.isAuthenticated)throw Error(`Cannot attach two providers with the same effective name "${t}". Use sessionAwareness: true to multiplex providers with the same document name.`);this.configuration.providerMap.set(t,e),this.status===$.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===$.Connected&&e.onOpen(this.receivedOnOpenPayload)}detach(e){let t=e.effectiveName;this.configuration.providerMap.has(t)&&(e.send(Pl,{documentName:t}),this.configuration.providerMap.delete(t))}setConfiguration(e={}){this.configuration={...this.configuration,...e},this.configuration.autoConnect||(this.shouldConnect=!1)}clearReconnectTimeout(){this.reconnectTimeout&&=(clearTimeout(this.reconnectTimeout),null)}async connect(){if(this.status===$.Connected)return;this.clearReconnectTimeout(),this.cancelWebsocketRetry&&=(this.cancelWebsocketRetry(),void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;let{retryPromise:e,cancelFunc:t}=(()=>{let e=!1;return{retryPromise:bc(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:t=>{(!this.shouldConnect||e)&&t.abort()}}).catch(e=>{if(e&&e.code!==`ATTEMPT_ABORTED`)throw e}),cancelFunc:()=>{e=!0}}})();return this.cancelWebsocketRetry=t,e}attachWebSocketListeners(e,t){let{identifier:n}=e,r=e=>this.emit(`message`,e),i=e=>this.emit(`close`,{event:e}),a=e=>this.emit(`open`,e),o=e=>{t(e)};this.webSocketHandlers[n]={message:r,close:i,open:a,error:o};let s=this.webSocketHandlers[e.identifier];Object.keys(s).forEach(t=>{e.addEventListener(t,s[t])})}cleanupWebSocket(){if(!this.webSocket)return;let{identifier:e}=this.webSocket,t=this.webSocketHandlers[e];Object.keys(t).forEach(n=>{this.webSocket?.removeEventListener(n,t[n]),delete this.webSocketHandlers[e]}),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise((e,t)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;let n=new this.configuration.WebSocketPolyfill(this.url);n.binaryType=`arraybuffer`,n.identifier=this.identifier,this.attachWebSocketListeners(n,t),this.webSocket=n,this.status=$.Connecting,this.emit(`status`,{status:$.Connecting}),this.connectionAttempt={resolve:e,reject:t}})}onMessage(e){this.resolveConnectionAttempt(),this.lastMessageReceived=_l();let t=new Uint8Array(e.data);if(t.length===1&&t[0]===Q.Ping){this.sendPong();return}let n=new Ml(t).peekVarString();this.configuration.providerMap.get(n)?.onMessage(e)}sendPong(){let e=Zc();X(e,Q.Pong),this.send($c(e))}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=$.Connected,this.emit(`status`,{status:$.Connected}),this.emit(`connect`),this.messageQueue.forEach(e=>this.send(e)),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){this.connectionAttempt?.reject(),this.connectionAttempt=null}checkConnection(){this.status===$.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=_l()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.emit(`close`,{event:{code:4408,reason:`forced`}}),this.closeTries=0):(this.webSocket?.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let e=this.configuration.url;for(;e[e.length-1]===`/`;)e=e.slice(0,e.length-1);return e}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,this.clearReconnectTimeout(),this.webSocket!==null)try{this.webSocket.close(),this.messageQueue=[]}catch(e){console.error(e)}}parseQueuedMessage(e){try{let t=ll(e);return{documentName:hl(t),messageType:pl(t)}}catch{return null}}addToQueue(t){if(t instanceof Uint8Array){let n=this.parseQueuedMessage(t);n&&e.DEDUPLICATABLE_TYPES.has(n.messageType)&&(this.messageQueue=this.messageQueue.filter(e=>{if(!(e instanceof Uint8Array))return!0;let t=this.parseQueuedMessage(e);return t?!(t.documentName===n.documentName&&t.messageType===n.messageType):!0}))}this.messageQueue.push(t)}send(e){this.webSocket?.readyState===qt.Open?this.webSocket.send(e):this.addToQueue(e)}onClose({event:e}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=$.Disconnected,this.emit(`status`,{status:$.Disconnected}),this.emit(`disconnect`,{event:e}),!this.cancelWebsocketRetry&&this.shouldConnect&&(this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,this.connect()},this.configuration.delay))}destroy(){this.emit(`destroy`),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}},Il=0,Ll=1,Rl=2,zl=(e,t)=>{X(e,Il),il(e,va(t))},Bl=(e,t,n)=>{X(e,Ll),il(e,fa(t,n))},Vl=(e,t,n)=>Bl(t,n,dl(e)),Hl=(e,t,n,r)=>{try{la(t,dl(e),n)}catch(e){r?.(e),console.error(`Caught error while handling a Yjs update`,e)}},Ul=(e,t)=>{X(e,Rl),il(e,t)},Wl=Hl,Gl=(e,t,n,r,i)=>{let a=pl(e);switch(a){case Il:Vl(e,t,n);break;case Ll:Hl(e,n,r,i);break;case Rl:Wl(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},Kl=class{constructor(e){this.message=e}apply(e,t){let{message:n}=this,r=n.readVarUint(),i=n.length();switch(r){case Q.Sync:this.applySyncMessage(e,t);break;case Q.Awareness:this.applyAwarenessMessage(e);break;case Q.Auth:this.applyAuthMessage(e);break;case Q.QueryAwareness:this.applyQueryAwarenessMessage(e);break;case Q.Stateless:e.receiveStateless(hl(n.decoder));break;case Q.SyncStatus:this.applySyncStatusMessage(e,ml(n.decoder)===1);break;case Q.CLOSE:let i={code:1e3,reason:hl(n.decoder)};e.onClose(),e.configuration.onClose({event:i}),e.forwardClose({event:i});break;default:console.error(`Can’t apply message of unknown type: ${r}`)}n.length()>i+1&&e.send(Nl,{encoder:n.encoder})}applySyncMessage(e,t){let{message:n}=this;n.writeVarUint(Q.Sync);let r=Gl(n.decoder,n.encoder,e.document,e);t&&r===Ll&&(e.synced=!0)}applySyncStatusMessage(e,t){t&&e.decrementUnsyncedChanges()}applyAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;Al(e.awareness,t.readVarUint8Array(),e)}applyAuthMessage(e){let{message:t}=this;Ht(t.decoder,e.sendToken.bind(e),e.permissionDeniedHandler.bind(e),e.authenticatedHandler.bind(e))}applyQueryAwarenessMessage(e){if(!e.awareness)return;let{message:t}=this;t.writeVarUint(Q.Awareness),t.writeVarUint8Array(kl(e.awareness,Array.from(e.awareness.getStates().keys())))}},ql=class{constructor(e,t={}){this.message=new e,this.encoder=this.message.get(t)}create(){return $c(this.encoder)}send(e){e?.send(this.create())}},Jl=`4.0.0-rc.1`,Yl=class extends Nl{constructor(...e){super(...e),this.type=Q.Auth,this.description=`Authentication`}get(e){if(e.token===void 0)throw Error("The authentication message requires `token` as an argument.");return Z(this.encoder,e.documentName),X(this.encoder,this.type),Vt(this.encoder,e.token),Z(this.encoder,Jl),this.encoder}},Xl=class extends Nl{constructor(...e){super(...e),this.type=Q.Awareness,this.description=`Awareness states update`}get(e){if(e.awareness===void 0)throw Error(`The awareness message requires awareness as an argument`);if(e.clients===void 0)throw Error(`The awareness message requires clients as an argument`);Z(this.encoder,e.documentName),X(this.encoder,this.type);let t;return t=e.states===void 0?kl(e.awareness,e.clients):kl(e.awareness,e.clients,e.states),il(this.encoder,t),this.encoder}},Zl=class extends Nl{constructor(...e){super(...e),this.type=Q.Stateless,this.description=`A stateless message`}get(e){return Z(this.encoder,e.documentName),X(this.encoder,this.type),Z(this.encoder,e.payload??``),this.encoder}},Ql=class extends Nl{constructor(...e){super(...e),this.type=Q.Sync,this.description=`First sync step`}get(e){if(e.document===void 0)throw Error(`The sync step one message requires document as an argument`);return Z(this.encoder,e.documentName),X(this.encoder,this.type),zl(this.encoder,e.document),this.encoder}},$l=class extends Nl{constructor(...e){super(...e),this.type=Q.Sync,this.description=`A document update`}get(e){return Z(this.encoder,e.documentName),X(this.encoder,this.type),Ul(this.encoder,e.update),this.encoder}},eu=class extends Error{constructor(...e){super(...e),this.code=1001}},tu=class extends jl{get effectiveName(){return this.configuration.sessionAwareness?Gt(this.configuration.name,this.sessionId):this.configuration.name}constructor(e){super(),this.configuration={name:``,document:void 0,awareness:void 0,token:null,sessionAwareness:!0,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.sessionId=Math.random().toString(36).slice(2),this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit(`connect`),this.forwardStatus=e=>this.emit(`status`,e),this.forwardClose=e=>this.emit(`close`,e),this.forwardDisconnect=e=>this.emit(`disconnect`,e),this.forwardDestroy=()=>this.emit(`destroy`),this.setConfiguration(e),this.configuration.document=e.document?e.document:new qi,this.configuration.awareness=e.awareness===void 0?new Dl(this.document):e.awareness,this.on(`open`,this.configuration.onOpen),this.on(`message`,this.configuration.onMessage),this.on(`outgoingMessage`,this.configuration.onOutgoingMessage),this.on(`synced`,this.configuration.onSynced),this.on(`destroy`,this.configuration.onDestroy),this.on(`awarenessUpdate`,this.configuration.onAwarenessUpdate),this.on(`awarenessChange`,this.configuration.onAwarenessChange),this.on(`stateless`,this.configuration.onStateless),this.on(`unsyncedChanges`,this.configuration.onUnsyncedChanges),this.on(`authenticated`,this.configuration.onAuthenticated),this.on(`authenticationFailed`,this.configuration.onAuthenticationFailed),this.awareness?.on(`update`,()=>{this.emit(`awarenessUpdate`,{states:Ut(this.awareness.getStates())})}),this.awareness?.on(`change`,()=>{this.emit(`awarenessChange`,{states:Ut(this.awareness.getStates())})}),this.document.on(`update`,this.boundDocumentUpdateHandler),this.awareness?.on(`update`,this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&typeof this.configuration.forceSyncInterval==`number`&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.manageSocket&&this.attach()}setConfiguration(e={}){e.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new Fl(e)),this.configuration={...this.configuration,...e}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&--this.unsyncedChanges,this.unsyncedChanges===0&&(this.synced=!0),this.emit(`unsyncedChanges`,{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(Ql,{document:this.document,documentName:this.effectiveName})}pageHide(){this.awareness&&Ol(this.awareness,[this.document.clientID],`page hide`)}registerEventListeners(){typeof window>`u`||!(`addEventListener`in window)||window.addEventListener(`pagehide`,this.boundPageHide)}sendStateless(e){this.send(Zl,{documentName:this.effectiveName,payload:e})}async sendToken(){let e;try{e=await this.getToken()}catch(e){this.permissionDeniedHandler(`Failed to get token during sendToken(): ${e}`);return}this.send(Yl,{token:e??``,documentName:this.effectiveName})}documentUpdateHandler(e,t){t!==this&&(this.incrementUnsyncedChanges(),this.send($l,{update:e,documentName:this.effectiveName}))}awarenessUpdateHandler({added:e,updated:t,removed:n},r){let i=e.concat(t).concat(n);this.send(Xl,{awareness:this.awareness,clients:i,documentName:this.effectiveName})}get synced(){return this.isSynced}set synced(e){this.isSynced!==e&&(this.isSynced=e,e&&this.emit(`synced`,{state:e}))}receiveStateless(e){this.emit(`stateless`,{payload:e})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn(`HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn(`HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.`)}async onOpen(e){this.isAuthenticated=!1,this.emit(`open`,{event:e}),await this.sendToken(),this.startSync()}async getToken(){return typeof this.configuration.token==`function`?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(Ql,{document:this.document,documentName:this.effectiveName}),this.awareness&&this.awareness.getLocalState()!==null&&this.send(Xl,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.effectiveName})}send(e,t){if(!this._isAttached)return;let n=new ql(e,t);this.emit(`outgoingMessage`,{message:n.message}),n.send(this.configuration.websocketProvider)}onMessage(e){let t=new Ml(e.data),{documentName:n}=Kt(t.readVarString());t.writeVarString(this.effectiveName),this.emit(`message`,{event:e,message:new Ml(e.data)}),new Kl(t).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&Ol(this.awareness,Array.from(this.awareness.getStates().keys()).filter(e=>e!==this.document.clientID),this)}destroy(){this.emit(`destroy`),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(Ol(this.awareness,[this.document.clientID],`provider destroy`),this.awareness.off(`update`,this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off(`update`,this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),!(typeof window>`u`||!(`removeEventListener`in window))&&window.removeEventListener(`pagehide`,this.boundPageHide)}detach(){this.configuration.websocketProvider.off(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.off(`connect`,this.forwardConnect),this.configuration.websocketProvider.off(`status`,this.forwardStatus),this.configuration.websocketProvider.off(`status`,this.configuration.onStatus),this.configuration.websocketProvider.off(`open`,this.boundOnOpen),this.configuration.websocketProvider.off(`close`,this.boundOnClose),this.configuration.websocketProvider.off(`close`,this.configuration.onClose),this.configuration.websocketProvider.off(`close`,this.forwardClose),this.configuration.websocketProvider.off(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.off(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.off(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.off(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||=(this.configuration.websocketProvider.on(`connect`,this.configuration.onConnect),this.configuration.websocketProvider.on(`connect`,this.forwardConnect),this.configuration.websocketProvider.on(`status`,this.configuration.onStatus),this.configuration.websocketProvider.on(`status`,this.forwardStatus),this.configuration.websocketProvider.on(`open`,this.boundOnOpen),this.configuration.websocketProvider.on(`close`,this.boundOnClose),this.configuration.websocketProvider.on(`close`,this.configuration.onClose),this.configuration.websocketProvider.on(`close`,this.forwardClose),this.configuration.websocketProvider.on(`disconnect`,this.configuration.onDisconnect),this.configuration.websocketProvider.on(`disconnect`,this.forwardDisconnect),this.configuration.websocketProvider.on(`destroy`,this.configuration.onDestroy),this.configuration.websocketProvider.on(`destroy`,this.forwardDestroy),this.configuration.websocketProvider.attach(this),!0)}permissionDeniedHandler(e){this.emit(`authenticationFailed`,{reason:e}),this.isAuthenticated=!1}authenticatedHandler(e){this.isAuthenticated=!0,this.authorizedScope=e,this.emit(`authenticated`,{scope:e})}setAwarenessField(e,t){if(!this.awareness)throw new eu(`Cannot set awareness field "${e}" to ${JSON.stringify(t)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(e,t)}},nu=`open-knowledge-config`;function ru(e,t,n){let r=de.getTracer(nu),i=t?{attributes:t}:{};return r.startActiveSpan(e,i,e=>{try{return n(e)}catch(t){throw e.recordException(t),e.setStatus({code:fe.ERROR,message:t instanceof Error?t.message:String(t)}),t}finally{e.end()}})}function iu(e,t){let n=de.getActiveSpan();n&&n.addEvent(e,t)}function au(e,t){return e===`either`?!0:e===t}function ou(e,t){let n=null;function r(e,i){if(n!==null||e===void 0)return;let a=h(oe,i);if(a?.scope!==void 0&&!au(a.scope,t)){n={code:`SCOPE_VIOLATION`,path:i,expectedScope:a.scope,actualScope:t};return}if(typeof e==`object`&&e&&!Array.isArray(e)){for(let[t,a]of Object.entries(e))if(r(a,[...i,t]),n!==null)return;return}}for(let[t,i]of Object.entries(e))if(r(i,[t]),n!==null)break;return n}var su=`source`;function cu(e){return{ok:!1,error:e}}function lu(e){return{ok:!0,...e}}function uu(){return oe.parse({})}function du(e,t){let n=e.toString();if(n.length===0)return uu();let r=u(n);if(r.errors.length>0)return console.warn(`[bindConfigDoc:${t}] Y.Text contains invalid YAML; returning schema defaults. Errors: ${r.errors.map(e=>e.message).join(`; `)}`),uu();let i=r.toJSON()??{},a=oe.safeParse(i);return a.success?a.data:(console.warn(`[bindConfigDoc:${t}] Y.Text content fails schema validation; returning schema defaults. First issue: ${a.error.issues[0]?.message??`(unknown)`}`),uu())}function fu(e,t,n={}){return ru(`config.bind`,{"config.scope":t,"config.transport":`ytext`},()=>pu(e,t,n))}function pu(e,t,n){let{ytextKey:r=su}=n,i=e.document,a=i.getText(r),o=new Set,s=new Set,c=!1,d=!1;function f(){if(c)return;let e=du(a,t);for(let n of o)try{n(e)}catch(e){console.warn(`[bindConfigDoc:${t}] listener threw:`,e)}}function p(){if(c||(f(),d))return;d=!0;let e=[...s];s.clear();for(let n of e)try{n()}catch(e){console.warn(`[bindConfigDoc:${t}] synced listener threw:`,e)}}a.observe(f),e.on(`synced`,p);function m(e){if(c)return cu({code:`WRITE_ERROR`,detail:`ConfigBinding (${t}) has been disposed`});if(!d)return cu({code:`NOT_SYNCED`,detail:`ConfigBinding (${t}) has not completed initial sync`});let n=ou(e,t);if(n!==null)return cu(n);let r=g(e);if(r!==null)return cu(r);let o=u(a.toString()),s=o.contents!==null&&!l(o.contents);if(o.errors.length>0||s){iu(`config.corrupt-ytext-reset`,{"config.scope":t,"config.parse.errorCount":o.errors.length,"config.parse.topLevelNonMap":s});let e=o.errors.length>0?o.errors.map(e=>e.message).join(`; `):`top-level YAML is not a mapping`;console.warn(`[bindConfigDoc:${t}] dropping corrupt Y.Text and re-applying patch onto empty doc. Reason: ${e}`),o=u(``)}o.contents===null&&(o.contents=o.createNode({}));let f=ae(o,e),p=o.toJSON()??{},m=ru(`config.validate`,{"config.scope":t,"config.validation.layer":`L1`},e=>{let t=oe.safeParse(p);if(e.setAttribute(`config.outcome`,t.success?`success`:`rejected`),!t.success)for(let e of t.error.issues)iu(`config.validation.issue`,{"issue.path":e.path.map(e=>String(e)).join(`.`),"issue.message":e.message});return t});if(!m.success)return cu({code:`SCHEMA_INVALID`,issues:m.error.issues.map(ie)});let ee=o.toString();return i.transact(()=>{a.length>0&&a.delete(0,a.length),a.insert(0,ee)}),lu({effective:m.data,appliedPaths:f})}return{current(){return du(a,t)},patch(e){return ru(`config.patch`,{"config.scope":t,"config.transport":`ytext`},t=>{let n=m(e);return t.setAttribute(`config.outcome`,n.ok?`success`:`rejected`),n.ok||t.setAttribute(`config.error.code`,n.error.code),n})},subscribe(e){return o.add(e),()=>{o.delete(e)}},hasSynced(){return d},subscribeSynced(e){if(c)return()=>{};if(d){let n=!1;return queueMicrotask(()=>{if(!(n||c))try{e()}catch(e){console.warn(`[bindConfigDoc:${t}] synced listener threw:`,e)}}),()=>{n=!0}}return s.add(e),()=>{s.delete(e)}},dispose(){c||(c=!0,a.unobserve(f),e.off(`synced`,p),o.clear(),s.clear())}}}var mu=`source`,hu=800;function gu(e){return{ok:!1,error:e}}function _u(e){return{ok:!0,...e}}function vu(e,t={}){let{ytextKey:n=mu,acceptanceDelayMs:r=hu}=t,i=e.document,a=i.getText(n),o=new Set,s=new Set,c=new Set,l=!1,u=`idle`,d=null;function f(){d!==null&&(clearTimeout(d),d=null)}function p(e){if(!l&&u!==e){u=e;for(let t of c)try{t(e)}catch(e){console.warn(`[bindOkignoreDoc] status listener threw:`,e)}}}function m(){if(l)return;let e=a.toString();for(let t of o)try{t(e)}catch(e){console.warn(`[bindOkignoreDoc] text listener threw:`,e)}}function ee(e){if(!l)for(let t of s)try{t(e)}catch(e){console.warn(`[bindOkignoreDoc] rejection listener threw:`,e)}}return a.observe(m),e.on(`synced`,m),{current(){return a.toString()},patch(e){return l?gu({code:`WRITE_ERROR`,detail:`OkignoreBinding has been disposed`}):(i.transact(()=>{a.length>0&&a.delete(0,a.length),e.length>0&&a.insert(0,e)}),f(),p(`pending`),d=setTimeout(()=>{d=null,!l&&u===`pending`&&p(`accepted`)},r),_u({text:e}))},subscribe(e){return o.add(e),()=>{o.delete(e)}},subscribeRejection(e){return s.add(e),()=>{s.delete(e)}},subscribeStatus(e){return c.add(e),()=>{c.delete(e)}},status(){return u},notifyRejection(e){l||(f(),p(`rejected`),ee({error:e,text:a.toString()}))},dispose(){l||(l=!0,f(),a.unobserve(m),e.off(`synced`,m),o.clear(),s.clear(),c.clear())}}}function yu(e,t,n){return bu([e,t,n],[])}function bu(e,t){if(t.length>0){let n=h(oe,t);if(n?.scope===`user`)return e[0];if(n?.scope===`project`)return e[1]??e[0];if(n?.scope===`project-local`)return e[2]??e[0]}let n=xu(e);if(n===void 0)return;if(n===null)return null;if(Array.isArray(n)||typeof n!=`object`)return n;let r=e.map(e=>Su(e)?e:void 0),i=new Set;for(let e of r)if(e!==void 0)for(let t of Object.keys(e))i.add(t);let a={};for(let e of i)a[e]=bu(r.map(t=>t===void 0?void 0:t[e]),[...t,e]);return a}function xu(e){for(let t=e.length-1;t>=0;t--)if(e[t]!==void 0)return e[t]}function Su(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Cu=e(n(),1);function wu(e,t,n){let r=(0,ve.c)(5),i,a;r[0]!==e||r[1]!==t||r[2]!==n?(i=()=>{!e||!n||typeof e.setLanguagePreference==`function`&&e.setLanguagePreference(t??`system`).catch(e=>{console.warn(JSON.stringify({event:`language-preference-push-failed`,preference:t??`system`,error:e instanceof Error?e.message:String(e)}))})},a=[e,t,n],r[0]=e,r[1]=t,r[2]=n,r[3]=i,r[4]=a):(i=r[3],a=r[4]),(0,Cu.useEffect)(i,a)}function Tu(e){let t=document.createElement(`span`);t.style.display=`none`,t.style.backgroundColor=`var(${e})`,document.body.appendChild(t);try{let e=getComputedStyle(t).backgroundColor;return!e||e===`rgba(0, 0, 0, 0)`||e.includes(`var(`)?null:ge(e)}finally{t.remove()}}function Eu(){if(!(typeof document>`u`))try{let e=Tu(`--desk`),t=Tu(`--sidebar-foreground`);return!e||!t?void 0:{bg:e,symbol:t}}catch{return}}function Du(e,t,n){let r=(0,ve.c)(7),i=(0,Cu.useRef)(null),a;r[0]!==e||r[1]!==t?(a=()=>{if(t!==`light`&&t!==`dark`&&t!==`system`||!e)return;let n=!1,r=!1,a,o=window.matchMedia(`(prefers-reduced-transparency: reduce)`),s=()=>{if(n||!r||me())return;let t={reducedTransparency:o.matches,chrome:Eu()},i=JSON.stringify(t);i!==a&&(e.signalThemeApplied(t),a=i)},c=he(s);o.addEventListener(`change`,s);let l=()=>{n||(r=!0,s())},u=i.current;if(u?.bridge===e&&u.source===t)u.settled.then(l);else{let n={bridge:e,source:t,settled:e.setThemeSource(t).catch(e=>{i.current===n&&(i.current=null),console.warn(JSON.stringify({event:`theme-source-set-failed`,themeValue:t,error:e instanceof Error?e.message:String(e)}))})};i.current=n,n.settled.then(l)}return()=>{n=!0,c(),o.removeEventListener(`change`,s)}},r[0]=e,r[1]=t,r[2]=a):a=r[2];let o;r[3]!==e||r[4]!==n||r[5]!==t?(o=[e,n,t],r[3]=e,r[4]=n,r[5]=t,r[6]=o):o=r[6],(0,Cu.useEffect)(a,o)}function Ou(e,t,n=null,r=null){let i={..._e()};return e!==null&&(i.principalId=e.principalId,i.tabSessionId=e.tabSessionId),t!==null&&t.length>0&&(i.expectedServerInstanceId=t),n!==null&&n.length>0&&(i.expectedBranch=n),r!==null&&r.length>0&&(i.expectedDocLineageEpoch=r),JSON.stringify(i)}var ku=t();function Au(e,t,n,r){console.warn(JSON.stringify({event:`ok-${e}-${n}`,docName:t,code:r?.code,reason:r?.reason??void 0}))}function ju(e,t,n,r){let i=new qi,a=new tu({url:e,name:t,document:i,token:Ou(null,r,null),onDisconnect:({event:e})=>Au(`config-provider`,t,`disconnect`,e),onClose:({event:e})=>Au(`config-provider`,t,`close`,e)}),o=fu(a,n);return{binding:o,config:o.current(),cleanup:()=>{o.dispose(),a.destroy(),i.destroy()}}}function Mu(e,t){let n=new qi,r=new tu({url:e,name:s,document:n,token:Ou(null,t,null),onDisconnect:({event:e})=>Au(`okignore-provider`,s,`disconnect`,e),onClose:({event:e})=>Au(`okignore-provider`,s,`close`,e)}),i=vu(r);return{binding:i,provider:r,cleanup:()=>{i.dispose(),r.destroy(),n.destroy()}}}function Nu(e){let t=(0,ve.c)(20),{collabUrl:n,collabTerminal:i,children:s}=e,l=i===void 0?!1:i,{themes:u,loaded:ie,loadError:ae}=ce(),h=se(),{systemTheme:oe}=r(),le=oe===`dark`,[g,de]=(0,Cu.useState)(null),[fe,me]=(0,Cu.useState)(null),[he,ge]=(0,Cu.useState)(null),[_e,_]=(0,Cu.useState)(null),ye,be;t[0]!==n||t[1]!==h?(ye=()=>{if(n===null)return;let e=ju(n,a,`user`,h),t=ju(n,c,`project`,h),r=ju(n,o,`project-local`,h),i=Mu(n,h);de({binding:e.binding,config:e.config,synced:e.binding.hasSynced()}),me({binding:t.binding,config:t.config,synced:t.binding.hasSynced()}),ge({binding:r.binding,config:r.config,synced:r.binding.hasSynced()}),_({binding:i.binding,synced:!1});let s=e.binding.subscribe(t=>{de(n=>n?.binding===e.binding?{...n,config:t}:n)}),l=e.binding.subscribeSynced(()=>{de(t=>t?.binding===e.binding?{...t,config:e.binding.current(),synced:!0}:t)}),u=t.binding.subscribe(e=>{me(n=>n?.binding===t.binding?{...n,config:e}:n)}),d=t.binding.subscribeSynced(()=>{me(e=>e?.binding===t.binding?{...e,config:t.binding.current(),synced:!0}:e)}),f=r.binding.subscribe(e=>{ge(t=>t?.binding===r.binding?{...t,config:e}:t)}),p=r.binding.subscribeSynced(()=>{ge(e=>e?.binding===r.binding?{...e,config:r.binding.current(),synced:!0}:e)}),m=()=>{_(e=>e?.binding===i.binding?{...e,synced:!0}:e)};return i.provider.on(`synced`,m),()=>{s(),l(),u(),d(),f(),p(),i.provider.off(`synced`,m);for(let n of[e,t,r,i])try{n.cleanup()}catch(e){console.warn(JSON.stringify({event:`ok-config-provider-cleanup-error`,error:String(e)}))}de(t=>t?.binding===e.binding?null:t),me(e=>e?.binding===t.binding?null:e),ge(e=>e?.binding===r.binding?null:e),_(e=>e?.binding===i.binding?null:e)}},be=[n,h],t[0]=n,t[1]=h,t[2]=ye,t[3]=be):(ye=t[2],be=t[3]),(0,Cu.useEffect)(ye,be);let v=g&&fe?yu(g.config,fe.config,he?.config):null,xe=v?.appearance?.theme,Se=v?.appearance?.customTheme,Ce=v?.appearance?.colorThemeEnabled!==!1,we=n===null||g?.synced===!0&&fe?.synced===!0&&he?.synced===!0,Te=[v?.appearance?.colorThemeLight,v?.appearance?.colorThemeDark,v?.appearance?.colorTheme],Ee=Ce&&Te.some(Pu),De=we&&(!Ee||ie),Oe=we&&(!Ee||ie||ae),ke=m(v?.appearance,u),Ae=re(xe,le),je=Ce?ke[Ae]:`default`,Me=je===`custom`?ee(te(Se)):p(je,u)??xe??(v?`system`:void 0);d(De?Me:void 0),ne({selection:ke,modePreference:xe,slotMode:Ae,customSeed:Se,themes:u,enabled:Ce,ready:De}),pe((n!==null||l)&&De),ue({preference:v?.appearance?.language,userConfigSynced:g?.synced??!1}),wu(typeof window<`u`?window.okDesktop:void 0,v?.appearance?.language,g?.synced??!1);let Ne=je.startsWith(`saved-`)?u.find(e=>e.id===je)?.scheme:void 0,Pe=je===`custom`?JSON.stringify(Se??null):Ne?JSON.stringify(Ne):``;Du(Oe&&typeof window<`u`?window.okDesktop:void 0,Oe?xe??`system`:void 0,`${je}:${Pe}`);let Fe=g?.binding??null,Ie=g?.synced??!1,Le=fe?.binding??null,y=he?.binding??null,Re=_e?.binding??null,ze=_e?.synced??!1,b=g?.config??null,Be=fe?.config??null,Ve=fe?.synced??!1,He=he?.config??null,x=he?.synced??!1,Ue;t[4]!==v||t[5]!==b||t[6]!==Be||t[7]!==Ve||t[8]!==He||t[9]!==x||t[10]!==Fe||t[11]!==Ie||t[12]!==Le||t[13]!==y||t[14]!==Re||t[15]!==ze?(Ue={userBinding:Fe,userSynced:Ie,projectBinding:Le,projectLocalBinding:y,okignoreBinding:Re,okignoreSynced:ze,userConfig:b,projectConfig:Be,projectSynced:Ve,projectLocalConfig:He,projectLocalSynced:x,merged:v},t[4]=v,t[5]=b,t[6]=Be,t[7]=Ve,t[8]=He,t[9]=x,t[10]=Fe,t[11]=Ie,t[12]=Le,t[13]=y,t[14]=Re,t[15]=ze,t[16]=Ue):Ue=t[16];let We=Ue,Ge;return t[17]!==s||t[18]!==We?(Ge=(0,ku.jsx)(f,{value:We,children:s}),t[17]=s,t[18]=We,t[19]=Ge):Ge=t[19],Ge}function Pu(e){return typeof e==`string`&&e.startsWith(`saved-`)}function Fu(e){let t=(0,ve.c)(2),n;return t[0]===e?n=t[1]:(n=(0,ku.jsx)(le,{children:(0,ku.jsx)(Nu,{...e})}),t[0]=e,t[1]=n),n}export{M as $,V as A,R as B,z as C,ma as D,za as E,ka as F,Rn as G,ai as H,Ba as I,hn as J,kn as K,U as L,Li as M,Da as N,fa as O,Fi as P,j as Q,Fo as R,Vi as S,Pa as T,P as U,ii as V,Bn as W,nn as X,sn as Y,Qt as Z,As as _,fu as a,v as at,La as b,Ys as c,J as d,E as et,Oa as f,Ts as g,bs as h,wu as i,Pe as it,Ea as j,va as k,ac as l,so as m,Ou as n,O as nt,tu as o,be as ot,Ra as p,yn as q,Du as r,y as rt,q as s,Fu as t,D as tt,qi as u,la as v,Aa as w,Ia as x,ca as y,pi as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./saved-themes-client-DX5dCXi5.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./field-controls-uK27_e3u.js";export{e as SectionSkeleton};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./react-f2sANaYj.js";import{t as n}from"./compiler-runtime-BfE3aGVn.js";import{s as r}from"./constants-upload-DZP-sCdl.js";import{S as i,a,d as o,f as s,g as c,i as l,p as u,t as d,u as f,v as p,x as m,y as h}from"./schemas-CxFhJLAM.js";import{c as g,l as _,u as v}from"./share-D-LUU2aX-rZ2lBHef.js";import{r as y}from"./_envelope-DuFpUEag-Beu481Zb.js";import{Ct as ee,F as b,I as x,L as S,M as C,Mt as w,N as T,P as E,Tt as D,j as O,wt as te}from"./schemas-api-WgoIuF0H.js";import{t as k}from"./doc-extensions-CcO7K8uD-DG9uHV54.js";import{t as ne}from"./constants-github-B7yhDvQc.js";import{_ as re,g as A,h as j,y as ie}from"./use-apply-config-color-theme-CTtLraO9.js";import{u as ae}from"./use-apply-config-language-9fLQZCsK.js";var M=Symbol.for(`@inkeep/open-knowledge/field-registry`),N=globalThis;N[M]===void 0&&(N[M]=i());var P=N[M];function oe(e){let t=e;for(let e=0;e<16;e++){if(t==null)return;let e=se(t)?P.get(t):void 0;if(e!==void 0)return e;let n=t._zod?.def?.innerType;if(n===void 0)return;t=n}}function se(e){return typeof e==`object`&&!!e&&`_zod`in e&&`parse`in e}var ce=[`markdownlint`,`frontmatter`,`okf`],le=[`missing`,`invalid`];function ue(e){return e.frontmatterScope!==void 0}[...ce];var de=[`off`,`warning`,`error`],F=`warning`,fe=[`error`,`warning`];function pe(e,t){for(let n=1;n<t.length;n++){let r=t.slice(0,n);e.hasIn(r)&&(w(e.getIn(r,!0))||e.deleteIn(r))}}function me(e,t){let n=[];function r(t,i){if(t!==void 0){if(t===null){e.deleteIn(i),n.push(i.join(`.`));return}if(Array.isArray(t)){pe(e,i),e.setIn(i,t),n.push(i.join(`.`));return}if(typeof t==`object`){for(let[e,n]of Object.entries(t))r(n,[...i,e]);return}pe(e,i),e.setIn(i,t),n.push(i.join(`.`))}}for(let[e,n]of Object.entries(t))r(n,[e]);return n}function he(e){return{path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message,issueCode:e.code}}var I={provider:d(ne).register(P,{scope:`user`,agentSettable:!1,reload:`boot`,defaultScope:`user`,description:"Declares that this git host is a GitHub Enterprise Server instance, so OpenKnowledge treats its remotes the way it treats github.com (OpenKnowledge credential handling, the push-permission check, share links, and the default host for `ok auth`). 'github' is the only accepted value today. A host that is not declared here and is not github.com is treated as a generic git remote, so OpenKnowledge leaves the machine's own git credentials alone and does not check push permission. Per-machine (user scope, global.yml in the OpenKnowledge home folder); a value in a project's `.ok/config.yml` is ignored. The declaration takes effect when OpenKnowledge next starts."})},ge=Object.fromEntries(Object.entries(I).map(([e,t])=>[e,t.optional().catch(void 0)])),_e=Object.fromEntries(Object.entries(I).map(([e,t])=>[e,t.nullish()])),ve=o(ge).catch({});c(p(),o(I).partial());var ye=o({git:o({hosts:c(p(),o(_e).nullish()).nullish()}).nullish()});function be(e){let t=ye.safeParse(e);return t.success?null:{code:`SCHEMA_INVALID`,issues:t.error.issues.map(he)}}var xe=u({prefix:p().regex(/^[A-Za-z][A-Za-z0-9_-]*$/,{message:`prefix must start with a letter and use only letters, digits, _ and -`}),url:p().regex(/^https?:\/\/[^\s<>]*<num>[^\s<>]*$/,{message:`url must be an http or https URL containing <num>`})});l(xe);var Se=xe.nullable().catch(null);function Ce(){return Object.fromEntries(ee.map(e=>[e,p().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: base16 ${e} — ${te[e]}, as a #rrggbb hex string.`}).optional()]))}function L(){return re.filter(e=>e!==`default`&&e!==`custom`).map(e=>`'${e}'`).join(`, `)}var R=Object.freeze([`authorization`,`auth.token`,`auth.bearer`,`cookie`,`set-cookie`,`x-api-key`,`password`,`secret`]),z=52428800,B=26214400,V=12582912,H=`https://api.openai.com/v1`,U=`text-embedding-3-small`,W=96e3,G=3e4,we=2048,Te=16384e3,Ee=6e5,De=Object.freeze([`127.0.0.1`]),Oe=/^[1-9]\d*(s|m|h)$/,ke=/^https?:\/\//,Ae=24550;function je(e){let t;try{t=new URL(e)}catch{return!1}let n=t.hostname.toLowerCase();return n===`localhost`||n===`127.0.0.1`||n===`[::1]`}function Me(e){let t;try{t=new URL(e)}catch{return`invalid-url`}return t.protocol===`https:`||t.protocol===`http:`&&je(e)?null:`insecure-scheme`}function K(e){let t=e.trim();return t===``?r:t}function Ne(e){let t=K(e);return t===`.`?`/`:t.startsWith(`./`)||t.startsWith(`/`)?t:`/${t}`}var Pe=[`filename`],Fe=/\{\{([^{}\n]+?)\}\}/g;function Ie(e){return Pe.includes(e)}function q(e){let t=[],n=0;for(let r of e.matchAll(Fe)){let i=r.index;i>n&&t.push({kind:`text`,text:e.slice(n,i),start:n});let a=(r[1]??``).trim();t.push(Ie(a)?{kind:`variable`,text:r[0],start:i,name:a}:{kind:`unknown-variable`,text:r[0],start:i,name:a}),n=i+r[0].length}return n<e.length&&t.push({kind:`text`,text:e.slice(n),start:n}),t}function Le(e){return e.filter(e=>e.kind===`variable`).length}function Re(e){let t=q(e),n=t.flatMap(e=>e.kind===`unknown-variable`?[e.text]:[]);return n.length>0?{kind:`unknown-variable`,variables:n}:t.some(e=>e.kind===`text`&&(e.text.includes(`{{`)||e.text.includes(`}}`)))?{kind:`unclosed-braces`}:e.split(`/`).some(e=>Le(q(e))>1)?{kind:`repeated-variable`}:null}function ze(e,t){return q(e).map(e=>e.kind===`variable`?t[e.name]:e.text).join(``)}function Be(e){let t=e.toLowerCase(),n=k.find(e=>t.endsWith(e));return n?e.slice(0,-n.length):``}function Ve(e,t){let n=t.lastIndexOf(`/`),r=n===-1?``:t.slice(0,n),i=Be(t.slice(n+1)),a=K(e),o=ze(i===``&&Le(q(a))>0?`./`:a,{filename:i}),s=o.startsWith(`./`),c=s?o.slice(2):o;return[...s?[r]:[],...c.split(`/`)].filter(e=>e!==``&&e!==`.`).join(`/`)}var He=`must not contain '..' segments, NUL bytes, backslashes, or drive letters`;function Ue(e){let t=K(e);if(t.includes(`\0`)||t.includes(`\\`))return!1;let n=t.split(`/`),r=n.find(e=>e!==``&&e!==`.`);return!(r!==void 0&&/^[A-Za-z]:/.test(r)||n.some(e=>e===`..`))}var We=/[<>:"\\|?*]/;function J(e){return{params:e}}function Ge(e){return q(e).some(e=>e.kind===`text`&&/[{}]/.test(e.text))}var Ke=p().refine(e=>e.trim()!==``,J({kind:`empty`})).refine(e=>!We.test(e),J({kind:`reserved-character`})).refine(Ue,J({kind:`outside-project`})).refine(e=>e===e.trim(),J({kind:`surrounding-space`})).refine(e=>e.startsWith(`./`)||e.startsWith(`/`),J({kind:`missing-prefix`})).refine(e=>!e.includes(`//`),J({kind:`empty-folder-name`})).refine(e=>e===`./`||e===`/`||!e.endsWith(`/`),J({kind:`trailing-slash`})).superRefine((e,t)=>{let n=Re(e);n&&t.addIssue({code:`custom`,params:n})}).refine(e=>!Ge(e),J({kind:`single-brace`})),qe={empty:!0,"outside-project":!0,"reserved-character":!0,"surrounding-space":!0,"missing-prefix":!0,"empty-folder-name":!0,"trailing-slash":!0,"single-brace":!0,"unknown-variable":!0,"unclosed-braces":!0,"repeated-variable":!0};function Je(e){if(typeof e!=`object`||!e||!(`kind`in e))return!1;let{kind:t}=e;return typeof t!=`string`||!Object.hasOwn(qe,t)?!1:t!==`unknown-variable`||`variables`in e&&Array.isArray(e.variables)}function Ye(e){let t=Ke.safeParse(e);if(t.success)return null;let[n]=t.error.issues,r=n?.code===`custom`?n.params:void 0;if(Je(r))return r;throw Error(`Attachment folder path check failed without a known problem kind: ${n?.message}`)}var Xe=o({content:o({dir:p().register(P,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Folder OpenKnowledge reads and writes documents under, relative to the project root (the folder that contains .ok/). Defaults to the project root. Exclude paths with .okignore. Read at server start; changing it requires a restart.`}).default(`.`),attachmentFolderPath:p().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Where pasted and dropped assets, and MCP write assets given a bare file name, are stored. The path must start with './' (relative to the current document) or '/' (relative to the content root): './' colocates beside the current document; './subdir' targets a subfolder next to it; '/' targets the content root; '/folder' targets a fixed folder under the content root. '{{filename}}' expands to the current document's name without its extension, so the default './{{filename}}.assets' keeps each document's files in its own folder. An upload whose parent is not a Markdown document, such as an MCP write asset given a bare file name, ignores {{filename}} and is placed as with './', which for a bare file name is the content root. A bare name such as 'attachments', saved by older versions, is read as '/attachments'. A path with an unknown variable refuses uploads until it is fixed. Whitespace-only values are treated as the default.`}).refine(Ue,{message:`Invalid attachment folder path: ${He}.`}).default(r)}).default({dir:`.`,attachmentFolderPath:r}),appearance:o({theme:d([`light`,`dark`,`system`]).register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Editor color theme: 'light', 'dark', or 'system' (follow the OS). A personal preference (user scope) — not shared with the project.`}).optional(),language:d([`system`,...ae]).register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Interface language. 'system' follows the operating system. A personal preference (user scope) — not shared with the project, and never applied to document content.`}).optional(),colorThemeLight:p().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`IDE color palette applied in light mode: 'default' (no palette), 'custom' (your own colors from appearance.customTheme), one of ${L()}, or the id of a saved theme. A short id of lowercase letters, digits, and hyphens (max 32 characters); an id no palette matches falls back to 'default' for this mode only, leaving the rest of your config untouched. A personal preference (user scope) — not shared with the project.`}).regex(j,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeDark:p().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`IDE color palette applied in dark mode: 'default' (no palette), 'custom' (your own colors from appearance.customTheme), one of ${L()}, or the id of a saved theme. A short id of lowercase letters, digits, and hyphens (max 32 characters); an id no palette matches falls back to 'default' for this mode only, leaving the rest of your config untouched. A personal preference (user scope) — not shared with the project.`}).regex(j,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorTheme:p().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Superseded by appearance.colorThemeLight / appearance.colorThemeDark. Read as the palette for both modes while neither of those is set. A short theme id (lowercase letters, digits, and hyphens; max 32 characters); an id no palette matches falls back to 'default'. A personal preference (user scope) — not shared with the project.`}).regex(j,{message:`Theme id must be lowercase letters, digits, and hyphens, 1–32 characters (e.g. 'dracula', 'custom', or a saved theme id).`}).optional(),colorThemeEnabled:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Whether the Themes plugin appears in Settings → Plugins. A personal preference (user scope). Default on.`}).optional(),customTheme:o({name:p().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: the scheme's display name.`}).optional(),author:p().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: the scheme's author credit, carried through from an imported base16 scheme.`}).optional(),variant:d([`dark`,`light`]).register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Custom theme: whether the scheme is 'dark' or 'light'. Auto-detected from the palette when omitted.`}).optional(),...Ce()}).optional(),preview:o({autoOpen:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`When on, the agent opens or refreshes the live preview after each edit. Turn off if you manage your own preview window. A personal preference (user scope).`}).default(!0)}).default({autoOpen:!0}),sidebar:o({showHiddenFiles:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show dot-prefixed entries (e.g. .ok/, .okignore) in the file tree. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showOnlyMarkdownFiles:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show only markdown documents (.md/.mdx) and folders in the file tree, hiding other file types from view. View-only: hidden files stay on disk and remain reachable via links and search. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showSkillsSection:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show the Skills section in the sidebar. Skill documents remain reachable via links and search while the section is hidden. Per-machine (project-local) — not shared with collaborators.`}).default(!0),showOkFolders:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show .ok folders (skills, templates, and other OpenKnowledge-managed state) in the file tree as read-only entries. .ok/worktrees and .ok/local never appear. Per-machine (project-local) — not shared with collaborators.`}).default(!1),showSkillGroups:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Group skills in the sidebar by where they came from — the publisher they were imported from, or the plugin that ships them. Skills you authored stay ungrouped at the top of their scope. Per-machine (project-local) — not shared with collaborators.`}).default(!0),pinnedProjectSkills:l(p()).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Project-scope skills pinned to the top of the Skills sidebar, by name. A pinned skill also keeps its normal row, so a provenance group still lists everything from its source. Per-machine (project-local) — not shared with collaborators.`}).default([]),pinnedGlobalSkills:l(p()).register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Global-scope skills pinned to the top of the Skills sidebar, by name. Stored per USER rather than per project, so a pinned global skill follows you into every project.`}).default([])}).optional()}).default({preview:{autoOpen:!0}}),editor:o({wordWrap:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Soft-wrap long lines in the source (CodeMirror) editor. A personal preference (user scope).`}).default(!0),previewTabs:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Reuse one tab when clicking through the Files and Skills sidebars, the way an editor preview tab works. Turn off to open every click in its own tab. Pinned tabs keep their own tab either way. A personal preference (user scope).`}).default(!0)}).default({wordWrap:!0,previewTabs:!0}),agents:o({autoApproveOkTools:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:"Auto-approve OpenKnowledge's own tools for agents launched from the built-in terminal (plus `ok open` on Claude) and for in-app Agents-panel chats with any ACP agent. Destructive tools (delete/move/share/install/import) still prompt. Per-machine personal preference (user scope)."}).default(!0),browserTools:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Give in-app Claude Code and Codex chats a browser they can drive (Playwright MCP, started through npx from OpenKnowledge's own folder with a fresh in-memory profile), so an agent can open pages, click, and take screenshots. Every browser action asks for approval, with no option to always allow it, unless the agent's own mode or permission settings skip approvals. Needs Google Chrome and Node.js. Off by default; takes effect for chats started after the change. Per-machine personal preference (user scope).`}).default(!1)}).default({autoApproveOkTools:!0,browserTools:!1}),autoSync:o({mode:d(v).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`What this machine syncs on a schedule for this project: 'off' (Manual — nothing scheduled; the manual pull/push actions still work), 'follow' (Auto, pull only — scheduled pulls, never a scheduled push; 'pull' is accepted as a legacy alias), or 'full' (Auto, pull and push — bidirectional). Explicit user-triggered pushes work in every mode. null = not chosen yet (onboarding asks). Per-machine (project-local) — not shared. Supersedes the legacy autoSync.enabled boolean.`}).nullable().default(null),enabled:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Legacy per-machine sync toggle, superseded by autoSync.mode. Read only when mode is absent (true = full, false = off). null = not chosen yet. Per-machine (project-local) — not shared.`}).nullable().default(null),resumeMode:d(_).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`When sync is paused (autoSync.mode 'off') after having been enabled, the active mode to resume into ('follow' | 'full'). Per-machine UI memory; ignored while a mode is active. Not shared.`}).optional(),pullIntervalSeconds:s().int().min(30).max(g).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Seconds between scheduled pulls while autoSync.mode is follow or full (default 30). Per-machine (project-local) — not shared.`}).optional().catch(void 0),pushIntervalSeconds:s().int().min(30).max(g).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Seconds between scheduled pushes while autoSync.mode is full (default 60). Ignored in every other mode, which never pushes on a schedule. Each cycle with pending edits authors a commit, so a shorter interval means more, smaller commits in the repo's shared history. Per-machine (project-local) — not shared.`}).optional().catch(void 0),default:h([a(),d(v)]).register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Committed project default for a machine's sync mode on first open: 'off' | 'follow' | 'full', or the legacy boolean (true = full, false = off). null = ask (show the onboarding prompt). Shared via git. A per-machine autoSync.mode choice overrides it.`}).nullable().default(null)}).default({mode:null,enabled:null,default:null}),git:o({hosts:c(p(),ve).register(P,{scope:`user`,agentSettable:!1,reload:`boot`,defaultScope:`user`,description:"Per-git-host declarations, keyed by hostname (for example ghes.example.com). Each entry says how OpenKnowledge should treat remotes on that host; today the only key an entry carries is `provider`. Hosts absent from this map are treated as generic git remotes. Per-machine (user scope, global.yml in the OpenKnowledge home folder); a value in a project's `.ok/config.yml` is ignored. Declarations take effect when OpenKnowledge next starts."}).default({}).catch({})}).default({hosts:{}}),terminal:o({enabled:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Opt-out for the in-app terminal (a real OS shell at full user privilege). The terminal is on by default; set false to disable it for this project on this machine. Per-machine (project-local) — never shared via git, clone, or sync.`}).nullable().default(null),shell:p().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Absolute Windows shell executable override for the in-app terminal. PowerShell, cmd.exe, and Git Bash support OpenKnowledge-managed launches (agent chat tabs and fixed commands such as Resolve in terminal or Install Slidev) and dropped-file path insertion. A different existing executable remains usable for plain terminal tabs and shows a capability notice; requested agent and command launches open only the plain shell without running the agent or command, and dropped-file paths are refused. Empty values use automatic shell discovery. Per-machine (project-local), human-managed, and never shared via git, clone, or sync.`}).optional()}).default({enabled:null}),slides:o({enabled:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:"Whether the Slides plugin appears in Settings → Plugins. When on, a document whose frontmatter has `slides: true` offers an action that opens the deck in a dedicated window (desktop only, requires a resolvable slidev). A personal preference (user scope). Default off."}).default(!1)}).default({enabled:!1}),telemetry:o({localSink:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Write per-project diagnostic spans + logs under the user-level OpenKnowledge logs directory for `ok diagnose bundle`. Files stay local unless shared, including in a support bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),spans:o({maxBytes:s().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic spans file before it rotates (default ~50 MB).`}).default(z)}).default({maxBytes:z}),logs:o({maxBytes:s().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local diagnostic logs file before it rotates (default ~25 MB).`}).default(B)}).default({maxBytes:B}),attributeDenylist:l(p()).register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Telemetry attribute keys whose values are redacted before any local span/log is written (credential / secret guard). Extends the built-in denylist.`}).default([...R])}).default({enabled:!0,spans:{maxBytes:z},logs:{maxBytes:B},attributeDenylist:[...R]}),skillInstallReports:o({enabled:a().register(P,{scope:`user`,agentSettable:!1,reload:`live`,defaultScope:`user`,description:`Report skill installs to skills.sh so a published skill shows an accurate install count. Sends the skill name, its source repo, and which agent tools it was installed for — never file contents, and never for a private or local source. One report per skill per machine. Default off; when it is on, the DO_NOT_TRACK and DISABLE_TELEMETRY environment variables still turn it off.`}).default(!1)}).default({enabled:!1})}).default({localSink:{enabled:!0,spans:{maxBytes:z},logs:{maxBytes:B},attributeDenylist:[...R]},skillInstallReports:{enabled:!1}}),lossCapture:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Record bridge loss-class events (content-free) under .ok/local/loss-capture/ for `ok diagnose bundle`. Local-only — never leaves the machine until you run bundle. Set false for sensitive workspaces. Shared across collaborators."}).default(!0),maxBytes:s().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Maximum size, in bytes, of the local loss-capture file before it rotates (default ~12 MB).`}).default(V)}).default({enabled:!0,maxBytes:V}),bridge:o({backgroundThrottle:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Keep the desktop window's timers running at full rate while it holds unsynced work, so backgrounding the app never starves sync or recovery; when the window is idle the OS-default background throttling is restored (battery). Honored by the desktop app. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),deferGuard:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Defer a drain-shaped Observer B re-derive when the WYSIWYG fragment holds an un-propagated keystroke Y.Text lacks, so the keystroke survives instead of being stomped. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),lossDetector:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Detect content the bridge silently dropped at its reconciliation boundary (an Observer-A apply arm or a paired agent-undo derive) and write a recovery checkpoint plus a content-free loss event. Detection only — never blocks a write. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),fixedPoint:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Bound the Y.Text→WYSIWYG re-derive loop with a drain-count backstop: a run of re-derive drains that never reaches a raw-byte fixed point freezes the re-derive loop and writes a recovery checkpoint plus a content-free loss event, instead of churning unbounded. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),preDrain:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Before an agent write or undo rebuilds the WYSIWYG fragment, flush an un-propagated keystroke that provably does not overlap the operation into Y.Text so the keystroke survives instead of needing recovery; overlapping or unmodellable cases fall back to the checkpoint floor. Scope: appending writes and single-frame undos — a write that replaces the whole body (replace / edit) overwrites the keystroke either way, so those always take the checkpoint floor. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0}),flushOnHide:o({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`On tab hide/unload, force-send each doc's unsynced work to the server and commit its local cache, and re-sync on return to foreground, so a backgrounded tab never strands edits that IndexedDB alone would lose on recycle. Honored client-side. Default ON — disable only to isolate a suspected regression.`}).default(!0)}).default({enabled:!0})}).default({backgroundThrottle:{enabled:!0},deferGuard:{enabled:!0},lossDetector:{enabled:!0},fixedPoint:{enabled:!0},preDrain:{enabled:!0},flushOnHide:{enabled:!0}}),search:o({semantic:o({enabled:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:"Add semantic (embeddings) ranking to the MCP search tool, fused with the lexical engine so conceptually-related pages surface even with no shared keywords. When ON and an API key is set (`ok embeddings set-key`), the search query and matching document content are sent to the configured embeddings provider — content egress. Default OFF. Per-machine (project-local) — not shared with collaborators."}).default(!1),baseUrl:p().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:"Base URL of the OpenAI-compatible embeddings API (default https://api.openai.com/v1). Override to point at a self-hosted server (Ollama / vLLM / LM Studio) or another provider. The API key is NOT stored here — set it with `ok embeddings set-key` (stored in secrets.yml in the OpenKnowledge home folder); it is sent to whichever endpoint this names."}).default(H),model:p().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Embeddings model id (default text-embedding-3-small). Must be served by the provider at baseUrl. Changing it re-embeds the corpus (the cache is keyed by provider + model + dimensions).`}).default(U),dimensions:s().int().positive().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Optional output vector dimensions. Omit (recommended) to detect the model's native size from its first response — that is what lets a non-OpenAI model work without knowing its size up front. Set a smaller value (text-embedding-3 supports e.g. 512 / 1024) to shrink the on-disk cache, trading a little retrieval quality; a server that ignores the request param then fails loudly instead of silently. Changing it re-embeds the corpus.`}).optional(),similarityFloor:s().min(0).max(1).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Optional hard cutoff: drop any "by meaning" match whose cosine similarity is below this value. Off by default (0) because retrieval is rank-based (the closest pages are returned regardless of absolute score) and the right cutoff is model-specific. Set it only to suppress weak matches for a specific provider/model whose cosine scale you know. Most setups should leave it unset and rely on the result-count cap.`}).optional(),maxBatchSize:s().int().min(1).max(we).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Maximum number of text chunks sent in one indexing request (1–2048, default 96). The ceiling follows OpenAI's input-array limit; other providers may impose different limits. Larger requests may still be split by the character budget. Changing it preserves cached vectors and document chunking; it applies to the next indexing pass. Invalid values use the default and are reported by ok config validate and server logs.`}).default(96).catch(96),maxBatchChars:s().int().min(1).max(Te).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Approximate cumulative character budget per indexing request (1–16384000, default 96000). A single chunk can exceed this budget. OpenAI separately caps total input at 300000 tokens per request; this character budget does not enforce that limit, and high values can produce rejected requests. Other providers have their own limits. Changing it preserves cached vectors and document chunking; it applies to the next indexing pass. Invalid values use the default and are reported by ok config validate and server logs.`}).default(W).catch(W),docTimeoutMs:s().int().min(1).max(Ee).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Timeout in milliseconds for each indexing request attempt (1–600000, default 30000). A request can retry four times, and a failed grouped request can trigger individual-document requests. There is no total indexing-pass deadline: large timeouts can delay newly queued work for hours. The query timeout remains 8 seconds per attempt. Changing it preserves cached vectors and applies to the next indexing pass; an in-progress pass keeps its current timeout. Invalid values use the default and are reported by ok config validate and server logs.`}).default(G).catch(G)}).default({enabled:!1,baseUrl:H,model:U,maxBatchSize:96,maxBatchChars:W,docTimeoutMs:G})}).default({semantic:{enabled:!1,baseUrl:H,model:U,maxBatchSize:96,maxBatchChars:W,docTimeoutMs:G}}),contentRules:o({markdownlint:u({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the markdownlint plugin (body rules) contributes diagnostics.`}).default(!1)}).default({enabled:!1}),frontmatter:u({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the frontmatter plugin (JSON-Schema validation of document frontmatter) contributes diagnostics.`}).default(!1),schemas:l(u({appliesTo:h([p(),l(p())]).optional(),file:p(),enabled:a().optional()})).register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Frontmatter schema mappings: which docs (appliesTo globs) validate against which JSON Schema file (project-root-relative path).`}).default([])}).default({enabled:!1,schemas:[]}),okf:u({enabled:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the OKF plugin (Open Knowledge Format portability + conformance rules) contributes diagnostics. Advisory warnings; never blocks a write.`}).default(!1),rules:c(p(),a()).register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Per-rule opt-outs for the OKF plugin, keyed by rule id (e.g. no-wiki-links). Omit a rule to leave it enabled; set false to silence it while keeping the plugin on.`}).optional(),generate:u({index:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether OK generates and maintains a navigation index.md in every folder that contains Markdown, each listing the documents in that folder grouped by frontmatter type and linking to its subfolders. OK owns these files: edits to them are replaced on the next rebuild.`}).default(!1)}).default({index:!1})}).default({enabled:!1,generate:{index:!1}})}).default({markdownlint:{enabled:!1},frontmatter:{enabled:!1,schemas:[]},okf:{enabled:!1,generate:{index:!1}}}),validation:o({links:d(de).register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`How broken internal links are reported on the validation plane: 'off' hides them, 'warning' (default) or 'error' sets their severity.`}).default(F),fileTreeIndicators:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether the file tree tints and badges files that have validation problems.`}).default(!0),suppressLogLinkAdvisories:a().register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:`Whether unresolved links in the reserved change-history documents (lowercase-stemmed log.md / log.mdx at any depth, where the extension's case does not matter and the stem's does) are omitted from broken-link advisories: the Problems panel, file-tree indicators, source diagnostics, audits, and agent write/edit results. Default true. Raw link views still show them, and LOG.md, Log.md, and every other stem spelling are ordinary documents.`}).default(!0)}).default({links:F,fileTreeIndicators:!0,suppressLogLinkAdvisories:!0}),autolinks:l(Se).register(P,{scope:`project`,agentSettable:!1,reload:`live`,defaultScope:`project`,description:"Turn ticket references into links; today they apply to Agents-panel chat messages. Each entry pairs a `prefix` (for example `PRD-`) with a `url` template containing `<num>` (for example `https://linear.app/inkeep/issue/PRD-<num>`); the prefix followed by digits links to that URL with the digits in place of `<num>`. Matching is case-sensitive. An invalid entry is skipped with a warning and the others still apply. Shared with collaborators (project scope, `.ok/config.yml`)."}).default([]).catch([]),linkPreviews:o({enabled:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Show a rich preview card (site name, page title, description, favicon) when you hover an external link in the editor, and a status card when you hover a GitHub pull request or issue link in an agent chat. When ON, hovering an external link sends that link's URL to the destination site to fetch its preview metadata, and hovering a GitHub reference asks the GitHub host's API for it, signed in as you when a GitHub sign-in is available — outbound egress, one request per previewed link. Default ON; set to false to turn external previews off. Per-machine (project-local) — not shared with collaborators. Previews of links to other documents in this project are read from the local index with no network request and are always on.`}).default(!0)}).default({enabled:!0}),server:o({port:s().int().min(1).max(65535).register(P,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`TCP port the server listens on. Unset by default: a local start picks a free port dynamically, and deployment platforms inject the PORT environment variable instead. Read at server start; changing it requires a restart.`}).optional(),bind:l(p().min(1)).min(1).register(P,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Addresses the server binds, e.g. [127.0.0.1] or [0.0.0.0]. Default loopback-only ([127.0.0.1]): nothing off this machine can connect. A non-loopback bind additionally requires the server.allowExternal consent interlock. Per-machine (project-local): a value committed to .ok/config.yml is ignored, so one machine exposing the server can never break local clones for the rest of the team — the exposing host sets it via OK_BIND, --bind, or .ok/local/config.yml. Lists replace, never merge. Read at server start; changing it requires a restart.`}).default([...De]),externalUrl:m({protocol:/^https?$/}).regex(ke).register(P,{scope:`project`,agentSettable:!1,reload:`boot`,defaultScope:`project`,description:`Canonical external origin the server is reached at, e.g. https://kb.example.com — its host joins the Host/Origin allowlists (external-Host + CORS admission). Unset by default: the server admits only loopback Hosts. Setting it declares external exposure, which additionally requires the server.allowExternal consent interlock. Read at server start; changing it requires a restart.`}).optional(),allowExternal:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Exposure consent interlock. A non-loopback server.bind without allowExternal: true is refused at boot with a one-line fix; a server.externalUrl without it boots (a committed externalUrl never arms exposure on clones — but it is project-scoped, so its host still joins the Host/Origin allowlists there), but requests carrying forwarding headers (X-Forwarded-For etc.) are refused until consent is given — proxy tolerance requires both keys. Default off. The server has no authentication of its own, so only consent behind an authenticating edge. Per-machine (project-local) — consent never travels via git, clone, or share; containers consent via the environment instead.`}).default(!1),openBrowser:a().register(P,{scope:`project-local`,agentSettable:!1,reload:`boot`,defaultScope:`project-local`,description:`Open the UI in a browser when the server starts. Default derived: true when every bind address is loopback (a laptop start pops the UI), false otherwise (a container or exposed bind is headless and must never try). Acts once at start. Per-machine (project-local) — not shared.`}).optional(),idleShutdown:h([f(`off`),p().regex(Oe)]).register(P,{scope:`project-local`,agentSettable:!1,reload:`live`,defaultScope:`project-local`,description:`Shut the server down after this long with no activity: a duration like '30m' (positive integer with unit s, m, or h), or 'off'. Default derived: '30m' for a loopback-only, unexposed server; 'off' otherwise — a non-loopback bind, or a loopback bind declared externally reachable (server.allowExternal + server.externalUrl), stays up, because a remote agent keeps it busy over /mcp, which the idle timer does not count. Residual case the derivation cannot see: a loopback server reached by remote agents with no server.externalUrl (e.g. behind a same-box reverse proxy) still idles at 30m — set 'off' by hand. Reloadable — a valid change applies without a restart. Per-machine (project-local) — not shared.`}).optional()}).default({bind:[...De],allowExternal:!1})});function Ze(e){let t=e;for(let e=0;e<16;e++){if(t==null||t?._zod?.def?.shape!==void 0)return t;let e=t?._zod?.def?.innerType;if(e===void 0)return t;t=e}return t}function Qe(e,t){let n=e;for(let e of t){n=Ze(n);let t=n?._zod?.def?.shape;if(!t){let e=n?._zod?.def;if(e?.type!==`record`)return;n=e.valueType;continue}if(n=t[String(e)],n===void 0)return}return n}function $e(e,t){let n=Qe(e,t);if(n!==void 0)return oe(n)}var et=n(),Y=e(t(),1),X=null,Z=new Set;function tt(){return X}function nt(e){let t=e!==null&&e.length>0?e:null;if(t!==X){X=t;for(let e of Z)try{e()}catch(e){console.warn(`[server-instance-store] subscriber threw:`,e)}}}function rt(e){return Z.add(e),()=>{Z.delete(e)}}function it(){return(0,Y.useSyncExternalStore)(rt,tt,tt)}function Q(e){return{authoritative:e,themes:A,warnings:[],truncated:!1}}function at(e){let{scheme:t}=e;return{id:e.id,label:t.name,kind:t.variant,scheme:t,toTokens:()=>D(t)}}function ot(e,t){return{id:e,label:t.name,kind:t.variant,scheme:t,toTokens:()=>D(t)}}function $(e,t,n={}){console.warn(JSON.stringify({event:`ok-saved-theme-request-failed`,action:e,result:t,...n.status===void 0?{}:{status:n.status},...n.error===void 0?{}:{errorName:n.error instanceof Error?n.error.name:`UnknownError`}}))}async function st(e={}){let t=e.request??globalThis.fetch;try{let n=await t(`/api/saved-themes`,{signal:e.signal});if(!n.ok)return $(`list`,`http-error`,{status:n.status}),Q(!1);let r=S.safeParse(await n.json());if(!r.success)return console.warn(`[themes] saved-themes response failed schema validation`,r.error.issues),Q(!1);let i=[],a=[];for(let e of r.data.themes)e.ok?i.push(at(e)):a.push({filename:e.filename,id:e.id,code:e.code,...e.conflictingFilenames?{conflictingFilenames:e.conflictingFilenames}:{}});return{authoritative:!0,themes:i.length===0?A:[...A,...i],warnings:a,truncated:r.data.truncated}}catch(t){return e.signal?.aborted||$(`list`,`request-error`,{error:t}),Q(!1)}}function ct(e){switch(e.detail){case`empty`:case`too-long`:case`invalid-chars`:return e.detail;default:return}}async function lt(e,t={}){let n=C.safeParse(e);if(!n.success)return{ok:!1,reason:`unexpected`};let r=t.request??globalThis.fetch;try{let e=await r(`/api/saved-theme`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n.data)}),t=await e.json().catch(()=>null);if(e.ok){let e=T.safeParse(t);return e.success?{ok:!0,...e.data}:{ok:!1,reason:`unexpected`}}let i=y.safeParse(t);if(!i.success)return{ok:!1,reason:`unexpected`};if(i.data.type===`urn:ok:error:theme-name-taken`)return{ok:!1,reason:`name-taken`};if(i.data.type===`urn:ok:error:theme-name-invalid`){let e=ct(i.data);return e?{ok:!1,reason:`name-invalid`,detail:e}:{ok:!1,reason:`name-invalid`}}return{ok:!1,reason:`unexpected`}}catch(e){return $(`save`,`request-error`,{error:e}),{ok:!1,reason:`unexpected`}}}async function ut(e,t={}){let n=b.safeParse(e);if(!n.success)return{ok:!1,reason:`unexpected`};let r=t.request??globalThis.fetch;try{let e=await r(`/api/saved-theme`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(n.data)}),t=await e.json().catch(()=>null);if(e.ok){let e=x.safeParse(t);return e.success?{ok:!0,...e.data}:{ok:!1,reason:`unexpected`}}let i=y.safeParse(t);return i.success&&i.data.type===`urn:ok:error:not-found`?{ok:!1,reason:`not-found`}:{ok:!1,reason:`unexpected`}}catch(e){return $(`update`,`request-error`,{error:e}),{ok:!1,reason:`unexpected`}}}async function dt(e,t={}){if(!ie(e).ok)return{ok:!1,reason:`unexpected`};let n=t.request??globalThis.fetch;try{let t=await n(`/api/saved-theme?${new URLSearchParams({id:e})}`,{method:`DELETE`}),r=await t.json().catch(()=>null);if(!t.ok)return{ok:!1,reason:`unexpected`};let i=O.safeParse(r);if(!i.success)return{ok:!1,reason:`unexpected`};if(!i.data.existed)return{ok:!0,existed:!1};let a=E.safeParse(i.data.scheme);return a.success?{ok:!0,existed:!0,filename:i.data.filename,scheme:a.data}:{ok:!1,reason:`unexpected`}}catch(e){return $(`delete`,`request-error`,{error:e}),{ok:!1,reason:`unexpected`}}}var ft=(0,Y.createContext)(null);function pt(e){let t=(0,et.c)(21),{children:n}=e,r=it(),[i,a]=(0,Y.useState)(_t),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(`custom`),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(0),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g={},t[0]=g):g=t[0];let _=(0,Y.useRef)(g),v;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(v={},t[1]=v):v=t[1];let[y,ee]=(0,Y.useState)(v),b=(0,Y.useRef)(0),x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{let e=0,t=null,n=!1,r=null,i,o=[250,1e3,4e3],c=()=>{i!==void 0&&clearTimeout(i),i=void 0},u=()=>{if(t)return n=!0,t;let i=e,o=(async()=>{let t;do{n=!1;let o=b.current,u=new AbortController;r=u;let{authoritative:d,...f}=await st({signal:u.signal});if(i!==e)return!1;t=d,d?(c(),o===b.current&&a(f),s(!0),l(!1)):l(!0)}while(n);return t})().finally(()=>{t===o&&(t=null)});return t=o,o};return{refresh:u,startAutomaticRetry:()=>{e+=1;let a=e;r?.abort(),r=null,t=null,n=!1,c();let s=async t=>{let n=await u();a!==e||n||t>=o.length||(i=setTimeout(()=>void s(t+1),o[t]))};return s(0),()=>{a===e&&(e+=1,r?.abort(),r=null,t=null,n=!1,c())}}}},t[2]=x):x=t[2];let[S]=(0,Y.useState)(x),C=S.refresh,w;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{let e=new Map,t=(t,n)=>{let r=(e.get(t)??Promise.resolve()).then(n,n),i=r.then(gt,ht);return e.set(t,i),i.finally(()=>{e.get(t)===i&&e.delete(t)}),r},n=(e,t,n)=>{b.current+=1;let r=ot(e,t);a(t=>({...t,themes:t.themes.some(t=>t.id===e)?t.themes.map(t=>t.id===e?r:t):[...t.themes,r],warnings:t.warnings.filter(t=>t.id!==e&&(n===void 0||t.filename!==n))}))};return{updateTheme:e=>t(e.id,async()=>{let t=await ut(e);return t.ok&&n(e.id,e.scheme,t.filename),t}),deleteTheme:e=>t(e,async()=>{let t=await dt(e);if(t.ok){let t={..._.current,[e]:(_.current[e]??0)+1};_.current=t,ee(t),b.current+=1,a(t=>({...t,themes:t.themes.filter(t=>t.id!==e),warnings:t.warnings.filter(t=>t.id!==e)}))}return t}),restoreTheme:e=>t(e.id,async()=>{let t=await lt({name:e.name,stem:e.stem,scheme:e.scheme,extension:e.extension});return t.ok&&n(t.id,e.scheme,t.filename),t})}},t[3]=w):w=t[3];let[T]=(0,Y.useState)(w),E;t[4]===S?E=t[5]:(E=()=>S.startAutomaticRetry(),t[4]=S,t[5]=E);let D;t[6]!==S||t[7]!==r?(D=[S,r],t[6]=S,t[7]=r,t[8]=D):D=t[8],(0,Y.useEffect)(E,D);let O;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(O=function(e){if(e===null){p(!1);return}d(e),p(!0),h(mt)},t[9]=O):O=t[9];let te=O,k;return t[10]!==n||t[11]!==i||t[12]!==u||t[13]!==c||t[14]!==o||t[15]!==T||t[16]!==C||t[17]!==f||t[18]!==m||t[19]!==y?(k=(0,Y.createElement)(ft,{value:{...i,loaded:o,loadError:c,refresh:C,...T,editingThemeId:u,themeIncarnations:y,themeEditorOpen:f,themeEditorOpenNonce:m,selectThemeToEdit:te}},n),t[10]=n,t[11]=i,t[12]=u,t[13]=c,t[14]=o,t[15]=T,t[16]=C,t[17]=f,t[18]=m,t[19]=y,t[20]=k):k=t[20],k}function mt(e){return e+1}function ht(){}function gt(){}function _t(){return Q(!1)}function vt(){let e=(0,Y.use)(ft);if(!e)throw Error(`useSavedThemes must be used within <SavedThemesProvider />`);return e}export{he as C,fe as D,le as E,ue as O,q as S,F as T,me as _,$e as a,Ne as b,Xe as c,W as d,U as f,we as g,Te as h,it as i,oe as k,H as l,Ee as m,vt as n,Qe as o,Ae as p,nt as r,Pe as s,pt as t,G as u,Ve as v,be as w,Me as x,Ye as y};
|