@clepit/core 0.9.0-beta.706 → 0.9.0-beta.801

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/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{a as e,i as t,n,r as a,t as o}from"./highlight-D9LdKWiT.mjs";var i={bg:"#ffffff",blockHighlightBg:"rgba(0, 0, 0, 0.05)",border:"rgba(17, 24, 39, 0.12)",borderSubtle:"rgba(17, 24, 39, 0.06)",codeBg:"#f2f4f7",codeBorder:"rgba(17, 24, 39, 0.10)",codeComment:"#868f9c",codeFunction:"#6f42c1",codeGutter:"#868f9c",codeKeyword:"#cf222e",codeNumber:"#0550ae",codePunctuation:"#525866",codeSelectionBg:"rgba(89, 88, 252, 0.14)",codeString:"#0a3069",codeText:"#0a0a0a",codeType:"#953800",dangerBg:"rgba(220, 38, 38, 0.12)",error:"#dc2626",errorBg:"rgba(220, 38, 38, 0.08)",focusRing:"#5958fc",hoverBg:"rgba(89, 88, 252, 0.08)",info:"#2563eb",infoBg:"rgba(37, 99, 235, 0.08)",inverseSurface:"#1b1f27",inverseText:"#ffffff",marker:"#ffe047",menuBg:"#ffffff",onPrimary:"#ffffff",pressedBg:"rgba(89, 88, 252, 0.12)",primary:"#5958fc",primaryBg:"rgba(89, 88, 252, 0.08)",primaryHover:"#4746ce",selectionBg:"rgba(89, 88, 252, 0.14)",success:"#16a34a",successBg:"rgba(22, 163, 74, 0.08)",surface:"#f8f9fa",surface2:"#f1f3f5",text:"#0a0a0a",textMuted:"#525866",textSubtle:"#868f9c",warning:"#d97706",warningBg:"rgba(217, 119, 6, 0.08)"},r={bg:"--clepit-bg",blockHighlightBg:"--clepit-block-highlight-bg",border:"--clepit-border",borderSubtle:"--clepit-border-subtle",codeBg:"--clepit-code-bg",codeBorder:"--clepit-code-border",codeComment:"--clepit-code-comment",codeFunction:"--clepit-code-function",codeGutter:"--clepit-code-gutter",codeKeyword:"--clepit-code-keyword",codeNumber:"--clepit-code-number",codePunctuation:"--clepit-code-punctuation",codeSelectionBg:"--clepit-code-selection-bg",codeString:"--clepit-code-string",codeText:"--clepit-code-text",codeType:"--clepit-code-type",dangerBg:"--clepit-danger-bg",error:"--clepit-error",errorBg:"--clepit-error-bg",focusRing:"--clepit-focus-ring",hoverBg:"--clepit-hover-bg",info:"--clepit-info",infoBg:"--clepit-info-bg",inverseSurface:"--clepit-inverse-surface",inverseText:"--clepit-inverse-text",marker:"--clepit-marker",menuBg:"--clepit-menu-bg",onPrimary:"--clepit-on-primary",pressedBg:"--clepit-pressed-bg",primary:"--clepit-primary",primaryBg:"--clepit-primary-bg",primaryHover:"--clepit-primary-hover",selectionBg:"--clepit-selection-bg",success:"--clepit-success",successBg:"--clepit-success-bg",surface:"--clepit-surface",surface2:"--clepit-surface-2",text:"--clepit-text",textMuted:"--clepit-text-muted",textSubtle:"--clepit-text-subtle",warning:"--clepit-warning",warningBg:"--clepit-warning-bg"},s=(e,t,n)=>{const a=[];for(const o of Object.keys(r)){const n=e[o],i=t[o];if(void 0===n&&void 0===i)continue;const s=r[o];void 0!==n&&void 0!==i?a.push(` ${s}: light-dark(${n}, ${i});`):a.push(` ${s}: ${n??i};`)}return 0===a.length?"":`${n} {\n${a.join("\n")}\n}`},l=class e{static{this.idSuffixes={actionBar:{clearButton:"action-bar-clear-button",copyButton:"action-bar-copy-button",downloadButton:"action-bar-download-button",editButton:"edit-button",jsonButton:"json-button",previewButton:"preview-button"},editorContent:"content"}}static{this.classNames={actionBar:{action:"clepit-view-actions",actionButton:"clepit-view-action-button",button:"clepit-action-bar-button",container:"clepit-action-bar",copyFeedback:"clepit-view-action-button--copy-feedback",group:"clepit-action-bar-group"},block:{active:"clepit-block--active",alert:"clepit-alert",audio:{captionEditable:"clepit-audio-caption-editable",container:"clepit-audio-container",dropArea:"clepit-audio-drop-area",wrapper:"clepit-audio-wrapper"},audioDeleteBtn:"clepit-audio-delete-btn",checklist:{checkbox:"clepit-checklist-checkbox",container:"clepit-checklist",item:"clepit-checklist-item",text:"clepit-checklist-text"},code:{container:"clepit-code-container",editor:"clepit-code-editor",header:"clepit-code-header",headerWrapper:"clepit-code-header-wrapper"},container:"clepit-block",content:"clepit-block-content",header:"clepit-header",image:{captionEditable:"clepit-image-caption-editable",container:"clepit-image-container",dropArea:"clepit-image-drop-area",wrapper:"clepit-image-wrapper"},imageDeleteBtn:"clepit-image-delete-btn",indent1:"clepit-block-indent-1",indent2:"clepit-block-indent-2",indent3:"clepit-block-indent-3",link:"clepit-link",list:{container:"clepit-list",item:"clepit-list-item"},output:"clepit-output-block",paragraph:"clepit-paragraph",quote:{author:"clepit-quote-author",container:"clepit-quote-container",divider:"clepit-quote-divider",text:"clepit-quote-text"},table:{caption:"clepit-table-caption",cell:"clepit-table-cell",downloadSwitch:"clepit-table-download-switch",headerCell:"clepit-table-header-cell",headerRow:"clepit-table-header-row",row:"clepit-table-row"},tooltip:"clepit-tooltip",video:{captionEditable:"clepit-video-caption-editable",container:"clepit-video-container",dropArea:"clepit-video-drop-area",iframe:"clepit-video-iframe",video:"clepit-video",wrapper:"clepit-video-wrapper"},videoDeleteBtn:"clepit-video-delete-btn"},editor:{container:"clepit-editor",content:"clepit-editor-content",jsonEditable:"clepit-json-editable",jsonEmpty:"clepit-json-empty",jsonError:"clepit-json-error",jsonOutput:"clepit-json-output"},renderer:{content:"clepit-renderer-content"},switch:{container:"clepit-custom-switch"}}}static applyStyles(e,t){t&&"object"==typeof t&&Object.entries(t).forEach(([t,n])=>{if(void 0!==n)if(t.startsWith("--"))e.style.setProperty(t,String(n));else{const a=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(a,String(n))}})}static applyClassNames(e,t){t&&("string"==typeof t?e.classList.add(t):Object.entries(t).forEach(([t,n])=>{n&&"string"==typeof n&&e.classList.add(n)}))}static applyStyling(t,n){const{styles:a,classNames:o}=n;if(a&&"object"==typeof a){const n=[],o={};Object.entries(a).forEach(([e,t])=>{void 0===t?n.push(e):o[e]=t}),Object.keys(o).length>0&&e.applyStyles(t,o),n.forEach(e=>t.style.removeProperty(e))}o&&e.applyClassNames(t,o)}static createStyledElement(t,n,a){const o=document.createElement(t);return o.className=n,a&&e.applyStyling(o,a),o}static injectStyles(t,n){if(e.injectedSheet(t))return!1;const a=new(document.defaultView?.CSSStyleSheet??CSSStyleSheet);return a.replaceSync(n),document.adoptedStyleSheets=[...document.adoptedStyleSheets,a],e.injectedSheets.set(t,a),!0}static injectedSheet(t){const n=e.injectedSheets.get(t);return n&&document.adoptedStyleSheets.includes(n)?n:void 0}static removeStyles(t){const n=e.injectedSheets.get(t);n&&(e.injectedSheets.delete(t),document.adoptedStyleSheets=document.adoptedStyleSheets.filter(e=>e!==n))}static{this.injectedSheets=/* @__PURE__ */new Map}static{this.themeRegistry=/* @__PURE__ */new Map}static{this.themeSubscribers=/* @__PURE__ */new Set}static registerEditor(t,n,a){const o=document.getElementById(t);if(o&&(o.setAttribute("data-clepit-theme",n),o.setAttribute("data-clepit-instance",t)),e.themeRegistry.set(t,n),e.syncBodyThemeAttribute(),e.removeStyles(`clepit-overrides-${t}`),a){const n=s(a.light??{},a.dark??{},`[data-clepit-instance='${t}']`);n&&e.injectStyles(`clepit-overrides-${t}`,n)}e.ensureThemeListener()}static unregisterEditor(t){e.removeStyles(`clepit-overrides-${t}`);const n=document.getElementById(t);n&&(n.removeAttribute("data-clepit-theme"),n.removeAttribute("data-clepit-instance")),e.themeRegistry.delete(t),e.syncBodyThemeAttribute(),e.maybeDetachThemeListener()}static syncBodyThemeAttribute(){if("undefined"==typeof document||!document.body)return;const t=e.themeRegistry.values().next().value;t?document.body.setAttribute("data-clepit-theme",t):document.body.removeAttribute("data-clepit-theme")}static getResolvedTheme(){return"undefined"==typeof window||"function"!=typeof window.matchMedia?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}static subscribe(t){return e.themeSubscribers.add(t),e.ensureThemeListener(),()=>{e.themeSubscribers.delete(t),e.maybeDetachThemeListener()}}static unregisterAllEditorsForTest(){for(const t of Array.from(e.themeRegistry.keys()))e.unregisterEditor(t);e.themeSubscribers.clear(),e.maybeDetachThemeListener()}static ensureThemeListener(){"undefined"!=typeof window&&"function"==typeof window.matchMedia&&0!==e.themeSubscribers.size&&(e.themeMediaQuery||(e.themeMediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaQueryListener=t=>{const n=t.matches?"dark":"light";for(const a of e.themeSubscribers)a(n)},e.themeMediaQuery.addEventListener("change",e.themeMediaQueryListener)))}static maybeDetachThemeListener(){e.themeSubscribers.size>0||e.themeMediaQuery&&e.themeMediaQueryListener&&(e.themeMediaQuery.removeEventListener("change",e.themeMediaQueryListener),e.themeMediaQuery=void 0,e.themeMediaQueryListener=void 0)}},c=e=>{const t=e.trim().toLowerCase().replace(/[\x00-\x20]/g,"");return!t.startsWith("javascript:")&&!t.startsWith("data:")&&!t.startsWith("vbscript:")},d=e=>/^https?:\/\//i.test(e.trim());function p(e,t,n){const a=document.createElement(e);if(t&&(a.className=t),n)for(const[o,i]of Object.entries(n))a.setAttribute(o,i);return a}function u(e,t){return`${e}-${t}`}function h(e){return!e||!e.trim()||"<br>"===e}function m(e){if(!e||h(e))return"";const t=document.implementation.createHTMLDocument("");t.body.innerHTML=e;const n=["strong","b","em","i","u","s","del","mark","code","a","span"],a=["href","target","title","contenteditable","data-tooltip","data-status","data-status-variant","data-user-id","data-page-id","data-issue-tool","data-issue-key","data-issue-title","data-issue-state","data-issue-category","data-issue-assignee","data-issue-avatar","data-issue-updated","data-issue-url","data-issue-pull","data-issue-reason","class"];function o(e){if(e.nodeType===Node.TEXT_NODE)return document.createTextNode(e.textContent||"");if(e.nodeType===Node.ELEMENT_NODE){const t=e,i=t.tagName.toLowerCase();if(!n.includes(i))return document.createTextNode(t.textContent||"");const r=document.createElement(i);for(const e of t.attributes){const t=e.name.toLowerCase();a.includes(t)&&("href"!==t||c(e.value))&&r.setAttribute(e.name,e.value)}"a"===i&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer"));for(const e of Array.from(t.childNodes)){const t=o(e);t&&r.appendChild(t)}return r}return null}const i=document.createElement("div");for(const r of Array.from(t.body.childNodes)){const e=o(r);e&&i.appendChild(e)}return i.innerHTML}function g(e,t){const n=window.getSelection();if(!n||0===n.rangeCount)return!1;const a=n.getRangeAt(0);if(!a)return!1;if(!e.contains(a.commonAncestorContainer))return!1;if(0===(e.textContent||"").length)return!0;if("left"===t){const t=e.firstChild;return t&&t.nodeType===Node.TEXT_NODE?a.startContainer===t&&0===a.startOffset:a.startContainer===e&&0===a.startOffset}{const t=e.lastChild;return t&&t.nodeType===Node.TEXT_NODE?a.endContainer===t&&a.endOffset===t.textContent?.length:a.endContainer===e&&a.endOffset===e.childNodes.length}}var b="data-showing-locale",f="clepit-block-showing-locale",v=class e{static{this.shown={}}static note(t,n,a){const o={...e.shown[t]};null===a?delete o[n]:o[n]=a,e.shown[t]=o}static apply(t,n){const a=n.getAttribute("data-id"),o=a?e.shown[t]?.[a]:void 0,i=n.querySelector(`.${l.classNames.block.content}`);if(n.querySelector(`.${f}`)?.remove(),void 0===o)return n.removeAttribute(b),void i?.removeAttribute("lang");n.setAttribute(b,o),i?.setAttribute("lang",o);const r=p("span",f);r.setAttribute("data-testid",f),r.textContent=o.toUpperCase(),i?n.insertBefore(r,i):n.appendChild(r)}static clear(t,n){if(!n.hasAttribute(b))return;const a=n.getAttribute("data-id");a&&e.note(t,a,null),e.apply(t,n)}static forget(t){delete e.shown[t]}},y=e=>{let t;const n=/* @__PURE__ */new Set,a=(e,a)=>{const o="function"==typeof e?e(t):e;if(Object.is(o,t))return;const i=t;t=a?o:Object.assign({},t,o);for(const r of n)r(t,i)},o=()=>t,i={getInitialState:()=>r,getState:o,setState:a,subscribe:e=>(n.add(e),()=>{n.delete(e)})},r=t=e(a,o,i);return i};var x,k,w,C=(w?y(w):y)((e=>(t,n,a)=>{const o=a.subscribe;return a.subscribe=(e,t,n)=>{if(!t)return o(e);const i=n?.equalityFn??Object.is;let r=e(a.getState());return n?.fireImmediately&&t(r,r),o(n=>{const a=e(n);if(!i(r,a)){const e=r;t(r=a,e)}})},e(t,n,a)})((e=>(t,n,a)=>e(t,n,a))((x=(e,t)=>({addBlock:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=[...i.data.blocks];void 0===o||o<0||o>r.length?r.push(a):r.splice(o,0,a);const s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},addInstance:(n,a)=>{const o=t().instances;o[n]?o[n].config=a.config:o[n]=a,e({instances:o})},clearData:n=>{const a=t().instances[n];if(!a)return;const o={...a,data:{...a.data,blocks:[]}};e(e=>({instances:{...e.instances,[n]:o}})),a.config.onChange&&a.config.onChange(o.data)},getContentElement:e=>{const n=t().instances[e];return n?document.querySelector(`#${n.contentId}`):null},getCurrentView:e=>t().instances[e]?.currentView||null,getData:e=>t().instances[e]?.data||null,getInstance:e=>t().instances[e]||null,getIsReady:e=>{const n=t().instances[e];return!!n&&n.isReady},instances:{},partialUpdateBlockData:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,data:{...e.data,...o}}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},removeBlock:(n,a)=>{const o=t().instances[n];if(!o)return;const i=o.data.blocks.filter((e,t)=>t!==a),r={...o,data:{...o.data,blocks:i}};e(e=>({instances:{...e.instances,[n]:r}})),o.config.onChange&&o.config.onChange(r.data)},removeInstance:t=>{e(e=>{const n={...e.instances};return delete n[t],{instances:n}})},seedBlocks:(n,a)=>{const o=t().instances[n];o&&e(e=>({instances:{...e.instances,[n]:{...o,data:{...o.data,blocks:a}}}}))},setCurrentView:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,currentView:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},setData:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,data:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(a)},setIsReady:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,isReady:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},updateBlock:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,...o}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},updateBlockData:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,data:o}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},updateData:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,data:{...o.data,...a}};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},updateInstance:(n,a)=>{const o=t().instances;o[n]&&(o[n].data=a.data,e({instances:o}))}}),k={name:"clepit-store",version:0},(e,t,n)=>{const a=k.version??0,o=k.storage??("undefined"==typeof localStorage?void 0:localStorage),i=k.merge??((e,t)=>Object.assign({},t,e)),r=x(e,t,n);if(o){try{const e=o.getItem(k.name);if(e){const t=JSON.parse(e),n=t.version===a?t.state:k.migrate?k.migrate(t.state,t.version??0):void 0;void 0!==n&&Object.assign(r,i(n,r))}}catch(s){console.warn(`store persist: "${k.name}" could not be read, starting from the initial state`,s)}n.subscribe(e=>{try{o.setItem(k.name,JSON.stringify({state:k.partialize?k.partialize(e):e,version:a}))}catch(s){console.warn(`store persist: "${k.name}" could not be written, this change stays in memory`,s)}})}return r})))),A=["http:","https:"],S=["youtube.com","www.youtube.com","m.youtube.com","youtu.be"],E=["file","design","board","proto","slides","deck"],L=["document","spreadsheets","presentation"],N=/^[0-9a-f]{32}$/,B=/^[A-Za-z0-9]+$/,$={figma:"figma",githubGist:"github_gist",googleDrive:"google_drive",loom:"loom",miro:"miro"};function M(e,t){const n=$[e];return void 0!==n&&(t??[]).includes(n)}var I=(e,t="link")=>({embedUrl:null,provider:t,url:e});function T(e,t){return e===t||e.endsWith(`.${t}`)}function _(e,t){const n=e.hostname.toLowerCase(),a=e.toString();if(S.includes(n)){const t=function(e){if(T(e.hostname,"youtu.be"))return e.pathname.slice(1).split("/")[0]||null;if("/watch"===e.pathname)return e.searchParams.get("v");const t=e.pathname.match(/^\/(?:embed|shorts|live)\/([^/]+)/);return t?t[1]:null}(e);return t?{aspect:16/9,embedUrl:`https://www.youtube.com/embed/${encodeURIComponent(t)}`,provider:"youtube",url:a}:I(a,"youtube")}if(T(n,"figma.com")){const[,t,n]=e.pathname.split("/");return t&&n&&E.includes(t)?{aspect:4/3,embedUrl:`https://embed.figma.com/${"file"===t?"design":t}/${encodeURIComponent(n)}?embed-host=clepit`,provider:"figma",url:a}:I(a,"figma")}if(T(n,"miro.com")){const t=e.pathname.match(/^\/app\/board\/([^/]+)/);return t?{aspect:16/9,embedUrl:`https://miro.com/app/live-embed/${encodeURIComponent(t[1])}`,provider:"miro",url:a}:I(a,"miro")}if(T(n,"loom.com")){const[,t,n]=e.pathname.split("/");return("share"===t||"embed"===t)&&n&&B.test(n)?{aspect:16/9,embedUrl:`https://www.loom.com/embed/${encodeURIComponent(n)}?hide_share=true`,provider:"loom",url:a}:I(a,"loom")}if("drive.google.com"===n){const t=e.pathname.match(/^\/file\/d\/([^/]+)/),n="/open"===e.pathname?e.searchParams.get("id"):null,o=t?.[1]??n;return o?{aspect:4/3,embedUrl:`https://drive.google.com/file/d/${encodeURIComponent(o)}/preview`,provider:"googleDrive",url:a}:I(a,"googleDrive")}if("docs.google.com"===n){const[,t,n,o]=e.pathname.split("/");return t&&L.includes(t)&&"d"===n&&o?{aspect:4/3,embedUrl:`https://docs.google.com/${t}/d/${encodeURIComponent(o)}/preview`,provider:"googleDrive",url:a}:I(a,"googleDrive")}if("gist.github.com"===n){const[,t,n]=e.pathname.split("/");return t&&n&&N.test(n)?{embedUrl:null,gist:{id:n,owner:t},provider:"githubGist",url:a}:I(a,"githubGist")}if(T(n,"airtable.com")){const t=e.pathname.match(/^\/embed\/([^/]+)/),n=e.pathname.match(/^\/(shr[^/]+)/),o=t?.[1]??n?.[1];return o?{aspect:4/3,embedUrl:`https://airtable.com/embed/${encodeURIComponent(o)}`,provider:"airtable",url:a}:I(a,"airtable")}if(T(n,"diagrams.net")||T(n,"drawio.com"))return{aspect:4/3,embedUrl:`https://viewer.diagrams.net/?edit=_blank&layers=1&nav=1#U${encodeURIComponent(a)}`,provider:"drawio",url:a};if(T(n,"google.com")&&e.pathname.startsWith("/maps")){const n=t?.mapsEmbedKey,o=e.searchParams.get("q");return n&&o?{aspect:4/3,embedUrl:`https://www.google.com/maps/embed/v1/place?key=${encodeURIComponent(n)}&q=${encodeURIComponent(o)}`,provider:"googleMaps",url:a}:I(a,"googleMaps")}return I(a)}function q(e,t){const n=function(e){try{const t=new URL(e);return A.includes(t.protocol)?t:null}catch{return null}}(e);if(!n)return{embedUrl:null,provider:"invalid",url:e};const a=_(n,t);return M(a.provider,t?.disabledProviders)?{embedUrl:null,provider:a.provider,switchedOff:!0,url:a.url}:a}async function D(e,t,n,a){const o=C.getState().getInstance(e)?.config,i=function(e,t){return{data:"card"===t?{display:"card",url:e}:{url:e},type:"embed"}}(a,"card"===(o?.pasteEmbeds??"live")?"card":"live");n?_s.replaceBlock(e,t,i):_s.insertBlock(i,e,t+1);const r=_s.getBlocks(e)[n?t:t+1]?.getAttribute("data-id")??null;return r&&o?.resolveLink&&await z(e,r,o.resolveLink),r}async function z(e,t,n){if(!n)return;const a=_s.getBlockData(t).data;try{const o=await n(a.url),{reason:i,...r}=a;_s.updateBlockData(t,{...r,...o,url:a.url},e)}catch{_s.updateBlockData(t,{...a,reason:"provider_unreachable"},e)}}var j="\n.clepit-embed {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n overflow: hidden;\n}\n.clepit-embed__frame {\n display: block;\n width: 100%;\n border: 0;\n}\n.clepit-embed-card {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n color: inherit;\n text-decoration: none;\n}\n.clepit-embed-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-embed-card__title {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-embed-card__description {\n opacity: 0.7;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n.clepit-embed-card--with-reason {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n}\n.clepit-embed-card--with-reason > .clepit-embed-card {\n padding: 0;\n border: 0;\n}\n.clepit-embed-card__reason {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 14px;\n align-items: center;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-embed-card__action {\n padding: 0;\n font: inherit;\n color: inherit;\n text-decoration: underline;\n background: none;\n border: 0;\n cursor: pointer;\n}\n.clepit-embed--gist-frame .clepit-embed__frame {\n height: 552px;\n}\n.clepit-embed-gist {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n.clepit-embed-gist__file {\n display: flex;\n gap: 10px;\n align-items: baseline;\n font-size: 0.9em;\n}\n.clepit-embed-gist__file b {\n font-weight: 600;\n}\n.clepit-embed-gist__file a {\n margin-left: auto;\n color: inherit;\n opacity: 0.7;\n}\n.clepit-embed-offer {\n position: absolute;\n z-index: 20;\n display: inline-flex;\n gap: 6px;\n align-items: center;\n padding: 4px 4px 4px 10px;\n font-size: 12px;\n background: var(--clepit-surface, #fff);\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 999px;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);\n}\n.clepit-embed-offer button {\n padding: 3px 9px;\n font: inherit;\n font-weight: 600;\n color: #fff;\n background: var(--clepit-primary, #5958fc);\n border: 0;\n border-radius: 999px;\n cursor: pointer;\n}\n",H=j,O=j,P=class{constructor(e){this.node=e}get tag(){return this.node.tagName.toLowerCase()}setAttribute(e,t){this.node.setAttribute(e,t)}addClass(...e){this.node.classList.add(...e.filter(Boolean))}setText(e){this.node.textContent=e}setHtml(e){this.node.innerHTML=m(e)}append(e){this.node.appendChild(e.node)}appendText(e){this.node.appendChild(document.createTextNode(e))}},R={create:e=>new P(document.createElement(e)),createNS:(e,t)=>new P(document.createElementNS(e,t))},F=/* @__PURE__ */new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),V=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),U=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;"),W=class{constructor(e,t){this.tag=e,this.sanitize=t,this.attributes=/* @__PURE__ */new Map,this.classes=[],this.children=[]}setAttribute(e,t){this.attributes.set(e,t)}addClass(...e){for(const t of e.filter(Boolean))this.classes.includes(t)||this.classes.push(t)}setText(e){this.children.length=0,this.children.push(V(e))}setHtml(e){this.children.length=0,this.children.push(this.sanitize(e))}append(e){this.children.push(e.toString())}appendText(e){this.children.push(V(e))}toString(){const e=[...this.classes.length>0?[`class="${U(this.classes.join(" "))}"`]:[],...[...this.attributes].map(([e,t])=>`${e}="${U(t)}"`)],t=[this.tag,...e].join(" ");return F.has(this.tag)?`<${t}>`:`<${t}>${this.children.join("")}</${this.tag}>`}},K=e=>({create:t=>new W(t,e),createNS:(t,n)=>new W(n,e)}),G=e=>String(e),J=e=>{if(!(e instanceof P))throw new TypeError("toDomElement needs an element built by the dom backing");return e.node};function X(){l.injectStyles("clepit-invalid-data-styles","\n/* Invalid data component styles */\n.clepit-invalid-data {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 1rem 0;\n background: #ffebee;\n color: #c62828;\n}\n\n.clepit-invalid-data-text {\n font-weight: bold;\n margin: 0;\n padding: 0;\n}\n");const e=p("div","clepit-invalid-data"),t=p("div","clepit-invalid-data-text");return t.textContent="Invalid data",e.appendChild(t),e}var Y={assembly:"Assembly",bash:"Bash",clojure:"Clojure",cobol:"COBOL",cpp:"C++",csharp:"C#",css:"CSS",dart:"Dart",diff:"Diff",dockerfile:"Dockerfile",erlang:"Erlang",fortran:"Fortran",go:"Go",graphql:"GraphQL",groovy:"Groovy",haskell:"Haskell",html:"HTML",java:"Java",javascript:"JavaScript",json:"JSON",jsx:"JSX",julia:"Julia",kotlin:"Kotlin",lua:"Lua",markdown:"Markdown",nginx:"Nginx",objectivec:"Objective-C",pascal:"Pascal",perl:"Perl",php:"PHP",plaintext:"Plain Text",powershell:"PowerShell",protobuf:"Protocol Buffers",python:"Python",r:"R",ruby:"Ruby",rust:"Rust",scala:"Scala",scheme:"Scheme",shell:"Shell",sql:"SQL",swift:"Swift",toml:"TOML",tsx:"TSX",typescript:"TypeScript",vb:"Visual Basic",verilog:"Verilog",vhdl:"VHDL",xml:"XML",yaml:"YAML"};function Z(e){return Y[e]||"Unknown"}var Q=Object.fromEntries(Object.keys(n).map(e=>[e,{name:Z(e)}])),ee=`\n/* Code block styles */\n.clepit-code {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-code-pre {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool="code"] .clepit-block-content {\n background: transparent;\n border: none;\n padding: 0;\n margin-right: 8px;\n}\n\n/* Code placeholder styles */\n.clepit-code[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Code container */\n.${l.classNames.block.code.container} {\n border: 1px solid var(--clepit-code-border);\n background: var(--clepit-code-bg);\n border-radius: var(--clepit-radius-md);\n overflow: visible; /* allow header tooltips to escape */\n margin: 8px 0;\n}\n\n.${l.classNames.block.code.editor} {\n height: 200px;\n max-height: 60vh;\n min-height: 200px;\n overflow: hidden;\n position: relative;\n}\n\n/* The editing surface: a textarea laid over a highlighted pre. The two must\n * agree on every metric that affects where a glyph lands, or the caret drifts\n * away from the colour behind it. They inherit from one rule for that reason. */\n.${l.classNames.block.code.editor} .clepit-code-highlight,\n.${l.classNames.block.code.editor} .clepit-code-input {\n margin: 0;\n border: 0;\n padding: 12px 34px;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n letter-spacing: normal;\n tab-size: 2;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n overflow: auto;\n scrollbar-gutter: stable;\n box-sizing: border-box;\n}\n\n.${l.classNames.block.code.editor} .clepit-code-highlight {\n position: absolute;\n inset: 0;\n pointer-events: none;\n color: var(--clepit-code-text);\n}\n\n/* The text itself is transparent: the colour the reader sees belongs to the pre\n * behind it. The caret keeps a colour of its own so it stays visible. */\n.${l.classNames.block.code.editor} .clepit-code-input {\n position: relative;\n width: 100%;\n height: 100%;\n display: block;\n background: transparent;\n color: transparent;\n caret-color: var(--clepit-code-text);\n resize: none;\n outline: none;\n}\n\n.${l.classNames.block.code.editor} .clepit-code-input::placeholder {\n color: var(--clepit-text-muted);\n}\n\n.${l.classNames.block.code.editor} .clepit-code-input::selection {\n background: var(--clepit-code-selection-bg);\n color: transparent;\n}\n\n/* Code header */\n.${l.classNames.block.code.headerWrapper} {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n width: 100%;\n padding: 8px 34px;\n position: relative; /* allow inner tooltip absolute positioning */\n overflow: visible; /* ensure tooltip not clipped */\n z-index: 2;\n border-bottom: 1px solid var(--clepit-border-color);\n}\n\n.${l.classNames.block.code.header} {\n font-size: 12px;\n font-weight: 500;\n}\n\n/* Code Language Submenu */\n.clepit-code-language-submenu {\n position: absolute;\n top: 0;\n left: 100%;\n z-index: 1002;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 160px;\n max-width: 200px;\n margin-left: 4px;\n max-height: 300px;\n overflow-y: auto;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-code-language-submenu--visible {\n display: block !important;\n transform: translateX(0);\n}\n\n.clepit-code-language-submenu--hidden {\n display: none !important;\n}\n\n/* Code Theme Submenu */\n.clepit-code-theme-submenu {\n position: absolute;\n top: 0;\n left: 100%;\n z-index: 1002;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 140px;\n max-width: 180px;\n margin-left: 4px;\n max-height: 250px;\n overflow-y: auto;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-code-theme-submenu--visible {\n display: block !important;\n transform: translateX(0);\n}\n\n.clepit-code-theme-submenu--hidden {\n display: none !important;\n}\n\n/* Code language submenu items */\n.clepit-code-language-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.clepit-code-language-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-surface));\n}\n\n/* Code theme submenu items */\n.clepit-code-theme-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.clepit-code-theme-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-surface));\n}\n\n\n`,te="\n/* Output Code Block */\n/* No margin of its own — every consumer already governs the gap around this\n * container (page rhythm via the block wrapper's margin-block, or a flex\n * container's gap inside the openapi block). A margin here just adds a second,\n * inconsistent gap on top of whichever one the consumer already applies. */\n.clepit-output-code-container {\n border: 1px solid var(--clepit-code-border);\n border-radius: var(--clepit-radius-md);\n overflow: hidden;\n background: var(--clepit-code-bg);\n margin: 0;\n}\n\n.clepit-output-code-header {\n background: var(--clepit-code-bg);\n padding: 8px 34px;\n border-bottom: 1px solid var(--clepit-code-border);\n font-size: 12px;\n color: var(--clepit-text-muted);\n font-weight: 500;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n/* Output header — theme-agnostic; tokens handle light/dark automatically */\n.clepit-output-code-header {\n background: var(--clepit-code-bg);\n color: var(--clepit-text-muted);\n border-bottom-color: var(--clepit-code-border);\n --clepit-svg-stroke-color: var(--clepit-text-muted);\n --clepit-btn-hover-bg: var(--clepit-block-highlight-bg);\n}\n\n/* Output code variant tabs */\n.clepit-output-code-tabs {\n display: flex;\n align-items: stretch;\n gap: 4px;\n margin: -8px 0 -8px -18px;\n overflow-x: auto;\n scrollbar-width: none;\n}\n\n.clepit-output-code-tabs::-webkit-scrollbar {\n display: none;\n}\n\n.clepit-output-code-tab {\n appearance: none;\n -webkit-appearance: none;\n background: transparent;\n border: none;\n border-bottom: 2px solid transparent;\n color: var(--clepit-text-muted);\n cursor: pointer;\n font: inherit;\n padding: 8px 10px;\n transition: color 0.2s ease, border-color 0.2s ease;\n white-space: nowrap;\n}\n\n.clepit-output-code-tab:hover {\n color: var(--clepit-text);\n}\n\n.clepit-output-code-tab[aria-selected=\"true\"] {\n border-bottom-color: var(--clepit-primary);\n color: var(--clepit-primary);\n}\n\n.clepit-output-code-tab:focus-visible {\n outline: 2px solid var(--clepit-primary);\n outline-offset: -2px;\n}\n\n.clepit-output-code-editor {\n overflow-y: auto;\n max-height: 60vh;\n position: relative;\n border: none;\n border-radius: 0;\n}\n\n/* The output panes: one pre per variant, the inactive ones carrying a hidden attribute.\n * Colour comes from the generated theme stylesheet, keyed on the container's\n * data-theme, so a published page keeps its palette with nothing running. */\n.clepit-output-code-pane {\n margin: 0;\n padding: 12px 34px;\n max-height: 60vh;\n overflow-y: auto;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n tab-size: 2;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n\n/* Code Output */\n.clepit-output-code {\n margin: 1rem 0;\n background-color: var(--clepit-code-bg);\n border: 1px solid var(--clepit-code-border);\n border-radius: var(--clepit-radius-md);\n overflow: hidden;\n}\n\n.clepit-output-code code {\n display: block;\n padding: 1rem;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n color: var(--clepit-code-text);\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n\n/* Output code copy button */\n.clepit-output-code-copy-btn {\n margin-left: auto;\n width: 24px;\n height: 24px;\n border: none;\n outline: none;\n cursor: pointer;\n border-radius: 50%;\n background: transparent;\n transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.clepit-output-code-copy-btn {\n color: var(--clepit-text-muted);\n}\n\n.clepit-output-code-copy-btn:hover {\n background: var(--clepit-block-highlight-bg);\n color: var(--clepit-primary);\n}\n\n.clepit-output-code-copy-btn:hover .clepit-copy-icon {\n stroke: var(--clepit-primary);\n}\n\n.clepit-output-code-copy-btn:active {\n transform: scale(0.95);\n}\n\n.clepit-copy-icon,\n.clepit-check-icon {\n width: 20px;\n height: 20px;\n stroke: var(--clepit-svg-stroke-color);\n stroke-width: 2;\n fill: none;\n display: block;\n}\n\n/* Code output button animation styles */\n.clepit-output-code-copy-btn--animating {\n color: var(--clepit-success);\n transform: scale(1.1);\n}\n\n.clepit-output-code-copy-btn--normal {\n color: var(--clepit-svg-stroke-color);\n transform: scale(1);\n}\n",ne=(e,t,n)=>C.getState().getInstance(e)?.config.blockToolbarLabels?.[t]||n,ae={auto:"Auto",dark:"Dark",default:"Auto",dracula:"Dracula",github:"GitHub","github-dark":"GitHub Dark",light:"Light",monokai:"Monokai",solarized:"Solarized","solarized-dark":"Solarized Dark",tomorrow:"Tomorrow"};function oe(e){return ae[e]||"Unknown"}var ie=Object.fromEntries(Object.keys(ae).map(e=>[e,{name:oe(e),theme:null}])),re=".clepit-output-code-container",se=`.${l.classNames.block.code.container}`,le="clepit-code-output-styles-theme",ce=(e,n)=>[`${[re,se].map(t=>`${t}${e}`).join(", ")} { background: ${n.background}; color: ${n.text}; }`,`${se}${e} .clepit-code-highlight { color: ${n.text}; }`,`${se}${e} .clepit-code-input { caret-color: ${n.text}; }`,...t.map(t=>`${((e,t)=>[re,se].map(n=>`${n}${e} ${t}`).join(", "))(e,`.clepit-code-${t}`)} { color: ${n[t]};${(e=>"comment"===e?" font-style: italic;":"")(t)} }`)].join("\n"),de=()=>[ce("",e()),...Object.entries(a).map(([e,t])=>ce(`[data-theme='${e}']`,t))].join("\n"),pe=`\n/* Custom Switch Container */\n.${l.classNames.switch.container} {\n --switch-blue: #0D7EFF;\n --switch-red: #FF0D0D;\n --switch-text: var(--clepit-bg);\n --switch-white: var(--clepit-bg);\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 8px;\n}\n\n.${l.classNames.switch.container} .tgl {\n display: none;\n}\n\n.${l.classNames.switch.container} .tgl,\n.${l.classNames.switch.container} .tgl:after,\n.${l.classNames.switch.container} .tgl:before,\n.${l.classNames.switch.container} .tgl *,\n.${l.classNames.switch.container} .tgl *:after,\n.${l.classNames.switch.container} .tgl *:before,\n.${l.classNames.switch.container} .tgl + .tgl-btn {\n box-sizing: border-box;\n}\n\n.${l.classNames.switch.container} .tgl::selection,\n.${l.classNames.switch.container} .tgl:after::selection,\n.${l.classNames.switch.container} .tgl:before::selection,\n.${l.classNames.switch.container} .tgl *::selection,\n.${l.classNames.switch.container} .tgl *:after::selection,\n.${l.classNames.switch.container} .tgl *:before::selection,\n.${l.classNames.switch.container} .tgl + .tgl-btn::selection {\n background: none;\n}\n\n.${l.classNames.switch.container} .tgl + .tgl-btn {\n outline: 0;\n display: block;\n width: 57px;\n height: 27px;\n position: relative;\n cursor: pointer;\n user-select: none;\n font-size: 12px;\n font-weight: 400;\n color: var(--switch-white);\n}\n\n.${l.classNames.switch.container} .tgl + .tgl-btn:after,\n.${l.classNames.switch.container} .tgl + .tgl-btn:before {\n position: relative;\n display: block;\n content: "";\n width: 44%;\n height: 100%;\n}\n\n.${l.classNames.switch.container} .tgl + .tgl-btn:after {\n left: 0;\n}\n\n.${l.classNames.switch.container} .tgl + .tgl-btn:before {\n display: inline;\n position: absolute;\n top: 3px;\n}\n\n.${l.classNames.switch.container} .tgl:checked + .tgl-btn:after {\n transform: translateX(calc(100% * 56.5 / 44));\n}\n\n.${l.classNames.switch.container} .tgl-ios + .tgl-btn {\n background: var(--switch-red);\n border-radius: 20rem;\n padding: 2px;\n transition: background-color 0.4s ease, box-shadow 0.4s ease;\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);\n}\n\n.${l.classNames.switch.container} .tgl-ios + .tgl-btn:after {\n border-radius: 2em;\n background: var(--switch-white);\n transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);\n box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.2);\n}\n\n.${l.classNames.switch.container} .tgl-ios + .tgl-btn:before {\n content: "No";\n left: 6px;\n transform: translateX(24px);\n color: var(--switch-text);\n transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);\n}\n\n.${l.classNames.switch.container} .tgl-ios + .tgl-btn:active {\n box-shadow: inset 0 0 0 30px rgba(0, 0, 0, 0.1);\n}\n\n.${l.classNames.switch.container} .tgl-ios + .tgl-btn:active:after {\n padding-right: 0.4em;\n}\n\n.${l.classNames.switch.container} .tgl-ios:checked + .tgl-btn {\n background: var(--switch-blue);\n}\n\n.${l.classNames.switch.container} .tgl-ios:checked + .tgl-btn:active {\n box-shadow: inset 0 0 0 30px rgba(0, 0, 0, 0.1);\n}\n\n.${l.classNames.switch.container} .tgl-ios:checked + .tgl-btn:active:after {\n transform: translateX(calc(100% * 56.5 / 44 - 0.4em));\n}\n\n.${l.classNames.switch.container} .tgl-ios:checked + .tgl-btn:before {\n content: "Yes";\n transform: none;\n color: var(--switch-white);\n}\n\n.clepit-switch-label-text {\n font-size: 13px;\n display: flex;\n align-items: center;\n}\n`,ue=class{static create(e={}){const{checked:t=!1,onToggle:n,classNames:a,styles:o,label:i,id:r=`switch-${Math.random().toString(36).substring(2,11)}`}=e;l.injectStyles("clepit-custom-switch-styles",pe);const s=l.createStyledElement("div",l.classNames.switch.container,{classNames:a?.container,styles:o?.container}),c=l.createStyledElement("input","tgl tgl-ios",{classNames:a?.input,styles:o?.input});c.type="checkbox",c.id=r,c.checked=t;const d=l.createStyledElement("label","tgl-btn",{classNames:a?.label,styles:o?.label});if(d.setAttribute("for",r),n&&c.addEventListener("change",e=>{const t=e.target;n(t.checked)}),s.appendChild(c),s.appendChild(d),i){const e=l.createStyledElement("span","clepit-switch-label-text",{classNames:a?.labelText,styles:o?.labelText});e.textContent=i,s.appendChild(e)}return s}static getState(e){const t=e.querySelector('input[type="checkbox"]');return!!t&&t.checked}static setState(e,t){const n=e.querySelector('input[type="checkbox"]');n&&(n.checked=t)}},he=class e{static{this.placeholder="Enter code..."}static{this.supportedLanguages=Q}static{this.supportedThemes=ie}static{this.defaultLanguage="typescript"}static{this.defaultTheme="auto"}static{this.inputMap=/* @__PURE__ */new WeakMap}static{this.dataMap=/* @__PURE__ */new WeakMap}static save(t){const n=t.querySelector(`.${l.classNames.block.code.container}`),a=n.querySelector(`.${l.classNames.block.code.headerWrapper}`),o=n?.getAttribute("data-language")||e.defaultLanguage,i=n?.getAttribute("data-theme")||e.defaultTheme,r=!!a&&ue.getState(a),s=e.inputMap.get(n);if(s){const t=s.value,a=e.dataMap.get(n),l={code:t.trim()||"",language:o,showCopy:r,theme:i};return a?.variants?.length&&(l.variants=a.variants),a?.syncKey&&(l.syncKey=a.syncKey),e.dataMap.set(n,l),l}return{...e.dataMap.get(n)||{code:"",language:e.defaultLanguage,theme:e.defaultTheme},showCopy:r}}static addVariant(e){const t=e.variants?.length?e.variants:[{code:e.code,...e.language?{language:e.language}:{}}];return{...e,variants:[...t,{code:""}]}}static removeVariant(e,t){const n=(e.variants??[]).filter((e,n)=>n!==t),a=n[0],o={...e,code:a?.code??e.code,...a?.language?{language:a.language}:{}};if(n.length<=1){const{variants:e,...t}=o;return t}return{...o,variants:n}}static render(t,n,a,o){l.injectStyles("clepit-code-input-styles",ee),l.injectStyles(le,de());const i={code:"",language:o?.language||e.defaultLanguage,showCopy:!0,theme:o?.theme||e.defaultTheme},r=n?{...i,...n}:i,s=l.createStyledElement("div",l.classNames.block.code.container,{classNames:a?.classNames?.container,styles:a?.styles?.container});s.setAttribute("data-language",r.language||e.defaultLanguage),s.setAttribute("data-theme",r.theme||e.defaultTheme);const c=l.createStyledElement("div",l.classNames.block.code.headerWrapper,{classNames:a?.classNames?.header?.wrapper,styles:a?.styles?.header?.wrapper}),d=l.createStyledElement("div",l.classNames.block.code.header,{classNames:a?.classNames?.header?.text,styles:a?.styles?.header?.text}),p=Q[r.language]?.name||Z(e.defaultLanguage),u=ie[r.theme]?.name||oe(e.defaultTheme);d.textContent=e.getHeaderText(p,u);const h=l.createStyledElement("div",l.classNames.block.code.editor,{classNames:a?.classNames?.container,styles:a?.styles?.container});h.setAttribute("data-placeholder",ne(t,"codeHint",e.placeholder));const m=t?C.getState().getInstance(t):null,g=m?.config.classNames?.switch,b=m?.config.styles?.switch,f=ue.create({checked:r.showCopy||!1,classNames:g,label:"Allow copy",onToggle:t=>{const n=e.dataMap.get(s)||{code:"",language:e.defaultLanguage,theme:e.defaultTheme};e.dataMap.set(s,{...n,showCopy:t}),_s.saveBlockData(s)},styles:b});return c.appendChild(d),c.appendChild(f),s.appendChild(c),s.appendChild(h),e.mountEditor(s,h,r),s}static mountEditor(t,n,a){const o=a.language??e.defaultLanguage,i=document.createElement("pre");i.className="clepit-code-highlight",i.setAttribute("aria-hidden","true");const r=document.createElement("code");i.appendChild(r);const s=document.createElement("textarea");s.className="clepit-code-input",s.value=a.code??"",s.spellcheck=!1,s.autocapitalize="off",s.setAttribute("autocorrect","off"),s.setAttribute("data-testid","code-input"),s.setAttribute("aria-label",`${Z(o)} code`),s.placeholder=n.getAttribute("data-placeholder")||e.placeholder,n.replaceChildren(i,s),e.inputMap.set(t,s),e.dataMap.set(t,a),e.paint(t,r,s.value),s.addEventListener("input",()=>{e.paint(t,r,s.value);const n=e.dataMap.get(t)??{code:"",language:t.getAttribute("data-language")||e.defaultLanguage,theme:t.getAttribute("data-theme")||e.defaultTheme};e.dataMap.set(t,{...n,code:s.value}),_s.saveBlockData(t)}),s.addEventListener("scroll",()=>{i.scrollTop=s.scrollTop,i.scrollLeft=s.scrollLeft}),s.addEventListener("keydown",n=>e.handleKeydown(t,s,n))}static paint(t,n,a){const i=t.getAttribute("data-language")||e.defaultLanguage;n.replaceChildren(...o(a.endsWith("\n")?`${a} `:a,i).map(e=>{const t=document.createElement("span");return e.classes&&(t.className=e.classes),t.textContent=e.text,t}))}static updateLanguage(t,n){const a=t.querySelector(`.${l.classNames.block.code.container}`);if(!a)return;const o=t.querySelector(`.${l.classNames.block.code.editor}`);if(!o)return;a.setAttribute("data-language",n);const i=a.querySelector(`.${l.classNames.block.code.header}`),r=a.getAttribute("data-theme")||e.defaultTheme,s=oe(r),c=Z(n);i&&(i.textContent=e.getHeaderText(c,s));const d=e.inputMap.get(a);d&&e.mountEditor(a,o,{code:d.value,language:n,theme:r}),_s.saveBlockData(a)}static updateTheme(t,n){const a=t.querySelector(`.${l.classNames.block.code.container}`);if(!a)return;const o=t.querySelector(`.${l.classNames.block.code.editor}`);if(!o)return;a.setAttribute("data-theme",n);const i=a.querySelector(`.${l.classNames.block.code.header}`),r=a.getAttribute("data-language")||e.defaultLanguage,s=Z(r),c=oe(n);i&&(i.textContent=e.getHeaderText(s,c));const d=e.inputMap.get(a);d&&e.mountEditor(a,o,{code:d.value,language:r,theme:n}),_s.saveBlockData(a)}static handleKeydown(e,t,n){const a=e.closest(`.${l.classNames.block.container}`);if(!a)return;const o=_s.getEditorId(a);if(!o)return;const i=_s.getBlockIndex(o,a.getAttribute("data-id")),r=n.metaKey||n.ctrlKey;return"Enter"!==n.key||n.shiftKey?"Backspace"===n.key&&r||"Delete"===n.key&&r?(n.preventDefault(),void _s.removeBlock(o,i)):"Backspace"!==n.key||""!==t.value.trim()?"ArrowUp"===n.key?(n.preventDefault(),void(n.shiftKey?_s.moveBlock(o,i,i-1):_s.focusBlock(a.previousElementSibling))):void("ArrowDown"===n.key&&(n.preventDefault(),n.shiftKey?_s.moveBlock(o,i,i+1):_s.focusBlock(a.nextElementSibling))):void _s.removeBlock(o,i):(n.preventDefault(),void _s.insertBlock({data:{html:""},type:"paragraph"},o,i+1))}static getHeaderText(e,t){return`${e} | ${t}`}static isEmpty(t){const n=t.querySelector(`.${l.classNames.block.code.container}`);if(!n)return!0;const a=e.inputMap.get(n);return!a||Boolean(a.value?.trim())}static isEmptyData(e){return h(e.code)}static destroy(t){const n=document.getElementById(t);if(!n)return console.warn("CodeInput::destroy: Container not found for containerId:",t);n.querySelectorAll(`.${l.classNames.block.code.container}`).forEach(t=>{e.inputMap.delete(t),e.dataMap.delete(t)})}},me="clepit:code-variant-sync",ge=e=>`clepit.code-variant.${e}`,be=(e,t)=>e.label?e.label:e.language?Y[e.language]??e.language:`Tab ${t+1}`,fe=(e,t)=>{if(!t)return 0;const n=e.findIndex((e,n)=>be(e,n)===t);return-1===n?0:n},ve=e=>{if(!e||"undefined"==typeof localStorage)return null;try{return localStorage.getItem(ge(e))}catch{return null}};function ye(e,t,n="below",a,o){let i=null,r=null;const s=()=>{if(i)return;l.injectStyles("clepit-inline-tooltip-styles","\n/* Inline Tooltip Container */\n.clepit-inline-tooltip {\n position: fixed;\n z-index: 9999;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.2s ease-in-out;\n}\n\n/* Tooltip Content */\n.clepit-inline-tooltip-content {\n background: var(--clepit-text);\n color: var(--clepit-bg);\n padding: 6px 10px;\n border-radius: 6px;\n font-size: 12px;\n font-weight: 500;\n white-space: nowrap;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\n transform: translateY(8px);\n transition: transform 0.2s ease-in-out;\n position: relative;\n}\n\n/* Tooltip Arrow */\n.clepit-inline-tooltip-arrow {\n position: absolute;\n width: 0;\n height: 0;\n}\n\n/* Arrow pointing down (when tooltip is above target) */\n.clepit-inline-tooltip-arrow--above {\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border-left: 6px solid transparent;\n border-right: 6px solid transparent;\n border-top: 6px solid var(--clepit-text);\n}\n\n/* Arrow pointing up (when tooltip is below target) */\n.clepit-inline-tooltip-arrow--below {\n bottom: 100%;\n left: 50%;\n transform: translateX(-50%);\n border-left: 6px solid transparent;\n border-right: 6px solid transparent;\n border-bottom: 6px solid var(--clepit-text);\n}\n"),i=document.createElement("div"),i.className=`clepit-inline-tooltip ${a?.container||""}`,l.applyStyling(i,{styles:o?.container});const s=document.createElement("div");s.className=`clepit-inline-tooltip-content ${a?.content||""}`,s.textContent=t,l.applyStyling(s,{styles:o?.content});const d=document.createElement("div");d.className=`clepit-inline-tooltip-arrow clepit-inline-tooltip-arrow--${n} ${a?.arrow||""}`,l.applyStyling(d,{styles:o?.arrow}),s.appendChild(d),i.appendChild(s),document.body.appendChild(i);const p=e.getBoundingClientRect(),u=s.offsetWidth,h=s.offsetHeight;let m,g=p.left+p.width/2-u/2;g=Math.max(8,Math.min(g,window.innerWidth-u-8));let b=n;"below"===n?(m=p.bottom+6+2,m+h>window.innerHeight-8&&(m=p.top-h-6-2,b="above")):(m=p.top-h-6-2,m<8&&(m=p.bottom+6+2,b="below")),d.className=`clepit-inline-tooltip-arrow clepit-inline-tooltip-arrow--${b} ${a?.arrow||""}`,i.style.left=`${g}px`,i.style.top=`${Math.max(8,Math.min(m,window.innerHeight-h-8))}px`,requestAnimationFrame(()=>{i&&(i.style.opacity="1",s.style.transform="translateY(0)")}),r||(r=new MutationObserver(()=>{document.body.contains(e)&&e.isConnected||(c(),r&&(r.disconnect(),r=null))}),r.observe(document.body,{childList:!0,subtree:!0}))},c=()=>{i&&(i.style.opacity="0",setTimeout(()=>{i&&i.parentElement&&i.parentElement.removeChild(i),i=null,r&&(r.disconnect(),r=null)},120))};return e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",c),()=>{e.removeEventListener("mouseenter",s),e.removeEventListener("mouseleave",c),c()}}var xe="http://www.w3.org/2000/svg",ke=e=>{if("pending"!==e.dataset.highlight)return;const t=e.querySelector("code");if(null===t)return;const n=e.dataset.language,a=o(t.textContent??"",(i=n,void 0!==i&&Object.prototype.hasOwnProperty.call(Y,i)?n:"plaintext")).map(e=>{const t=document.createElement("span");return e.classes&&(t.className=e.classes),t.textContent=e.text,t});var i;t.replaceChildren(...a),delete e.dataset.highlight,delete e.dataset.language},we=e=>e.variants?.length?e.variants:[{code:e.code,language:e.language}],Ce=class e{static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static draw(t,n=R,a){if(!e.validate(t)||he.isEmptyData(t))return null;const i=we(t),r=i.length>1,s=Math.min(Math.max(a?.activeVariant??0,0),i.length-1),l=n.create("div");l.addClass("clepit-output-code-container"),l.setAttribute("data-theme",t.theme??he.defaultTheme),t.syncKey&&l.setAttribute("data-sync-key",t.syncKey);const c=n.create("div");if(c.addClass("clepit-output-code-header"),r){const e=n.create("div");e.addClass("clepit-output-code-tabs"),e.setAttribute("role","tablist"),e.setAttribute("data-testid","code-variant-tabs"),i.forEach((t,a)=>{const o=n.create("button");o.addClass("clepit-output-code-tab"),o.setAttribute("type","button"),o.setAttribute("role","tab"),o.setAttribute("aria-selected",a===s?"true":"false"),o.setAttribute("tabindex",a===s?"0":"-1"),o.setAttribute("data-testid",`code-variant-tab-${a}`),o.setText(be(t,a)),e.append(o)}),c.append(e)}else{const e=n.create("span");e.setText(Y[t.language??"typescript"]??"TypeScript"),c.append(e)}if(t.showCopy){const e=n.create("button");e.addClass("clepit-output-code-copy-btn"),e.setAttribute("type","button"),e.setAttribute("aria-label","Copy code"),e.append((e=>{const t=e.createNS(xe,"svg");t.setAttribute("class","clepit-copy-icon"),t.setAttribute("width","16"),t.setAttribute("height","16"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");const n=e.createNS(xe,"path");return n.setAttribute("d","M7.5 3H14.6C16.8402 3 17.9603 3 18.816 3.43597C19.5686 3.81947 20.1805 4.43139 20.564 5.18404C21 6.03969 21 7.15979 21 9.4V16.5M6.2 21H14.3C15.4201 21 15.9802 21 16.408 20.782C16.7843 20.5903 17.0903 20.2843 17.282 19.908C17.5 19.4802 17.5 18.9201 17.5 17.8V9.7C17.5 8.57989 17.5 8.01984 17.282 7.59202C17.0903 7.21569 16.7843 6.90973 16.408 6.71799C15.9802 6.5 15.4201 6.5 14.3 6.5H6.2C5.0799 6.5 4.51984 6.5 4.09202 6.71799C3.71569 6.90973 3.40973 7.21569 3.21799 7.59202C3 8.01984 3 8.57989 3 9.7V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.0799 21 6.2 21Z"),n.setAttribute("stroke","var(--clepit-svg-stroke-color)"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),t.append(n),t})(n)),c.append(e)}l.append(c);const d=n.create("div");return d.addClass("clepit-output-code-editor"),r&&d.setAttribute("role","tabpanel"),i.forEach((e,i)=>{const r=n.create("pre");r.addClass("clepit-output-code-pane"),r.setAttribute("data-variant-index",String(i));const l=e.language??t.language??"plaintext",c=n.create("code");if(i!==s||a?.deferHighlight)i!==s&&r.setAttribute("hidden",""),r.setAttribute("data-highlight","pending"),r.setAttribute("data-language",l),c.setText(e.code??t.code);else for(const a of o(e.code??t.code,l)){const e=n.create("span");a.classes&&e.addClass(...a.classes.split(" ")),e.setText(a.text),c.append(e)}r.append(c),d.append(r)}),l.append(d),l}static render(t,n,a,o,i){if(l.injectStyles("clepit-code-output-styles",te),l.injectStyles(le,de()),!e.validate(t))return X();if(he.isEmptyData(t))return document.createElement("div");const r=we(t),s=r.length>1?fe(r,ve(t.syncKey)):0,c=J(e.draw(t,R,{activeVariant:s}));o?.container&&c.classList.add(o.container),a?.container&&Object.assign(c.style,a.container);const d=c.querySelector(".clepit-output-code-header");return d&&o?.header?.text&&d.classList.add(o.header.text),d&&a?.header?.text&&Object.assign(d.style,a.header.text),e.attach(c,t,s,i),c}static activate(t,n){if(!e.validate(n)||he.isEmptyData(n))return()=>{};const a=we(n),o=a.length>1?fe(a,ve(n.syncKey)):0;return e.attach(t,n,o,void 0,!0)}static reveal(e){for(const t of[...e.querySelectorAll('.clepit-output-code-pane[data-highlight="pending"]')])t.hidden||ke(t)}static activateFromMarkup(t){const n=[...t.querySelectorAll(".clepit-output-code-pane")];if(0===n.length)return()=>{};const a=[...t.querySelectorAll(".clepit-output-code-tab")],o=n.map((e,t)=>({code:e.textContent??"",label:a[t]?.textContent||void 0})),i=t.getAttribute("data-sync-key")??void 0,r={code:o[0]?.code??"",showCopy:null!==t.querySelector(".clepit-output-code-copy-btn"),syncKey:i,variants:o},s=o.length>1?fe(o,ve(i)):0;return e.attach(t,r,s,void 0,!0)}static attach(t,n,a,o,i=!1){const r=we(n),s=o?document.getElementById(o):null,l=[...t.querySelectorAll(".clepit-output-code-tab")],c=[...t.querySelectorAll(".clepit-output-code-pane")];let d=a;const p=[];let u;const h=(t,n,a)=>{if(t.addEventListener(n,a),p.push({event:n,handler:a,target:t}),s){const o=e.eventListenersMap.get(s)??[];o.push({element:t,event:n,handler:a}),e.eventListenersMap.set(s,o)}},m=(e,a)=>{if(e<0||e>=r.length)return;if(d=e,l.forEach((t,n)=>{t.setAttribute("aria-selected",n===e?"true":"false"),t.tabIndex=n===e?0:-1}),c.forEach((n,a)=>{a===e&&null===t.closest("[hidden]")&&ke(n),n.hidden=a!==e}),!a||!n.syncKey)return;const o=be(r[e],e);((e,t)=>{if(e&&"undefined"!=typeof localStorage)try{localStorage.setItem(ge(e),t)}catch{return}})(n.syncKey,o),window.dispatchEvent(new CustomEvent(me,{detail:{label:o,syncKey:n.syncKey}}))};if(l.forEach((e,t)=>{h(e,"click",()=>m(t,!0)),h(e,"keydown",e=>{const n=e.key,a="ArrowRight"===n?1:"ArrowLeft"===n?-1:0,o="Home"===n?0:"End"===n?r.length-1:0===a?-1:(t+a+r.length)%r.length;-1!==o&&(e.preventDefault(),m(o,!0),l[o]?.focus())})}),l.length>1&&n.syncKey){const t=e=>{const t=e.detail;if(!t||t.syncKey!==n.syncKey)return;const a=r.findIndex((e,n)=>be(e,n)===t.label);-1!==a&&a!==d&&m(a,!1)};if(window.addEventListener(me,t),p.push({event:me,handler:t,target:window}),s){const n=e.eventListenersMap.get(s)??[];n.push({element:window,event:me,handler:t}),e.eventListenersMap.set(s,n)}}const g=()=>{for(const{event:e,handler:t,target:n}of p)n.removeEventListener(e,t);u?.()};i&&m(a,!1);const b=t.querySelector(".clepit-output-code-copy-btn");if(!b)return g;h(b,"click",()=>{e.copyCodeToClipboard(r[d]?.code??n.code),e.animateCopyButton(b)});const f=o?C.getState().getInstance(o):null;return u=ye(b,"Copy code","above",f?.config.classNames?.tooltips,f?.config.styles?.tooltips),g}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.code}static copyCodeToClipboard(e){navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(e).catch(e=>{console.error("Failed to copy code to clipboard:",e)}):console.warn("Clipboard API not available in this context")}static animateCopyButton(e){const t=e.innerHTML;e.innerHTML='<svg class="clepit-check-icon" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="CheckIcon"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path></svg>',e.classList.remove("clepit-output-code-copy-btn--normal"),e.classList.add("clepit-output-code-copy-btn--animating"),setTimeout(()=>{e.innerHTML=t,e.classList.remove("clepit-output-code-copy-btn--animating"),e.classList.add("clepit-output-code-copy-btn--normal")},1e3)}static destroy(t){const n=document.getElementById(t);if(!n)return console.warn("CodeOutput::destroy: Container not found for containerId:",t);const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n))}},Ae="inline-issue",Se='\n.clepit-issue {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n max-width: 100%;\n padding: 1px 8px 1px 6px;\n vertical-align: baseline;\n font-size: 0.92em;\n line-height: 1.5;\n color: inherit;\n text-decoration: none;\n white-space: nowrap;\n background: rgba(127, 127, 127, 0.1);\n border: 1px solid rgba(127, 127, 127, 0.25);\n border-radius: 999px;\n cursor: pointer;\n}\n.clepit-issue:hover {\n background: rgba(127, 127, 127, 0.16);\n}\n.clepit-issue__key {\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n}\n.clepit-issue__title {\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 28ch;\n}\n.clepit-issue__state {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 0 7px;\n font-size: 12px;\n line-height: 18px;\n border-radius: 999px;\n background: rgba(127, 127, 127, 0.16);\n}\n.clepit-issue__state::before {\n content: \'\';\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: currentColor;\n}\n.clepit-issue__state[data-issue-category="todo"] {\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue__state[data-issue-category="started"] {\n color: var(--clepit-primary, #5958fc);\n background: var(--clepit-primary-bg, rgba(89, 88, 252, 0.16));\n}\n.clepit-issue__state[data-issue-category="done"] {\n color: var(--clepit-success, #15803d);\n background: var(--clepit-success-bg, rgba(21, 128, 61, 0.16));\n}\n.clepit-issue__state[data-issue-category="cancelled"] {\n color: var(--clepit-text-muted, #6b7280);\n text-decoration: line-through;\n}\n.clepit-issue__assignee {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n font-size: 10px;\n font-weight: 600;\n letter-spacing: 0.02em;\n color: #fff;\n background: var(--clepit-primary, #5958fc);\n border-radius: 50%;\n}\n.clepit-issue__reason {\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue--reason {\n border-style: dashed;\n}\n[data-issue-chip-status="off"] .clepit-issue__state,\n[data-issue-chip-assignee="off"] .clepit-issue__assignee {\n display: none;\n}\n.clepit-issue-menu {\n position: absolute;\n z-index: 20;\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 180px;\n padding: 4px;\n font-size: 13px;\n background: var(--clepit-surface, #fff);\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);\n}\n.clepit-issue-menu a,\n.clepit-issue-menu button {\n display: block;\n width: 100%;\n padding: 6px 10px;\n font: inherit;\n color: inherit;\n text-align: left;\n text-decoration: none;\n background: none;\n border: 0;\n border-radius: 6px;\n cursor: pointer;\n}\n.clepit-issue-menu a:hover,\n.clepit-issue-menu button:hover {\n background: rgba(127, 127, 127, 0.1);\n}\n.clepit-issue-menu__reason {\n padding: 6px 10px 2px;\n font-size: 12px;\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue-card {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 12px;\n color: inherit;\n text-decoration: none;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n}\n.clepit-issue-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-issue-card__head {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n}\n.clepit-issue-card__key {\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n}\n.clepit-issue-card__title {\n font-weight: 600;\n}\n.clepit-issue-card__meta {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px 12px;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-issue-card__assignee {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n}\n.clepit-issue-card__reason {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 14px;\n align-items: center;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-issue-card__action {\n padding: 0;\n font: inherit;\n color: inherit;\n text-decoration: underline;\n background: none;\n border: 0;\n cursor: pointer;\n}\n.clepit-issues {\n width: 100%;\n border-collapse: collapse;\n font-size: 0.95em;\n}\n.clepit-issues th,\n.clepit-issues td {\n padding: 6px 10px;\n text-align: left;\n border-bottom: 1px solid rgba(127, 127, 127, 0.25);\n}\n.clepit-issues th {\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.02em;\n text-transform: uppercase;\n opacity: 0.7;\n}\n.clepit-issues a {\n color: inherit;\n font-weight: 600;\n text-decoration: none;\n}\n.clepit-issues a:hover {\n text-decoration: underline;\n}\n.clepit-issues__empty {\n opacity: 0.55;\n}\n',Ee={categoryCancelled:"Cancelled",categoryDone:"Done",categoryStarted:"In progress",categoryTodo:"To do",columnAssignee:"Assignee",columnIssue:"Issue",columnStatus:"Status",columnTitle:"Title",connectAction:"Connect",connectTool:"Connect {tool} to see this issue",linkedIssuesEmpty:"No issues linked on this page yet",noAccess:"You do not have access to this issue in {tool}",openInTool:"Open in {tool}",providerUnreachable:"{tool} did not answer",showAsCard:"Show as card",unassigned:"Unassigned",updatedRelative:"updated {when}"},Le={asana:"Asana",github_issues:"GitHub",jira:"Jira",linear:"Linear"},Ne={cancelled:"categoryCancelled",done:"categoryDone",started:"categoryStarted",todo:"categoryTodo"};function Be(e,t,n={}){let a=e?.[t]??Ee[t];for(const[o,i]of Object.entries(n))a=a.replace(`{${o}}`,i);return a}var $e=e=>Le[e]??e,Me="clepit-issue",Ie=["todo","started","done","cancelled"],Te=["connect_tool","no_access","provider_unreachable"],_e={connect_tool:"connectTool",no_access:"noAccess",provider_unreachable:"providerUnreachable"},qe=e=>e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(""),De=(e,t)=>e.reason?Be(t,_e[e.reason],{tool:$e(e.tool)}):null,ze=(e,t)=>e.stateName||Be(t,Ne[e.category]),je=(e,t,n="")=>({category:"todo",key:n,stateName:"",title:"",tool:t,updatedAt:"",url:e}),He=e=>d(e)?e:"",Oe=class e{static build(t,n,a=R){const o=a.create("a");o.addClass(Me),t.reason&&o.addClass(`${Me}--reason`),d(t.url)&&o.setAttribute("href",t.url),o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer"),o.setAttribute("contenteditable","false");for(const[s,l]of Object.entries(e.attributes(t)))o.setAttribute(s,l);const i=a.create("span");i.addClass(`${Me}__key`),i.setText(t.key||(t.title?"":$e(t.tool))),!t.key&&t.title||o.append(i);const r=De(t,n);if(r){const e=a.create("span");return e.addClass(`${Me}__reason`),e.setText(r),o.append(e),o}if(t.title){const e=a.create("span");e.addClass(`${Me}__title`),e.setText(t.title),o.append(e)}if(t.stateName||t.updatedAt){const e=a.create("span");e.addClass(`${Me}__state`),e.setAttribute("data-issue-category",t.category),e.setText(ze(t,n)),o.append(e)}if(t.assigneeName){const e=a.create("span");e.addClass(`${Me}__assignee`),e.setAttribute("title",t.assigneeName),e.setText(qe(t.assigneeName)),o.append(e)}return o}static markup(t,n,a){return G(e.build(t,n,K(a)))}static create(t,n){return l.injectStyles(Ae,Se),J(e.build(t,n))}static refresh(t,n,a){const o=e.create(n,a);for(const e of Array.from(t.attributes))e.name.startsWith("data-issue-")&&t.removeAttribute(e.name);for(const e of Array.from(o.attributes))t.setAttribute(e.name,e.value);t.replaceChildren(...Array.from(o.childNodes))}static read(e){const t=t=>e.getAttribute(`data-issue-${t}`)??"",n=t("category"),a=t("reason");return{assigneeAvatarUrl:He(t("avatar"))||void 0,assigneeName:t("assignee")||void 0,category:Ie.includes(n)?n:"todo",key:t("key"),pull:"true"===t("pull")||void 0,reason:Te.includes(a)?a:void 0,stateName:t("state"),title:t("title"),tool:t("tool"),updatedAt:t("updated"),url:He(t("url")||e.getAttribute("href")||"")}}static collect(e){return Array.from(e.querySelectorAll(`a.${Me}`))}static refreshAll(t,n,a){for(const o of e.collect(t)){const t=o.getAttribute("data-issue-url")||o.getAttribute("href")||"",i=n[t];i&&e.refresh(o,{...i,url:t},a)}}static applyParts(e,t){e.setAttribute("data-issue-chip-status",!1===t?.status?"off":"on"),e.setAttribute("data-issue-chip-assignee",!1===t?.assignee?"off":"on")}static insertAtCaret(t,n){const a=window.getSelection();if(!a||0===a.rangeCount)return null;const o=a.getRangeAt(0);o.deleteContents();const i=e.create(t,n);o.insertNode(i);const r=document.createTextNode(" ");i.after(r);const s=document.createRange();return s.setStartAfter(r),s.collapse(!0),a.removeAllRanges(),a.addRange(s),i}static attributes(e){const t={"data-issue-category":e.category,"data-issue-key":e.key,"data-issue-state":e.stateName,"data-issue-title":e.title,"data-issue-tool":e.tool,"data-issue-updated":e.updatedAt,"data-issue-url":e.url};return e.assigneeName&&(t["data-issue-assignee"]=e.assigneeName),e.assigneeAvatarUrl&&(t["data-issue-avatar"]=e.assigneeAvatarUrl),e.pull&&(t["data-issue-pull"]="true"),e.reason&&(t["data-issue-reason"]=e.reason),t}},Pe=/<a\b[^>]*\bclepit-issue(?=["'\s])[^>]*>[\s\S]*?<\/a>/g,Re=(e,t)=>(new RegExp(`\\b${t}="([^"]*)"`).exec(e)?.[1]??"").replace(/&quot;/g,'"').replace(/&amp;/g,"&"),Fe=e=>{const t=t=>Re(e,`data-issue-${t}`),n=t("category"),a=t("reason");return{assigneeAvatarUrl:He(t("avatar"))||void 0,assigneeName:t("assignee")||void 0,category:Ie.includes(n)?n:"todo",key:t("key"),pull:"true"===t("pull")||void 0,reason:Te.includes(a)?a:void 0,stateName:t("state"),title:t("title"),tool:t("tool"),updatedAt:t("updated"),url:He(t("url")||Re(e,"href"))}},Ve=e=>Array.from(e.matchAll(Pe),e=>Fe(e[0])),Ue=(e,t,n,a,o)=>t||n?e.replace(Pe,e=>{const i=Fe(e),r={...t?.[i.url]?{...t[i.url],url:i.url}:i};return!1===n?.status&&(r.stateName="",r.updatedAt=""),!1===n?.assignee&&(r.assigneeName=void 0),Oe.markup(r,a,o)}):e,We=class e{static render(t,n){return l.injectStyles(Ae,Se),J(e.draw(t,R,n,!0))}static draw(t,n,a,o){const i=De(t,a);if(i)return e.drawReason(t,i,n,a,o);const r=n.create("a");r.addClass("clepit-issue-card","clepit-output-embed"),r.setAttribute("data-testid","issue-card"),d(t.url)&&r.setAttribute("href",t.url),r.setAttribute("rel","noopener noreferrer nofollow"),r.setAttribute("target","_blank");const s=n.create("span");if(s.addClass("clepit-issue-card__head"),t.key){const e=n.create("span");e.addClass("clepit-issue-card__key"),e.setText(t.key),s.append(e)}const l=n.create("span");l.addClass("clepit-issue-card__title"),l.setText(t.title||t.url),s.append(l);const c=n.create("span");c.addClass("clepit-issue__state"),c.setAttribute("data-issue-category",t.category),c.setText(ze(t,a)),s.append(c),r.append(s);const p=n.create("span");p.addClass("clepit-issue-card__meta");const u=n.create("span");if(u.addClass("clepit-issue-card__assignee"),t.assigneeName){const e=n.create("span");e.addClass("clepit-issue__assignee"),e.setAttribute("title",t.assigneeName),e.setText(qe(t.assigneeName)),u.append(e),u.appendText(t.assigneeName)}else u.setText(Be(a,"unassigned"));if(p.append(u),t.updatedAt){const e=n.create("span");e.addClass("clepit-issue-card__updated"),e.setText(Be(a,"updatedRelative",{when:(h=t.updatedAt,h.length>=10?h.slice(0,10):h)})),p.append(e)}var h;return r.append(p),r}static drawReason(e,t,n,a,o){const i=n.create("div");i.addClass("clepit-issue-card","clepit-issue-card--reason","clepit-output-embed"),i.setAttribute("data-testid","issue-card");const r=n.create("a");r.addClass("clepit-issue-card__head"),d(e.url)&&r.setAttribute("href",e.url),r.setAttribute("rel","noopener noreferrer nofollow"),r.setAttribute("target","_blank");const s=n.create("span");if(s.addClass("clepit-issue-card__key"),s.setText(e.key||$e(e.tool)),r.append(s),e.title){const t=n.create("span");t.addClass("clepit-issue-card__title"),t.setText(e.title),r.append(t)}i.append(r);const l=n.create("span");l.addClass("clepit-issue-card__reason"),l.setAttribute("data-testid","issue-reason");const c=n.create("span");if(c.setText(t),l.append(c),o&&"connect_tool"===e.reason){const t=n.create("button");t.addClass("clepit-issue-card__action"),t.setAttribute("type","button"),t.setAttribute("data-issue-action","connect"),t.setAttribute("data-issue-tool",e.tool),t.setAttribute("data-testid","issue-reason-action-connect"),t.setText(Be(a,"connectAction")),l.append(t)}return i.append(l),i}},Ke="allow-scripts allow-same-origin allow-presentation allow-forms",Ge={connectGoogle:"Connect your Google account to show this file",connectGoogleAction:"Connect",noAccess:"You do not have access to this file in Google Drive",offerShowLive:"{tool} · Show live",providerUnreachable:"{tool} did not answer, so the content is not shown",switchedOff:"Live view for {tool} is switched off for this workspace",truncated:"truncated",tryAgain:"Try again",viewOnGithub:"View on GitHub"},Je={figma:"Figma",githubGist:"GitHub",googleDrive:"Google Drive",loom:"Loom",miro:"Miro"};function Xe(e,t,n={}){let a=e?.[t]??Ge[t];for(const[o,i]of Object.entries(n))a=a.replace(`{${o}}`,i);return a}var Ye=new Set(Object.keys(Y)),Ze={"c#":"csharp","c++":"cpp","html+erb":"html","objective-c":"objectivec",shell:"bash"};function Qe(e){if(!e)return;const t=e.toLowerCase(),n=Ze[t];return n||(Ye.has(t)?t:void 0)}var et={connect_google:"connectGoogle",no_access:"noAccess",provider_unreachable:"providerUnreachable",switched_off:"switchedOff"},tt={connectGoogle:"connectGoogleAction",retry:"tryAgain"};function nt(e,t){const n=Je[t.provider]??"The tool";if(t.switchedOff)return{reason:"switched_off",tool:n};switch(e.reason){case"connect_google":return{action:"connectGoogle",reason:"connect_google",tool:n};case"no_access":return{reason:"no_access",tool:n};case"provider_unreachable":return{action:"retry",reason:"provider_unreachable",tool:n};case"switched_off":return{reason:"switched_off",tool:n};default:return null}}var at=(e,t)=>"card"===e.display||!0===t.switchedOff||void 0!==e.reason,ot=class e{static render(t,n,a,o){if(l.injectStyles("embed-output",O),!e.validate(t))return X();if(t.issue)return We.render({...t.issue,...n?.issues?.[t.url],url:t.url},n?.issueLabels);const i=q(t.url,{disabledProviders:n?.disabledEmbedProviders,mapsEmbedKey:n?.mapsEmbedKey});if("invalid"===i.provider)return X();if(!at(t,i)){if(i.gist)return e.gistFrame(i.gist,a,o);if(i.embedUrl)return e.frame(i.embedUrl,i.aspect,a,o)}const r=e.card(t,i.url,a,o),s=nt(t,i);if(!s)return r;const c=l.createStyledElement("div","clepit-embed-card--with-reason clepit-output-embed",{classNames:o?.wrapper,styles:a?.wrapper});r.classList.remove("clepit-output-embed"),c.appendChild(r);const d=document.createElement("span");d.className="clepit-embed-card__reason",d.setAttribute("data-testid","embed-reason");const p=document.createElement("span");if(p.textContent=Xe(n?.embedLabels,et[s.reason],{tool:s.tool}),d.appendChild(p),s.action){const e=document.createElement("button");e.type="button",e.className="clepit-embed-card__action",e.setAttribute("data-embed-action",s.action),e.setAttribute("data-testid",`embed-reason-action-${s.action}`),e.textContent=Xe(n?.embedLabels,tt[s.action]),d.appendChild(e)}return c.appendChild(d),c}static draw(t,n=R,a){if(!e.validate(t))return null;if(t.issue)return We.draw({...t.issue,...a?.issues?.[t.url],url:t.url},n,a?.issueLabels,!1);const o=q(t.url,{disabledProviders:a?.disabledEmbedProviders,mapsEmbedKey:a?.mapsEmbedKey});if("invalid"===o.provider)return null;if(!at(t,o)){if(o.gist&&t.gist&&t.gist.files.length>0)return e.drawGist(t,n,a);if(o.embedUrl)return e.drawFrame(o.embedUrl,o.aspect,n)}const i=nt(t,o);if(!i)return e.drawCard(t,o.url,n,!0);const r=n.create("div");r.addClass("clepit-embed-card--with-reason","clepit-output-embed"),r.append(e.drawCard(t,o.url,n,!1));const s=n.create("span");s.addClass("clepit-embed-card__reason"),s.setAttribute("data-testid","embed-reason");const l=n.create("span");return l.setText(Xe(a?.embedLabels,et[i.reason],{tool:i.tool})),s.append(l),r.append(s),r}static drawGist(e,t,n){const a=e.gist,o=t.create("div");o.addClass("clepit-embed-gist","clepit-output-embed");for(const i of a.files){const e=t.create("div");e.addClass("clepit-embed-gist__file");const r=t.create("b");if(r.setText(i.name),e.append(r),i.truncated){const a=t.create("span");a.setText(Xe(n?.embedLabels,"truncated")),e.append(a)}const s=t.create("a");s.setAttribute("href",a.htmlUrl),s.setAttribute("rel","noopener noreferrer nofollow"),s.setAttribute("target","_blank"),s.setText(Xe(n?.embedLabels,"viewOnGithub")),e.append(s),o.append(e);const l=Ce.draw({code:i.content,language:Qe(i.language),showCopy:!1},t,n);l&&o.append(l)}return o}static drawFrame(e,t,n){const a=n.create("div");a.addClass("clepit-embed","clepit-output-embed");const o=n.create("iframe");return o.addClass("clepit-embed__frame"),o.setAttribute("src",e),o.setAttribute("sandbox",Ke),o.setAttribute("referrerpolicy","no-referrer"),o.setAttribute("loading","lazy"),o.setAttribute("allowfullscreen","true"),o.setAttribute("style",`aspect-ratio: ${t??16/9};`),a.append(o),a}static drawCard(e,t,n,a){const o=n.create("a");o.addClass("clepit-embed-card"),a&&o.addClass("clepit-output-embed"),o.setAttribute("href",t),o.setAttribute("rel","noopener noreferrer nofollow"),o.setAttribute("target","_blank");const i=n.create("span"),r=n.create("span");if(r.addClass("clepit-embed-card__title"),r.setText(e.title||t),i.append(r),e.description){const t=n.create("span");t.addClass("clepit-embed-card__description"),t.setText(e.description),i.append(t)}return o.append(i),o}static gistFrame(e,t,n){const a=l.createStyledElement("div","clepit-embed clepit-embed--gist-frame clepit-output-embed",{classNames:n?.wrapper,styles:t?.wrapper}),o=document.createElement("iframe");var i,r;return o.className="clepit-embed__frame",o.setAttribute("srcdoc",(i=e.owner,r=e.id,`<!doctype html><html><head><meta charset="utf-8"><base target="_blank"><style>body{margin:0;padding:8px;font:13px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}.gist .gist-file{margin-bottom:0}</style></head><body><script src="https://gist.github.com/${encodeURIComponent(i)}/${encodeURIComponent(r)}.js"><\/script></body></html>`)),o.setAttribute("sandbox","allow-scripts allow-popups allow-popups-to-escape-sandbox"),o.setAttribute("referrerpolicy","no-referrer"),o.setAttribute("loading","lazy"),o.style.height="552px",a.appendChild(o),a}static frame(e,t,n,a){const o=l.createStyledElement("div","clepit-embed clepit-output-embed",{classNames:a?.wrapper,styles:n?.wrapper}),i=document.createElement("iframe");return i.className="clepit-embed__frame",i.src=e,i.setAttribute("sandbox",Ke),i.setAttribute("referrerpolicy","no-referrer"),i.setAttribute("loading","lazy"),i.setAttribute("allowfullscreen","true"),i.style.aspectRatio=String(t??16/9),o.appendChild(i),o}static card(e,t,n,a){const o=l.createStyledElement("a","clepit-embed-card clepit-output-embed",{classNames:a?.card,styles:n?.card});o.href=t,o.rel="noopener noreferrer nofollow",o.target="_blank";const i=document.createElement("span"),r=document.createElement("span");if(r.className="clepit-embed-card__title",r.textContent=e.title||t,i.appendChild(r),e.description){const t=document.createElement("span");t.className="clepit-embed-card__description",t.textContent=e.description,i.appendChild(t)}return o.appendChild(i),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url&&e.url.length>0}},it=/^[A-Z][A-Z0-9_]*-\d+$/,rt=/^\d+$/,st=(e,t)=>e.endsWith(".atlassian.net")||t.some(t=>(e=>{try{return new URL(e).host.toLowerCase()}catch{return null}})(t)===e),lt=(e,t,n)=>n?{key:t,site:n,tool:e}:{key:t,tool:e};function ct(e,t=[]){let n;try{n=new URL(e)}catch{return null}if("https:"!==n.protocol&&"http:"!==n.protocol)return null;const a=n.host.toLowerCase(),o=n.pathname.split("/").filter(Boolean);if("linear.app"===a){const[,e,t]=o;return"issue"===e&&t&&it.test(t)?lt("linear",t):null}if("github.com"===a||"www.github.com"===a){const[e,t,n,a]=o;return e&&t&&("issues"===n||"pull"===n)&&a&&rt.test(a)?lt("github_issues",`${e}/${t}#${a}`):null}if("app.asana.com"===a){const[e,...t]=o;return"0"===e&&t.length>=2&&rt.test(t[0])&&rt.test(t[1])||("1"===e&&"project"===t[1]&&"task"===t[3]&&t[4]&&rt.test(t[4])||"1"===e&&"task"===t[1]&&t[2]&&rt.test(t[2]))?lt("asana",""):null}if(st(a,t)){const e=`https://${a}`;if("browse"===o[0]&&o[1]&&it.test(o[1]))return lt("jira",o[1],e);const t=n.searchParams.get("selectedIssue");return t&&it.test(t)?lt("jira",t,e):null}return null}var dt=/* @__PURE__ */new WeakMap,pt=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-output-embed")?e:e.querySelector(".clepit-output-embed");return(t?dt.get(t):void 0)??{url:""}}static render(t,n,a){l.injectStyles("embed-input",H);const o=n??{url:""},i=C.getState().getInstance(t)?.config,r=ot.render(o,{disabledEmbedProviders:i?.disabledEmbedProviders,embedLabels:i?.embedLabels},a?.styles,a?.classNames);return r.classList.add("clepit-embed--input"),r.setAttribute("contenteditable","false"),dt.set(r,o),e.listenForActions(t,r),r}static isEmpty(t){return""===e.save(t).url}static isEmptyData(e){return!e.url}static handleOperation(t,n,a){const o=n.getAttribute("data-id"),i=e.save(n);switch(t){case"embedShowLive":{const{display:e,...t}=i;return _s.updateBlockData(o,t,a)}case"embedShowCard":return _s.updateBlockData(o,{...i,display:"card"},a);case"embedShowLink":{const e=_s.getBlockIndex(a,o);if(-1===e)return;const t=document.createElement("a");return t.href=i.url,t.textContent=i.url,_s.replaceBlock(a,e,{data:{html:t.outerHTML},type:"paragraph"})}case"embedCopyLink":return void navigator.clipboard?.writeText(i.url);case"embedShowChip":{const e=_s.getBlockIndex(a,o);if(-1===e)return;const t=C.getState().getInstance(a)?.config,n=ct(i.url,t?.jiraSites),r=i.issue??je(i.url,n?.tool??"",n?.key??""),s=Oe.create({...r,url:i.url},t?.issueLabels);return _s.replaceBlock(a,e,{data:{html:`${s.outerHTML} `},type:"paragraph"})}default:return}}static refreshIssue(t,n,a){const o=e.save(t);if(!o.issue)return;const i=t.querySelector(`.${l.classNames.block.content}`);if(!i)return;const r=C.getState().getInstance(n),s={classNames:r?.config.classNames?.blocks?.embed,styles:r?.config.styles?.blocks?.embed};i.replaceChildren(e.render(n,{...o,issue:{...a,url:o.url}},s))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}static listenForActions(t,n){const a=e=>{const a=e.target?.closest("[data-issue-action]");if(a)return e.preventDefault(),e.stopPropagation(),void C.getState().getInstance(t)?.config.onIssueAction?.("connect",a.getAttribute("data-issue-tool")??"");const o=e.target?.closest("[data-embed-action]");if(!o)return;e.preventDefault(),e.stopPropagation();const i=o.getAttribute("data-embed-action"),r=n.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");if(!r)return;const s=C.getState().getInstance(t)?.config;"retry"===i?z(t,r,s?.resolveLink):s?.onEmbedAction?.(i,r)};n.addEventListener("click",a),e.eventListenersMap[t]??=[],e.eventListenersMap[t].push({element:n,event:"click",handler:a})}};async function ut(e,t){const n=C.getState().getInstance(e)?.config;if(!n?.resolveIssues||0===t.length)return{};try{const e=await n.resolveIssues([...t]),a={};for(const n of t)e[n]&&(a[n]={...e[n],url:n});return a}catch{const e={};for(const a of t){const t=ct(a,n.jiraSites);e[a]={...je(a,t?.tool??"",t?.key??""),reason:"provider_unreachable"}}return e}}async function ht(e,t,n,a,o,i){const r=C.getState().getInstance(e)?.config,s=je(o,i.tool,i.key);if(a&&"on"===r?.issueCards){const t={data:{issue:s,url:o},type:"embed"};_s.replaceBlock(e,n,t);const a=_s.getBlocks(e)[n]?.getAttribute("data-id");return void(a&&await async function(e,t,n){const a=(await ut(e,[n]))[n];if(!a)return;const o=_s.getBlock(t);if(!o)return;const i=pt.save(o);_s.updateBlockData(t,{...i,issue:{...a,url:i.url}},e)}(e,a,o))}const l=Oe.insertAtCaret(s,r?.issueLabels);if(!l)return;const c=l.closest('[contenteditable="true"]');c&&_s.saveBlockData(c),await async function(e,t,n){const a=(await ut(e,[n]))[n];if(!a||!t.isConnected)return;const o=C.getState().getInstance(e)?.config;Oe.refresh(t,a,o?.issueLabels);const i=t.closest('[contenteditable="true"]');i&&_s.saveBlockData(i)}(e,l,o)}function mt(e){const t=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".tiff",".ico"].some(e=>t.includes(e))||t.includes("data:image/")||t.includes("blob:")}function gt(e){const t=e.toLowerCase();return[".mp4",".webm",".ogg",".mov",".avi",".mkv",".flv",".wmv",".m4v"].some(e=>t.includes(e))||t.includes("data:video/")||t.includes("blob:")}function bt(e){const t=e.toLowerCase();return t.includes("youtube.com")||t.includes("youtu.be")}function ft(e){return e.toLowerCase().includes("vimeo.com")}function vt(e){const t=e.trim();if(!function(e){try{return new URL(e),!0}catch{return!1}}(t))return{isImage:!1,isUrl:!1,isVideo:!1,isVimeo:!1,isYouTube:!1,url:t};const n=bt(t),a=ft(t);return{isImage:mt(t),isUrl:!0,isVideo:gt(t)||n||a,isVimeo:a,isYouTube:n,url:t}}var yt=(e,t)=>void 0===e?.allowedBlockTools||e.allowedBlockTools.includes(t),xt=(e,t)=>{const n=vt(t);if(!n.isUrl)return null;if(n.isImage)return yt(e,"image")?{kind:"image",url:n.url}:null;if(n.isVideo)return yt(e,"video")?{isVimeo:n.isVimeo,isYouTube:n.isYouTube,kind:"video",url:n.url}:null;const a=(o=t,i=e?.jiraSites,ct(o,i));var o,i;if(a)return{issue:a,kind:"issue"};if(!yt(e,"embed"))return null;const r=function(e,t){const n=q(e,{disabledProviders:t});return"invalid"===n.provider||"link"===n.provider?null:n}(t,e?.disabledEmbedProviders);return r?{embed:r,kind:"embed"}:null},kt=(e,t,n)=>{e.addEventListener("pointerdown",a=>{if(0!==a.button)return;const o=document.getElementById(n);if(!o)return;const i=a.clientY;let r=!1,s=!1,l=null;e.setPointerCapture?.(a.pointerId);const c=()=>{l?.remove(),l=null,t.removeAttribute("data-dragging"),e.removeEventListener("pointermove",d),e.removeEventListener("pointerup",h),e.removeEventListener("pointercancel",m),document.removeEventListener("keydown",g)},d=e=>{if(!s&&(r||!(Math.abs(e.clientY-i)<=4))){if(!r){if(_s.getBlocks(n).length<2)return;r=!0,t.setAttribute("data-dragging","")}(e=>{const t=_s.getBlocks(n).map(e=>e.getBoundingClientRect()),a=t.filter(t=>t.top+t.height/2<e).length,i=a<t.length?t[a]?.top??0:t[t.length-1]?.bottom??0;l||(l=p("div","clepit-drop-line",{"aria-hidden":"true"}),o.appendChild(l));const r=o.getBoundingClientRect();l.style.setProperty("--clepit-drop-line-top",`${i}px`),l.style.setProperty("--clepit-drop-line-left",`${r.left+54}px`),l.style.setProperty("--clepit-drop-line-width",`${Math.max(r.width-54,0)}px`)})(e.clientY)}},u=e=>{e.stopPropagation(),e.preventDefault()},h=e=>{const a=r&&!s;if(c(),!r)return;if(window.addEventListener("click",u,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",u,{capture:!0}),0),!(a&&(i=o.getBoundingClientRect(),l=e.clientX,d=e.clientY,l>=i.left&&l<=i.right&&d>=i.top&&d<=i.bottom)))return;var i,l,d;const p=_s.getBlocks(n),h=_s.getBlocks(n).indexOf(t),m=((e,t,n)=>{const a=e.filter(e=>e.top+e.height/2<t).length;return a>n?a-1:a})(p.map(e=>e.getBoundingClientRect()),e.clientY,h);h>=0&&m!==h&&_s.moveBlock(n,h,m)},m=()=>{s=!0,c()},g=e=>{"Escape"===e.key&&r&&(s=!0,l?.remove(),l=null,t.removeAttribute("data-dragging"))};e.addEventListener("pointermove",d),e.addEventListener("pointerup",h),e.addEventListener("pointercancel",m),document.addEventListener("keydown",g)})},wt="data-highlighted",Ct=(e,t)=>{e.forEach((e,n)=>{n===t?(e.setAttribute(wt,""),e.scrollIntoView?.({block:"nearest"})):e.removeAttribute(wt)})},At="\n/* Output alert styles */\n.clepit-output-alert {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 1rem 0;\n}\n\n.clepit-output-alert--info {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-output-alert--warning {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-output-alert--error {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-output-alert--success {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-output-alert--plain {\n background: transparent;\n color: inherit;\n}\n\n.clepit-output-alert-content {\n line-height: 1.5;\n}\n\n/* Output alert link styles */\n.clepit-output-alert a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-alert a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output alert inline code styling */\n.clepit-output-alert code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output alert marker brush effect */\n.clepit-output-alert mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-alert mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n",St=class e{static{this.placeholder="Alert message here..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${l.classNames.block.alert}`)||e,n=t.getAttribute("data-variant")||"info";return{html:m(t.innerHTML),variant:n}}static render(t,n,a){l.injectStyles("clepit-alert-input-styles","\n/* Alert block styles */\n.clepit-alert {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 0 20px;\n}\n\n.clepit-alert[data-variant=\"info\"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-alert[data-variant=\"warning\"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-alert[data-variant=\"error\"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-alert[data-variant=\"success\"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-alert[data-variant=\"plain\"] {\n background: transparent;\n color: inherit;\n}\n\n.clepit-alert-text {\n outline: none;\n margin: 0;\n padding: 0;\n}\n\n.clepit-alert[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: rgba(0, 0, 0, 0.6);\n font-style: italic;\n pointer-events: none;\n}\n\n/* Alert link styles */\n.clepit-alert-text a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-alert-text a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Alert inline code styling */\n.clepit-alert-text code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Alert marker brush effect */\n.clepit-alert-text mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-alert-text mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o={html:"",variant:"info"},i=n?{...o,...n}:o,r=l.createStyledElement("div","clepit-alert",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});return r.setAttribute("data-variant",i.variant),r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",ne(t,"alertTextHint",e.placeholder)),r.innerHTML=m(i.html),e.addEventListener(t,r,"keydown",_s.handleKeydown),e.addEventListener(t,r,"input",_s.handleInput),r}static changeVariant(t,n,a){const o=C.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-variant")===n)return;const i=t.innerHTML||"",r={html:i.trim()&&"<br>"!==i.trim()?i:"",variant:n},s={classNames:o.config.classNames?.blocks?.alert,margins:o.config.margins,styles:o.config.styles?.blocks?.alert},c=_s.getBlockIndex(a,t.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id")),d=e.render(a,r,s);t.replaceWith(d),C.getState().updateBlockData(a,c,r)}static isEmpty(e){return h(e.querySelector(`.${l.classNames.block.alert}`)?.innerHTML)}static isEmptyData(e){return h(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Et=class e{static render(t,n,a,o){if(l.injectStyles("clepit-alert-output-styles",At),!e.validate(t))return X();if(St.isEmptyData(t))return document.createElement("div");const i=t.variant,r=l.createStyledElement("div",`clepit-output-alert clepit-output-alert--${i}`,{classNames:o?.[i],styles:a?.[i]});return r.innerHTML=m(t.html),r}static draw(t,n=R){if(!e.validate(t)||St.isEmptyData(t))return null;const a=n.create("div");return a.addClass("clepit-output-alert",`clepit-output-alert--${t.variant}`),t.html&&a.setHtml(t.html),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"variant"in e&&"html"in e&&"string"==typeof e.html}},Lt='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M17 7h-3c-.55 0-1 .45-1 1s.45 1 1 1h3c1.65 0 3 1.35 3 3s-1.35 3-3 3h-3c-.55 0-1 .45-1 1s.45 1 1 1h3c2.76 0 5-2.24 5-5s-2.24-5-5-5m-9 5c0 .55.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1H9c-.55 0-1 .45-1 1m2 3H7c-1.65 0-3-1.35-3-3s1.35-3 3-3h3c.55 0 1-.45 1-1s-.45-1-1-1H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h3c.55 0 1-.45 1-1s-.45-1-1-1"></path></svg>',Nt='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"></path></svg>',Bt='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M4 11h16v2H4z" fill-rule="evenodd"></path></svg>',$t={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M4.47 21h15.06c1.54 0 2.5-1.67 1.73-3L13.73 4.99c-.77-1.33-2.69-1.33-3.46 0L2.74 18c-.77 1.33.19 3 1.73 3M12 14c-.55 0-1-.45-1-1v-2c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1m1 4h-2v-2h2z"></path></svg>',get input(){return St},label:"Alert",get output(){return Et},testId:"block-type-alert",type:"alert"},Mt=`\n/* Audio block styles */\n.clepit-audio-container {\n margin: 0 16px;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 96%;\n box-sizing: border-box;\n}\n\n.${l.classNames.block.audio.wrapper} {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.clepit-audio {\n width: 100%;\n}\n\n.align-left {\n justify-content: flex-start;\n}\n\n.align-center {\n justify-content: center;\n}\n\n.align-right {\n justify-content: flex-end;\n}\n\n.${l.classNames.block.audio.wrapper}:hover {\n opacity: 0.9;\n}\n\n.clepit-audio-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-audio-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-audio-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-audio-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Audio caption styling */\n.clepit-audio-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Audio caption placeholder styles */\n.clepit-audio-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Audio Drop Area */\n.clepit-audio-drop-area {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n}\n\n.clepit-audio-drop-area:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-audio-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-audio-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-audio-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n margin-bottom: 8px;\n}\n\n.clepit-audio-drop-subtext {\n font-size: 14px;\n color: var(--clepit-text-subtle);\n line-height: 1.4;\n}\n\n.clepit-audio-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Audio Loading State */\n.clepit-audio-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-audio-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-audio-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Audio Error State */\n.clepit-audio-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-audio-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-audio-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-audio-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-audio-error-retry:hover {\n background: var(--clepit-error);\n}\n\n/* Audio delete button */\n.${l.classNames.block.audioDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${l.classNames.block.audioDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Audio drop area delete button */\n.clepit-audio-drop-area .${l.classNames.block.audioDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-audio-drop-area .${l.classNames.block.audioDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,It="\n/* Output audio styles */\n.clepit-output-audio-container {\n width: 100%;\n margin: 1rem 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: flex-start;\n}\n\n.clepit-output-audio-wrapper {\n width: 100%;\n display: flex;\n}\n\n.clepit-output-audio {\n width: 100%;\n}\n\n\n.clepit-output-audio-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Output audio alignment */\n.clepit-output-audio-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-output-audio-wrapper--center {\n justify-content: center;\n}\n\n.clepit-output-audio-wrapper--right {\n justify-content: flex-end;\n}\n",Tt=class e{static{this.placeholder="Add a caption..."}static{this.eventListenersMap={}}static{this.validTypes=["audio/mp3","audio/wav","audio/ogg","audio/mpeg","audio/mp4","audio/webm"]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("audio"),n=e.querySelector(`.${l.classNames.block.audio.captionEditable}`),a=e.querySelector(`.${l.classNames.block.audio.wrapper}`);let o="center";return a&&(o=a.classList.contains("align-left")?"left":a.classList.contains("align-right")?"right":"center"),{alignment:o,alt:t&&t.getAttribute("alt")||"",caption:m(n?.innerHTML),url:t&&t.getAttribute("src")||""}}static render(t,n,a,o){l.injectStyles("clepit-audio-input-styles",Mt);const i=a||{alt:"",caption:"",url:""},r=l.createStyledElement("div",l.classNames.block.audio.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return i.url?e.renderAudio(r,i,t,n,o):e.renderDropArea(r,t,n,o),r}static renderAudio(t,n,a,o,i){if(!document.getElementById(o))return;t.innerHTML="";const r=l.createStyledElement("div",l.classNames.block.audio.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("align-left");break;case"center":r.classList.add("align-center");break;case"right":r.classList.add("align-right")}const s=l.createStyledElement("audio","clepit-audio",{classNames:i?.classNames?.container,styles:i?.styles?.container});s.src=n.url,s.controls=!0,s.preload="metadata",n.alt&&s.setAttribute("alt",n.alt);const c=l.createStyledElement("div","clepit-audio-caption-container",{classNames:i?.classNames?.container,styles:i?.styles?.container});c.classList.add("clepit-audio-caption-container");const d=l.createStyledElement("div","clepit-audio-caption-editable",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});d.setAttribute("contenteditable","true"),d.setAttribute("data-placeholder",ne(o,"mediaCaptionHint",e.placeholder)),d.innerHTML=m(n.caption),e.addEventListener(o,d,"keydown",_s.handleKeydown),e.addEventListener(o,d,"input",_s.handleInput),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),r.appendChild(s),c.appendChild(d),t.appendChild(r),t.appendChild(c),d.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const i=l.createStyledElement("div",l.classNames.block.audio.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});i.setAttribute("tabindex","0"),i.classList.add("clepit-drop-area");const r=l.createStyledElement("div","clepit-audio-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});r.textContent="♪";const s=l.createStyledElement("div","clepit-audio-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text});s.innerHTML='<strong>Drop an audio file here</strong><br>or <span class="clepit-audio-click-text">click to select</span>';const c=l.createStyledElement("div","clepit-audio-drop-subtext",{classNames:o?.classNames?.dropArea?.subtext,styles:o?.styles?.dropArea?.subtext});c.textContent="Supports MP3, WAV, OGG, and other audio formats";const d=l.createStyledElement("button",`${l.classNames.block.audioDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});d.type="button",d.textContent="✕",i.appendChild(r),i.appendChild(s),i.appendChild(c),i.appendChild(d);const p=a?C.getState().getInstance(a):null,u=p?.config.classNames?.tooltips,h=p?.config.styles?.tooltips;ye(d,"Delete block","below",u,h),e.addEventListener(a,d,"click",e=>{e.preventDefault(),e.stopPropagation();const t=d.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");t&&_s.removeBlock(a,_s.getBlockIndex(a,t))}),e.addEventListener(a,i,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,i,"dragleave",()=>{i.classList.remove("clepit-audio-drop-area--dragover")}),e.addEventListener(a,i,"dragover",e=>{e.preventDefault(),e.stopPropagation(),i.classList.add("clepit-audio-drop-area--dragover")}),e.addEventListener(a,i,"drop",r=>{r.preventDefault(),r.stopPropagation(),i.classList.remove("clepit-audio-drop-area--dragover"),e.handleFileDrop(r,t,n,a,o)}),e.addEventListener(a,i,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,i,"mousedown",e=>{e.preventDefault(),e.stopPropagation()}),t.appendChild(i)}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="audio/*",i.style.display="none",i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidAudioFile(i)?e.processAudioFile(i,t,n,a,o):e.showError(t,"Please select a valid audio file (MP3, WAV, OGG)")}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidAudioFile(t)?e.processAudioFile(t,n,a,o,i):e.showError(n,"Please select a valid audio file (MP3, WAV, OGG)")}}static isValidAudioFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("audio/")}static async processAudioFile(t,n,a,o,i){e.showLoading(n);try{let r=await a(t);if(r){e.renderAudio(n,{alignment:"center",alt:t.name,caption:"",url:r},a,o,i);const s=n.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");s&&C.getState().updateBlockData(o,_s.getBlockIndex(o,s),_s.getBlockData(s).data)}else e.showError(n,"Failed to upload audio. Please try again.")}catch(r){console.error("Audio upload error:",r),e.showError(n,"Failed to upload audio. Please try again.")}}static showLoading(e){e.innerHTML="";const t=l.createStyledElement("div","clepit-audio-loading",void 0);t.textContent="Uploading audio...",e.appendChild(t)}static showError(e,t){e.innerHTML="";const n=l.createStyledElement("div","clepit-audio-error",void 0);n.textContent=t,e.appendChild(n)}static setAlignment(e,t){const n=e.querySelector(".clepit-audio-wrapper");n&&(n.classList.remove("align-left","align-center","align-right"),n.classList.add(`align-${t}`));const a=_s.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&C.getState().partialUpdateBlockData(a,_s.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${l.classNames.block.audio.wrapper} audio`),n=e.querySelector(`.${l.classNames.block.audio.captionEditable}`);let a=!1,o=!1;return t&&t.getAttribute("src")?.trim()||(a=!0),n?h(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return!e.url?.trim()&&h(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},_t=class e{static render(t,n,a,o){if(l.injectStyles("clepit-audio-output-styles",It),!e.validate(t))return X();if(Tt.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alignment||"center",c=l.createStyledElement("div","clepit-output-audio-container",{classNames:o?.container,styles:a?.container}),d=l.createStyledElement("div","clepit-output-audio-wrapper");switch(s){case"left":d.classList.add("clepit-output-audio-wrapper--left");break;case"center":d.classList.add("clepit-output-audio-wrapper--center");break;case"right":d.classList.add("clepit-output-audio-wrapper--right")}const u=p("audio","clepit-output-audio");if(u.src=i,u.controls=!0,u.preload="metadata",t.alt&&u.setAttribute("alt",t.alt),d.appendChild(u),c.appendChild(d),r){const e=l.createStyledElement("figcaption","clepit-output-audio-caption",{classNames:o?.caption,styles:a?.caption});e.innerHTML=m(r),c.appendChild(e)}if(a&&(a.container&&Object.assign(c.style,a.container),a.caption)){const e=c.querySelector(".clepit-output-audio-caption");e&&Object.assign(e.style,a.caption)}if(o&&(o.container&&c.classList.add(o.container),o.caption)){const e=c.querySelector(".clepit-output-audio-caption");e&&e.classList.add(o.caption)}return c}static draw(t,n=R){if(!e.validate(t)||Tt.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-audio-container");const o=n.create("div");o.addClass("clepit-output-audio-wrapper");const i=t.alignment??"center";i&&o.addClass(`clepit-output-audio-wrapper--${i}`);const r=n.create("audio");if(r.addClass("clepit-output-audio"),r.setAttribute("src",t.url),r.setAttribute("controls","controls"),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-audio-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},qt={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 5v8.55c-.94-.54-2.1-.75-3.33-.32-1.34.48-2.37 1.67-2.61 3.07-.46 2.74 1.86 5.08 4.59 4.65 1.96-.31 3.35-2.11 3.35-4.1V7h2c1.1 0 2-.9 2-2s-.9-2-2-2h-2c-1.1 0-2 .9-2 2z"></path></svg>',get input(){return Tt},label:"Audio",get output(){return _t},section:"media",testId:"block-type-audio",type:"audio"},Dt=`\n/* Checklist input block styles */\n.${l.classNames.block.checklist.container} {\n margin: 0;\n padding: 0 20px;\n}\n\n.${l.classNames.block.checklist.item} {\n --text: var(--clepit-text);\n --check: var(--clepit-primary);\n --disabled: var(--clepit-text-muted);\n --border-radius: 10px;\n border-radius: var(--border-radius);\n position: relative;\n padding: 5px;\n display: grid;\n grid-template-columns: 30px auto;\n align-items: center;\n margin: 4px 0;\n}\n\n.${l.classNames.block.checklist.text} {\n color: var(--text);\n position: relative;\n cursor: pointer;\n display: grid;\n align-items: center;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n transition: color 0.3s ease;\n outline: none;\n min-height: 1.2em;\n line-height: 1.6;\n padding: 0;\n margin: 0;\n}\n\n.${l.classNames.block.checklist.text}::before,\n.${l.classNames.block.checklist.text}::after {\n content: "";\n position: absolute;\n}\n\n.${l.classNames.block.checklist.text}::before {\n height: 2px;\n width: 8px;\n left: -27px;\n background: var(--check);\n border-radius: 2px;\n transition: background 0.3s ease;\n}\n\n.${l.classNames.block.checklist.text}::after {\n height: 4px;\n width: 4px;\n top: 8px;\n left: -25px;\n border-radius: 50%;\n}\n\n.${l.classNames.block.checklist.checkbox} {\n -webkit-appearance: none;\n -moz-appearance: none;\n position: relative;\n height: 15px;\n width: 15px;\n outline: none;\n border: 0;\n margin: 0 15px 0 0;\n cursor: pointer;\n background: var(--background);\n display: grid;\n align-items: center;\n}\n\n.${l.classNames.block.checklist.checkbox}::before,\n.${l.classNames.block.checklist.checkbox}::after {\n content: "";\n position: absolute;\n height: 2px;\n top: auto;\n background: var(--check);\n border-radius: 2px;\n}\n\n.${l.classNames.block.checklist.checkbox}::before {\n width: 0px;\n right: 60%;\n transform-origin: right bottom;\n}\n\n.${l.classNames.block.checklist.checkbox}::after {\n width: 0px;\n left: 40%;\n transform-origin: left bottom;\n}\n\n.${l.classNames.block.checklist.checkbox}:checked::before {\n -webkit-animation: clepit-check-01-11 0.4s ease forwards;\n animation: clepit-check-01-11 0.4s ease forwards;\n}\n\n.${l.classNames.block.checklist.checkbox}:checked::after {\n -webkit-animation: clepit-check-02-11 0.4s ease forwards;\n animation: clepit-check-02-11 0.4s ease forwards;\n}\n\n.${l.classNames.block.checklist.checkbox}:checked + .${l.classNames.block.checklist.text} {\n color: var(--disabled);\n -webkit-animation: clepit-move-11 0.3s ease 0.1s forwards;\n animation: clepit-move-11 0.3s ease 0.1s forwards;\n}\n\n.${l.classNames.block.checklist.checkbox}:checked + .${l.classNames.block.checklist.text}::before {\n background: var(--disabled);\n -webkit-animation: clepit-slice-11 0.4s ease forwards;\n animation: clepit-slice-11 0.4s ease forwards;\n}\n\n.${l.classNames.block.checklist.checkbox}:checked + .${l.classNames.block.checklist.text}::after {\n -webkit-animation: clepit-firework-11 0.5s ease forwards 0.1s;\n animation: clepit-firework-11 0.5s ease forwards 0.1s;\n}\n\n.${l.classNames.block.checklist.text}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Checklist input link styles */\n.${l.classNames.block.checklist.text} a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.${l.classNames.block.checklist.text} a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n@-webkit-keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@-webkit-keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@-webkit-keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@-webkit-keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@-webkit-keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n\n@keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n`,zt='\n/* Checklist output block styles */\n.clepit-output-checklist {\n margin: 0 0 1rem 0;\n padding-left: 0;\n}\n\n.clepit-output-checklist-item {\n --text: var(--clepit-text);\n --check: var(--clepit-primary);\n --disabled: var(--clepit-text-muted);\n --border-radius: 10px;\n border-radius: var(--border-radius);\n position: relative;\n padding: 5px;\n display: grid;\n grid-template-columns: 30px auto;\n align-items: center;\n margin: 0.5rem 0;\n line-height: 1.6;\n}\n\n.clepit-output-checklist-text {\n color: var(--text);\n position: relative;\n cursor: pointer;\n display: grid;\n align-items: center;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n transition: color 0.3s ease;\n line-height: 1.6;\n}\n\n.clepit-output-checklist-text::before,\n.clepit-output-checklist-text::after {\n content: "";\n position: absolute;\n}\n\n.clepit-output-checklist-text::before {\n height: 2px;\n width: 8px;\n left: -27px;\n background: var(--check);\n border-radius: 2px;\n transition: background 0.3s ease;\n}\n\n.clepit-output-checklist-text::after {\n height: 4px;\n width: 4px;\n top: 8px;\n left: -25px;\n border-radius: 50%;\n}\n\n.clepit-output-checklist-checkbox {\n -webkit-appearance: none;\n -moz-appearance: none;\n position: relative;\n height: 15px;\n width: 15px;\n outline: none;\n border: 0;\n margin: 0 15px 0 0;\n cursor: pointer;\n background: var(--background);\n display: grid;\n align-items: center;\n pointer-events: none;\n}\n\n.clepit-output-checklist-checkbox::before,\n.clepit-output-checklist-checkbox::after {\n content: "";\n position: absolute;\n height: 2px;\n top: auto;\n background: var(--check);\n border-radius: 2px;\n}\n\n.clepit-output-checklist-checkbox::before {\n width: 0px;\n right: 60%;\n transform-origin: right bottom;\n}\n\n.clepit-output-checklist-checkbox::after {\n width: 0px;\n left: 40%;\n transform-origin: left bottom;\n}\n\n.clepit-output-checklist-checkbox:checked::before {\n -webkit-animation: clepit-check-01-11 0.4s ease forwards;\n animation: clepit-check-01-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked::after {\n -webkit-animation: clepit-check-02-11 0.4s ease forwards;\n animation: clepit-check-02-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text {\n color: var(--disabled);\n -webkit-animation: clepit-move-11 0.3s ease 0.1s forwards;\n animation: clepit-move-11 0.3s ease 0.1s forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text::before {\n background: var(--disabled);\n -webkit-animation: clepit-slice-11 0.4s ease forwards;\n animation: clepit-slice-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text::after {\n -webkit-animation: clepit-firework-11 0.5s ease forwards 0.1s;\n animation: clepit-firework-11 0.5s ease forwards 0.1s;\n}\n\n@-webkit-keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@-webkit-keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@-webkit-keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@-webkit-keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@-webkit-keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n\n@keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n',jt=class e{static{this.placeholder="Add checklist item..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=[];return e.querySelectorAll(`.${l.classNames.block.checklist.item}`).forEach(e=>{const n=e.querySelector('input[type="checkbox"]'),a=e.querySelector(`.${l.classNames.block.checklist.text}`);n&&a&&t.push({checked:n.checked,text:m(a.innerHTML)})}),{items:t}}static render(t,n,a){l.injectStyles("clepit-checklist-input-styles",Dt);const o={items:[]},i=n?{...o,...n}:o,r=l.createStyledElement("div",l.classNames.block.checklist.container,{classNames:a?.classNames?.container,styles:a?.styles?.container});return i.items.length>0?i.items.forEach(n=>e.createAndAppendChecklistItem(n,r,t,a)):e.createAndAppendChecklistItem({checked:!1,text:""},r,t,a),r}static createAndAppendChecklistItem(t,n,a,o){const i=l.createStyledElement("div",l.classNames.block.checklist.item,{classNames:o?.classNames?.item,styles:o?.styles?.item}),r=l.createStyledElement("input",l.classNames.block.checklist.checkbox,{classNames:o?.classNames?.checkbox,styles:o?.styles?.checkbox});r.type="checkbox",r.checked=t.checked;const s=l.createStyledElement("div",l.classNames.block.checklist.text,{classNames:o?.classNames?.text,styles:o?.styles?.text});s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",ne(a,"checklistItemHint",e.placeholder)),s.innerHTML=m(t.text?.trim()),e.addEventListener(a,r,"change",()=>_s.saveBlockData(r)),e.addEventListener(a,s,"keydown",t=>{const r=t,c=n.closest(`.${l.classNames.block.container}`);if(!c)return;const d=_s.getBlockIndex(a,c.getAttribute("data-id")),p=r.metaKey||r.ctrlKey;if(r.shiftKey)switch(r.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),d>0&&_s.moveBlock(a,d,d-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const e=_s.getBlocks(a);e&&d<e.length-1&&_s.moveBlock(a,d,d+1)}else if(p)switch(r.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),_s.removeBlock(a,d)}else if("Enter"===r.key)if(t.preventDefault(),t.stopPropagation(),h(s.innerHTML)){e.cleanupEmptyItems(n);const t=n.closest(`.${l.classNames.block.container}`);if(!t)return;const o=_s.getBlockIndex(a,t.getAttribute("data-id"));_s.insertBlock({data:{html:""},type:"paragraph"},a,o+1)}else e.createAndAppendChecklistItem({checked:!1,text:""},n,a,o);else if("Backspace"===r.key){if(h(s.innerHTML)){t.preventDefault(),t.stopPropagation();const e=Array.from(n.querySelectorAll(`.${l.classNames.block.checklist.item}`)),o=e.indexOf(i);if(1===e.length){const e=n.closest(`.${l.classNames.block.container}`);if(!e)return;const t=_s.getBlockIndex(a,e.getAttribute("data-id"));if(-1===t)return;_s.removeBlock(a,t)}else i.remove(),o>0?e[o-1].querySelector(".clepit-checklist-text")?.focus():e[o+1].querySelector(".clepit-checklist-text")?.focus()}}else{_s.ensureActiveBlock(a);const e=_s.getBlocks(a);switch(r.key){case"ArrowUp":t.preventDefault(),t.stopPropagation();const a=Array.from(n.querySelectorAll(`.${l.classNames.block.checklist.item}`)),o=a.indexOf(i);if(0===o){if(d>0){const t=e[d-1];t&&_s.focusBlock(t)}}else{const e=a[o-1].querySelector(`.${l.classNames.block.checklist.text}`);e&&e.focus()}return;case"ArrowDown":t.preventDefault(),t.stopPropagation();const r=Array.from(n.querySelectorAll(`.${l.classNames.block.checklist.item}`)),s=r.indexOf(i);if(s===r.length-1){if(d<e.length-1){const t=e[d+1];t&&_s.focusBlock(t)}}else{const e=r[s+1].querySelector(`.${l.classNames.block.checklist.text}`);e&&e.focus()}return}}}),e.addEventListener(a,s,"input",_s.handleInput),i.appendChild(r),i.appendChild(s),n.appendChild(i),s.focus()}static cleanupEmptyItems(e){const t=Array.from(e.querySelectorAll(`.${l.classNames.block.checklist.item}`)),n=t.filter(e=>h(e.querySelector(`.${l.classNames.block.checklist.text}`)?.innerHTML||""));if(t.length===n.length){if(t.length<2)return;for(let e=1;e<n.length;e++)n[e].remove()}else n.forEach(e=>e.remove())}static isEmpty(e){const t=e.querySelectorAll(`.${l.classNames.block.checklist.item}`);return!t||Array.from(t).every(e=>h(e.querySelector(`.${l.classNames.block.checklist.text}`)?.innerHTML))}static isEmptyData(e){return 0===e.items.length||e.items.every(e=>h(e.text))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Ht=class e{static render(t,n,a,o){if(l.injectStyles("clepit-checklist-output-styles",zt),!e.validate(t))return X();if(jt.isEmptyData(t))return document.createElement("div");const i=t.items,r=l.createStyledElement("div","clepit-output-checklist",{classNames:o?.container,styles:a?.container});return i.forEach((e,t)=>{const n=l.createStyledElement("div","clepit-output-checklist-item",{classNames:o?.item,styles:a?.item}),i=l.createStyledElement("input","clepit-output-checklist-checkbox",{classNames:o?.checkbox,styles:a?.checkbox});i.type="checkbox",i.checked=e.checked,i.setAttribute("readonly","true");const s=l.createStyledElement("div","clepit-output-checklist-text",{classNames:o?.text,styles:a?.text});s.innerHTML=m(e.text),i.checked&&n.classList.add("checked"),n.appendChild(i),n.appendChild(s),r.appendChild(n)}),r}static draw(t,n=R){if(!e.validate(t)||jt.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-checklist");for(const e of t.items){const t=n.create("div");t.addClass("clepit-output-checklist-item");const o=n.create("input");o.addClass("clepit-output-checklist-checkbox"),o.setAttribute("type","checkbox"),e.checked&&o.setAttribute("checked","checked"),o.setAttribute("readonly","true"),t.append(o);const i=n.create("div");i.addClass("clepit-output-checklist-text"),e.text?.trim()&&i.setHtml(e.text),t.append(i),a.append(t)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.items)}},Ot={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2m-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"></path></svg>',get input(){return jt},label:"Checklist",get output(){return Ht},testId:"block-type-checklist",type:"checklist"},Pt={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M8.7 15.9 4.8 12l3.9-3.9c.39-.39.39-1.01 0-1.4a.984.984 0 0 0-1.4 0l-4.59 4.59c-.39.39-.39 1.02 0 1.41l4.59 4.6c.39.39 1.01.39 1.4 0s.39-1.01 0-1.4m6.6 0 3.9-3.9-3.9-3.9a.984.984 0 0 1 0-1.4c.39-.39 1.01-.39 1.4 0l4.59 4.59c.39.39.39 1.02 0 1.41l-4.59 4.6c-.39.39-1.01.39-1.4 0a.984.984 0 0 1 0-1.4"></path></svg>',get input(){return he},label:"Code",get output(){return Ce},section:"media",testId:"block-type-code",type:"code"},Rt="\n.clepit-collapsible {\n display: block;\n}\n.clepit-collapsible > summary {\n display: flex;\n align-items: flex-start;\n gap: 6px;\n cursor: pointer;\n font-weight: 600;\n list-style: none;\n}\n.clepit-collapsible > summary::-webkit-details-marker {\n display: none;\n}\n.clepit-collapsible > summary::before {\n content: '';\n flex: 0 0 auto;\n width: 8px;\n height: 8px;\n margin-top: 7px;\n border-right: 2px solid currentColor;\n border-bottom: 2px solid currentColor;\n transform: rotate(-45deg);\n transition: transform 120ms ease;\n}\n.clepit-collapsible[open] > summary::before {\n transform: rotate(45deg);\n}\n.clepit-collapsible__children {\n padding-left: 22px;\n}\n.clepit-collapsible__children > * + * {\n margin-top: 8px;\n}\n",Ft=`${Rt}\n.clepit-collapsible__title-input {\n border: none;\n outline: none;\n background: transparent;\n font: inherit;\n font-weight: 600;\n width: 100%;\n}\n.clepit-collapsible__add-child {\n border: none;\n background: transparent;\n cursor: pointer;\n font: inherit;\n opacity: 0.6;\n padding: 4px 0;\n}\n.clepit-collapsible__add-child:hover {\n opacity: 1;\n}\n.clepit-collapsible__child-row {\n display: flex;\n align-items: flex-start;\n gap: 4px;\n}\n.clepit-collapsible__child-row > :first-child {\n flex: 1 1 auto;\n}\n.clepit-collapsible__remove-child {\n border: none;\n background: transparent;\n cursor: pointer;\n opacity: 0.4;\n padding: 2px;\n}\n.clepit-collapsible__remove-child:hover {\n opacity: 1;\n}\n`,Vt=Rt,Ut=/* @__PURE__ */new WeakMap;var Wt=class e{static{this.placeholder="Section title"}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.classList.contains("clepit-collapsible")?e:e.querySelector(".clepit-collapsible");if(!t)return{children:[],html:"",open:!1};const n=t.querySelector(".clepit-collapsible__title"),a=t.open??!1,o=Ut.get(t)??[],i=[];return t.querySelectorAll(".clepit-collapsible__child").forEach((e,t)=>{const n=o[t],a=e.getAttribute("data-child-type")??n?.type,r=a?function(e){return Sr.find(t=>t.type===e)}(a):void 0;if(r){const t=r.input.save(e);i.push({...n?.id?{id:n.id}:{},data:t,type:r.type})}else n&&i.push(n)}),{children:i,html:m(n?.innerHTML),open:a}}static render(t,n,a){l.injectStyles("collapsible-input",Ft);const o={children:[],html:"",open:!0},i=n?{...o,...n}:o,r=l.createStyledElement("details","clepit-collapsible clepit-collapsible--input",{classNames:a?.classNames?.section,styles:a?.styles?.section});r.open=i.open??!0,Ut.set(r,[...i.children??[]]);const s=document.createElement("summary"),c=document.createElement("span");c.className="clepit-collapsible__title",c.setAttribute("contenteditable","true"),c.setAttribute("data-placeholder",ne(t,"collapsibleTitleHint",e.placeholder)),i.html&&(c.innerHTML=m(i.html)),s.appendChild(c),r.appendChild(s);const d=document.createElement("div");return d.className="clepit-collapsible__children",(i.children??[]).forEach(n=>{d.appendChild(e.renderChild(t,n))}),r.appendChild(d),e.addEventListener(t,c,"keydown",_s.handleKeydown),e.addEventListener(t,c,"input",_s.handleInput),r}static renderChild(e,t){const n=document.createElement("div");n.className="clepit-collapsible__child";const a=_s.renderTool(t.type,t.data,e);if(a)n.setAttribute("data-child-type",t.type),n.appendChild(a);else{const e=document.createElement("div");e.className="clepit-collapsible__unknown-child",e.textContent=`Unsupported block: ${t.type}`,n.appendChild(e)}return n}static isEmpty(e){const t=e.querySelector(".clepit-collapsible");if(!t)return!0;const n=t.querySelector(".clepit-collapsible__title"),a=t.querySelectorAll(".clepit-collapsible__child").length>0;return h(n?.innerHTML)&&!a}static isEmptyData(e){return h(e.html)&&0===(e.children??[]).length}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Kt="\n.clepit-collection {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n color: inherit;\n}\n.clepit-collection__icon {\n font-size: 18px;\n line-height: 1;\n}\n.clepit-collection__label {\n opacity: 0.7;\n}\n",Gt=Kt,Jt=Kt,Xt=class e{static render(t,n,a,o){if(l.injectStyles("collection-output",Jt),!e.validate(t))return X();const i=l.createStyledElement("div","clepit-collection clepit-output-collection",{classNames:o?.wrapper,styles:a?.wrapper});i.setAttribute("data-collection-id",t.collectionId);const r=document.createElement("span");r.className="clepit-collection__icon",r.textContent="▦",i.appendChild(r);const s=document.createElement("span");return s.className="clepit-collection__label",s.textContent="Collection",i.appendChild(s),i}static draw(t,n=R){if(!e.validate(t))return null;const a=n.create("div");a.addClass("clepit-collection","clepit-output-collection"),a.setAttribute("data-collection-id",t.collectionId);const o=n.create("span");o.addClass("clepit-collection__icon"),o.setText("▦"),a.append(o);const i=n.create("span");return i.addClass("clepit-collection__label"),i.setText("Collection"),a.append(i),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.collectionId&&e.collectionId.length>0}},Yt="\n.clepit-columns {\n display: flex;\n gap: 16px;\n align-items: flex-start;\n}\n.clepit-columns__column {\n flex: 1 1 0;\n min-width: 0;\n}\n.clepit-columns__column > * + * {\n margin-top: 8px;\n}\n@media (max-width: 640px) {\n .clepit-columns {\n flex-direction: column;\n }\n}\n",Zt=`${Yt}\n.clepit-columns__add-child,\n.clepit-columns__add-column {\n border: none;\n background: transparent;\n cursor: pointer;\n font: inherit;\n opacity: 0.6;\n padding: 4px 0;\n}\n.clepit-columns__add-child:hover,\n.clepit-columns__add-column:hover {\n opacity: 1;\n}\n`,Qt=Yt,en=class e{static render(t,n,a,o){if(l.injectStyles("columns-output",Qt),!e.validate(t))return X();const i=l.createStyledElement("div","clepit-columns clepit-output-columns",{classNames:o?.container,styles:a?.container});for(const r of t.columns){const t=l.createStyledElement("div","clepit-columns__column",{classNames:o?.column,styles:a?.column});for(const a of r)t.appendChild(e.renderChild(a,n));i.appendChild(t)}return i}static renderChild(e,t){const n=Sr.find(t=>t.type===e.type);if(!n){const t=document.createElement("div");return t.className="clepit-columns__unknown-child",t.textContent=`Unsupported block: ${e.type}`,t}return n.output.render(e.data,t)}static draw(t,n=R,a){if(!e.validate(t))return null;const o=n.create("div");o.addClass("clepit-columns","clepit-output-columns");for(const e of t.columns){const t=n.create("div");t.addClass("clepit-columns__column");for(const o of e){const e=Li(o,n,a);e&&t.append(e)}o.append(t)}return o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.columns)&&e.columns.length>=2&&e.columns.length<=4&&e.columns.every(e=>Array.isArray(e))}},tn="\n.clepit-date {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 2px 8px;\n border-radius: 6px;\n background: rgba(127, 127, 127, 0.12);\n font-variant-numeric: tabular-nums;\n}\n",nn=`${tn}\n.clepit-date--input {\n cursor: pointer;\n border: none;\n font: inherit;\n}\n`,an=tn,on=/^(\d{4})-(\d{2})-(\d{2})$/;function rn(e){const t=on.exec(e.trim());if(!t)return null;const n=Number(t[1]),a=Number(t[2]),o=Number(t[3]),i=new Date(Date.UTC(n,a-1,o));return i.getUTCFullYear()!==n||i.getUTCMonth()!==a-1||i.getUTCDate()!==o?null:i}var sn=class e{static render(t,n,a,o){l.injectStyles("date-output",an);const i=e.validate(t)?rn(t.date):null;if(!i)return X();const r=l.createStyledElement("time","clepit-date clepit-output-date",{classNames:o?.pill,styles:a?.pill});return r.dateTime=t.date,r.textContent=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}).format(i),r}static draw(t,n=R){const a=e.validate(t)?rn(t.date):null;if(!a)return null;const o=n.create("time");return o.addClass("clepit-date","clepit-output-date"),o.setAttribute("datetime",t.date),o.setText(new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}).format(a)),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.date}},ln='\n/* Output delimiter styles */\n.clepit-output-delimiter {\n margin: 2rem 0;\n text-align: center;\n}\n\n.clepit-output-delimiter[data-variant="stars"] {\n font-size: 1.5rem;\n font-weight: 300;\n letter-spacing: 8px;\n margin: 0; /* Remove margin for star variant */\n}\n\n.clepit-output-delimiter hr[data-variant="line"] {\n border: none;\n height: 2px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 20px 0;\n}\n\n.clepit-output-delimiter[data-variant="line"] {\n margin: 0; /* Remove container margin for line variant */\n}\n',cn=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{variant:e.querySelector(".clepit-delimiter")?.getAttribute("data-variant")||"line"}}static render(t,n,a){l.injectStyles("clepit-delimiter-input-styles",'\n/* Delimiter block styles */\n.clepit-delimiter-container {\n margin: 0.5rem 0;\n text-align: center;\n}\n\n.clepit-delimiter {\n border: none;\n height: 2px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 20px 0;\n}\n\n.clepit-delimiter[data-variant="stars"] {\n height: auto;\n background: none;\n font-size: 24px;\n letter-spacing: 8px;\n margin: 0; /* Remove margin for star variant */\n}\n\n');const o={variant:"line"},i=n?{...o,...n}:o,r=l.createStyledElement("div","clepit-delimiter-container",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});if(r.setAttribute("contenteditable","true"),r.setAttribute("tabindex","0"),"stars"===i.variant){const e=l.createStyledElement("div","clepit-delimiter",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});e.setAttribute("data-variant",i.variant),e.textContent="***",r.appendChild(e)}else{const e=l.createStyledElement("hr","clepit-delimiter",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});e.setAttribute("data-variant",i.variant),r.appendChild(e)}return e.addEventListener(t,r,"keydown",e=>{const n=e,a=r.closest(`.${l.classNames.block.container}`);if(!a)return;const o=_s.getBlockIndex(t,a.getAttribute("data-id")),i=n.metaKey||n.ctrlKey;if(n.shiftKey)switch(n.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),o>0&&_s.moveBlock(t,o,o-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const n=_s.getBlocks(t);n&&o<n.length-1&&_s.moveBlock(t,o,o+1)}else if(i)switch(n.key){case"Delete":case"Backspace":e.preventDefault(),e.stopPropagation(),_s.removeBlock(t,o)}else if("Enter"===n.key)n.preventDefault(),n.stopPropagation(),_s.insertBlock({data:{html:""},type:"paragraph"},t,o+1);else if("Backspace"===n.key)n.preventDefault(),n.stopPropagation(),_s.removeBlock(t,o);else{_s.ensureActiveBlock(t);const a=_s.getBlocks(t);switch(n.key){case"ArrowUp":if(e.preventDefault(),e.stopPropagation(),o>0){const e=a[o-1];e&&_s.focusBlock(e)}return;case"ArrowDown":if(e.preventDefault(),e.stopPropagation(),o<a.length-1){const e=a[o+1];e&&_s.focusBlock(e)}return}}}),r.focus(),r}static changeVariant(t,n,a){const o=C.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-variant")===n)return;const i={variant:n},r={classNames:o.config.classNames?.blocks?.delimiter,styles:o.config.styles?.blocks?.delimiter},s=_s.getBlockIndex(a,t.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id")),c=e.render(a,i,r);t.replaceWith(c),C.getState().updateBlockData(a,s,i)}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},dn=class e{static render(t,n,a,o){if(l.injectStyles("clepit-delimiter-output-styles",ln),!e.validate(t))return X();if(cn.isEmptyData(t))return document.createElement("div");const i=t.variant,r=l.createStyledElement("div","clepit-output-delimiter",{classNames:o?.[i],styles:a?.[i]});if("stars"===i)r.innerHTML="***",r.setAttribute("data-variant","stars");else{const e=document.createElement("hr");e.setAttribute("data-variant","line"),e.className="clepit-delimiter",r.appendChild(e)}return r}static draw(t,n=R){if(!e.validate(t)||cn.isEmptyData(t))return null;const a=n.create("div");if(a.addClass("clepit-output-delimiter"),"stars"===t.variant)return a.setHtml("***"),a.setAttribute("data-variant","stars"),a;const o=n.create("hr");return o.setAttribute("data-variant","line"),o.addClass("clepit-delimiter"),a.append(o),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.variant}},pn="\n.clepit-doc-card {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n cursor: pointer;\n color: inherit;\n text-decoration: none;\n}\n.clepit-doc-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-doc-card__icon {\n font-size: 20px;\n line-height: 1;\n}\n.clepit-doc-card__title {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-doc-card__description {\n opacity: 0.7;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n",un=pn,hn=pn,mn=class e{static render(t,n,a,o){if(l.injectStyles("doc-card-output",hn),!e.validate(t))return X();const i=l.createStyledElement("a","clepit-doc-card clepit-output-doc-card",{classNames:o?.card,styles:a?.card});i.setAttribute("data-page-id",t.pageId),n?.docHref&&(i.href=n.docHref(t.pageId));const r=document.createElement("span");r.className="clepit-doc-card__icon",r.textContent=t.icon??"📄",i.appendChild(r);const s=document.createElement("span"),c=document.createElement("span");if(c.className="clepit-doc-card__title",c.textContent=t.title||"Untitled",s.appendChild(c),t.description){const e=document.createElement("span");e.className="clepit-doc-card__description",e.textContent=t.description,s.appendChild(e)}return i.appendChild(s),i}static draw(t,n=R,a){if(!e.validate(t))return null;const o=n.create("a");o.addClass("clepit-doc-card","clepit-output-doc-card"),o.setAttribute("data-page-id",t.pageId),a?.docHref&&o.setAttribute("href",a.docHref(t.pageId));const i=n.create("span");i.addClass("clepit-doc-card__icon"),i.setText(t.icon??"📄"),o.append(i);const r=n.create("span"),s=n.create("span");if(s.addClass("clepit-doc-card__title"),s.setText(t.title||"Untitled"),r.append(s),t.description){const e=n.create("span");e.addClass("clepit-doc-card__description"),e.setText(t.description),r.append(e)}return o.append(r),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.pageId&&e.pageId.length>0&&"string"==typeof e.title}},gn="\n.clepit-file {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n color: inherit;\n text-decoration: none;\n}\n.clepit-file:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-file__name {\n font-weight: 500;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-file__size {\n opacity: 0.6;\n font-size: 12px;\n}\n",bn=`${gn}\n.clepit-file__upload {\n border: 1px dashed rgba(127, 127, 127, 0.5);\n background: transparent;\n cursor: pointer;\n font: inherit;\n padding: 10px 12px;\n border-radius: 8px;\n}\n`,fn=gn;function vn(e){return null==e?"":e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}var yn=class e{static render(t,n,a,o){if(l.injectStyles("file-output",fn),!e.validate(t))return X();const i=l.createStyledElement("a","clepit-file clepit-output-file",{classNames:o?.row,styles:a?.row});i.href=t.url,i.setAttribute("download",t.name),i.setAttribute("rel","noopener noreferrer");const r=document.createElement("span");r.className="clepit-file__name",r.textContent=t.name,i.appendChild(r);const s=vn(t.size);if(s){const e=document.createElement("span");e.className="clepit-file__size",e.textContent=s,i.appendChild(e)}return i}static draw(t,n=R){if(!e.validate(t))return null;const a=n.create("a");a.addClass("clepit-file","clepit-output-file"),a.setAttribute("href",t.url),a.setAttribute("download",t.name),a.setAttribute("rel","noopener noreferrer");const o=n.create("span");o.addClass("clepit-file__name"),o.setText(t.name),a.append(o);const i=vn(t.size);if(i){const e=n.create("span");e.addClass("clepit-file__size"),e.setText(i),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&("string"==typeof e.url&&0!==e.url.length&&("string"==typeof e.name&&0!==e.name.length&&/^https?:\/\//i.test(e.url)))}},xn='\n.clepit-glance {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n padding: 12px 14px;\n}\n\n/* A variant tints the surface only. Text keeps the reading colours the rest of\n * the page uses, so a glance stays as legible as the prose around it. */\n.clepit-glance[data-variant="info"] {\n background: var(--clepit-primary-bg);\n}\n\n.clepit-glance[data-variant="success"] {\n background: var(--clepit-success-bg);\n}\n\n.clepit-glance[data-variant="warning"] {\n background: var(--clepit-warning-bg);\n}\n\n.clepit-glance[data-variant="error"] {\n background: var(--clepit-error-bg);\n}\n\n.clepit-glance-caption {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 0 0 8px;\n text-transform: uppercase;\n}\n\n/* Labels form a single vertical rail whatever their length, so the reader scans\n * one column for the question and one for the answer. */\n.clepit-glance-rows {\n column-gap: 16px;\n display: grid;\n grid-template-columns: max-content 1fr;\n margin: 0;\n row-gap: 4px;\n}\n\n.clepit-glance-label {\n color: var(--clepit-text-subtle);\n font-size: 14px;\n}\n\n.clepit-glance-value {\n color: var(--clepit-text);\n font-size: 14px;\n margin: 0;\n}\n\n.clepit-glance-value code {\n background: var(--clepit-code-bg);\n border-radius: 4px;\n font-family: \'SF Mono\', \'Monaco\', \'Roboto Mono\', monospace;\n font-size: 13px;\n padding: 1px 5px;\n}\n\n.clepit-glance-value a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-glance-value a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* A single-column stack below the narrowest tablet: a max-content label column\n * squeezes the value to a few characters once the viewport is phone width. */\n@media (max-width: 600px) {\n .clepit-glance-rows {\n grid-template-columns: 1fr;\n row-gap: 2px;\n }\n\n .clepit-glance-value {\n margin: 0 0 6px;\n }\n}\n',kn="At a glance",wn=class e{static render(t,n,a,o){if(l.injectStyles("clepit-glance-output-styles",xn),!e.validate(t))return X();if(0===t.rows.length)return document.createElement("div");const i=l.createStyledElement("div","clepit-glance",{classNames:o?.wrapper,styles:a?.wrapper});i.setAttribute("data-variant",t.variant??"plain"),i.setAttribute("data-testid","glance");const r=p("p","clepit-glance-caption");r.textContent=t.caption?.trim()?t.caption:kn,i.appendChild(r);const s=p("dl","clepit-glance-rows");for(const e of t.rows){const t=p("dt","clepit-glance-label");t.textContent=e.label,s.appendChild(t);const n=p("dd","clepit-glance-value");n.innerHTML=m(e.html),s.appendChild(n)}return i.appendChild(s),i}static draw(t,n=R){if(!e.validate(t)||0===t.rows.length)return null;const a=n.create("div");a.addClass("clepit-glance"),a.setAttribute("data-variant",t.variant??"plain"),a.setAttribute("data-testid","glance");const o=n.create("p");o.addClass("clepit-glance-caption"),o.setText(t.caption?.trim()?t.caption:kn),a.append(o);const i=n.create("dl");i.addClass("clepit-glance-rows");for(const e of t.rows){const t=n.create("dt");t.addClass("clepit-glance-label"),t.setText(e.label),i.append(t);const a=n.create("dd");a.addClass("clepit-glance-value"),a.setHtml(e.html),i.append(a)}return a.append(i),a}static validate(e){return null!=e&&"object"==typeof e&&(!!Array.isArray(e.rows)&&e.rows.every(e=>null!==e&&"object"==typeof e&&"string"==typeof e.label&&"string"==typeof e.html))}},Cn="\n/* Output header styles */\n.clepit-output-header {\n margin: 0 0 1rem 0;\n font-weight: 600;\n color: var(--clepit-text);\n}\n\nh1.clepit-output-header {\n font-size: 2.5rem;\n line-height: 1.2;\n}\n\nh2.clepit-output-header {\n font-size: 2rem;\n line-height: 1.3;\n}\n\nh3.clepit-output-header {\n font-size: 1.75rem;\n line-height: 1.4;\n}\n\nh4.clepit-output-header {\n font-size: 1.5rem;\n line-height: 1.4;\n}\n\nh5.clepit-output-header {\n font-size: 1.25rem;\n line-height: 1.4;\n}\n\nh6.clepit-output-header {\n font-size: 1rem;\n line-height: 1.4;\n}\n\n/* Output header inline code styling */\n.clepit-output-header code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n/* Output header marker brush effect */\n.clepit-output-header mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-header mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Output header link styles */\n.clepit-output-header a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-header a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Responsive Design */\n@media (max-width: 768px) {\n h1.clepit-output-header {\n font-size: 2rem;\n }\n\n h2.clepit-output-header {\n font-size: 1.75rem;\n }\n\n h3.clepit-output-header {\n font-size: 1.5rem;\n }\n}\n",An=class e{static{this.placeholder="Enter heading..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${l.classNames.block.header}`),n=t?.getAttribute("data-level")||"h1";return{html:m(t?.innerHTML),level:n}}static render(t,n,a){l.injectStyles("clepit-header-input-styles",'\n/* Header block styles */\n.clepit-header {\n outline: none;\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 20px;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content {\n font-weight: bold;\n margin: 16px 0 8px 0;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h1 {\n font-size: 32px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h2 {\n font-size: 24px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h3 {\n font-size: 20px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h4 {\n font-size: 18px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h5 {\n font-size: 16px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h6 {\n font-size: 14px;\n margin: 0;\n color: inherit;\n}\n\n/* Header placeholder styles */\n.clepit-header[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Header link styles */\n.clepit-header a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-header a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Header inline code styling */\n.clepit-header code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Header marker brush effect */\n.clepit-header mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-header mark::before {\n content: \'\';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 100 20\' preserveAspectRatio=\'none\'><path d=\'M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z\' fill=\'%23FFE047\'/></svg>") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark\'s stacking context */\n}\n\n');const o={html:"",level:"h1"},i=n?{...o,...n}:o,r=i.level??"h1",s=l.createStyledElement(r,l.classNames.block.header,{classNames:a?.classNames?.[r],styles:a?.styles?.[r]});return s.setAttribute("data-level",r),s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",ne(t,"headerHint",e.placeholder)),s.innerHTML=m(i.html),e.addEventListener(t,s,"keydown",_s.handleKeydown),e.addEventListener(t,s,"input",_s.handleInput),s}static changeLevel(t,n,a){const o=C.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-level")===n)return;const i={html:t.innerHTML,level:n},r={classNames:o.config.classNames?.blocks?.header,margins:o.config.margins,styles:o.config.styles?.blocks?.header},s=_s.getBlockIndex(a,t.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id")),c=e.render(a,i,r);t.replaceWith(c),C.getState().updateBlockData(a,s,i)}static isEmpty(e){return h(e.querySelector(`.${l.classNames.block.header}`)?.innerHTML)}static isEmptyData(e){return h(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Sn=class e{static render(t,n,a,o){if(l.injectStyles("clepit-header-output-styles",Cn),!e.validate(t))return X();if(An.isEmptyData(t))return document.createElement("div");const i=t.level||"h1",r=l.createStyledElement(i,"clepit-output-header",{classNames:o?.[i],styles:a?.[i]});return r.innerHTML=m(t.html),r}static draw(t,n=R){if(!e.validate(t)||An.isEmptyData(t))return null;const a=n.create(t.level||"h1");return a.addClass("clepit-output-header"),t.html&&a.setHtml(t.html),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},En=`\n/* Image block styles */\n.${l.classNames.block.image.container} {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-image-caption {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool="image"] .clepit-block-content {\n text-align: center;\n}\n\n.clepit-block[data-tool="image"] .clepit-block-content img {\n max-width: 100%;\n height: auto;\n border-radius: 4px;\n}\n\n/* Image Block Enhanced Styles */\n.${l.classNames.block.image.container} {\n margin: 16px 0;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 100%;\n box-sizing: border-box;\n}\n\n.${l.classNames.block.image.wrapper} {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.${l.classNames.block.image.wrapper}:hover {\n opacity: 0.9;\n}\n\n.clepit-image {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n display: block;\n}\n\n.clepit-image-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-image-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-image-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-image-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Image caption styling */\n.clepit-image-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Image caption placeholder styles */\n.clepit-image-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Image Drop Area */\n.${l.classNames.block.image.dropArea} {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n min-height: 120px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n}\n\n.${l.classNames.block.image.dropArea}:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-image-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-image-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-image-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n margin-bottom: 8px;\n}\n\n.clepit-image-drop-subtext {\n font-size: 14px;\n color: var(--clepit-text-subtle);\n line-height: 1.4;\n}\n\n.clepit-image-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Image Loading State */\n.clepit-image-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-image-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-image-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Image Error State */\n.clepit-image-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-image-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-image-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-image-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-image-error-retry:hover {\n background: var(--clepit-error);\n}\n\n.clepit-image-refusal {\n display: flex;\n flex-direction: column;\n gap: 6px;\n align-items: center;\n margin: 16px 0;\n padding: 14px 12px;\n text-align: center;\n border: 1px dashed var(--clepit-border);\n border-radius: 8px;\n}\n\n.clepit-image-refusal-title {\n font-size: 14.5px;\n font-weight: 600;\n color: var(--clepit-text);\n}\n\n.clepit-image-refusal-body {\n max-width: 44ch;\n font-size: 13px;\n line-height: 1.5;\n color: var(--clepit-text-muted);\n}\n\n.clepit-image-refusal-actions {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n justify-content: center;\n}\n\n.clepit-image-refusal-action {\n display: inline-flex;\n align-items: center;\n height: 26px;\n padding: 0 10px;\n font-size: 12px;\n font-weight: 550;\n color: var(--clepit-bg);\n white-space: nowrap;\n text-decoration: none;\n background: var(--clepit-primary);\n border-radius: 6px;\n}\n\n.clepit-image-refusal-action:hover {\n background: var(--clepit-primary-hover);\n}\n\n.clepit-image-refusal-remove {\n display: inline-flex;\n align-items: center;\n height: 28px;\n padding: 0 10px;\n font: inherit;\n font-size: 13px;\n font-weight: 550;\n color: var(--clepit-text);\n white-space: nowrap;\n background: none;\n border: 0;\n border-radius: 6px;\n cursor: pointer;\n}\n\n.clepit-image-refusal-remove:hover {\n background: var(--clepit-block-highlight-bg);\n}\n\n/* Image delete button */\n.${l.classNames.block.imageDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${l.classNames.block.imageDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Image drop area delete button */\n.clepit-image-drop-area .${l.classNames.block.imageDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-image-drop-area .${l.classNames.block.imageDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,Ln="\n/* Output image styles */\n.clepit-output-image-container {\n margin: 1rem 0;\n text-align: center;\n}\n\n.clepit-output-image {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n}\n\n.clepit-output-image-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Image wrapper positioning */\n.clepit-image-wrapper {\n position: relative;\n cursor: pointer;\n display: flex;\n margin-bottom: 10px;\n}\n.clepit-output-image-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-output-image-wrapper--center {\n justify-content: center;\n}\n\n.clepit-output-image-wrapper--right {\n justify-content: flex-end;\n}\n",Nn=class extends Error{constructor(e){super(e.title),this.notice=e,this.name="UploadRefusal"}},Bn=class e{static{this.placeholder="Add a caption..."}static{this.validTypes=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/ico","image/x-icon","image/avif","image/heic"]}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("img"),n=e.querySelector(`.${l.classNames.block.image.captionEditable}`),a=e.querySelector(".clepit-image-wrapper");let o="center";return a&&(o=a.classList.contains("clepit-image-wrapper--left")?"left":a.classList.contains("clepit-image-wrapper--right")?"right":"center"),{alignment:o,alt:t?.getAttribute("alt")||"",caption:m(n?.innerHTML),url:t?.getAttribute("src")||""}}static render(t,n,a,o){l.injectStyles("clepit-image-input-styles",En);const i={alt:"",caption:"",url:""},r=a?{...i,...a}:i,s=l.createStyledElement("div",l.classNames.block.image.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return r.url?e.renderImage(s,r,t,n,o):e.renderDropArea(s,t,n,o),s}static renderImage(t,n,a,o,i){t.innerHTML="";const r=l.createStyledElement("div",l.classNames.block.image.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("clepit-image-wrapper--left");break;case"center":r.classList.add("clepit-image-wrapper--center");break;case"right":r.classList.add("clepit-image-wrapper--right")}const s=l.createStyledElement("img","clepit-image",{classNames:i?.classNames?.container,styles:i?.styles?.container});s.alt=n?.alt||"",s.src=n?.url||"",s.classList.add("clepit-image");const c=l.createStyledElement("div","clepit-image-caption-container",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});c.classList.add("clepit-image-caption-container");const d=l.createStyledElement("div",l.classNames.block.image.captionEditable,{classNames:i?.classNames?.caption,styles:i?.styles?.caption});d.setAttribute("contenteditable","true"),d.setAttribute("data-placeholder",ne(o,"mediaCaptionHint",e.placeholder)),d.innerHTML=m(n?.caption),e.addEventListener(o,d,"keydown",_s.handleKeydown),e.addEventListener(o,d,"input",_s.handleInput),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),r.appendChild(s),c.appendChild(d),t.appendChild(r),t.appendChild(c),d.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const i=l.createStyledElement("div",l.classNames.block.image.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});i.setAttribute("tabindex","0"),i.setAttribute("data-testid","image-drop"),i.classList.add("clepit-drop-area");const r=l.createStyledElement("div","clepit-image-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});r.textContent="📷";const s=l.createStyledElement("div","clepit-image-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text}),c=document.createElement("strong");c.setAttribute("data-testid","image-drop-title"),c.textContent=ne(a,"imageDropTitle","Drop an image here");const d=document.createElement("span");d.className="clepit-image-click-text",d.setAttribute("data-testid","image-drop-action"),d.textContent=ne(a,"imageDropAction","or click to select"),s.append(c,document.createElement("br"),d);const p=l.createStyledElement("div","clepit-image-drop-subtext",{classNames:o?.classNames?.dropArea?.subtext,styles:o?.styles?.dropArea?.subtext});p.setAttribute("data-testid","image-drop-formats"),p.textContent=ne(a,"imageDropFormats","Supports JPEG, PNG, GIF, WebP, SVG, and other image formats");const u=l.createStyledElement("button",`${l.classNames.block.imageDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});u.type="button",u.textContent="✕",u.setAttribute("data-testid","image-drop-delete");const h=ne(a,"delete","Delete block");u.setAttribute("aria-label",h),i.appendChild(r),i.appendChild(s),i.appendChild(p),i.appendChild(u);const m=C.getState().getInstance(a),g=m?.config.classNames?.tooltips,b=m?.config.styles?.tooltips;ye(u,h,"below",g,b),e.addEventListener(a,u,"click",e=>{e.preventDefault(),e.stopPropagation();const t=u.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");t&&_s.removeBlock(a,_s.getBlockIndex(a,t))}),e.addEventListener(a,i,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,i,"dragleave",()=>{i.classList.remove("clepit-image-drop-area--dragover")}),e.addEventListener(a,i,"dragover",e=>{e.preventDefault(),e.stopPropagation(),i.classList.add("clepit-image-drop-area--dragover")}),e.addEventListener(a,i,"drop",r=>{r.preventDefault(),r.stopPropagation(),i.classList.remove("clepit-image-drop-area--dragover"),e.handleFileDrop(r,t,n,a,o)}),e.addEventListener(a,i,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,i,"mousedown",e=>{e.preventDefault(),e.stopPropagation()}),t.appendChild(i)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidImageFile(t)?e.processImageFile(t,n,a,o,i):e.showInvalidType(n,o)}}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="image/*",i.classList.add("clepit-hidden-input"),i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidImageFile(i)?e.processImageFile(i,t,n,a,o):e.showInvalidType(t,a)}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static isValidImageFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("image/")}static async processImageFile(t,n,a,o,i){e.showLoading(n,ne(o,"imageUploading","Uploading image..."));try{let r=await a(t);if(r){e.renderImage(n,{alignment:"center",alt:t.name,caption:"",url:r},a,o,i);const s=n.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");s&&C.getState().updateBlockData(o,_s.getBlockIndex(o,s),_s.getBlockData(s).data)}else e.showUploadFailed(n,o)}catch(r){if(r instanceof Nn)return void e.showRefusal(n,o,r.notice);console.error("Image upload error:",r),e.showUploadFailed(n,o)}}static showRefusal(t,n,a){t.innerHTML="";const o=l.createStyledElement("div","clepit-image-refusal",void 0);o.setAttribute("data-testid","image-refusal"),o.setAttribute("role","status");const i=document.createElement("span");i.className="clepit-image-refusal-title",i.setAttribute("data-testid","image-refusal-title"),i.textContent=a.title;const r=document.createElement("span");r.className="clepit-image-refusal-body",r.setAttribute("data-testid","image-refusal-body"),r.textContent=a.body;const s=document.createElement("span");if(s.className="clepit-image-refusal-actions",a.action&&/^https?:\/\//i.test(a.action.href)){const e=document.createElement("a");e.className="clepit-image-refusal-action",e.setAttribute("data-testid","image-refusal-action"),e.setAttribute("href",a.action.href),e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer"),e.textContent=a.action.label,s.appendChild(e)}const c=document.createElement("button");c.type="button",c.className="clepit-image-refusal-remove",c.setAttribute("data-testid","image-refusal-remove"),c.textContent=a.remove,e.addEventListener(n,c,"click",e=>{e.preventDefault(),e.stopPropagation();const t=c.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");t&&_s.removeBlock(n,_s.getBlockIndex(n,t))}),s.appendChild(c),o.append(i,r,s),t.appendChild(o)}static showLoading(e,t){e.innerHTML="";const n=l.createStyledElement("div","clepit-image-loading",void 0);n.setAttribute("data-testid","image-uploading"),n.textContent=t,e.appendChild(n)}static showUploadFailed(t,n){e.showError(t,ne(n,"imageUploadFailed","Failed to upload image. Please try again."),"image-upload-failed")}static showInvalidType(t,n){e.showError(t,ne(n,"imageInvalidType","Please select a valid image file (JPEG, PNG, GIF, WebP, SVG, BMP, TIFF, ICO, AVIF, HEIC, JXL, and more)"),"image-invalid-type")}static showError(e,t,n){e.innerHTML="";const a=l.createStyledElement("div","clepit-image-error",void 0);a.setAttribute("data-testid",n),a.textContent=t,e.appendChild(a)}static setAlignment(e,t){const n=e.querySelector(".clepit-image-wrapper");n&&(n.classList.remove("clepit-image-wrapper--left","clepit-image-wrapper--center","clepit-image-wrapper--right"),n.classList.add(`clepit-image-wrapper--${t}`));const a=_s.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&C.getState().partialUpdateBlockData(a,_s.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${l.classNames.block.image.wrapper} img`),n=e.querySelector(`.${l.classNames.block.image.captionEditable}`);let a=!1,o=!1;return t&&t.getAttribute("src")?.trim()||(a=!0),n?h(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return!e.url?.trim()&&h(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},$n=class e{static render(t,n,a,o){if(l.injectStyles("clepit-image-output-styles",Ln),!e.validate(t))return X();if(Bn.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alt||r||"",c=l.createStyledElement("div","clepit-output-image-container",{classNames:o?.container,styles:a?.container}),d=l.createStyledElement("div","clepit-output-image-wrapper");if(t.alignment)switch(t.alignment){case"left":d.classList.add("clepit-output-image-wrapper--left");break;case"center":d.classList.add("clepit-output-image-wrapper--center");break;case"right":d.classList.add("clepit-output-image-wrapper--right")}const u=p("img","clepit-output-image");if(u.src=i,u.alt=s,d.appendChild(u),c.appendChild(d),r){const e=l.createStyledElement("figcaption","clepit-output-image-caption",{classNames:o?.caption,styles:a?.caption});e.innerHTML=m(r),c.appendChild(e)}return c}static draw(t,n=R){if(!e.validate(t)||Bn.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-image-container");const o=n.create("div");o.addClass("clepit-output-image-wrapper");const i=t.alignment??"";i&&o.addClass(`clepit-output-image-wrapper--${i}`);const r=n.create("img");if(r.addClass("clepit-output-image"),r.setAttribute("src",t.url),r.setAttribute("alt",t.alt||t.caption||""),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-image-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},Mn=Se,In=Se,Tn=(e,t)=>{if("string"!=typeof e){if(Array.isArray(e))for(const n of e)Tn(n,t);else if(e&&"object"==typeof e){const n=e;if("embed"===n.type&&n.data&&"object"==typeof n.data){const e=n.data;e.issue&&"object"==typeof e.issue&&t.push({...e.issue,url:e.issue.url||e.url||""})}for(const e of Object.values(n))Tn(e,t)}}else e.includes("clepit-issue")&&t.push(...Ve(e))},_n=class e{static collect(e,t){const n=[];Tn(e??[],n);const a=/* @__PURE__ */new Set,o=[];for(const i of n)i.url&&!a.has(i.url)&&(a.add(i.url),o.push(t?.[i.url]?{...t[i.url],url:i.url}:i));return o}static render(t,n,a,o){l.injectStyles("issues-output",In);const i=e.collect(n?.documentBlocks,n?.issues);if(0===i.length){const e=l.createStyledElement("div","clepit-issues__empty clepit-output-issues",{classNames:o,styles:a});return e.setAttribute("data-testid","issues-empty"),e.textContent=Be(n?.issueLabels,"linkedIssuesEmpty"),e}const r=J(e.table(i,R,n?.issueLabels));return l.applyStyling(r,{classNames:o,styles:a}),r}static draw(t,n=R,a){if(null==t||"object"!=typeof t)return null;const o=e.collect(a?.documentBlocks,a?.issues);return 0===o.length?null:e.table(o,n,a?.issueLabels)}static table(e,t,n){const a=t.create("table");a.addClass("clepit-issues","clepit-output-issues"),a.setAttribute("data-testid","issues-table");const o=t.create("thead"),i=t.create("tr");for(const s of["columnIssue","columnTitle","columnStatus","columnAssignee"]){const e=t.create("th");e.setText(Be(n,s)),i.append(e)}o.append(i),a.append(o);const r=t.create("tbody");for(const s of e){const e=t.create("tr");e.setAttribute("data-testid","issues-row"),e.setAttribute("data-issue-url",s.url);const a=t.create("td"),o=t.create("a");d(s.url)&&o.setAttribute("href",s.url),o.setAttribute("rel","noopener noreferrer nofollow"),o.setAttribute("target","_blank"),o.setText(s.key||s.title||s.url),a.append(o),e.append(a);const i=t.create("td");i.setText(s.key?s.title:""),e.append(i);const l=t.create("td");if(!s.reason){const e=t.create("span");e.addClass("clepit-issue__state"),e.setAttribute("data-issue-category",s.category),e.setText(ze(s,n)),l.append(e)}e.append(l);const c=t.create("td");c.setText(s.reason?"":s.assigneeName||Be(n,"unassigned")),e.append(c),r.append(e)}return a.append(r),a}},qn="\n/* Output list styles */\n.clepit-output-list {\n margin: 0 0 1rem 0;\n padding-left: 2rem;\n}\n\n.clepit-output-list-item {\n margin: 0.5rem 0;\n line-height: 1.6;\n}\n\n/* Output list link styles */\n.clepit-output-list a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-list a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output list inline code styling */\n.clepit-output-list li code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n/* Output list marker brush effect */\n.clepit-output-list li mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-list li mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Responsive Design */\n@media (max-width: 768px) {\n .clepit-output-list {\n padding-left: 1.5rem;\n }\n}\n",Dn=class e{static{this.placeholder="Enter list item..."}static{this.defaultType="unordered"}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(t){const n=t.getAttribute("data-type")||e.defaultType,a=[];return t.querySelectorAll("li").forEach(e=>a.push(m(e.innerHTML))),{items:a,type:n}}static render(t,n,a){l.injectStyles("clepit-list-input-styles","\n/* List block styles */\n.clepit-list {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 16px;\n}\n\n.clepit-list-item {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content {\n padding-left: 40px;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content ul,\n.clepit-block[data-tool=\"list\"] .clepit-block-content ol {\n margin: 0;\n padding-left: 20px;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content li {\n margin: 4px 0;\n}\n\n/* List item placeholder styles */\n.clepit-list-item[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* List item link styles */\n.clepit-list-item a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-list-item a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* List item inline code styling */\n.clepit-list-item code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* List item marker brush effect */\n.clepit-list-item mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-list-item mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o={items:[],type:e.defaultType},i=n?{...o,...n}:o,r="ordered"===i.type?"ol":"ul",s=l.createStyledElement(r,l.classNames.block.list.container,{classNames:a?.classNames?.[i.type]?.container,styles:a?.styles?.[i.type]?.container});s.setAttribute("data-type",i.type);const c=a?.classNames?.[i.type]?.item,d=a?.styles?.[i.type]?.item;return i.items.length>0?i.items.forEach(n=>e.createAndAppendListItem(n,s,t,c,d)):e.createAndAppendListItem("",s,t,c,d),s}static createAndAppendListItem(t,n,a,o,i){const r=l.createStyledElement("li",l.classNames.block.list.item,{classNames:o,styles:i});r.innerHTML=m(t),r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",ne(a,"listItemHint",e.placeholder)),e.addEventListener(a,r,"keydown",t=>{const s=t,c=n.closest(`.${l.classNames.block.container}`);if(!c)return;const d=_s.getBlockIndex(a,c.getAttribute("data-id")),p=s.metaKey||s.ctrlKey;if(s.shiftKey)switch(s.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),d>0&&_s.moveBlock(a,d,d-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const e=_s.getBlocks(a);e&&d<e.length-1&&_s.moveBlock(a,d,d+1)}else if(p)switch(s.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),_s.removeBlock(a,d)}else if("Enter"===s.key)if(t.preventDefault(),t.stopPropagation(),h(r.innerHTML)){e.cleanupEmptyItems(n);const t=n.closest(`.${l.classNames.block.container}`);if(!t)return;const o=_s.getBlockIndex(a,t.getAttribute("data-id"));_s.insertBlock({data:{html:""},type:"paragraph"},a,o+1)}else e.createAndAppendListItem("",n,a,o,i);else if("Backspace"===s.key){if(h(r.innerHTML)){t.preventDefault(),t.stopPropagation();const e=Array.from(n.querySelectorAll("li")),o=e.indexOf(r);if(1===e.length){const e=n.closest(`.${l.classNames.block.container}`);if(!e)return;const t=_s.getBlockIndex(a,e.getAttribute("data-id"));if(-1===t)return;_s.removeBlock(a,t)}else r.remove(),o>0?e[o-1].focus():e[o+1].focus()}}else{_s.ensureActiveBlock(a);const e=_s.getBlocks(a);switch(s.key){case"ArrowUp":t.preventDefault(),t.stopPropagation();const a=Array.from(n.querySelectorAll(`.${l.classNames.block.list.item}`)),o=a.indexOf(r);if(0===o){if(d>0){const t=e[d-1];t&&_s.focusBlock(t)}}else{const e=a[o-1];e&&e.focus()}return;case"ArrowDown":t.preventDefault(),t.stopPropagation();const i=Array.from(n.querySelectorAll(`.${l.classNames.block.list.item}`)),s=i.indexOf(r);if(s===i.length-1){if(d<e.length-1){const t=e[d+1];t&&_s.focusBlock(t)}}else{const e=i[s+1];e&&e.focus()}return}}}),e.addEventListener(a,r,"input",_s.handleInput),n.appendChild(r),r.focus()}static changeType(t,n,a){const o=C.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-type")===n)return;const i={items:[...t.querySelectorAll("li")||[]].map(e=>e.innerHTML),type:n},r={classNames:o.config.classNames?.blocks?.list,styles:o.config.styles?.blocks?.list},s=_s.getBlockIndex(a,t.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id")),c=e.render(a,i,r);t.replaceWith(c),C.getState().updateBlockData(a,s,i)}static cleanupEmptyItems(e){const t=Array.from(e.querySelectorAll("li")),n=t.filter(e=>h(e.innerHTML));if(t.length===n.length){if(t.length<2)return;for(let e=1;e<n.length;e++)n[e].remove()}else n.forEach(e=>e.remove())}static isEmpty(e){const t=e.querySelectorAll(`.${l.classNames.block.list.item}`);return!t||Array.from(t).every(e=>h(e.innerHTML))}static isEmptyData(e){return 0===e.items.length||e.items.every(e=>h(e))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},zn=class e{static render(t,n,a,o){if(l.injectStyles("clepit-list-output-styles",qn),!e.validate(t))return X();if(Dn.isEmptyData(t))return document.createElement("div");const i=t.items,r="ordered"===t.type?"ordered":"unordered",s=l.createStyledElement("ordered"===r?"ol":"ul","clepit-output-list",{classNames:o?.[r]?.container,styles:a?.[r]?.container});return i.forEach((e,t)=>{const n=l.createStyledElement("li","clepit-output-list-item",{classNames:o?.[r]?.item,styles:a?.[r]?.item});n.innerHTML=m(e),s.appendChild(n)}),s}static draw(t,n=R){if(!e.validate(t)||Dn.isEmptyData(t))return null;const a="ordered"===t.type,o=n.create(a?"ol":"ul");o.addClass("clepit-output-list");for(const e of t.items){const t=n.create("li");t.addClass("clepit-output-list-item"),e?.trim()&&t.setHtml(e),o.append(t)}return o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.items)&&"string"==typeof e.type}},jn="\n.clepit-openapi {\n display: flex;\n flex-direction: column;\n gap: 40px;\n margin: 16px 0;\n}\n\n/* Groups and operations are separated by rhythm, never by rules — the same\n * house style the tables follow. */\n.clepit-openapi-group {\n display: flex;\n flex-direction: column;\n gap: 14px;\n}\n\n/* An eyebrow label rather than a heading, matching the uppercase group headings\n * in the docs sidebar so the reference echoes the nav. */\n.clepit-openapi-group-title {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 0;\n text-transform: uppercase;\n}\n\n.clepit-openapi-operation {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n\n/* The head is a tinted strip so an operation reads as one bounded unit in a\n * page of a dozen. */\n.clepit-openapi-operation-head {\n align-items: center;\n background: color-mix(in oklab, var(--clepit-text) 4%, transparent);\n border-bottom: 1px solid var(--clepit-border);\n display: flex;\n flex-wrap: wrap;\n gap: 10px;\n padding: 10px 14px;\n}\n\n.clepit-openapi-operation-body {\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 14px;\n}\n\n.clepit-openapi-method {\n border-radius: 4px;\n color: var(--clepit-bg);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.04em;\n padding: 3px 8px;\n}\n\n.clepit-openapi-method[data-method=\"GET\"] { background: var(--clepit-success); }\n.clepit-openapi-method[data-method=\"POST\"],\n.clepit-openapi-method[data-method=\"PUT\"],\n.clepit-openapi-method[data-method=\"PATCH\"] { background: var(--clepit-primary); }\n.clepit-openapi-method[data-method=\"DELETE\"] { background: var(--clepit-error); }\n\n.clepit-openapi-path {\n color: var(--clepit-text);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 14px;\n}\n\n.clepit-openapi-host {\n color: var(--clepit-text-subtle);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 12px;\n margin-left: auto;\n}\n\n.clepit-openapi-summary {\n color: var(--clepit-text);\n font-size: 16px;\n font-weight: 600;\n margin: 0;\n}\n\n.clepit-openapi-description {\n color: var(--clepit-text-muted);\n margin: 0;\n}\n\n.clepit-openapi-section-title {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 4px 0 0;\n text-transform: uppercase;\n}\n\n/* A table has no scroll surface of its own — a cell the house style cannot\n * break (a long host URL) would otherwise force the table, and every ancestor\n * up to the page itself, wider than the viewport. */\n.clepit-openapi-table-scroll {\n max-width: 100%;\n overflow-x: auto;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n}\n\n.clepit-openapi-table {\n border-collapse: collapse;\n font-size: 14px;\n width: 100%;\n}\n\n.clepit-openapi-table th {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n color: var(--clepit-text-subtle);\n font-weight: 600;\n padding: 6px 8px;\n text-align: left;\n}\n\n/* House style: no horizontal dividers between rows. Zebra striping is what\n * separates them instead. */\n.clepit-openapi-table td {\n color: var(--clepit-text);\n padding: 7px 8px;\n vertical-align: top;\n}\n\n.clepit-openapi-table tr:nth-child(even) td {\n background: var(--clepit-surface);\n}\n\n.clepit-openapi-name {\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n overflow-wrap: anywhere;\n}\n\n.clepit-openapi-type {\n color: var(--clepit-text-muted);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n}\n\n.clepit-openapi-required {\n color: var(--clepit-error);\n font-size: 12px;\n}\n\n.clepit-openapi-badge {\n background: var(--clepit-primary-bg);\n border-radius: 4px;\n color: var(--clepit-primary);\n font-size: 12px;\n padding: 2px 8px;\n}\n\n.clepit-openapi-status {\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-weight: 600;\n}\n\n.clepit-openapi-status[data-kind=\"success\"] { color: var(--clepit-success); }\n.clepit-openapi-status[data-kind=\"client\"] { color: var(--clepit-warning); }\n.clepit-openapi-status[data-kind=\"server\"] { color: var(--clepit-error); }\n\n/* One response at a time behind a status tab strip. */\n.clepit-openapi-responses {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.clepit-openapi-response-tabs {\n border-bottom: 1px solid var(--clepit-border);\n display: flex;\n flex-wrap: wrap;\n gap: 16px;\n margin-bottom: 4px;\n}\n\n.clepit-openapi-response-tab {\n background: none;\n border: 0;\n border-bottom: 2px solid transparent;\n color: var(--clepit-text-muted);\n cursor: pointer;\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 12px;\n margin-bottom: -1px;\n padding: 6px 0;\n}\n\n.clepit-openapi-response-tab[aria-selected=\"true\"] {\n border-bottom-color: var(--clepit-primary);\n color: var(--clepit-text);\n font-weight: 600;\n}\n\n.clepit-openapi-response-tab:focus-visible {\n outline: 2px solid var(--clepit-primary);\n outline-offset: 2px;\n}\n\n.clepit-openapi-response-description {\n color: var(--clepit-text-muted);\n margin: 0;\n}\n\n/* Tabs hide three quarters of the contract from a printed page, so print gets\n * every response expanded and the strip removed. */\n@media print {\n .clepit-openapi-response-tabs { display: none; }\n .clepit-openapi-response { display: block !important; }\n .clepit-openapi-response + .clepit-openapi-response { margin-top: 10px; }\n}\n\n.clepit-openapi-servers {\n color: var(--clepit-text-muted);\n font-size: 14px;\n margin: 0;\n}\n",Hn=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),On=(e,t)=>{const n={children:[],cyclic:!1,nullable:!1,required:!1,type:"unknown"};if(!Hn(e))return n;if("string"==typeof e.$ref){const o=(a=e.$ref).split("/").pop()??a;if(n.ref=o,t.stack.has(o))return n.cyclic=!0,n.type=o,n;const i=t.schemas[o];if(void 0===i)return n;t.stack.add(o);const r=On(i,t);return t.stack.delete(o),r.ref=o,r}var a;"string"==typeof e.description&&(n.description=e.description),"string"==typeof e.format&&(n.format=e.format),Array.isArray(e.enum)&&(n.enum=e.enum.map(e=>String(e)));const o=["allOf","anyOf","oneOf"].find(t=>Array.isArray(e[t]));if(o){const a=e[o].map(e=>On(e,t));if("allOf"===o){n.type="object";for(const e of a)n.children.push(...e.children);return n}const i=a.filter(e=>"null"!==e.type&&!("unknown"===e.type&&e.nullable));return(a.length!==i.length||a.some(e=>e.nullable))&&(n.nullable=!0),n.type=i.map(e=>e.ref??e.type).join(" | ")||"unknown",n.children.push(...i.flatMap(e=>e.children)),n}if(n.type=((e,t)=>{const n=e.type;if(Array.isArray(n)){const e=n.filter(e=>"string"==typeof e);return e.includes("null")&&(t.nullable=!0),e.find(e=>"null"!==e)??"unknown"}return"string"==typeof n?n:"unknown"})(e,n),"array"===n.type){const a=On(e.items,t);return n.type=`${a.ref??a.type}[]`,n.children.push(...a.children),n}return"object"===n.type&&((e,t,n)=>{if(!Hn(e.properties))return;const a=Array.isArray(e.required)?e.required.filter(e=>"string"==typeof e):[];for(const[o,i]of Object.entries(e.properties)){const e=On(i,n);e.name=o,e.required=a.includes(o),t.children.push(e)}})(e,n,t),n},Pn=(e,t)=>On(e,{schemas:t,stack:/* @__PURE__ */new Set}),Rn=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Fn=e=>{if(!Rn(e))return"string";const t=Array.isArray(e.type)?e.type.find(e=>"null"!==e):e.type;if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];switch(t){case"array":return[];case"boolean":return!0;case"integer":case"number":return 0;case"object":return{};default:return"string"}},Vn=e=>{if(!Rn(e)||!Rn(e.properties))return;const t={};for(const[n,a]of Object.entries(e.properties))t[n]=Fn(a);return t},Un=e=>e.security[0],Wn=(e,t)=>{return`${t}${n=e.path,n.replace(/\{([^}]+)\}/g,":$1")}`;var n},Kn={bash:{build:(e,t)=>{const n=[`curl -X ${e.method} "${Wn(e,t)}"`],a=Un(e);var o;a&&n.push(` -H "Authorization: Bearer $${o=a,o.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()}"`);const i=Vn(e.request);return i&&(n.push(' -H "Content-Type: application/json"'),n.push(` -d '${JSON.stringify(i)}'`)),n.join(" \\\n")},label:"cURL"},dart:{build:(e,t)=>{const n=Vn(e.request),a=e.method.toLowerCase(),o=[` Uri.parse('${Wn(e,t)}'),`],i=[],r=Un(e);return r&&i.push(` 'Authorization': 'Bearer $${r}',`),n&&i.push(" 'Content-Type': 'application/json',"),i.length>0&&o.push(" headers: {",...i," },"),n&&o.push(` body: jsonEncode(${JSON.stringify(n)}),`),[`final response = await http.${a}(`,...o,");"].join("\n")},label:"Dart"},python:{build:(e,t)=>{const n=Vn(e.request),a=e.method.toLowerCase(),o=[` "${Wn(e,t)}",`],i=Un(e);var r;return i&&o.push(` headers={"Authorization": f"Bearer {${r=i,r.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}}"},`),n&&o.push(` json=${JSON.stringify(n)},`),[`response = requests.${a}(`,...o,")"].join("\n")},label:"Python"},typescript:{build:(e,t)=>{const n=Vn(e.request),a=[],o=Un(e);o&&a.push(` Authorization: \`Bearer \${${o}}\`,`),n&&a.push(" 'Content-Type': 'application/json',");const i=[` method: '${e.method}',`];return a.length>0&&i.push(" headers: {",...a," },"),n&&i.push(` body: JSON.stringify(${JSON.stringify(n,null,2).replace(/\n/g,"\n ")}),`),[`const response = await fetch('${Wn(e,t)}', {`,...i,"});","","const data = await response.json();"].join("\n")},label:"TypeScript"}},Gn=["bash","typescript","dart","python"],Jn=["get","post","put","patch","delete"],Xn=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Yn=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),Zn=(e,t,n)=>!!e&&(!!e.tags?.some(e=>t.includes(e))||(e.paths?.includes(n)??!1)),Qn=e=>(Array.isArray(e.parameters)?e.parameters:[]).filter(Xn).map(e=>({..."string"==typeof e.description?{description:e.description}:{},in:"path"===e.in||"header"===e.in?e.in:"query",name:String(e.name??""),required:!0===e.required,...void 0===e.schema?{}:{schema:e.schema}})),ea=e=>Xn(e.responses)?Object.entries(e.responses).map(([e,t])=>{const n=Xn(t)?t:{},a=Xn(n.content)?n.content:void 0,o=a&&Xn(a["application/json"])?a["application/json"]:void 0;return{description:"string"==typeof n.description?n.description:"",...void 0===o?.schema?{}:{schema:o.schema},status:e}}):[],ta=e=>{if(!Xn(e.requestBody))return;const t=Xn(e.requestBody.content)?e.requestBody.content:void 0;return(t&&Xn(t["application/json"])?t["application/json"]:void 0)?.schema},na=e=>{if(!Array.isArray(e.security))return[];const t=e.security.find(Xn);return t?Object.keys(t):[]},aa=e=>{if(!Array.isArray(e.servers))return;const t=e.servers.find(Xn);return"string"==typeof t?.url?t.url:void 0},oa=(e,t)=>e[0]??t.split("/").filter(Boolean)[0]??"default",ia=(e,t)=>{const n=Xn(e)?e:{},a=Xn(n.info)?n.info:{},o=Xn(n.components)?n.components:{},i={groups:[],schemas:Xn(o.schemas)?o.schemas:{},servers:(Array.isArray(n.servers)?n.servers:[]).filter(Xn).map(e=>({..."string"==typeof e.description?{description:e.description}:{},url:String(e.url??"")})),title:"string"==typeof a.title?a.title:"",version:"string"==typeof a.version?a.version:""},r=Xn(n.paths)?n.paths:{},s=/* @__PURE__ */new Map;for(const[l,c]of Object.entries(r))if(Xn(c))for(const e of Jn){const n=c[e];if(!Xn(n))continue;const a=(Array.isArray(n.tags)?n.tags:[]).filter(e=>"string"==typeof e),o=!0===n["x-internal"],i=t.include?.paths?.includes(l)??!1;if(o&&!i)continue;if(Zn(t.exclude,a,l))continue;if(t.include&&!i&&!Zn(t.include,a,l))continue;const r={..."string"==typeof n.description?{description:n.description}:{},id:Yn(`${e}-${l}`),internal:o,method:e.toUpperCase(),params:Qn(n),path:l,...void 0===ta(n)?{}:{request:ta(n)},responses:ea(n),security:na(n),...void 0===aa(n)?{}:{server:aa(n)},summary:"string"==typeof n.summary?n.summary:l,tags:a},d=oa(a,l),p=s.get(d);p?p.operations.push(r):s.set(d,{id:Yn(d),operations:[r],title:d})}return i.groups=[...s.values()],i},ra=(e,t,n,a)=>{const o=e.create(t);return n&&o.addClass(...n.split(" ")),void 0!==a&&o.setText(a),o},sa=(e,t)=>{const n=ra(e,"div","clepit-openapi-table-scroll");return n.append(t),n},la=(e,t,n,a)=>{const o=ra(e,"p","clepit-openapi-section-title",t);return o.setAttribute("data-testid",`openapi-section-${n}-${a}`),o},ca=e=>{const t=e.ref&&"object"===e.type?e.ref:e.type,n=e.enum?e.enum.join(" | "):t;return e.nullable?`${n} | null`:n},da=(e,t=0)=>t>6?ca(e):e.type.endsWith("[]")?0===e.children.length?[]:[Object.fromEntries(e.children.map(e=>[e.required?e.name:`${e.name}?`,da(e,t+1)]))]:e.children.length>0?Object.fromEntries(e.children.map(e=>[e.required?e.name:`${e.name}?`,da(e,t+1)])):ca(e),pa=e=>{const t=Number.parseInt(e,10);return t>=200&&t<300?"success":t>=400&&t<500?"client":t>=500?"server":"other"},ua=(e,t,n,a)=>{const o=ra(e,"section","clepit-openapi-operation");o.setAttribute("data-testid",`openapi-operation-${t.id}`);const i=t.server??a.defaultServer??n.servers[0]?.url??"";o.setAttribute("data-server",i);const r=ra(e,"div","clepit-openapi-operation-head"),s=ra(e,"span","clepit-openapi-method",t.method);s.setAttribute("data-method",t.method),s.setAttribute("data-testid",`openapi-method-${t.id}`);const l=ra(e,"span","clepit-openapi-path",t.path);if(l.setAttribute("data-testid",`openapi-path-${t.id}`),r.append(s),r.append(l),i){const n=ra(e,"span","clepit-openapi-host",i);n.setAttribute("data-testid",`openapi-host-${t.id}`),r.append(n)}o.append(r);const c=ra(e,"div","clepit-openapi-operation-body"),d=ra(e,"h3","clepit-openapi-summary",t.summary);d.setAttribute("id",t.id),c.append(d),t.description&&c.append(ra(e,"p","clepit-openapi-description",t.description));const p=ra(e,"div","clepit-openapi-security");p.setAttribute("data-testid",`openapi-security-${t.id}`),p.append(ra(e,"span","clepit-openapi-section-title","Auth")),p.appendText(" "),p.append(ra(e,"span","clepit-openapi-badge",t.security.length>0?t.security.join(", "):"public")),c.append(p);const u=((e,t,n)=>{if(0===t.params.length)return null;const a=ra(e,"table","clepit-openapi-table");a.setAttribute("data-testid",`openapi-params-${t.id}`);const o=e.create("tr");for(const i of["Name","In","Type","Description"])o.append(ra(e,"th","clepit-openapi-th",i));a.append(o);for(const i of t.params){const t=e.create("tr"),o=ra(e,"td","clepit-openapi-name",i.name);i.required&&o.append(ra(e,"span","clepit-openapi-required"," required")),t.append(o),t.append(ra(e,"td","clepit-openapi-cell",i.in)),t.append(ra(e,"td","clepit-openapi-type",ca(Pn(i.schema,n.schemas)))),t.append(ra(e,"td","clepit-openapi-cell",i.description??"")),a.append(t)}return a})(e,t,n);if(u&&(c.append(la(e,"Parameters","parameters",t.id)),c.append(sa(e,u))),void 0!==t.request){const a=Pn(t.request,n.schemas);if(a.children.length>0){c.append(la(e,"Body","body",t.id));const n=ra(e,"div","clepit-openapi-body");n.setAttribute("data-testid",`openapi-body-${t.id}`);const o=Ce.draw({code:JSON.stringify(da(a),null,2),language:"json",showCopy:!0},e);o&&n.append(o),c.append(n)}}t.responses.length>0&&(c.append(la(e,"Responses","responses",t.id)),c.append(((e,t,n)=>{const a=ra(e,"div","clepit-openapi-responses");a.setAttribute("data-testid",`openapi-responses-${t.id}`);const o=ra(e,"div","clepit-openapi-response-tabs");o.setAttribute("role","tablist"),o.setAttribute("data-testid",`openapi-response-tabs-${t.id}`);const i=[],r=1===t.responses.length;t.responses.forEach((a,s)=>{const l=ra(e,"div","clepit-openapi-response");l.setAttribute("id",`${t.id}-response-${a.status}`),l.setAttribute("role","tabpanel"),l.setAttribute("data-status",a.status),l.setAttribute("data-testid",`openapi-response-${t.id}-${a.status}`),0!==s&&l.setAttribute("hidden","");const c=ra(e,"p","clepit-openapi-response-description");if(r){const t=ra(e,"span","clepit-openapi-status",a.status);t.setAttribute("data-kind",pa(a.status)),c.append(t),c.appendText(` ${a.description}`)}else c.setText(a.description);if(l.append(c),void 0!==a.schema){const t=Pn(a.schema,n.schemas);if(t.children.length>0){const n=Ce.draw({code:JSON.stringify(da(t),null,2),language:"json",showCopy:!0},e,{deferHighlight:0!==s});n&&l.append(n)}}i.push(l);const d=ra(e,"button","clepit-openapi-response-tab",a.status);d.setAttribute("type","button"),d.setAttribute("role","tab"),d.setAttribute("aria-controls",`${t.id}-response-${a.status}`),d.setAttribute("aria-selected",0===s?"true":"false"),d.setAttribute("tabindex",0===s?"0":"-1"),d.setAttribute("data-kind",pa(a.status)),d.setAttribute("data-testid",`openapi-response-tab-${t.id}-${a.status}`),o.append(d)}),r||a.append(o);for(const s of i)a.append(s);return a})(e,t,n)));const h=((e,t,n)=>n.flatMap(n=>{const a=Kn[n];return a?[{code:a.build(e,t),label:a.label,language:n}]:[]}))(t,i,a.snippetLanguages??Gn);if(h.length>0){c.append(la(e,"Try it","try-it",t.id));const n=Ce.draw({code:h[0].code,language:h[0].language,showCopy:!0,syncKey:"api-reference",variants:h},e);n&&c.append(n)}return o.append(c),o},ha=class e{static draw(t,n=R){if(!e.validate(t))return null;const a=ia(t.spec,t),o=ra(n,"div","clepit-openapi");if(a.servers.length>0){const e=ra(n,"table","clepit-openapi-table clepit-openapi-servers");e.setAttribute("data-testid","openapi-servers");const t=n.create("tr");t.append(ra(n,"th","clepit-openapi-th","Host")),t.append(ra(n,"th","clepit-openapi-th","Serves")),e.append(t);for(const o of a.servers){const t=n.create("tr");t.append(ra(n,"td","clepit-openapi-name",o.url)),t.append(ra(n,"td","clepit-openapi-cell",o.description??"")),e.append(t)}o.append(sa(n,e))}for(const e of a.groups){const i=ra(n,"section","clepit-openapi-group");i.setAttribute("data-testid",`openapi-group-${e.id}`);const r=ra(n,"h2","clepit-openapi-group-title",e.title);r.setAttribute("id",e.id),i.append(r);for(const o of e.operations)i.append(ua(n,o,a,t));o.append(i)}return o}static render(t,n,a,o){if(l.injectStyles("clepit-openapi-output-styles",jn),!e.validate(t))return X();const i=J(e.draw(t,R));o?.container&&i.classList.add(o.container),a?.container&&Object.assign(i.style,a.container),e.attach(i);for(const e of[...i.querySelectorAll(".clepit-output-code-container")])Ce.activateFromMarkup(e);return i}static activate(t){const n=[e.attach(t)];for(const e of[...t.querySelectorAll(".clepit-output-code-container")])n.push(Ce.activateFromMarkup(e));return()=>{for(const e of n)e()}}static attach(e){const t=[],n=(e,n,a)=>{e.addEventListener(n,a),t.push({event:n,handler:a,target:e})};for(const o of[...e.querySelectorAll(".clepit-openapi-responses")]){const e=[...o.querySelectorAll(".clepit-openapi-response-tab")],t=[...o.querySelectorAll(".clepit-openapi-response")],a=n=>{e.forEach((e,t)=>{e.setAttribute("aria-selected",t===n?"true":"false"),e.tabIndex=t===n?0:-1}),t.forEach((e,t)=>{e.hidden=t!==n,t===n&&Ce.reveal(e)})};e.forEach((t,o)=>{n(t,"click",()=>a(o)),n(t,"keydown",t=>{const n=t.key,i="ArrowRight"===n?1:"ArrowLeft"===n?-1:0,r="Home"===n?0:"End"===n?e.length-1:0===i?-1:(o+i+e.length)%e.length;-1!==r&&(t.preventDefault(),a(r),e[r]?.focus())})})}const a=()=>Ce.reveal(e);return window.addEventListener("beforeprint",a),t.push({event:"beforeprint",handler:a,target:window}),()=>{for(const{event:e,handler:n,target:a}of t)a.removeEventListener(e,n)}}static validate(e){return null!=e&&"object"==typeof e&&("string"==typeof e.url&&e.url.length>0||"object"==typeof e.spec&&null!==e.spec&&!Array.isArray(e.spec))}},ma="\n/* Output paragraph styles */\n.clepit-output-paragraph {\n margin: 0 0 1rem 0;\n line-height: 1.6;\n color: var(--clepit-text);\n}\n\n/* Output paragraph inline code styling */\n.clepit-output-paragraph code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n/* Output paragraph marker brush effect */\n.clepit-output-paragraph mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-paragraph mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Output paragraph link styles */\n.clepit-output-paragraph a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-paragraph a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n",ga=class e{static{this.placeholder="Start writing..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{html:m(e.querySelector(`.${l.classNames.block.paragraph}`)?.innerHTML)}}static render(t,n,a){l.injectStyles("clepit-paragraph-input-styles","\n/* Paragraph block styles */\n.clepit-paragraph {\n outline: none;\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 20px;\n}\n\n.clepit-block[data-tool=\"paragraph\"] .clepit-block-content {\n font-size: 16px;\n line-height: 1.6;\n}\n\n/* Paragraph placeholder styles */\n.clepit-paragraph[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Paragraph link styles */\n.clepit-paragraph a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-paragraph a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Paragraph inline code styling */\n.clepit-paragraph code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Paragraph marker brush effect */\n.clepit-paragraph mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-paragraph mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o=l.createStyledElement("div",l.classNames.block.paragraph,{classNames:a?.classNames,styles:a?.styles});return o.setAttribute("contenteditable","true"),o.setAttribute("data-placeholder",C.getState().getInstance(t)?.config.placeholder||e.placeholder),o.innerHTML=m(n?.html),e.addEventListener(t,o,"keydown",_s.handleKeydown),e.addEventListener(t,o,"input",_s.handleInput),o}static isEmpty(e){return h(e.querySelector(`.${l.classNames.block.paragraph}`)?.innerHTML)}static isEmptyData(e){return h(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},ba=class e{static render(t,n,a,o){if(l.injectStyles("clepit-paragraph-output-styles",ma),!e.validate(t))return X();const i=l.createStyledElement("p","clepit-output-paragraph",{classNames:o,styles:a});return ga.isEmptyData(t)?(i.appendChild(document.createElement("br")),i):(i.innerHTML=m(t.html),i)}static draw(t,n=R){if(!e.validate(t))return null;const a=n.create("p");return a.addClass("clepit-output-paragraph"),ga.isEmptyData(t)?(a.append(n.create("br")),a):(t.html&&a.setHtml(t.html),a)}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},fa=`\n/* Quote block styles */\n.${l.classNames.block.quote.container} {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n padding: 16px 20px;\n margin: 16px 16px 16px 0;\n position: relative;\n}\n\n.${l.classNames.block.quote.text} {\n font-size: 1.2em;\n line-height: 1.6;\n font-family: cursive, serif;\n font-style: italic;\n margin-bottom: 15px;\n padding: 4px 6px;\n}\n\n.${l.classNames.block.quote.author} {\n color: var(--clepit-text-muted);\n font-size: 0.9em;\n font-style: normal;\n font-family: inherit;\n text-align: right;\n margin-top: 10px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n.${l.classNames.block.quote.author}:focus {\n outline: none;\n}\n\n.${l.classNames.block.quote.divider} {\n height: 1px;\n margin: 15px 0;\n background: linear-gradient(to right, transparent, var(--clepit-border-subtle), transparent);\n}\n\n/* Quote placeholder styles */\n.${l.classNames.block.quote.text}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n.${l.classNames.block.quote.author}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Quote link styles */\n.${l.classNames.block.quote.text} a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.${l.classNames.block.quote.text} a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Quote inline code styling */\n.${l.classNames.block.quote.text} code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n`,va="\n/* Output quote styles */\n.clepit-output-quote-container {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n padding: 12px 14px;\n margin: 20px 0;\n position: relative;\n}\n\n.clepit-output-quote-author {\n color: var(--clepit-text-muted);\n font-size: 0.9em;\n font-style: normal;\n font-family: inherit;\n text-align: right;\n margin-top: 10px;\n}\n\n.clepit-output-quote-divider {\n height: 1px;\n margin: 15px 0;\n background: linear-gradient(to right, transparent, var(--clepit-border-subtle), transparent);\n}\n\n.clepit-output-quote-text {\n font-size: 1.2em;\n line-height: 1.6;\n font-family: cursive, serif;\n font-style: italic;\n margin-bottom: 15px;\n}\n\n.clepit-output-quote-content {\n /* Content styling handled by parent */\n}\n\n/* Output quote link styles */\n.clepit-output-quote a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-quote a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output quote inline code styling */\n.clepit-output-quote code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n.clepit-output-quote cite code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n/* Output quote marker brush effect */\n.clepit-output-quote mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-quote mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n.clepit-output-quote cite mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-quote cite mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n",ya=class e{static{this.placeholder="Enter quote..."}static{this.authorPlaceholder="Enter author..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${l.classNames.block.quote.text}`),n=e.querySelector(`.${l.classNames.block.quote.author}`);return{author:m(n?.innerHTML),html:m(t?.innerHTML)}}static render(t,n,a){l.injectStyles("clepit-quote-input-styles",fa);const o=n||{author:"",html:""},i=l.createStyledElement("div",l.classNames.block.quote.container,{classNames:a?.classNames?.container,styles:a?.styles?.container}),r=l.createStyledElement("div",l.classNames.block.quote.text,{classNames:a?.classNames?.text,styles:a?.styles?.text}),s=l.createStyledElement("div",l.classNames.block.quote.author,{classNames:a?.classNames?.author,styles:a?.styles?.author});if(r.innerHTML=m(o.html),r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",ne(t,"quoteBodyHint",e.placeholder)),s.innerHTML=m(o.author),s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",ne(t,"quoteAuthorHint",e.authorPlaceholder)),e.addEventListener(t,r,"keydown",e.handleKeydown),e.addEventListener(t,r,"input",_s.handleInput),e.addEventListener(t,s,"keydown",e.handleKeydown),e.addEventListener(t,s,"input",_s.handleInput),i.appendChild(r),o.author){const e=l.createStyledElement("div",l.classNames.block.quote.divider,{classNames:a?.classNames?.divider,styles:a?.styles?.divider});i.appendChild(e)}return i.appendChild(s),i}static handleKeydown(e){const t=e,n=e.currentTarget,a=n.closest(`.${l.classNames.block.container}`),o=_s.getEditorId(a);if(!o)return;const i=_s.getBlockIndex(o,a.getAttribute("data-id")),r=a.querySelector(`.${l.classNames.block.quote.text}`),s=a.querySelector(`.${l.classNames.block.quote.author}`),c=t.metaKey||t.ctrlKey;if(t.shiftKey)switch(t.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),i>0&&_s.moveBlock(o,i,i-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const t=_s.getBlocks(o);t&&i<t.length-1&&_s.moveBlock(o,i,i+1)}else if(c)switch(t.key){case"Delete":case"Backspace":e.preventDefault(),e.stopPropagation(),_s.removeBlock(o,i)}else if("Enter"===t.key)t.preventDefault(),t.stopPropagation(),_s.insertBlock({data:{html:""},type:"paragraph"},o,i+1);else if("Backspace"===t.key){if(!h(n.innerHTML))return;t.preventDefault(),t.stopPropagation(),n===r?_s.removeBlock(o,i):n===s&&(h(r.innerHTML)?_s.removeBlock(o,i):r.focus())}else if("ArrowUp"===t.key)if(t.preventDefault(),t.stopPropagation(),n===r){const e=a.previousElementSibling;e&&_s.focusBlock(e)}else r.focus();else if("ArrowDown"===t.key)if(t.preventDefault(),t.stopPropagation(),n===s){const e=a.nextElementSibling;e&&_s.focusBlock(e)}else s.focus()}static handleKeydownInAuthorInput(e){const t=e,n=e.currentTarget,a=n.closest(`.${l.classNames.block.container}`),o=_s.getEditorId(a);if(o)if("Enter"!==t.key||t.shiftKey){if("Backspace"===t.key){if(n.innerHTML?.trim()&&"<br>"!==n.innerHTML.trim())return;t.preventDefault(),t.stopPropagation();const e=a.querySelector(`.${l.classNames.block.quote.text}`);e&&e.focus()}}else{t.preventDefault(),t.stopPropagation();const e=_s.getBlockIndex(o,a.getAttribute("data-id"));_s.insertBlock({data:{html:""},type:"paragraph"},o,e+1)}}static isEmpty(e){const t=e.querySelector(`.${l.classNames.block.quote.text}`),n=e.querySelector(`.${l.classNames.block.quote.author}`);let a=!1,o=!1;return t?h(t.innerHTML)&&(a=!0):a=!0,n?h(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return h(e.html)&&h(e.author)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},xa=class e{static render(t,n,a,o){if(l.injectStyles("clepit-quote-output-styles",va),!e.validate(t))return X();if(ya.isEmptyData(t))return document.createElement("div");const i=t.author||"",r=l.createStyledElement("div","clepit-output-quote-container",{classNames:o?.container,styles:a?.container}),s=l.createStyledElement("div","clepit-output-quote-text",{classNames:o?.text,styles:a?.text}),c=p("div","clepit-output-quote-content");if(c.innerHTML=m(t.html),s.appendChild(c),r.appendChild(s),i){const e=l.createStyledElement("div","clepit-output-quote-divider",{classNames:o?.divider,styles:a?.divider});r.appendChild(e);const t=l.createStyledElement("div","clepit-output-quote-author",{classNames:o?.author,styles:a?.author});t.textContent=`— ${i}`,r.appendChild(t)}return r.querySelectorAll(`span.${l.classNames.block.tooltip}[data-tooltip]`).forEach(e=>{const t=e;t.hasAttribute("data-tooltip-initialized")||(ye(t,String(t.getAttribute("data-tooltip")||""),"above",n?.tooltipClassNames,void 0),t.setAttribute("data-tooltip-initialized","true"))}),r}static draw(t,n=R){if(!e.validate(t)||ya.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-quote-container");const o=n.create("div");o.addClass("clepit-output-quote-text");const i=n.create("div");if(i.addClass("clepit-output-quote-content"),t.html?.trim()&&i.setHtml(t.html),o.append(i),a.append(o),t.author){const e=n.create("div");e.addClass("clepit-output-quote-divider"),a.append(e);const o=n.create("div");o.addClass("clepit-output-quote-author"),o.setText(`— ${t.author}`),a.append(o)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},ka="\n.clepit-sketch {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n overflow: hidden;\n}\n.clepit-sketch__canvas {\n display: block;\n width: 100%;\n height: 240px;\n touch-action: none;\n}\n.clepit-sketch--input .clepit-sketch__canvas {\n cursor: crosshair;\n}\n",wa=ka,Ca=ka,Aa="http://www.w3.org/2000/svg";function Sa(e){return e&&/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(e.trim())?e.trim():"#000000"}function Ea(e){if(e.length<4)return"";const t=[`M ${e[0]} ${e[1]}`];for(let n=2;n+1<e.length;n+=2)t.push(`L ${e[n]} ${e[n+1]}`);return t.join(" ")}var La=class e{static render(t,n,a,o){if(l.injectStyles("sketch-output",Ca),!e.validate(t))return X();const i=l.createStyledElement("div","clepit-sketch clepit-output-sketch",{classNames:o?.wrapper,styles:a?.wrapper}),r=document.createElementNS(Aa,"svg");r.setAttribute("class","clepit-sketch__canvas"),r.setAttribute("viewBox","0 0 1000 240"),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("role","img");for(const s of t.strokes??[]){const t=Ea(s.points??[]);if(!t)continue;const n=document.createElementNS(Aa,"path");n.setAttribute("d",t),n.setAttribute("fill","none"),n.setAttribute("stroke",Sa(s.color)),n.setAttribute("stroke-width",String(e.safeWidth(s))),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),r.appendChild(n)}return i.appendChild(r),i}static draw(t,n=R){if(!e.validate(t))return null;const a=n.create("div");a.addClass("clepit-sketch","clepit-output-sketch");const o=n.createNS(Aa,"svg");o.setAttribute("class","clepit-sketch__canvas"),o.setAttribute("viewBox","0 0 1000 240"),o.setAttribute("preserveAspectRatio","none"),o.setAttribute("role","img");for(const i of t.strokes??[]){const t=Ea(i.points??[]);if(!t)continue;const a=n.createNS(Aa,"path");a.setAttribute("d",t),a.setAttribute("fill","none"),a.setAttribute("stroke",Sa(i.color)),a.setAttribute("stroke-width",String(e.safeWidth(i))),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),o.append(a)}return a.append(o),a}static safeWidth(e){const t=Number(e.width);return Number.isFinite(t)&&t>0&&t<=64?t:2}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.strokes)}},Na=`\n/* Table block styles */\n.clepit-table-container {\n position: relative;\n display: block;\n max-width: 100%;\n overflow-x: auto;\n overflow-y: visible; /* allow buttons to be visible outside */\n margin: 16px 0;\n padding: 20px;\n}\n\n.clepit-table {\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n background: var(--clepit-bg);\n border-radius: var(--clepit-radius-md);\n border: 1px solid var(--clepit-border);\n}\n\n.clepit-table-controls {\n display: flex;\n gap: 6px;\n margin: 6px 0;\n}\n\n.clepit-table-btn {\n border: 1px solid var(--clepit-border);\n background: var(--clepit-surface);\n border-radius: 4px;\n padding: 2px 6px;\n font-size: 12px;\n color: var(--clepit-text);\n cursor: pointer;\n}\n\n.clepit-table-btn:hover {\n background: var(--clepit-surface-2);\n}\n\n.clepit-table-corner {\n width: 28px;\n min-width: 28px;\n border-right: 1px solid var(--clepit-border);\n}\n\n.${l.classNames.block.table.headerCell} {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n border-right: 1px solid var(--clepit-border);\n padding: 10px 12px;\n font-weight: 600;\n min-width: 120px;\n vertical-align: top;\n text-align: left;\n position: relative;\n}\n\n.${l.classNames.block.table.cell} {\n border-right: 1px solid var(--clepit-border);\n border-bottom: 1px solid var(--clepit-border);\n padding: 10px 12px;\n min-width: 120px;\n vertical-align: top;\n text-align: left;\n}\n\n/* Zebra striping: odd white, even light grey */\n.clepit-table-tbody tr:nth-child(odd) .${l.classNames.block.table.cell} {\n background: var(--clepit-bg);\n}\n\n.clepit-table-tbody tr:nth-child(even) .${l.classNames.block.table.cell} {\n background: var(--clepit-surface);\n}\n\n.${l.classNames.block.table.caption} {\n margin: 8px 0 0 0; /* full width, no horizontal margins */\n width: 100%;\n padding: 10px 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n background: var(--clepit-surface);\n font-size: 13px;\n outline: none;\n flex: 1;\n min-width: 0;\n}\n\n.${l.classNames.block.table.caption}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: rgba(0, 0, 0, 0.6);\n font-style: italic;\n}\n\n/* Table Download Switch Container */\n.clepit-table-download-switch {\n margin: 8px 0 0 0;\n padding: 6px 8px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 13px;\n}\n\n.${l.classNames.block.table.headerCell}:focus,\n.clepit-table-cell:focus {\n outline: 2px solid var(--clepit-primary);\n outline-offset: -2px;\n}\n\n/* Table placeholder styles */\n.${l.classNames.block.table.headerCell}[data-placeholder]:empty::before,\n.${l.classNames.block.table.cell}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Table container */\n.clepit-table-container {\n overflow: visible;\n position: relative;\n}\n\n.clepit-table-scroll-container {\n overflow-x: auto;\n overflow-y: visible;\n max-width: 100%;\n}\n\n/* Table caption download container */\n.clepit-table-caption-download-container {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-top: 8px;\n}\n\n.clepit-table-download-switch {\n flex-shrink: 0;\n}\n\n`,Ba="\n/* Output table styles */\n.clepit-output-table-container {\n margin: 1rem 0;\n overflow-x: auto;\n}\n\n.clepit-output-table {\n width: 100%;\n border-collapse: collapse;\n border: 0;\n overflow: hidden;\n background: var(--clepit-bg);\n}\n\n/* House style: rows carry no horizontal dividers and no column rules. Rows are\n * told apart by zebra striping, which is what does that job instead — removing\n * the rules is not a licence to remove the banding too. */\n/* These four rules were assigned from JavaScript, one element at a time, which\n * is a browser call inside a render path. In a stylesheet they cost nothing to\n * a page that draws without a browser, and a caller's own inline style still\n * wins over them exactly as it did before. */\n.clepit-output-table-wrapper {\n overflow: hidden;\n width: 100%;\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n margin-bottom: 1rem;\n}\n\n.clepit-output-table-scroller {\n overflow-x: auto;\n}\n\n.clepit-output-table {\n table-layout: auto;\n margin-top: 0;\n margin-bottom: 0;\n border-radius: 0;\n}\n\n.clepit-output-table th,\n.clepit-output-table td {\n padding: 10px 12px;\n text-align: left;\n min-width: 120px;\n max-width: 400px;\n}\n\n.clepit-output-table th {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n color: var(--clepit-text);\n font-weight: 600;\n}\n\n.clepit-output-table tbody tr:nth-child(odd) {\n background: var(--clepit-bg);\n}\n\n.clepit-output-table tbody tr:nth-child(even) {\n background: var(--clepit-surface);\n}\n\n/* No hover state: a rendered table is display, not a control. A row that\n * changes colour under the pointer reads as clickable when it is not. */\n\n/* Table Output Caption */\n.clepit-output-table-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Make footer cell neutral so caption styles are visible */\n.clepit-output-table tfoot td,\n.clepit-output-table tfoot .clepit-output-table-caption-cell {\n padding: 0;\n border: 0;\n background: transparent;\n}\n\n.clepit-output-table-download-btn {\n margin-left: auto;\n width: 24px;\n height: 24px;\n border: none;\n outline: none;\n cursor: pointer;\n border-radius: 50%;\n background: transparent;\n transition: background-color 0.2s ease, transform 0.2s ease;\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.clepit-output-table-download-btn:hover {\n background: var(--clepit-bg);\n}\n\n.clepit-output-table-download-btn:hover .clepit-download-icon {\n stroke: var(--clepit-primary);\n}\n\n.clepit-output-table-download-btn:active {\n transform: scale(0.95);\n}\n\n.clepit-download-icon {\n width: 20px;\n height: 20px;\n stroke: var(--clepit-text-muted);\n transition: stroke 0.2s ease;\n}\n\n.clepit-output-table-footer-container {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 8px 12px;\n background: var(--clepit-surface);\n border-top: 1px solid var(--clepit-border);\n}\n";function $a(){if("undefined"==typeof navigator)return"unknown";const e=navigator.platform.toLowerCase(),t=navigator.userAgent.toLowerCase();return e.includes("mac")||t.includes("mac")?"mac":e.includes("win")||t.includes("win")?"windows":e.includes("linux")||t.includes("linux")?"linux":"unknown"}function Ma(){return"mac"===$a()?"⌘":"Ctrl"}function Ia(){return"mac"===$a()?"⌥":"Alt"}function Ta(e){return"mac"===$a()?e.join(""):e.join(" + ")}var _a=e=>Ta([Ma(),e]),qa=e=>Ta([Ma(),{down:"↓",left:"←",right:"→",up:"↑"}[e]]),Da=()=>Ta([Ma(),"B"]),za=()=>Ta([Ma(),"⌫"]),ja=()=>Ta([Ma(),"⌦"]),Ha=()=>Ta([Ma(),"I"]),Oa=()=>Ta([Ma(),"K"]),Pa=e=>Ta([Ma(),Ia(),e]),Ra=()=>Ta([Ma(),"U"]),Fa=class e{static{this.defaultCols=3}static{this.defaultRows=3}static{this.headerPlaceholder="Enter header..."}static{this.cellPlaceholder="Enter text..."}static{this.captionPlaceholder="Add a caption..."}static{this.defaultData={caption:"",data:Array.from({length:e.defaultRows},()=>Array.from({length:e.defaultCols},()=>"")),showDownload:!1}}static{this.eventListenersMap={}}static addEventListener(t,n,a,o,i){n.addEventListener(a,o,i);const r=e.eventListenersMap[t]||[];r.push({element:n,event:a,handler:o,options:i}),e.eventListenersMap[t]=r}static save(t){const n=t.querySelector("table");if(!n)return e.defaultData;const a=n.querySelector("thead tr"),o=a?Array.from(a.querySelectorAll(`.${l.classNames.block.table.headerCell}`)):[],i=[],r=[];for(const e of o)r.push(m(e.innerHTML));i.push(r);const s=n.querySelectorAll("tbody tr");for(const e of Array.from(s)){const t=Array.from(e.querySelectorAll(`.${l.classNames.block.table.cell}`)),n=[];for(const e of t)n.push(m(e.innerHTML));i.push(n)}const c=(t.querySelector(".clepit-table-download-switch")?.querySelector('input[type="checkbox"]'))?.checked||!1;return{caption:m(t.querySelector(`.${l.classNames.block.table.caption}`)?.innerHTML||""),data:i,showDownload:c}}static render(t,n,a){l.injectStyles("clepit-table-input-styles",Na);const o=n?{...e.defaultData,...n}:e.defaultData,i=l.createStyledElement("div","clepit-table-container",{classNames:a?.classNames?.container,styles:a?.styles?.container}),r=l.createStyledElement("table","clepit-table",{classNames:a?.classNames?.table,styles:a?.styles?.table}),s=l.createStyledElement("thead","clepit-table-thead",{classNames:a?.classNames?.table,styles:a?.styles?.table}),c=e.createRow(t,o.data[0],!0);s.appendChild(c),r.appendChild(s);const d=l.createStyledElement("tbody","clepit-table-tbody",{classNames:a?.classNames?.table,styles:a?.styles?.table});for(let l=1;l<o.data.length;l++){const n=e.createRow(t,o.data[l]);d.appendChild(n)}r.appendChild(d);const p=l.createStyledElement("div","clepit-table-scroll-container");p.appendChild(r),i.appendChild(p);const u=l.createStyledElement("button","clepit-table-btn clepit-row-menu-btn",{classNames:a?.classNames?.rowMenuButton,styles:a?.styles?.rowMenuButton});u.style.position="absolute",u.style.display="none",u.style.zIndex="1000",u.textContent="⋮",u.setAttribute("aria-label",ne(t,"tableRowActions","Row actions")),i.appendChild(u);const h=l.createStyledElement("button","clepit-table-btn clepit-col-menu-btn",{classNames:a?.classNames?.columnMenuButton,styles:a?.styles?.columnMenuButton});h.style.position="absolute",h.style.display="none",h.style.zIndex="1000",h.textContent="⋯",h.setAttribute("aria-label",ne(t,"tableColumnActions","Column actions")),i.appendChild(h);let g=null,b=-1,f=null;e.addEventListener(t,i,"mouseleave",()=>(u.style.display="none",h.style.display="none",void(f&&(f.remove(),f=null))));const v=e=>{g=e;const t=e.getBoundingClientRect(),n=i.getBoundingClientRect(),a=t.top-n.top+t.height/2-12;u.style.left="4px",u.style.top=`${Math.max(4,a)}px`,u.style.display="flex"},y=e=>{if(b=Array.from(c.querySelectorAll(`.${l.classNames.block.table.headerCell}`)).indexOf(e),b<0)return;const t=e.getBoundingClientRect(),n=i.getBoundingClientRect(),a=t.left-n.left+t.width/2-12,o=t.top-n.top-20;h.style.left=`${a}px`,h.style.top=`${Math.max(4,o)}px`,h.style.display="flex"};e.addEventListener(t,d,"mouseover",e=>{const t=e.target.closest("tr");t&&v(t)}),e.addEventListener(t,s,"mouseover",e=>{const t=e.target.closest(`.${l.classNames.block.table.headerCell}`);t&&y(t)}),e.addEventListener(t,d,"mouseover",e=>{const t=e.target.closest(`.${l.classNames.block.table.cell}`);if(!t)return;const n=t.closest("tr");if(!n)return;const a=Array.from(n.querySelectorAll(`.${l.classNames.block.table.cell}`)).indexOf(t);if(a>=0){const e=c.querySelectorAll(`.${l.classNames.block.table.headerCell}`)[a];e&&y(e)}v(n)});const x=()=>{g&&"none"!==u.style.display&&v(g);const e=c.querySelectorAll(`.${l.classNames.block.table.headerCell}`)[b];e&&"none"!==h.style.display&&y(e)};e.addEventListener(t,window,"scroll",x,{passive:!0}),e.addEventListener(t,p,"scroll",x,{passive:!0}),e.addEventListener(t,u,"click",n=>{if(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation?.(),!g)return;const o=Array.from(d.querySelectorAll("tr")),r=o.indexOf(g),s=u.getBoundingClientRect(),p=i.getBoundingClientRect();e.createMenu(t,i,u,h,[{icon:"↑",label:ne(t,"moveUp","Move up"),onClick:()=>{r>0&&(d.insertBefore(g,o[r-1]),_s.saveBlockData(g))},shortcut:qa("up"),testId:"table-row-move-up"},{icon:"↓",label:ne(t,"moveDown","Move down"),onClick:()=>{r>=0&&r<o.length-1&&(d.insertBefore(o[r+1],g),_s.saveBlockData(g))},shortcut:qa("down"),testId:"table-row-move-down"},{icon:"+",label:ne(t,"tableInsertAbove","Insert above"),onClick:()=>{const n=c.querySelectorAll(`.${l.classNames.block.table.headerCell}`).length||3,a=e.createRow(t,Array.from({length:n},()=>""));d.insertBefore(a,g),_s.saveBlockData(g)},testId:"table-row-insert-above"},{icon:"+",label:ne(t,"tableInsertBelow","Insert below"),onClick:()=>{const n=c.querySelectorAll(`.${l.classNames.block.table.headerCell}`).length||3,a=e.createRow(t,Array.from({length:n},()=>""));g.nextSibling?d.insertBefore(a,g.nextSibling):d.appendChild(a),_s.saveBlockData(g)},testId:"table-row-insert-below"},{icon:"×",isDanger:!0,label:ne(t,"delete","Delete"),onClick:()=>{o.length>1&&(g.remove(),_s.saveBlockData(g))},shortcut:za(),testId:"table-row-delete"}],s.left-p.left,s.bottom-p.top+4,a,f)}),e.addEventListener(t,h,"click",n=>{if(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation?.(),b<0)return;const o=Array.from(c.querySelectorAll(`.${l.classNames.block.table.headerCell}`)),r=h.getBoundingClientRect(),s=i.getBoundingClientRect();e.createMenu(t,i,u,h,[{icon:"←",label:ne(t,"tableMoveLeft","Move left"),onClick:()=>{if(b<=0)return;const e=b,t=o[e-1],n=o[e];t&&n&&c.insertBefore(n,t),d.querySelectorAll("tr").forEach(t=>{const n=Array.from(t.querySelectorAll(`.${l.classNames.block.table.cell}`)),a=n[e-1],o=n[e];a&&o&&t.insertBefore(o,a)}),b=e-1,_s.saveBlockData(c)},shortcut:qa("left"),testId:"table-column-move-left"},{icon:"→",label:ne(t,"tableMoveRight","Move right"),onClick:()=>{const e=b;if(e<0||e>=o.length-1)return;const t=o[e],n=o[e+1];t&&n&&c.insertBefore(n,t),d.querySelectorAll("tr").forEach(t=>{const n=Array.from(t.querySelectorAll(`.${l.classNames.block.table.cell}`)),a=n[e],o=n[e+1];a&&o&&t.insertBefore(o,a)}),b=e+1,_s.saveBlockData(c)},shortcut:qa("right"),testId:"table-column-move-right"},{icon:"+",label:ne(t,"tableInsertLeft","Insert left"),onClick:()=>{const n=b,a=e.createHeaderCell(t,"");c.insertBefore(a,o[n]),d.querySelectorAll("tr").forEach(a=>{const o=e.createCell(t,""),i=a.querySelectorAll(`.${l.classNames.block.table.cell}`);i[n]?a.insertBefore(o,i[n]):a.appendChild(o)}),_s.saveBlockData(c)},testId:"table-column-insert-left"},{icon:"+",label:ne(t,"tableInsertRight","Insert right"),onClick:()=>{const n=b+1,a=o[b]?.nextSibling||null,i=e.createHeaderCell(t,"");c.insertBefore(i,a),d.querySelectorAll("tr").forEach(a=>{const o=e.createCell(t,""),i=a.querySelectorAll(`.${l.classNames.block.table.cell}`);i[n]?a.insertBefore(o,i[n]):a.appendChild(o)}),_s.saveBlockData(c)},testId:"table-column-insert-right"},{icon:"×",isDanger:!0,label:ne(t,"delete","Delete"),onClick:()=>{const e=c.querySelectorAll(`.${l.classNames.block.table.headerCell}`);if(b<0||e.length<=1)return;const t=e[b];t?.parentElement?.removeChild(t),d.querySelectorAll("tr").forEach(e=>{const t=e.querySelectorAll(`.${l.classNames.block.table.cell}`);t[b]&&t[b].parentElement?.removeChild(t[b])}),_s.saveBlockData(c)},shortcut:ja(),testId:"table-column-delete"}],r.left-s.left,r.bottom-s.top+4,a,f)});Array.from(d.querySelectorAll("tr")).forEach(n=>(n=>{e.addEventListener(t,n,"mouseenter",()=>v(n))})(n)),Array.from(c.querySelectorAll(`.${l.classNames.block.table.headerCell}`)).forEach(n=>{return a=n,void e.addEventListener(t,a,"mouseenter",()=>y(a));var a});const k=l.createStyledElement("div","clepit-table-caption-download-container",{classNames:a?.classNames?.container,styles:a?.styles?.container});k.style.display="flex",k.style.alignItems="center",k.style.gap="8px",k.style.marginTop="8px";const w=l.createStyledElement("div",`${l.classNames.block.table.caption}`,{classNames:a?.classNames?.caption,styles:a?.styles?.caption});w.contentEditable="true",w.setAttribute("tabindex","0"),w.setAttribute("data-placeholder",ne(t,"tableCaptionHint",e.captionPlaceholder)),w.style.flex="1",w.style.minWidth="0",w.innerHTML=m(o.caption),e.addEventListener(t,w,"input",_s.handleInput),e.addEventListener(t,w,"keydown",e.handleKeydown),e.addEventListener(t,w,"click",e.handleClick),k.appendChild(w);const A=l.createStyledElement("div",`${l.classNames.block.table.downloadSwitch}`);A.style.flexShrink="0";const S=ue.create({checked:o.showDownload||!1,label:"Allow download",onToggle:e=>{const n=i.closest(`.${l.classNames.block.container}`);if(n){const a=n.getAttribute("data-id");a&&C.getState().partialUpdateBlockData(t,_s.getBlockIndex(t,a),{showDownload:e})}}});A.appendChild(S),k.appendChild(A),i.appendChild(k);return e.addEventListener(t,i,"focusin",()=>{const e=document.activeElement;if(e&&i.contains(e))if(e.classList.contains(l.classNames.block.table.cell)){const t=e.closest("tr");t&&(g=t,v(t))}else e.classList.contains(l.classNames.block.table.headerCell)&&y(e)}),i}static createRow(t,n,a){const o=C.getState().getInstance(t),i=o?.config.classNames?.blocks?.table?.row,r=o?.config.styles?.blocks?.table?.row,s=l.createStyledElement("tr",a?`${l.classNames.block.table.headerRow}`:`${l.classNames.block.table.row}`,{classNames:i,styles:r});for(let l=0;l<n.length;l++)s.appendChild(a?e.createHeaderCell(t,n[l]):e.createCell(t,n[l]));return s.querySelector(`.${l.classNames.block.table.cell}`)?.focus(),s}static createCell(t,n){const a=C.getState().getInstance(t),o=a?.config.classNames?.blocks?.table?.cell,i=a?.config.styles?.blocks?.table?.cell,r=l.createStyledElement("td",`${l.classNames.block.table.cell}`,{classNames:o,styles:i});return r.contentEditable="true",r.setAttribute("tabindex","0"),r.setAttribute("data-placeholder",ne(t,"tableCellHint",e.cellPlaceholder)),r.innerHTML=m(n),e.addEventListener(t,r,"input",_s.handleInput),e.addEventListener(t,r,"keydown",e.handleKeydown),e.addEventListener(t,r,"click",e.handleClick),r}static createHeaderCell(t,n){const a=C.getState().getInstance(t),o=a?.config.classNames?.blocks?.table?.header,i=a?.config.styles?.blocks?.table?.header,r=l.createStyledElement("th",`${l.classNames.block.table.headerCell}`,{classNames:o,styles:i});return r.contentEditable="true",r.setAttribute("tabindex","0"),r.setAttribute("data-placeholder",ne(t,"tableHeaderHint",e.headerPlaceholder)),r.innerHTML=m(n),e.addEventListener(t,r,"input",_s.handleInput),e.addEventListener(t,r,"keydown",e.handleKeydown),e.addEventListener(t,r,"click",e.handleClick),r}static handleAction(t,n){const a=n.querySelector("table");if(a)switch(t){case"addRow":return e.addRow(a);case"removeRow":return e.removeRow(a);case"addColumn":return e.addColumn(a);case"removeColumn":return e.removeColumn(a)}}static addRow(t){const n=t.querySelector("tbody");if(!n)return;const a=_s.getEditorId(t);if(!a)return;const o=t.querySelector("thead tr")?.querySelectorAll("th").length||e.defaultData.data[0].length,i=e.createRow(a,Array.from({length:o},()=>""));n.appendChild(i)}static removeRow(e){const t=e.querySelector("tbody");if(!t)return;const n=t.querySelectorAll("tr");n.length>1&&t.removeChild(n[n.length-1])}static addColumn(t){const n=_s.getEditorId(t);if(!n)return;const a=t.querySelector("thead tr"),o=t.querySelector("tbody");if(!a||!o)return;const i=e.createHeaderCell(n,"");a.appendChild(i),o.querySelectorAll("tr").forEach(t=>{const a=e.createCell(n,"");t.appendChild(a)})}static removeColumn(e){const t=e.querySelector("thead tr"),n=e.querySelector("tbody");if(!t||!n)return;const a=t.querySelectorAll("th");a.length>1&&(t.removeChild(a[a.length-1]),n.querySelectorAll("tr").forEach(e=>{const t=e.querySelectorAll("td");t.length>1&&e.removeChild(t[t.length-1])}))}static createMenu(t,n,a,o,i,r,s,c,d){d&&(d.remove(),d=null);const p=l.createStyledElement("div","clepit-block-operations-menu clepit-table-menu",{classNames:c?.classNames?.menu,styles:c?.styles?.menu});p.classList.add("clepit-block-operations-menu--visible"),p.style.position="absolute",p.style.zIndex="20",p.style.left=`${r}px`,p.style.top=`${s}px`,p.style.minWidth="180px",i.forEach(n=>{const a=l.createStyledElement("div","clepit-menu-item"+(n.isDanger?" clepit-menu-item--danger":""),{classNames:c?.classNames?.menuItem,styles:c?.styles?.menuItem});a.setAttribute("data-testid",n.testId),a.style.fontSize="14px";const o=l.createStyledElement("span","clepit-menu-icon");o.textContent=n.icon;const i=l.createStyledElement("span","clepit-menu-text");if(i.textContent=n.label,a.appendChild(o),a.appendChild(i),n.shortcut){const e=l.createStyledElement("span","clepit-menu-shortcut");e.style.marginLeft="auto",e.style.fontSize="9px",e.style.color="#666",e.style.opacity="0.7",e.textContent=n.shortcut,a.appendChild(e)}e.addEventListener(t,a,"click",e=>{e.stopPropagation(),e.stopImmediatePropagation?.(),n.onClick(),d&&(d.remove(),d=null)}),p.appendChild(a)}),n.appendChild(p),d=p;const u=e=>{p.contains(e.target)||e.target===a||e.target===o||(p.remove(),d=null,document.removeEventListener("click",u))};return setTimeout(()=>document.addEventListener("click",u),0),p}static handleClick(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget.closest(`.${l.classNames.block.container}`);t&&_s.setActiveBlock(t)}static handleKeydown(e){const t=e,n=e.currentTarget,a=_s.getEditorId(n);if(!a)return;const o=n.closest(`.${l.classNames.block.container}`);if(!o)return;const i=_s.getBlockIndex(a,o.getAttribute("data-id")),r=t.metaKey||t.ctrlKey;if(t.shiftKey)switch(t.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),i>0&&_s.moveBlock(a,i,i-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const t=_s.getBlocks(a);t&&i<t.length-1&&_s.moveBlock(a,i,i+1)}else if(r){const o=n.closest("table"),r=o.querySelector("tbody"),s=o.querySelector("thead tr");switch(t.key){case"ArrowUp":if(n.classList.contains(l.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr"),a=Array.from(r.querySelectorAll("tr")),o=a.indexOf(t);if(o>0){const e=Array.from(t.querySelectorAll(`.${l.classNames.block.table.cell}`)).indexOf(n);r.insertBefore(t,a[o-1]),_s.saveBlockData(t);const i=t.querySelectorAll(`.${l.classNames.block.table.cell}`)[e];i&&i.focus()}}break;case"ArrowDown":if(n.classList.contains(l.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr"),a=Array.from(r.querySelectorAll("tr")),o=a.indexOf(t);if(o>=0&&o<a.length-1){const e=Array.from(t.querySelectorAll(`.${l.classNames.block.table.cell}`)).indexOf(n);r.insertBefore(a[o+1],t),_s.saveBlockData(t);const i=t.querySelectorAll(`.${l.classNames.block.table.cell}`)[e];i&&i.focus()}}break;case"ArrowLeft":let t=-1;const c=Array.from(s.querySelectorAll(`.${l.classNames.block.table.headerCell}`));if(n.classList.contains(l.classNames.block.table.headerCell))t=c.indexOf(n);else if(n.classList.contains(l.classNames.block.table.cell)){const e=n.closest("tr");t=Array.from(e.querySelectorAll(`.${l.classNames.block.table.cell}`)).indexOf(n)}if(t>0){e.preventDefault(),e.stopPropagation();const a=t,i=c[a-1],r=c[a];if(i&&r&&s.insertBefore(r,i),o.querySelectorAll("tbody tr").forEach(e=>{const t=Array.from(e.querySelectorAll(`.${l.classNames.block.table.cell}`)),n=t[a-1],o=t[a];n&&o&&e.insertBefore(o,n)}),n.classList.contains(l.classNames.block.table.cell)){const e=n.closest("tr").querySelectorAll(`.${l.classNames.block.table.cell}`)[a-1];e&&e.focus()}else{r&&r.focus()}_s.saveBlockData(s)}break;case"ArrowRight":let d=-1;const p=Array.from(s.querySelectorAll(`.${l.classNames.block.table.headerCell}`));if(n.classList.contains(l.classNames.block.table.headerCell))d=p.indexOf(n);else if(n.classList.contains(l.classNames.block.table.cell)){const e=n.closest("tr");d=Array.from(e.querySelectorAll(`.${l.classNames.block.table.cell}`)).indexOf(n)}if(d<p.length-1){e.preventDefault(),e.stopPropagation();const t=d,a=p[t],i=p[t+1];if(a&&i&&s.insertBefore(i,a),o.querySelectorAll("tbody tr").forEach(e=>{const n=Array.from(e.querySelectorAll(`.${l.classNames.block.table.cell}`)),a=n[t],o=n[t+1];a&&o&&e.insertBefore(o,a)}),n.classList.contains(l.classNames.block.table.cell)){const e=n.closest("tr").querySelectorAll(`.${l.classNames.block.table.cell}`)[t+1];e&&e.focus()}else{i&&i.focus()}_s.saveBlockData(s)}break;case"Backspace":if(n.classList.contains(l.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr");Array.from(r.querySelectorAll("tr")).length>1&&(t.remove(),_s.saveBlockData(t))}else e.preventDefault(),e.stopPropagation(),_s.removeBlock(a,i);break;case"Delete":let u=-1;const h=Array.from(s.querySelectorAll(`.${l.classNames.block.table.headerCell}`));if(n.classList.contains(l.classNames.block.table.headerCell))u=h.indexOf(n);else if(n.classList.contains(l.classNames.block.table.cell)){const e=n.closest("tr");u=Array.from(e.querySelectorAll(`.${l.classNames.block.table.cell}`)).indexOf(n)}if(u>=0&&h.length>1){e.preventDefault(),e.stopPropagation();const t=h[u];t?.parentElement?.removeChild(t),o.querySelectorAll("tbody tr").forEach(e=>{const t=e.querySelectorAll(`.${l.classNames.block.table.cell}`);t[u]&&t[u].parentElement?.removeChild(t[u])}),_s.saveBlockData(s)}else e.preventDefault(),e.stopPropagation(),_s.removeBlock(a,i)}}else if("Enter"===t.key)e.preventDefault(),e.stopPropagation(),_s.insertBlock({data:{html:""},type:"paragraph"},a,i+1);else if("Backspace"===t.key){const t=n.closest(`.${l.classNames.block.container}`);if(!t)return;Array.from(t.querySelectorAll(`.${l.classNames.block.table.cell},.${l.classNames.block.table.headerCell}`)).every(e=>h(e.innerHTML))&&(e.preventDefault(),e.stopPropagation(),_s.removeBlock(a,i))}else{_s.ensureActiveBlock(a);const o=_s.getBlocks(a);switch(t.key){case"ArrowUp":if(e.preventDefault(),e.stopPropagation(),n.classList.contains(l.classNames.block.table.caption)){const e=n.closest(`.${l.classNames.block.container}`)?.querySelector("table");if(e){const t=e.querySelector("tbody")?.lastElementChild;if(t&&t.cells.length>0){const e=t.cells[t.cells.length-1];return void(e&&e.focus())}}}const t=n.closest("table");if(!t)return;const a=n.closest("tr"),r=Array.from(a?.cells||[]).indexOf(n);if("TBODY"===a?.parentElement?.tagName&&a===a.parentElement.firstElementChild){const e=t.querySelector("thead")?.querySelector("tr");if(e&&e.cells[r])return void e.cells[r].focus()}if(a?.previousElementSibling){const e=a.previousElementSibling.cells[r];e&&e.focus()}else if(i>0){const e=o[i-1];e&&_s.focusBlock(e)}return;case"ArrowDown":if(e.preventDefault(),e.stopPropagation(),n.classList.contains(l.classNames.block.table.caption)){if(i<o.length-1){const e=o[i+1];e&&_s.focusBlock(e)}return}const s=n.closest("table");if(!s)return;const c=n.closest("tr"),d=Array.from(c?.cells||[]).indexOf(n);if("THEAD"===c?.parentElement?.tagName){const e=s.querySelector("tbody")?.firstElementChild;if(e&&e.cells[d])return void e.cells[d].focus()}if(c?.nextElementSibling){const e=c.nextElementSibling.cells[d];e&&e.focus()}else{if("TBODY"===c?.parentElement?.tagName&&c===c.parentElement.lastElementChild){const e=s.closest(`.${l.classNames.block.container}`)?.querySelector(`.${l.classNames.block.table.caption}`);if(e)return void e.focus()}if(i<o.length-1){const e=o[i+1];e&&_s.focusBlock(e)}}return;case"ArrowLeft":if(!g(n,"left"))return;e.preventDefault(),e.stopPropagation();const p=n.closest("table");if(!p)return;const u=n.closest("tr"),h=Array.from(u?.cells||[]).indexOf(n);if(h>0){const e=u?.cells[h-1];e&&e.focus()}else{if("TBODY"===u?.parentElement?.tagName&&u===u.parentElement.firstElementChild){const e=p.querySelector("thead")?.querySelector("tr");if(e&&e.cells.length>0){const t=e.cells[e.cells.length-1];return void(t&&t.focus())}}if(u?.previousElementSibling){const e=u.previousElementSibling,t=e.cells[e.cells.length-1];t&&t.focus()}}return;case"ArrowRight":if(!g(n,"right"))return;e.preventDefault(),e.stopPropagation();const m=n.closest("table");if(!m)return;const b=n.closest("tr"),f=Array.from(b?.cells||[]).indexOf(n);if(f<(b?.cells.length||0)-1){const e=b?.cells[f+1];e&&e.focus()}else{if("THEAD"===b?.parentElement?.tagName){const e=m.querySelector("tbody")?.firstElementChild;if(e&&e.cells.length>0){const t=e.cells[0];return void(t&&t.focus())}}if(b?.nextElementSibling){const e=b.nextElementSibling.cells[0];e&&e.focus()}}return}}}static isEmpty(e){const t=e.querySelector(`.${l.classNames.block.table.caption}`),n=e.querySelectorAll(`.${l.classNames.block.table.cell},.${l.classNames.block.table.headerCell}`);let a=!1,o=!1;return t?h(t.innerHTML)&&(a=!0):a=!0,n?Array.from(n).every(e=>h(e.innerHTML))&&(o=!0):o=!0,a&&o}static isEmptyData(e){return h(e.caption)&&e.data.every(e=>e.every(e=>h(e)))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Va="http://www.w3.org/2000/svg",Ua=["M3 15C3 17.8284 3 19.2426 3.87868 20.1213C4.75736 21 6.17157 21 9 21H15C17.8284 21 19.2426 21 20.1213 20.1213C21 19.2426 21 17.8284 21 15","M12 3V16M12 16L16 11.625M12 16L8 11.625"],Wa=/^[=+@\t\r-]/,Ka=class e{static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static render(t,n,a,o,i){if(l.injectStyles("clepit-table-output-styles",Ba),!e.validate(t))return X();if(Fa.isEmptyData(t))return document.createElement("div");const r=e.draw(t,R);if(!r)return document.createElement("div");const s=J(r);o?.container&&s.classList.add(o.container),a?.container&&Object.assign(s.style,a.container);const c=s.querySelector(".clepit-output-table-caption");c&&o?.caption&&c.classList.add(o.caption),c&&a?.caption&&Object.assign(c.style,a.caption);const d=s.querySelector(".clepit-output-table-footer-container");return d&&o?.footerContainer&&d.classList.add(o.footerContainer),d&&a?.footerContainer&&Object.assign(d.style,a.footerContainer),e.attach(s,t,a,o,i),s}static activate(t,n){return!e.validate(n)||Fa.isEmptyData(n)?()=>{}:e.attach(t,n)}static attach(t,n,a,o,i){const r=t.querySelector(".clepit-output-table-download-btn");if(!r)return()=>{};o?.downloadButton&&r.classList.add(o.downloadButton),a?.downloadButton&&Object.assign(r.style,a.downloadButton);const s=()=>e.downloadTableAsCSV(n);r.addEventListener("click",s);const l=i?document.getElementById(i):null;if(l){const t=e.eventListenersMap.get(l)??[];t.push({element:r,event:"click",handler:s}),e.eventListenersMap.set(l,t)}const c=i?C.getState().getInstance(i):null,d=ye(r,"Download CSV","above",c?.config.classNames?.tooltips,c?.config.styles?.tooltips);return()=>{r.removeEventListener("click",s),d()}}static draw(t,n=R){if(!e.validate(t)||Fa.isEmptyData(t))return null;const a=Array.isArray(t.data)&&t.data.length>0?t.data:[];if(0===a.length)return null;const o=n.create("div");o.addClass("clepit-output-table-wrapper");const i=n.create("div");i.addClass("clepit-output-table-scroller");const r=n.create("table");r.addClass("clepit-output-table");const s=n.create("thead"),l=n.create("tr");for(const e of a[0]??[]){const t=n.create("th");t.setText(e),l.append(t)}if(s.append(l),r.append(s),a.length>1){const e=n.create("tbody");for(const t of a.slice(1)){const a=n.create("tr");for(const e of t){const t=n.create("td");t.setText(e),a.append(t)}e.append(a)}r.append(e)}if(i.append(r),o.append(i),t.caption||t.showDownload){const a=n.create("div");if(a.addClass("clepit-output-table-footer-container"),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-table-caption"),t.caption.trim()&&e.setHtml(t.caption),a.append(e)}if(t.showDownload){const t=n.create("button");t.addClass("clepit-output-table-download-btn"),t.setAttribute("type","button"),t.setAttribute("aria-label","Download CSV"),t.append(e.drawDownloadIcon(n)),a.append(t)}o.append(a)}return o}static drawDownloadIcon(e){const t=e.createNS(Va,"svg");t.setAttribute("class","clepit-download-icon"),t.setAttribute("width","20"),t.setAttribute("height","20"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");for(const n of Ua){const a=e.createNS(Va,"path");a.setAttribute("d",n),a.setAttribute("stroke","currentColor"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),t.append(a)}return t}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.data)}static downloadTableAsCSV(e){const t=e.data||[];if(0===t.length)return;const n=t.map(e=>e.map(e=>{const t=(e=>Wa.test(e)&&Number.isNaN(Number(e))?`'${e}`:e)(e).replace(/"/g,'""');return t.includes(",")||t.includes('"')||t.includes("\n")||t.includes("\r")?`"${t}"`:t}).join(",")).join("\n"),a=new Blob([n],{type:"text/csv;charset=utf-8;"}),o=document.createElement("a"),i=URL.createObjectURL(a);o.setAttribute("href",i),o.setAttribute("download","table-data.csv"),o.style.visibility="hidden",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}static destroy(t){const n=document.getElementById(t);if(!n)return console.warn("TableOutput::destroy: Container not found for containerId:",t);const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n))}},Ga="\n.clepit-toc {\n display: block;\n}\n.clepit-toc__entry {\n display: block;\n padding: 2px 0;\n color: inherit;\n text-decoration: none;\n}\n.clepit-toc__entry:hover {\n text-decoration: underline;\n}\n.clepit-toc__empty {\n opacity: 0.55;\n}\n",Ja=Ga,Xa=Ga,Ya={h1:0,h2:1,h3:2,h4:3,h5:4,h6:5},Za=class{static render(e,t,n,a){l.injectStyles("toc-output",Xa);const o=(t?.documentBlocks??[]).filter(e=>"header"===e.type),i=l.createStyledElement("nav","clepit-toc clepit-output-toc",{classNames:a?.list,styles:n?.list});if(0===o.length){const e=document.createElement("div");return e.className="clepit-toc__empty",e.textContent="Table of contents: headings appear here",i.appendChild(e),i}return o.forEach((e,t)=>{const o=e.data,r=l.createStyledElement("a","clepit-toc__entry",{classNames:a?.entry,styles:n?.entry});r.setAttribute("data-toc-index",t.toString());const s=Ya[o.level??"h1"];r.style.paddingLeft=16*s+"px",e.id&&(r.href=`#${e.id}`),r.innerHTML=m(o.html),i.appendChild(r)}),i}static draw(e,t=R,n){if(null==e||"object"!=typeof e)return null;const a=(n?.documentBlocks??[]).filter(e=>"header"===e.type);if(0===a.length)return null;const o=t.create("nav");return o.addClass("clepit-toc","clepit-output-toc"),a.forEach((e,n)=>{const a=e.data,i=t.create("a");i.addClass("clepit-toc__entry"),i.setAttribute("data-toc-index",n.toString()),i.setAttribute("style",`padding-left: ${16*Ya[a.level??"h1"]}px;`),e.id&&i.setAttribute("href",`#${e.id}`),i.setHtml(a.html),o.append(i)}),o}},Qa="\n.clepit-typeset {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n padding: 12px;\n}\n.clepit-typeset__kind {\n display: block;\n opacity: 0.7;\n font-size: 0.85em;\n margin-bottom: 6px;\n}\n.clepit-typeset__kind:has(+ .clepit-typeset__title) {\n display: inline-block;\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.06em;\n margin-bottom: 0;\n text-transform: uppercase;\n}\n.clepit-typeset__title {\n display: block;\n font-size: 1em;\n font-weight: 600;\n margin: 2px 0 8px;\n opacity: 1;\n}\n.clepit-typeset__title[data-placeholder]:empty::before {\n color: inherit;\n content: attr(data-placeholder);\n font-style: italic;\n font-weight: 400;\n opacity: 0.5;\n pointer-events: none;\n}\n.clepit-typeset__source {\n display: block;\n margin: 0;\n white-space: pre-wrap;\n word-break: break-word;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n.clepit-typeset--input .clepit-typeset__source {\n outline: none;\n}\n.clepit-typeset__diagram {\n display: block;\n max-width: 100%;\n height: auto;\n}\n.clepit-typeset__node {\n fill: rgba(127, 127, 127, 0.08);\n stroke: currentColor;\n stroke-width: 1.5;\n}\n.clepit-typeset__label {\n fill: currentColor;\n font-size: 13px;\n font-family: inherit;\n}\n.clepit-typeset__edge,\n.clepit-typeset__message,\n.clepit-typeset__lifeline {\n stroke: currentColor;\n fill: none;\n}\n.clepit-typeset__lifeline {\n stroke-dasharray: 4 4;\n opacity: 0.55;\n}\n.clepit-typeset__arrowhead {\n fill: currentColor;\n}\n.clepit-typeset__edge-label {\n fill: currentColor;\n font-size: 12px;\n font-family: inherit;\n}\n.clepit-typeset__activation {\n fill: rgba(127, 127, 127, 0.3);\n stroke: currentColor;\n stroke-width: 1;\n}\n.clepit-typeset__note {\n fill: rgba(240, 200, 100, 0.18);\n stroke: currentColor;\n stroke-width: 1;\n}\n.clepit-typeset__formula {\n display: block;\n max-width: 100%;\n height: auto;\n}\n.clepit-typeset__glyph {\n fill: currentColor;\n font-family: ui-serif, Georgia, 'Times New Roman', serif;\n}\n.clepit-typeset__glyph--text {\n font-family: inherit;\n}\n.clepit-typeset__rule,\n.clepit-typeset__radical {\n fill: currentColor;\n}\n.clepit-typeset__radical {\n stroke: currentColor;\n stroke-width: 1.2;\n fill: none;\n}\n.clepit-typeset__fallback-reason {\n display: block;\n opacity: 0.7;\n font-size: 0.85em;\n margin-bottom: 6px;\n}\n",eo=Qa,to=Qa,no=.55,ao=.52,oo=(e,t,n)=>e.draw.map(e=>({...e,x:e.x+t,y:e.y+n}));function io(e,t=18){switch(e.kind){case"atom":return ro(e.text,e.style,t);case"space":return{depth:0,draw:[],height:0,width:e.width/18*t};case"row":return function(e,t){const n=[];let a=0,o=0,i=0;for(const r of e){const e=io(r,t);n.push(...oo(e,a,0)),a+=e.width,o=Math.max(o,e.height),i=Math.max(i,e.depth)}return{depth:i,draw:n,height:o,width:a}}(e.items,t);case"script":return function(e,t){const n=io(e.base,t),a=so(t),o=[...n.draw];let i=n.width,r=n.height,s=n.depth;if(null!==e.sup){const s=io(e.sup,a),l=Math.max(.62*n.height,.4*t);o.push(...oo(s,n.width,-l)),i=Math.max(i,n.width+s.width),r=Math.max(r,l+s.height)}if(null!==e.sub){const r=io(e.sub,a),l=Math.max(.5*n.depth,.22*t);o.push(...oo(r,n.width,l)),i=Math.max(i,n.width+r.width),s=Math.max(s,l+r.depth)}return{depth:s,draw:o,height:r,width:i}}(e,t);case"fraction":return function(e,t){const n=io(e.numerator,t),a=io(e.denominator,t),o=.25*t,i=.045*t,r=.18*t,s=Math.max(n.width,a.width)+.3*t,l=-(o+r+n.depth),c=-o+r+a.height;return{depth:c+a.depth,draw:[...oo(n,(s-n.width)/2,l),{kind:"rule",thickness:i,width:s,x:0,y:-o},...oo(a,(s-a.width)/2,c)],height:-l+n.height,width:s}}(e,t);case"radical":return function(e,t){const n=io(e.radicand,t),a=.6*t,o=null===e.index?null:io(e.index,so(so(t))),i=a+.6*(o?.width??0),r=n.height+.18*t,s=[{height:r+n.depth,kind:"radical",size:t,width:n.width+.2*t,x:i,y:0},...oo(n,i+.12*t,0)];null!==o&&s.push(...oo(o,.1*t,.55*-r));return{depth:n.depth,draw:s,height:r,width:i+n.width+.3*t}}(e,t);case"bigop":return function(e,t){const n=1.4*t,a=ro(e.symbol,"upright",n),o=so(t),i=null===e.upper?null:io(e.upper,o),r=null===e.lower?null:io(e.lower,o),s=Math.max(a.width,i?.width??0,r?.width??0),l=[...oo(a,(s-a.width)/2,0)];let c=a.height,d=a.depth;if(null!==i){const e=a.height+i.depth+.16*t;l.push(...oo(i,(s-i.width)/2,-e)),c=e+i.height}if(null!==r){const e=a.depth+r.height+.16*t;l.push(...oo(r,(s-r.width)/2,e)),d=e+r.depth}return{depth:d,draw:l,height:c,width:s}}(e,t);case"accent":return function(e,t){const n=io(e.base,t),a=ro(e.over,"upright",so(t)),o="_"===e.over;return{depth:o?n.depth+.2*t:n.depth,draw:[...n.draw,...oo(a,(n.width-a.width)/2,o?n.depth+.18*t:-(n.height+.04*t))],height:o?n.height:n.height+.2*t,width:n.width}}(e,t);case"delimited":return function(e,t){const n=io(e.body,t),a=n.height+n.depth,o=Math.max(t,a*(1/.55)*.62),i=""===e.open?{depth:0,draw:[],height:0,width:0}:ro(e.open,"upright",o),r=""===e.close?{depth:0,draw:[],height:0,width:0}:ro(e.close,"upright",o),s=e=>(n.height-n.depth)/2-(e.height-e.depth)/2;return{depth:Math.max(n.depth,i.depth-s(i),r.depth-s(r)),draw:[...oo(i,0,s(i)),...oo(n,i.width,0),...oo(r,i.width+n.width,s(r))],height:Math.max(n.height,i.height+s(i),r.height+s(r)),width:i.width+n.width+r.width}}(e,t);case"matrix":return function(e,t){const n=e.rows.map(e=>e.map(e=>io(e,t))),a=Math.max(...n.map(e=>e.length),0),o=[];for(let y=0;y<a;y+=1)o.push(Math.max(...n.map(e=>e[y]?.width??0),0));const i=n.map(e=>Math.max(...e.map(e=>e.height),0)),r=n.map(e=>Math.max(...e.map(e=>e.depth),0)),s=.6*t,l=.35*t,c=o.reduce((e,t)=>e+t,0)+s*Math.max(a-1,0),d=i.reduce((e,t,n)=>e+t+(r[n]??0),0)+l*Math.max(n.length-1,0),p=[];let u=-d/2;for(const[y,x]of n.entries()){u+=i[y]??0;let e=0;for(const[t,n]of x.entries()){const a=o[t]??0;p.push(...oo(n,e+(a-n.width)/2,u)),e+=a+s}u+=(r[y]??0)+l}const[h,m]=lo[e.style],g=Math.max(t,.62*d),b=""===h?{depth:0,draw:[],height:0,width:0}:ro(h,"upright",g),f=""===m?{depth:0,draw:[],height:0,width:0}:ro(m,"upright",g),v=e=>(e.height-e.depth)/2;return{depth:d/2,draw:[...oo(b,0,v(b)),...p.map(e=>({...e,x:e.x+b.width})),...oo(f,b.width+c,v(f))],height:d/2,width:b.width+c+f.width}}(e,t)}}function ro(e,t,n){const a="italic"===t?no:ao;return{depth:.22*n,draw:[{kind:"glyph",size:n,style:t,text:e,x:0,y:0}],height:.72*n,width:e.length*a*n}}function so(e){return Math.max(9,.7*e)}var lo={bracket:["[","]"],"double-pipe":["‖","‖"],paren:["(",")"],pipe:["|","|"],plain:["",""]};var co={alpha:"α",beta:"β",chi:"χ",Delta:"Δ",delta:"δ",epsilon:"ϵ",eta:"η",Gamma:"Γ",gamma:"γ",iota:"ι",kappa:"κ",Lambda:"Λ",lambda:"λ",mu:"μ",nu:"ν",Omega:"Ω",omega:"ω",Phi:"Φ",Pi:"Π",Psi:"Ψ",phi:"ϕ",pi:"π",psi:"ψ",rho:"ρ",Sigma:"Σ",sigma:"σ",Theta:"Θ",tau:"τ",theta:"θ",Upsilon:"Υ",upsilon:"υ",varepsilon:"ε",varphi:"φ",vartheta:"ϑ",Xi:"Ξ",xi:"ξ",zeta:"ζ"},po={angle:"∠",approx:"≈",ast:"∗",cap:"∩",cdot:"⋅",cup:"∪",div:"÷",equiv:"≡",exists:"∃",forall:"∀",geq:"≥",in:"∈",infty:"∞",Leftarrow:"⇐",leftarrow:"←",leftrightarrow:"↔",leq:"≤",mp:"∓",nabla:"∇",neg:"¬",neq:"≠",notin:"∉",parallel:"∥",partial:"∂",perp:"⊥",pm:"±",propto:"∝",Rightarrow:"⇒",rightarrow:"→",sim:"∼",simeq:"≃",star:"⋆",subset:"⊂",subseteq:"⊆",supset:"⊃",supseteq:"⊇",times:"×",to:"→"},uo={bigcap:"⋂",bigcup:"⋃",int:"∫",lim:"lim",oint:"∮",prod:"∏",sum:"∑"},ho=["arccos","arcsin","arctan","cos","cosh","cot","csc","deg","det","dim","exp","gcd","ln","log","max","min","sec","sin","sinh","tan","tanh"],mo={bar:"‾",ddot:"¨",dot:"˙",hat:"^",tilde:"~",vec:"→"},go={",":3,";":5,":":4,"!":-3,qquad:36,quad:18},bo={".":"","(":"(",")":")","[":"[","]":"]","\\{":"{","\\}":"}","\\|":"‖","|":"|"},fo=["catcode","csname","def","href","include","input","newcommand","renewcommand","url","write"],vo={bmatrix:"bracket",matrix:"plain",pmatrix:"paren",Vmatrix:"double-pipe",vmatrix:"pipe"},yo=/[A-Za-z0-9+\-=<>()[\]|,./!:;]/,xo=/[A-Za-z]/,ko=/[0-9]/,wo={mathbf:"bold",mathit:"italic",mathrm:"upright",text:"text"},Co=class{constructor(e){this.source=e,this.at=0}get done(){return this.at>=this.source.length}peek(e=0){return this.source[this.at+e]??""}take(){const e=this.peek();return this.at+=1,e}skipSpace(){for(;!this.done&&/\s/.test(this.peek());)this.at+=1}readCommand(){if(this.at+=1,!xo.test(this.peek()))return this.take();let e="";for(;xo.test(this.peek());)e+=this.take();return e}},Ao=class extends Error{};function So(e){const t=new Co(e);try{const e=Eo(t,null);if(No(t))throw new Ao("a \\right appears without a matching \\left");if(!t.done)throw new Ao(`"${t.peek()}" is unexpected here`);return{ok:!0,root:e}}catch(n){if(n instanceof Ao)return{ok:!1,reason:n.message};throw n}}function Eo(e,t){const n=[];for(;(e.skipSpace(),!e.done)&&("}"!==t||"}"!==e.peek())&&("]"!==t||"]"!==e.peek())&&("cell"!==t||"&"!==e.peek()&&!Lo(e)&&!Bo(e))&&!No(e);){const t=$o(e);if(null===t)break;n.push(t)}return(e=>1===e.length&&void 0!==e[0]?e[0]:{items:e,kind:"row"})(n)}function Lo(e){return"\\"===e.peek()&&"\\"===e.peek(1)}function No(e){return!!e.source.startsWith("\\right",e.at)&&!xo.test(e.peek(6))}function Bo(e){return"\\"===e.peek()&&e.source.startsWith("\\end",e.at)}function $o(e){const t=Mo(e);if(null===t)return null;let n=null,a=null;for(;;){e.skipSpace();const t=e.peek();if("^"!==t&&"_"!==t)break;e.take();const o=Mo(e);if(null===o)throw new Ao(`"${t}" has nothing after it`);if("^"===t){if(null!==a)throw new Ao("a term carries two superscripts");a=o}else{if(null!==n)throw new Ao("a term carries two subscripts");n=o}}return null===n&&null===a?t:"bigop"===t.kind?{...t,lower:n,upper:a}:{base:t,kind:"script",sub:n,sup:a}}function Mo(e){if(e.skipSpace(),e.done)return null;const t=e.peek();if("}"===t||"&"===t||"^"===t||"_"===t)return null;if("{"===t){e.take();const t=Eo(e,"}");if("}"!==e.peek())throw new Ao("a { group is never closed");return e.take(),t}if("\\"===t)return function(e){const t=e.readCommand();if(fo.includes(t))throw new Ao(`"\\${t}" is refused for safety, not merely unsupported`);if("\\"===t)throw new Ao("a row break appears outside a matrix");if("begin"===t)return function(e){const t=To(e),n=vo[t];if(void 0===n)throw new Ao(`the "${t}" environment is not supported yet`);const a=[];let o=[];for(let i=0;i<4096;i+=1)if(o.push(Eo(e,"cell")),e.skipSpace(),"&"!==e.peek()){if(!Lo(e)){if(Bo(e)){e.at+=4;const i=To(e);if(i!==t)throw new Ao(`\\begin{${t}} is closed by \\end{${i}}`);return a.push(o),{kind:"matrix",rows:a,style:n}}throw new Ao(`\\begin{${t}} is never closed`)}e.at+=2,a.push(o),o=[]}else e.take();throw new Ao(`\\begin{${t}} is never closed`)}(e);if("end"===t)throw new Ao("an \\end appears without a matching \\begin");if("frac"===t||"dfrac"===t||"tfrac"===t){const t=Io(e);return{denominator:Io(e),kind:"fraction",numerator:t}}if("sqrt"===t)return function(e){e.skipSpace();let t=null;if("["===e.peek()){if(e.take(),t=Eo(e,"]"),"]"!==e.peek())throw new Ao("a \\sqrt index is never closed");e.take()}return{index:t,kind:"radical",radicand:Io(e)}}(e);if("left"===t)return function(e){const t=_o(e,"left"),n=Eo(e,null);if(!No(e))throw new Ao("a \\left has no matching \\right");return e.at+=6,{body:n,close:_o(e,"right"),kind:"delimited",open:t}}(e);if("right"===t)throw new Ao("a \\right appears without a matching \\left");const n=wo[t];if(void 0!==n)return{kind:"atom",style:n,text:To(e)};const a=mo[t];if(void 0!==a)return{base:Io(e),kind:"accent",over:a};if("overline"===t)return{base:Io(e),kind:"accent",over:"‾"};if("underline"===t)return{base:Io(e),kind:"accent",over:"_"};const o=uo[t];if(void 0!==o)return{kind:"bigop",lower:null,symbol:o,upper:null};const i=co[t];if(void 0!==i)return{kind:"atom",style:"italic",text:i};const r=po[t];if(void 0!==r)return{kind:"atom",style:"upright",text:r};if(ho.includes(t))return{kind:"atom",style:"upright",text:t};const s=go[t];if(void 0!==s)return{kind:"space",width:s};const l=bo[`\\${t}`];if(void 0!==l)return{kind:"atom",style:"upright",text:l};throw new Ao(`"\\${t}" is not supported yet`)}(e);if(yo.test(t))return e.take(),{kind:"atom",style:ko.test(t)?"upright":"italic",text:t};throw new Ao(`"${t}" is not a character this engine understands`)}function Io(e){if(e.skipSpace(),"{"!==e.peek()){const t=Mo(e);if(null===t)throw new Ao("a command is missing its argument");return t}e.take();const t=Eo(e,"}");if("}"!==e.peek())throw new Ao("a { group is never closed");return e.take(),t}function To(e){if(e.skipSpace(),"{"!==e.peek())throw new Ao("a text command is missing its { group");e.take();let t="",n=1;for(;!e.done;){const a=e.peek();if("{"===a&&(n+=1),"}"===a&&(n-=1,0===n))return e.take(),t;t+=e.take()}throw new Ao("a text command’s { group is never closed")}function _o(e,t){e.skipSpace();const n=e.peek();if("\\"===n){const t=e.readCommand(),n=bo[`\\${t}`];if(void 0===n)throw new Ao(`"\\${t}" is not a delimiter this engine understands`);return n}const a=bo[n];if(void 0===a)throw new Ao(`\\${t} is missing a delimiter`);return e.take(),a}var qo={bold:{style:"normal",weight:"700"},italic:{style:"italic",weight:"400"},text:{style:"normal",weight:"400"},upright:{style:"normal",weight:"400"}};function Do(e,t,n){const a=n.createNS("http://www.w3.org/2000/svg",e);for(const[o,i]of Object.entries(t))a.setAttribute(o,String(i));return a}function zo(e,t=R){const n=e.width+16,a=e.height+e.depth+16,o=e.height+8,i=Do("svg",{class:"clepit-typeset__formula",height:a,role:"img",viewBox:`0 0 ${n} ${a}`,width:n},t);for(const r of e.draw){if("glyph"===r.kind){const e=qo[r.style],n=Do("text",{class:"clepit-typeset__glyph","dominant-baseline":"alphabetic","font-size":r.size,"font-style":e.style,"font-weight":e.weight,x:r.x+8,y:o+r.y},t);"text"===r.style&&n.setAttribute("class","clepit-typeset__glyph clepit-typeset__glyph--text"),n.setText(r.text),i.append(n);continue}"rule"!==r.kind?i.append(jo(r,o,t)):i.append(Do("rect",{class:"clepit-typeset__rule",height:r.thickness,width:r.width,x:r.x+8,y:o+r.y-r.thickness/2},t))}return i}function jo(e,t,n){const a=e.x+8,o=t+e.y-e.height,i=t+e.y,r=.32*e.size;return Do("path",{class:"clepit-typeset__radical",d:[`M ${a-1.6*r} ${i-.45*e.height}`,`L ${a-.9*r} ${i-.55*e.height}`,`L ${a-.2*r} ${i}`,`L ${a+.35*r} ${o}`,`L ${a+e.width} ${o}`].join(" "),fill:"none"},n)}var Ho=72,Oo=40,Po=28,Ro=16;function Fo(e){return"flowchart"===e.kind?function(e){const t="LR"===e.direction||"RL"===e.direction,n=function(e){const t=/* @__PURE__ */new Map;for(const a of e.nodes)t.set(a.id,0);const n=function(e){const t=/* @__PURE__ */new Map;for(const o of e.edges)t.set(o.from,[...t.get(o.from)??[],o]);const n=/* @__PURE__ */new Map,a=/* @__PURE__ */new Set;for(const o of e.nodes){if(n.has(o.id))continue;n.set(o.id,"visiting");const e=[{id:o.id,index:0}];for(;e.length>0;){const o=e[e.length-1],i=t.get(o.id)??[];if(o.index>=i.length){n.set(o.id,"done"),e.pop();continue}const r=i[o.index];o.index+=1;const s=n.get(r.to);"visiting"===s?a.add(r):void 0===s&&(n.set(r.to,"visiting"),e.push({id:r.to,index:0}))}}return e.edges.filter(e=>!a.has(e))}(e);for(let a=0;a<e.nodes.length;a+=1){let e=!1;for(const a of n){if(a.from===a.to)continue;const n=(t.get(a.from)??0)+1;n>(t.get(a.to)??0)&&(t.set(a.to,n),e=!0)}if(!e)break}return t}(e),a=/* @__PURE__ */new Map;for(const b of e.nodes){const e=n.get(b.id)??0;a.set(e,[...a.get(e)??[],b.id])}const o=/* @__PURE__ */new Map;for(const b of e.nodes)o.set(b.id,Vo(b.label,Ho));const i=/* @__PURE__ */new Map,r=[...a.keys()].sort((e,t)=>e-t),s=e=>t?e.length*Oo+(e.length-1)*Po:e.reduce((e,t)=>e+(o.get(t)??Ho),0)+(e.length-1)*Po,l=Math.max(...r.map(e=>s(a.get(e)??[])),0);for(const b of r){const n=a.get(b)??[],r=Ro+b*((t?Ho:Oo)+64);let c=Ro+(l-s(n))/2;for(const a of n){const n=e.nodes.find(e=>e.id===a);if(void 0===n)continue;const s=o.get(a)??Ho;i.set(a,{height:Oo,id:a,label:n.label,shape:n.shape,width:s,x:t?r:c,y:t?c:r}),c+=(t?Oo:s)+Po}}const c=e.nodes.map(e=>i.get(e.id)).filter(e=>void 0!==e),d=Math.max(...c.map(e=>e.x+e.width),0),p=Math.max(...c.map(e=>e.y+e.height),0),u=(t?p:d)+24,h=e.edges.map(e=>function(e,t,n,a){const o=t.get(e.from),i=t.get(e.to);if(void 0===o||void 0===i)return null;if(n?i.x<o.x:i.y<o.y){const t=n?{x:o.x+o.width/2,y:o.y+o.height}:{x:o.x+o.width,y:o.y+o.height/2},r=n?{x:i.x+i.width/2,y:i.y+i.height}:{x:i.x+i.width,y:i.y+i.height/2},s=n?{x:t.x,y:a}:{x:a,y:t.y},l=n?{x:r.x,y:a}:{x:a,y:r.y};return{arrow:e.arrow,label:e.label,labelX:(s.x+l.x)/2,labelY:(s.y+l.y)/2,line:e.line,points:[t,s,l,r]}}const r=n?{x:o.x+o.width,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height},s=n?{x:i.x,y:i.y+i.height/2}:{x:i.x+i.width/2,y:i.y};return{arrow:e.arrow,label:e.label,labelX:(r.x+s.x)/2,labelY:(r.y+s.y)/2,line:e.line,points:[r,s]}}(e,i,t,u)).filter(e=>null!==e),m=h.some(e=>e.points.length>2),g=t?d:Math.max(d,m?u:0);return{edges:h,height:(t?Math.max(p,m?u:0):p)+Ro,kind:"flowchart",nodes:c,width:g+Ro}}(e):function(e){const t=[];let n=Ro;for(const h of e.participants){const e=Vo(h.label,96);t.push({actor:h.actor,centerX:n+e/2,headHeight:36,headWidth:e,id:h.id,label:h.label}),n+=e+Po}const a=e=>t.find(t=>t.id===e)?.centerX??null,o=[],i=[],r=[],s=/* @__PURE__ */new Map;let l=100;const c=(e,t)=>{const n=s.get(e),o=a(e);void 0!==n&&null!==o&&(r.push({height:Math.max(t-n,24),width:10,x:o-5,y:n}),s.delete(e))};for(const h of e.steps){if("activation"===h.kind){h.active?s.set(h.participant,l):c(h.participant,l);continue}if("note"===h.kind){const e=h.targets.map(a).filter(e=>null!==e);if(0===e.length)continue;const t=Vo(h.text,96),n=Math.min(...e),o=Math.max(...e),r="left"===h.placement?n-t-Po:"right"===h.placement?o+Po:(n+o)/2-t/2;i.push({height:34,text:h.text,width:t,x:r,y:l}),l+=62;continue}const e=a(h.from),t=a(h.to);null!==e&&null!==t&&(h.activate&&s.set(h.to,l),o.push({end:h.end,fromX:e,line:h.line,selfCall:h.from===h.to,text:h.text,toX:t,y:l}),l+=48,h.deactivate&&c(h.to,l))}const d=l;for(const h of[...s.keys()])c(h,d);const p=Math.max(...i.map(e=>e.x+e.width),0),u=Math.max(n-Po+Ro,p+Ro);return{activations:r,height:d+Ro,kind:"sequence",lifelineBottom:d,lifelines:t,messages:o,notes:i,width:u}}(e)}function Vo(e,t){return Math.max(t,Math.round(7.2*e.length)+32)}var Uo=["BT","LR","RL","TB","TD"],Wo=["subgraph","end","click","style","classDef","class","linkStyle","direction"],Ko=["loop","alt","else","opt","par","and","critical","option","break","rect","box","autonumber","end"],Go=[{arrow:!0,line:"dotted",token:"-.->"},{arrow:!0,line:"thick",token:"==>"},{arrow:!0,line:"solid",token:"--\x3e"},{arrow:!1,line:"thick",token:"==="},{arrow:!1,line:"solid",token:"---"},{arrow:!1,line:"dotted",token:"-.-"}],Jo=[{end:"arrow",line:"dotted",token:"--\x3e>"},{end:"arrow",line:"solid",token:"->>"},{end:"cross",line:"dotted",token:"--x"},{end:"cross",line:"solid",token:"-x"},{end:"none",line:"dotted",token:"--\x3e"},{end:"none",line:"solid",token:"->"}],Xo=[{close:"]]",open:"[[",shape:"subroutine"},{close:"])",open:"([",shape:"stadium"},{close:"))",open:"((",shape:"circle"},{close:"]",open:"[",shape:"rect"},{close:"}",open:"{",shape:"rhombus"},{close:")",open:"(",shape:"round"}],Yo=e=>({ok:!1,reason:e});function Zo(e){return e.split(/[\s(]/,1)[0]??""}function Qo(e){const t=function(e){return e.split("\n").map(e=>function(e){const t=e.indexOf("%%");return-1===t?e:e.slice(0,t)}(e).trim()).filter(e=>e.length>0)}(e);if(0===t.length)return Yo("the block is empty");const[n,...a]=t,o=Zo(n??"");return"sequenceDiagram"===o?function(e){const t=/* @__PURE__ */new Map,n=[],a=e=>(t.has(e)||t.set(e,{actor:!1,id:e,label:e}),e);for(const o of e){const e=Zo(o);if(Ko.includes(e))return Yo(`"${e}" is not supported yet`);if("participant"===e||"actor"===e){const n=ii(o,e);if(null===n)return Yo(`"${o}" is not a participant declaration this engine understands`);t.set(n.id,n);continue}if("activate"===e||"deactivate"===e){const t=o.slice(e.length).trim();if(!oi(t))return Yo(`"${o}" does not name a participant to ${e}`);n.push({active:"activate"===e,kind:"activation",participant:a(t)});continue}if("Note"===e||"note"===e){const e=ri(o);if(null===e)return Yo(`"${o}" is not a note this engine understands`);for(const t of e.targets)a(t);n.push(e);continue}const i=si(o);if(null===i)return Yo(`"${o}" is not a message this engine understands`);a(i.from),a(i.to),n.push(i)}return{model:{kind:"sequence",participants:[...t.values()],steps:n},ok:!0}}(a):"flowchart"===o||"graph"===o?function(e,t){const n=e.slice(Zo(e).length).trim();if(0===n.length)return Yo('the flowchart header is missing a direction, e.g. "flowchart TD"');const a=Uo.find(e=>e===n);if(void 0===a)return Yo(`"${n}" is not a supported direction: use TD, TB, BT, LR or RL`);const o=/* @__PURE__ */new Map,i=[];for(const r of t){const e=Zo(r);if(Wo.includes(e))return Yo(`"${e}" is not supported yet`);if(r.includes("&"))return Yo('"&" fan-out is not supported yet');const t=ei(r,o,i);if(null!==t)return Yo(t)}return{model:{direction:a,edges:i,kind:"flowchart",nodes:[...o.values()]},ok:!0}}(n??"",a):Yo(`"${o}" diagrams are not supported yet (only flowchart and sequenceDiagram are)`)}function ei(e,t,n){const a=function(e){const t=[],n=[];let a=e.trim();for(let o=0;o<64;o+=1){const e=ti(a);if(null===e)return t.push(a.trim()),t.every(e=>e.length>0)?{links:n,terms:t}:null;t.push(a.slice(0,e.at).trim()),n.push({arrow:e.arrow,label:e.label,line:e.line}),a=a.slice(e.at+e.length)}return null}(e);if(null===a)return`"${e}" is not a node or edge this engine understands`;const o=[];for(const i of a.terms){const e=ai(i);if(null===e)return`"${i}" is not a node declaration this engine understands`;t.has(e.id)||t.set(e.id,e),o.push(e)}for(const[i,r]of a.links.entries()){const t=o[i],a=o[i+1];if(void 0===t||void 0===a)return`"${e}" has a link with nothing on one side of it`;n.push({arrow:r.arrow,from:t.id,label:r.label,line:r.line,to:a.id})}return null}function ti(e){const t=function(e){const t=/--\s+([^->|][^-]*?)\s+(-->|---|-\.->|-\.-|==>|===)/.exec(e);if(null===t||void 0===t.index)return null;const n=Go.find(e=>e.token===t[2]);return void 0===n?null:{arrow:n.arrow,at:t.index,label:(t[1]??"").trim(),length:t[0].length,line:n.line}}(e);if(null!==t)return t;let n=null;for(const a of Go){const t=e.indexOf(a.token);if(-1===t)continue;if(null!==n&&t>=n.at)continue;const o=ni(e,t+a.token.length);n={arrow:a.arrow,at:t,label:o.label,length:a.token.length+o.consumed,line:a.line}}return n}function ni(e,t){if("|"!==e[t])return{consumed:0,label:null};const n=e.indexOf("|",t+1);return-1===n?{consumed:0,label:null}:{consumed:n-t+1,label:e.slice(t+1,n).trim()}}function ai(e){const t=e.trim();if(0===t.length)return null;for(const n of Xo){const e=t.indexOf(n.open);if(e<=0||!t.endsWith(n.close))continue;const a=t.slice(0,e).trim(),o=t.slice(e+n.open.length,t.length-n.close.length);if(oi(a))return{id:a,label:o.trim(),shape:n.shape}}return oi(t)?{id:t,label:t,shape:"rect"}:null}function oi(e){return/^[A-Za-z_][\w-]*$/.test(e)}function ii(e,t){const n=e.slice(t.length).trim(),a=/ as /.exec(n),o=(null===a?n:n.slice(0,a.index)).trim();if(!oi(o))return null;const i=null===a?o:n.slice(a.index+a[0].length).trim();return{actor:"actor"===t,id:o,label:0===i.length?o:i}}function ri(e){const t=e.slice(Zo(e).length).trim(),n=t.indexOf(":");if(-1===n)return null;const a=t.slice(0,n).trim(),o=t.slice(n+1).trim(),i=/^over\s+(.+)$/i.exec(a);if(null!==i){const e=(i[1]??"").split(",").map(e=>e.trim());return e.every(oi)?{kind:"note",placement:"over",targets:e,text:o}:null}const r=/^(left|right)\s+of\s+(.+)$/i.exec(a);if(null===r)return null;const s=(r[2]??"").trim();return oi(s)?{kind:"note",placement:(r[1]??"").toLowerCase(),targets:[s],text:o}:null}function si(e){const t=e.indexOf(":");if(-1===t)return null;const n=e.slice(0,t),a=e.slice(t+1).trim();for(const o of Jo){const e=n.indexOf(o.token);if(-1===e)continue;const t=n.slice(0,e).trim(),i=n.slice(e+o.token.length).trim(),r=i.startsWith("+")||i.startsWith("-")?i[0]:null,s=null===r?i:i.slice(1).trim();if(oi(t)&&oi(s))return{activate:"+"===r,deactivate:"-"===r,end:o.end,from:t,kind:"message",line:o.line,text:a,to:s}}return null}var li={dotted:"5 4",solid:"",thick:""},ci={dotted:1.5,solid:1.5,thick:3};function di(e,t,n){const a=n.createNS("http://www.w3.org/2000/svg",e);for(const[o,i]of Object.entries(t))a.setAttribute(o,String(i));return a}function pi(e,t,n,a,o){const i=di("text",{class:a,"dominant-baseline":"middle","text-anchor":"middle",x:t,y:n},o);return i.setText(e),i}function ui(e,t=R){const n=di("svg",{class:"clepit-typeset__diagram",height:e.height,role:"img",viewBox:`0 0 ${e.width} ${e.height}`,width:e.width},t);return n.append(function(e){const t=di("defs",{},e),n=di("marker",{id:"clepit-mermaid-arrow",markerHeight:7,markerUnits:"strokeWidth",markerWidth:7,orient:"auto-start-reverse",refX:7,refY:3.5},e);return n.append(di("path",{class:"clepit-typeset__arrowhead",d:"M 0 0 L 7 3.5 L 0 7 z"},e)),t.append(n),t}(t)),"flowchart"===e.kind?function(e,t,n){for(const a of t.edges)mi(e,a,n);for(const a of t.nodes)hi(e,a,n)}(n,e,t):function(e,t,n){for(const a of t.lifelines){e.append(di("line",{class:"clepit-typeset__lifeline",x1:a.centerX,x2:a.centerX,y1:a.headHeight+16,y2:t.lifelineBottom},n));const o={class:a.actor?"clepit-typeset__node clepit-typeset__actor":"clepit-typeset__node",height:a.headHeight,rx:a.actor?a.headHeight/2:4,ry:a.actor?a.headHeight/2:4,width:a.headWidth,x:a.centerX-a.headWidth/2,y:16};e.append(di("rect",o,n)),e.append(pi(a.label,a.centerX,16+a.headHeight/2,"clepit-typeset__label",n))}for(const a of t.activations)e.append(di("rect",{class:"clepit-typeset__activation",height:a.height,width:a.width,x:a.x,y:a.y},n));for(const a of t.messages)gi(e,a,n);for(const a of t.notes)e.append(di("rect",{class:"clepit-typeset__note",height:a.height,width:a.width,x:a.x,y:a.y},n)),e.append(pi(a.text,a.x+a.width/2,a.y+a.height/2,"clepit-typeset__label",n))}(n,e,t),n}function hi(e,t,n){e.append(function(e,t){const{height:n,shape:a,width:o,x:i,y:r}=e,s={class:"clepit-typeset__node"};if("circle"===a)return di("ellipse",{...s,cx:i+o/2,cy:r+n/2,rx:o/2,ry:n/2},t);if("rhombus"===a){const e=`${i+o/2},${r} ${i+o},${r+n/2} ${i+o/2},${r+n} ${i},${r+n/2}`;return di("polygon",{...s,points:e},t)}if("stadium"===a)return di("rect",{...s,height:n,rx:n/2,ry:n/2,width:o,x:i,y:r},t);if("round"===a)return di("rect",{...s,height:n,rx:10,ry:10,width:o,x:i,y:r},t);if("subroutine"===a){const e=di("g",{},t);return e.append(di("rect",{...s,height:n,rx:8,ry:8,width:o,x:i,y:r},t)),e.append(di("line",{...s,x1:i+6,x2:i+6,y1:r,y2:r+n},t)),e.append(di("line",{...s,x1:i+o-6,x2:i+o-6,y1:r,y2:r+n},t)),e}return di("rect",{...s,height:n,rx:8,ry:8,width:o,x:i,y:r},t)}(t,n)),e.append(pi(t.label,t.x+t.width/2,t.y+t.height/2,"clepit-typeset__label",n))}function mi(e,t,n){const[a,o]=t.points;if(void 0===a||void 0===o)return;const i=t.points.length>2?di("polyline",{class:"clepit-typeset__edge",fill:"none",points:t.points.map(e=>`${e.x},${e.y}`).join(" "),"stroke-dasharray":li[t.line],"stroke-width":ci[t.line]},n):di("line",{class:"clepit-typeset__edge","stroke-dasharray":li[t.line],"stroke-width":ci[t.line],x1:a.x,x2:o.x,y1:a.y,y2:o.y},n);if(t.arrow&&i.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(i),null!==t.label){const a=pi(t.label,t.labelX,t.labelY,"clepit-typeset__edge-label",n);a.setAttribute("paint-order","stroke"),e.append(a)}}function gi(e,t,n){const a={class:"clepit-typeset__message","stroke-dasharray":li[t.line],"stroke-width":ci[t.line]};if(t.selfCall){const o=`M ${t.fromX} ${t.y} h 28 v 18 h -28`,i=di("path",{...a,d:o,fill:"none"},n);return"arrow"===t.end&&i.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(i),void e.append(pi(t.text,t.fromX+52,t.y+9,"clepit-typeset__edge-label",n))}const o=di("line",{...a,x1:t.fromX,x2:t.toX,y1:t.y,y2:t.y},n);if("arrow"===t.end&&o.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(o),"cross"===t.end){const o=t.toX+(t.toX>t.fromX?-5:5);e.append(di("line",{...a,x1:o-5,x2:o+5,y1:t.y-5,y2:t.y+5},n)),e.append(di("line",{...a,x1:o-5,x2:o+5,y1:t.y+5,y2:t.y-5},n))}e.append(pi(t.text,(t.fromX+t.toX)/2,t.y-8,"clepit-typeset__edge-label",n))}var bi=class e{static render(t,n,a,o,i){if(l.injectStyles("typeset-output",to),!e.validate(n))return X();const r=l.createStyledElement("div",`clepit-typeset clepit-output-typeset clepit-typeset--${t.toLowerCase()}`,{classNames:i?.wrapper,styles:o?.wrapper});if(r.setAttribute("data-language",t.toLowerCase()),n.title){const e=document.createElement("span");e.className="clepit-typeset__title",e.textContent=n.title,e.setAttribute("data-testid","typeset-title"),r.appendChild(e)}if("Mermaid"===t){const a=Qo(n.source);return a.ok?(r.setAttribute("data-rendered","diagram"),r.appendChild(J(ui(Fo(a.model)))),r):e.appendFallback(r,n.source,a.reason,t)}if(0===n.source.trim().length)return e.appendFallback(r,n.source,null,t);const s=So(n.source);return s.ok?(r.setAttribute("data-rendered","formula"),r.appendChild(J(zo(io(s.root)))),r):e.appendFallback(r,n.source,s.reason,t)}static appendFallback(e,t,n,a){e.setAttribute("data-rendered","source");const o=document.createElement("span");if(o.className="clepit-typeset__kind",o.textContent=a,e.prepend(o),null!==n){const t=document.createElement("span");t.className="clepit-typeset__fallback-reason",t.textContent=n,e.appendChild(t)}const i=document.createElement("pre");return i.className="clepit-typeset__source",i.textContent=t,e.appendChild(i),e}static draw(t,n,a=R){if(!e.validate(n))return null;const o=a.create("div");o.addClass("clepit-typeset","clepit-output-typeset",`clepit-typeset--${t.toLowerCase()}`),o.setAttribute("data-language",t.toLowerCase());const i=()=>{if(!n.title)return;const e=a.create("span");e.addClass("clepit-typeset__title"),e.setText(n.title),e.setAttribute("data-testid","typeset-title"),o.append(e)};if("Mermaid"===t){const r=Qo(n.source);return r.ok?(o.setAttribute("data-rendered","diagram"),i(),o.append(ui(Fo(r.model),a)),o):e.drawFallback(o,n,r.reason,t,a,i)}if(0===n.source.trim().length)return e.drawFallback(o,n,null,t,a,i);const r=So(n.source);return r.ok?(o.setAttribute("data-rendered","formula"),i(),o.append(zo(io(r.root),a)),o):e.drawFallback(o,n,r.reason,t,a,i)}static drawFallback(e,t,n,a,o,i){e.setAttribute("data-rendered","source");const r=o.create("span");if(r.addClass("clepit-typeset__kind"),r.setText(a),e.append(r),i(),null!==n){const t=o.create("span");t.addClass("clepit-typeset__fallback-reason"),t.setText(n),e.append(t)}const s=o.create("pre");return s.addClass("clepit-typeset__source"),s.setText(t.source),e.append(s),e}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.source&&(void 0===e.title||"string"==typeof e.title)}},fi=class{static render(e,t,n,a){return bi.render("LaTeX",e,t,n,a)}static draw(e,t=R){return bi.draw("LaTeX",e,t)}},vi=class{static render(e,t,n,a){return bi.render("Mermaid",e,t,n,a)}static draw(e,t=R){return bi.draw("Mermaid",e,t)}},yi="\n.clepit-updates {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n color: inherit;\n}\n.clepit-updates__icon {\n font-size: 18px;\n line-height: 1;\n}\n.clepit-updates__label {\n opacity: 0.7;\n}\n",xi=yi,ki=yi,wi=class{static render(e,t,n,a){l.injectStyles("updates-output",ki);const o=l.createStyledElement("div","clepit-updates clepit-output-updates",{classNames:a?.wrapper,styles:n?.wrapper});e?.pageId&&o.setAttribute("data-page-id",e.pageId);const i=document.createElement("span");i.className="clepit-updates__icon",i.textContent="🕘",o.appendChild(i);const r=document.createElement("span");return r.className="clepit-updates__label",r.textContent="Updates",o.appendChild(r),o}static draw(e,t=R){if(null==e||"object"!=typeof e)return null;const n=t.create("div");n.addClass("clepit-updates","clepit-output-updates"),e.pageId&&n.setAttribute("data-page-id",e.pageId);const a=t.create("span");a.addClass("clepit-updates__icon"),a.setText("🕘"),n.append(a);const o=t.create("span");return o.addClass("clepit-updates__label"),o.setText("Updates"),n.append(o),n}},Ci=`\n/* Video block styles */\n.clepit-video-container {\n margin: 16px 0;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 100%;\n box-sizing: border-box;\n}\n\n.clepit-video-wrapper {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.clepit-video-wrapper:hover {\n opacity: 0.9;\n}\n\n.clepit-video {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n display: block;\n}\n\n.clepit-video-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-video-wrapper--center {\n justify-content: center;\n}\n\n.clepit-video-wrapper--right {\n justify-content: flex-end;\n}\n\n.clepit-video-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-video-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-video-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-video-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Video caption styling */\n.clepit-video-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Video caption placeholder styles */\n.clepit-video-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Video Drop Area */\n.clepit-video-drop-area {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n}\n\n.clepit-video-drop-area:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-video-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-video-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-video-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n}\n\n.clepit-video-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Video Loading State */\n.clepit-video-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-video-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-video-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Video Error State */\n.clepit-video-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-video-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-video-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-video-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-video-error-retry:hover {\n background: var(--clepit-error);\n}\n\n/* Video caption placeholder */\n.clepit-video-caption-placeholder {\n color: var(--clepit-text-subtle);\n}\n\n/* Video delete button */\n.${l.classNames.block.videoDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${l.classNames.block.videoDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Video drop area delete button */\n.clepit-video-drop-area .${l.classNames.block.videoDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-video-drop-area .${l.classNames.block.videoDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,Ai="\n/* Output video styles */\n.clepit-output-video-container {\n margin: 1rem 0;\n text-align: center;\n}\n\n.clepit-output-video {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n}\n\n.clepit-output-video-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Output video alignment */\n.clepit-output-video-wr--left {\n justify-content: flex-start;\n}\n\n.clepit-output-video-wr--center {\n justify-content: center;\n}\n\n.clepit-output-video-wr--right {\n justify-content: flex-end;\n}\n",Si=class e{static{this.placeholder="Add a caption..."}static{this.eventListenersMap={}}static{this.validTypes=["video/mp4","video/webm","video/ogg","video/ogv"]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("video"),n=e.querySelector("iframe"),a=e.querySelector(`.${l.classNames.block.video.captionEditable}`),o=e.querySelector(`.${l.classNames.block.video.wrapper}`);let i="center";o&&(i=o.classList.contains("clepit-video-wrapper--left")?"left":o.classList.contains("clepit-video-wrapper--right")?"right":"center");let r="",s="";return t?(r=t.getAttribute("src")||"",s=t.getAttribute("alt")||""):n&&(r=n.getAttribute("src")||"",s="Embedded video"),{alignment:i,alt:s,caption:m(a?.innerHTML),url:r}}static render(t,n,a,o){l.injectStyles("clepit-video-input-styles",Ci);const i=a||{alt:"",caption:"",url:""},r=l.createStyledElement("div",l.classNames.block.video.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return i.url?e.renderVideo(r,i,t,n,o):e.renderDropArea(r,t,n,o),r}static renderVideo(t,n,a,o,i){t.innerHTML="";const r=l.createStyledElement("div",l.classNames.block.video.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("clepit-video-wrapper--left");break;case"center":r.classList.add("clepit-video-wrapper--center");break;case"right":r.classList.add("clepit-video-wrapper--right")}const s=bt(n?.url||""),c=ft(n?.url||"");if(s||c){const e=l.createStyledElement("iframe",l.classNames.block.video.iframe,{classNames:i?.classNames?.container,styles:i?.styles?.container});e.src=n?.url||"",e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),e.style.maxWidth="100%",e.style.width="560px",e.style.height="315px",e.style.display="block",e.style.borderRadius="8px",r.appendChild(e)}else{const e=l.createStyledElement("video",l.classNames.block.video.video,{classNames:i?.classNames?.container,styles:i?.styles?.container});e.setAttribute("alt",n?.alt||""),e.src=n?.url||"",e.controls=!0,r.appendChild(e)}const d=l.createStyledElement("div","clepit-video-caption-container",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});d.classList.add("clepit-video-caption-container");const p=l.createStyledElement("div",l.classNames.block.video.captionEditable,{classNames:i?.classNames?.caption,styles:i?.styles?.caption});p.setAttribute("contenteditable","true"),p.setAttribute("data-placeholder",ne(o,"mediaCaptionHint",e.placeholder)),p.innerHTML=m(n?.caption),e.addEventListener(o,p,"input",_s.handleInput),e.addEventListener(o,p,"keydown",_s.handleKeydown),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),d.appendChild(p),t.appendChild(r),t.appendChild(d),p.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const i=l.createStyledElement("div",l.classNames.block.video.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});i.setAttribute("tabindex","0"),i.classList.add("clepit-drop-area");const r=l.createStyledElement("div","clepit-video-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});r.textContent="🎥";const s=l.createStyledElement("div","clepit-video-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text});s.innerHTML='<strong>Drop a video here</strong><br>or <span class="clepit-video-click-text">click to select</span>';const c=l.createStyledElement("button",`${l.classNames.block.videoDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});c.type="button",c.textContent="✕",i.appendChild(r),i.appendChild(s),i.appendChild(c),e.addEventListener(a,c,"click",e=>{e.preventDefault(),e.stopPropagation();const t=c.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");t&&_s.removeBlock(a,_s.getBlockIndex(a,t))}),e.addEventListener(a,i,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,i,"dragleave",()=>{i.classList.remove("clepit-video-drop-area--dragover")}),e.addEventListener(a,i,"dragover",e=>{e.preventDefault(),e.stopPropagation(),i.classList.add("clepit-video-drop-area--dragover")}),e.addEventListener(a,i,"drop",r=>{r.preventDefault(),r.stopPropagation(),i.classList.remove("clepit-video-drop-area--dragover"),e.handleFileDrop(r,t,n,a,o)}),e.addEventListener(a,i,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,i,"mousedown",e=>{e.preventDefault(),e.stopPropagation()});const d=a?C.getState().getInstance(a):null,p=d?.config.classNames?.tooltips,u=d?.config.styles?.tooltips;ye(c,"Delete block","below",p,u),t.appendChild(i)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidVideoFile(t)?e.processVideoFile(t,n,a,o,i):e.showError(n,"Please select a valid video file (MP4, WebM, OGV)")}}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="video/*",i.style.display="none",i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidVideoFile(i)?e.processVideoFile(i,t,n,a,o):e.showError(t,"Please select a valid video file (MP4, WebM, OGV)")}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static isValidVideoFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("video/")}static async processVideoFile(t,n,a,o,i){e.showLoading(n);try{let r=await a(t);if(r){e.renderVideo(n,{alignment:"center",alt:t.name,caption:"",url:r},a,o,i);const s=n.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");s&&C.getState().updateBlockData(o,_s.getBlockIndex(o,s),_s.getBlockData(s).data)}else e.showError(n,"Failed to upload video. Please try again.")}catch(r){console.error("Video upload error:",r),e.showError(n,"Failed to upload video. Please try again.")}}static showLoading(e){e.innerHTML="";const t=l.createStyledElement("div","clepit-video-loading",void 0);t.textContent="Uploading video...",e.appendChild(t)}static showError(e,t){e.innerHTML="";const n=l.createStyledElement("div","clepit-video-error",void 0);n.textContent=t,e.appendChild(n)}static setAlignment(e,t){const n=e.querySelector(".clepit-video-wrapper");n&&(n.classList.remove("clepit-video-wrapper--left","clepit-video-wrapper--center","clepit-video-wrapper--right"),n.classList.add(`clepit-video-wrapper--${t}`));const a=_s.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&C.getState().partialUpdateBlockData(a,_s.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${l.classNames.block.video.wrapper} video`),n=e.querySelector(`.${l.classNames.block.video.wrapper} iframe`),a=e.querySelector(`.${l.classNames.block.video.captionEditable}`);let o=!1,i=!1,r=!1;return t&&t.getAttribute("src")?.trim()||(o=!0),n&&n.getAttribute("src")?.trim()||(i=!0),a?h(a.innerHTML)&&(r=!0):r=!0,o&&i&&r}static isEmptyData(e){return!e.url?.trim()&&h(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Ei=class e{static render(t,n,a,o){if(l.injectStyles("clepit-video-output-styles",Ai),!e.validate(t))return X();if(Si.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alignment||"center",c=l.createStyledElement("div","clepit-output-video-container",{classNames:o?.container,styles:a?.container}),d=l.createStyledElement("div","clepit-output-video-wrapper");switch(s){case"left":d.classList.add("clepit-output-video-wrapper--left");break;case"center":d.classList.add("clepit-output-video-wrapper--center");break;case"right":d.classList.add("clepit-output-video-wrapper--right")}const u=bt(i),h=ft(i);if(u||h){const e=p("iframe","clepit-output-video-iframe");e.src=i,e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),e.style.maxWidth="100%",e.style.width="560px",e.style.height="315px",e.style.display="block",e.style.borderRadius="8px",d.appendChild(e),c.appendChild(d)}else{const e=p("video","clepit-output-video");e.src=i,e.controls=!0,e.preload="metadata",e.style.maxWidth="100%",e.style.height="auto",e.style.display="block",d.appendChild(e),c.appendChild(d)}if(r){const e=l.createStyledElement("figcaption","clepit-output-video-caption",{classNames:o?.caption,styles:a?.caption});e.innerHTML=m(r),c.appendChild(e)}if(a&&(a.container&&Object.assign(c.style,a.container),a.caption)){const e=c.querySelector(".clepit-output-video-caption");e&&Object.assign(e.style,a.caption)}if(o&&(o.container&&c.classList.add(o.container),o.caption)){const e=c.querySelector(".clepit-output-video-caption");e&&e.classList.add(o.caption)}return c}static draw(t,n=R){if(!e.validate(t)||Si.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-video-container");const o=n.create("div");o.addClass("clepit-output-video-wrapper");const i=t.alignment??"center";i&&o.addClass(`clepit-output-video-wrapper--${i}`);const r=n.create("video");if(r.addClass("clepit-output-video"),r.setAttribute("src",t.url),r.setAttribute("controls","controls"),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-video-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},Li=(e,t,n)=>{const a=Ni(e,t,n);return a&&(a.setAttribute("data-block-type",e.type),e.id&&(a.setAttribute("data-clepit-block-id",e.id),n?.anchorTargets&&a.setAttribute("id",e.id))),a},Ni=(e,t,n)=>{switch(e.type){case"alert":return Et.draw(e.data,t);case"audio":return _t.draw(e.data,t);case"checklist":return Ht.draw(e.data,t);case"code":return Ce.draw(e.data,t,n);case"collapsible":return $i.draw(e.data,t,n);case"collection":return Xt.draw(e.data,t);case"columns":return en.draw(e.data,t,n);case"date":return sn.draw(e.data,t);case"delimiter":return dn.draw(e.data,t);case"doc_card":return mn.draw(e.data,t,n);case"embed":return ot.draw(e.data,t,n);case"file":return yn.draw(e.data,t);case"glance":return wn.draw(e.data,t);case"header":return Sn.draw(e.data,t);case"image":return $n.draw(e.data,t);case"issues":return _n.draw(e.data,t,n);case"latex":return fi.draw(e.data,t);case"list":return zn.draw(e.data,t);case"mermaid":return vi.draw(e.data,t);case"openapi":return ha.draw(e.data,t);case"paragraph":return ba.draw(e.data,t);case"quote":return xa.draw(e.data,t);case"sketch":return La.draw(e.data,t);case"table":return Ka.draw(e.data,t);case"toc":return Za.draw(e.data,t,n);case"updates":return wi.draw(e.data,t);case"video":return Ei.draw(e.data,t);default:return Bi(e)}},Bi=e=>(console.warn("drawBlock: no drawer for block",e),null),$i=class e{static render(t,n,a,o){if(l.injectStyles("collapsible-output",Vt),!e.validate(t))return X();const i=l.createStyledElement("details","clepit-collapsible clepit-output-collapsible",{classNames:o?.section,styles:a?.section});i.open=t.open??!1;const r=document.createElement("summary"),s=document.createElement("span");s.innerHTML=m(t.html),r.appendChild(s),i.appendChild(r);const c=document.createElement("div");c.className="clepit-collapsible__children";for(const l of t.children??[])c.appendChild(e.renderChild(l,n));return i.appendChild(c),i}static renderChild(e,t){const n=Sr.find(t=>t.type===e.type);if(!n){const t=document.createElement("div");return t.className="clepit-collapsible__unknown-child",t.textContent=`Unsupported block: ${e.type}`,t}return n.output.render(e.data,t)}static draw(t,n=R,a){if(!e.validate(t))return null;const o=n.create("details");o.addClass("clepit-collapsible","clepit-output-collapsible"),t.open&&o.setAttribute("open","");const i=n.create("summary"),r=n.create("span");r.setHtml(t.html),i.append(r),o.append(i);const s=n.create("div");s.addClass("clepit-collapsible__children");for(const e of t.children??[]){const t=Li(e,n,a);t&&s.append(t)}return o.append(s),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"html"in e&&"string"==typeof e.html&&(void 0===e.children||Array.isArray(e.children))}},Mi={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12,2C6.48,2,2,6.48,2,12c0,5.52,4.48,10,10,10s10-4.48,10-10C22,6.48,17.52,2,12,2z M15.79,11.71l-3.08,3.08 c-0.39,0.39-1.02,0.39-1.42,0l-3.08-3.08c-0.39-0.39-0.39-1.03,0-1.42c0.39-0.39,1.02-0.39,1.41,0L12,12.67l2.38-2.38 c0.39-0.39,1.02-0.39,1.41,0C16.18,10.68,16.18,11.32,15.79,11.71z"></path></svg>',get input(){return Wt},label:"Collapsible section",get output(){return $i},testId:"block-type-collapsible",type:"collapsible"},Ii=/* @__PURE__ */new WeakMap,Ti=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-collection")?e:e.querySelector(".clepit-collection");if(t){const e=Ii.get(t);if(e)return e;const n=t.getAttribute("data-collection-id");if(n)return{collectionId:n}}return{collectionId:""}}static render(e,t,n){l.injectStyles("collection-input",Gt);const a=t??{collectionId:""},o=Xt.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-collection--input"),o.setAttribute("contenteditable","false"),Ii.set(o,a),o}static isEmpty(t){return""===e.save(t).collectionId}static isEmptyData(e){return!e.collectionId}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},_i={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><g><g><path d="M5,11h4c1.1,0,2-0.9,2-2V5c0-1.1-0.9-2-2-2H5C3.9,3,3,3.9,3,5v4C3,10.1,3.9,11,5,11z"></path><path d="M5,21h4c1.1,0,2-0.9,2-2v-4c0-1.1-0.9-2-2-2H5c-1.1,0-2,0.9-2,2v4C3,20.1,3.9,21,5,21z"></path><path d="M13,5v4c0,1.1,0.9,2,2,2h4c1.1,0,2-0.9,2-2V5c0-1.1-0.9-2-2-2h-4C13.9,3,13,3.9,13,5z"></path><path d="M15,21h4c1.1,0,2-0.9,2-2v-4c0-1.1-0.9-2-2-2h-4c-1.1,0-2,0.9-2,2v4C13,20.1,13.9,21,15,21z"></path></g></g></svg>',get input(){return Ti},label:"Collection",get output(){return Xt},section:"media",testId:"block-type-collection",type:"collection"},qi=/* @__PURE__ */new WeakMap;var Di=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-columns")?e:e.querySelector(".clepit-columns");if(!t)return{columns:[[],[]]};const n=qi.get(t)??[],a=[];return t.querySelectorAll(":scope > .clepit-columns__column").forEach((e,t)=>{const o=n[t]??[],i=[];e.querySelectorAll(":scope > .clepit-columns__child").forEach((e,t)=>{const n=o[t],a=e.getAttribute("data-child-type")??n?.type,r=a?function(e){return Sr.find(t=>t.type===e)}(a):void 0;if(r){const t=r.input.save(e);i.push({...n?.id?{id:n.id}:{},data:t,type:r.type})}else n&&i.push(n)}),a.push(i)}),{columns:a.length>=2?a:[[],[]]}}static render(t,n,a){l.injectStyles("columns-input",Zt);const o=n&&Array.isArray(n.columns)&&n.columns.length>=2?n:{columns:[[],[]]},i=l.createStyledElement("div","clepit-columns clepit-columns--input",{classNames:a?.classNames?.container,styles:a?.styles?.container});return qi.set(i,o.columns.map(e=>[...e])),o.columns.forEach(n=>{const o=l.createStyledElement("div","clepit-columns__column",{classNames:a?.classNames?.column,styles:a?.styles?.column});n.forEach(n=>{o.appendChild(e.renderChild(t,n))}),i.appendChild(o)}),i}static renderChild(e,t){const n=document.createElement("div");n.className="clepit-columns__child";const a=_s.renderTool(t.type,t.data,e);if(a)n.setAttribute("data-child-type",t.type),n.appendChild(a);else{const e=document.createElement("div");e.className="clepit-columns__unknown-child",e.textContent=`Unsupported block: ${t.type}`,n.appendChild(e)}return n}static isEmpty(e){const t=e.querySelector(".clepit-columns");return!t||0===t.querySelectorAll(".clepit-columns__child").length}static isEmptyData(e){return(e.columns??[]).every(e=>0===e.length)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},zi={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M14.67 5v14H9.33V5zm1 14H21V5h-5.33zm-7.34 0V5H3v14z"></path></svg>',get input(){return Di},label:"Columns",get output(){return en},testId:"block-type-columns",type:"columns"},ji=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{date:(e.matches('input[type="date"]')?e:e.querySelector('input[type="date"]'))?.value??""}}static render(t,n,a){l.injectStyles("date-input",nn);const o=l.createStyledElement("input","clepit-date clepit-date--input",{classNames:a?.classNames?.pill,styles:a?.styles?.pill});return o.type="date",n?.date&&rn(n.date)&&(o.value=n.date),e.addEventListener(t,o,"keydown",e=>{e.stopPropagation()}),o}static isEmpty(t){return""===e.save(t).date}static isEmptyData(e){return!e.date}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Hi={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M20 3h-1V2c0-.55-.45-1-1-1s-1 .45-1 1v1H7V2c0-.55-.45-1-1-1s-1 .45-1 1v1H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-1 18H5c-.55 0-1-.45-1-1V8h16v12c0 .55-.45 1-1 1z"></path></svg>',get input(){return ji},label:"Date",get output(){return sn},testId:"block-type-date",type:"date"},Oi={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M4 11h16v2H4z" fill-rule="evenodd"></path></svg>',get input(){return cn},label:"Delimiter",get output(){return dn},testId:"block-type-delimiter",type:"delimiter"},Pi=/* @__PURE__ */new WeakMap,Ri=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-doc-card")?e:e.querySelector(".clepit-doc-card");if(t){const e=Pi.get(t);if(e)return e;const n=t.getAttribute("data-page-id");if(n)return{pageId:n,title:t.querySelector(".clepit-doc-card__title")?.textContent??""}}return{pageId:"",title:""}}static render(e,t,n){l.injectStyles("doc-card-input",un);const a=t??{pageId:"",title:""},o=mn.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-doc-card--input"),o.setAttribute("contenteditable","false"),Pi.set(o,a),o}static isEmpty(t){return""===e.save(t).pageId}static isEmptyData(e){return!e.pageId}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Fi={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M14.59 2.59c-.38-.38-.89-.59-1.42-.59H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8.83c0-.53-.21-1.04-.59-1.41l-4.82-4.83zM15 18H9c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1zm0-4H9c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1zm-2-6V3.5L18.5 9H14c-.55 0-1-.45-1-1z"></path></svg>',get input(){return Ri},label:"Doc card",get output(){return mn},section:"media",testId:"block-type-doc-card",type:"doc_card"},Vi={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M17 7h-3c-.55 0-1 .45-1 1s.45 1 1 1h3c1.65 0 3 1.35 3 3s-1.35 3-3 3h-3c-.55 0-1 .45-1 1s.45 1 1 1h3c2.76 0 5-2.24 5-5s-2.24-5-5-5m-9 5c0 .55.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1H9c-.55 0-1 .45-1 1m2 3H7c-1.65 0-3-1.35-3-3s1.35-3 3-3h3c.55 0 1-.45 1-1s-.45-1-1-1H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h3c.55 0 1-.45 1-1s-.45-1-1-1"></path></svg>',get input(){return pt},label:"Embed",get output(){return ot},section:"media",testId:"block-type-embed",type:"embed"},Ui=/* @__PURE__ */new WeakMap,Wi=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.classList.contains("clepit-file-host")?e:e.querySelector(".clepit-file-host");if(t){const e=Ui.get(t);if(e)return e}return{name:"",url:""}}static render(t,n,a,o){l.injectStyles("file-input",bn);const i=document.createElement("div");return i.className="clepit-file-host",i.setAttribute("contenteditable","false"),a?.url&&a.name&&Ui.set(i,a),e.renderState(i,t,n,o),i}static renderState(t,n,a,o){t.innerHTML="";const i=Ui.get(t);if(!i){const i=document.createElement("button");return i.type="button",i.className="clepit-file__upload",i.setAttribute("data-testid","file-upload-button"),i.textContent="Upload file",e.addEventListener(a,i,"click",()=>{e.pick(t,n,a,o)}),void t.appendChild(i)}const r=yn.render(i,void 0,o?.styles,o?.classNames);r.removeAttribute("href"),t.appendChild(r)}static pick(t,n,a,o){const i=document.createElement("input");i.type="file",i.addEventListener("change",async()=>{const r=i.files?.[0];if(!r)return;const s=await n(r);Ui.set(t,{contentType:r.type||void 0,name:r.name,size:r.size,url:s}),e.renderState(t,n,a,o)}),i.click()}static isEmpty(t){return""===e.save(t).url}static isEmptyData(e){return!e.url}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Ki={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M16.5 6.75v10.58c0 2.09-1.53 3.95-3.61 4.15-2.39.23-4.39-1.64-4.39-3.98V5.14c0-1.31.94-2.5 2.24-2.63 1.5-.15 2.76 1.02 2.76 2.49v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6.75c0-.41-.34-.75-.75-.75s-.75.34-.75.75v8.61c0 1.31.94 2.5 2.24 2.63 1.5.15 2.76-1.02 2.76-2.49V5.17c0-2.09-1.53-3.95-3.61-4.15C9.01.79 7 2.66 7 5v12.27c0 2.87 2.1 5.44 4.96 5.71 3.29.3 6.04-2.26 6.04-5.48V6.75c0-.41-.34-.75-.75-.75s-.75.34-.75.75z"></path></svg>',get input(){return Wi},label:"File",get output(){return yn},section:"media",testId:"block-type-file",type:"file"},Gi={html:"",label:""},Ji=class e{static{this.placeholder="At a glance"}static save(e){const t=e.classList.contains("clepit-glance")?e:e.querySelector(".clepit-glance");if(!t)return{rows:[]};const n=[...t.querySelectorAll(".clepit-glance-label")],a=[...t.querySelectorAll(".clepit-glance-value")],o=n.map((e,t)=>({html:m(a[t]?.innerHTML??""),label:e.textContent??""})),i=t.getAttribute("data-variant")??"plain",r=t.querySelector(".clepit-glance-caption")?.textContent??"";return r?{caption:r,rows:o,variant:i}:{rows:o,variant:i}}static render(e,t,n){l.injectStyles("clepit-glance-input-styles","\n.clepit-glance--input {\n cursor: text;\n}\n\n.clepit-glance--input .clepit-glance-label:empty::before,\n.clepit-glance--input .clepit-glance-value:empty::before {\n color: var(--clepit-text-subtle);\n content: attr(data-placeholder);\n font-style: italic;\n pointer-events: none;\n}\n");const a=t?.rows?.length?t:{rows:[Gi]},o=wn.render(a,void 0,n?.styles,n?.classNames);o.classList.add("clepit-glance--input");for(const i of o.querySelectorAll(".clepit-glance-label"))i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",ne(e,"glanceLabelHint","Label"));for(const i of o.querySelectorAll(".clepit-glance-value"))i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",ne(e,"glanceValueHint","Value"));return o}static changeVariant(t,n,a){const o=C.getState().getInstance(a);if(!o)return;if((t.getAttribute("data-variant")??"plain")===n)return;const i=_s.getBlockIndex(a,t.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id")),r={...e.save(t),variant:n},s={classNames:o.config.classNames?.blocks?.glance,margins:o.config.margins,styles:o.config.styles?.blocks?.glance},c=e.render(a,r,s);t.replaceWith(c),C.getState().updateBlockData(a,i,r)}static isEmpty(t){return e.isEmptyData(e.save(t))}static isEmptyData(e){return!e?.rows?.length||e.rows.every(e=>""===e.label.trim()&&""===m(e.html).trim())}static destroy(e){}},Xi={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><g><g><path d="M15.59,3.59C15.21,3.21,14.7,3,14.17,3H5C3.9,3,3.01,3.9,3.01,5L3,19c0,1.1,0.89,2,1.99,2H19c1.1,0,2-0.9,2-2V9.83 c0-0.53-0.21-1.04-0.59-1.41L15.59,3.59z M8,17c-0.55,0-1-0.45-1-1s0.45-1,1-1s1,0.45,1,1S8.55,17,8,17z M8,13c-0.55,0-1-0.45-1-1 s0.45-1,1-1s1,0.45,1,1S8.55,13,8,13z M8,9C7.45,9,7,8.55,7,8s0.45-1,1-1s1,0.45,1,1S8.55,9,8,9z M14,9V4.5l5.5,5.5H15 C14.45,10,14,9.55,14,9z"></path></g></g></svg>',get input(){return Ji},label:"At a glance",get output(){return wn},testId:"block-type-glance",type:"glance"},Yi={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M5 5.5C5 6.33 5.67 7 6.5 7h4v10.5c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5V7h4c.83 0 1.5-.67 1.5-1.5S18.33 4 17.5 4h-11C5.67 4 5 4.67 5 5.5z"></path></svg>',get input(){return An},label:"Header",get output(){return Sn},shortcut:Pa("1"),testId:"block-type-header",type:"header"},Zi={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2M8.5 13.5l2.5 3.01L14.5 12l4.5 6H5z"></path></svg>',get input(){return Bn},label:"Image",get output(){return $n},section:"media",testId:"block-type-image",type:"image"},Qi={},er=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){return{}}static render(e,t,n){l.injectStyles("issues-input",Mn);const a=C.getState().getInstance(e)?.config,o=C.getState().getData(e)?.blocks??[],i=_n.render({},{documentBlocks:o,issueLabels:a?.issueLabels,issues:Qi[e]},n?.styles,n?.classNames);return i.classList.add("clepit-issues--input"),i.setAttribute("contenteditable","false"),i}static refresh(t,n){Qi[t]={...Qi[t],...n};const a=document.getElementById(t);if(a)for(const o of Array.from(a.querySelectorAll(`.${l.classNames.block.container}[data-tool="issues"]`))){const n=o.querySelector(`.${l.classNames.block.content}`);if(!n)continue;const a=C.getState().getInstance(t),i={classNames:a?.config.classNames?.blocks?.issues,styles:a?.config.styles?.blocks?.issues};n.replaceChildren(e.render(t,{},i))}}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){delete Qi[t];const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},tr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M21.29,5.89l-10,10c-0.39,0.39-1.02,0.39-1.41,0l-2.83-2.83c-0.39-0.39-0.39-1.02,0-1.41l0,0c0.39-0.39,1.02-0.39,1.41,0 l2.12,2.12l9.29-9.29c0.39-0.39,1.02-0.39,1.41,0l0,0C21.68,4.87,21.68,5.5,21.29,5.89z M15.77,2.74c-1.69-0.69-3.61-0.93-5.61-0.57 C6.09,2.9,2.84,6.18,2.15,10.25C1.01,17,6.63,22.78,13.34,21.91c3.96-0.51,7.28-3.46,8.32-7.31c0.4-1.47,0.44-2.89,0.21-4.22 c-0.13-0.8-1.12-1.11-1.7-0.54v0c-0.23,0.23-0.33,0.57-0.27,0.89c0.22,1.33,0.12,2.75-0.52,4.26c-1.16,2.71-3.68,4.7-6.61,4.97 c-5.1,0.47-9.33-3.85-8.7-8.98c0.43-3.54,3.28-6.42,6.81-6.91c1.73-0.24,3.37,0.09,4.77,0.81c0.39,0.2,0.86,0.13,1.17-0.18l0,0 c0.48-0.48,0.36-1.29-0.24-1.6C16.31,2.98,16.04,2.85,15.77,2.74z"></path></svg>',get input(){return er},label:"Linked issues",get output(){return _n},section:"media",testId:"block-type-issues",type:"issues"},nr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5m0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5m0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5M7 19h14v-2H7zm0-6h14v-2H7zm0-8v2h14V5z"></path></svg>',get input(){return Dn},label:"List",get output(){return zn},testId:"block-type-list",type:"list"},ar="clepit-openapi__source",or=(e,t)=>{const n=e.trim();if(""===n)return{};if(/^https?:\/\//i.test(n))return{url:n};try{return{spec:JSON.parse(n)}}catch{return t??{}}},ir=class e{static{this.placeholder="Paste an OpenAPI document, or a URL to one…"}static{this.dataMap=/* @__PURE__ */new WeakMap}static render(t,n,a){l.injectStyles("clepit-openapi-input-styles","\n.clepit-openapi-input {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.clepit-openapi__source {\n background: var(--clepit-code-bg);\n border: 1px solid var(--clepit-code-border);\n border-radius: var(--clepit-radius-md);\n color: var(--clepit-code-text);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 13px;\n max-height: 240px;\n overflow: auto;\n padding: 12px;\n white-space: pre-wrap;\n}\n\n.clepit-openapi__source[data-placeholder]:empty::before {\n color: var(--clepit-text-subtle);\n content: attr(data-placeholder);\n font-style: italic;\n pointer-events: none;\n}\n");const o=p("div","clepit-openapi-input"),i=p("div",ar);i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",ne(t,"openApiSourceHint",e.placeholder)),i.setAttribute("data-testid","openapi-source"),i.textContent=n?.url??(n?.spec?JSON.stringify(n.spec,null,2):"");const r=p("div","clepit-openapi-input__preview");return r.setAttribute("data-testid","openapi-preview"),n&&r.appendChild(ha.render(n)),i.addEventListener("input",()=>{const t=or(i.textContent??"",e.dataMap.get(o));e.dataMap.set(o,t),r.replaceChildren(ha.render(t))}),n&&e.dataMap.set(o,n),o.appendChild(i),o.appendChild(r),o}static save(t){const n=(e=>e.classList.contains(ar)?e:e.querySelector(`.${ar}`))(t),a=t.classList.contains("clepit-openapi-input")?t:t.querySelector(".clepit-openapi-input"),o=a?e.dataMap.get(a):void 0;return or(n?.textContent??"",o)}static isEmpty(t){return e.isEmptyData(e.save(t))}static isEmptyData(e){return void 0===e.spec&&!e.url}static destroy(e){}},rr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><g><path d="M13,13L13,13c-0.56,0.56-1.45,0.56-2,0.01L11,13c-0.55-0.55-0.55-1.44,0-1.99L11,11c0.55-0.55,1.44-0.55,1.99,0L13,11 C13.55,11.55,13.55,12.45,13,13z M12,6l2.12,2.12l2.5-2.5l-3.2-3.2c-0.78-0.78-2.05-0.78-2.83,0l-3.2,3.2l2.5,2.5L12,6z M6,12 l2.12-2.12l-2.5-2.5l-3.2,3.2c-0.78,0.78-0.78,2.05,0,2.83l3.2,3.2l2.5-2.5L6,12z M18,12l-2.12,2.12l2.5,2.5l3.2-3.2 c0.78-0.78,0.78-2.05,0-2.83l-3.2-3.2l-2.5,2.5L18,12z M12,18l-2.12-2.12l-2.5,2.5l3.2,3.2c0.78,0.78,2.05,0.78,2.83,0l3.2-3.2 l-2.5-2.5L12,18z"></path></g></svg>',get input(){return ir},label:"API reference",get output(){return ha},section:"media",testId:"block-type-openapi",type:"openapi"},sr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M20 11H4c-.55 0-1 .45-1 1s.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1M4 18h10c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1M20 6H4c-.55 0-1 .45-1 1v.01c0 .55.45 1 1 1h16c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1"></path></svg>',get input(){return ga},label:"Paragraph",get output(){return ba},shortcut:Pa("0"),testId:"block-type-paragraph",type:"paragraph"},lr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"></path></svg>',get input(){return ya},label:"Quote",get output(){return xa},testId:"block-type-quote",type:"quote"},cr=/* @__PURE__ */new WeakMap,dr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-sketch")?e:e.querySelector(".clepit-sketch");return(t?cr.get(t):void 0)??{strokes:[]}}static render(t,n,a){l.injectStyles("sketch-input",wa);const o=n??{strokes:[]},i=La.render(o,void 0,a?.styles,a?.classNames);return i.classList.add("clepit-sketch--input"),i.setAttribute("contenteditable","false"),cr.set(i,o),e.attachDrawing(t,i),i}static attachDrawing(t,n){const a=n.querySelector("svg");if(!a)return;let o=null;const i=e=>{const t=a.getBoundingClientRect(),n=0===t.width?0:(e.clientX-t.left)/t.width*1e3,o=0===t.height?0:(e.clientY-t.top)/t.height*240;return[Math.round(100*n)/100,Math.round(100*o)/100]},r=()=>{const e=cr.get(n)??{strokes:[]},t=o&&o.length>=4?{strokes:[...e.strokes,{points:o}]}:e,i=La.render(t).querySelector("svg");i&&a.replaceChildren(...Array.from(i.childNodes))},s=[],l=(e,t)=>{a.addEventListener(e,t),s.push({element:a,event:e,handler:t})};l("pointerdown",e=>{o=i(e),e.target.setPointerCapture?.(e.pointerId)}),l("pointermove",e=>{o&&(o.push(...i(e)),r())});const c=()=>{if(o&&o.length>=4){const e=cr.get(n)??{strokes:[]};cr.set(n,{strokes:[...e.strokes,{points:o}]})}o=null,r()};l("pointerup",c),l("pointercancel",c),e.eventListenersMap[t]=[...e.eventListenersMap[t]??[],...s]}static isEmpty(t){return 0===e.save(t).strokes.length}static isEmptyData(e){return 0===(e.strokes??[]).length}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},pr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M18.85,10.39l1.06-1.06c0.78-0.78,0.78-2.05,0-2.83L18.5,5.09c-0.78-0.78-2.05-0.78-2.83,0l-1.06,1.06L18.85,10.39z M13.19,7.56l-9.05,9.05C4.05,16.7,4,16.83,4,16.96v3.54C4,20.78,4.22,21,4.5,21h3.54c0.13,0,0.26-0.05,0.35-0.15l9.05-9.05 L13.19,7.56z M19,17.5c0,2.19-2.54,3.5-5,3.5c-0.55,0-1-0.45-1-1s0.45-1,1-1c1.54,0,3-0.73,3-1.5c0-0.47-0.48-0.87-1.23-1.2 l1.48-1.48C18.32,15.45,19,16.29,19,17.5z M4.58,13.35C3.61,12.79,3,12.06,3,11c0-1.8,1.89-2.63,3.56-3.36C7.59,7.18,9,6.56,9,6 c0-0.41-0.78-1-2-1C5.74,5,5.2,5.61,5.17,5.64C4.82,6.05,4.19,6.1,3.77,5.76C3.36,5.42,3.28,4.81,3.62,4.38C3.73,4.24,4.76,3,7,3 c2.24,0,4,1.32,4,3c0,1.87-1.93,2.72-3.64,3.47C6.42,9.88,5,10.5,5,11c0,0.31,0.43,0.6,1.07,0.86L4.58,13.35z"></path></svg>',get input(){return dr},label:"Sketch",get output(){return La},section:"media",testId:"block-type-sketch",type:"sketch"},ur={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M10 10.02h5V21h-5zM17 21h3c1.1 0 2-.9 2-2v-9h-5zm3-18H5c-1.1 0-2 .9-2 2v3h19V5c0-1.1-.9-2-2-2M3 19c0 1.1.9 2 2 2h3V10H3z"></path></svg>',get input(){return Fa},label:"Table",get output(){return Ka},section:"media",testId:"block-type-table",type:"table"},hr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){return{}}static render(e,t,n){l.injectStyles("toc-input",Ja);const a=C.getState().getData(e)?.blocks??[],o=Za.render({},{documentBlocks:a},n?.styles,n?.classNames);return o.classList.add("clepit-toc--input"),o.setAttribute("contenteditable","false"),o}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},mr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M4 9h12c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm0 4h12c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm0 4h12c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm15 0h2v-2h-2v2zm0-10v2h2V7h-2zm0 6h2v-2h-2v2z"></path></svg>',get input(){return hr},label:"Table of contents",get output(){return Za},testId:"block-type-toc",type:"toc"},gr={latex:"LaTeX",mermaid:"Mermaid"};function br(e){const t=e.classList.contains("clepit-typeset")?e:e.querySelector(".clepit-typeset"),n=t?.querySelector(".clepit-typeset__source"),a=t?.querySelector(".clepit-typeset__title")?.textContent?.trim();return a?{source:n?.textContent??"",title:a}:{source:n?.textContent??""}}function fr(e,t,n,a){l.injectStyles("typeset-input",eo);const o=n??{source:""},i=l.createStyledElement("div",`clepit-typeset clepit-output-typeset clepit-typeset--input clepit-typeset--${e}`,{classNames:a?.classNames?.wrapper,styles:a?.styles?.wrapper});i.setAttribute("data-language",e),i.setAttribute("data-rendered","source");const r=p("span","clepit-typeset__kind");r.textContent=gr[e],i.appendChild(r);const s=p("span","clepit-typeset__title");s.setAttribute("data-testid","typeset-title"),s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",t),s.textContent=o.title??"",i.appendChild(s);const c=p("pre","clepit-typeset__source");return c.setAttribute("contenteditable","true"),c.textContent=o.source,i.appendChild(c),i}var vr=class{static{this.placeholder=""}static save(e){return br(e)}static render(e,t,n){return fr("latex",ne(e,"formulaTitleHint","What does this formula show?"),t,n)}static isEmpty(e){return""===br(e).source.trim()}static isEmptyData(e){return!e.source.trim()}static destroy(e){}},yr=class{static{this.placeholder=""}static save(e){return br(e)}static render(e,t,n){return fr("mermaid",ne(e,"diagramTitleHint","What does this diagram show?"),t,n)}static isEmpty(e){return""===br(e).source.trim()}static isEmptyData(e){return!e.source.trim()}static destroy(e){}},xr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M16.5 4H7.56C6.7 4 6 4.7 6 5.56c0 .28.12.55.32.74L12.5 12l-6.18 5.7c-.2.19-.32.46-.32.74C6 19.3 6.7 20 7.56 20h8.94c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5H11l3.59-3.59c.78-.78.78-2.05 0-2.83L11 7h5.5c.83 0 1.5-.67 1.5-1.5S17.33 4 16.5 4z"></path></svg>',get input(){return vr},label:"LaTeX",get output(){return fi},section:"media",testId:"block-type-latex",type:"latex"},kr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M14,10.5V11h-3v-0.5C11,9.67,10.33,9,9.5,9h-1V7h1C10.33,7,11,6.33,11,5.5v-3C11,1.67,10.33,1,9.5,1h-4C4.67,1,4,1.67,4,2.5 v3C4,6.33,4.67,7,5.5,7h1v2h-1C4.67,9,4,9.67,4,10.5v3C4,14.33,4.67,15,5.5,15h1v2h-1C4.67,17,4,17.67,4,18.5v3 C4,22.33,4.67,23,5.5,23h4c0.83,0,1.5-0.67,1.5-1.5v-3c0-0.83-0.67-1.5-1.5-1.5h-1v-2h1c0.83,0,1.5-0.67,1.5-1.5V13h3v0.5 c0,0.83,0.67,1.5,1.5,1.5h4c0.83,0,1.5-0.67,1.5-1.5v-3C21,9.67,20.33,9,19.5,9h-4C14.67,9,14,9.67,14,10.5z"></path></svg>',get input(){return yr},label:"Mermaid",get output(){return vi},section:"media",testId:"block-type-mermaid",type:"mermaid"},wr=/* @__PURE__ */new WeakMap,Cr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-updates")?e:e.querySelector(".clepit-updates");if(t){const e=wr.get(t);if(e)return e;const n=t.getAttribute("data-page-id");if(n)return{pageId:n}}return{}}static render(e,t,n){l.injectStyles("updates-input",xi);const a=t??{},o=wi.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-updates--input"),o.setAttribute("contenteditable","false"),wr.set(o,a),o}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Ar=e=>e.section??"basic",Sr=[$t,qt,Ot,Pt,Mi,_i,{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9m-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8z"></path></svg>',get input(){return Cr},label:"Updates",get output(){return wi},section:"media",testId:"block-type-updates",type:"updates"},zi,Hi,Oi,Fi,Vi,Ki,Xi,Yi,Zi,tr,nr,rr,sr,lr,pr,xr,kr,ur,mr,{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M21 3H3c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h5v1c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-1h5c1.1 0 1.99-.9 1.99-2L23 5c0-1.11-.9-2-2-2m-1 14H4c-.55 0-1-.45-1-1V6c0-.55.45-1 1-1h16c.55 0 1 .45 1 1v10c0 .55-.45 1-1 1m-5.52-5.13-3.98 2.28c-.67.38-1.5-.11-1.5-.87V8.72c0-.77.83-1.25 1.5-.87l3.98 2.28c.67.39.67 1.35 0 1.74"></path></svg>',get input(){return Si},label:"Video",get output(){return Ei},section:"media",testId:"block-type-video",type:"video"}],Er=["bold","inline-code","italic","link","marker","status","strikethrough","tooltip","underline"],Lr=["alert","audio","checklist","code","collapsible","collection","columns","date","delimiter","doc_card","embed","file","glance","header","image","issues","latex","list","mermaid","openapi","paragraph","quote","sketch","table","toc","updates","video"],Nr=["asana","github_issues","jira","linear"],Br=["categoryCancelled","categoryDone","categoryStarted","categoryTodo","columnAssignee","columnIssue","columnStatus","columnTitle","connectAction","connectTool","linkedIssuesEmpty","noAccess","openInTool","providerUnreachable","showAsCard","unassigned","updatedRelative"],$r=["connectGoogle","connectGoogleAction","noAccess","providerUnreachable","tryAgain","switchedOff","offerShowLive","viewOnGithub","truncated"],Mr=["editView","previewView","jsonView","copyJson","downloadJson","clearEditor","viewSwitcher"],Ir=["insertLink","insertTooltip","inlineStatus","textField","urlField","tooltipField","statusLabelField","statusVariantField","urlPlaceholder","textPlaceholder","tooltipPlaceholder","statusLabelPlaceholder","cancel","apply","removeLink","statusInfo","statusSuccess","statusWarning","statusError","statusPlain"],Tr=["formatText","textType","text","more","bold","italic","underline","strikethrough","inlineCode","link","highlight","status","tooltip"],_r=["improve","shorten","lengthen","simplify","fix_grammar"],qr="clepit-block-type-selector",Dr="clepit-code-language-submenu",zr="clepit-code-theme-submenu",jr="clepit-convert-submenu",Hr="clepit-block-operations-menu";function Or(e){return Lr.includes(e)}function Pr(e,t,n){return e?.[t]??n}var Rr,Fr=class e{static{this.defaultClassName="clepit-block-toolbar"}static{this.menuAnchor="--clepit-block-toolbar"}static{this.submenuAnchorSeq=0}static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static{this.documentListeners=[]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap.get(t)||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap.set(t,i)}static addDocumentEventListener(t,n){const a=e=>n(e);document.addEventListener(t,a),e.documentListeners.push({event:t,handler:a})}static create({containerId:t,block:n}){const a=C.getState().getInstance(t);if(!a)return console.error("BlockToolbar::create: Instance not found for containerId:",t);const o=document.getElementById(t);if(!o)return console.error("BlockToolbar::create: Container not found for containerId:",t);e.eventListenersMap.has(o)||e.eventListenersMap.set(o,[]);const i=void 0!==a.config.audioUploader,r=void 0!==a.config.imageUploader,s=void 0!==a.config.videoUploader,c=a.config.classNames?.blockToolbar,d=a.config.classNames?.blockTypeMenu,u=a.config.classNames?.convertSubmenu,h=a.config.classNames?.operationsMenu,m=a.config.styles?.blockToolbar,g=a.config.styles?.blockTypeMenu,b=a.config.styles?.convertSubmenu,f=a.config.styles?.operationsMenu;e.remove(n),l.injectStyles("clepit-block-toolbar-styles",'\n.clepit-block-toolbar {\n position: absolute;\n top: 6px;\n left: 4px;\n z-index: 1000;\n display: none;\n flex-shrink: 0;\n gap: 2px;\n padding: 0;\n border: 0;\n background: transparent;\n}\n\n.clepit-block-toolbar--visible {\n display: flex !important;\n pointer-events: auto !important;\n}\n\n.clepit-block-toolbar--hidden {\n display: none !important;\n pointer-events: none !important;\n}\n\n.clepit-block--active .clepit-block-toolbar,\n.clepit-block:focus-within .clepit-block-toolbar,\n.clepit-block-toolbar[style*="display: flex"] {\n display: flex;\n pointer-events: auto;\n}\n\n@media (hover: hover) {\n .clepit-block:hover > .clepit-block-toolbar.clepit-block-toolbar--hidden {\n display: flex !important;\n pointer-events: auto !important;\n }\n}\n\n.clepit-block-toolbar-add,\n.clepit-block-toolbar-ops {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n padding: 0;\n border: 0;\n border-radius: var(--clepit-radius-md);\n background: transparent;\n color: var(--clepit-text-subtle);\n cursor: pointer;\n transition: background-color 120ms ease, color 120ms ease;\n}\n\n.clepit-block-toolbar-ops {\n cursor: grab;\n touch-action: none;\n}\n\n.clepit-block-toolbar-add svg,\n.clepit-block-toolbar-ops svg {\n display: block;\n width: 18px;\n height: 18px;\n}\n\n.clepit-block-toolbar-add:hover,\n.clepit-block-toolbar-ops:hover {\n background: var(--clepit-hover-bg);\n color: var(--clepit-text-muted);\n}\n\n.clepit-block-toolbar-add:focus-visible,\n.clepit-block-toolbar-ops:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: 1px;\n}\n\n.clepit-block[data-dragging] {\n opacity: 0.5;\n}\n\n.clepit-block[data-dragging] .clepit-block-toolbar-ops {\n cursor: grabbing;\n}\n\n.clepit-drop-line {\n position: fixed;\n top: var(--clepit-drop-line-top, 0);\n left: var(--clepit-drop-line-left, 0);\n width: var(--clepit-drop-line-width, 0);\n z-index: 1002;\n height: 2px;\n margin-top: -1px;\n border-radius: 1px;\n background: var(--clepit-primary);\n pointer-events: none;\n}\n\n@media (max-width: 768px) {\n .clepit-block-toolbar-add,\n .clepit-block-toolbar-ops {\n width: 44px;\n height: 44px;\n }\n}\n\n/* Block toolbar positioning and display classes */\n.clepit-block-toolbar--positioned {\n position: absolute;\n}\n\n.clepit-block-toolbar--menu-positioned {\n position: absolute;\n z-index: 1001;\n}\n\n.clepit-block-toolbar--submenu-positioned {\n position: absolute;\n top: 0;\n left: calc(100% + 4px);\n z-index: 998;\n}\n\n@supports (anchor-name: --a) {\n .clepit-code-language-submenu.clepit-block-toolbar--submenu-positioned,\n .clepit-code-theme-submenu.clepit-block-toolbar--submenu-positioned {\n position: fixed;\n position-area: inline-end span-block-end;\n position-try-fallbacks: flip-inline;\n inset: auto;\n margin-inline-start: 4px;\n }\n}\n\n.clepit-block-toolbar--item-hidden {\n display: none;\n}\n\n.clepit-block-toolbar--item-visible {\n display: flex;\n}\n\n.clepit-block-toolbar--separator-hidden {\n display: none;\n}\n\n.clepit-block-toolbar--separator-visible {\n display: block;\n}\n\n.clepit-block-toolbar--delete-disabled {\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n}\n\n.clepit-block-toolbar--delete-enabled {\n color: var(--clepit-error);\n}\n\n/* The toolbar stays absolutely positioned at every width. It used to go\n * position: static below 768px, which made it a flex item of .clepit-block —\n * and because it is appended after the content it landed to the RIGHT of the\n * text rather than above it, taking a further 60px off an already narrow\n * column. Absolute keeps it inside the gutter the block opens for it. */\n');const v=p("div",e.defaultClassName);v.id=`${t}-block-toolbar`,v.innerHTML="",l.applyStyling(v,{classNames:c?.container,styles:m?.container});const y=p("button","clepit-block-toolbar-add",{"data-testid":"toolbar-add-button",type:"button"});y.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M18 13h-5v5c0 .55-.45 1-1 1s-1-.45-1-1v-5H6c-.55 0-1-.45-1-1s.45-1 1-1h5V6c0-.55.45-1 1-1s1 .45 1 1v5h5c.55 0 1 .45 1 1s-.45 1-1 1"></path></svg>';const x=Pr(a.config.blockToolbarLabels,"addBlock","Add a block below");y.setAttribute("aria-label",x),ye(y,x,"above"),l.applyStyling(y,{classNames:c?.button,styles:m?.button}),e.addEventListener(o,y,"click",()=>e.showBlockTypeMenu({audioIsEnabled:i,block:n,classNames:d,containerId:t,imageIsEnabled:r,menuLabels:a.config.blockToolbarLabels,styles:g,toolLabels:a.config.blockToolLabels,videoIsEnabled:s}));const k=p("button","clepit-block-toolbar-ops",{"data-testid":"toolbar-operations-button",type:"button"});k.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"></path></svg>';const w=Pr(a.config.blockToolbarLabels,"blockActions","Drag to move, click for options");k.setAttribute("aria-label",w),ye(k,w,"above"),kt(k,n,t),l.applyStyling(k,{classNames:c?.button,styles:m?.button}),e.addEventListener(o,k,"click",()=>e.showOperationsMenu({audioIsEnabled:i,block:n,classNames:h,containerId:t,convertSubmenuClassNames:u,convertSubmenuStyles:b,imageIsEnabled:r,operationLabels:a.config.blockToolbarLabels,styles:f,toolLabels:a.config.blockToolLabels,videoIsEnabled:s})),v.appendChild(y),v.appendChild(k),e.addEventListener(o,v,"click",e=>e.stopPropagation()),n.appendChild(v)}static showBlockTypeMenu({containerId:t,block:n,imageIsEnabled:a,videoIsEnabled:o,audioIsEnabled:i,classNames:r,styles:s,menuLabels:c,toolLabels:d}){e.closeAllMenus();const u=document.querySelector(`.${qr}`);if(u)return u.classList.remove(`${qr}--visible`),u.classList.add(`${qr}--hidden`),void setTimeout(()=>u.remove(),200);const h=p("div",qr);l.applyStyling(h,{classNames:r?.container,styles:s?.container});const m=p("input","",{placeholder:Pr(c,"searchBlocks","Search blocks..."),type:"text"});m.setAttribute("data-testid","block-type-search"),l.applyStyling(m,{classNames:r?.input,styles:s?.input}),h.appendChild(m);const g=document.querySelector(`#${t}`),b=p("div",`${qr}-items`),f=((e,t)=>t.filter(t=>yt(e,t.type)))(C.getState().getInstance(t)?.config,Sr).filter(e=>!("image"===e.type&&!a||"video"===e.type&&!o||"audio"===e.type&&!i)),v=(e=>{const t=/* @__PURE__ */new Map;for(const{shortcut:n}of e)n&&t.set(n,(t.get(n)??0)+1);return new Set([...t].filter(([,e])=>1===e).map(([e])=>e))})(f),y=(a,o)=>{b.innerHTML="";const i=o?[{key:"basic",label:Pr(c,"sectionBasic","Basic")},{key:"media",label:Pr(c,"sectionMedia","Media")}].filter(e=>a.some(t=>Ar(t)===e.key)).map(e=>{const n=p("div","clepit-menu-group",{"data-testid":`block-type-section-${e.key}`,role:"group"}),a=p("p","clepit-menu-section",{id:`${t}-block-type-section-${e.key}`});return a.textContent=e.label,n.setAttribute("aria-labelledby",a.id),n.appendChild(a),b.appendChild(n),{...e,parent:n}}):[];a.forEach(a=>{const o=p("div","clepit-menu-item clepit-block-type-item");o.setAttribute("data-testid",`block-type-${a.type}`),l.applyStyling(o,{classNames:r?.item?.container,styles:s?.item?.container});const c=p("span","clepit-menu-icon "+("image"===a.type?"clepit-menu-icon--italic":""));c.innerHTML=a.icon,l.applyStyling(c,{classNames:r?.item?.icon,styles:s?.item?.icon}),o.appendChild(c);const u=p("span","clepit-menu-label");if(u.textContent=(Or(a.type)?d?.[a.type]:void 0)??a.label,l.applyStyling(u,{classNames:r?.item?.text,styles:s?.item?.text}),o.appendChild(u),a.shortcut&&v.has(a.shortcut)){const e=p("span","clepit-menu-shortcut");e.textContent=a.shortcut,l.applyStyling(e,{classNames:r?.item?.shortcut,styles:s?.item?.shortcut}),o.appendChild(e)}e.addEventListener(g,o,"click",e=>{if(e.stopPropagation(),n){const e=_s.getBlockIndex(t,n.getAttribute("data-id")||"");_s.insertBlock({data:{html:""},type:a.type},t,e+1)}h.hidePopover()}),(i.find(e=>e.key===Ar(a))?.parent??b).appendChild(o)})},x=e=>(Or(e.type)?d?.[e.type]:void 0)??e.label;y(f,!0),e.addEventListener(g,m,"click",e=>e.stopPropagation()),e.addEventListener(g,m,"focus",e=>e.stopPropagation()),e.addEventListener(g,m,"input",()=>{const e=m.value.trim().toLowerCase(),t=""===e?f:f.filter(t=>[x(t),t.label,t.type].some(t=>t.toLowerCase().includes(e)));if(y(t,""===e),0===t.length){const e=p("div","clepit-not-found-message");e.textContent=Pr(c,"noBlockTypesFound","No block types found"),b.appendChild(e)}});const k=n?.querySelector('[data-testid="toolbar-add-button"]');var w,A;if(w=()=>[...b.querySelectorAll(".clepit-block-type-item")],A=()=>{"function"==typeof h.hidePopover&&h.matches(":popover-open")?h.hidePopover():h.remove(),k?.focus()},m.addEventListener("keydown",e=>{const t=w(),n=t.findIndex(e=>e.hasAttribute(wt));switch(e.key){case"ArrowDown":return e.preventDefault(),void(t.length>0&&Ct(t,n<0?0:(n+1)%t.length));case"ArrowUp":return e.preventDefault(),void(t.length>0&&Ct(t,n<=0?t.length-1:n-1));case"Enter":if(n<0)return;return e.preventDefault(),void t[n]?.click();case"Escape":return e.preventDefault(),void A()}}),h.appendChild(b),h.classList.add(qr),h.setAttribute("popover","auto"),m.setAttribute("autofocus",""),n){const t=n.querySelector(`.${e.defaultClassName}`);t&&t.style.setProperty("anchor-name",e.menuAnchor)}e.menuHost(t).appendChild(h),h.addEventListener("toggle",e=>{"closed"===e.newState&&h.remove()}),"function"!=typeof h.showPopover?(h.classList.add(`${qr}--visible`),m.focus(),e.addDocumentEventListener("click",e=>{const t=e.target;h.contains(t)||n?.contains(t)||h.remove()})):h.showPopover()}static showOperationsMenu({containerId:t,block:n,classNames:a,styles:o,convertSubmenuClassNames:i,convertSubmenuStyles:r,imageIsEnabled:s,videoIsEnabled:c,audioIsEnabled:d,operationLabels:u,toolLabels:h}){e.closeAllMenus();const m=p("div",Hr);o?.container&&l.applyStyling(m,{classNames:a?.container,styles:o.container}),a?.container&&m.classList.add(a.container);const g=p("input","",{placeholder:Pr(u,"searchOperations","Search operations..."),type:"text"});g.setAttribute("data-testid","operations-search"),l.applyStyling(g,{classNames:a?.input,styles:o?.input}),m.appendChild(g);const b=document.querySelector(`#${t}`),f=p("div",`${Hr}-items`),v=n.getAttribute("data-tool");if(!v)return;const y=(e,t)=>Pr(u,e,t),x=i=>{const r=p("div","clepit-menu-item clepit-block-operation-item"+(i.danger?" clepit-menu-item--danger":""));l.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=p("span","clepit-menu-icon"+(i.textIcon?" clepit-menu-icon--text":""));i.textIcon?s.textContent=i.icon:s.innerHTML=i.icon,i.iconColor&&(s.style.color=i.iconColor),l.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const c=p("span","clepit-menu-label");if(c.textContent=i.label,l.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(c),i.shortcut){const e=p("span","clepit-menu-shortcut");e.textContent=i.shortcut,l.applyStyling(e,{classNames:a?.item?.shortcut,styles:o?.item?.shortcut}),r.appendChild(e)}if(i.submenu){const e=p("span","clepit-menu-arrow");e.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path></svg>',r.appendChild(e)}i.active&&r.classList.add("active"),"delete"===i.value&&(r.classList.add("clepit-block-toolbar--delete-enabled"),1===b.querySelectorAll(".clepit-block").length&&(r.classList.add("clepit-block-toolbar--delete-disabled"),r.setAttribute("aria-disabled","true"),r.title=y("deleteLastBlock","Cannot delete the last block"))),e.addEventListener(b,r,"click",a=>{a.stopPropagation(),i.submenu?i.submenu():(e.handleOperationSelect(i.value,n,t),m.remove())}),f.appendChild(r)},k=()=>{const e=p("div","clepit-menu-divider");l.applyStyling(e,{classNames:a?.divider,styles:o?.divider}),f.appendChild(e)},w=(e,t)=>{const a=(e=>{const t=n.querySelector(e)?.style.textAlign;return"left"===t?"left":"right"===t?"right":"center"})(t);return[{active:"left"===a,icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M14 15H4c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1zm0-8H4c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1zM4 13h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm0 8h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zM3 4c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1z"></path></svg>',label:y("alignLeft","Align left"),testId:`${e}-align-left`,value:`${e}AlignLeft`},{active:"center"===a,icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M7 16c0 .55.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1zm-3 5h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm0-8h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm3-5c0 .55.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1zM3 4c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1z"></path></svg>',label:y("alignCenter","Align center"),testId:`${e}-align-center`,value:`${e}AlignCenter`},{active:"right"===a,icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M4 21h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm6-4h10c.55 0 1-.45 1-1s-.45-1-1-1H10c-.55 0-1 .45-1 1s.45 1 1 1zm-6-4h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm6-4h10c.55 0 1-.45 1-1s-.45-1-1-1H10c-.55 0-1 .45-1 1s.45 1 1 1zM3 4c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1z"></path></svg>',label:y("alignRight","Align right"),testId:`${e}-align-right`,value:`${e}AlignRight`}]},C=(t,n,a,o)=>{const i={error:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"></path></svg>',label:y("variantError","Error")},info:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8"></path></svg>',label:y("variantInfo","Info")},plain:{icon:Bt,label:y("variantPlain","Plain")},success:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"></path></svg>',label:y("variantSuccess","Success")},warning:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 5.99 19.53 19H4.47zM12 2 1 21h22zm1 14h-2v2h2zm0-6h-2v4h2z"></path></svg>',label:y("variantWarning","Warning")}};return o.map(o=>({active:o===a,icon:i[o]?.icon??"",iconColor:e.getAlertIconColor(o),label:i[o]?.label??o,testId:`${t}-${o}`,value:`${n}${o}`}))};x({icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="m6.14 11.86-2.78 2.79c-.19.2-.19.51 0 .71l2.78 2.79c.31.32.85.09.85-.35V16H13c.55 0 1-.45 1-1s-.45-1-1-1H6.99v-1.79c0-.45-.54-.67-.85-.35m14.51-3.21-2.78-2.79c-.31-.32-.85-.09-.85.35V8H11c-.55 0-1 .45-1 1s.45 1 1 1h6.01v1.79c0 .45.54.67.85.35l2.78-2.79c.2-.19.2-.51.01-.7"></path></svg>',label:y("convert","Turn into"),submenu:()=>{document.querySelector(`.${Dr}`)?.remove(),document.querySelector(`.${zr}`)?.remove(),e.showConvertSubmenu({audioIsEnabled:d,block:n,classNames:i,containerId:t,imageIsEnabled:s,menuLabels:u,parentItem:f.querySelector('[data-testid="operation-convert"]'),parentMenu:m,styles:r,toolLabels:h,videoIsEnabled:c})},testId:"operation-convert",value:"convert"}),x({icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M13 19V7.83l4.88 4.88c.39.39 1.03.39 1.42 0s.39-1.02 0-1.41l-6.59-6.59a.996.996 0 0 0-1.41 0l-6.6 6.58a.996.996 0 1 0 1.41 1.41L11 7.83V19c0 .55.45 1 1 1s1-.45 1-1"></path></svg>',label:y("moveUp","Move up"),shortcut:"⌘⇧↑",testId:"operation-moveUp",value:"moveUp"}),x({icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M11 5v11.17l-4.88-4.88c-.39-.39-1.03-.39-1.42 0s-.39 1.02 0 1.41l6.59 6.59c.39.39 1.02.39 1.41 0l6.59-6.59a.996.996 0 1 0-1.41-1.41L13 16.17V5c0-.55-.45-1-1-1s-1 .45-1 1"></path></svg>',label:y("moveDown","Move down"),shortcut:"⌘⇧↓",testId:"operation-moveDown",value:"moveDown"});const A=(()=>{switch(v){case"image":return w("image",".clepit-image-wrapper");case"video":return w("video",".clepit-video-wrapper");case"audio":return w("audio",".clepit-audio-wrapper");case"code":return[{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M8.7 15.9 4.8 12l3.9-3.9c.39-.39.39-1.01 0-1.4a.984.984 0 0 0-1.4 0l-4.59 4.59c-.39.39-.39 1.02 0 1.41l4.59 4.6c.39.39 1.01.39 1.4 0s.39-1.01 0-1.4m6.6 0 3.9-3.9-3.9-3.9a.984.984 0 0 1 0-1.4c.39-.39 1.01-.39 1.4 0l4.59 4.59c.39.39.39 1.02 0 1.41l-4.59 4.6c-.39.39-1.01.39-1.4 0a.984.984 0 0 1 0-1.4"></path></svg>',label:y("codeLanguage","Language"),submenu:()=>e.showCodeLanguageSubmenu({block:n,classNames:i,containerId:t,menuLabels:u,parentItem:f.querySelector('[data-testid="code-language"]'),parentMenu:m,styles:r}),testId:"code-language",value:"codeLanguage"},{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><g><path d="M12,2C6.49,2,2,6.49,2,12s4.49,10,10,10c1.38,0,2.5-1.12,2.5-2.5c0-0.61-0.23-1.2-0.64-1.67c-0.08-0.1-0.13-0.21-0.13-0.33 c0-0.28,0.22-0.5,0.5-0.5H16c3.31,0,6-2.69,6-6C22,6.04,17.51,2,12,2z M17.5,13c-0.83,0-1.5-0.67-1.5-1.5c0-0.83,0.67-1.5,1.5-1.5 s1.5,0.67,1.5,1.5C19,12.33,18.33,13,17.5,13z M14.5,9C13.67,9,13,8.33,13,7.5C13,6.67,13.67,6,14.5,6S16,6.67,16,7.5 C16,8.33,15.33,9,14.5,9z M5,11.5C5,10.67,5.67,10,6.5,10S8,10.67,8,11.5C8,12.33,7.33,13,6.5,13S5,12.33,5,11.5z M11,7.5 C11,8.33,10.33,9,9.5,9S8,8.33,8,7.5C8,6.67,8.67,6,9.5,6S11,6.67,11,7.5z"></path></g></svg>',label:y("codeTheme","Theme"),submenu:()=>e.showCodeThemeSubmenu({block:n,classNames:i,containerId:t,menuLabels:u,parentItem:f.querySelector('[data-testid="code-theme"]'),parentMenu:m,styles:r}),testId:"code-theme",value:"codeTheme"}];case"embed":return pt.save(n).issue?[{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M17.63 5.84C17.27 5.33 16.67 5 16 5L5 5.01C3.9 5.01 3 5.9 3 7v10c0 1.1.9 1.99 2 1.99L16 19c.67 0 1.27-.33 1.63-.84l3.96-5.58c.25-.35.25-.81 0-1.16l-3.96-5.58z"></path></svg>',label:y("embedShowChip","Show as chip"),testId:"embed-show-chip",value:"embedShowChip"},{icon:Lt,label:y("embedShowLink","Show as link"),testId:"embed-show-link",value:"embedShowLink"},{icon:Nt,label:y("embedCopyLink","Copy link"),testId:"embed-copy-link",value:"embedCopyLink"}]:[{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M8 6.82v10.36c0 .79.87 1.27 1.54.84l8.14-5.18c.62-.39.62-1.29 0-1.69L9.54 5.98C8.87 5.55 8 6.03 8 6.82"></path></svg>',label:y("embedShowLive","Show live"),testId:"embed-show-live",value:"embedShowLive"},{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M19 4H5c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2zm-1 14H6c-.55 0-1-.45-1-1V8h14v9c0 .55-.45 1-1 1z"></path></svg>',label:y("embedShowCard","Show as card"),testId:"embed-show-card",value:"embedShowCard"},{icon:Lt,label:y("embedShowLink","Show as link"),testId:"embed-show-link",value:"embedShowLink"},{icon:Nt,label:y("embedCopyLink","Copy link"),testId:"embed-copy-link",value:"embedCopyLink"}];case"header":{const t=e.getCurrentHeadingLevel(n);return[y("headingH1","Heading 1"),y("headingH2","Heading 2"),y("headingH3","Heading 3"),y("headingH4","Heading 4"),y("headingH5","Heading 5"),y("headingH6","Heading 6")].map((e,n)=>({active:`h${n+1}`===t,icon:`H${n+1}`,label:e,testId:`heading-h${n+1}`,textIcon:!0,value:`heading-h${n+1}`}))}case"list":{const e=n.querySelector(".clepit-list")?.getAttribute("data-type")||"unordered";return[{active:"unordered"===e,icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5m0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5m0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5M7 19h14v-2H7zm0-6h14v-2H7zm0-8v2h14V5z"></path></svg>',label:y("listUnordered","Unordered"),testId:"list-unordered",value:"listTypeunordered"},{active:"ordered"===e,icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M8 7h12c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zm12 10H8c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zm0-6H8c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zM4.5 16h-2c-.28 0-.5.22-.5.5s.22.5.5.5H4v.5h-.5c-.28 0-.5.22-.5.5s.22.5.5.5H4v.5H2.5c-.28 0-.5.22-.5.5s.22.5.5.5h2c.28 0 .5-.22.5-.5v-3c0-.28-.22-.5-.5-.5zm-2-11H3v2.5c0 .28.22.5.5.5s.5-.22.5-.5v-3c0-.28-.22-.5-.5-.5h-1c-.28 0-.5.22-.5.5s.22.5.5.5zm2 5h-2c-.28 0-.5.22-.5.5s.22.5.5.5h1.3l-1.68 1.96c-.08.09-.12.21-.12.32v.22c0 .28.22.5.5.5h2c.28 0 .5-.22.5-.5s-.22-.5-.5-.5H3.2l1.68-1.96c.08-.09.12-.21.12-.32v-.22c0-.28-.22-.5-.5-.5z"></path></svg>',label:y("listOrdered","Ordered"),testId:"list-ordered",value:"listTypeordered"}]}case"alert":return C("alert","alertVariant",n.querySelector(".clepit-alert")?.getAttribute("data-variant")||"info",["info","warning","error","success","plain"]);case"glance":return C("glance","glanceVariant",n.querySelector(".clepit-glance")?.getAttribute("data-variant")||"plain",["plain","info","warning","error","success"]);case"delimiter":{const e=n.querySelector(".clepit-delimiter")?.getAttribute("data-variant")||"line";return[{active:"line"===e,icon:Bt,label:y("delimiterLine","Line"),testId:"delimiter-line",value:"delimiterVariantline"},{active:"stars"===e,icon:"***",label:y("delimiterStars","Stars"),testId:"delimiter-stars",textIcon:!0,value:"delimiterVariantstars"}]}default:return[]}})();A.length>0&&(k(),A.forEach(x)),k(),x({danger:!0,icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2zM18 4h-2.5l-.71-.71c-.18-.18-.44-.29-.7-.29H9.91c-.26 0-.52.11-.7.29L8.5 4H6c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1"></path></svg>',label:y("delete","Delete"),shortcut:"⌘⇧⌫",testId:"operation-delete",value:"delete"});const S=f.querySelectorAll(".clepit-block-operation-item"),E=f.querySelectorAll(".clepit-menu-divider");if(e.addEventListener(b,g,"click",e=>e.stopPropagation()),e.addEventListener(b,g,"focus",e=>e.stopPropagation()),e.addEventListener(b,g,"input",e=>{(e=>{let t=0;S.forEach(n=>{(n.querySelector(".clepit-menu-label")?.textContent?.toLowerCase()||"").includes(e.toLowerCase())?(n.classList.remove("clepit-block-toolbar--item-hidden"),n.classList.add("clepit-block-toolbar--item-visible"),t++):(n.classList.remove("clepit-block-toolbar--item-visible"),n.classList.add("clepit-block-toolbar--item-hidden"))});const n=f.querySelector(".clepit-not-found-message");if(0===t&&""!==e.trim()){if(!n){const e=p("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=y("noOperationsFound","No operations found"),f.appendChild(e)}}else n&&n.remove();E.forEach(t=>{""!==e.trim()?(t.classList.remove("clepit-block-toolbar--separator-visible"),t.classList.add("clepit-block-toolbar--separator-hidden")):(t.classList.remove("clepit-block-toolbar--separator-hidden"),t.classList.add("clepit-block-toolbar--separator-visible"))})})(e.target.value)}),e.addEventListener(b,g,"keydown",e=>{"Escape"===e.key&&m.remove()}),m.appendChild(f),m.classList.add(Hr),m.setAttribute("popover","auto"),g.setAttribute("autofocus",""),n){const t=n.querySelector(`.${e.defaultClassName}`);t&&t.style.setProperty("anchor-name",e.menuAnchor)}e.menuHost(t).appendChild(m),m.addEventListener("toggle",e=>{"closed"===e.newState&&m.remove()}),"function"!=typeof m.showPopover?(m.classList.add(`${Hr}--visible`),g.focus(),e.addDocumentEventListener("click",e=>{const t=e.target;m.contains(t)||n?.contains(t)||t.closest?.(".clepit-block-toolbar-ops")||m.remove()})):m.showPopover()}static showConvertSubmenu({containerId:t,block:n,parentItem:a,parentMenu:o,classNames:i,styles:r,imageIsEnabled:s,videoIsEnabled:c,audioIsEnabled:d,menuLabels:u,toolLabels:h}){const m=document.querySelector(`.${jr}`);m&&m.remove();const g=n.getAttribute("data-tool");if(!g)return;const b=p("div",jr);b.classList.add(jr),b.classList.add(`${jr}--hidden`),r?.container&&l.applyStyles(b,r.container),i?.container&&b.classList.add(i.container);const f=p("input","",{placeholder:Pr(u,"searchConvertOptions","Search convert options..."),type:"text"});f.setAttribute("data-testid","convert-search"),l.applyStyling(f,{classNames:i?.input,styles:r?.input}),b.appendChild(f),setTimeout(()=>f.focus(),10);const v=document.querySelector(`#${t}`),y=p("div",`${jr}-items`),x=e=>(Or(e.type)?h?.[e.type]:void 0)??e.label,k=C.getState().getInstance(t)?.config;Sr.filter(e=>e.type!==g&&(!!yt(k,e.type)&&(!("image"===e.type&&!s||"video"===e.type&&!c||"audio"===e.type&&!d)||void 0))).sort((e,t)=>x(e).localeCompare(x(t))).forEach(a=>{const s=p("div","clepit-menu-item clepit-convert-option-item");s.setAttribute("data-testid",a.testId),l.applyStyling(s,{classNames:i?.item?.container,styles:r?.item?.container});const c=p("span","clepit-menu-icon");c.innerHTML=a.icon,l.applyStyling(c,{classNames:i?.item?.icon,styles:r?.item?.icon}),s.appendChild(c);const d=p("span","clepit-menu-label");if(d.textContent=x(a),l.applyStyling(d,{classNames:i?.item?.text,styles:r?.item?.text}),s.appendChild(d),a.shortcut){const e=p("span","clepit-menu-shortcut");e.textContent=a.shortcut,l.applyStyling(e,{classNames:i?.item?.shortcut,styles:r?.item?.shortcut}),s.appendChild(e)}e.addEventListener(v,s,"click",i=>{i.stopPropagation(),e.turnInto(n,t,a.type),o.remove()}),y.appendChild(s)});const w=y.querySelectorAll(".clepit-convert-option-item");e.addEventListener(v,f,"click",e=>e.stopPropagation()),e.addEventListener(v,f,"focus",e=>e.stopPropagation()),e.addEventListener(v,f,"input",e=>{(e=>{let t=0;w.forEach(n=>{(n.querySelector(".clepit-menu-label")?.textContent?.toLowerCase()||"").includes(e.toLowerCase())?(n.classList.remove("clepit-block-toolbar--item-hidden"),n.classList.add("clepit-block-toolbar--item-visible"),t++):(n.classList.remove("clepit-block-toolbar--item-visible"),n.classList.add("clepit-block-toolbar--item-hidden"))});const n=y.querySelector(".clepit-not-found-message");if(0===t&&""!==e.trim()){if(!n){const e=p("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=Pr(u,"noConvertOptionsFound","No convert options found"),y.appendChild(e)}}else n&&n.remove()})(e.target.value)}),e.addEventListener(v,f,"keydown",t=>{"Escape"===t.key&&e.closeMenu(jr)}),b.appendChild(y);const A="--clepit-convert-parent-"+e.submenuAnchorSeq++;a.style.setProperty("anchor-name",A),b.style.setProperty("position-anchor",A),b.classList.remove(`${jr}--hidden`),b.setAttribute("popover","auto"),e.menuHost(t).appendChild(b),b.addEventListener("toggle",e=>{"closed"===e.newState&&b.remove()}),"function"!=typeof b.showPopover?(o.appendChild(b),b.classList.add(`${jr}--visible`),e.addDocumentEventListener("click",e=>{const t=e.target;b.contains(t)||a.contains(t)||o.contains(t)||b.remove()})):b.showPopover()}static handleOperationSelect(e,t,n){if(!t)return;const a=document.querySelector(`#${n}`);if(e.startsWith("convertTo")){const a=e.replace("convertTo",""),o=t.getAttribute("data-id");return void(o&&_s.convertBlock(o,a,n))}if(e.startsWith("heading-")){const n=e.replace("heading-","");if(-1===_s.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector('[contenteditable="true"]');return void(o&&An.changeLevel(o,n,a.id))}if(e.startsWith("listType")){const n=e.replace("listType","");if(-1===_s.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-list");return void(o&&Dn.changeType(o,n,a.id))}if(e.startsWith("alertVariant")){const n=e.replace("alertVariant","");if(-1===_s.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-alert");return void(o&&St.changeVariant(o,n,a.id))}if(e.startsWith("glanceVariant")){const n=e.replace("glanceVariant","");if(-1===_s.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-glance");return void(o&&Ji.changeVariant(o,n,a.id))}if(e.startsWith("delimiterVariant")){const n=e.replace("delimiterVariant","");if(-1===_s.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-delimiter");if(!o)return;return cn.changeVariant(o,n,a.id)}if(e.startsWith("tableAction")){const n=e.replace("tableAction",""),a=t.querySelector(`.${l.classNames.block.content}`);if(!a)return;return Fa.handleAction(n,a)}if(e.startsWith("embed"))return pt.handleOperation(e,t,a.id);if(e.startsWith("imageAlign"))return Bn.setAlignment(t,e.replace("imageAlign","").toLowerCase());if(e.startsWith("videoAlign"))return Si.setAlignment(t,e.replace("videoAlign","").toLowerCase());if(e.startsWith("audioAlign"))return Tt.setAlignment(t,e.replace("audioAlign","").toLowerCase());if(e.startsWith("codeLanguage")){const n=e.replace("codeLanguage","");if(-1===_s.getBlockIndex(a.id,t.getAttribute("data-id")))return;return he.updateLanguage(t,n)}if(e.startsWith("codeTheme")){const n=e.replace("codeTheme","");if(-1===_s.getBlockIndex(a.id,t.getAttribute("data-id")))return;return he.updateTheme(t,n)}const o=_s.getBlockIndex(a.id,t.getAttribute("data-id"));if(-1!==o)switch(e){case"delete":_s.removeBlock(a.id,o);break;case"moveUp":o>0&&_s.moveBlock(a.id,o,o-1);break;case"moveDown":o<_s.getBlocks(a.id).length-1&&_s.moveBlock(a.id,o,o+1);break;default:console.warn(`Unknown block operation: ${e}`)}}static showCodeLanguageSubmenu({parentItem:t,parentMenu:n,block:a,containerId:o,classNames:i,menuLabels:r,styles:s}){const c=document.querySelector(`.${Dr}`);c&&c.remove();const d=document.querySelector(`.${zr}`);d&&d.remove();const u=document.getElementById(o);if(!u)return;const h=a?.querySelector(`.${l.classNames.block.code.container}`)?.getAttribute("data-language")||"javascript",m=l.createStyledElement("div",Dr,{classNames:i?.container,styles:s?.container});m.classList.add(jr,"clepit-block-toolbar--submenu-positioned");const g=p("input","",{placeholder:Pr(r,"searchLanguages","Search languages..."),type:"text"});g.setAttribute("data-testid","language-search"),m.appendChild(g);const b=he.supportedLanguages;Object.entries(b).forEach(([t,r])=>{const c=l.createStyledElement("div","clepit-menu-item clepit-code-language-item",{classNames:i?.item?.container,styles:s?.item?.container});c.setAttribute("data-testid",`code-language-${t}`);const d=l.createStyledElement("span","",{classNames:i?.item?.text,styles:s?.item?.text});d.textContent=r.name,c.appendChild(d),t===h&&c.classList.add("active"),e.addEventListener(u,c,"click",i=>{i.stopPropagation(),e.handleOperationSelect(`codeLanguage${t}`,a,o),n.remove()}),m.appendChild(c)});const f=m.querySelectorAll(".clepit-code-language-item");e.addEventListener(u,g,"click",e=>e.stopPropagation()),e.addEventListener(u,g,"input",e=>{const t=e.target.value.toLowerCase();f.forEach(e=>{const n=e.querySelector("span")?.textContent?.toLowerCase()||"";e.classList.toggle("clepit-block-toolbar--item-hidden",!n.includes(t))})});const v="--clepit-code-parent-"+e.submenuAnchorSeq++;t.style.setProperty("anchor-name",v),m.style.setProperty("position-anchor",v),n.appendChild(m),setTimeout(()=>{m.classList.remove(`${Dr}--hidden`),m.classList.add(`${Dr}--visible`)},10),setTimeout(()=>{const t=e=>{const a=e.target,o=m.contains(a),i=n.contains(a);o||i||(m.classList.remove(`${Dr}--visible`),m.classList.add(`${Dr}--hidden`),setTimeout(()=>m.remove(),200),document.removeEventListener("click",t))};e.addDocumentEventListener("click",t)},0)}static showCodeThemeSubmenu({parentItem:t,parentMenu:n,block:a,containerId:o,classNames:i,menuLabels:r,styles:s}){const c=document.querySelector(`.${zr}`);c&&c.remove();const d=document.querySelector(`.${Dr}`);d&&d.remove();const u=document.getElementById(o);if(!u)return;const h=a?.querySelector(`.${l.classNames.block.code.container}`)?.getAttribute("data-theme")||"default",m=l.createStyledElement("div",zr,{classNames:i?.container,styles:s?.container});m.classList.add(jr,"clepit-block-toolbar--submenu-positioned");const g=p("input","",{placeholder:Pr(r,"searchThemes","Search themes..."),type:"text"});g.setAttribute("data-testid","theme-search"),m.appendChild(g);const b=he.supportedThemes;Object.entries(b).forEach(([t,r])=>{const c=l.createStyledElement("div","clepit-menu-item clepit-code-theme-item",{classNames:i?.item?.container,styles:s?.item?.container});c.setAttribute("data-testid",`code-theme-${t}`);const d=l.createStyledElement("span","",{classNames:i?.item?.text,styles:s?.item?.text});d.textContent=r.name,c.appendChild(d),t===h&&c.classList.add("active"),e.addEventListener(u,c,"click",i=>{i.stopPropagation(),e.handleOperationSelect(`codeTheme${t}`,a,o),n.remove()}),m.appendChild(c)});const f=m.querySelectorAll(".clepit-code-theme-item");e.addEventListener(u,g,"click",e=>e.stopPropagation()),e.addEventListener(u,g,"input",e=>{const t=e.target.value.toLowerCase();f.forEach(e=>{const n=e.querySelector("span")?.textContent?.toLowerCase()||"";e.classList.toggle("clepit-block-toolbar--item-hidden",!n.includes(t))})});const v="--clepit-code-parent-"+e.submenuAnchorSeq++;t.style.setProperty("anchor-name",v),m.style.setProperty("position-anchor",v),n.appendChild(m),setTimeout(()=>{m.classList.remove(`${zr}--hidden`),m.classList.add(`${zr}--visible`)},10),setTimeout(()=>{const t=e=>{const a=e.target,o=m.contains(a),i=n.contains(a);o||i||(m.classList.remove(`${zr}--visible`),m.classList.add(`${zr}--hidden`),setTimeout(()=>m.remove(),200),document.removeEventListener("click",t))};e.addDocumentEventListener("click",t)},0)}static turnInto(e,t,n){const a=e?.getAttribute("data-tool");if(!a)return;let o;if(e){const t=e.querySelector(".clepit-block-content");"paragraph"===a?o=t.querySelector(".clepit-paragraph")?.innerText||"":"quote"===a?o=t.querySelector(".clepit-quote-text")?.innerText||"":"list"===a?o=Array.from(t.querySelectorAll(".clepit-list-item")).map(e=>e.innerText.trim()).filter(Boolean).join("\n"):"alert"===a?o=t.querySelector(".clepit-alert")?.innerText||"":"header"===a&&(o=t.querySelector(".clepit-header")?.innerText||"")}const i=e?.getAttribute("data-id");i&&_s.convertBlock(i,n,t),setTimeout(()=>{if(!e)return;const t=e.getAttribute("data-tool");if(o&&o.trim()){const n=e.querySelector(".clepit-block-content");if("paragraph"===t){const e=n.querySelector(".clepit-paragraph");e&&(e.innerText=o)}else if("quote"===t){const e=n.querySelector(".clepit-quote-text");e&&(e.innerText=o)}else if("list"===t){const e=n.querySelector(".clepit-list");e&&(e.innerHTML="",o.split("\n").forEach(t=>{const n=document.createElement("li");n.className="clepit-list-item",n.setAttribute("contenteditable","true"),n.innerText=t,e.appendChild(n)}))}else if("alert"===t){const e=n.querySelector(".clepit-alert");e&&(e.innerText=o)}else if("header"===t){const e=n.querySelector(".clepit-header");e&&(e.innerText=o)}}},0)}static show(t,n){e.closeAllMenus(),e.hideAllToolbars(t);const a=n.querySelector(`.${e.defaultClassName}`);a&&(a.classList.add("clepit-block-toolbar--visible"),a.classList.remove("clepit-block-toolbar--hidden"))}static hide(t){document.querySelector(`.${qr}, .${Hr}, .${jr}`)||e.hideAllToolbars(t)}static menuHost(e){return document.getElementById(e)?.closest("dialog")??document.body}static hideAllToolbars(t){const n=document.getElementById(t);n&&n.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>{e.classList.remove("clepit-block-toolbar--visible"),e.classList.add("clepit-block-toolbar--hidden")})}static getCurrentHeadingLevel(e){if(!e)return"h1";const t=e.querySelector(".clepit-header");if(!t)return"h1";const n=t.getAttribute("data-level");if(n)return n;const a=t.tagName.toLowerCase();return a||"h1"}static closeMenu(e){const t=document.querySelector(`.${e}`);t&&(t.matches(":popover-open")&&"function"==typeof t.hidePopover?t.hidePopover():t.remove())}static closeAllMenus(){e.closeMenu(qr),e.closeMenu(Hr),e.closeMenu(jr)}static getAlertIconColor(e){switch(e){case"info":return"#2196f3";case"warning":return"#ff9800";case"error":return"#f44336";case"success":return"#4caf50";default:return"#666"}}static remove(t){t.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>e.remove())}static destroy(t){const n=document.getElementById(t);if(!n)return;const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n)),e.documentListeners.forEach(({event:e,handler:t})=>{document.removeEventListener(e,t)}),e.documentListeners=[],n.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>e.remove())}},Vr=class e{static{this.label="bold"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 4h6a4 4 0 0 1 0 8H7z"/><path d="M7 12h7a4 4 0 0 1 0 8H7z"/></svg>'}static{this.shortcut=Da()}static apply(e){l.injectStyles("clepit-bold-styles","\n/* Bold inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n");const t=document.createElement("strong");e.surroundContents(t),_s.updateStateFromRange(e)}static remove(t){const n=e.findBoldElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("strong");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}_s.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findBoldElement(n)||t.cloneContents().querySelectorAll('b, strong, [style*="font-weight: bold"], [style*="font-weight:bold"]').length>0}static findBoldElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("B"===e.tagName||"STRONG"===e.tagName)return e;if("bold"===e.style.fontWeight||Number.parseInt(e.style.fontWeight)>=700)return e}return t.parentNode?e.findBoldElement(t.parentNode):null}},Ur=class e{static{this.label="inline code"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="7 8 3 12 7 16"/><polyline points="17 8 21 12 17 16"/></svg>'}static{this.shortcut=_a("E")}static apply(e,t,n){l.injectStyles("clepit-inline-code-styles","\n/* Inline code styling when <code> is within editable text */\n.clepit-paragraph code,\n.clepit-header code,\n.clepit-list-item code,\n.clepit-quote-text code,\n.clepit-quote-caption code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n/* Output inline code styling */\n.clepit-output-paragraph code,\n.clepit-output-header code,\n.clepit-output-list li code,\n.clepit-output-quote code,\n.clepit-output-quote cite code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n/* Toolbar button code styling */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n");const a=document.createElement("code");a.classList.add("clepit-inline-code"),t&&l.applyClassNames(a,t),n&&Object.entries(n).forEach(([e,t])=>{if(void 0!==t){const n=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);a.style.setProperty(n,String(t))}}),e.surroundContents(a),_s.updateStateFromRange(e)}static remove(t){const n=e.findCodeElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("code");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}_s.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findCodeElement(n)||t.cloneContents().querySelectorAll('code, [style*="font-family: monospace"], [style*="font-family:monospace"]').length>0}static findCodeElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("CODE"===e.tagName)return e;const n=window.getComputedStyle(e);if(n.fontFamily.includes("monospace")||n.fontFamily.includes("Monaco")||n.fontFamily.includes("Menlo"))return e;if(e.style.fontFamily.includes("monospace")||e.style.fontFamily.includes("Monaco")||e.style.fontFamily.includes("Menlo"))return e}return t.parentNode?e.findCodeElement(t.parentNode):null}static updateExistingCodeElements(e,t){document.querySelectorAll("code").forEach(n=>{n instanceof HTMLElement&&(n.classList.contains("clepit-inline-code")||n.classList.add("clepit-inline-code"),e&&l.applyClassNames(n,e),t&&Object.entries(t).forEach(([e,t])=>{if(void 0!==t){const a=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);n.style.setProperty(a,String(t))}}))})}},Wr=class e{static{this.label="italic"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 4h8"/><path d="M7 20h8"/><path d="M13 4L9 20"/></svg>'}static{this.shortcut=Ha()}static apply(e){l.injectStyles("clepit-italic-styles","\n/* Italic inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n.clepit-menu-icon--italic {\n font-style: italic;\n}\n");const t=document.createElement("em");e.surroundContents(t),_s.updateStateFromRange(e)}static remove(t){const n=e.findItalicElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("em, i");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}_s.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findItalicElement(n)||t.cloneContents().querySelectorAll('i, em, [style*="font-style: italic"], [style*="font-style:italic"]').length>0}static findItalicElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("I"===e.tagName||"EM"===e.tagName)return e;if("italic"===window.getComputedStyle(e).fontStyle)return e;if("italic"===e.style.fontStyle)return e}return t.parentNode?e.findItalicElement(t.parentNode):null}},Kr="clepit-link-styles",Gr=`\n.${l.classNames.block.link} {\n color: var(--clepit-primary);\n cursor: pointer;\n}\n\n.${l.classNames.block.link}:hover {\n color: var(--clepit-primary-hover);\n}\n\n.clepit-link-card {\n position: fixed;\n inset: auto;\n top: var(--clepit-link-card-top, 50%);\n left: var(--clepit-link-card-left, 50%);\n display: flex;\n align-items: center;\n gap: 6px;\n width: min(380px, calc(100vw - 32px));\n margin: 0;\n padding: 6px;\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-lg);\n background: var(--clepit-menu-bg);\n box-shadow: var(--clepit-menu-shadow);\n color: var(--clepit-text);\n font-family: inherit;\n box-sizing: border-box;\n}\n\n.clepit-link-card:not(:popover-open) {\n display: none;\n}\n\n.clepit-link-card-input {\n flex: 1;\n min-width: 0;\n height: 30px;\n padding: 0 8px;\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n background: var(--clepit-bg);\n color: var(--clepit-text);\n font: inherit;\n font-size: 14px;\n box-sizing: border-box;\n}\n\n.clepit-link-card-input:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: -1px;\n border-color: transparent;\n}\n\n.clepit-link-card-input[aria-invalid="true"] {\n border-color: var(--clepit-error);\n}\n\n.clepit-link-card-button {\n height: 30px;\n padding: 0 12px;\n border: 0;\n border-radius: var(--clepit-radius-md);\n font: inherit;\n font-size: 13.5px;\n font-weight: 500;\n white-space: nowrap;\n cursor: pointer;\n transition: background-color 0.15s ease;\n}\n\n.clepit-link-card-button:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: 1px;\n}\n\n.clepit-link-card-button--apply {\n background: var(--clepit-primary);\n color: var(--clepit-on-primary);\n}\n\n.clepit-link-card-button--apply:hover {\n background: var(--clepit-primary-hover);\n}\n\n.clepit-link-card-button--remove {\n background: transparent;\n color: var(--clepit-text-muted);\n}\n\n.clepit-link-card-button--remove:hover {\n background: var(--clepit-hover-bg);\n color: var(--clepit-text);\n}\n\n@media (pointer: coarse) {\n .clepit-link-card-input,\n .clepit-link-card-button {\n height: 44px;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .clepit-link-card-button {\n transition: none;\n }\n}\n`,Jr=class e{static{this.isOpen=!1}constructor(e){this.card=null,this.urlInput=null,this.handleInputKeyDown=e=>{"Enter"===e.key?(e.preventDefault(),this.applyUrl()):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),this.dismiss())},this.handleToggle=e=>{"newState"in e&&"closed"===e.newState&&this.card&&this.dismiss()},this.options=e}show(){this.card||e.isOpen||(l.injectStyles(Kr,Gr),e.isOpen=!0,this.createCard(),this.urlInput?.focus(),this.urlInput?.select())}hide(){const t=this.card;if(!t)return;this.card=null,this.urlInput=null,e.isOpen=!1,t.removeEventListener("toggle",this.handleToggle),"function"==typeof t.hidePopover&&t.matches(":popover-open")&&t.hidePopover(),t.remove();const n=document.querySelector(".clepit-toolbar");n&&(n.style.display="flex")}word(e,t){return this.options.labels?.[e]||t}createCard(){const e=p("div","clepit-link-card",{"aria-label":this.word("insertLink","Add a link"),"data-testid":"link-card",popover:"auto",role:"dialog"});this.applyStyles(e,this.options.styles?.container),this.applyClassNames(e,this.options.classNames?.container);const t=this.options.anchor;t&&(e.style.setProperty("--clepit-link-card-top",`${t.bottom+8}px`),e.style.setProperty("--clepit-link-card-left",`${t.left}px`));const n=p("input","clepit-link-card-input",{"aria-label":this.word("urlField","Link address"),"data-testid":"link-card-url",placeholder:this.word("urlPlaceholder","Paste or type a link"),type:"url"});n.value=this.options.url,this.applyStyles(n,this.options.styles?.input),this.applyClassNames(n,this.options.classNames?.input),n.addEventListener("keydown",this.handleInputKeyDown),n.addEventListener("input",()=>n.removeAttribute("aria-invalid")),this.urlInput=n;const a=p("button","clepit-link-card-button clepit-link-card-button--apply",{"data-testid":"link-card-apply",type:"button"});if(a.textContent=this.word("apply","Apply"),this.applyStyles(a,this.options.styles?.saveButton),this.applyClassNames(a,this.options.classNames?.saveButton),a.addEventListener("click",()=>this.applyUrl()),e.append(n,a),this.options.isLinked){const t=p("button","clepit-link-card-button clepit-link-card-button--remove",{"data-testid":"link-card-remove",type:"button"});t.textContent=this.word("removeLink","Remove"),this.applyStyles(t,this.options.styles?.cancelButton),this.applyClassNames(t,this.options.classNames?.cancelButton),t.addEventListener("click",()=>{this.hide(),this.options.onRemove()}),e.append(t)}document.body.appendChild(e),this.card=e,"function"==typeof e.showPopover&&(e.showPopover(),e.addEventListener("toggle",this.handleToggle));const o=document.querySelector(".clepit-toolbar");o&&(o.style.display="none")}applyUrl(){const e=this.urlInput?.value.trim()??"";if(e){if(!c(e))return this.urlInput?.setAttribute("aria-invalid","true"),void this.urlInput?.focus();this.hide(),this.options.onConfirm(this.options.text,e)}else this.dismiss()}dismiss(){this.hide(),this.options.onCancel()}applyStyles(e,t){if(t)for(const[n,a]of Object.entries(t))void 0!==a&&e.style.setProperty(n,String(a))}applyClassNames(e,t){t&&e.classList.add(t)}destroy(){this.hide(),e.isOpen=!1}},Xr=class e{static{this.label="link"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.07 0l1.76-1.76a5 5 0 0 0-7.07-7.07L10 5"/><path d="M14 11a5 5 0 0 0-7.07 0L5.17 12.76a5 5 0 0 0 7.07 7.07L14 19"/></svg>'}static{this.shortcut=Oa()}static apply(t,n,a,o){l.injectStyles(Kr,Gr);const i=e.findLinkElement(t.commonAncestorContainer),r=t.cloneRange(),s=()=>{const e=window.getSelection();return e?(e.removeAllRanges(),e.addRange(r),e):null};new Jr({anchor:t.getBoundingClientRect(),classNames:n,isLinked:null!==i,labels:o,onCancel:()=>{s()},onConfirm:(t,n)=>{try{const t=s();if(!t)return;if(i instanceof HTMLAnchorElement)return i.href=n,void e.announce(i);const a=l.createStyledElement("a",l.classNames.block.link);a.href=n,a.target="_blank",a.rel="noopener noreferrer";try{r.surroundContents(a)}catch{const e=r.extractContents();a.appendChild(e),r.insertNode(a)}const o=document.createRange();o.selectNodeContents(a),t.removeAllRanges(),t.addRange(o),e.announce(a)}catch(a){console.error("Failed to apply link:",a)}},onRemove:()=>{s(),e.remove(r)},styles:a,text:(i?.textContent??t.toString()).trim(),url:i?.getAttribute("href")??""}).show(),_s.updateStateFromRange(t)}static announce(e){e.closest('[contenteditable="true"]')?.dispatchEvent(new Event("input",{bubbles:!0}))}static remove(t){const n=e.findLinkElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("a");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}_s.updateStateFromRange(t)}static findLinkElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("A"===e.tagName)return e}return t.parentNode?e.findLinkElement(t.parentNode):null}static isActive(t){const n=t.commonAncestorContainer;return!!e.findLinkElement(n)||t.cloneContents().querySelectorAll("a").length>0}},Yr="clepit-marker-styles",Zr="\n/* Marker brush effect */\n.clepit-paragraph mark,\n.clepit-header mark,\n.clepit-list-item mark,\n.clepit-quote-text mark,\n.clepit-quote-caption mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n.clepit-paragraph mark::before,\n.clepit-header mark::before,\n.clepit-list-item mark::before,\n.clepit-quote-text mark::before,\n.clepit-quote-caption mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n/* Output marker brush effect for <mark> */\n.clepit-output-paragraph mark,\n.clepit-output-header mark,\n.clepit-output-list li mark,\n.clepit-output-quote mark,\n.clepit-output-quote cite mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n.clepit-output-paragraph mark::before,\n.clepit-output-header mark::before,\n.clepit-output-list li mark::before,\n.clepit-output-quote mark::before,\n.clepit-output-quote cite mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n z-index: -1;\n}\n\n/* Marker wrapper styling */\n.clepit-marker-wrapper {\n position: relative;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n color: inherit;\n}\n\n/* Marker stroke styling */\n.clepit-marker-stroke {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n z-index: -1;\n pointer-events: none;\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n}\n\n/* Toolbar button mark styling */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n",Qr=class e{static{this.label="marker"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 21l6-2 9-9a2.828 2.828 0 0 0-4-4l-9 9-2 6z"/><path d="M14 7l3 3"/></svg>'}static apply(t,n,a){l.injectStyles(Yr,Zr);const o=document.createElement("span");o.classList.add("clepit-marker-wrapper");const i=document.createElement("span");i.classList.add("clepit-marker-stroke");const r=t.extractContents();o.appendChild(document.createTextNode(" ")),o.appendChild(r),o.appendChild(document.createTextNode(" ")),o.insertBefore(i,o.firstChild),t.insertNode(o),t.selectNodeContents(o),e.applyUserStyles(o,i,n,a);const s=o.closest('[contenteditable="true"]');s&&s.dispatchEvent(new Event("input",{bubbles:!0})),_s.updateStateFromRange(t)}static remove(t){const n=e.findMarkerElement(t.commonAncestorContainer);if(n){const t=n.parentElement;if(t){const a=n.previousSibling,o=n.nextSibling,i=document.createDocumentFragment();Array.from(n.childNodes).forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&e.classList?.contains("clepit-marker-stroke")||i.appendChild(e.cloneNode(!0))}),n.replaceWith(i),e.cleanupSpaces(t,a,o);const r=t.closest('[contenteditable="true"]');r&&r.dispatchEvent(new Event("input",{bubbles:!0}))}return}const a=t.cloneContents().querySelectorAll(".clepit-marker-wrapper");if(a.length>0){a.forEach(t=>{const n=t.parentElement;if(n){const a=t.previousSibling,o=t.nextSibling,i=document.createDocumentFragment();Array.from(t.childNodes).forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&e.classList?.contains("clepit-marker-stroke")||i.appendChild(e.cloneNode(!0))}),t.replaceWith(i),e.cleanupSpaces(n,a,o)}});const n=t.commonAncestorContainer.closest('[contenteditable="true"]');return void(n&&n.dispatchEvent(new Event("input",{bubbles:!0})))}const o=e.findLegacyMarkElement(t.commonAncestorContainer);if(o){const e=o.parentElement;if(e){const t=o.textContent||"",n=document.createTextNode(t);e.insertBefore(n,o),e.removeChild(o);const a=e.closest('[contenteditable="true"]');a&&a.dispatchEvent(new Event("input",{bubbles:!0}))}}_s.updateStateFromRange(t)}static cleanupSpaces(e,t,n){const a=Array.from(e.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE);a.forEach((e,o)=>{let i=e.textContent||"";if(0===o&&t?.nodeType===Node.TEXT_NODE&&(t.textContent||"").endsWith(" ")&&i.startsWith(" ")&&(i=i.substring(1)),o===a.length-1&&n?.nodeType===Node.TEXT_NODE){const e=n.textContent||"";i.endsWith(" ")&&e.startsWith(" ")&&(i=i.substring(0,i.length-1))}e.textContent=i})}static isActive(t){if(t.collapsed)return!1;if(t.cloneContents().querySelectorAll(".clepit-marker-wrapper").length>0)return!0;if(e.findMarkerElement(t.commonAncestorContainer))return!0;const n=t.startContainer,a=t.endContainer;return!(n===t.commonAncestorContainer||!e.findMarkerElement(n))||(!(a===t.commonAncestorContainer||a===n||!e.findMarkerElement(a))||null!==e.findLegacyMarkElement(t.commonAncestorContainer))}static findMarkerElement(e){let t=e,n=0;for(;t&&n<10;){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList?.contains("clepit-marker-wrapper"))return e;if(e.classList?.contains("clepit-block")||e.classList?.contains(l.classNames.editor.container))break}t=t.parentNode,n++}return null}static findLegacyMarkElement(e){let t=e,n=0;for(;t&&n<10;){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("MARK"===e.tagName)return e;if(e.classList?.contains("clepit-block")||e.classList?.contains(l.classNames.editor.container))break;if(0===n){const t=window.getComputedStyle(e);if("yellow"===t.backgroundColor||"rgb(255, 255, 0)"===t.backgroundColor)return e;if("yellow"===e.style.backgroundColor||"rgb(255, 255, 0)"===e.style.backgroundColor)return e}}t=t.parentNode,n++}return null}static applyUserStyles(t,n,a,o){a&&l.applyClassNames(t,a),o&&Object.entries(o).forEach(([e,n])=>{if(void 0!==n&&"background"!==e){const a=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);t.style.setProperty(a,String(n))}});const i=t.style.getPropertyValue("--marker-background")||t.getAttribute("data-marker-background");if(i){const t=e.createStrokeSVG(i);return void(n.style.background=t)}if(o?.background){const t=o.background;if(t){const a=e.createStrokeSVG(String(t));return void(n.style.background=a)}}const r=t.closest(`.${l.classNames.editor.content}, .${l.classNames.renderer.content}`);if(r){const t=window.getComputedStyle(r).getPropertyValue("--clepit-marker-background");if(t&&"initial"!==t&&"inherit"!==t){const a=e.createStrokeSVG(t.trim());return void(n.style.background=a)}}const s=t.closest(`.${l.classNames.block.content}`);if(!s)return;const c=s.style.background||s.style.backgroundColor||s.style.getPropertyValue("background-color");if(c&&"initial"!==c&&"inherit"!==c){const t=e.createStrokeSVG(c);return void(n.style.background=t)}const d=window.getComputedStyle(s).backgroundColor;if(d&&"rgba(0, 0, 0, 0)"!==d&&"transparent"!==d){const t=e.createStrokeSVG(d);n.style.background=t}}static createStrokeSVG(t){const n=e.colorToHex(t);return`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='${encodeURIComponent(n)}'/></svg>") no-repeat center / 100% 100%`}static colorToHex(e){if(e.startsWith("#"))return e;if(e.startsWith("rgb")){const t=e.match(/\d+/g);if(t&&t.length>=3)return`#${parseInt(t[0]).toString(16).padStart(2,"0")}${parseInt(t[1]).toString(16).padStart(2,"0")}${parseInt(t[2]).toString(16).padStart(2,"0")}`}return{blue:"#3742FA",cyan:"#7FDBDA",green:"#2ED573",lime:"#32FF7E",orange:"#FFA502",pink:"#FF6B9D",purple:"#A55EEA",red:"#FF4757",teal:"#006266",yellow:"#FFE047"}[e.toLowerCase()]||"#FFE047"}},es="clepit-inline-status-styles",ts='\n/* Inline status — same visual language as the Alert block but inline. */\n.clepit-status {\n display: inline;\n padding: 2px 8px;\n border-radius: 4px;\n font-size: 0.9em;\n line-height: 1.5;\n vertical-align: baseline;\n}\n\n.clepit-status[data-status-variant="info"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-status[data-status-variant="success"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-status[data-status-variant="warning"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-status[data-status-variant="error"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-status[data-status-variant="plain"] {\n background: transparent;\n color: inherit;\n}\n\n/* Dialog variant picker — mirrors inline chip styling at rest, highlight on hover/selected. */\n.clepit-status-dialog-variants {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 4px;\n}\n\n.clepit-status-dialog-variant {\n appearance: none;\n -webkit-appearance: none;\n background: transparent;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 6px 12px;\n cursor: pointer;\n font-family: inherit;\n font-size: 13px;\n color: var(--clepit-text);\n transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;\n}\n\n.clepit-status-dialog-variant:hover {\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--info:hover,\n.clepit-status-dialog-variant--info[data-selected="true"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--success:hover,\n.clepit-status-dialog-variant--success[data-selected="true"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--warning:hover,\n.clepit-status-dialog-variant--warning[data-selected="true"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--error:hover,\n.clepit-status-dialog-variant--error[data-selected="true"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--plain:hover,\n.clepit-status-dialog-variant--plain[data-selected="true"] {\n background: var(--clepit-surface);\n color: var(--clepit-text);\n border-color: transparent;\n}\n',ns="clepit-dialogs-styles",as="\n.clepit-dialog-overlay {\n border: none;\n padding: 0;\n background: transparent;\n max-width: none;\n max-height: none;\n}\n\n.clepit-dialog-overlay[open] {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.clepit-dialog-overlay::backdrop {\n background: rgba(0, 0, 0, 0.5);\n}\n\n.clepit-dialog-overlay:not([open]) {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.5);\n align-items: center;\n justify-content: center;\n z-index: 10000;\n}\n\n.clepit-dialog {\n position: relative;\n box-sizing: border-box;\n width: min(440px, calc(100vw - 32px));\n max-height: 80vh;\n overflow-y: auto;\n padding: 24px;\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-lg);\n background: var(--clepit-menu-bg);\n box-shadow: var(--clepit-menu-shadow);\n color: var(--clepit-text);\n font-family: inherit;\n transform: scale(0.98);\n opacity: 0;\n transition: transform 0.15s ease-out, opacity 0.15s ease-out;\n}\n\n.clepit-dialog:not(.clepit-dialog--hidden) {\n transform: scale(1);\n opacity: 1;\n}\n\n.clepit-dialog--hidden {\n transform: scale(0.98);\n opacity: 0;\n}\n\n.clepit-dialog-title {\n margin: 0 0 16px;\n font-size: 17px;\n font-weight: 600;\n line-height: 1.4;\n color: var(--clepit-text);\n}\n\n.clepit-dialog-group {\n margin-bottom: 16px;\n}\n\n.clepit-dialog-label {\n display: block;\n margin-bottom: 6px;\n font-size: 13px;\n font-weight: 500;\n color: var(--clepit-text);\n}\n\n.clepit-dialog-input {\n display: block;\n width: 100%;\n height: 36px;\n margin-bottom: 16px;\n padding: 0 10px;\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n background: var(--clepit-bg);\n color: var(--clepit-text);\n font: inherit;\n font-size: 14px;\n box-sizing: border-box;\n}\n\n.clepit-dialog-group .clepit-dialog-input {\n margin-bottom: 0;\n}\n\n.clepit-dialog-input:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: -1px;\n border-color: transparent;\n}\n\n.clepit-dialog-input::placeholder {\n color: var(--clepit-text-subtle);\n}\n\n.clepit-dialog-buttons {\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n margin-top: 24px;\n}\n\n.clepit-dialog-button {\n height: 30px;\n padding: 0 14px;\n border: 0;\n border-radius: var(--clepit-radius-md);\n font: inherit;\n font-size: 13.5px;\n font-weight: 500;\n white-space: nowrap;\n cursor: pointer;\n transition: background-color 0.15s ease;\n}\n\n.clepit-dialog-button:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: 1px;\n}\n\n.clepit-dialog-button--cancel {\n background: transparent;\n color: var(--clepit-text-muted);\n}\n\n.clepit-dialog-button--cancel:hover {\n background: var(--clepit-hover-bg);\n color: var(--clepit-text);\n}\n\n.clepit-dialog-button--save {\n background: var(--clepit-primary);\n color: var(--clepit-on-primary);\n}\n\n.clepit-dialog-button--save:hover {\n background: var(--clepit-primary-hover);\n}\n\n.clepit-dialog-button--save:disabled {\n background: var(--clepit-text-subtle);\n cursor: not-allowed;\n}\n\n@media (pointer: coarse) {\n .clepit-dialog-input,\n .clepit-dialog-button {\n height: 44px;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .clepit-dialog,\n .clepit-dialog-button {\n transition: none;\n }\n}\n",os=["info","success","warning","error","plain"],is={error:"statusError",info:"statusInfo",plain:"statusPlain",success:"statusSuccess",warning:"statusWarning"},rs=class e{static{this.isOpen=!1}static{this.count=0}constructor(e){this.overlay=null,this.dialog=null,this.textInput=null,this.options=e,this.variant=e.variant}show(){this.overlay||e.isOpen||(l.injectStyles(ns,as),e.isOpen=!0,this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const t=this.overlay;"function"==typeof t.close&&t.open&&t.close(),t.remove(),this.overlay=null,this.dialog=null,this.textInput=null,e.isOpen=!1;const n=document.querySelector(".clepit-toolbar");n&&(n.style.display="flex")}word(e,t){return this.options.labels?.[e]||t}createDialog(){const t="clepit-status-dialog-"+ ++e.count;this.overlay=p("dialog","clepit-dialog-overlay",{"aria-labelledby":`${t}-title`}),this.applyStyles(this.overlay,this.options.styles?.overlay),this.dialog=p("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container);const n=p("h3","clepit-dialog-title",{id:`${t}-title`});n.dataset.testid="status-dialog-title",n.textContent=this.word("inlineStatus","Inline status"),this.applyStyles(n,this.options.styles?.title),this.dialog.appendChild(n);const a=p("label","clepit-dialog-label",{for:`${t}-text`});a.dataset.testid="status-dialog-text-label",a.textContent=this.word("statusLabelField","Label"),this.applyStyles(a,this.options.styles?.label),this.dialog.appendChild(a),this.textInput=p("input","clepit-dialog-input",{id:`${t}-text`}),this.textInput.type="text",this.textInput.value=this.options.text,this.textInput.dataset.testid="status-dialog-text-input",this.textInput.placeholder=this.word("statusLabelPlaceholder","Status label"),this.applyStyles(this.textInput,this.options.styles?.input),this.dialog.appendChild(this.textInput);const o=p("span","clepit-dialog-label",{id:`${t}-variant`});o.dataset.testid="status-dialog-variant-label",o.textContent=this.word("statusVariantField","Variant"),this.applyStyles(o,this.options.styles?.label),this.dialog.appendChild(o);const i=p("div","clepit-status-dialog-variants",{"aria-labelledby":`${t}-variant`,role:"radiogroup"});for(const e of os){const t=p("button",`clepit-status-dialog-variant clepit-status-dialog-variant--${e}`);t.type="button",t.dataset.variant=e,t.dataset.testid=`status-dialog-variant-${e}`,t.textContent=this.word(is[e],e),t.setAttribute("role","radio"),t.setAttribute("aria-checked",String(e===this.variant)),t.dataset.selected=String(e===this.variant),t.addEventListener("click",()=>{this.variant=e;for(const t of i.querySelectorAll('[role="radio"]')){const n=t.dataset.variant===e;t.dataset.selected=String(n),t.setAttribute("aria-checked",String(n))}}),i.appendChild(t)}this.dialog.appendChild(i);const r=p("div","clepit-dialog-buttons");this.applyStyles(r,this.options.styles?.buttons);const s=p("button","clepit-dialog-button clepit-dialog-button--cancel");s.type="button",s.dataset.testid="status-dialog-cancel",s.textContent=this.word("cancel","Cancel"),s.addEventListener("click",()=>this.handleCancel()),this.applyStyles(s,this.options.styles?.cancelButton),r.appendChild(s);const l=p("button","clepit-dialog-button clepit-dialog-button--save");l.type="button",l.dataset.testid="status-dialog-apply",l.textContent=this.word("apply","Apply"),l.addEventListener("click",()=>this.handleConfirm()),this.applyStyles(l,this.options.styles?.saveButton),r.appendChild(l),this.dialog.appendChild(r),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const c=this.overlay;"function"==typeof c.showModal?c.showModal():c.style.display="flex";const d=document.querySelector(".clepit-toolbar");d&&(d.style.display="none")}bindEvents(){if(!this.overlay||!this.dialog||!this.textInput)return;this.overlay.addEventListener("click",e=>{e.target===this.overlay&&this.handleCancel()});const e=e=>{"Escape"===e.key&&this.handleCancel(),"Enter"===e.key&&e.target===this.textInput&&(e.preventDefault(),this.handleConfirm())};document.addEventListener("keydown",e),this.dialog.dataset.keyHandlerRegistered="true",this.dialog.__keyHandler=e}focusFirstInput(){setTimeout(()=>this.textInput?.focus(),50)}handleConfirm(){this.textInput&&(this.options.onConfirm(this.textInput.value.trim(),this.variant),this.cleanupKeyHandler(),this.hide())}handleCancel(){this.options.onCancel(),this.cleanupKeyHandler(),this.hide()}cleanupKeyHandler(){if(!this.dialog)return;const e=this.dialog.__keyHandler;e&&document.removeEventListener("keydown",e)}applyStyles(e,t){if(t)for(const[n,a]of Object.entries(t))void 0!==a&&e.style.setProperty(n,String(a))}},ss="clepit-status",ls=class e{static{this.label="status"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="8" width="18" height="8" rx="4"/><circle cx="8" cy="12" r="1.25"/><circle cx="16" cy="12" r="1.25"/></svg>'}static apply(t,n,a,o){l.injectStyles(es,ts);const i=t.toString().trim(),r=e.findStatusElement(t.commonAncestorContainer),s=r?r.textContent??i:i,c=r?e.readVariant(r):"info",d=t.cloneRange();new rs({classNames:n,labels:o,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(d))},onConfirm:(t,n)=>{try{const a=window.getSelection();if(!a)return;if(a.removeAllRanges(),a.addRange(d),!t.trim())return void e.remove(d);if(e.unwrap(d),t!==i){d.deleteContents();const e=document.createTextNode(t);d.insertNode(e),d.selectNode(e)}const o=document.createElement("span");o.className=(e=>`${ss} ${ss}--${e}`)(n),o.dataset.statusVariant=n;try{d.surroundContents(o)}catch{const e=d.extractContents();o.appendChild(e),d.insertNode(o)}const r=document.createRange();r.selectNodeContents(o),a.removeAllRanges(),a.addRange(r);const s=o.closest('[contenteditable="true"]');s&&s.dispatchEvent(new Event("input",{bubbles:!0}))}catch(a){console.error("Failed to apply inline status:",a)}},styles:a,text:s||"status",variant:c}).show(),_s.updateStateFromRange(t)}static remove(t){e.unwrap(t),_s.updateStateFromRange(t)}static isActive(t){return!!e.findStatusElement(t.commonAncestorContainer)||t.cloneContents().querySelectorAll(`.${ss}`).length>0}static unwrap(t){const n=e.findStatusElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}return}const a=t.commonAncestorContainer;if(a.nodeType!==Node.ELEMENT_NODE)return;const o=a.querySelectorAll(`.${ss}`);for(const e of Array.from(o)){if(!t.intersectsNode(e))continue;const n=e.parentElement;n&&(n.insertBefore(document.createTextNode(e.textContent||""),e),n.removeChild(e))}}static findStatusElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList?.contains(ss))return e}return t.parentNode?e.findStatusElement(t.parentNode):null}static readVariant(e){const t=e.dataset.statusVariant;if(t&&["info","success","warning","error"].includes(t))return t;for(const n of["info","success","warning","error"])if(e.classList.contains(`${ss}--${n}`))return n;return"info"}},cs=class e{static{this.label="strikethrough"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M16 4H9a3 3 0 0 0-2.83 4"/><path d="M14 12a4 4 0 0 1 0 8H6"/><line x1="4" x2="20" y1="12" y2="12"/></svg>'}static apply(e){l.injectStyles("clepit-strikethrough-styles",'\n/* Strikethrough inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button s,\n.clepit-toolbar-button del,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n/* Keep strikethrough visual hint without changing size */\n.clepit-toolbar-button[data-tool="strikethrough"] {\n text-decoration: line-through;\n}\n');const t=document.createElement("s");e.surroundContents(t),_s.updateStateFromRange(e)}static remove(t){const n=e.findStrikethroughElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll('s, del, [style*="text-decoration: line-through"], [style*="text-decoration:line-through"]');for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}_s.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findStrikethroughElement(n)||t.cloneContents().querySelectorAll('s, del, [style*="text-decoration: line-through"], [style*="text-decoration:line-through"]').length>0}static findStrikethroughElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("S"===e.tagName||"DEL"===e.tagName)return e;if(window.getComputedStyle(e).textDecoration.includes("line-through"))return e;if(e.style.textDecoration.includes("line-through"))return e}return t.parentNode?e.findStrikethroughElement(t.parentNode):null}},ds="clepit-tooltip-styles",ps=`\n/* Tooltip styles - border bottom instead of text-decoration to avoid underline tool conflict */\n.${l.classNames.block.tooltip} {\n border-bottom: 1px dotted var(--clepit-text-subtle);\n cursor: help;\n}\n\n.${l.classNames.block.tooltip}:hover {\n border-bottom: 1px dotted var(--clepit-text-muted);\n}\n`,us=class e{static{this.count=0}constructor(e){this.overlay=null,this.dialog=null,this.inputText=null,this.inputTooltip=null,this.handleKeyDown=e=>{"Escape"===e.key&&(this.options.onCancel(),this.hide())},this.handleInputKeyDown=e=>{if("Enter"===e.key){const e=this.inputText?.value.trim()||"",t=this.inputTooltip?.value.trim()||"";this.options.onConfirm(e,t),this.hide()}},this.options=e}show(){this.overlay||(l.injectStyles(ns,as),document.querySelectorAll(".clepit-dialog-overlay").forEach(e=>{e!==this.overlay&&e.remove()}),this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const e=this.overlay;"function"==typeof e.close&&e.open&&e.close(),this.destroy()}word(e,t){return this.options.labels?.[e]||t}createDialog(){const t="clepit-tooltip-dialog-"+ ++e.count;this.overlay=p("dialog","clepit-dialog-overlay",{"aria-labelledby":`${t}-title`}),this.applyStyles(this.overlay,this.options.styles?.overlay),this.applyClassNames(this.overlay,this.options.classNames?.overlay),this.dialog=p("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container),this.applyClassNames(this.dialog,this.options.classNames?.container);const n=p("h3","clepit-dialog-title",{id:`${t}-title`});n.dataset.testid="tooltip-dialog-title",n.textContent=this.word("insertTooltip","Insert Tooltip"),this.applyStyles(n,this.options.styles?.title),this.applyClassNames(n,this.options.classNames?.title);const a=this.createInputGroup(this.word("textField","Text"),this.word("textPlaceholder","Text"),this.options.text,"text","tooltip-dialog-text",`${t}-text`);this.inputText=a.querySelector("input");const o=this.createInputGroup(this.word("tooltipField","Tooltip"),this.word("tooltipPlaceholder","Tooltip text"),this.options.tooltip,"text","tooltip-dialog-tooltip",`${t}-tooltip`);this.inputTooltip=o.querySelector("input");const i=this.createButtonGroup();this.dialog.appendChild(n),this.dialog.appendChild(a),this.dialog.appendChild(o),this.dialog.appendChild(i),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const r=this.overlay;"function"==typeof r.showModal?r.showModal():r.style.display="flex",this.dialog?.classList.remove("clepit-dialog--hidden");const s=document.querySelector(".clepit-toolbar");s&&(s.style.display="none"),this.options.onShow?.()}createInputGroup(e,t,n,a,o,i){const r=p("div","clepit-dialog-group");this.applyStyles(r,this.options.styles?.group),this.applyClassNames(r,this.options.classNames?.group);const s=p("label","clepit-dialog-label",{for:i});s.dataset.testid=`${o}-label`,s.textContent=e,this.applyStyles(s,this.options.styles?.label),this.applyClassNames(s,this.options.classNames?.label);const l=p("input","clepit-dialog-input",{id:i});return l.type="url"===a?"url":"text",l.value=n,l.dataset.testid=`${o}-input`,l.placeholder=t,this.applyStyles(l,this.options.styles?.input),this.applyClassNames(l,this.options.classNames?.input),r.appendChild(s),r.appendChild(l),r}createButtonGroup(){const e=p("div","clepit-dialog-buttons");this.applyStyles(e,this.options.styles?.buttons),this.applyClassNames(e,this.options.classNames?.buttons);const t=p("button","clepit-dialog-button clepit-dialog-button--cancel");t.dataset.testid="tooltip-dialog-cancel",t.textContent=this.word("cancel","Cancel"),t.type="button",this.applyStyles(t,this.options.styles?.cancelButton),this.applyClassNames(t,this.options.classNames?.cancelButton);const n=p("button","clepit-dialog-button clepit-dialog-button--save");return n.dataset.testid="tooltip-dialog-apply",n.textContent=this.word("apply","Apply"),n.type="button",this.applyStyles(n,this.options.styles?.saveButton),this.applyClassNames(n,this.options.classNames?.saveButton),t.addEventListener("click",()=>{this.options.onCancel(),this.hide()}),n.addEventListener("click",()=>{this.options.onConfirm(this.inputText?.value.trim()||"",this.inputTooltip?.value.trim()||""),this.hide()}),e.appendChild(t),e.appendChild(n),e}bindEvents(){this.overlay&&(this.overlay.addEventListener("click",e=>{e.target===this.overlay&&(this.options.onCancel(),this.hide())}),document.addEventListener("keydown",this.handleKeyDown),this.inputText&&this.inputText.addEventListener("keydown",this.handleInputKeyDown),this.inputTooltip&&this.inputTooltip.addEventListener("keydown",this.handleInputKeyDown))}focusFirstInput(){setTimeout(()=>{this.inputTooltip&&(this.inputTooltip.focus(),this.inputTooltip.select())},100)}applyStyles(e,t){t&&Object.entries(t).forEach(([t,n])=>{if(void 0!==n){const a=t.replace(/([A-Z])/g,"-$1").toLowerCase();e.style.setProperty(a,String(n))}})}applyClassNames(e,t){t&&e.classList.add(t)}destroy(){if(document.removeEventListener("keydown",this.handleKeyDown),this.overlay){this.overlay.remove(),this.overlay=null,this.dialog=null,this.inputText=null,this.inputTooltip=null;const e=document.querySelector(".clepit-toolbar");e&&(e.style.display="flex"),this.options.onHide&&this.options.onHide()}}},hs=class e{static{this.label="tooltip"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 7l-2.5 3H5a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-4.5L12 7z"/><path d="M8 13h8"/><path d="M8 16h6"/></svg>'}static apply(t,n,a,o){l.injectStyles(ds,ps);const i=t.toString(),r=t.cloneRange();let s="",c=i;const d=e.findTooltipSpan(t.commonAncestorContainer);d&&(s=d.getAttribute("data-tooltip")||"",c=d.textContent||""),new us({classNames:n.classNames,labels:o,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(r))},onConfirm:(t,o)=>{const i=window.getSelection();if(!i)return;if(i.removeAllRanges(),i.addRange(r),!o.trim())return e.remove(r),void(t!==c&&(r.deleteContents(),r.insertNode(document.createTextNode(t))));if(d){const e=d.parentElement;if(e){const t=document.createTextNode(d.textContent||"");e.insertBefore(t,d),e.removeChild(d),r.selectNode(t)}}if(t!==c){r.deleteContents();const e=document.createTextNode(t);r.insertNode(e),r.selectNode(e)}const s=l.createStyledElement("span",l.classNames.block.tooltip);s.setAttribute("data-tooltip",o),a.classNames&&l.applyClassNames(s,a.classNames),a.styles&&Object.entries(a.styles).forEach(([e,t])=>{if(void 0!==t){const n=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);s.style.setProperty(n,String(t))}});try{r.surroundContents(s)}catch{const e=r.extractContents();s.appendChild(e),r.insertNode(s)}t!==c&&s.textContent!==t&&(s.textContent=t),ye(s,o,"above",n.classNames,n.styles);const p=s.closest('[contenteditable="true"]');p&&p.dispatchEvent(new Event("input",{bubbles:!0}))},styles:n.styles,text:c,tooltip:s}).show(),_s.updateStateFromRange(t)}static remove(t){const n=t.commonAncestorContainer,a=e.findTooltipSpan(n);if(a){const e=a.parentElement;if(!e)return;e.insertBefore(document.createTextNode(a.textContent||""),a),e.removeChild(a),t.selectNode(e)}_s.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findTooltipSpan(n)||t.cloneContents().querySelectorAll(`span.${l.classNames.block.tooltip}`).length>0}static initializeElements(e,t){e.querySelectorAll(`span.${l.classNames.block.tooltip}`).forEach(e=>{if(e instanceof HTMLElement&&(t.classNames&&l.applyClassNames(e,t.classNames),t.styles&&Object.entries(t.styles).forEach(([t,n])=>{if(void 0!==n){const a=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(a,String(n))}}),!e.hasAttribute("data-tooltip-initialized"))){const t=e.getAttribute("data-tooltip");t&&(ye(e,t,"above"),e.setAttribute("data-tooltip-initialized","true"))}})}static findTooltipSpan(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList.contains(l.classNames.block.tooltip))return e}return t.parentNode?e.findTooltipSpan(t.parentNode):null}},ms=class e{static{this.label="underline"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 4v7a6 6 0 0 0 12 0V4"/><path d="M4 20h16"/></svg>'}static{this.shortcut=Ra()}static apply(e){l.injectStyles("clepit-underline-styles",'\n/* Underline inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n/* Keep underline visual hint without changing size */\n.clepit-toolbar-button[data-tool="underline"] {\n text-decoration: underline;\n}\n');const t=document.createElement("u");e.surroundContents(t),_s.updateStateFromRange(e)}static remove(t){const n=e.findUnderlineElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("u");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}_s.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findUnderlineElement(n)||t.cloneContents().querySelectorAll('u, [style*="text-decoration: underline"], [style*="text-decoration:underline"]').length>0}static findUnderlineElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("U"===e.tagName)return e;if(window.getComputedStyle(e).textDecoration.includes("underline"))return e;if(e.style.textDecoration.includes("underline"))return e}return t.parentNode?e.findUnderlineElement(t.parentNode):null}},gs=()=>[Vr,Wr,ms,cs,Ur,Qr,ls,Xr,hs],bs="inline-toolbar",fs=["bold","italic","underline","strikethrough"],vs=["inline code","link","marker"],ys=["status","tooltip"],xs={b:"bold",e:"inline code",i:"italic",k:"link",u:"underline"},ks=/* @__PURE__ */new Set(["paragraph","header","list","checklist","quote"]),ws={bold:"Bold",formatText:"Format text",highlight:"Highlight",inlineCode:"Inline code",italic:"Italic",link:"Link",more:"More formatting",status:"Status",strikethrough:"Strikethrough",text:"Text",textType:"Text type",tooltip:"Tooltip",underline:"Underline"},Cs={bold:"bold","inline code":"inlineCode",italic:"italic",link:"link",marker:"highlight",status:"status",strikethrough:"strikethrough",tooltip:"tooltip",underline:"underline"},As=(e,t)=>e.inlineToolbarLabels?.[t]||ws[t],Ss=(e,t)=>{const n=Cs[t.label];return n?As(e,n):t.label},Es={h1:"headingH1",h2:"headingH2",h3:"headingH3",h4:"headingH4",h5:"headingH5",h6:"headingH6"},Ls=class e{static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static{this.hideTimeoutMap=/* @__PURE__ */new Map}static{this.tooltipAnchorSeq=0}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap.get(t)||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap.set(t,i)}static create(t){const n=C.getState().getInstance(t);if(!n)return console.error("InlineToolbar::create: Instance not found for containerId:",t);const a=document.getElementById(t);if(!a)return console.error("InlineToolbar::create: Container not found for containerId:",t);e.eventListenersMap.has(a)||e.eventListenersMap.set(a,[]),l.injectStyles("clepit-inline-toolbar-styles","\n/* Inline Toolbar */\n.clepit-toolbar {\n position: absolute;\n left: 0;\n top: 0;\n translate: var(--clepit-toolbar-x, 0) var(--clepit-toolbar-y, 0);\n z-index: 1002;\n background: var(--clepit-toolbar-bg, var(--clepit-menu-bg));\n border: var(--clepit-toolbar-border, 1px solid var(--clepit-border));\n border-radius: 10px;\n padding: 4px;\n box-shadow: var(--clepit-toolbar-shadow, var(--clepit-menu-shadow));\n display: none;\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n white-space: nowrap;\n will-change: transform;\n}\n\n.clepit-toolbar--layout {\n display: flex;\n flex-direction: row;\n gap: 2px;\n align-items: center;\n}\n\n.clepit-toolbar--hidden {\n display: none !important;\n}\n\n.clepit-toolbar--visible {\n display: flex !important;\n transform: translateY(0) scale(1) !important;\n}\n\n@keyframes toolbarFadeIn {\n from {\n opacity: 0;\n transform: translateY(-10px) scale(0.95);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n}\n\n.clepit-toolbar-button {\n width: 30px;\n height: 30px;\n border: none;\n border-radius: 6px;\n background: transparent;\n color: var(--clepit-toolbar-color, var(--clepit-text));\n font-size: 12px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n line-height: 1;\n /* Ensure all content inside buttons inherits the same font size and styling */\n text-rendering: optimizeLegibility;\n will-change: transform, background-color, color;\n}\n\n/* Normalize SVG icon sizing in toolbar buttons */\n.clepit-toolbar-button svg {\n width: 18px;\n height: 18px;\n display: block;\n stroke: currentColor;\n}\n\n.clepit-toolbar-button:hover {\n background: var(--clepit-toolbar-hover-bg, var(--clepit-hover-bg));\n color: var(--clepit-toolbar-hover-color, var(--clepit-text));\n}\n\n.clepit-toolbar-button:focus-visible,\n.clepit-toolbar-type:focus-visible,\n.clepit-toolbar-menu-item:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: 1px;\n}\n\n.clepit-toolbar-button.active,\n.clepit-toolbar-button[aria-pressed='true'] {\n background: var(--clepit-toolbar-active-bg, var(--clepit-pressed-bg));\n color: var(--clepit-toolbar-active-color, var(--clepit-primary));\n}\n\n.clepit-toolbar-group {\n position: relative;\n display: flex;\n gap: 2px;\n align-items: center;\n}\n\n.clepit-toolbar-separator {\n flex: none;\n width: 1px;\n height: 18px;\n margin: 0 4px;\n background: var(--clepit-border);\n}\n\n.clepit-toolbar-type {\n display: inline-flex;\n gap: 2px;\n align-items: center;\n height: 30px;\n padding: 0 6px;\n border: 0;\n border-radius: 6px;\n background: transparent;\n color: var(--clepit-text);\n font: inherit;\n font-size: 13px;\n cursor: pointer;\n}\n\n.clepit-toolbar-type:hover,\n.clepit-toolbar-type[aria-expanded='true'] {\n background: var(--clepit-hover-bg);\n}\n\n.clepit-toolbar-type-chevron svg {\n display: block;\n width: 16px;\n height: 16px;\n color: var(--clepit-text-subtle);\n}\n\n.clepit-toolbar-menu {\n position: absolute;\n top: calc(100% + 8px);\n left: 0;\n z-index: 1003;\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 200px;\n padding: 6px;\n border-radius: var(--clepit-radius-lg);\n background: var(--clepit-menu-bg);\n box-shadow: var(--clepit-menu-shadow);\n}\n\n.clepit-toolbar-menu[hidden] {\n display: none;\n}\n\n.clepit-toolbar-group[data-testid='toolbar-group-more'] .clepit-toolbar-menu {\n right: 0;\n left: auto;\n}\n\n.clepit-toolbar-menu-item {\n display: flex;\n gap: 12px;\n align-items: center;\n min-height: 38px;\n padding: 8px 10px;\n border: 0;\n border-radius: var(--clepit-radius-md);\n background: transparent;\n color: var(--clepit-text);\n font: inherit;\n font-size: 14px;\n text-align: left;\n cursor: pointer;\n}\n\n.clepit-toolbar-menu-item:hover,\n.clepit-toolbar-menu-item[aria-checked='true'] {\n background: var(--clepit-hover-bg);\n}\n\n.clepit-toolbar-menu-icon {\n display: inline-flex;\n color: var(--clepit-text-muted);\n}\n\n.clepit-toolbar-menu-icon svg {\n display: block;\n width: 18px;\n height: 18px;\n}\n\n/* Ensure consistent base font size for character-based icons */\n.clepit-toolbar-button { font-size: 12px; }\n\n/* Tooltip styles */\n/* Anchored to its own button and shown by :hover / :focus-visible, so no\n * JavaScript measures or centres it. :focus-visible is not decoration: the old\n * mouseenter-only version was invisible to a keyboard user.\n *\n * Guarded by @supports — anchor positioning is Baseline 2026 at ~91%. Without\n * it the tooltip simply never shows, which is what it already did before this\n * change for anyone not using a mouse. */\n.clepit-toolbar-tooltip {\n position: absolute;\n display: none;\n z-index: 9999;\n pointer-events: none;\n}\n\n@supports (anchor-name: --a) {\n .clepit-toolbar-tooltip {\n position: fixed;\n position-area: top;\n margin-block-end: 8px;\n justify-self: anchor-center;\n opacity: 0;\n transform: translateY(8px);\n transition:\n opacity 0.15s ease-in-out,\n transform 0.15s ease-in-out,\n display 0.15s allow-discrete;\n }\n\n .clepit-toolbar-button:hover + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip {\n display: block;\n opacity: 1;\n transform: translateY(0);\n }\n\n @starting-style {\n .clepit-toolbar-button:hover + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip {\n opacity: 0;\n transform: translateY(8px);\n }\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .clepit-toolbar-tooltip {\n transition-duration: 0s;\n }\n}\n\n.clepit-toolbar-tooltip-content {\n white-space: nowrap;\n font-size: 12px;\n font-weight: 500;\n color: var(--clepit-inverse-text);\n background-color: var(--clepit-inverse-surface);\n padding: 4px 8px;\n border-radius: var(--clepit-radius-md);\n transition: transform 0.2s ease-in-out;\n}\n\n.clepit-toolbar-tooltip-arrow {\n position: absolute;\n top: 100%;\n left: 50%;\n margin-left: -4px;\n width: 0;\n height: 0;\n border-left: 4px solid transparent;\n border-right: 4px solid transparent;\n border-top: 4px solid var(--clepit-inverse-surface);\n}\n\n.clepit-toolbar-tooltip--hidden {\n display: none;\n transform: translateY(8px);\n}\n\n.clepit-toolbar-tooltip--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-toolbar-tooltip--fade-out {\n transform: translateY(5px);\n}\n\n/* Toolbar positioning and animation classes */\n.clepit-toolbar--positioned {\n position: absolute;\n}\n\n.clepit-toolbar--measurement {\n display: flex;\n visibility: hidden;\n opacity: 0;\n position: absolute;\n left: -9999px;\n top: -9999px;\n}\n\n.clepit-toolbar--show-animation {\n display: flex;\n visibility: visible;\n transform: translateY(-10px) scale(0.95);\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar--show-animation.clepit-toolbar--visible {\n transform: translateY(0) scale(1);\n}\n\n.clepit-toolbar--position-animation {\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), translate 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar--hide-animation {\n transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n transform: translateY(-5px) scale(0.98);\n}\n\n/* Rewrite menu — the sparkle-wand's action list, anchored under the toolbar */\n.clepit-toolbar-rewrite-menu {\n position: absolute;\n top: 100%;\n right: 0;\n margin-top: 4px;\n flex-direction: column;\n min-width: 160px;\n padding: 4px;\n border-radius: var(--clepit-radius-sm, 6px);\n background: var(--clepit-surface, #fff);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);\n z-index: 2;\n}\n\n.clepit-toolbar-rewrite-item {\n appearance: none;\n border: 0;\n background: transparent;\n color: var(--clepit-text-primary, inherit);\n font: inherit;\n text-align: start;\n padding: 6px 10px;\n border-radius: var(--clepit-radius-xs, 4px);\n cursor: pointer;\n}\n\n.clepit-toolbar-rewrite-item:hover,\n.clepit-toolbar-rewrite-item:focus-visible {\n background: var(--clepit-surface-hover, rgba(0, 0, 0, 0.06));\n}\n\n/* The wand stays put while a rewrite is in flight, so the toolbar does not\n reflow under the pointer mid-request. */\n.clepit-toolbar-button.busy {\n opacity: 0.5;\n pointer-events: none;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n .clepit-toolbar {\n flex-wrap: wrap;\n max-width: 200px;\n }\n}\n");const o=p("div","clepit-toolbar");o.id=`${t}-${bs}`,o.classList.add("clepit-toolbar--hidden","clepit-toolbar--layout"),l.applyStyling(o,{classNames:n.config.classNames?.inlineToolbar?.container,styles:n.config.styles?.inlineToolbar?.container}),a.appendChild(o)}static repaint(t,n){const a=C.getState().getInstance(t);if(!a)return console.error("InlineToolbar::repaint: Instance not found for containerId:",t);const o=e.getElementFromContainerId(t);if(!o)return console.error("InlineToolbar::repaint: Toolbar not found for containerId:",t);e.clearButtons(t),o.setAttribute("role","toolbar"),o.setAttribute("aria-label",As(a.config,"formatText"));const i=(n.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?n.commonAncestorContainer:n.commonAncestorContainer.parentElement)?.closest(`.${l.classNames.block.container}`),r=i?.getAttribute("data-tool"),s=e.getFilteredTools(r,a.config),c=e=>e.map(e=>s.find(t=>t.label===e)).filter(e=>void 0!==e),d=i?e.typePicker(t,i):null,u=[];d&&u.push(d);const h=c(fs);h.length>0&&u.push(e.buttonGroup(t,"marks",h,n));const m=c(vs);m.length>0&&u.push(e.buttonGroup(t,"insert",m,n));const g=c(ys);g.length>0&&u.push(e.moreGroup(t,g,n)),u.forEach((e,t)=>{t>0&&o.appendChild(p("span","clepit-toolbar-separator",{"aria-hidden":"true"})),o.appendChild(e)}),a.config.onInlineRewrite&&e.addRewriteButton(t,n);const b=n.getBoundingClientRect(),f=document.getElementById(a.config.containerId)?.getBoundingClientRect();if(!f)return;const v=o.getBoundingClientRect(),y=v.width>0?{height:v.height,width:v.width}:((e=!1,t=gs().length)=>({height:38,width:30*(t+(e?1:0))+8}))(Boolean(a.config.onInlineRewrite),s.length),x=b.left-f.left+b.width/2-y.width/2;let k=b.top-f.top-y.height-8;k<0&&(k=b.bottom-f.top+8),e.show(a.config.containerId,x,k)}static buttonGroup(t,n,a,o){const i=p("div","clepit-toolbar-group",{"data-testid":`toolbar-group-${n}`,role:"group"});return a.forEach(n=>e.addButton(t,n,o,i)),i}static toggleMenu(e,t,n){const a=n.hidden;e.querySelectorAll(".clepit-toolbar-menu").forEach(e=>{e.hidden=!0}),e.querySelectorAll('[aria-haspopup="menu"]').forEach(e=>e.setAttribute("aria-expanded","false")),n.hidden=!a,t.setAttribute("aria-expanded",String(a))}static typePicker(t,n){const a=C.getState().getInstance(t),o=e.getElementFromContainerId(t),i=document.getElementById(t),r=n.getAttribute("data-tool");if(!(a&&o&&i&&r&&ks.has(r)))return null;const s=n.querySelector(".clepit-header")?.getAttribute("data-level")??"h1",l="header"===r?`heading-${s}`:r,c=(e=>{const t=(t,n)=>({icon:Yi.icon,id:`heading-${t}`,label:e.blockToolbarLabels?.[Es[t]]||n,level:t,type:"header"});return[{icon:sr.icon,id:"paragraph",label:As(e,"text"),type:"paragraph"},t("h1","Heading 1"),t("h2","Heading 2"),t("h3","Heading 3"),t("h4","Heading 4"),t("h5","Heading 5"),t("h6","Heading 6"),{icon:nr.icon,id:"list",label:e.blockToolLabels?.list||nr.label,type:"list"},{icon:Ot.icon,id:"checklist",label:e.blockToolLabels?.checklist||Ot.label,type:"checklist"},{icon:lr.icon,id:"quote",label:e.blockToolLabels?.quote||lr.label,type:"quote"}]})(a.config).filter(e=>yt(a.config,e.type)),d=c.find(e=>e.id===l)?.label??As(a.config,"text"),u=p("div","clepit-toolbar-group",{"data-testid":"toolbar-group-type",role:"group"}),h=p("button","clepit-toolbar-type",{"aria-expanded":"false","aria-haspopup":"menu","aria-label":`${As(a.config,"textType")}: ${d}`,"data-testid":"toolbar-type-picker",type:"button"}),m=p("span","clepit-toolbar-type-label");m.textContent=d,h.appendChild(m);const g=p("span","clepit-toolbar-type-chevron",{"aria-hidden":"true"});g.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M8.12 9.29 12 13.17l3.88-3.88c.39-.39 1.02-.39 1.41 0s.39 1.02 0 1.41l-4.59 4.59c-.39.39-1.02.39-1.41 0L6.7 10.7a.996.996 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0"></path></svg>',h.appendChild(g);const b=p("div","clepit-toolbar-menu",{"data-testid":"toolbar-type-menu",role:"menu"});return b.hidden=!0,c.forEach(a=>{const o=p("button","clepit-toolbar-menu-item",{"data-testid":`toolbar-type-${a.id}`,role:"menuitemradio",type:"button"});o.setAttribute("aria-checked",String(a.id===l));const s=p("span","clepit-toolbar-menu-icon",{"aria-hidden":"true"});s.innerHTML=a.icon,o.appendChild(s);const c=p("span","clepit-toolbar-menu-label");c.textContent=a.label,o.appendChild(c),e.addEventListener(i,o,"mousedown",e=>e.preventDefault()),e.addEventListener(i,o,"click",()=>{if(b.hidden=!0,h.setAttribute("aria-expanded","false"),a.id===l)return;const e=n.querySelector(".clepit-header");if(a.level&&"header"===r&&e)An.changeLevel(e,a.level,t);else if(Fr.turnInto(n,t,a.type),a.level){const e=a.level;setTimeout(()=>{const a=n.querySelector(".clepit-header");a&&An.changeLevel(a,e,t)},0)}}),b.appendChild(o)}),e.addEventListener(i,h,"mousedown",e=>e.preventDefault()),e.addEventListener(i,h,"click",()=>e.toggleMenu(o,h,b)),u.appendChild(h),u.appendChild(b),u}static moreGroup(t,n,a){const o=C.getState().getInstance(t),i=e.getElementFromContainerId(t),r=document.getElementById(t),s=p("div","clepit-toolbar-group",{"data-testid":"toolbar-group-more",role:"group"});if(!o||!i||!r)return s;const l=As(o.config,"more"),c=p("button","clepit-toolbar-button",{"aria-expanded":"false","aria-haspopup":"menu","aria-label":l,"data-testid":"toolbar-more",type:"button"});c.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"></path></svg>';const d=p("div","clepit-toolbar-menu",{"data-testid":"toolbar-more-menu",role:"menu"});return d.hidden=!0,n.forEach(n=>{const i=p("button","clepit-toolbar-menu-item",{"data-tool":n.label.toLowerCase(),role:"menuitem",type:"button"}),s=p("span","clepit-toolbar-menu-icon",{"aria-hidden":"true"});s.innerHTML=n.icon,i.appendChild(s);const l=p("span","clepit-toolbar-menu-label");l.textContent=Ss(o.config,n),i.appendChild(l),n.isActive(a)&&i.setAttribute("aria-pressed","true"),e.addEventListener(r,i,"mousedown",e=>e.preventDefault()),e.addEventListener(r,i,"click",()=>{d.hidden=!0,c.setAttribute("aria-expanded","false");const o=e.toggleTool(t,n,a);null!==o&&(i.classList.toggle("active",o),i.setAttribute("aria-pressed",String(o)))}),d.appendChild(i)}),e.addEventListener(r,c,"mousedown",e=>e.preventDefault()),e.addEventListener(r,c,"click",()=>e.toggleMenu(i,c,d)),s.appendChild(c),e.createTooltip(i,c,l),s.appendChild(d),s}static addRewriteButton(t,n){const a=C.getState().getInstance(t),o=a?.config.onInlineRewrite;if(!a||!o)return;const i=e.getElementFromContainerId(t),r=document.getElementById(t);if(!i||!r)return;const s=p("button","clepit-toolbar-button",{type:"button"});s.innerHTML='<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M12 2l1.6 4.4L18 8l-4.4 1.6L12 14l-1.6-4.4L6 8l4.4-1.6L12 2zm6 10l.9 2.5L21 15l-2.1.8L18 18l-.9-2.2L15 15l2.1-.5L18 12zM6 13l1.1 3L10 17l-2.9 1L6 21l-1.1-3L2 17l2.9-1L6 13z"/></svg>',s.setAttribute("data-tool","rewrite"),l.applyStyling(s,{classNames:a.config.classNames?.inlineToolbar?.button,styles:a.config.styles?.inlineToolbar?.button});const c=p("div","clepit-toolbar-rewrite-menu");c.style.display="none",c.setAttribute("data-rewrite-menu","true");for(const l of _r){const t=p("button","clepit-toolbar-rewrite-item",{type:"button"});t.textContent=a.config.inlineRewriteLabels?.[l]??l,t.setAttribute("data-rewrite-action",l),e.addEventListener(r,t,"mousedown",e=>e.preventDefault()),e.addEventListener(r,t,"click",()=>{c.style.display="none";const e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0):null,a=t&&!t.collapsed?t:n,i=a.toString();i.trim()&&(s.classList.add("busy"),o(i,l).then(e=>{e&&(a.deleteContents(),a.insertNode(document.createTextNode(e)),r.dispatchEvent(new Event("input",{bubbles:!0})))}).catch(e=>console.error("The rewrite failed, the passage is unchanged:",e)).finally(()=>s.classList.remove("busy")))}),c.appendChild(t)}e.addEventListener(r,s,"mousedown",e=>e.preventDefault()),e.addEventListener(r,s,"click",()=>{c.style.display="none"===c.style.display?"flex":"none"}),i.appendChild(s),e.createTooltip(i,s,a.config.inlineRewriteTooltip??"rewrite"),i.appendChild(c)}static addButton(t,n,a,o){const i=C.getState().getInstance(t);if(!i)return console.error("InlineToolbar::addButton: Instance not found for containerId:",t);const r=e.getElementFromContainerId(t);if(!r)return console.error("InlineToolbar::addButton: Toolbar not found for containerId:",t);const s=p("button","clepit-toolbar-button",{type:"button"});s.innerHTML=n.icon,l.applyStyling(s,{classNames:i.config.classNames?.inlineToolbar?.button,styles:i.config.styles?.inlineToolbar?.button});const c=n.isActive(a);c&&s.classList.add("active"),s.setAttribute("aria-pressed",String(c)),s.setAttribute("data-tool",n.label.toLowerCase());const d="shortcut"in n?n.shortcut:"";s.setAttribute("aria-label",d?`${Ss(i.config,n)} ${d}`:Ss(i.config,n));const u=document.getElementById(t);u&&(e.addEventListener(u,s,"mousedown",e=>e.preventDefault()),e.addEventListener(u,s,"click",()=>{const o=e.toggleTool(t,n,a);null!==o&&(s.classList.toggle("active",o),s.setAttribute("aria-pressed",String(o)))})),(o??r).appendChild(s),e.createTooltip(r,s,s.getAttribute("aria-label")??"")}static toolForKey(t,n,a){const o=xs[a.toLowerCase()];if(o)return e.getFilteredTools(n,C.getState().getInstance(t)?.config).find(e=>e.label===o)}static toggleTool(e,t,n){const a=C.getState().getInstance(e);if(!a)return null;try{const e=window.getSelection(),o=e&&e.rangeCount>0?e.getRangeAt(0):null,i=o&&!o.collapsed?o:n;if(i&&t.isActive(i))return t.remove(i),!1;if(i){switch(t.label){case"italic":Wr.apply(i);break;case"bold":Vr.apply(i);break;case"underline":ms.apply(i);break;case"strikethrough":cs.apply(i);break;case"inline code":Ur.apply(i,a.config.classNames?.blocks?.["inline-code"],a.config.styles?.blocks?.["inline-code"]);break;case"marker":Qr.apply(i,a.config.classNames?.blocks?.marker,a.config.styles?.blocks?.marker);break;case"status":ls.apply(i,a.config.classNames?.dialogs,a.config.styles?.dialogs,a.config.dialogLabels);break;case"link":Xr.apply(i,a.config.classNames?.dialogs,a.config.styles?.dialogs,a.config.dialogLabels);break;case"tooltip":hs.apply(i,{classNames:a.config.classNames?.tooltips,styles:a.config.styles?.tooltips},{classNames:a.config.classNames?.blocks?.tooltip,styles:a.config.styles?.blocks?.tooltip},a.config.dialogLabels)}return!0}return null}catch(o){return console.warn("Error applying inline tool:",o),null}}static createTooltip(t,n,a){const o=p("div","clepit-toolbar-tooltip clepit-toolbar-tooltip--hidden"),i=p("div","clepit-toolbar-tooltip-content");i.textContent=a;const r=p("div","clepit-toolbar-tooltip-arrow");i.appendChild(r),o.appendChild(i),n.insertAdjacentElement("afterend",o);const s="--clepit-inline-tool-"+e.tooltipAnchorSeq++;n.style.setProperty("anchor-name",s),o.style.setProperty("position-anchor",s),o.classList.remove("clepit-toolbar-tooltip--hidden")}static clearButtons(t){const n=e.getElementFromContainerId(t);if(!n)return console.error("InlineToolbar::clearButtons: Toolbar not found for containerId:",t);n.replaceChildren()}static show(t,n,a){const o=e.getElementFromContainerId(t);if(!o)return console.error("InlineToolbar::show: Toolbar not found for containerId:",t);const i=o.classList.contains("clepit-toolbar--visible")&&!o.classList.contains("clepit-toolbar--hidden");if(e.cancelPendingHide(t),o.classList.remove("clepit-toolbar--hidden","clepit-toolbar--hide-animation"),i){const t=Math.abs(e.offset(o,"x")-n)>1||Math.abs(e.offset(o,"y")-a)>1;o.classList.toggle("clepit-toolbar--position-animation",t)}else o.classList.remove("clepit-toolbar--position-animation"),o.classList.add("clepit-toolbar--show-animation");o.style.setProperty("--clepit-toolbar-x",`${n}px`),o.style.setProperty("--clepit-toolbar-y",`${a}px`),requestAnimationFrame(()=>{o.classList.contains("clepit-toolbar--hidden")||o.classList.add("clepit-toolbar--visible")})}static offset(e,t){return Number.parseFloat(e.style.getPropertyValue(`--clepit-toolbar-${t}`))||0}static hide(t){const n=e.getElementFromContainerId(t);if(n)if(e.cancelPendingHide(t),n.classList.contains("clepit-toolbar--visible")){n.classList.add("clepit-toolbar--hide-animation");const a=setTimeout(()=>{n.classList.remove("clepit-toolbar--visible","clepit-toolbar--hide-animation"),n.classList.add("clepit-toolbar--hidden"),e.hideTimeoutMap.delete(t)},200);e.hideTimeoutMap.set(t,a)}else n.classList.remove("clepit-toolbar--visible"),n.classList.add("clepit-toolbar--hidden")}static cancelPendingHide(t){const n=e.hideTimeoutMap.get(t);void 0!==n&&(clearTimeout(n),e.hideTimeoutMap.delete(t))}static getElementFromContainerId(e){const t=document.querySelector(`#${e}`);return t?t.querySelector(`#${t.id}-${bs}`):(console.error("InlineToolbar::getElementFromContainerId: Container not found for containerId:",e),null)}static getFilteredTools(e,t){const n=gs().filter(e=>((e,t)=>void 0===e?.allowedInlineTools||e.allowedInlineTools.includes(t))(t,e.label.replace(" ","-")));return"header"===e?n.filter(e=>"bold"!==e.label):n}static destroy(t){e.cancelPendingHide(t);const n=document.querySelector(`#${t}`);if(!n)return;const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n));const o=n.querySelector(`#${t}-${bs}`);if(!o)return console.warn("InlineToolbar::destroy: Toolbar not found for containerId:",t);o.remove()}},Ns={},Bs={dismiss(e){for(const{capture:t,element:n,event:a,handler:o}of Ns[e]??[])n.removeEventListener(a,o,t);Ns[e]=[],document.querySelector(`[data-embed-offer-for="${e}"]`)?.remove()},show(e,t,n,a){Bs.dismiss(e);const o=window.getSelection(),i=o?.rangeCount?o.getRangeAt(0):null;if(!i)return;i.deleteContents();const r=document.createTextNode(n);i.insertNode(r),i.setStartAfter(r),i.collapse(!0),o?.removeAllRanges(),o?.addRange(i);const s=document.getElementById(e);if(!s)return;const l=C.getState().getInstance(e)?.config,c=Je[a.provider]??a.provider,d=document.createElement("div");d.className="clepit-embed-offer",d.setAttribute("data-testid","embed-offer"),d.setAttribute("data-embed-offer-for",e);const p=document.createElement("span");p.textContent=Xe(l?.embedLabels,"offerShowLive",{tool:c}).replace(" · Show live",""),d.appendChild(p);const u=document.createElement("button");u.type="button",u.setAttribute("data-testid","embed-offer-accept"),u.textContent=Xe(l?.embedLabels,"offerShowLive",{tool:c}).split(" · ").pop()??"Show live",d.appendChild(u);const h=i.getBoundingClientRect(),m=s.getBoundingClientRect();d.style.left=`${Math.max(0,h.left-m.left)}px`,d.style.top=h.bottom-m.top+6+"px",s.appendChild(d);const g=()=>{const a=t.getAttribute("data-id"),o=_s.getBlockIndex(e,a);Bs.dismiss(e),-1!==o&&D(e,o,!0,n)},b=t=>{const n=t.key;if("Enter"===n)return t.preventDefault(),t.stopPropagation(),void g();"Shift"!==n&&"Meta"!==n&&"Control"!==n&&"Alt"!==n&&Bs.dismiss(e)},f=t=>{d.contains(t.target)||Bs.dismiss(e)};u.addEventListener("click",g),document.addEventListener("keydown",b,!0),document.addEventListener("mousedown",f),Ns[e]=[{element:u,event:"click",handler:g},{capture:!0,element:document,event:"keydown",handler:b},{element:document,event:"mousedown",handler:f}]}},$s={},Ms={dismiss(e){for(const{element:t,event:n,handler:a}of $s[e]??[])t.removeEventListener(n,a);$s[e]=[],document.querySelector(`[data-issue-menu-for="${e}"]`)?.remove()},show(e,t){Ms.dismiss(e),l.injectStyles(Ae,Se);const n=document.getElementById(e);if(!n)return;const a=C.getState().getInstance(e)?.config,o=Oe.read(t),i=$e(o.tool),r=document.createElement("div");r.className="clepit-issue-menu",r.setAttribute("data-testid","issue-menu"),r.setAttribute("data-issue-menu-for",e);const s=De(o,a?.issueLabels);if(s){const t=document.createElement("div");if(t.className="clepit-issue-menu__reason",t.setAttribute("data-testid","issue-reason"),t.textContent=s,r.appendChild(t),"connect_tool"===o.reason){const t=document.createElement("button");t.type="button",t.setAttribute("data-testid","issue-connect"),t.textContent=Be(a?.issueLabels,"connectAction"),t.addEventListener("click",()=>{Ms.dismiss(e),a?.onIssueAction?.("connect",o.tool)}),r.appendChild(t)}}const c=document.createElement("a");c.href=o.url,c.target="_blank",c.rel="noopener noreferrer",c.setAttribute("data-testid","issue-open"),c.textContent=Be(a?.issueLabels,"openInTool",{tool:i}),c.addEventListener("click",()=>Ms.dismiss(e)),r.appendChild(c);const d=document.createElement("button");d.type="button",d.setAttribute("data-testid","issue-show-card"),d.textContent=Be(a?.issueLabels,"showAsCard"),d.addEventListener("click",()=>{Ms.dismiss(e),Ms.showAsCard(e,t)}),r.appendChild(d);const p=t.getBoundingClientRect(),u=n.getBoundingClientRect();r.style.left=`${Math.max(0,p.left-u.left)}px`,r.style.top=p.bottom-u.top+6+"px",n.appendChild(r);const h=t=>{"Escape"===t.key&&Ms.dismiss(e)},m=n=>{r.contains(n.target)||t.contains(n.target)||Ms.dismiss(e)};document.addEventListener("keydown",h),document.addEventListener("mousedown",m),$s[e]=[{element:document,event:"keydown",handler:h},{element:document,event:"mousedown",handler:m}]},showAsCard(e,t){const n=Oe.read(t),a=t.closest(`.${l.classNames.block.container}`),o=a?.getAttribute("data-id");if(!a||!o)return;const i=_s.getBlockIndex(e,o);if(-1===i)return;const r=t.closest('[contenteditable="true"]');t.remove();const s={data:{issue:n,url:n.url},type:"embed"};_s.getTool(a.getAttribute("data-tool"))?.input.isEmpty(a)?_s.replaceBlock(e,i,s):(r&&_s.saveBlockData(r),_s.insertBlock(s,e,i+1))}},Is={Digit0:0,Digit1:1,Digit2:2,Digit3:3,Digit4:4},Ts=class e{static addListeners(t){const n=document.getElementById(t);if(!n)return console.error("EventManager::addListeners: Container not found for containerId:",t);document.addEventListener("selectionchange",e.handleSelectionChange),document.addEventListener("paste",e.handlePaste),n.addEventListener("click",e.handleClick),n.addEventListener("keydown",e.handleShortcut)}static removeListeners(t){const n=document.getElementById(t);n&&(document.removeEventListener("selectionchange",e.handleSelectionChange),document.removeEventListener("paste",e.handlePaste),n.removeEventListener("click",e.handleClick),n.removeEventListener("keydown",e.handleShortcut))}static handleShortcut(t){if(!t.metaKey&&!t.ctrlKey||t.shiftKey)return;const n=t.currentTarget,a=t.target.closest(`.${l.classNames.block.container}`);a&&(t.altKey?e.setTextBlockStyle(n.id,a,t):e.toggleInlineTool(n.id,a,t))}static toggleInlineTool(e,t,n){if(!(n.key.toLowerCase()in xs))return;const a=window.getSelection(),o=a&&a.rangeCount>0?a.getRangeAt(0):null;if(!o||o.collapsed||!t.contains(o.commonAncestorContainer))return;n.preventDefault();const i=Ls.toolForKey(e,t.getAttribute("data-tool"),n.key);i&&Ls.toggleTool(e,i,o)}static setTextBlockStyle(e,t,n){const a=Is[n.code],o=t.getAttribute("data-id"),i=t.getAttribute("data-tool");if(void 0===a||!o||"paragraph"!==i&&"header"!==i)return;if(n.preventDefault(),0===a)return void("header"===i&&_s.convertBlock(o,"paragraph",e));"paragraph"===i&&_s.convertBlock(o,"header",e);const r=_s.getBlock(o)?.querySelector(`.${l.classNames.block.header}`);r&&An.changeLevel(r,`h${a}`,e)}static getInstanceAndTargetFromRange(e){const t=e.commonAncestorContainer,n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!n)return null;const a=n.closest(`.${l.classNames.editor.content}`);if(!a)return null;const o=a.getAttribute("data-container-id");if(!o)return null;const i=C.getState().getInstance(o);return i?{instance:i,target:n}:null}static handleClick(e){const t=e.currentTarget,n=e.target,a=n.closest(`a.${Me}`);if(a){if("edit"!==C.getState().getInstance(t.id)?.currentView)return;return e.preventDefault(),void Ms.show(t.id,a)}const o=n.closest(`.${l.classNames.block.link}`);if(o){const e=document.createRange();e.selectNodeContents(o);const n=C.getState().getInstance(t.id);return void(n&&Xr.apply(e,n.config.classNames?.dialogs,n.config.styles?.dialogs,n.config.dialogLabels))}const i=n.closest(`.${l.classNames.block.tooltip}`);if(i){const e=document.createRange();e.selectNodeContents(i);const n=C.getState().getInstance(t.id);return void(n&&hs.apply(e,{classNames:n.config.classNames?.tooltips,styles:n.config.styles?.tooltips},{classNames:n.config.classNames?.blocks?.tooltip,styles:n.config.styles?.blocks?.tooltip},n.config.dialogLabels))}}static handleSelectionChange(){const t=window.getSelection();if(!t||0===t.rangeCount)return;const n=t.getRangeAt(0),a=e.getInstanceAndTargetFromRange(n);if(!a)return;if("edit"!==a.instance.currentView)return void Ls.hide(a.instance.config.containerId);if(null!==document.querySelector(".clepit-dialog-overlay"))return;const o=t?.toString().trim();o&&o.length>0||t&&t.rangeCount>0&&!t.getRangeAt(0).collapsed?Ls.repaint(a.instance.config.containerId,n):Ls.hide(a.instance.config.containerId)}static handlePaste(e){const t=e.clipboardData?.getData("text/plain").trim()??"";if(!t)return;const n=document.activeElement;if(!n)return;const a=n.closest(`.${l.classNames.block.container}`);if(!a)return;const o=a.closest(`.${l.classNames.editor.container}`);if(!o)return;const i=C.getState().getInstance(o.id)?.config,r=xt(i,t);if(!r)return;const s=a.getAttribute("data-id"),c=_s.getBlockIndex(o.id,s);if(-1===c)return;const d=_s.getTool(a.getAttribute("data-tool"));if(!d)return;const p=d.input.isEmpty(a);if(e.preventDefault(),"issue"!==r.kind)if("embed"!==r.kind)if("image"===r.kind){const e={data:{alignment:"center",alt:"Image",caption:"",url:r.url},type:"image"};p?_s.replaceBlock(o.id,c,e):_s.insertBlock(e,o.id,c+1)}else{let e=r.url;r.isYouTube?e=function(e){const t=function(e){for(const t of[/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&\n?#]+)/,/youtube\.com\/embed\/([^&\n?#]+)/]){const n=e.match(t);if(n)return n[1]}return null}(e);return t?`https://www.youtube.com/embed/${t}`:null}(r.url)||r.url:r.isVimeo&&(e=function(e){const t=function(e){for(const t of[/vimeo\.com\/(\d+)/,/player\.vimeo\.com\/video\/(\d+)/]){const n=e.match(t);if(n)return n[1]}return null}(e);return t?`https://player.vimeo.com/video/${t}`:null}(r.url)||r.url);const t={data:{alignment:"center",alt:"Video",caption:"",url:e},type:"video"};p?_s.replaceBlock(o.id,c,t):_s.insertBlock(t,o.id,c+1)}else"offer"===(i?.pasteEmbeds??"live")?Bs.show(o.id,a,t,r.embed):D(o.id,c,p,t);else ht(o.id,0,c,p,t,r.issue)}},_s=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static createBlockElement(t,n){const a=C.getState().getInstance(n);if(!a)return console.error("BlockManager::createBlockElement: Instance not found for containerId:",n),null;const o=p("div",l.classNames.block.container);o.setAttribute("data-container-id",n),o.setAttribute("data-id",t.id??crypto.randomUUID()),o.setAttribute("data-tool",t.type),o.setAttribute("data-indent","0");const i={classNames:a.config.classNames?.blocks?.[t.type],styles:a.config.styles?.blocks?.[t.type]};let r,s;if(i.margins&&(r=i.margins.top,s=i.margins.bottom),void 0===r&&i.styles){const e=i.styles;if(e.marginTop){const t=e.marginTop;"string"==typeof t&&t.endsWith("px")?r=parseInt(t.replace("px",""),10):"number"==typeof t&&(r=t)}}if(void 0===s&&i.styles){const e=i.styles;if(e.marginBottom){const t=e.marginBottom;"string"==typeof t&&t.endsWith("px")?s=parseInt(t.replace("px",""),10):"number"==typeof t&&(s=t)}}void 0===r&&void 0!==a.config.margins?.top&&(r=a.config.margins.top),void 0===s&&void 0!==a.config.margins?.bottom&&(s=a.config.margins.bottom),void 0!==r&&(o.style.marginTop=`${r}px`),void 0!==s&&(o.style.marginBottom=`${s}px`),Fr.create({block:o,containerId:n});const c=p("div",l.classNames.block.content),d=e.renderTool(t.type,t.data,n);return d?(c.appendChild(d),e.addEventListener(n,o,"click",t=>e.focusBlock(t.currentTarget)),o.appendChild(c),v.apply(n,o),o):(console.error("BlockManager::createBlockElement: Rendered element not found for type:",t.type),null)}static insertBlock(t,n,a){e.adoptStartingBlock(n);const o=e.createBlockElement(t,n);if(!o)return null;e.renderBlock(o,n,a);const i=e.getBlockData(o.getAttribute("data-id"));return C.getState().addBlock(n,i,e.getBlockIndex(n,o.getAttribute("data-id"))),o}static removeBlock(t,n){const a=e.getBlocks(t);if(n<0||n>=a.length||1===a.length)return null;if(n>0){const t=e.getBlock(a[n-1].getAttribute("data-id"));t&&e.focusBlock(t)}else if(0===n&&a.length>1){const t=e.getBlock(a[n+1].getAttribute("data-id"));t&&e.focusBlock(t)}a[n].remove(),C.getState().removeBlock(t,n)}static replaceBlock(t,n,a){e.insertBlock(a,t,n+1),e.removeBlock(t,n)}static moveBlock(t,n,a){const o=e.getBlocks(t);if(n<0||n>=o.length||a<0||a>=o.length)return;const i=C.getState().getData(t);if(!i)return;const r=C.getState().getContentElement(t);if(!r)return;const s=o[n];o.splice(n,1),o.splice(a,0,s),0===a?r.insertBefore(s,r.firstChild):a>=o.length-1?r.appendChild(s):r.insertBefore(s,o[a+1]);const l=o.map(t=>e.getBlockData(t.getAttribute("data-id"))),c={...i,blocks:l};C.getState().setData(t,c),e.focusBlock(s)}static getBlock(e){return document.querySelector(`[data-id="${e}"]`)}static getBlocks(e){const t=document.getElementById(e);if(!t)return[];const n=t.querySelectorAll(`.${l.classNames.block.container}`);return Array.from(n)}static getActiveBlocks(e){const t=document.getElementById(e);if(!t)return[];const n=t.querySelectorAll(`.${l.classNames.block.active}`);return Array.from(n)}static getBlockIndex(t,n){return e.getBlocks(t).findIndex(e=>e.getAttribute("data-id")===n)}static getTool(e){return Sr.find(t=>t.type===e)||null}static getBlockData(t){const n=e.getBlock(t);if(!n)return{data:{html:""},type:"paragraph"};const a=n.getAttribute("data-tool"),o=a?e.getTool(a):null;if(!o)return{data:{html:""},id:t,type:"paragraph"};const i=n.querySelector(`.${l.classNames.block.content}`);return i?{data:o.input.save(i),id:t,tunes:e.getBlockTunes(n),type:a}:{data:{html:""},id:t,tunes:e.getBlockTunes(n),type:a}}static extractData(t){return{blocks:e.getBlocks(t).map(t=>e.getBlockData(t.getAttribute("data-id"))),time:Date.now(),version:"1.0.0"}}static renderTool(e,t,n){const a=C.getState().getInstance(n);if(!a)return null;const o={classNames:a.config.classNames?.blocks?.[e],styles:a.config.styles?.blocks?.[e]};switch(e){case"alert":return St.render(n,t,o);case"audio":return a.config.audioUploader?Tt.render(a.config.audioUploader,n,t,o):(console.error("BlockManager::renderTool: Audio uploader not found for containerId:",n),null);case"code":return he.render(n,t,o);case"collapsible":return Wt.render(n,t,o);case"columns":return Di.render(n,t,o);case"date":return ji.render(n,t,o);case"delimiter":return cn.render(n,t,o);case"collection":return Ti.render(n,t,o);case"doc_card":return Ri.render(n,t,o);case"embed":return pt.render(n,t,o);case"openapi":return ir.render(n,t,o);case"sketch":return dr.render(n,t,o);case"latex":return vr.render(n,t,o);case"mermaid":return yr.render(n,t,o);case"file":return a.config.fileUploader?Wi.render(a.config.fileUploader,n,t,o):(console.error("BlockManager::renderTool: File uploader not found for containerId:",n),null);case"glance":return Ji.render(n,t,o);case"header":return An.render(n,t,o);case"image":return a.config.imageUploader?Bn.render(a.config.imageUploader,n,t,o):(console.error("BlockManager::renderTool: Image uploader not found for containerId:",n),null);case"list":return Dn.render(n,t,o);case"checklist":return jt.render(n,t,o);case"paragraph":return ga.render(n,t,o);case"quote":return ya.render(n,t,o);case"table":return Fa.render(n,t,o);case"toc":return hr.render(n,t,o);case"issues":return er.render(n,t,o);case"updates":return Cr.render(n,t,o);case"video":return a.config.videoUploader?Si.render(a.config.videoUploader,n,t,o):(console.error("BlockManager::renderTool: Video uploader not found for containerId:",n),null);default:return null}}static focusBlock(t){const n=t.querySelector('[contenteditable="true"]');n&&n.focus({preventScroll:!0}),e.setActiveBlock(t)}static setActiveBlock(t){const n=t.getAttribute("data-container-id");for(const a of e.getActiveBlocks(n))a.classList.remove(l.classNames.block.active);t.classList.add(l.classNames.block.active),Fr.show(n,t)}static getActiveBlock(e){const t=document.getElementById(e);return t?t.querySelector(`.${l.classNames.block.active}`):null}static convertBlock(t,n,a){const o=e.getBlock(t);if(!o)return console.error("BlockManager::convertBlock: Block not found for blockId:",t);e.adoptStartingBlock(a);const i=e.getBlockData(t),r=e.getTool(n);if(!r)return console.error("BlockManager::convertBlock: New tool not found for newType:",n);const s=e.getBlockIndex(a,t);let l=i.data;if("list"===n){const e=i.data,t=e.html||e.text||"";l={items:t?[t]:[""],type:"unordered"}}else if("header"===n){const e=i.data;l={html:e.html||e.text||"",level:"h1"}}const c={data:l,id:t,type:r.type},d=e.createBlockElement(c,a);if(!d)return console.error("BlockManager::convertBlock: New block element not found for newType:",n);o.replaceWith(d);const p=e.getBlockData(d.getAttribute("data-id"));C.getState().updateBlock(a,s,p),e.focusBlock(d)}static getBlockTunes(e){const t={},n=e.querySelectorAll("[data-tune]");for(const a of n){const e=a.getAttribute("data-tune");e&&(t[e]=a.getAttribute("data-value")||!0)}return Object.keys(t).length>0?t:void 0}static updateStateFromRange(t){const n=Ts.getInstanceAndTargetFromRange(t);if(!n)return;const a=n.target.closest(`.${l.classNames.block.container}`);if(!a)return;e.adoptStartingBlock(n.instance.config.containerId);const o=e.getBlockIndex(n.instance.config.containerId,a.getAttribute("data-id"));C.getState().updateBlock(n.instance.config.containerId,o,e.getBlockData(a.getAttribute("data-id")))}static renderBlock(t,n,a){const o=e.getBlocks(n),i=C.getState().getContentElement(n);if(!i)return console.error("BlockManager::renderBlock: Container not found for containerId:",n);if(void 0!==a&&a>=0)if(a<o.length){const e=o[a];i.insertBefore(t,e),o.splice(a,0,t)}else i.appendChild(t),o.push(t);else i.appendChild(t),o.push(t);e.focusBlock(t);const r=C.getState().getInstance(n);r&&hs.initializeElements(t,{classNames:r.config.classNames?.blocks?.tooltip,styles:r.config.styles?.blocks?.tooltip})}static setBlocks(t,n){e.removeAllBlocks(n),t.forEach((t,a)=>e.insertBlock(t,n,a)),C.getState().updateData(n,{blocks:t})}static renderBlocks(t,n){for(const o of e.getBlocks(n))o.remove();const a=(t,a)=>{const o=e.createBlockElement(t,n);o&&e.renderBlock(o,n,a)};if(0===t.length)return a({data:{html:""},type:"paragraph"},0);t.forEach(a)}static adoptStartingBlock(t){const n=C.getState().getInstance(t)?.data.blocks,a=e.getBlocks(t);!n||n.length>0||1!==a.length||C.getState().seedBlocks(t,[e.getBlockData(a[0].getAttribute("data-id"))])}static removeAllBlocks(t){for(const n of e.getBlocks(t))n.remove();C.getState().setData(t,{blocks:[],time:Date.now(),version:"1.0.0"})}static resetBlocks(t){e.removeAllBlocks(t),e.insertBlock({data:{html:""},type:"paragraph"},t,0)}static getEditorId(e){const t=e.closest(`.${l.classNames.editor.container}`);return t?t.id:null}static handleKeydown(t){const n=t,a=t.currentTarget,o=a.closest(`.${l.classNames.block.container}`),i=e.getEditorId(o);if(!i)return;const r=e.getBlockIndex(i,o.getAttribute("data-id")),s=n.metaKey||n.ctrlKey;if(n.shiftKey)switch(n.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),r>0&&e.moveBlock(i,r,r-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const n=e.getBlocks(i);n&&r<n.length-1&&e.moveBlock(i,r,r+1)}else if(s)switch(n.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),e.removeBlock(i,r)}else if("Enter"===n.key)n.preventDefault(),n.stopPropagation(),e.insertBlock({data:{html:""},type:"paragraph"},i,r+1);else if("Backspace"===n.key){if(!h(a.innerHTML))return;n.preventDefault(),n.stopPropagation(),e.removeBlock(i,r)}else{e.ensureActiveBlock(i);const a=e.getBlocks(i);switch(n.key){case"ArrowUp":if(t.preventDefault(),t.stopPropagation(),r>0){const t=a[r-1];t&&e.focusBlock(t)}return;case"ArrowDown":if(t.preventDefault(),t.stopPropagation(),r<a.length-1){const t=a[r+1];t&&e.focusBlock(t)}return}}}static handleInput(t){e.saveBlockData(t.currentTarget)}static ensureActiveBlock(t){const n=e.getBlocks(t);let a=e.getActiveBlock(t);if(!a){const t=document.activeElement;if(!t)return;const o=t.closest(`.${l.classNames.block.container}`);if(o)a=o,e.setActiveBlock(a);else{if(0===n.length)return;a=n[0],e.setActiveBlock(a)}}}static saveBlockData(t){const n=t.closest(`.${l.classNames.block.container}`),a=e.getEditorId(n);if(!a)return;e.adoptStartingBlock(a),v.clear(a,n);const o=n.getAttribute("data-id");C.getState().updateBlockData(a,e.getBlockIndex(a,o),e.getBlockData(o).data)}static updateBlockData(t,n,a){e.adoptStartingBlock(a);const o=e.getBlock(t);if(o){const t=o.querySelector(`.${l.classNames.block.content}`);t&&(t.innerHTML="");const i=e.renderTool(o.getAttribute("data-tool"),n,a);i&&t.appendChild(i),v.apply(a,o)}C.getState().updateBlockData(a,e.getBlockIndex(a,t),n)}static destroy(t){if(!document.getElementById(t))return;const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[]),Sr.forEach(e=>e.input.destroy(t));for(const a of e.getBlocks(t))a.remove()}},qs=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static create(t){const n=C.getState().getInstance(t);if(!n)return console.error("ActionBar::create: Instance not found for containerId:",t);l.injectStyles("clepit-action-bar-styles",'\n.clepit-action-bar {\n display: flex;\n align-items: center;\n gap: 8px;\n min-height: 40px;\n border-bottom: 1px solid var(--clepit-border);\n}\n\n.clepit-action-bar-group {\n display: flex;\n align-self: stretch;\n gap: 4px;\n}\n\n.clepit-action-bar-button {\n display: inline-flex;\n align-items: center;\n margin-bottom: -1px;\n padding: 8px 12px 10px;\n border: 0;\n border-bottom: 2px solid transparent;\n background: transparent;\n color: var(--clepit-text-muted);\n font-family: inherit;\n font-size: 13.5px;\n font-weight: 500;\n white-space: nowrap;\n cursor: pointer;\n transition: color 0.15s ease, border-color 0.15s ease;\n}\n\n.clepit-action-bar-button:hover {\n color: var(--clepit-text);\n}\n\n.clepit-action-bar-button[aria-selected="true"] {\n color: var(--clepit-text);\n border-bottom-color: var(--clepit-primary);\n}\n\n.clepit-action-bar-button:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: -2px;\n}\n\n.clepit-view-actions {\n display: flex;\n align-items: center;\n gap: 2px;\n margin-inline-start: auto;\n}\n\n.clepit-view-action-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n border: 0;\n border-radius: var(--clepit-radius-md);\n background: transparent;\n color: var(--clepit-text-muted);\n cursor: pointer;\n transition: background-color 0.15s ease, color 0.15s ease;\n}\n\n.clepit-view-action-button svg {\n width: 18px;\n height: 18px;\n}\n\n.clepit-view-action-button:hover {\n background: var(--clepit-hover-bg);\n color: var(--clepit-text);\n}\n\n.clepit-view-action-button:active {\n background: var(--clepit-pressed-bg);\n}\n\n.clepit-view-action-button:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: 1px;\n}\n\n.clepit-view-action-button--copy-feedback {\n background-color: var(--clepit-success);\n color: var(--clepit-bg);\n}\n\n.clepit-action-bar ~ .clepit-editor-content {\n border-top: 0;\n border-start-start-radius: 0;\n border-start-end-radius: 0;\n}\n\n@media (pointer: coarse) {\n .clepit-action-bar-button {\n min-height: 44px;\n }\n\n .clepit-view-action-button {\n width: 44px;\n height: 44px;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .clepit-action-bar-button,\n .clepit-view-action-button {\n transition: none;\n }\n}\n');const a=document.getElementById(t);if(!a)return;const o=!1!==n.config.hasViewSwitcher,i=!1!==n.config.hasDocumentActions;if(!o&&!i)return;const r=n.config.styles?.controls?.group,s=n.config.classNames?.controls?.group,c=n.config.styles?.controls?.button,d=n.config.classNames?.controls?.button,u=n.config.styles?.tooltips,h=n.config.classNames?.tooltips,m=p("div",l.classNames.actionBar.container);e.createButtonGroup(a,m,{buttonClassNames:d,buttonStyles:c,currentView:n.currentView,groupClassNames:s,groupStyles:r,hasDocumentActions:i,hasViewSwitcher:o,labels:n.config.controlLabels,tooltipClassNames:h,tooltipStyles:u}),a.insertBefore(m,a.firstChild)}static createButtonGroup(t,n,a){const o=(e,t)=>a.labels?.[e]||t,i=o("copyJson","Copy as JSON"),r=o("downloadJson","Download as JSON"),s=o("clearEditor","Clear page");if(a.hasViewSwitcher){const i=p("div",l.classNames.actionBar.group,{"aria-label":o("viewSwitcher","Editor view"),role:"tablist"});l.applyStyling(i,{classNames:a.groupClassNames,styles:a.groupStyles});const r=[{label:o("editView","Edit"),suffix:l.idSuffixes.actionBar.editButton,testId:"action-bar-edit-button",view:"edit"},{label:o("previewView","Preview"),suffix:l.idSuffixes.actionBar.previewButton,testId:"action-bar-preview-button",view:"preview"},{label:o("jsonView","JSON"),suffix:l.idSuffixes.actionBar.jsonButton,testId:"action-bar-json-button",view:"json"}];for(const n of r){const o=n.view===a.currentView,r=p("button",l.classNames.actionBar.button,{"aria-label":n.label,"aria-selected":String(o),"data-testid":n.testId,"data-view":n.view,id:u(t.id,n.suffix),role:"tab",tabindex:o?"0":"-1",type:"button"});r.textContent=n.label,o&&r.classList.add("active"),l.applyStyling(r,{classNames:a.buttonClassNames,styles:a.buttonStyles}),e.addEventListener(t.id,r,"click",e.handleViewChange),i.appendChild(r)}e.addEventListener(t.id,i,"keydown",e.handleTabKeys),n.appendChild(i)}if(a.hasDocumentActions){const o=p("div",l.classNames.actionBar.action);l.applyStyling(o,{classNames:a.groupClassNames,styles:a.groupStyles});const c=p("button",l.classNames.actionBar.actionButton,{"aria-label":i,"data-testid":"view-copy-button",id:u(t.id,l.idSuffixes.actionBar.copyButton),type:"button"});c.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',l.applyStyling(c,{classNames:a.buttonClassNames,styles:a.buttonStyles});const d=p("button",l.classNames.actionBar.actionButton,{"aria-label":r,"data-testid":"view-download-button",id:u(t.id,l.idSuffixes.actionBar.downloadButton),type:"button"});d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7,10 12,15 17,10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',l.applyStyling(d,{classNames:a.buttonClassNames,styles:a.buttonStyles});const h=p("button",l.classNames.actionBar.actionButton,{"aria-label":s,"data-testid":"view-clear-button",id:u(t.id,l.idSuffixes.actionBar.clearButton),type:"button"});h.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',l.applyStyling(h,{classNames:a.buttonClassNames,styles:a.buttonStyles}),e.addEventListener(t.id,c,"click",e.handleCopyJson),e.addEventListener(t.id,d,"click",e.handleDownloadJson),e.addEventListener(t.id,h,"click",e.handleClearEditor),o.appendChild(c),o.appendChild(d),o.appendChild(h),n.appendChild(o),ye(c,i,"above",a.tooltipClassNames,a.tooltipStyles),ye(d,r,"above",a.tooltipClassNames,a.tooltipStyles),ye(h,s,"above",a.tooltipClassNames,a.tooltipStyles)}}static getCurrentView(e){const t=document.getElementById(e);if(!t)return console.error("ActionBar::getCurrentView: Container not found for containerId:",e),null;const n=t.querySelector(`.${l.classNames.actionBar.group}`);if(!n)return console.error("ActionBar::getCurrentView: View toggle group not found for container:",t.id),null;const a=n.querySelector(".active");return a?a.getAttribute("data-view"):(console.error("ActionBar::getCurrentView: Active button not found for container:",t.id),null)}static updateButtonStates(e,t){const n=document.getElementById(e);if(!n)return;const a=n.querySelector(`.${l.classNames.actionBar.container}`);a&&a.querySelectorAll(`#${u(e,l.idSuffixes.actionBar.editButton)}, #${u(e,l.idSuffixes.actionBar.previewButton)}, #${u(e,l.idSuffixes.actionBar.jsonButton)}`).forEach(e=>{const n=e.getAttribute("data-view")===t;e.classList.toggle("active",n),e.setAttribute("aria-selected",String(n)),e.setAttribute("tabindex",n?"0":"-1")})}static handleTabKeys(e){if(!(e instanceof KeyboardEvent))return;const t=e.currentTarget;if(!(t instanceof HTMLElement))return;const n=[...t.querySelectorAll('[role="tab"]')],a=n.findIndex(e=>e===document.activeElement);if(a<0)return;const o={ArrowLeft:a-1,ArrowRight:a+1,End:n.length-1,Home:0}[e.key];if(void 0===o)return;e.preventDefault();const i=n[(o+n.length)%n.length];i.focus(),i.click()}static handleViewChange(t){const n=t.currentTarget,a=_s.getEditorId(n);if(!a)return;const o=n.getAttribute("data-view");o&&(C.getState().setCurrentView(a,o),e.updateButtonStates(a,o))}static handleCopyJson(e){const t=e.currentTarget,n=_s.getEditorId(t);if(!n)return;const a=C.getState().getInstance(n);a&&(navigator.clipboard.writeText(JSON.stringify(a.data,null,2)),t.classList.add(l.classNames.actionBar.copyFeedback),setTimeout(()=>t.classList.remove(l.classNames.actionBar.copyFeedback),200))}static handleClearEditor(e){const t=e.currentTarget,n=_s.getEditorId(t);if(!n)return;const a=C.getState().getInstance(n)?.config.onClearRequest;a?a().then(e=>{e&&_s.resetBlocks(n)},e=>console.error("Clear was not confirmed, the page is unchanged:",e)):_s.resetBlocks(n)}static handleDownloadJson(e){const t=e.currentTarget,n=_s.getEditorId(t);if(!n)return;const a=_s.getBlocks(n).map(e=>_s.getBlockData(e.getAttribute("data-id"))),o=new Blob([JSON.stringify(a,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${n}--content.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(i)}static destroy(e){const t=document.getElementById(e);if(!t)return;const n=t.querySelector(`.${l.classNames.actionBar.container}`);n&&n.remove()}},Ds=`\n/* Editor Container */\n.${l.classNames.editor.container} {\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n line-height: 1.6;\n color: var(--clepit-text);\n padding: 20px; /* Normal padding - no extra left padding needed */\n outline: none;\n box-sizing: border-box;\n width: 100%;\n}\n\n.${l.classNames.editor.container}:focus {\n outline: none;\n}\n\n.${l.classNames.editor.container}[data-readonly="true"] {\n background: var(--clepit-surface);\n color: var(--clepit-text-muted);\n cursor: not-allowed;\n}\n\n/* Editor Content Container */\n.${l.classNames.editor.content} {\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n overflow-y: auto;\n padding: 16px 24px; /* Increased horizontal padding for better preview content spacing */\n background: var(--clepit-bg);\n height: 100%;\n max-height: var(--clepit-max-height, 410px);\n min-height: var(--clepit-min-height, 200px);\n}\n\n/* JSON Output */\n.${l.classNames.editor.jsonOutput} {\n margin: 0;\n padding: 16px;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n font-size: 13px;\n line-height: 1.4;\n color: var(--clepit-text); /* default readonly is black */\n overflow-x: auto;\n white-space: pre-wrap;\n word-wrap: break-word;\n outline: none;\n min-height: 100%;\n}\n\n.${l.classNames.editor.jsonOutput}:focus {\n outline: none;\n}\n\n/* Editable (allowed) -> green text */\n.${l.classNames.editor.jsonOutput}.clepit-json-editable {\n color: var(--clepit-success);\n}\n\n/* Invalid JSON -> red text */\n.${l.classNames.editor.jsonOutput}.clepit-json-error {\n color: var(--clepit-error);\n background-color: transparent;\n}\n\n.${l.classNames.editor.jsonEmpty} {\n padding: 16px;\n text-align: center;\n color: var(--clepit-text-muted);\n font-style: italic;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n /* Container and content each carried their own inset, so a phone spent 80px\n * of a ~400px editor on nested padding before a single character. */\n .${l.classNames.editor.container} {\n padding: 8px;\n }\n\n .${l.classNames.editor.content} {\n padding: 12px;\n }\n}\n`,zs=class e{static{this.timers={}}static{this.focusHandlers={}}static start(t){if(e.stop(t),!(C.getState().getInstance(t)?.config)?.resolveIssues)return;e.run(t),e.timers[t]=setInterval(()=>{e.run(t)},3e5);const n=()=>{e.run(t)};window.addEventListener("focus",n),e.focusHandlers[t]=n}static stop(t){const n=e.timers[t];n&&clearInterval(n),delete e.timers[t];const a=e.focusHandlers[t];a&&window.removeEventListener("focus",a),delete e.focusHandlers[t]}static urls(e){const t=document.getElementById(e);if(!t)return[];const n=/* @__PURE__ */new Set;for(const a of Oe.collect(t))n.add(Oe.read(a).url);for(const a of _s.getBlocks(e)){if("embed"!==a.getAttribute("data-tool"))continue;const e=pt.save(a);e.issue&&n.add(e.url)}return n.delete(""),[...n]}static async run(t){const n=e.urls(t);if(0===n.length)return;const a=await ut(t,n),o=document.getElementById(t),i=C.getState().getInstance(t)?.config;if(o&&i&&0!==Object.keys(a).length){Oe.refreshAll(o,a,i.issueLabels);for(const e of _s.getBlocks(t)){if("embed"!==e.getAttribute("data-tool"))continue;const n=pt.save(e),o=n.issue?a[n.url]:void 0;o&&pt.refreshIssue(e,t,o)}er.refresh(t,a)}}},js=class{static render(e){const t=C.getState().getInstance(e);t&&(Ls.create(e),l.injectStyles("clepit-block-manager-styles",'\n/* Blocks */\n.clepit-block {\n position: relative;\n margin: var(--block-margin-top, 8px) 0 var(--block-margin-bottom, 16px) 0;\n padding: 8px 0;\n padding-left: 54px;\n border-radius: 4px;\n transition: background-color 0.2s ease;\n display: flex;\n align-items: flex-start;\n gap: 6px;\n}\n\n.clepit-block--active {\n background-color: transparent;\n}\n\n.clepit-block-content {\n outline: none;\n min-height: 1.2em;\n flex: 1;\n min-width: 0; /* Allow content to shrink */\n}\n\n.clepit-block[data-showing-locale] .clepit-block-content {\n color: color-mix(in oklab, var(--clepit-text) 60%, transparent);\n}\n\n.clepit-block-showing-locale {\n display: inline-flex;\n flex: none;\n align-items: center;\n align-self: flex-start;\n height: 18px;\n margin-top: 2px;\n padding: 0 6px;\n border-radius: 999px;\n background-color: var(--clepit-surface-2);\n color: var(--clepit-text-muted);\n font-size: 11px;\n font-weight: 500;\n letter-spacing: 0.02em;\n line-height: 1;\n user-select: none;\n}\n\n/* Remove focus outline from editable elements */\n.clepit-block-content [contenteditable="true"] {\n outline: none;\n}\n\n/* Placeholder styles for all text elements */\n.clepit-block-content:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Menu animation classes */\n.clepit-block-type-selector--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-type-selector--hidden {\n display: none;\n}\n\n/* Block Operations Menu */\n.clepit-block-operations-menu {\n position: absolute;\n top: 100%;\n left: 0;\n z-index: 1001;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 200px;\n margin-top: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-operations-menu--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-operations-menu--hidden {\n display: none;\n}\n\n/* Block Type Selector */\n.clepit-block-type-selector {\n position: absolute;\n top: 100%;\n left: 0;\n z-index: 1001;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 150px;\n margin-top: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-type-selector--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-type-selector--hidden {\n display: none;\n}\n\n.clepit-menu-item {\n box-sizing: border-box;\n display: flex;\n gap: 12px;\n align-items: center;\n min-height: 38px;\n padding: 8px 10px;\n border-radius: var(--clepit-radius-md);\n color: var(--clepit-text);\n font-size: 14px;\n line-height: 1.5;\n cursor: pointer;\n transition: background-color 120ms ease;\n}\n\n.clepit-menu-item .clepit-menu-icon {\n display: inline-flex;\n flex: none;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n color: var(--clepit-text-muted);\n}\n\n.clepit-menu-item .clepit-menu-icon--text {\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0;\n}\n\n.clepit-menu-arrow svg {\n display: block;\n width: 18px;\n height: 18px;\n}\n\n.clepit-menu-icon svg {\n display: block;\n width: 18px;\n height: 18px;\n}\n\n.clepit-menu-item:hover,\n.clepit-menu-item[data-highlighted] {\n background-color: var(--clepit-hover-bg);\n}\n\n.clepit-menu-item.active {\n background-color: var(--clepit-pressed-bg);\n color: var(--clepit-primary);\n}\n\n.clepit-menu-item--danger,\n.clepit-menu-item--danger .clepit-menu-icon {\n color: var(--clepit-error);\n}\n\n.clepit-menu-item--danger:hover,\n.clepit-menu-item--danger[data-highlighted] {\n background-color: var(--clepit-danger-bg);\n}\n\n.clepit-menu-group {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.clepit-menu-group + .clepit-menu-group {\n margin-top: 6px;\n padding-top: 6px;\n border-top: 1px solid var(--clepit-border);\n}\n\n.clepit-menu-section {\n margin: 0;\n padding: 6px 10px 4px;\n color: var(--clepit-text-subtle);\n font-size: 12px;\n font-weight: 600;\n line-height: 1.4;\n}\n\n.clepit-menu-divider {\n height: 1px;\n margin: 6px 0;\n background: var(--clepit-border);\n}\n\n.clepit-menu-arrow {\n margin-left: auto;\n color: var(--clepit-text-subtle);\n}\n\n.clepit-block-type-selector input {\n width: 100%;\n min-height: 34px;\n margin-bottom: 6px;\n padding: 6px 10px;\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n background-color: var(--clepit-bg);\n color: var(--clepit-text);\n font-size: 14px;\n outline: none;\n transition: border-color 120ms ease;\n}\n\n.clepit-block-type-selector input:focus-visible {\n border-color: var(--clepit-focus-ring);\n box-shadow: 0 0 0 1px var(--clepit-focus-ring);\n}\n\n.clepit-block-type-selector input::placeholder {\n color: var(--clepit-text-subtle);\n}\n\n.clepit-block-type-selector-items {\n display: flex;\n flex-direction: column;\n gap: 2px;\n max-height: 360px;\n overflow-y: auto;\n}\n\n.clepit-not-found-message {\n padding: 8px 10px;\n color: var(--clepit-text-muted);\n font-size: 14px;\n}\n\n.clepit-menu-shortcut {\n margin-left: auto;\n padding-left: 12px;\n color: var(--clepit-text-subtle);\n font-size: 12px;\n white-space: nowrap;\n}\n\n.clepit-menu-positioned {\n position: absolute;\n z-index: 1001;\n top: var(--menu-top, 0);\n left: var(--menu-left, 0);\n}\n\n/* The block menus are popovers in the top layer. Anchor positioning puts them\n * under the block toolbar without JavaScript measuring anything.\n *\n * Guarded: anchor positioning is Baseline 2026 (Chrome 125+, Firefox 132+,\n * Safari 18.2+), roughly 91% of traffic. Browsers without it get the popover\'s\n * default centred placement rather than a second JS positioning path — the menu\n * stays usable, just not adjacent to its button. */\n.clepit-block-type-selector:popover-open,\n.clepit-block-operations-menu:popover-open {\n /* The base menu rules above still say display:none from the pre-popover\n * mechanism, and an author rule outranks the UA\'s popover reveal. Without\n * an explicit display here every menu opens into the top layer invisible. */\n display: block;\n min-width: 260px;\n margin: 0;\n border: 0;\n border-radius: var(--clepit-radius-lg);\n background: var(--clepit-menu-bg);\n box-shadow: var(--clepit-menu-shadow);\n padding: 6px;\n overflow: visible;\n}\n\n.clepit-convert-submenu:popover-open {\n display: block;\n}\n\n@supports (anchor-name: --a) {\n .clepit-block-type-selector:popover-open,\n .clepit-block-operations-menu:popover-open {\n position-anchor: --clepit-block-toolbar;\n position-area: block-end span-inline-end;\n margin-block-start: 5px;\n inset: auto;\n }\n}\n\n@supports (position-try-fallbacks: flip-block) {\n .clepit-block-type-selector:popover-open,\n .clepit-block-operations-menu:popover-open {\n position-try-fallbacks: flip-block;\n }\n}\n\n/* Convert Submenu */\n@supports (anchor-name: --a) {\n .clepit-convert-submenu:popover-open {\n position: fixed;\n position-area: inline-end span-block-end;\n margin: 0 0 0 4px;\n inset: auto;\n }\n\n .clepit-convert-submenu:popover-open {\n position-try-fallbacks: flip-inline;\n }\n}\n\n.clepit-convert-submenu {\n position: absolute;\n top: var(--submenu-top, 0);\n left: var(--submenu-left, 100%);\n z-index: var(--submenu-z-index, 1002);\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 140px;\n margin-left: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-convert-submenu--visible {\n display: block;\n opacity: 1;\n transform: translateX(0);\n}\n\n.clepit-convert-submenu--hidden {\n display: none;\n opacity: 0;\n transform: translateX(-10px);\n}\n\n/* Input styles for convert submenu */\n.clepit-convert-submenu input {\n width: 100%;\n padding: 6px 8px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 12px;\n outline: none;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-convert-submenu input:focus {\n border-color: var(--clepit-input-focus-border, var(--clepit-primary));\n box-shadow: 0 0 0 2px var(--clepit-input-focus-shadow, var(--clepit-primary-bg));\n}\n\n.clepit-convert-submenu input::placeholder {\n color: var(--clepit-input-placeholder, var(--clepit-text-subtle));\n}\n\n.clepit-convert-submenu-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-block-operation-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n}\n\n.clepit-block-operation-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-selection-bg));\n}\n\n/* Input styles for operations menu */\n.clepit-block-operations-menu input {\n width: 100%;\n padding: 8px 12px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 14px;\n margin-bottom: 8px;\n outline: none;\n transition: border-color 0.2s;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-block-operations-menu input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n.clepit-block-operations-menu input::placeholder {\n color: var(--placeholder-color, var(--clepit-text-subtle));\n}\n\n.clepit-block-operations-menu-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-block-operation-item[data-operation="delete"] {\n color: var(--clepit-error);\n}\n\n/* Convert submenu items */\n.clepit-convert-option-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n}\n\n.clepit-convert-option-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-selection-bg));\n}\n\n/* Indentation */\n.clepit-block[data-indent="1"] .clepit-block-content {\n margin-left: 20px;\n}\n\n.clepit-block[data-indent="2"] .clepit-block-content {\n margin-left: 40px;\n}\n\n.clepit-block[data-indent="3"] .clepit-block-content {\n margin-left: 60px;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n /* The 54px gutter exists to hold the block toolbar, which is only ever\n * displayed on the active block. On a phone that reserved a seventh of the\n * editor\'s width on every idle block at once, pushing the text into a narrow\n * column with empty space either side. Give the width back and let the\n * gutter open only under the block whose toolbar is actually showing. */\n /* No transition on padding-left. The block element is re-created as you\n * interact with it, so an animated gutter restarts from 0 every time and\n * never reaches its end value — the toolbar would sit on top of the text. */\n .clepit-block {\n padding-left: 0;\n }\n\n .clepit-block--active,\n .clepit-block:focus-within,\n .clepit-block:has(.clepit-block-toolbar--visible) {\n padding-left: 54px;\n }\n}\n'),_s.renderBlocks(t.data.blocks,e))}},Hs=class e{static render(t){const n=C.getState().getInstance(t);if(!n)return;const a=document.getElementById(n.contentId);if(a)if(a.innerHTML="",n.data&&n.data.blocks&&n.data.blocks.length>0){const t=l.createStyledElement("pre",l.classNames.editor.jsonOutput);t.textContent=JSON.stringify(n.data,null,2),t.setAttribute("data-testid","json-editable-textarea"),n.config.allowJsonViewEditing&&(t.setAttribute("contenteditable","true"),t.classList.add(l.classNames.editor.jsonEditable),setTimeout(()=>t.focus(),0),e.addEventListeners(t)),a.appendChild(t)}else{const e=l.createStyledElement("div",l.classNames.editor.jsonEmpty);e.textContent="No content to display",a.appendChild(e)}}static addEventListeners(t){t.addEventListener("input",e.handleJsonInput),t.addEventListener("blur",e.validateAndUpdateJson),t.addEventListener("keydown",e.validateAndUpdateJson)}static removeEventListeners(t){t.removeEventListener("input",e.handleJsonInput),t.removeEventListener("blur",e.validateAndUpdateJson),t.removeEventListener("keydown",e.validateAndUpdateJson)}static handleJsonInput(e){const t=e.target,n=t.textContent||"",a=_s.getEditorId(t);if(a)try{const e=JSON.parse(n);if("object"==typeof e&&null!==e){e.blocks&&Array.isArray(e.blocks)||(e.blocks=[]);const t=C.getState().getInstance(a);if(t){const n=document.querySelector(`#${t.contentId} .${l.classNames.editor.jsonOutput}`);n&&(n.classList.remove(l.classNames.editor.jsonError),t.config.allowJsonViewEditing&&n.classList.add("clepit-json-editable"));const o=t.currentView;C.getState().setData(a,e),"json"===o&&C.getState().setCurrentView(a,"json"),console.log("Store updated successfully")}}}catch{const e=C.getState().getInstance(a);if(e){const t=document.querySelector(`#${e.contentId} .${l.classNames.editor.jsonOutput}`);t&&(t.classList.add("clepit-json-error"),t.classList.remove("clepit-json-editable"))}}}static validateAndUpdateJson(t){const n=t.target,a=n.textContent||"",o=_s.getEditorId(n);if(!o)return;const i=C.getState().getInstance(o);if(i)try{const t=JSON.parse(a);if("object"==typeof t&&null!==t){t.blocks&&Array.isArray(t.blocks)||(t.blocks=[]),Ls.hide(o),Fr.hide(o);const e=i.currentView;C.getState().setData(o,t),"json"===e&&C.getState().setCurrentView(o,"json");const n=document.querySelector(`#${i.contentId} .${l.classNames.editor.jsonOutput}`);n&&(n.classList.remove("clepit-json-error"),i.config.allowJsonViewEditing?n.classList.add("clepit-json-editable"):n.classList.remove("clepit-json-editable")),i.config.onChange&&i.config.onChange(t)}else e.markInvalid(i.contentId)}catch{e.markInvalid(i.contentId)}}static markInvalid(e){const t=document.querySelector(`#${e} .${l.classNames.editor.jsonOutput}`);t&&(t.classList.add("clepit-json-error"),t.classList.remove("clepit-json-editable"))}static destroy(t){const n=C.getState().getInstance(t);if(!n)return;const a=document.querySelector(`#${n.contentId} .${l.classNames.editor.jsonOutput}`);a&&e.removeEventListeners(a)}},Os=class extends Error{constructor(e,t){super(t),this.code=e,this.name="ClepitError"}},Ps=/* @__PURE__ */new Set(["alert.html","audio.alt","audio.caption","checklist.items","header.html","image.alt","image.caption","list.items","paragraph.html","quote.html","table.caption","table.data","video.alt","video.caption"]),Rs=(e,t)=>Ps.has(`${e}.${t}`),Fs=/* @__PURE__ */new Set(["checklist.items","list.items","table.data"]),Vs=(e,t)=>Fs.has(`${e}.${t}`),Us=(e,t,n,a)=>{if(!Array.isArray(t))return t;let o=!1;const i=e=>{const t=((e,t,n)=>{const a=Js(e,t,n);return null===a?e:a.value})(e,n,a);return t!==e&&(o=!0),t},r=t.map(t=>{if("table"===e)return Array.isArray(t)?t.map(i):t;if("checklist"===e){if("object"!=typeof t||null===t)return t;const e=t,n=i(e.text);return n===e.text?t:{...e,text:n}}return i(t)});return o?r:t},Ws=(e,t,n,a)=>{let o=!1;const i={};for(const[r,s]of Object.entries(t)){if(Vs(e,r)){const t=Us(e,s,n,a);i[r]=t,t!==s&&(o=!0);continue}if(!Rs(e,r)){i[r]=s;continue}const t=Js(s,n,a);null!==t?(i[r]=t.value,t.value!==s&&(o=!0)):i[r]=s}return o?i:t},Ks=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Gs=(e,t)=>Ks(e)?Object.keys(e).sort():[t],Js=(e,t,n)=>{if(void 0===e)return null;if(!Ks(e))return{isFallback:t!==n,locale:n,value:e};const a=e[t];if(void 0!==a)return{isFallback:!1,locale:t,value:a};const o=e[n];if(void 0!==o)return{isFallback:!0,locale:n,value:o};const i=Object.keys(e).sort()[0];return void 0===i?null:{isFallback:!0,locale:i,value:e[i]}},Xs=(e,t,n,a)=>void 0===e?t===a?n:{[t]:n}:Ks(e)?{...e,[t]:n}:t===a?n:{[a]:e,[t]:n},Ys=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Zs=e=>"string"==typeof e?e:"",Qs=(e,t,n,a)=>{const o=Js(e,n,a);return null!==o&&o.value===t?e:Xs(e,n,t,a)},el=(e,t,n)=>"table"===e?Array.isArray(t)?t.map(e=>Zs(n(e))).join("\0"):"":"checklist"===e?Ys(t)?Zs(n(t.text)):"":Zs(n(t)),tl=(e,t,n,a,o)=>{if(!Array.isArray(n))return n;const i=Array.isArray(t)?t:[],r=e=>Js(e,a,o)?.value,s=((e,t)=>{const n=Array.from({length:e.length+1},()=>new Array(t.length+1).fill(0));for(let c=e.length-1;c>=0;c--)for(let a=t.length-1;a>=0;a--)n[c][a]=e[c]===t[a]?n[c+1][a+1]+1:Math.max(n[c+1][a],n[c][a+1]);const a=new Array(t.length).fill(null);let o=[],i=[];const r=()=>{i.forEach((e,t)=>{a[e]=t<o.length?o[t]:null}),o=[],i=[]};let s=0,l=0;for(;s<e.length&&l<t.length;)e[s]===t[l]?(r(),a[l]=s,s++,l++):n[s+1][l]>=n[s][l+1]?o.push(s++):i.push(l++);for(;s<e.length;)o.push(s++);for(;l<t.length;)i.push(l++);return r(),a})(i.map(t=>el(e,t,r)),n.map(t=>el(e,t,e=>e)));return n.map((t,n)=>{const r=s[n];return((e,t,n,a,o)=>{if("table"===e){if(!Array.isArray(n))return n;const e=Array.isArray(t)?t:[];return n.map((t,n)=>Qs(e[n],t,a,o))}return"checklist"===e?Ys(n)?{...n,text:Qs(Ys(t)?t.text:void 0,n.text,a,o)}:n:Qs(t,n,a,o)})(e,null===r?void 0:i[r],t,a,o)})},nl=(e,t,n,a,o)=>{const i={};for(const[r,s]of Object.entries(n))Vs(e,r)?i[r]=tl(e,t?.[r],s,a,o):Rs(e,r)?i[r]=Qs(t?.[r],s,a,o):i[r]=s;for(const[r,s]of Object.entries(t??{}))r in n||!Rs(e,r)||Vs(e,r)||Gs(s,o).some(e=>e!==a)&&(i[r]=Xs(s,a,"",o));return i},al=(e,t)=>{if(Ys(e))for(const n of Object.keys(e))t.add(n)},ol=e=>{const t=/* @__PURE__ */new Set;for(const n of e)if(Ys(n.data))for(const[e,a]of Object.entries(n.data))if(Vs(n.type,e)&&Array.isArray(a))for(const o of a)if("table"===n.type){if(Array.isArray(o))for(const e of o)al(e,t)}else"checklist"===n.type?Ys(o)&&al(o.text,t):al(o,t);else Rs(n.type,e)&&al(a,t);return[...t].sort()[0]},il="clepit-theme-styles",rl=".clepit-editor, .clepit-renderer-content, body[data-clepit-theme]",sl=`@layer clepit.reset, clepit.tokens, clepit.blocks, clepit.overrides;\n\n${Rr=i,Object.keys(r).map(e=>`@property ${r[e]} {\n syntax: '<color>';\n inherits: true;\n initial-value: ${Rr[e]};\n}`).join("\n\n")}\n\n@property --clepit-radius-md {\n syntax: '<length>';\n inherits: true;\n initial-value: 8px;\n}\n\n@property --clepit-radius-lg {\n syntax: '<length>';\n inherits: true;\n initial-value: 12px;\n}\n\n@layer clepit.tokens {\n${s(i,{bg:"#161b22",blockHighlightBg:"rgba(0, 0, 0, 0.25)",border:"rgba(240, 246, 252, 0.1)",borderSubtle:"rgba(240, 246, 252, 0.06)",codeBg:"#1e242c",codeBorder:"rgba(240, 246, 252, 0.10)",codeComment:"rgba(240, 246, 252, 0.42)",codeFunction:"#d2a8ff",codeGutter:"rgba(240, 246, 252, 0.42)",codeKeyword:"#ff7b72",codeNumber:"#79c0ff",codePunctuation:"#c9d1d9",codeSelectionBg:"rgba(120, 129, 255, 0.18)",codeString:"#a5d6ff",codeText:"rgba(240, 246, 252, 0.92)",codeType:"#ffa657",dangerBg:"rgba(248, 113, 113, 0.12)",error:"#f87171",errorBg:"rgba(248, 113, 113, 0.12)",focusRing:"#7881ff",hoverBg:"rgba(120, 129, 255, 0.08)",info:"#60a5fa",infoBg:"rgba(96, 165, 250, 0.12)",inverseSurface:"#ffffff",inverseText:"rgba(0, 0, 0, 0.87)",marker:"rgba(255, 224, 71, 0.28)",menuBg:"#1c222a",onPrimary:"#000000",pressedBg:"rgba(120, 129, 255, 0.12)",primary:"#7881ff",primaryBg:"rgba(120, 129, 255, 0.14)",primaryHover:"#8896ff",selectionBg:"rgba(120, 129, 255, 0.18)",success:"#4ade80",successBg:"rgba(74, 222, 128, 0.12)",surface:"#1c222a",surface2:"#222a33",text:"rgba(240, 246, 252, 0.92)",textMuted:"rgba(240, 246, 252, 0.62)",textSubtle:"rgba(240, 246, 252, 0.42)",warning:"#fbbf24",warningBg:"rgba(251, 191, 36, 0.12)"},rl)}\n\n${rl} {\n color-scheme: light;\n}\n\n${rl} {\n --clepit-menu-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);\n}\n\n.clepit-editor[data-clepit-theme='auto'], .clepit-renderer-content[data-clepit-theme='auto'], body[data-clepit-theme='auto'] {\n color-scheme: light dark;\n}\n\n.clepit-editor[data-clepit-theme='dark'], .clepit-renderer-content[data-clepit-theme='dark'], body[data-clepit-theme='dark'] {\n color-scheme: dark;\n}\n\n.clepit-editor[data-clepit-theme='light'], .clepit-renderer-content[data-clepit-theme='light'], body[data-clepit-theme='light'] {\n color-scheme: light;\n}\n}\n\n@layer clepit.blocks {\n[data-clepit-block-id]:target {\n background: var(--clepit-block-highlight-bg);\n border-radius: 6px;\n scroll-margin-top: 24px;\n}\n}\n`,ll=class e{static render(t){const n=document.getElementById(t.containerId);if(!n)throw new Os("CONTAINER_MISSING",`Container element with ID '${t.containerId}' not found`);return l.injectStyles(il,sl),l.injectStyles(es,ts),l.injectStyles(Ae,Se),n.classList.add(l.classNames.renderer.content),l.registerEditor(t.containerId,t.theme??"auto",t.themeOverrides),n.innerHTML="",Oe.applyParts(n,t.issueChip),t.data?.blocks&&Array.isArray(t.data.blocks)?(t.data.blocks.forEach((a,o)=>{const i=e.renderBlock(e.localize(a,t),o,t);i&&n.appendChild(i)}),t.issues&&Oe.refreshAll(n,t.issues,t.issueLabels),n):n}static localize(e,t){if(!t.locale)return e;const n=Ws(e.type,e.data,t.locale,t.defaultLocale??t.locale);return n===e.data?e:{...e,data:n}}static renderBlock(e,t,n){const a=p("div",l.classNames.block.output);a.setAttribute("data-block-type",e.type),a.setAttribute("data-block-index",t.toString()),e.tunes&&Object.entries(e.tunes).forEach(([e,t])=>{a.setAttribute(`data-tune-${e}`,String(t))});const o=n.styles?.[e.type],i=n.classNames?.[e.type];let r,s,c,d=n.configs?.[e.type];if("paragraph"===e.type&&n.editorClassNames?.tooltips&&(d={...d,tooltipClassNames:n.editorClassNames.tooltips}),d?.margins&&(r=d.margins.top,s=d.margins.bottom),void 0===r&&void 0!==n.margins?.top&&(r=n.margins.top),void 0===s&&void 0!==n.margins?.bottom&&(s=n.margins.bottom),void 0!==r){const e=parseFloat(a.style.marginTop||"0")||0;a.style.marginTop=`${e+r}px`}if(void 0!==s){const e=parseFloat(a.style.marginBottom||"0")||0;a.style.marginBottom=`${e+s}px`}switch(e.type){case"alert":c=Et.render(e.data,d,o,i);break;case"audio":c=_t.render(e.data,d,o,i);break;case"code":c=Ce.render(e.data,d,o,i);break;case"collapsible":c=$i.render(e.data,d,o,i);break;case"columns":c=en.render(e.data,d,o,i);break;case"date":c=sn.render(e.data,d,o,i);break;case"delimiter":c=dn.render(e.data,d,o,i);break;case"collection":c=Xt.render(e.data,d,o,i);break;case"updates":c=wi.render(e.data,d,o,i);break;case"glance":c=wn.render(e.data,d,o,i);break;case"embed":c=ot.render(e.data,{...d,issueLabels:n.issueLabels,issues:n.issues},o,i);break;case"sketch":c=La.render(e.data,d,o,i);break;case"latex":c=fi.render(e.data,d,o,i);break;case"mermaid":c=vi.render(e.data,d,o,i);break;case"openapi":c=ha.render(e.data,d,o,i);break;case"doc_card":c=mn.render(e.data,d,o,i);break;case"file":c=yn.render(e.data,d,o,i);break;case"header":c=Sn.render(e.data,d,o,i);break;case"image":c=$n.render(e.data,d,o,i);break;case"list":c=zn.render(e.data,d,o,i);break;case"checklist":c=Ht.render(e.data,d,o,i);break;case"paragraph":c=ba.render(e.data,d,o,i);break;case"quote":c=xa.render(e.data,d,o,i);break;case"table":c=Ka.render(e.data,d,o,i);break;case"toc":c=Za.render(e.data,{...d,documentBlocks:n.data?.blocks??[]},o,i);break;case"issues":c=_n.render(e.data,{...d,documentBlocks:n.data?.blocks??[],issueLabels:n.issueLabels,issues:n.issues},o,i);break;case"video":c=Ei.render(e.data,d,o,i);break;default:c=null}return c?(a.appendChild(c),hs.initializeElements(a,{classNames:n.classNames?.tooltip,styles:n.styles?.tooltip}),a):null}},cl=class{static render(e){const t=C.getState().getInstance(e);t&&ll.render({classNames:t.config.classNames?.blocks,containerId:t.contentId,data:t.data,editorClassNames:t.config.classNames,margins:t.config.margins,styles:t.config.styles?.blocks})}},dl=class e{static{this.sources={}}static create(t){return e.teardown(t.containerId),e.initialize(t),qs.create(t.containerId),e.render(t.containerId),Ts.addListeners(t.containerId),zs.start(t.containerId),C.getState().setIsReady(t.containerId,!0),C.subscribe(e=>e.instances,(n,a)=>{const o=n[t.containerId];if(!o)return;const i=a[t.containerId];i&&o.currentView!==i.currentView&&e.render(t.containerId)}),{blocks:{convert:(e,n)=>_s.convertBlock(e,n,t.containerId),count:()=>_s.getBlocks(t.containerId).length,get:n=>_s.getBlock(n)?e.delocalizeBlock(t.containerId,_s.getBlockData(n)):null,getAll:()=>_s.getBlocks(t.containerId).map(n=>e.delocalizeBlock(t.containerId,_s.getBlockData(n.getAttribute("data-id")))),insert:(n,a,o,i)=>_s.insertBlock(e.localizeArriving(t.containerId,{data:a,id:i??Math.random().toString(36).substring(2,11),type:n}),t.containerId,o),move:(e,n)=>_s.moveBlock(t.containerId,e,n),remove:e=>_s.removeBlock(t.containerId,e),update:(n,a)=>{const o=_s.getBlock(n)?.getAttribute("data-tool")??"paragraph";_s.updateBlockData(n,e.localizeArriving(t.containerId,{data:a,id:n,type:o}).data,t.containerId)}},blur:()=>{const e=document.activeElement;e&&document.getElementById(t.containerId)?.contains(e)&&e.blur()},data:{clear:()=>{C.getState().clearData(t.containerId),_s.destroy(t.containerId)},clearContent:()=>_s.destroy(t.containerId),clearStorage:()=>C.getState().clearData(t.containerId),extract:()=>e.delocalizeData(t.containerId,_s.extractData(t.containerId)),set:n=>_s.setBlocks(n.blocks.map(n=>e.localizeArriving(t.containerId,n)),t.containerId)},destroy:()=>e.destroy(t.containerId),focus:()=>{const e=_s.getBlocks(t.containerId)[0];e&&_s.focusBlock(e)},selection:{clear:()=>window.getSelection()?.removeAllRanges(),get:()=>window.getSelection(),set:e=>{const t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e.getRangeAt(0)))}},ui:{hideBlockMenu:()=>Fr.hide(t.containerId),hideToolbar:()=>Ls.hide(t.containerId),showBlockMenu:e=>Fr.show(t.containerId,e),showToolbar:(e,n)=>Ls.show(t.containerId,e,n)},view:{getCurrentView:e=>C.getState().getCurrentView(e),switchView:(e,t)=>C.getState().setCurrentView(e,t)}}}static initialize(t){console.info("Editor::initialize: Creating editor instance for containerId:",t.containerId);const n=document.getElementById(t.containerId);if(!n)throw`Unable to find container with ID ${t.containerId}`;l.injectStyles(il,sl),l.injectStyles("clepit-editor-container-styles",Ds),l.injectStyles(Kr,Gr),l.injectStyles(ds,ps),l.injectStyles(Yr,Zr),l.injectStyles(Ae,Se);const a=t.defaultLocale??t.locale??ol(t.initialData?.blocks??[]),o=t.onChange,i={allowJsonViewEditing:!1,initialView:"edit",maxHeight:0,minHeight:300,placeholder:"Start writing...",...t,defaultLocale:a,locale:t.locale??a,onChange:o&&(n=>o(e.delocalizeData(t.containerId,n)))};n.className=l.classNames.editor.container,n.setAttribute("contenteditable","false"),Oe.applyParts(n,i.issueChip),l.registerEditor(t.containerId,i.theme??"auto",i.themeOverrides),i.minHeight&&n.style.setProperty("--clepit-min-height",`${i.minHeight}px`),i.maxHeight&&n.style.setProperty("--clepit-max-height",`${i.maxHeight}px`),l.applyStyles(n,i.styles?.container),l.applyClassNames(n,i.classNames?.container),i.margins&&(void 0!==i.margins.top&&n.style.setProperty("--block-margin-top",`${i.margins.top}px`),void 0!==i.margins.bottom&&n.style.setProperty("--block-margin-bottom",`${i.margins.bottom}px`));const r=`${i.containerId}-${l.idSuffixes.editorContent}`,s=p("div",l.classNames.editor.content);s.id=r,s.setAttribute("data-testid","editor-content-container"),s.setAttribute("data-container-id",t.containerId),l.applyStyles(s,i.styles?.editorContent),l.applyClassNames(s,i.classNames?.editorContent),n.appendChild(s),C.getState().addInstance(t.containerId,{config:i,contentId:r,currentView:i.initialView||"edit",data:e.localizeData(t.containerId,i.initialData,i),isReady:!1})}static localizeData(t,n,a){const o=n||{blocks:[],time:Date.now(),version:"1.0.0"};return a.locale?{...o,blocks:o.blocks.map(n=>e.localizeBlock(t,n,a))}:o}static localizeBlock(t,n,a){const o=a.locale;if(!o)return n;const i=a.defaultLocale??o;n.id&&(e.sources[t]={...e.sources[t],[n.id]:n});const r=n.data;let s=null;for(const e of(e=>Array.from(Ps).filter(t=>t.startsWith(`${e}.`)).map(t=>t.slice(e.length+1)).sort())(n.type)){const t=Js(r[e],o,i);t?.isFallback&&(s??=t.locale,a.onLocaleFallback?.({blockId:n.id??"",field:e,requested:o,showing:t.locale}))}n.id&&v.note(t,n.id,s);const l=Ws(n.type,r,o,i);return l===r?n:{...n,data:l}}static localizeArriving(t,n){const a=C.getState().getInstance(t)?.config;return a?e.localizeBlock(t,n,a):n}static delocalizeBlock(t,n){const a=C.getState().getInstance(t)?.config,o=a?.locale;if(!o||!n.id)return n;const i=e.sources[t]?.[n.id],r=i?.data,s=void 0===i||void 0===r?void 0:i.type===n.type?r:Object.fromEntries(Object.entries(r).filter(([e])=>Rs(n.type,e)));return{...n,data:nl(n.type,s,n.data,o,a.defaultLocale??o)}}static delocalizeData(t,n){return{...n,blocks:n.blocks.map(n=>e.delocalizeBlock(t,n))}}static render(e){const t=C.getState().getInstance(e);if(!t)return;const n=document.getElementById(t.contentId);n&&(Hs.destroy(e),n.innerHTML=""),"edit"===t.currentView?js.render(e):"preview"===t.currentView?cl.render(e):"json"===t.currentView&&Hs.render(e),t.config.onReady&&t.config.onReady()}static teardown(t){delete e.sources[t],v.forget(t),zs.stop(t),Ms.dismiss(t),Ts.removeListeners(t),qs.destroy(t),Fr.destroy(t),Ls.destroy(t),_s.destroy(t),l.unregisterEditor(t);const n=document.getElementById(t);n&&(n.innerHTML="")}static destroy(t){e.teardown(t),C.getState().removeInstance(t)}},pl=e=>e.replace(/["\\]/g,"\\$&"),ul=e=>e.flatMap(e=>"collapsible"===e.type?[e,...ul(e.data.children??[])]:"columns"===e.type?[e,...ul(e.data.columns?.flat()??[])]:[e]),hl=(e,t)=>{const n=[];for(const a of ul(t)){if(!a.id)continue;if("code"!==a.type&&"openapi"!==a.type&&"table"!==a.type)continue;const t=e.querySelector(`[data-clepit-block-id="${pl(a.id)}"]`);if(!t||t.hasAttribute("data-clepit-activated"))continue;t.setAttribute("data-clepit-activated","");const o="code"===a.type?Ce.activate(t,a.data):"openapi"===a.type?ha.activate(t):Ka.activate(t,a.data);n.push(()=>{o(),t.removeAttribute("data-clepit-activated")})}return()=>{for(const e of n)e()}},ml=/* @__PURE__ */new Set(["strong","b","em","i","u","s","del","mark","code","a","span"]),gl=/* @__PURE__ */new Set(["href","target","title","contenteditable","data-tooltip","data-status","data-status-variant","data-user-id","data-page-id","data-issue-tool","data-issue-key","data-issue-title","data-issue-state","data-issue-category","data-issue-assignee","data-issue-avatar","data-issue-updated","data-issue-url","data-issue-pull","data-issue-reason","class"]),bl=/* @__PURE__ */new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),fl=e=>" "===e||"\t"===e||"\n"===e||"\r"===e||"\f"===e,vl=e=>void 0!==e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"),yl=(e,t,n)=>{const a=e.indexOf(n,t);return-1===a?e.length:a+n.length},xl=(e,t,n)=>{let a=t,o="";for(;a<e.length&&!fl(e[a])&&"/"!==e[a]&&">"!==e[a];)o+=e[a],a+=1;const i=/* @__PURE__ */new Map;let r=!1;for(;a<e.length;){const t=e[a];if(">"===t){const e=o.toLowerCase();return{end:a+1,token:n?{tag:e,type:"close"}:{attributes:i,selfClosing:r,tag:e,type:"open"}}}if(fl(t)){a+=1;continue}if("/"===t){r=!0,a+=1;continue}r=!1;let s=t;for(a+=1;a<e.length&&!fl(e[a])&&"/"!==e[a]&&">"!==e[a]&&"="!==e[a];)s+=e[a],a+=1;let l=a;for(;fl(e[l]);)l+=1;let c="";if("="===e[l]){for(a=l+1;fl(e[a]);)a+=1;const t=e[a];if('"'===t||"'"===t){const n=e.indexOf(t,a+1);if(-1===n)return{end:e.length,token:null};c=e.slice(a+1,n),a=n+1}else for(;a<e.length&&!fl(e[a])&&">"!==e[a];)c+=e[a],a+=1}const d=s.toLowerCase();i.has(d)||i.set(d,c)}return{end:e.length,token:null}},kl=(e,t)=>{const n=e[t+1];if(e.startsWith("\x3c!--",t))return">"===e[t+4]?{end:t+5,token:null}:e.startsWith("->",t+4)?{end:t+6,token:null}:{end:yl(e,t+4,"--\x3e"),token:null};if("!"===n||"?"===n)return{end:yl(e,t+2,">"),token:null};if("/"===n){const n=e[t+2];return void 0===n?null:">"===n?{end:t+3,token:null}:vl(n)?xl(e,t+2,!0):{end:yl(e,t+2,">"),token:null}}return vl(n)?xl(e,t+1,!1):null},wl=e=>{if(!e)return"";const t=[],n=[];for(const a of(e=>{const t=[];let n=0;for(let a=e.indexOf("<");-1!==a;a=e.indexOf("<",a)){const o=kl(e,a);null!==o?(a>n&&t.push({type:"text",value:e.slice(n,a)}),null!==o.token&&t.push(o.token),a=o.end,n=a):a+=1}return n<e.length&&t.push({type:"text",value:e.slice(n)}),t})(e)){if("text"===a.type){t.push(a.value.replace(/</g,"&lt;").replace(/>/g,"&gt;"));continue}if("close"===a.type){if(!ml.has(a.tag))continue;const e=n.lastIndexOf(a.tag);if(-1===e)continue;t.push(`</${a.tag}>`),n.splice(e,1);continue}if(!ml.has(a.tag))continue;const e=[];for(const[t,n]of a.attributes)gl.has(t)&&("href"!==t||c(n))&&e.push(`${t}="${U(n)}"`);"a"===a.tag&&e.push('target="_blank"','rel="noopener noreferrer"'),t.push(`<${[a.tag,...e].join(" ")}>`),a.selfClosing||bl.has(a.tag)||n.push(a.tag)}for(const a of[...n].reverse())t.push(`</${a}>`);return t.join("")},Cl=()=>".clepit-public-page__notice{display:flex;flex-direction:column;gap:4px;margin:0 0 16px;padding:8px 12px;background:color-mix(in oklab, var(--clepit-info) 8%, transparent);border:1px solid color-mix(in oklab, var(--clepit-info) 35%, transparent);border-radius:8px}.clepit-public-page__notice-title{margin:0;font-size:12px;font-weight:600;color:var(--clepit-info)}.clepit-public-page__notice-body{margin:0;font-size:12px;line-height:1.55;color:var(--clepit-text-muted)}",Al=e=>`<aside class="clepit-public-page__notice" data-testid="public-page-notice" role="note"><p class="clepit-public-page__notice-title">${V(e.title)}</p><p class="clepit-public-page__notice-body">${V(e.body)}</p></aside>`,Sl=e=>[e.description?`<meta name="description" content="${U(e.description)}">`:"",e.canonicalUrl?`<link rel="canonical" href="${U(e.canonicalUrl)}">`:"",...(e.alternates??[]).map(e=>`<link rel="alternate" hreflang="${U(e.hreflang)}" href="${U(e.href)}">`),`<meta property="og:title" content="${U(e.title)}">`,e.description?`<meta property="og:description" content="${U(e.description)}">`:""].join(""),El=()=>[sl,At,It,zt,te,de(),Vt,Jt,Qt,an,ln,hn,O,fn,xn,Cn,Ln,Se,qn,jn,ma,va,Ca,Ba,Xa,to,ki,Ai].join("\n"),Ll=(e,t)=>{const n=t?.defaultLocale??t?.locale??ol(e),a=t?.locale??n,o=void 0===a?e:e.map(e=>{const t=Ws(e.type,e.data,a,n??a);return t===e.data?e:{...e,data:t}}),i=K(wl),r={...t,documentBlocks:t?.documentBlocks??o},s=o.map(e=>Li(e,i,r)).filter(e=>null!==e).map(e=>G(e)).join("\n");return Ue(s,t?.issues,t?.issueChip,t?.issueLabels,wl)},Nl=(e,t)=>{const n=V(e.title),a=['<meta charset="utf-8">','<meta name="viewport" content="width=device-width, initial-scale=1">',e.scheme?`<meta name="color-scheme" content="${U(e.scheme)}">`:"",`<title>${n}</title>`,Sl(e),`<style>${El()}</style>`,e.notice?"<style>.clepit-public-page__notice{display:flex;flex-direction:column;gap:4px;margin:0 0 16px;padding:8px 12px;background:color-mix(in oklab, var(--clepit-info) 8%, transparent);border:1px solid color-mix(in oklab, var(--clepit-info) 35%, transparent);border-radius:8px}.clepit-public-page__notice-title{margin:0;font-size:12px;font-weight:600;color:var(--clepit-info)}.clepit-public-page__notice-body{margin:0;font-size:12px;line-height:1.55;color:var(--clepit-text-muted)}</style>":""].filter(Boolean);return["<!doctype html>",`<html lang="${U(e.locale??"en")}">`,`<head>${a.join("")}</head>`,e.scheme?`<body data-clepit-theme="${U(e.scheme)}">`:"<body>",'<main class="clepit-public-page">',`<h1 class="clepit-public-page__title">${n}</h1>`,...e.notice?[Al(e.notice)]:[],Ll(e.blocks,{...t,anchorTargets:!0}),"</main>","</body>","</html>"].join("\n")},Bl={am:[[4608,4991]],ar:[[1536,1791]],bn:[[2432,2559]],hi:[[2304,2431]],ja:[[12352,12543]],ko:[[4352,4607],[44032,55215]],ru:[[1024,1279]],zh:[[19968,40959]]},$l={de:["auch","auf","das","dem","den","der","die","ein","eine","für","ich","ist","mit","nicht","sich","sie","und","von","wir","zu"],en:["and","are","as","be","for","have","in","is","it","not","of","on","that","the","this","to","was","with","you"],es:["con","como","del","el","en","es","la","las","lo","los","no","para","por","que","se","su","un","una","y"],et:["aga","ei","et","ja","ka","kes","kui","mis","ning","nii","oli","oma","on","see","seda","siis","tema","ole","välja"],fil:["ako","ang","at","ay","hindi","ito","ka","kung","lang","may","mga","na","ng","ni","nila","para","sa","si","siya"],fr:["au","avec","ce","dans","des","du","est","et","le","les","pas","pour","qui","sur","une","nous","vous","sont","elle"],id:["ada","akan","atau","bisa","dalam","dan","dari","dengan","di","ini","itu","juga","kami","ke","pada","saya","tidak","untuk","yang"],pt:["com","da","do","em","isso","mais","não","no","os","para","pela","por","que","se","um","uma","é","está","são"],sw:["cha","hii","hiyo","ili","kama","katika","kuwa","kwa","lakini","mimi","na","ni","sana","wa","wako","ya","yake","za","la"],vi:["các","cho","có","cũng","của","khi","không","là","một","người","như","những","này","trong","và","với","được","đã","để"]},Ml=/\p{L}/u,Il=(e,t)=>t.some(([t,n])=>e>=t&&e<=n),Tl=e=>{const t=(e=>e.replace(/`[^`]*`/g," ").replace(/https?:\/\/\S+/g," ").replace(/@\S+/g," "))(e);return(e=>{const t={};let n=0;for(const s of e){if(!Ml.test(s))continue;n+=1;const e=s.codePointAt(0)??0,a=Object.keys(Bl).find(t=>Il(e,Bl[t]??[]));void 0!==a&&(t[a]=(t[a]??0)+1)}const a=t.ja??0,o=t.zh??0;a>0&&(t.ja=a+o,delete t.zh);const[i,r]=Object.entries(t).sort((e,t)=>t[1]-e[1])[0]??[null,0];return null!==i&&r>=8&&2*r>=n?i:null})(t)??(e=>{const t=e.toLowerCase().match(/[\p{L}']+/gu)??[];if(t.length<8)return null;const n=e=>100*e/t.length,[a,o]=[...Object.entries($l).map(([e,a])=>{const o=new Set(a),i=t.filter(e=>o.has(e)).length,r="vi"===e?t.filter(e=>[...e].some(e=>"ăâđêôơưạảãấầẩẫậắằẳẵặẹẻẽếềểễệỉĩịỏọốồổỗộớờởỡợủũụứừửữựỳỷỹỵ".includes(e))).length:0;return[e,n(i+r)]})].sort((e,t)=>t[1]-e[1]);return void 0===a||0===a[1]?null:a[1]-(o?.[1]??0)>5?a[0]:null})(t)};export{Lr as BLOCK_TOOLS,Mr as CONTROL_LABELS,Os as ClepitError,Ir as DIALOG_LABELS,Ge as EMBED_ENGLISH,$r as EMBED_LABELS,Je as EMBED_TOOL_NAMES,$ as EMBED_WIRE_KEYS,dl as Editor,_r as INLINE_REWRITE_ACTIONS,Tr as INLINE_TOOLBAR_LABELS,Er as INLINE_TOOLS,Ee as ISSUE_ENGLISH,Br as ISSUE_LABELS,Nr as ISSUE_TOOLS,Le as ISSUE_TOOL_NAMES,Oe as IssueChip,ll as Renderer,l as StyleManager,Nn as UploadRefusal,hl as activateBlocks,Ve as chipsInHtml,ct as classifyIssueUrl,Tl as detectLanguage,R as domBacking,Li as drawBlock,Xe as embedLabel,M as isEmbedProviderDisabled,Be as issueLabel,$e as issueToolName,Cl as noticeStylesheet,Sl as pageMetadata,El as pageStylesheet,ia as parseOpenApi,Fe as readChipMarkup,Ue as refreshChipsInHtml,Ll as renderBlocks,Al as renderNotice,Nl as renderPage,G as renderToString,q as resolveEmbed,wl as sanitizeHtmlWithoutDom,K as stringBacking,J as toDomElement,s as tokensToLightDarkBlock};
1
+ import{a as e,i as t,n,r as a,t as o}from"./highlight-D9LdKWiT.mjs";var i={bg:"#ffffff",blockHighlightBg:"rgba(0, 0, 0, 0.05)",border:"rgba(17, 24, 39, 0.12)",borderSubtle:"rgba(17, 24, 39, 0.06)",codeBg:"#f2f4f7",codeBorder:"rgba(17, 24, 39, 0.10)",codeComment:"#868f9c",codeFunction:"#6f42c1",codeGutter:"#868f9c",codeKeyword:"#cf222e",codeNumber:"#0550ae",codePunctuation:"#525866",codeSelectionBg:"rgba(89, 88, 252, 0.14)",codeString:"#0a3069",codeText:"#0a0a0a",codeType:"#953800",dangerBg:"rgba(220, 38, 38, 0.12)",error:"#dc2626",errorBg:"rgba(220, 38, 38, 0.08)",focusRing:"#5958fc",hoverBg:"rgba(89, 88, 252, 0.08)",info:"#2563eb",infoBg:"rgba(37, 99, 235, 0.08)",inverseSurface:"#1b1f27",inverseText:"#ffffff",marker:"#ffe047",menuBg:"#ffffff",onPrimary:"#ffffff",pressedBg:"rgba(89, 88, 252, 0.12)",primary:"#5958fc",primaryBg:"rgba(89, 88, 252, 0.08)",primaryHover:"#4746ce",selectionBg:"rgba(89, 88, 252, 0.14)",success:"#16a34a",successBg:"rgba(22, 163, 74, 0.08)",surface:"#f8f9fa",surface2:"#f1f3f5",text:"#0a0a0a",textMuted:"#525866",textSubtle:"#868f9c",warning:"#d97706",warningBg:"rgba(217, 119, 6, 0.08)"},r={bg:"--clepit-bg",blockHighlightBg:"--clepit-block-highlight-bg",border:"--clepit-border",borderSubtle:"--clepit-border-subtle",codeBg:"--clepit-code-bg",codeBorder:"--clepit-code-border",codeComment:"--clepit-code-comment",codeFunction:"--clepit-code-function",codeGutter:"--clepit-code-gutter",codeKeyword:"--clepit-code-keyword",codeNumber:"--clepit-code-number",codePunctuation:"--clepit-code-punctuation",codeSelectionBg:"--clepit-code-selection-bg",codeString:"--clepit-code-string",codeText:"--clepit-code-text",codeType:"--clepit-code-type",dangerBg:"--clepit-danger-bg",error:"--clepit-error",errorBg:"--clepit-error-bg",focusRing:"--clepit-focus-ring",hoverBg:"--clepit-hover-bg",info:"--clepit-info",infoBg:"--clepit-info-bg",inverseSurface:"--clepit-inverse-surface",inverseText:"--clepit-inverse-text",marker:"--clepit-marker",menuBg:"--clepit-menu-bg",onPrimary:"--clepit-on-primary",pressedBg:"--clepit-pressed-bg",primary:"--clepit-primary",primaryBg:"--clepit-primary-bg",primaryHover:"--clepit-primary-hover",selectionBg:"--clepit-selection-bg",success:"--clepit-success",successBg:"--clepit-success-bg",surface:"--clepit-surface",surface2:"--clepit-surface-2",text:"--clepit-text",textMuted:"--clepit-text-muted",textSubtle:"--clepit-text-subtle",warning:"--clepit-warning",warningBg:"--clepit-warning-bg"},s=(e,t,n)=>{const a=[];for(const o of Object.keys(r)){const n=e[o],i=t[o];if(void 0===n&&void 0===i)continue;const s=r[o];void 0!==n&&void 0!==i?a.push(` ${s}: light-dark(${n}, ${i});`):a.push(` ${s}: ${n??i};`)}return 0===a.length?"":`${n} {\n${a.join("\n")}\n}`},l=class e{static{this.idSuffixes={actionBar:{clearButton:"action-bar-clear-button",copyButton:"action-bar-copy-button",downloadButton:"action-bar-download-button",editButton:"edit-button",jsonButton:"json-button",previewButton:"preview-button"},editorContent:"content"}}static{this.classNames={actionBar:{action:"clepit-view-actions",actionButton:"clepit-view-action-button",button:"clepit-action-bar-button",container:"clepit-action-bar",copyFeedback:"clepit-view-action-button--copy-feedback",group:"clepit-action-bar-group"},block:{active:"clepit-block--active",alert:"clepit-alert",audio:{captionEditable:"clepit-audio-caption-editable",container:"clepit-audio-container",dropArea:"clepit-audio-drop-area",wrapper:"clepit-audio-wrapper"},audioDeleteBtn:"clepit-audio-delete-btn",checklist:{checkbox:"clepit-checklist-checkbox",container:"clepit-checklist",item:"clepit-checklist-item",text:"clepit-checklist-text"},code:{container:"clepit-code-container",editor:"clepit-code-editor",header:"clepit-code-header",headerWrapper:"clepit-code-header-wrapper"},container:"clepit-block",content:"clepit-block-content",header:"clepit-header",image:{captionEditable:"clepit-image-caption-editable",container:"clepit-image-container",dropArea:"clepit-image-drop-area",wrapper:"clepit-image-wrapper"},imageDeleteBtn:"clepit-image-delete-btn",indent1:"clepit-block-indent-1",indent2:"clepit-block-indent-2",indent3:"clepit-block-indent-3",link:"clepit-link",list:{container:"clepit-list",item:"clepit-list-item"},output:"clepit-output-block",paragraph:"clepit-paragraph",quote:{author:"clepit-quote-author",container:"clepit-quote-container",divider:"clepit-quote-divider",text:"clepit-quote-text"},table:{caption:"clepit-table-caption",cell:"clepit-table-cell",downloadSwitch:"clepit-table-download-switch",headerCell:"clepit-table-header-cell",headerRow:"clepit-table-header-row",row:"clepit-table-row"},tooltip:"clepit-tooltip",video:{captionEditable:"clepit-video-caption-editable",container:"clepit-video-container",dropArea:"clepit-video-drop-area",iframe:"clepit-video-iframe",video:"clepit-video",wrapper:"clepit-video-wrapper"},videoDeleteBtn:"clepit-video-delete-btn"},editor:{container:"clepit-editor",content:"clepit-editor-content",jsonEditable:"clepit-json-editable",jsonEmpty:"clepit-json-empty",jsonError:"clepit-json-error",jsonOutput:"clepit-json-output"},renderer:{content:"clepit-renderer-content"},switch:{container:"clepit-custom-switch"}}}static applyStyles(e,t){t&&"object"==typeof t&&Object.entries(t).forEach(([t,n])=>{if(void 0!==n)if(t.startsWith("--"))e.style.setProperty(t,String(n));else{const a=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(a,String(n))}})}static applyClassNames(e,t){t&&("string"==typeof t?e.classList.add(t):Object.entries(t).forEach(([t,n])=>{n&&"string"==typeof n&&e.classList.add(n)}))}static applyStyling(t,n){const{styles:a,classNames:o}=n;if(a&&"object"==typeof a){const n=[],o={};Object.entries(a).forEach(([e,t])=>{void 0===t?n.push(e):o[e]=t}),Object.keys(o).length>0&&e.applyStyles(t,o),n.forEach(e=>t.style.removeProperty(e))}o&&e.applyClassNames(t,o)}static createStyledElement(t,n,a){const o=document.createElement(t);return o.className=n,a&&e.applyStyling(o,a),o}static injectStyles(t,n){if(e.injectedSheet(t))return!1;const a=new(document.defaultView?.CSSStyleSheet??CSSStyleSheet);return a.replaceSync(n),document.adoptedStyleSheets=[...document.adoptedStyleSheets,a],e.injectedSheets.set(t,a),!0}static injectedSheet(t){const n=e.injectedSheets.get(t);return n&&document.adoptedStyleSheets.includes(n)?n:void 0}static removeStyles(t){const n=e.injectedSheets.get(t);n&&(e.injectedSheets.delete(t),document.adoptedStyleSheets=document.adoptedStyleSheets.filter(e=>e!==n))}static{this.injectedSheets=/* @__PURE__ */new Map}static{this.themeRegistry=/* @__PURE__ */new Map}static{this.themeSubscribers=/* @__PURE__ */new Set}static registerEditor(t,n,a){const o=document.getElementById(t);if(o&&(o.setAttribute("data-clepit-theme",n),o.setAttribute("data-clepit-instance",t)),e.themeRegistry.set(t,n),e.syncBodyThemeAttribute(),e.removeStyles(`clepit-overrides-${t}`),a){const n=s(a.light??{},a.dark??{},`[data-clepit-instance='${t}']`);n&&e.injectStyles(`clepit-overrides-${t}`,n)}e.ensureThemeListener()}static unregisterEditor(t){e.removeStyles(`clepit-overrides-${t}`);const n=document.getElementById(t);n&&(n.removeAttribute("data-clepit-theme"),n.removeAttribute("data-clepit-instance")),e.themeRegistry.delete(t),e.syncBodyThemeAttribute(),e.maybeDetachThemeListener()}static syncBodyThemeAttribute(){if("undefined"==typeof document||!document.body)return;const t=e.themeRegistry.values().next().value;t?document.body.setAttribute("data-clepit-theme",t):document.body.removeAttribute("data-clepit-theme")}static getResolvedTheme(){return"undefined"==typeof window||"function"!=typeof window.matchMedia?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}static subscribe(t){return e.themeSubscribers.add(t),e.ensureThemeListener(),()=>{e.themeSubscribers.delete(t),e.maybeDetachThemeListener()}}static unregisterAllEditorsForTest(){for(const t of Array.from(e.themeRegistry.keys()))e.unregisterEditor(t);e.themeSubscribers.clear(),e.maybeDetachThemeListener()}static ensureThemeListener(){"undefined"!=typeof window&&"function"==typeof window.matchMedia&&0!==e.themeSubscribers.size&&(e.themeMediaQuery||(e.themeMediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaQueryListener=t=>{const n=t.matches?"dark":"light";for(const a of e.themeSubscribers)a(n)},e.themeMediaQuery.addEventListener("change",e.themeMediaQueryListener)))}static maybeDetachThemeListener(){e.themeSubscribers.size>0||e.themeMediaQuery&&e.themeMediaQueryListener&&(e.themeMediaQuery.removeEventListener("change",e.themeMediaQueryListener),e.themeMediaQuery=void 0,e.themeMediaQueryListener=void 0)}},c=e=>{const t=e.trim().toLowerCase().replace(/[\x00-\x20]/g,"");return!t.startsWith("javascript:")&&!t.startsWith("data:")&&!t.startsWith("vbscript:")},d=e=>/^https?:\/\//i.test(e.trim());function p(e,t,n){const a=document.createElement(e);if(t&&(a.className=t),n)for(const[o,i]of Object.entries(n))a.setAttribute(o,i);return a}function u(e,t){return`${e}-${t}`}function h(e){return!e||!e.trim()||"<br>"===e}function m(e){if(!e||h(e))return"";const t=document.implementation.createHTMLDocument("");t.body.innerHTML=e;const n=["strong","b","em","i","u","s","del","mark","code","a","span"],a=["href","target","title","contenteditable","data-tooltip","data-status","data-status-variant","data-user-id","data-page-id","data-issue-tool","data-issue-key","data-issue-title","data-issue-state","data-issue-category","data-issue-assignee","data-issue-avatar","data-issue-updated","data-issue-url","data-issue-pull","data-issue-reason","class"];function o(e){if(e.nodeType===Node.TEXT_NODE)return document.createTextNode(e.textContent||"");if(e.nodeType===Node.ELEMENT_NODE){const t=e,i=t.tagName.toLowerCase();if(!n.includes(i))return document.createTextNode(t.textContent||"");const r=document.createElement(i);for(const e of t.attributes){const t=e.name.toLowerCase();a.includes(t)&&("href"!==t||c(e.value))&&r.setAttribute(e.name,e.value)}"a"===i&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer"));for(const e of Array.from(t.childNodes)){const t=o(e);t&&r.appendChild(t)}return r}return null}const i=document.createElement("div");for(const r of Array.from(t.body.childNodes)){const e=o(r);e&&i.appendChild(e)}return i.innerHTML}function g(e,t){const n=window.getSelection();if(!n||0===n.rangeCount)return!1;const a=n.getRangeAt(0);if(!a)return!1;if(!e.contains(a.commonAncestorContainer))return!1;if(0===(e.textContent||"").length)return!0;if("left"===t){const t=e.firstChild;return t&&t.nodeType===Node.TEXT_NODE?a.startContainer===t&&0===a.startOffset:a.startContainer===e&&0===a.startOffset}{const t=e.lastChild;return t&&t.nodeType===Node.TEXT_NODE?a.endContainer===t&&a.endOffset===t.textContent?.length:a.endContainer===e&&a.endOffset===e.childNodes.length}}var b="data-showing-locale",f="clepit-block-showing-locale",v=class e{static{this.shown={}}static note(t,n,a){const o={...e.shown[t]};null===a?delete o[n]:o[n]=a,e.shown[t]=o}static apply(t,n){const a=n.getAttribute("data-id"),o=a?e.shown[t]?.[a]:void 0,i=n.querySelector(`.${l.classNames.block.content}`);if(n.querySelector(`.${f}`)?.remove(),void 0===o)return n.removeAttribute(b),void i?.removeAttribute("lang");n.setAttribute(b,o),i?.setAttribute("lang",o);const r=p("span",f);r.setAttribute("data-testid",f),r.textContent=o.toUpperCase(),i?n.insertBefore(r,i):n.appendChild(r)}static clear(t,n){if(!n.hasAttribute(b))return;const a=n.getAttribute("data-id");a&&e.note(t,a,null),e.apply(t,n)}static forget(t){delete e.shown[t]}},y=e=>{let t;const n=/* @__PURE__ */new Set,a=(e,a)=>{const o="function"==typeof e?e(t):e;if(Object.is(o,t))return;const i=t;t=a?o:Object.assign({},t,o);for(const r of n)r(t,i)},o=()=>t,i={getInitialState:()=>r,getState:o,setState:a,subscribe:e=>(n.add(e),()=>{n.delete(e)})},r=t=e(a,o,i);return i};var x,k,w,C=(w?y(w):y)((e=>(t,n,a)=>{const o=a.subscribe;return a.subscribe=(e,t,n)=>{if(!t)return o(e);const i=n?.equalityFn??Object.is;let r=e(a.getState());return n?.fireImmediately&&t(r,r),o(n=>{const a=e(n);if(!i(r,a)){const e=r;t(r=a,e)}})},e(t,n,a)})((e=>(t,n,a)=>e(t,n,a))((x=(e,t)=>({addBlock:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=[...i.data.blocks];void 0===o||o<0||o>r.length?r.push(a):r.splice(o,0,a);const s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},addInstance:(n,a)=>{const o=t().instances;o[n]?o[n].config=a.config:o[n]=a,e({instances:o})},clearData:n=>{const a=t().instances[n];if(!a)return;const o={...a,data:{...a.data,blocks:[]}};e(e=>({instances:{...e.instances,[n]:o}})),a.config.onChange&&a.config.onChange(o.data)},getContentElement:e=>{const n=t().instances[e];return n?document.querySelector(`#${n.contentId}`):null},getCurrentView:e=>t().instances[e]?.currentView||null,getData:e=>t().instances[e]?.data||null,getInstance:e=>t().instances[e]||null,getIsReady:e=>{const n=t().instances[e];return!!n&&n.isReady},instances:{},partialUpdateBlockData:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,data:{...e.data,...o}}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},removeBlock:(n,a)=>{const o=t().instances[n];if(!o)return;const i=o.data.blocks.filter((e,t)=>t!==a),r={...o,data:{...o.data,blocks:i}};e(e=>({instances:{...e.instances,[n]:r}})),o.config.onChange&&o.config.onChange(r.data)},removeInstance:t=>{e(e=>{const n={...e.instances};return delete n[t],{instances:n}})},seedBlocks:(n,a)=>{const o=t().instances[n];o&&e(e=>({instances:{...e.instances,[n]:{...o,data:{...o.data,blocks:a}}}}))},setCurrentView:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,currentView:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},setData:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,data:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(a)},setIsReady:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,isReady:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},updateBlock:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,...o}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},updateBlockData:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,data:o}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},updateData:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,data:{...o.data,...a}};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},updateInstance:(n,a)=>{const o=t().instances;o[n]&&(o[n].data=a.data,e({instances:o}))}}),k={name:"clepit-store",version:0},(e,t,n)=>{const a=k.version??0,o=k.storage??("undefined"==typeof localStorage?void 0:localStorage),i=k.merge??((e,t)=>Object.assign({},t,e)),r=x(e,t,n);if(o){try{const e=o.getItem(k.name);if(e){const t=JSON.parse(e),n=t.version===a?t.state:k.migrate?k.migrate(t.state,t.version??0):void 0;void 0!==n&&Object.assign(r,i(n,r))}}catch(s){console.warn(`store persist: "${k.name}" could not be read, starting from the initial state`,s)}n.subscribe(e=>{try{o.setItem(k.name,JSON.stringify({state:k.partialize?k.partialize(e):e,version:a}))}catch(s){console.warn(`store persist: "${k.name}" could not be written, this change stays in memory`,s)}})}return r})))),A=["http:","https:"],S=["youtube.com","www.youtube.com","m.youtube.com","youtu.be"],E=["file","design","board","proto","slides","deck"],L=["document","spreadsheets","presentation"],N=/^[0-9a-f]{32}$/,B=/^[A-Za-z0-9]+$/,M={figma:"figma",githubGist:"github_gist",googleDrive:"google_drive",loom:"loom",miro:"miro"};function $(e,t){const n=M[e];return void 0!==n&&(t??[]).includes(n)}var I=(e,t="link")=>({embedUrl:null,provider:t,url:e});function T(e,t){return e===t||e.endsWith(`.${t}`)}function _(e,t){const n=e.hostname.toLowerCase(),a=e.toString();if(S.includes(n)){const t=function(e){if(T(e.hostname,"youtu.be"))return e.pathname.slice(1).split("/")[0]||null;if("/watch"===e.pathname)return e.searchParams.get("v");const t=e.pathname.match(/^\/(?:embed|shorts|live)\/([^/]+)/);return t?t[1]:null}(e);return t?{aspect:16/9,embedUrl:`https://www.youtube.com/embed/${encodeURIComponent(t)}`,provider:"youtube",url:a}:I(a,"youtube")}if(T(n,"figma.com")){const[,t,n]=e.pathname.split("/");return t&&n&&E.includes(t)?{aspect:4/3,embedUrl:`https://embed.figma.com/${"file"===t?"design":t}/${encodeURIComponent(n)}?embed-host=clepit`,provider:"figma",url:a}:I(a,"figma")}if(T(n,"miro.com")){const t=e.pathname.match(/^\/app\/board\/([^/]+)/);return t?{aspect:16/9,embedUrl:`https://miro.com/app/live-embed/${encodeURIComponent(t[1])}`,provider:"miro",url:a}:I(a,"miro")}if(T(n,"loom.com")){const[,t,n]=e.pathname.split("/");return("share"===t||"embed"===t)&&n&&B.test(n)?{aspect:16/9,embedUrl:`https://www.loom.com/embed/${encodeURIComponent(n)}?hide_share=true`,provider:"loom",url:a}:I(a,"loom")}if("drive.google.com"===n){const t=e.pathname.match(/^\/file\/d\/([^/]+)/),n="/open"===e.pathname?e.searchParams.get("id"):null,o=t?.[1]??n;return o?{aspect:4/3,embedUrl:`https://drive.google.com/file/d/${encodeURIComponent(o)}/preview`,provider:"googleDrive",url:a}:I(a,"googleDrive")}if("docs.google.com"===n){const[,t,n,o]=e.pathname.split("/");return t&&L.includes(t)&&"d"===n&&o?{aspect:4/3,embedUrl:`https://docs.google.com/${t}/d/${encodeURIComponent(o)}/preview`,provider:"googleDrive",url:a}:I(a,"googleDrive")}if("gist.github.com"===n){const[,t,n]=e.pathname.split("/");return t&&n&&N.test(n)?{embedUrl:null,gist:{id:n,owner:t},provider:"githubGist",url:a}:I(a,"githubGist")}if(T(n,"airtable.com")){const t=e.pathname.match(/^\/embed\/([^/]+)/),n=e.pathname.match(/^\/(shr[^/]+)/),o=t?.[1]??n?.[1];return o?{aspect:4/3,embedUrl:`https://airtable.com/embed/${encodeURIComponent(o)}`,provider:"airtable",url:a}:I(a,"airtable")}if(T(n,"diagrams.net")||T(n,"drawio.com"))return{aspect:4/3,embedUrl:`https://viewer.diagrams.net/?edit=_blank&layers=1&nav=1#U${encodeURIComponent(a)}`,provider:"drawio",url:a};if(T(n,"google.com")&&e.pathname.startsWith("/maps")){const n=t?.mapsEmbedKey,o=e.searchParams.get("q");return n&&o?{aspect:4/3,embedUrl:`https://www.google.com/maps/embed/v1/place?key=${encodeURIComponent(n)}&q=${encodeURIComponent(o)}`,provider:"googleMaps",url:a}:I(a,"googleMaps")}return I(a)}function q(e,t){const n=function(e){try{const t=new URL(e);return A.includes(t.protocol)?t:null}catch{return null}}(e);if(!n)return{embedUrl:null,provider:"invalid",url:e};const a=_(n,t);return $(a.provider,t?.disabledProviders)?{embedUrl:null,provider:a.provider,switchedOff:!0,url:a.url}:a}async function D(e,t,n,a){const o=C.getState().getInstance(e)?.config,i=function(e,t){return{data:"card"===t?{display:"card",url:e}:{url:e},type:"embed"}}(a,"card"===(o?.pasteEmbeds??"live")?"card":"live");n?Ds.replaceBlock(e,t,i):Ds.insertBlock(i,e,t+1);const r=Ds.getBlocks(e)[n?t:t+1]?.getAttribute("data-id")??null;return r&&o?.resolveLink&&await z(e,r,o.resolveLink),r}async function z(e,t,n){if(!n)return;const a=Ds.getBlockData(t).data;try{const o=await n(a.url),{reason:i,...r}=a;Ds.updateBlockData(t,{...r,...o,url:a.url},e)}catch{Ds.updateBlockData(t,{...a,reason:"provider_unreachable"},e)}}var j="\n.clepit-embed {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n overflow: hidden;\n}\n.clepit-embed__frame {\n display: block;\n width: 100%;\n border: 0;\n}\n.clepit-embed-card {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n color: inherit;\n text-decoration: none;\n}\n.clepit-embed-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-embed-card__title {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-embed-card__description {\n opacity: 0.7;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n.clepit-embed-card--with-reason {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n}\n.clepit-embed-card--with-reason > .clepit-embed-card {\n padding: 0;\n border: 0;\n}\n.clepit-embed-card__reason {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 14px;\n align-items: center;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-embed-card__action {\n padding: 0;\n font: inherit;\n color: inherit;\n text-decoration: underline;\n background: none;\n border: 0;\n cursor: pointer;\n}\n.clepit-embed--gist-frame .clepit-embed__frame {\n height: 552px;\n}\n.clepit-embed-gist {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n.clepit-embed-gist__file {\n display: flex;\n gap: 10px;\n align-items: baseline;\n font-size: 0.9em;\n}\n.clepit-embed-gist__file b {\n font-weight: 600;\n}\n.clepit-embed-gist__file a {\n margin-left: auto;\n color: inherit;\n opacity: 0.7;\n}\n.clepit-embed-offer {\n position: absolute;\n z-index: 20;\n display: inline-flex;\n gap: 6px;\n align-items: center;\n padding: 4px 4px 4px 10px;\n font-size: 12px;\n background: var(--clepit-surface, #fff);\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 999px;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);\n}\n.clepit-embed-offer button {\n padding: 3px 9px;\n font: inherit;\n font-weight: 600;\n color: #fff;\n background: var(--clepit-primary, #5958fc);\n border: 0;\n border-radius: 999px;\n cursor: pointer;\n}\n",H=j,O=j,P=class{constructor(e){this.node=e}get tag(){return this.node.tagName.toLowerCase()}setAttribute(e,t){this.node.setAttribute(e,t)}addClass(...e){this.node.classList.add(...e.filter(Boolean))}setText(e){this.node.textContent=e}setHtml(e){this.node.innerHTML=m(e)}append(e){this.node.appendChild(e.node)}appendText(e){this.node.appendChild(document.createTextNode(e))}},R={create:e=>new P(document.createElement(e)),createNS:(e,t)=>new P(document.createElementNS(e,t))},F=/* @__PURE__ */new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),V=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),U=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;"),W=class{constructor(e,t){this.tag=e,this.sanitize=t,this.attributes=/* @__PURE__ */new Map,this.classes=[],this.children=[]}setAttribute(e,t){this.attributes.set(e,t)}addClass(...e){for(const t of e.filter(Boolean))this.classes.includes(t)||this.classes.push(t)}setText(e){this.children.length=0,this.children.push(V(e))}setHtml(e){this.children.length=0,this.children.push(this.sanitize(e))}append(e){this.children.push(e.toString())}appendText(e){this.children.push(V(e))}toString(){const e=[...this.classes.length>0?[`class="${U(this.classes.join(" "))}"`]:[],...[...this.attributes].map(([e,t])=>`${e}="${U(t)}"`)],t=[this.tag,...e].join(" ");return F.has(this.tag)?`<${t}>`:`<${t}>${this.children.join("")}</${this.tag}>`}},K=e=>({create:t=>new W(t,e),createNS:(t,n)=>new W(n,e)}),G=e=>String(e),J=e=>{if(!(e instanceof P))throw new TypeError("toDomElement needs an element built by the dom backing");return e.node};function X(){l.injectStyles("clepit-invalid-data-styles","\n/* Invalid data component styles */\n.clepit-invalid-data {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 1rem 0;\n background: #ffebee;\n color: #c62828;\n}\n\n.clepit-invalid-data-text {\n font-weight: bold;\n margin: 0;\n padding: 0;\n}\n");const e=p("div","clepit-invalid-data"),t=p("div","clepit-invalid-data-text");return t.textContent="Invalid data",e.appendChild(t),e}var Y={assembly:"Assembly",bash:"Bash",clojure:"Clojure",cobol:"COBOL",cpp:"C++",csharp:"C#",css:"CSS",dart:"Dart",diff:"Diff",dockerfile:"Dockerfile",erlang:"Erlang",fortran:"Fortran",go:"Go",graphql:"GraphQL",groovy:"Groovy",haskell:"Haskell",html:"HTML",java:"Java",javascript:"JavaScript",json:"JSON",jsx:"JSX",julia:"Julia",kotlin:"Kotlin",lua:"Lua",markdown:"Markdown",nginx:"Nginx",objectivec:"Objective-C",pascal:"Pascal",perl:"Perl",php:"PHP",plaintext:"Plain Text",powershell:"PowerShell",protobuf:"Protocol Buffers",python:"Python",r:"R",ruby:"Ruby",rust:"Rust",scala:"Scala",scheme:"Scheme",shell:"Shell",sql:"SQL",swift:"Swift",toml:"TOML",tsx:"TSX",typescript:"TypeScript",vb:"Visual Basic",verilog:"Verilog",vhdl:"VHDL",xml:"XML",yaml:"YAML"};function Z(e){return Y[e]||"Unknown"}var Q=Object.fromEntries(Object.keys(n).map(e=>[e,{name:Z(e)}])),ee=`\n/* Code block styles */\n.clepit-code {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-code-pre {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool="code"] .clepit-block-content {\n background: transparent;\n border: none;\n padding: 0;\n margin-right: 8px;\n}\n\n/* Code placeholder styles */\n.clepit-code[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Code container */\n.${l.classNames.block.code.container} {\n border: 1px solid var(--clepit-code-border);\n background: var(--clepit-code-bg);\n border-radius: var(--clepit-radius-md);\n overflow: visible; /* allow header tooltips to escape */\n margin: 8px 0;\n}\n\n.${l.classNames.block.code.editor} {\n height: 200px;\n max-height: 60vh;\n min-height: 200px;\n overflow: hidden;\n position: relative;\n}\n\n/* The editing surface: a textarea laid over a highlighted pre. The two must\n * agree on every metric that affects where a glyph lands, or the caret drifts\n * away from the colour behind it. They inherit from one rule for that reason. */\n.${l.classNames.block.code.editor} .clepit-code-highlight,\n.${l.classNames.block.code.editor} .clepit-code-input {\n margin: 0;\n border: 0;\n padding: 12px 34px;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n letter-spacing: normal;\n tab-size: 2;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n overflow: auto;\n scrollbar-gutter: stable;\n box-sizing: border-box;\n}\n\n.${l.classNames.block.code.editor} .clepit-code-highlight {\n position: absolute;\n inset: 0;\n pointer-events: none;\n color: var(--clepit-code-text);\n}\n\n/* The text itself is transparent: the colour the reader sees belongs to the pre\n * behind it. The caret keeps a colour of its own so it stays visible. */\n.${l.classNames.block.code.editor} .clepit-code-input {\n position: relative;\n width: 100%;\n height: 100%;\n display: block;\n background: transparent;\n color: transparent;\n caret-color: var(--clepit-code-text);\n resize: none;\n outline: none;\n}\n\n.${l.classNames.block.code.editor} .clepit-code-input::placeholder {\n color: var(--clepit-text-muted);\n}\n\n.${l.classNames.block.code.editor} .clepit-code-input::selection {\n background: var(--clepit-code-selection-bg);\n color: transparent;\n}\n\n/* Code header */\n.${l.classNames.block.code.headerWrapper} {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n width: 100%;\n padding: 8px 34px;\n position: relative; /* allow inner tooltip absolute positioning */\n overflow: visible; /* ensure tooltip not clipped */\n z-index: 2;\n border-bottom: 1px solid var(--clepit-border-color);\n}\n\n.${l.classNames.block.code.header} {\n font-size: 12px;\n font-weight: 500;\n}\n\n/* Code Language Submenu */\n.clepit-code-language-submenu {\n position: absolute;\n top: 0;\n left: 100%;\n z-index: 1002;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 160px;\n max-width: 200px;\n margin-left: 4px;\n max-height: 300px;\n overflow-y: auto;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-code-language-submenu--visible {\n display: block !important;\n transform: translateX(0);\n}\n\n.clepit-code-language-submenu--hidden {\n display: none !important;\n}\n\n/* Code Theme Submenu */\n.clepit-code-theme-submenu {\n position: absolute;\n top: 0;\n left: 100%;\n z-index: 1002;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 140px;\n max-width: 180px;\n margin-left: 4px;\n max-height: 250px;\n overflow-y: auto;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-code-theme-submenu--visible {\n display: block !important;\n transform: translateX(0);\n}\n\n.clepit-code-theme-submenu--hidden {\n display: none !important;\n}\n\n/* Code language submenu items */\n.clepit-code-language-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.clepit-code-language-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-surface));\n}\n\n/* Code theme submenu items */\n.clepit-code-theme-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.clepit-code-theme-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-surface));\n}\n\n\n`,te="\n/* Output Code Block */\n/* No margin of its own — every consumer already governs the gap around this\n * container (page rhythm via the block wrapper's margin-block, or a flex\n * container's gap inside the openapi block). A margin here just adds a second,\n * inconsistent gap on top of whichever one the consumer already applies. */\n.clepit-output-code-container {\n border: 1px solid var(--clepit-code-border);\n border-radius: var(--clepit-radius-md);\n overflow: hidden;\n background: var(--clepit-code-bg);\n margin: 0;\n}\n\n.clepit-output-code-header {\n background: var(--clepit-code-bg);\n padding: 8px 34px;\n border-bottom: 1px solid var(--clepit-code-border);\n font-size: 12px;\n color: var(--clepit-text-muted);\n font-weight: 500;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n/* Output header — theme-agnostic; tokens handle light/dark automatically */\n.clepit-output-code-header {\n background: var(--clepit-code-bg);\n color: var(--clepit-text-muted);\n border-bottom-color: var(--clepit-code-border);\n --clepit-svg-stroke-color: var(--clepit-text-muted);\n --clepit-btn-hover-bg: var(--clepit-block-highlight-bg);\n}\n\n/* Output code variant tabs */\n.clepit-output-code-tabs {\n display: flex;\n align-items: stretch;\n gap: 4px;\n margin: -8px 0 -8px -18px;\n overflow-x: auto;\n scrollbar-width: none;\n}\n\n.clepit-output-code-tabs::-webkit-scrollbar {\n display: none;\n}\n\n.clepit-output-code-tab {\n appearance: none;\n -webkit-appearance: none;\n background: transparent;\n border: none;\n border-bottom: 2px solid transparent;\n color: var(--clepit-text-muted);\n cursor: pointer;\n font: inherit;\n padding: 8px 10px;\n transition: color 0.2s ease, border-color 0.2s ease;\n white-space: nowrap;\n}\n\n.clepit-output-code-tab:hover {\n color: var(--clepit-text);\n}\n\n.clepit-output-code-tab[aria-selected=\"true\"] {\n border-bottom-color: var(--clepit-primary);\n color: var(--clepit-primary);\n}\n\n.clepit-output-code-tab:focus-visible {\n outline: 2px solid var(--clepit-primary);\n outline-offset: -2px;\n}\n\n.clepit-output-code-editor {\n overflow-y: auto;\n max-height: 60vh;\n position: relative;\n border: none;\n border-radius: 0;\n}\n\n/* The output panes: one pre per variant, the inactive ones carrying a hidden attribute.\n * Colour comes from the generated theme stylesheet, keyed on the container's\n * data-theme, so a published page keeps its palette with nothing running. */\n.clepit-output-code-pane {\n margin: 0;\n padding: 12px 34px;\n max-height: 60vh;\n overflow-y: auto;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n tab-size: 2;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n\n/* Code Output */\n.clepit-output-code {\n margin: 1rem 0;\n background-color: var(--clepit-code-bg);\n border: 1px solid var(--clepit-code-border);\n border-radius: var(--clepit-radius-md);\n overflow: hidden;\n}\n\n.clepit-output-code code {\n display: block;\n padding: 1rem;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n color: var(--clepit-code-text);\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n\n/* Output code copy button */\n.clepit-output-code-copy-btn {\n margin-left: auto;\n width: 24px;\n height: 24px;\n border: none;\n outline: none;\n cursor: pointer;\n border-radius: 50%;\n background: transparent;\n transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.clepit-output-code-copy-btn {\n color: var(--clepit-text-muted);\n}\n\n.clepit-output-code-copy-btn:hover {\n background: var(--clepit-block-highlight-bg);\n color: var(--clepit-primary);\n}\n\n.clepit-output-code-copy-btn:hover .clepit-copy-icon {\n stroke: var(--clepit-primary);\n}\n\n.clepit-output-code-copy-btn:active {\n transform: scale(0.95);\n}\n\n.clepit-copy-icon,\n.clepit-check-icon {\n width: 20px;\n height: 20px;\n stroke: var(--clepit-svg-stroke-color);\n stroke-width: 2;\n fill: none;\n display: block;\n}\n\n/* Code output button animation styles */\n.clepit-output-code-copy-btn--animating {\n color: var(--clepit-success);\n transform: scale(1.1);\n}\n\n.clepit-output-code-copy-btn--normal {\n color: var(--clepit-svg-stroke-color);\n transform: scale(1);\n}\n",ne=(e,t,n)=>C.getState().getInstance(e)?.config.blockToolbarLabels?.[t]||n,ae={auto:"Auto",dark:"Dark",default:"Auto",dracula:"Dracula",github:"GitHub","github-dark":"GitHub Dark",light:"Light",monokai:"Monokai",solarized:"Solarized","solarized-dark":"Solarized Dark",tomorrow:"Tomorrow"};function oe(e){return ae[e]||"Unknown"}var ie=Object.fromEntries(Object.keys(ae).map(e=>[e,{name:oe(e),theme:null}])),re=".clepit-output-code-container",se=`.${l.classNames.block.code.container}`,le="clepit-code-output-styles-theme",ce=(e,n)=>[`${[re,se].map(t=>`${t}${e}`).join(", ")} { background: ${n.background}; color: ${n.text}; }`,`${se}${e} .clepit-code-highlight { color: ${n.text}; }`,`${se}${e} .clepit-code-input { caret-color: ${n.text}; }`,...t.map(t=>`${((e,t)=>[re,se].map(n=>`${n}${e} ${t}`).join(", "))(e,`.clepit-code-${t}`)} { color: ${n[t]};${(e=>"comment"===e?" font-style: italic;":"")(t)} }`)].join("\n"),de=()=>[ce("",e()),...Object.entries(a).map(([e,t])=>ce(`[data-theme='${e}']`,t))].join("\n"),pe=`\n.${l.classNames.switch.container} {\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 8px;\n}\n\n.clepit-switch-control {\n position: relative;\n z-index: 0;\n box-sizing: border-box;\n display: inline-flex;\n align-items: stretch;\n overflow: hidden;\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n}\n\n.clepit-switch-input {\n position: absolute;\n inset-inline-start: 0;\n top: 0;\n z-index: 1;\n width: 100%;\n height: 100%;\n padding: 0;\n margin: 0;\n cursor: pointer;\n opacity: 0;\n}\n\n.clepit-switch-face {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: 3px 9px;\n font-size: 12px;\n font-weight: 500;\n line-height: 1.4;\n color: var(--clepit-text-muted);\n white-space: nowrap;\n user-select: none;\n background-color: transparent;\n}\n\n.clepit-switch-control:hover .clepit-switch-face:not([data-selected]) {\n color: var(--clepit-text);\n background-color: var(--clepit-hover-bg);\n}\n\n.clepit-switch-face[data-selected] {\n color: var(--clepit-text);\n background-color: color-mix(in srgb, var(--clepit-primary) 16%, transparent);\n}\n\n.clepit-switch-input:focus-visible ~ .clepit-switch-face {\n outline: 2px solid var(--clepit-primary);\n outline-offset: -2px;\n}\n\n.clepit-switch-label-text {\n display: flex;\n align-items: center;\n font-size: 13px;\n color: var(--clepit-text);\n cursor: pointer;\n}\n`,ue="clepit-switch-face",he=e=>{e.setAttribute("aria-checked",String(e.checked));for(const t of e.parentElement?.querySelectorAll(`:scope > .${ue}`)??[])t.toggleAttribute("data-selected","on"===t.getAttribute("data-state")===e.checked)},me=class{static create(e={}){const{checked:t=!1,onToggle:n,classNames:a,styles:o,label:i,onLabel:r="On",offLabel:s="Off",id:c=`switch-${Math.random().toString(36).substring(2,11)}`}=e;l.injectStyles("clepit-custom-switch-styles",pe);const d=l.createStyledElement("div",l.classNames.switch.container,{classNames:a?.container,styles:o?.container}),p=l.createStyledElement("span","clepit-switch-control",{classNames:a?.label,styles:o?.label}),u=l.createStyledElement("input","clepit-switch-input",{classNames:a?.input,styles:o?.input});u.type="checkbox",u.id=c,u.checked=t,u.setAttribute("role","switch"),p.appendChild(u);for(const[l,h]of[["on",r],["off",s]]){const e=document.createElement("span");e.className=ue,e.setAttribute("aria-hidden","true"),e.setAttribute("data-state",l),e.textContent=h,p.appendChild(e)}if(he(u),u.addEventListener("change",()=>{he(u),n?.(u.checked)}),d.appendChild(p),i){const e=l.createStyledElement("label","clepit-switch-label-text",{classNames:a?.labelText,styles:o?.labelText});e.setAttribute("for",c),e.textContent=i,d.appendChild(e)}return d}static getState(e){const t=e.querySelector('input[type="checkbox"]');return!!t&&t.checked}static setState(e,t){const n=e.querySelector('input[type="checkbox"]');n&&(n.checked=t,he(n))}},ge=class e{static{this.placeholder="Enter code..."}static{this.supportedLanguages=Q}static{this.supportedThemes=ie}static{this.defaultLanguage="typescript"}static{this.defaultTheme="auto"}static{this.inputMap=/* @__PURE__ */new WeakMap}static{this.dataMap=/* @__PURE__ */new WeakMap}static save(t){const n=t.querySelector(`.${l.classNames.block.code.container}`),a=n.querySelector(`.${l.classNames.block.code.headerWrapper}`),o=n?.getAttribute("data-language")||e.defaultLanguage,i=n?.getAttribute("data-theme")||e.defaultTheme,r=!!a&&me.getState(a),s=e.inputMap.get(n);if(s){const t=s.value,a=e.dataMap.get(n),l={code:t.trim()||"",language:o,showCopy:r,theme:i};return a?.variants?.length&&(l.variants=a.variants),a?.syncKey&&(l.syncKey=a.syncKey),e.dataMap.set(n,l),l}return{...e.dataMap.get(n)||{code:"",language:e.defaultLanguage,theme:e.defaultTheme},showCopy:r}}static addVariant(e){const t=e.variants?.length?e.variants:[{code:e.code,...e.language?{language:e.language}:{}}];return{...e,variants:[...t,{code:""}]}}static removeVariant(e,t){const n=(e.variants??[]).filter((e,n)=>n!==t),a=n[0],o={...e,code:a?.code??e.code,...a?.language?{language:a.language}:{}};if(n.length<=1){const{variants:e,...t}=o;return t}return{...o,variants:n}}static render(t,n,a,o){l.injectStyles("clepit-code-input-styles",ee),l.injectStyles(le,de());const i={code:"",language:o?.language||e.defaultLanguage,showCopy:!0,theme:o?.theme||e.defaultTheme},r=n?{...i,...n}:i,s=l.createStyledElement("div",l.classNames.block.code.container,{classNames:a?.classNames?.container,styles:a?.styles?.container});s.setAttribute("data-language",r.language||e.defaultLanguage),s.setAttribute("data-theme",r.theme||e.defaultTheme);const c=l.createStyledElement("div",l.classNames.block.code.headerWrapper,{classNames:a?.classNames?.header?.wrapper,styles:a?.styles?.header?.wrapper}),d=l.createStyledElement("div",l.classNames.block.code.header,{classNames:a?.classNames?.header?.text,styles:a?.styles?.header?.text}),p=Q[r.language]?.name||Z(e.defaultLanguage),u=ie[r.theme]?.name||oe(e.defaultTheme);d.textContent=e.getHeaderText(p,u);const h=l.createStyledElement("div",l.classNames.block.code.editor,{classNames:a?.classNames?.container,styles:a?.styles?.container});h.setAttribute("data-placeholder",ne(t,"codeHint",e.placeholder));const m=t?C.getState().getInstance(t):null,g=m?.config.classNames?.switch,b=m?.config.styles?.switch,f=me.create({checked:r.showCopy||!1,classNames:g,label:ne(t,"codeAllowCopy","Allow copy"),offLabel:ne(t,"switchOff","Off"),onLabel:ne(t,"switchOn","On"),onToggle:t=>{const n=e.dataMap.get(s)||{code:"",language:e.defaultLanguage,theme:e.defaultTheme};e.dataMap.set(s,{...n,showCopy:t}),Ds.saveBlockData(s)},styles:b});return c.appendChild(d),c.appendChild(f),s.appendChild(c),s.appendChild(h),e.mountEditor(s,h,r),s}static mountEditor(t,n,a){const o=a.language??e.defaultLanguage,i=document.createElement("pre");i.className="clepit-code-highlight",i.setAttribute("aria-hidden","true");const r=document.createElement("code");i.appendChild(r);const s=document.createElement("textarea");s.className="clepit-code-input",s.value=a.code??"",s.spellcheck=!1,s.autocapitalize="off",s.setAttribute("autocorrect","off"),s.setAttribute("data-testid","code-input"),s.setAttribute("aria-label",`${Z(o)} code`),s.placeholder=n.getAttribute("data-placeholder")||e.placeholder,n.replaceChildren(i,s),e.inputMap.set(t,s),e.dataMap.set(t,a),e.paint(t,r,s.value),s.addEventListener("input",()=>{e.paint(t,r,s.value);const n=e.dataMap.get(t)??{code:"",language:t.getAttribute("data-language")||e.defaultLanguage,theme:t.getAttribute("data-theme")||e.defaultTheme};e.dataMap.set(t,{...n,code:s.value}),Ds.saveBlockData(t)}),s.addEventListener("scroll",()=>{i.scrollTop=s.scrollTop,i.scrollLeft=s.scrollLeft}),s.addEventListener("keydown",n=>e.handleKeydown(t,s,n))}static paint(t,n,a){const i=t.getAttribute("data-language")||e.defaultLanguage;n.replaceChildren(...o(a.endsWith("\n")?`${a} `:a,i).map(e=>{const t=document.createElement("span");return e.classes&&(t.className=e.classes),t.textContent=e.text,t}))}static updateLanguage(t,n){const a=t.querySelector(`.${l.classNames.block.code.container}`);if(!a)return;const o=t.querySelector(`.${l.classNames.block.code.editor}`);if(!o)return;a.setAttribute("data-language",n);const i=a.querySelector(`.${l.classNames.block.code.header}`),r=a.getAttribute("data-theme")||e.defaultTheme,s=oe(r),c=Z(n);i&&(i.textContent=e.getHeaderText(c,s));const d=e.inputMap.get(a);d&&e.mountEditor(a,o,{code:d.value,language:n,theme:r}),Ds.saveBlockData(a)}static updateTheme(t,n){const a=t.querySelector(`.${l.classNames.block.code.container}`);if(!a)return;const o=t.querySelector(`.${l.classNames.block.code.editor}`);if(!o)return;a.setAttribute("data-theme",n);const i=a.querySelector(`.${l.classNames.block.code.header}`),r=a.getAttribute("data-language")||e.defaultLanguage,s=Z(r),c=oe(n);i&&(i.textContent=e.getHeaderText(s,c));const d=e.inputMap.get(a);d&&e.mountEditor(a,o,{code:d.value,language:r,theme:n}),Ds.saveBlockData(a)}static handleKeydown(e,t,n){const a=e.closest(`.${l.classNames.block.container}`);if(!a)return;const o=Ds.getEditorId(a);if(!o)return;const i=Ds.getBlockIndex(o,a.getAttribute("data-id")),r=n.metaKey||n.ctrlKey;return"Enter"!==n.key||n.shiftKey?"Backspace"===n.key&&r||"Delete"===n.key&&r?(n.preventDefault(),void Ds.removeBlock(o,i)):"Backspace"!==n.key||""!==t.value.trim()?"ArrowUp"===n.key?(n.preventDefault(),void(n.shiftKey?Ds.moveBlock(o,i,i-1):Ds.focusBlock(a.previousElementSibling))):void("ArrowDown"===n.key&&(n.preventDefault(),n.shiftKey?Ds.moveBlock(o,i,i+1):Ds.focusBlock(a.nextElementSibling))):void Ds.removeBlock(o,i):(n.preventDefault(),void Ds.insertBlock({data:{html:""},type:"paragraph"},o,i+1))}static getHeaderText(e,t){return`${e} | ${t}`}static isEmpty(t){const n=t.querySelector(`.${l.classNames.block.code.container}`);if(!n)return!0;const a=e.inputMap.get(n);return!a||Boolean(a.value?.trim())}static isEmptyData(e){return h(e.code)}static destroy(t){const n=document.getElementById(t);if(!n)return console.warn("CodeInput::destroy: Container not found for containerId:",t);n.querySelectorAll(`.${l.classNames.block.code.container}`).forEach(t=>{e.inputMap.delete(t),e.dataMap.delete(t)})}},be="clepit:code-variant-sync",fe=e=>`clepit.code-variant.${e}`,ve=(e,t)=>e.label?e.label:e.language?Y[e.language]??e.language:`Tab ${t+1}`,ye=(e,t)=>{if(!t)return 0;const n=e.findIndex((e,n)=>ve(e,n)===t);return-1===n?0:n},xe=e=>{if(!e||"undefined"==typeof localStorage)return null;try{return localStorage.getItem(fe(e))}catch{return null}};function ke(e,t,n="below",a,o){let i=null,r=null;const s=()=>{if(i)return;l.injectStyles("clepit-inline-tooltip-styles","\n/* Inline Tooltip Container */\n.clepit-inline-tooltip {\n position: fixed;\n z-index: 9999;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.2s ease-in-out;\n}\n\n/* Tooltip Content */\n.clepit-inline-tooltip-content {\n background: var(--clepit-text);\n color: var(--clepit-bg);\n padding: 6px 10px;\n border-radius: 6px;\n font-size: 12px;\n font-weight: 500;\n white-space: nowrap;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\n transform: translateY(8px);\n transition: transform 0.2s ease-in-out;\n position: relative;\n}\n\n/* Tooltip Arrow */\n.clepit-inline-tooltip-arrow {\n position: absolute;\n width: 0;\n height: 0;\n}\n\n/* Arrow pointing down (when tooltip is above target) */\n.clepit-inline-tooltip-arrow--above {\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border-left: 6px solid transparent;\n border-right: 6px solid transparent;\n border-top: 6px solid var(--clepit-text);\n}\n\n/* Arrow pointing up (when tooltip is below target) */\n.clepit-inline-tooltip-arrow--below {\n bottom: 100%;\n left: 50%;\n transform: translateX(-50%);\n border-left: 6px solid transparent;\n border-right: 6px solid transparent;\n border-bottom: 6px solid var(--clepit-text);\n}\n"),i=document.createElement("div"),i.className=`clepit-inline-tooltip ${a?.container||""}`,l.applyStyling(i,{styles:o?.container});const s=document.createElement("div");s.className=`clepit-inline-tooltip-content ${a?.content||""}`,s.textContent=t,l.applyStyling(s,{styles:o?.content});const d=document.createElement("div");d.className=`clepit-inline-tooltip-arrow clepit-inline-tooltip-arrow--${n} ${a?.arrow||""}`,l.applyStyling(d,{styles:o?.arrow}),s.appendChild(d),i.appendChild(s),document.body.appendChild(i);const p=e.getBoundingClientRect(),u=s.offsetWidth,h=s.offsetHeight;let m,g=p.left+p.width/2-u/2;g=Math.max(8,Math.min(g,window.innerWidth-u-8));let b=n;"below"===n?(m=p.bottom+6+2,m+h>window.innerHeight-8&&(m=p.top-h-6-2,b="above")):(m=p.top-h-6-2,m<8&&(m=p.bottom+6+2,b="below")),d.className=`clepit-inline-tooltip-arrow clepit-inline-tooltip-arrow--${b} ${a?.arrow||""}`,i.style.left=`${g}px`,i.style.top=`${Math.max(8,Math.min(m,window.innerHeight-h-8))}px`,requestAnimationFrame(()=>{i&&(i.style.opacity="1",s.style.transform="translateY(0)")}),r||(r=new MutationObserver(()=>{document.body.contains(e)&&e.isConnected||(c(),r&&(r.disconnect(),r=null))}),r.observe(document.body,{childList:!0,subtree:!0}))},c=()=>{i&&(i.style.opacity="0",setTimeout(()=>{i&&i.parentElement&&i.parentElement.removeChild(i),i=null,r&&(r.disconnect(),r=null)},120))};return e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",c),()=>{e.removeEventListener("mouseenter",s),e.removeEventListener("mouseleave",c),c()}}var we="http://www.w3.org/2000/svg",Ce=e=>{if("pending"!==e.dataset.highlight)return;const t=e.querySelector("code");if(null===t)return;const n=e.dataset.language,a=o(t.textContent??"",(i=n,void 0!==i&&Object.prototype.hasOwnProperty.call(Y,i)?n:"plaintext")).map(e=>{const t=document.createElement("span");return e.classes&&(t.className=e.classes),t.textContent=e.text,t});var i;t.replaceChildren(...a),delete e.dataset.highlight,delete e.dataset.language},Ae=e=>e.variants?.length?e.variants:[{code:e.code,language:e.language}],Se=class e{static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static draw(t,n=R,a){if(!e.validate(t)||ge.isEmptyData(t))return null;const i=Ae(t),r=i.length>1,s=Math.min(Math.max(a?.activeVariant??0,0),i.length-1),l=n.create("div");l.addClass("clepit-output-code-container"),l.setAttribute("data-theme",t.theme??ge.defaultTheme),t.syncKey&&l.setAttribute("data-sync-key",t.syncKey);const c=n.create("div");if(c.addClass("clepit-output-code-header"),r){const e=n.create("div");e.addClass("clepit-output-code-tabs"),e.setAttribute("role","tablist"),e.setAttribute("data-testid","code-variant-tabs"),i.forEach((t,a)=>{const o=n.create("button");o.addClass("clepit-output-code-tab"),o.setAttribute("type","button"),o.setAttribute("role","tab"),o.setAttribute("aria-selected",a===s?"true":"false"),o.setAttribute("tabindex",a===s?"0":"-1"),o.setAttribute("data-testid",`code-variant-tab-${a}`),o.setText(ve(t,a)),e.append(o)}),c.append(e)}else{const e=n.create("span");e.setText(Y[t.language??"typescript"]??"TypeScript"),c.append(e)}if(t.showCopy){const e=n.create("button");e.addClass("clepit-output-code-copy-btn"),e.setAttribute("type","button"),e.setAttribute("aria-label","Copy code"),e.append((e=>{const t=e.createNS(we,"svg");t.setAttribute("class","clepit-copy-icon"),t.setAttribute("width","16"),t.setAttribute("height","16"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");const n=e.createNS(we,"path");return n.setAttribute("d","M7.5 3H14.6C16.8402 3 17.9603 3 18.816 3.43597C19.5686 3.81947 20.1805 4.43139 20.564 5.18404C21 6.03969 21 7.15979 21 9.4V16.5M6.2 21H14.3C15.4201 21 15.9802 21 16.408 20.782C16.7843 20.5903 17.0903 20.2843 17.282 19.908C17.5 19.4802 17.5 18.9201 17.5 17.8V9.7C17.5 8.57989 17.5 8.01984 17.282 7.59202C17.0903 7.21569 16.7843 6.90973 16.408 6.71799C15.9802 6.5 15.4201 6.5 14.3 6.5H6.2C5.0799 6.5 4.51984 6.5 4.09202 6.71799C3.71569 6.90973 3.40973 7.21569 3.21799 7.59202C3 8.01984 3 8.57989 3 9.7V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.0799 21 6.2 21Z"),n.setAttribute("stroke","var(--clepit-svg-stroke-color)"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),t.append(n),t})(n)),c.append(e)}l.append(c);const d=n.create("div");return d.addClass("clepit-output-code-editor"),r&&d.setAttribute("role","tabpanel"),i.forEach((e,i)=>{const r=n.create("pre");r.addClass("clepit-output-code-pane"),r.setAttribute("data-variant-index",String(i));const l=e.language??t.language??"plaintext",c=n.create("code");if(i!==s||a?.deferHighlight)i!==s&&r.setAttribute("hidden",""),r.setAttribute("data-highlight","pending"),r.setAttribute("data-language",l),c.setText(e.code??t.code);else for(const a of o(e.code??t.code,l)){const e=n.create("span");a.classes&&e.addClass(...a.classes.split(" ")),e.setText(a.text),c.append(e)}r.append(c),d.append(r)}),l.append(d),l}static render(t,n,a,o,i){if(l.injectStyles("clepit-code-output-styles",te),l.injectStyles(le,de()),!e.validate(t))return X();if(ge.isEmptyData(t))return document.createElement("div");const r=Ae(t),s=r.length>1?ye(r,xe(t.syncKey)):0,c=J(e.draw(t,R,{activeVariant:s}));o?.container&&c.classList.add(o.container),a?.container&&Object.assign(c.style,a.container);const d=c.querySelector(".clepit-output-code-header");return d&&o?.header?.text&&d.classList.add(o.header.text),d&&a?.header?.text&&Object.assign(d.style,a.header.text),e.attach(c,t,s,i),c}static activate(t,n){if(!e.validate(n)||ge.isEmptyData(n))return()=>{};const a=Ae(n),o=a.length>1?ye(a,xe(n.syncKey)):0;return e.attach(t,n,o,void 0,!0)}static reveal(e){for(const t of[...e.querySelectorAll('.clepit-output-code-pane[data-highlight="pending"]')])t.hidden||Ce(t)}static activateFromMarkup(t){const n=[...t.querySelectorAll(".clepit-output-code-pane")];if(0===n.length)return()=>{};const a=[...t.querySelectorAll(".clepit-output-code-tab")],o=n.map((e,t)=>({code:e.textContent??"",label:a[t]?.textContent||void 0})),i=t.getAttribute("data-sync-key")??void 0,r={code:o[0]?.code??"",showCopy:null!==t.querySelector(".clepit-output-code-copy-btn"),syncKey:i,variants:o},s=o.length>1?ye(o,xe(i)):0;return e.attach(t,r,s,void 0,!0)}static attach(t,n,a,o,i=!1){const r=Ae(n),s=o?document.getElementById(o):null,l=[...t.querySelectorAll(".clepit-output-code-tab")],c=[...t.querySelectorAll(".clepit-output-code-pane")];let d=a;const p=[];let u;const h=(t,n,a)=>{if(t.addEventListener(n,a),p.push({event:n,handler:a,target:t}),s){const o=e.eventListenersMap.get(s)??[];o.push({element:t,event:n,handler:a}),e.eventListenersMap.set(s,o)}},m=(e,a)=>{if(e<0||e>=r.length)return;if(d=e,l.forEach((t,n)=>{t.setAttribute("aria-selected",n===e?"true":"false"),t.tabIndex=n===e?0:-1}),c.forEach((n,a)=>{a===e&&null===t.closest("[hidden]")&&Ce(n),n.hidden=a!==e}),!a||!n.syncKey)return;const o=ve(r[e],e);((e,t)=>{if(e&&"undefined"!=typeof localStorage)try{localStorage.setItem(fe(e),t)}catch{return}})(n.syncKey,o),window.dispatchEvent(new CustomEvent(be,{detail:{label:o,syncKey:n.syncKey}}))};if(l.forEach((e,t)=>{h(e,"click",()=>m(t,!0)),h(e,"keydown",e=>{const n=e.key,a="ArrowRight"===n?1:"ArrowLeft"===n?-1:0,o="Home"===n?0:"End"===n?r.length-1:0===a?-1:(t+a+r.length)%r.length;-1!==o&&(e.preventDefault(),m(o,!0),l[o]?.focus())})}),l.length>1&&n.syncKey){const t=e=>{const t=e.detail;if(!t||t.syncKey!==n.syncKey)return;const a=r.findIndex((e,n)=>ve(e,n)===t.label);-1!==a&&a!==d&&m(a,!1)};if(window.addEventListener(be,t),p.push({event:be,handler:t,target:window}),s){const n=e.eventListenersMap.get(s)??[];n.push({element:window,event:be,handler:t}),e.eventListenersMap.set(s,n)}}const g=()=>{for(const{event:e,handler:t,target:n}of p)n.removeEventListener(e,t);u?.()};i&&m(a,!1);const b=t.querySelector(".clepit-output-code-copy-btn");if(!b)return g;h(b,"click",()=>{e.copyCodeToClipboard(r[d]?.code??n.code),e.animateCopyButton(b)});const f=o?C.getState().getInstance(o):null;return u=ke(b,"Copy code","above",f?.config.classNames?.tooltips,f?.config.styles?.tooltips),g}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.code}static copyCodeToClipboard(e){navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(e).catch(e=>{console.error("Failed to copy code to clipboard:",e)}):console.warn("Clipboard API not available in this context")}static animateCopyButton(e){const t=e.innerHTML;e.innerHTML='<svg class="clepit-check-icon" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="CheckIcon"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path></svg>',e.classList.remove("clepit-output-code-copy-btn--normal"),e.classList.add("clepit-output-code-copy-btn--animating"),setTimeout(()=>{e.innerHTML=t,e.classList.remove("clepit-output-code-copy-btn--animating"),e.classList.add("clepit-output-code-copy-btn--normal")},1e3)}static destroy(t){const n=document.getElementById(t);if(!n)return console.warn("CodeOutput::destroy: Container not found for containerId:",t);const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n))}},Ee="inline-issue",Le='\n.clepit-issue {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n max-width: 100%;\n padding: 1px 8px 1px 6px;\n vertical-align: baseline;\n font-size: 0.92em;\n line-height: 1.5;\n color: inherit;\n text-decoration: none;\n white-space: nowrap;\n background: rgba(127, 127, 127, 0.1);\n border: 1px solid rgba(127, 127, 127, 0.25);\n border-radius: 999px;\n cursor: pointer;\n}\n.clepit-issue:hover {\n background: rgba(127, 127, 127, 0.16);\n}\n.clepit-issue__key {\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n}\n.clepit-issue__title {\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 28ch;\n}\n.clepit-issue__state {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 0 7px;\n font-size: 12px;\n line-height: 18px;\n border-radius: 999px;\n background: rgba(127, 127, 127, 0.16);\n}\n.clepit-issue__state::before {\n content: \'\';\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: currentColor;\n}\n.clepit-issue__state[data-issue-category="todo"] {\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue__state[data-issue-category="started"] {\n color: var(--clepit-primary, #5958fc);\n background: var(--clepit-primary-bg, rgba(89, 88, 252, 0.16));\n}\n.clepit-issue__state[data-issue-category="done"] {\n color: var(--clepit-success, #15803d);\n background: var(--clepit-success-bg, rgba(21, 128, 61, 0.16));\n}\n.clepit-issue__state[data-issue-category="cancelled"] {\n color: var(--clepit-text-muted, #6b7280);\n text-decoration: line-through;\n}\n.clepit-issue__assignee {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n font-size: 10px;\n font-weight: 600;\n letter-spacing: 0.02em;\n color: #fff;\n background: var(--clepit-primary, #5958fc);\n border-radius: 50%;\n}\n.clepit-issue__reason {\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue--reason {\n border-style: dashed;\n}\n[data-issue-chip-status="off"] .clepit-issue__state,\n[data-issue-chip-assignee="off"] .clepit-issue__assignee {\n display: none;\n}\n.clepit-issue-menu {\n position: absolute;\n z-index: 20;\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 180px;\n padding: 4px;\n font-size: 13px;\n background: var(--clepit-surface, #fff);\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);\n}\n.clepit-issue-menu a,\n.clepit-issue-menu button {\n display: block;\n width: 100%;\n padding: 6px 10px;\n font: inherit;\n color: inherit;\n text-align: left;\n text-decoration: none;\n background: none;\n border: 0;\n border-radius: 6px;\n cursor: pointer;\n}\n.clepit-issue-menu a:hover,\n.clepit-issue-menu button:hover {\n background: rgba(127, 127, 127, 0.1);\n}\n.clepit-issue-menu__reason {\n padding: 6px 10px 2px;\n font-size: 12px;\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue-card {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 12px;\n color: inherit;\n text-decoration: none;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n}\n.clepit-issue-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-issue-card__head {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n}\n.clepit-issue-card__key {\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n}\n.clepit-issue-card__title {\n font-weight: 600;\n}\n.clepit-issue-card__meta {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px 12px;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-issue-card__assignee {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n}\n.clepit-issue-card__reason {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 14px;\n align-items: center;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-issue-card__action {\n padding: 0;\n font: inherit;\n color: inherit;\n text-decoration: underline;\n background: none;\n border: 0;\n cursor: pointer;\n}\n.clepit-issues {\n width: 100%;\n border-collapse: collapse;\n font-size: 0.95em;\n}\n.clepit-issues th,\n.clepit-issues td {\n padding: 6px 10px;\n text-align: left;\n border-bottom: 1px solid rgba(127, 127, 127, 0.25);\n}\n.clepit-issues th {\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.02em;\n text-transform: uppercase;\n opacity: 0.7;\n}\n.clepit-issues a {\n color: inherit;\n font-weight: 600;\n text-decoration: none;\n}\n.clepit-issues a:hover {\n text-decoration: underline;\n}\n.clepit-issues__empty {\n opacity: 0.55;\n}\n',Ne={categoryCancelled:"Cancelled",categoryDone:"Done",categoryStarted:"In progress",categoryTodo:"To do",columnAssignee:"Assignee",columnIssue:"Issue",columnStatus:"Status",columnTitle:"Title",connectAction:"Connect",connectTool:"Connect {tool} to see this issue",linkedIssuesEmpty:"No issues linked on this page yet",noAccess:"You do not have access to this issue in {tool}",openInTool:"Open in {tool}",providerUnreachable:"{tool} did not answer",showAsCard:"Show as card",unassigned:"Unassigned",updatedRelative:"updated {when}"},Be={asana:"Asana",github_issues:"GitHub",jira:"Jira",linear:"Linear"},Me={cancelled:"categoryCancelled",done:"categoryDone",started:"categoryStarted",todo:"categoryTodo"};function $e(e,t,n={}){let a=e?.[t]??Ne[t];for(const[o,i]of Object.entries(n))a=a.replace(`{${o}}`,i);return a}var Ie=e=>Be[e]??e,Te="clepit-issue",_e=["todo","started","done","cancelled"],qe=["connect_tool","no_access","provider_unreachable"],De={connect_tool:"connectTool",no_access:"noAccess",provider_unreachable:"providerUnreachable"},ze=e=>e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(""),je=(e,t)=>e.reason?$e(t,De[e.reason],{tool:Ie(e.tool)}):null,He=(e,t)=>e.stateName||$e(t,Me[e.category]),Oe=(e,t,n="")=>({category:"todo",key:n,stateName:"",title:"",tool:t,updatedAt:"",url:e}),Pe=e=>d(e)?e:"",Re=class e{static build(t,n,a=R){const o=a.create("a");o.addClass(Te),t.reason&&o.addClass(`${Te}--reason`),d(t.url)&&o.setAttribute("href",t.url),o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer"),o.setAttribute("contenteditable","false");for(const[s,l]of Object.entries(e.attributes(t)))o.setAttribute(s,l);const i=a.create("span");i.addClass(`${Te}__key`),i.setText(t.key||(t.title?"":Ie(t.tool))),!t.key&&t.title||o.append(i);const r=je(t,n);if(r){const e=a.create("span");return e.addClass(`${Te}__reason`),e.setText(r),o.append(e),o}if(t.title){const e=a.create("span");e.addClass(`${Te}__title`),e.setText(t.title),o.append(e)}if(t.stateName||t.updatedAt){const e=a.create("span");e.addClass(`${Te}__state`),e.setAttribute("data-issue-category",t.category),e.setText(He(t,n)),o.append(e)}if(t.assigneeName){const e=a.create("span");e.addClass(`${Te}__assignee`),e.setAttribute("title",t.assigneeName),e.setText(ze(t.assigneeName)),o.append(e)}return o}static markup(t,n,a){return G(e.build(t,n,K(a)))}static create(t,n){return l.injectStyles(Ee,Le),J(e.build(t,n))}static refresh(t,n,a){const o=e.create(n,a);for(const e of Array.from(t.attributes))e.name.startsWith("data-issue-")&&t.removeAttribute(e.name);for(const e of Array.from(o.attributes))t.setAttribute(e.name,e.value);t.replaceChildren(...Array.from(o.childNodes))}static read(e){const t=t=>e.getAttribute(`data-issue-${t}`)??"",n=t("category"),a=t("reason");return{assigneeAvatarUrl:Pe(t("avatar"))||void 0,assigneeName:t("assignee")||void 0,category:_e.includes(n)?n:"todo",key:t("key"),pull:"true"===t("pull")||void 0,reason:qe.includes(a)?a:void 0,stateName:t("state"),title:t("title"),tool:t("tool"),updatedAt:t("updated"),url:Pe(t("url")||e.getAttribute("href")||"")}}static collect(e){return Array.from(e.querySelectorAll(`a.${Te}`))}static refreshAll(t,n,a){for(const o of e.collect(t)){const t=o.getAttribute("data-issue-url")||o.getAttribute("href")||"",i=n[t];i&&e.refresh(o,{...i,url:t},a)}}static applyParts(e,t){e.setAttribute("data-issue-chip-status",!1===t?.status?"off":"on"),e.setAttribute("data-issue-chip-assignee",!1===t?.assignee?"off":"on")}static insertAtCaret(t,n){const a=window.getSelection();if(!a||0===a.rangeCount)return null;const o=a.getRangeAt(0);o.deleteContents();const i=e.create(t,n);o.insertNode(i);const r=document.createTextNode(" ");i.after(r);const s=document.createRange();return s.setStartAfter(r),s.collapse(!0),a.removeAllRanges(),a.addRange(s),i}static attributes(e){const t={"data-issue-category":e.category,"data-issue-key":e.key,"data-issue-state":e.stateName,"data-issue-title":e.title,"data-issue-tool":e.tool,"data-issue-updated":e.updatedAt,"data-issue-url":e.url};return e.assigneeName&&(t["data-issue-assignee"]=e.assigneeName),e.assigneeAvatarUrl&&(t["data-issue-avatar"]=e.assigneeAvatarUrl),e.pull&&(t["data-issue-pull"]="true"),e.reason&&(t["data-issue-reason"]=e.reason),t}},Fe=/<a\b[^>]*\bclepit-issue(?=["'\s])[^>]*>[\s\S]*?<\/a>/g,Ve=(e,t)=>(new RegExp(`\\b${t}="([^"]*)"`).exec(e)?.[1]??"").replace(/&quot;/g,'"').replace(/&amp;/g,"&"),Ue=e=>{const t=t=>Ve(e,`data-issue-${t}`),n=t("category"),a=t("reason");return{assigneeAvatarUrl:Pe(t("avatar"))||void 0,assigneeName:t("assignee")||void 0,category:_e.includes(n)?n:"todo",key:t("key"),pull:"true"===t("pull")||void 0,reason:qe.includes(a)?a:void 0,stateName:t("state"),title:t("title"),tool:t("tool"),updatedAt:t("updated"),url:Pe(t("url")||Ve(e,"href"))}},We=e=>Array.from(e.matchAll(Fe),e=>Ue(e[0])),Ke=(e,t,n,a,o)=>t||n?e.replace(Fe,e=>{const i=Ue(e),r={...t?.[i.url]?{...t[i.url],url:i.url}:i};return!1===n?.status&&(r.stateName="",r.updatedAt=""),!1===n?.assignee&&(r.assigneeName=void 0),Re.markup(r,a,o)}):e,Ge=class e{static render(t,n){return l.injectStyles(Ee,Le),J(e.draw(t,R,n,!0))}static draw(t,n,a,o){const i=je(t,a);if(i)return e.drawReason(t,i,n,a,o);const r=n.create("a");r.addClass("clepit-issue-card","clepit-output-embed"),r.setAttribute("data-testid","issue-card"),d(t.url)&&r.setAttribute("href",t.url),r.setAttribute("rel","noopener noreferrer nofollow"),r.setAttribute("target","_blank");const s=n.create("span");if(s.addClass("clepit-issue-card__head"),t.key){const e=n.create("span");e.addClass("clepit-issue-card__key"),e.setText(t.key),s.append(e)}const l=n.create("span");l.addClass("clepit-issue-card__title"),l.setText(t.title||t.url),s.append(l);const c=n.create("span");c.addClass("clepit-issue__state"),c.setAttribute("data-issue-category",t.category),c.setText(He(t,a)),s.append(c),r.append(s);const p=n.create("span");p.addClass("clepit-issue-card__meta");const u=n.create("span");if(u.addClass("clepit-issue-card__assignee"),t.assigneeName){const e=n.create("span");e.addClass("clepit-issue__assignee"),e.setAttribute("title",t.assigneeName),e.setText(ze(t.assigneeName)),u.append(e),u.appendText(t.assigneeName)}else u.setText($e(a,"unassigned"));if(p.append(u),t.updatedAt){const e=n.create("span");e.addClass("clepit-issue-card__updated"),e.setText($e(a,"updatedRelative",{when:(h=t.updatedAt,h.length>=10?h.slice(0,10):h)})),p.append(e)}var h;return r.append(p),r}static drawReason(e,t,n,a,o){const i=n.create("div");i.addClass("clepit-issue-card","clepit-issue-card--reason","clepit-output-embed"),i.setAttribute("data-testid","issue-card");const r=n.create("a");r.addClass("clepit-issue-card__head"),d(e.url)&&r.setAttribute("href",e.url),r.setAttribute("rel","noopener noreferrer nofollow"),r.setAttribute("target","_blank");const s=n.create("span");if(s.addClass("clepit-issue-card__key"),s.setText(e.key||Ie(e.tool)),r.append(s),e.title){const t=n.create("span");t.addClass("clepit-issue-card__title"),t.setText(e.title),r.append(t)}i.append(r);const l=n.create("span");l.addClass("clepit-issue-card__reason"),l.setAttribute("data-testid","issue-reason");const c=n.create("span");if(c.setText(t),l.append(c),o&&"connect_tool"===e.reason){const t=n.create("button");t.addClass("clepit-issue-card__action"),t.setAttribute("type","button"),t.setAttribute("data-issue-action","connect"),t.setAttribute("data-issue-tool",e.tool),t.setAttribute("data-testid","issue-reason-action-connect"),t.setText($e(a,"connectAction")),l.append(t)}return i.append(l),i}},Je="allow-scripts allow-same-origin allow-presentation allow-forms",Xe={connectGoogle:"Connect your Google account to show this file",connectGoogleAction:"Connect",noAccess:"You do not have access to this file in Google Drive",offerShowLive:"{tool} · Show live",providerUnreachable:"{tool} did not answer, so the content is not shown",switchedOff:"Live view for {tool} is switched off for this workspace",truncated:"truncated",tryAgain:"Try again",viewOnGithub:"View on GitHub"},Ye={figma:"Figma",githubGist:"GitHub",googleDrive:"Google Drive",loom:"Loom",miro:"Miro"};function Ze(e,t,n={}){let a=e?.[t]??Xe[t];for(const[o,i]of Object.entries(n))a=a.replace(`{${o}}`,i);return a}var Qe=new Set(Object.keys(Y)),et={"c#":"csharp","c++":"cpp","html+erb":"html","objective-c":"objectivec",shell:"bash"};function tt(e){if(!e)return;const t=e.toLowerCase(),n=et[t];return n||(Qe.has(t)?t:void 0)}var nt={connect_google:"connectGoogle",no_access:"noAccess",provider_unreachable:"providerUnreachable",switched_off:"switchedOff"},at={connectGoogle:"connectGoogleAction",retry:"tryAgain"};function ot(e,t){const n=Ye[t.provider]??"The tool";if(t.switchedOff)return{reason:"switched_off",tool:n};switch(e.reason){case"connect_google":return{action:"connectGoogle",reason:"connect_google",tool:n};case"no_access":return{reason:"no_access",tool:n};case"provider_unreachable":return{action:"retry",reason:"provider_unreachable",tool:n};case"switched_off":return{reason:"switched_off",tool:n};default:return null}}var it=(e,t)=>"card"===e.display||!0===t.switchedOff||void 0!==e.reason,rt=class e{static render(t,n,a,o){if(l.injectStyles("embed-output",O),!e.validate(t))return X();if(t.issue)return Ge.render({...t.issue,...n?.issues?.[t.url],url:t.url},n?.issueLabels);const i=q(t.url,{disabledProviders:n?.disabledEmbedProviders,mapsEmbedKey:n?.mapsEmbedKey});if("invalid"===i.provider)return X();if(!it(t,i)){if(i.gist)return e.gistFrame(i.gist,a,o);if(i.embedUrl)return e.frame(i.embedUrl,i.aspect,a,o)}const r=e.card(t,i.url,a,o),s=ot(t,i);if(!s)return r;const c=l.createStyledElement("div","clepit-embed-card--with-reason clepit-output-embed",{classNames:o?.wrapper,styles:a?.wrapper});r.classList.remove("clepit-output-embed"),c.appendChild(r);const d=document.createElement("span");d.className="clepit-embed-card__reason",d.setAttribute("data-testid","embed-reason");const p=document.createElement("span");if(p.textContent=Ze(n?.embedLabels,nt[s.reason],{tool:s.tool}),d.appendChild(p),s.action){const e=document.createElement("button");e.type="button",e.className="clepit-embed-card__action",e.setAttribute("data-embed-action",s.action),e.setAttribute("data-testid",`embed-reason-action-${s.action}`),e.textContent=Ze(n?.embedLabels,at[s.action]),d.appendChild(e)}return c.appendChild(d),c}static draw(t,n=R,a){if(!e.validate(t))return null;if(t.issue)return Ge.draw({...t.issue,...a?.issues?.[t.url],url:t.url},n,a?.issueLabels,!1);const o=q(t.url,{disabledProviders:a?.disabledEmbedProviders,mapsEmbedKey:a?.mapsEmbedKey});if("invalid"===o.provider)return null;if(!it(t,o)){if(o.gist&&t.gist&&t.gist.files.length>0)return e.drawGist(t,n,a);if(o.embedUrl)return e.drawFrame(o.embedUrl,o.aspect,n)}const i=ot(t,o);if(!i)return e.drawCard(t,o.url,n,!0);const r=n.create("div");r.addClass("clepit-embed-card--with-reason","clepit-output-embed"),r.append(e.drawCard(t,o.url,n,!1));const s=n.create("span");s.addClass("clepit-embed-card__reason"),s.setAttribute("data-testid","embed-reason");const l=n.create("span");return l.setText(Ze(a?.embedLabels,nt[i.reason],{tool:i.tool})),s.append(l),r.append(s),r}static drawGist(e,t,n){const a=e.gist,o=t.create("div");o.addClass("clepit-embed-gist","clepit-output-embed");for(const i of a.files){const e=t.create("div");e.addClass("clepit-embed-gist__file");const r=t.create("b");if(r.setText(i.name),e.append(r),i.truncated){const a=t.create("span");a.setText(Ze(n?.embedLabels,"truncated")),e.append(a)}const s=t.create("a");s.setAttribute("href",a.htmlUrl),s.setAttribute("rel","noopener noreferrer nofollow"),s.setAttribute("target","_blank"),s.setText(Ze(n?.embedLabels,"viewOnGithub")),e.append(s),o.append(e);const l=Se.draw({code:i.content,language:tt(i.language),showCopy:!1},t,n);l&&o.append(l)}return o}static drawFrame(e,t,n){const a=n.create("div");a.addClass("clepit-embed","clepit-output-embed");const o=n.create("iframe");return o.addClass("clepit-embed__frame"),o.setAttribute("src",e),o.setAttribute("sandbox",Je),o.setAttribute("referrerpolicy","no-referrer"),o.setAttribute("loading","lazy"),o.setAttribute("allowfullscreen","true"),o.setAttribute("style",`aspect-ratio: ${t??16/9};`),a.append(o),a}static drawCard(e,t,n,a){const o=n.create("a");o.addClass("clepit-embed-card"),a&&o.addClass("clepit-output-embed"),o.setAttribute("href",t),o.setAttribute("rel","noopener noreferrer nofollow"),o.setAttribute("target","_blank");const i=n.create("span"),r=n.create("span");if(r.addClass("clepit-embed-card__title"),r.setText(e.title||t),i.append(r),e.description){const t=n.create("span");t.addClass("clepit-embed-card__description"),t.setText(e.description),i.append(t)}return o.append(i),o}static gistFrame(e,t,n){const a=l.createStyledElement("div","clepit-embed clepit-embed--gist-frame clepit-output-embed",{classNames:n?.wrapper,styles:t?.wrapper}),o=document.createElement("iframe");var i,r;return o.className="clepit-embed__frame",o.setAttribute("srcdoc",(i=e.owner,r=e.id,`<!doctype html><html><head><meta charset="utf-8"><base target="_blank"><style>body{margin:0;padding:8px;font:13px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}.gist .gist-file{margin-bottom:0}</style></head><body><script src="https://gist.github.com/${encodeURIComponent(i)}/${encodeURIComponent(r)}.js"><\/script></body></html>`)),o.setAttribute("sandbox","allow-scripts allow-popups allow-popups-to-escape-sandbox"),o.setAttribute("referrerpolicy","no-referrer"),o.setAttribute("loading","lazy"),o.style.height="552px",a.appendChild(o),a}static frame(e,t,n,a){const o=l.createStyledElement("div","clepit-embed clepit-output-embed",{classNames:a?.wrapper,styles:n?.wrapper}),i=document.createElement("iframe");return i.className="clepit-embed__frame",i.src=e,i.setAttribute("sandbox",Je),i.setAttribute("referrerpolicy","no-referrer"),i.setAttribute("loading","lazy"),i.setAttribute("allowfullscreen","true"),i.style.aspectRatio=String(t??16/9),o.appendChild(i),o}static card(e,t,n,a){const o=l.createStyledElement("a","clepit-embed-card clepit-output-embed",{classNames:a?.card,styles:n?.card});o.href=t,o.rel="noopener noreferrer nofollow",o.target="_blank";const i=document.createElement("span"),r=document.createElement("span");if(r.className="clepit-embed-card__title",r.textContent=e.title||t,i.appendChild(r),e.description){const t=document.createElement("span");t.className="clepit-embed-card__description",t.textContent=e.description,i.appendChild(t)}return o.appendChild(i),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url&&e.url.length>0}},st=/^[A-Z][A-Z0-9_]*-\d+$/,lt=/^\d+$/,ct=(e,t)=>e.endsWith(".atlassian.net")||t.some(t=>(e=>{try{return new URL(e).host.toLowerCase()}catch{return null}})(t)===e),dt=(e,t,n)=>n?{key:t,site:n,tool:e}:{key:t,tool:e};function pt(e,t=[]){let n;try{n=new URL(e)}catch{return null}if("https:"!==n.protocol&&"http:"!==n.protocol)return null;const a=n.host.toLowerCase(),o=n.pathname.split("/").filter(Boolean);if("linear.app"===a){const[,e,t]=o;return"issue"===e&&t&&st.test(t)?dt("linear",t):null}if("github.com"===a||"www.github.com"===a){const[e,t,n,a]=o;return e&&t&&("issues"===n||"pull"===n)&&a&&lt.test(a)?dt("github_issues",`${e}/${t}#${a}`):null}if("app.asana.com"===a){const[e,...t]=o;return"0"===e&&t.length>=2&&lt.test(t[0])&&lt.test(t[1])||("1"===e&&"project"===t[1]&&"task"===t[3]&&t[4]&&lt.test(t[4])||"1"===e&&"task"===t[1]&&t[2]&&lt.test(t[2]))?dt("asana",""):null}if(ct(a,t)){const e=`https://${a}`;if("browse"===o[0]&&o[1]&&st.test(o[1]))return dt("jira",o[1],e);const t=n.searchParams.get("selectedIssue");return t&&st.test(t)?dt("jira",t,e):null}return null}var ut=/* @__PURE__ */new WeakMap,ht=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-output-embed")?e:e.querySelector(".clepit-output-embed");return(t?ut.get(t):void 0)??{url:""}}static render(t,n,a){l.injectStyles("embed-input",H);const o=n??{url:""},i=C.getState().getInstance(t)?.config,r=rt.render(o,{disabledEmbedProviders:i?.disabledEmbedProviders,embedLabels:i?.embedLabels},a?.styles,a?.classNames);return r.classList.add("clepit-embed--input"),r.setAttribute("contenteditable","false"),ut.set(r,o),e.listenForActions(t,r),r}static isEmpty(t){return""===e.save(t).url}static isEmptyData(e){return!e.url}static handleOperation(t,n,a){const o=n.getAttribute("data-id"),i=e.save(n);switch(t){case"embedShowLive":{const{display:e,...t}=i;return Ds.updateBlockData(o,t,a)}case"embedShowCard":return Ds.updateBlockData(o,{...i,display:"card"},a);case"embedShowLink":{const e=Ds.getBlockIndex(a,o);if(-1===e)return;const t=document.createElement("a");return t.href=i.url,t.textContent=i.url,Ds.replaceBlock(a,e,{data:{html:t.outerHTML},type:"paragraph"})}case"embedCopyLink":return void navigator.clipboard?.writeText(i.url);case"embedShowChip":{const e=Ds.getBlockIndex(a,o);if(-1===e)return;const t=C.getState().getInstance(a)?.config,n=pt(i.url,t?.jiraSites),r=i.issue??Oe(i.url,n?.tool??"",n?.key??""),s=Re.create({...r,url:i.url},t?.issueLabels);return Ds.replaceBlock(a,e,{data:{html:`${s.outerHTML} `},type:"paragraph"})}default:return}}static refreshIssue(t,n,a){const o=e.save(t);if(!o.issue)return;const i=t.querySelector(`.${l.classNames.block.content}`);if(!i)return;const r=C.getState().getInstance(n),s={classNames:r?.config.classNames?.blocks?.embed,styles:r?.config.styles?.blocks?.embed};i.replaceChildren(e.render(n,{...o,issue:{...a,url:o.url}},s))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}static listenForActions(t,n){const a=e=>{const a=e.target?.closest("[data-issue-action]");if(a)return e.preventDefault(),e.stopPropagation(),void C.getState().getInstance(t)?.config.onIssueAction?.("connect",a.getAttribute("data-issue-tool")??"");const o=e.target?.closest("[data-embed-action]");if(!o)return;e.preventDefault(),e.stopPropagation();const i=o.getAttribute("data-embed-action"),r=n.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");if(!r)return;const s=C.getState().getInstance(t)?.config;"retry"===i?z(t,r,s?.resolveLink):s?.onEmbedAction?.(i,r)};n.addEventListener("click",a),e.eventListenersMap[t]??=[],e.eventListenersMap[t].push({element:n,event:"click",handler:a})}};async function mt(e,t){const n=C.getState().getInstance(e)?.config;if(!n?.resolveIssues||0===t.length)return{};try{const e=await n.resolveIssues([...t]),a={};for(const n of t)e[n]&&(a[n]={...e[n],url:n});return a}catch{const e={};for(const a of t){const t=pt(a,n.jiraSites);e[a]={...Oe(a,t?.tool??"",t?.key??""),reason:"provider_unreachable"}}return e}}async function gt(e,t,n,a,o,i){const r=C.getState().getInstance(e)?.config,s=Oe(o,i.tool,i.key);if(a&&"on"===r?.issueCards){const t={data:{issue:s,url:o},type:"embed"};Ds.replaceBlock(e,n,t);const a=Ds.getBlocks(e)[n]?.getAttribute("data-id");return void(a&&await async function(e,t,n){const a=(await mt(e,[n]))[n];if(!a)return;const o=Ds.getBlock(t);if(!o)return;const i=ht.save(o);Ds.updateBlockData(t,{...i,issue:{...a,url:i.url}},e)}(e,a,o))}const l=Re.insertAtCaret(s,r?.issueLabels);if(!l)return;const c=l.closest('[contenteditable="true"]');c&&Ds.saveBlockData(c),await async function(e,t,n){const a=(await mt(e,[n]))[n];if(!a||!t.isConnected)return;const o=C.getState().getInstance(e)?.config;Re.refresh(t,a,o?.issueLabels);const i=t.closest('[contenteditable="true"]');i&&Ds.saveBlockData(i)}(e,l,o)}function bt(e){const t=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".tiff",".ico"].some(e=>t.includes(e))||t.includes("data:image/")||t.includes("blob:")}function ft(e){const t=e.toLowerCase();return[".mp4",".webm",".ogg",".mov",".avi",".mkv",".flv",".wmv",".m4v"].some(e=>t.includes(e))||t.includes("data:video/")||t.includes("blob:")}function vt(e){const t=e.toLowerCase();return t.includes("youtube.com")||t.includes("youtu.be")}function yt(e){return e.toLowerCase().includes("vimeo.com")}function xt(e){const t=e.trim();if(!function(e){try{return new URL(e),!0}catch{return!1}}(t))return{isImage:!1,isUrl:!1,isVideo:!1,isVimeo:!1,isYouTube:!1,url:t};const n=vt(t),a=yt(t);return{isImage:bt(t),isUrl:!0,isVideo:ft(t)||n||a,isVimeo:a,isYouTube:n,url:t}}var kt=(e,t)=>void 0===e?.allowedBlockTools||e.allowedBlockTools.includes(t),wt=(e,t)=>{const n=xt(t);if(!n.isUrl)return null;if(n.isImage)return kt(e,"image")?{kind:"image",url:n.url}:null;if(n.isVideo)return kt(e,"video")?{isVimeo:n.isVimeo,isYouTube:n.isYouTube,kind:"video",url:n.url}:null;const a=(o=t,i=e?.jiraSites,pt(o,i));var o,i;if(a)return{issue:a,kind:"issue"};if(!kt(e,"embed"))return null;const r=function(e,t){const n=q(e,{disabledProviders:t});return"invalid"===n.provider||"link"===n.provider?null:n}(t,e?.disabledEmbedProviders);return r?{embed:r,kind:"embed"}:null},Ct=(e,t,n)=>{e.addEventListener("pointerdown",a=>{if(0!==a.button)return;const o=document.getElementById(n);if(!o)return;const i=a.clientY;let r=!1,s=!1,l=null;e.setPointerCapture?.(a.pointerId);const c=()=>{l?.remove(),l=null,t.removeAttribute("data-dragging"),e.removeEventListener("pointermove",d),e.removeEventListener("pointerup",h),e.removeEventListener("pointercancel",m),document.removeEventListener("keydown",g)},d=e=>{if(!s&&(r||!(Math.abs(e.clientY-i)<=4))){if(!r){if(Ds.getBlocks(n).length<2)return;r=!0,t.setAttribute("data-dragging","")}(e=>{const t=Ds.getBlocks(n).map(e=>e.getBoundingClientRect()),a=t.filter(t=>t.top+t.height/2<e).length,i=a<t.length?t[a]?.top??0:t[t.length-1]?.bottom??0;l||(l=p("div","clepit-drop-line",{"aria-hidden":"true"}),o.appendChild(l));const r=o.getBoundingClientRect();l.style.setProperty("--clepit-drop-line-top",`${i}px`),l.style.setProperty("--clepit-drop-line-left",`${r.left+54}px`),l.style.setProperty("--clepit-drop-line-width",`${Math.max(r.width-54,0)}px`)})(e.clientY)}},u=e=>{e.stopPropagation(),e.preventDefault()},h=e=>{const a=r&&!s;if(c(),!r)return;if(window.addEventListener("click",u,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",u,{capture:!0}),0),!(a&&(i=o.getBoundingClientRect(),l=e.clientX,d=e.clientY,l>=i.left&&l<=i.right&&d>=i.top&&d<=i.bottom)))return;var i,l,d;const p=Ds.getBlocks(n),h=Ds.getBlocks(n).indexOf(t),m=((e,t,n)=>{const a=e.filter(e=>e.top+e.height/2<t).length;return a>n?a-1:a})(p.map(e=>e.getBoundingClientRect()),e.clientY,h);h>=0&&m!==h&&Ds.moveBlock(n,h,m)},m=()=>{s=!0,c()},g=e=>{"Escape"===e.key&&r&&(s=!0,l?.remove(),l=null,t.removeAttribute("data-dragging"))};e.addEventListener("pointermove",d),e.addEventListener("pointerup",h),e.addEventListener("pointercancel",m),document.addEventListener("keydown",g)})},At="data-highlighted",St=(e,t)=>{e.forEach((e,n)=>{n===t?(e.setAttribute(At,""),e.scrollIntoView?.({block:"nearest"})):e.removeAttribute(At)})},Et="\n/* Output alert styles */\n.clepit-output-alert {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 1rem 0;\n}\n\n.clepit-output-alert--info {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-output-alert--warning {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-output-alert--error {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-output-alert--success {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-output-alert--plain {\n background: transparent;\n color: inherit;\n}\n\n.clepit-output-alert-content {\n line-height: 1.5;\n}\n\n/* Output alert link styles */\n.clepit-output-alert a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-alert a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output alert inline code styling */\n.clepit-output-alert code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output alert marker brush effect */\n.clepit-output-alert mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-alert mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n",Lt=class e{static{this.placeholder="Alert message here..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${l.classNames.block.alert}`)||e,n=t.getAttribute("data-variant")||"info";return{html:m(t.innerHTML),variant:n}}static render(t,n,a){l.injectStyles("clepit-alert-input-styles","\n/* Alert block styles */\n.clepit-alert {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 0 20px;\n}\n\n.clepit-alert[data-variant=\"info\"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-alert[data-variant=\"warning\"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-alert[data-variant=\"error\"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-alert[data-variant=\"success\"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-alert[data-variant=\"plain\"] {\n background: transparent;\n color: inherit;\n}\n\n.clepit-alert-text {\n outline: none;\n margin: 0;\n padding: 0;\n}\n\n.clepit-alert[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: rgba(0, 0, 0, 0.6);\n font-style: italic;\n pointer-events: none;\n}\n\n/* Alert link styles */\n.clepit-alert-text a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-alert-text a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Alert inline code styling */\n.clepit-alert-text code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Alert marker brush effect */\n.clepit-alert-text mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-alert-text mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o={html:"",variant:"info"},i=n?{...o,...n}:o,r=l.createStyledElement("div","clepit-alert",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});return r.setAttribute("data-variant",i.variant),r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",ne(t,"alertTextHint",e.placeholder)),r.innerHTML=m(i.html),e.addEventListener(t,r,"keydown",Ds.handleKeydown),e.addEventListener(t,r,"input",Ds.handleInput),r}static changeVariant(t,n,a){const o=C.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-variant")===n)return;const i=t.innerHTML||"",r={html:i.trim()&&"<br>"!==i.trim()?i:"",variant:n},s={classNames:o.config.classNames?.blocks?.alert,margins:o.config.margins,styles:o.config.styles?.blocks?.alert},c=Ds.getBlockIndex(a,t.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id")),d=e.render(a,r,s);t.replaceWith(d),C.getState().updateBlockData(a,c,r)}static isEmpty(e){return h(e.querySelector(`.${l.classNames.block.alert}`)?.innerHTML)}static isEmptyData(e){return h(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Nt=class e{static render(t,n,a,o){if(l.injectStyles("clepit-alert-output-styles",Et),!e.validate(t))return X();if(Lt.isEmptyData(t))return document.createElement("div");const i=t.variant,r=l.createStyledElement("div",`clepit-output-alert clepit-output-alert--${i}`,{classNames:o?.[i],styles:a?.[i]});return r.innerHTML=m(t.html),r}static draw(t,n=R){if(!e.validate(t)||Lt.isEmptyData(t))return null;const a=n.create("div");return a.addClass("clepit-output-alert",`clepit-output-alert--${t.variant}`),t.html&&a.setHtml(t.html),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"variant"in e&&"html"in e&&"string"==typeof e.html}},Bt='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M17 7h-3c-.55 0-1 .45-1 1s.45 1 1 1h3c1.65 0 3 1.35 3 3s-1.35 3-3 3h-3c-.55 0-1 .45-1 1s.45 1 1 1h3c2.76 0 5-2.24 5-5s-2.24-5-5-5m-9 5c0 .55.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1H9c-.55 0-1 .45-1 1m2 3H7c-1.65 0-3-1.35-3-3s1.35-3 3-3h3c.55 0 1-.45 1-1s-.45-1-1-1H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h3c.55 0 1-.45 1-1s-.45-1-1-1"></path></svg>',Mt='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"></path></svg>',$t='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M4 11h16v2H4z" fill-rule="evenodd"></path></svg>',It={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M4.47 21h15.06c1.54 0 2.5-1.67 1.73-3L13.73 4.99c-.77-1.33-2.69-1.33-3.46 0L2.74 18c-.77 1.33.19 3 1.73 3M12 14c-.55 0-1-.45-1-1v-2c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1m1 4h-2v-2h2z"></path></svg>',get input(){return Lt},label:"Alert",get output(){return Nt},testId:"block-type-alert",type:"alert"},Tt=`\n/* Audio block styles */\n.clepit-audio-container {\n margin: 0 16px;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 96%;\n box-sizing: border-box;\n}\n\n.${l.classNames.block.audio.wrapper} {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.clepit-audio {\n width: 100%;\n}\n\n.align-left {\n justify-content: flex-start;\n}\n\n.align-center {\n justify-content: center;\n}\n\n.align-right {\n justify-content: flex-end;\n}\n\n.${l.classNames.block.audio.wrapper}:hover {\n opacity: 0.9;\n}\n\n.clepit-audio-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-audio-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-audio-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-audio-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Audio caption styling */\n.clepit-audio-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Audio caption placeholder styles */\n.clepit-audio-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Audio Drop Area */\n.clepit-audio-drop-area {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n}\n\n.clepit-audio-drop-area:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-audio-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-audio-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-audio-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n margin-bottom: 8px;\n}\n\n.clepit-audio-drop-subtext {\n font-size: 14px;\n color: var(--clepit-text-subtle);\n line-height: 1.4;\n}\n\n.clepit-audio-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Audio Loading State */\n.clepit-audio-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-audio-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-audio-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Audio Error State */\n.clepit-audio-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-audio-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-audio-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-audio-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-audio-error-retry:hover {\n background: var(--clepit-error);\n}\n\n/* Audio delete button */\n.${l.classNames.block.audioDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${l.classNames.block.audioDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Audio drop area delete button */\n.clepit-audio-drop-area .${l.classNames.block.audioDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-audio-drop-area .${l.classNames.block.audioDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,_t="\n/* Output audio styles */\n.clepit-output-audio-container {\n width: 100%;\n margin: 1rem 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: flex-start;\n}\n\n.clepit-output-audio-wrapper {\n width: 100%;\n display: flex;\n}\n\n.clepit-output-audio {\n width: 100%;\n}\n\n\n.clepit-output-audio-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Output audio alignment */\n.clepit-output-audio-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-output-audio-wrapper--center {\n justify-content: center;\n}\n\n.clepit-output-audio-wrapper--right {\n justify-content: flex-end;\n}\n",qt=class e{static{this.placeholder="Add a caption..."}static{this.eventListenersMap={}}static{this.validTypes=["audio/mp3","audio/wav","audio/ogg","audio/mpeg","audio/mp4","audio/webm"]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("audio"),n=e.querySelector(`.${l.classNames.block.audio.captionEditable}`),a=e.querySelector(`.${l.classNames.block.audio.wrapper}`);let o="center";return a&&(o=a.classList.contains("align-left")?"left":a.classList.contains("align-right")?"right":"center"),{alignment:o,alt:t&&t.getAttribute("alt")||"",caption:m(n?.innerHTML),url:t&&t.getAttribute("src")||""}}static render(t,n,a,o){l.injectStyles("clepit-audio-input-styles",Tt);const i=a||{alt:"",caption:"",url:""},r=l.createStyledElement("div",l.classNames.block.audio.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return i.url?e.renderAudio(r,i,t,n,o):e.renderDropArea(r,t,n,o),r}static renderAudio(t,n,a,o,i){if(!document.getElementById(o))return;t.innerHTML="";const r=l.createStyledElement("div",l.classNames.block.audio.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("align-left");break;case"center":r.classList.add("align-center");break;case"right":r.classList.add("align-right")}const s=l.createStyledElement("audio","clepit-audio",{classNames:i?.classNames?.container,styles:i?.styles?.container});s.src=n.url,s.controls=!0,s.preload="metadata",n.alt&&s.setAttribute("alt",n.alt);const c=l.createStyledElement("div","clepit-audio-caption-container",{classNames:i?.classNames?.container,styles:i?.styles?.container});c.classList.add("clepit-audio-caption-container");const d=l.createStyledElement("div","clepit-audio-caption-editable",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});d.setAttribute("contenteditable","true"),d.setAttribute("data-placeholder",ne(o,"mediaCaptionHint",e.placeholder)),d.innerHTML=m(n.caption),e.addEventListener(o,d,"keydown",Ds.handleKeydown),e.addEventListener(o,d,"input",Ds.handleInput),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),r.appendChild(s),c.appendChild(d),t.appendChild(r),t.appendChild(c),d.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const i=l.createStyledElement("div",l.classNames.block.audio.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});i.setAttribute("tabindex","0"),i.classList.add("clepit-drop-area");const r=l.createStyledElement("div","clepit-audio-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});r.textContent="♪";const s=l.createStyledElement("div","clepit-audio-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text});s.innerHTML='<strong>Drop an audio file here</strong><br>or <span class="clepit-audio-click-text">click to select</span>';const c=l.createStyledElement("div","clepit-audio-drop-subtext",{classNames:o?.classNames?.dropArea?.subtext,styles:o?.styles?.dropArea?.subtext});c.textContent="Supports MP3, WAV, OGG, and other audio formats";const d=l.createStyledElement("button",`${l.classNames.block.audioDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});d.type="button",d.textContent="✕",i.appendChild(r),i.appendChild(s),i.appendChild(c),i.appendChild(d);const p=a?C.getState().getInstance(a):null,u=p?.config.classNames?.tooltips,h=p?.config.styles?.tooltips;ke(d,"Delete block","below",u,h),e.addEventListener(a,d,"click",e=>{e.preventDefault(),e.stopPropagation();const t=d.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");t&&Ds.removeBlock(a,Ds.getBlockIndex(a,t))}),e.addEventListener(a,i,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,i,"dragleave",()=>{i.classList.remove("clepit-audio-drop-area--dragover")}),e.addEventListener(a,i,"dragover",e=>{e.preventDefault(),e.stopPropagation(),i.classList.add("clepit-audio-drop-area--dragover")}),e.addEventListener(a,i,"drop",r=>{r.preventDefault(),r.stopPropagation(),i.classList.remove("clepit-audio-drop-area--dragover"),e.handleFileDrop(r,t,n,a,o)}),e.addEventListener(a,i,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,i,"mousedown",e=>{e.preventDefault(),e.stopPropagation()}),t.appendChild(i)}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="audio/*",i.style.display="none",i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidAudioFile(i)?e.processAudioFile(i,t,n,a,o):e.showError(t,"Please select a valid audio file (MP3, WAV, OGG)")}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidAudioFile(t)?e.processAudioFile(t,n,a,o,i):e.showError(n,"Please select a valid audio file (MP3, WAV, OGG)")}}static isValidAudioFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("audio/")}static async processAudioFile(t,n,a,o,i){e.showLoading(n);try{let r=await a(t);if(r){e.renderAudio(n,{alignment:"center",alt:t.name,caption:"",url:r},a,o,i);const s=n.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");s&&C.getState().updateBlockData(o,Ds.getBlockIndex(o,s),Ds.getBlockData(s).data)}else e.showError(n,"Failed to upload audio. Please try again.")}catch(r){console.error("Audio upload error:",r),e.showError(n,"Failed to upload audio. Please try again.")}}static showLoading(e){e.innerHTML="";const t=l.createStyledElement("div","clepit-audio-loading",void 0);t.textContent="Uploading audio...",e.appendChild(t)}static showError(e,t){e.innerHTML="";const n=l.createStyledElement("div","clepit-audio-error",void 0);n.textContent=t,e.appendChild(n)}static setAlignment(e,t){const n=e.querySelector(".clepit-audio-wrapper");n&&(n.classList.remove("align-left","align-center","align-right"),n.classList.add(`align-${t}`));const a=Ds.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&C.getState().partialUpdateBlockData(a,Ds.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${l.classNames.block.audio.wrapper} audio`),n=e.querySelector(`.${l.classNames.block.audio.captionEditable}`);let a=!1,o=!1;return t&&t.getAttribute("src")?.trim()||(a=!0),n?h(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return!e.url?.trim()&&h(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Dt=class e{static render(t,n,a,o){if(l.injectStyles("clepit-audio-output-styles",_t),!e.validate(t))return X();if(qt.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alignment||"center",c=l.createStyledElement("div","clepit-output-audio-container",{classNames:o?.container,styles:a?.container}),d=l.createStyledElement("div","clepit-output-audio-wrapper");switch(s){case"left":d.classList.add("clepit-output-audio-wrapper--left");break;case"center":d.classList.add("clepit-output-audio-wrapper--center");break;case"right":d.classList.add("clepit-output-audio-wrapper--right")}const u=p("audio","clepit-output-audio");if(u.src=i,u.controls=!0,u.preload="metadata",t.alt&&u.setAttribute("alt",t.alt),d.appendChild(u),c.appendChild(d),r){const e=l.createStyledElement("figcaption","clepit-output-audio-caption",{classNames:o?.caption,styles:a?.caption});e.innerHTML=m(r),c.appendChild(e)}if(a&&(a.container&&Object.assign(c.style,a.container),a.caption)){const e=c.querySelector(".clepit-output-audio-caption");e&&Object.assign(e.style,a.caption)}if(o&&(o.container&&c.classList.add(o.container),o.caption)){const e=c.querySelector(".clepit-output-audio-caption");e&&e.classList.add(o.caption)}return c}static draw(t,n=R){if(!e.validate(t)||qt.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-audio-container");const o=n.create("div");o.addClass("clepit-output-audio-wrapper");const i=t.alignment??"center";i&&o.addClass(`clepit-output-audio-wrapper--${i}`);const r=n.create("audio");if(r.addClass("clepit-output-audio"),r.setAttribute("src",t.url),r.setAttribute("controls","controls"),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-audio-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},zt={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 5v8.55c-.94-.54-2.1-.75-3.33-.32-1.34.48-2.37 1.67-2.61 3.07-.46 2.74 1.86 5.08 4.59 4.65 1.96-.31 3.35-2.11 3.35-4.1V7h2c1.1 0 2-.9 2-2s-.9-2-2-2h-2c-1.1 0-2 .9-2 2z"></path></svg>',get input(){return qt},label:"Audio",get output(){return Dt},section:"media",testId:"block-type-audio",type:"audio"},jt=`\n/* Checklist input block styles */\n.${l.classNames.block.checklist.container} {\n margin: 0;\n padding: 0 20px;\n}\n\n.${l.classNames.block.checklist.item} {\n --text: var(--clepit-text);\n --check: var(--clepit-primary);\n --disabled: var(--clepit-text-muted);\n --border-radius: 10px;\n border-radius: var(--border-radius);\n position: relative;\n padding: 5px;\n display: grid;\n grid-template-columns: 30px auto;\n align-items: center;\n margin: 4px 0;\n}\n\n.${l.classNames.block.checklist.text} {\n color: var(--text);\n position: relative;\n cursor: pointer;\n display: grid;\n align-items: center;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n transition: color 0.3s ease;\n outline: none;\n min-height: 1.2em;\n line-height: 1.6;\n padding: 0;\n margin: 0;\n}\n\n.${l.classNames.block.checklist.text}::before,\n.${l.classNames.block.checklist.text}::after {\n content: "";\n position: absolute;\n}\n\n.${l.classNames.block.checklist.text}::before {\n height: 2px;\n width: 8px;\n left: -27px;\n background: var(--check);\n border-radius: 2px;\n transition: background 0.3s ease;\n}\n\n.${l.classNames.block.checklist.text}::after {\n height: 4px;\n width: 4px;\n top: 8px;\n left: -25px;\n border-radius: 50%;\n}\n\n.${l.classNames.block.checklist.checkbox} {\n -webkit-appearance: none;\n -moz-appearance: none;\n position: relative;\n height: 15px;\n width: 15px;\n outline: none;\n border: 0;\n margin: 0 15px 0 0;\n cursor: pointer;\n background: var(--background);\n display: grid;\n align-items: center;\n}\n\n.${l.classNames.block.checklist.checkbox}::before,\n.${l.classNames.block.checklist.checkbox}::after {\n content: "";\n position: absolute;\n height: 2px;\n top: auto;\n background: var(--check);\n border-radius: 2px;\n}\n\n.${l.classNames.block.checklist.checkbox}::before {\n width: 0px;\n right: 60%;\n transform-origin: right bottom;\n}\n\n.${l.classNames.block.checklist.checkbox}::after {\n width: 0px;\n left: 40%;\n transform-origin: left bottom;\n}\n\n.${l.classNames.block.checklist.checkbox}:checked::before {\n -webkit-animation: clepit-check-01-11 0.4s ease forwards;\n animation: clepit-check-01-11 0.4s ease forwards;\n}\n\n.${l.classNames.block.checklist.checkbox}:checked::after {\n -webkit-animation: clepit-check-02-11 0.4s ease forwards;\n animation: clepit-check-02-11 0.4s ease forwards;\n}\n\n.${l.classNames.block.checklist.checkbox}:checked + .${l.classNames.block.checklist.text} {\n color: var(--disabled);\n -webkit-animation: clepit-move-11 0.3s ease 0.1s forwards;\n animation: clepit-move-11 0.3s ease 0.1s forwards;\n}\n\n.${l.classNames.block.checklist.checkbox}:checked + .${l.classNames.block.checklist.text}::before {\n background: var(--disabled);\n -webkit-animation: clepit-slice-11 0.4s ease forwards;\n animation: clepit-slice-11 0.4s ease forwards;\n}\n\n.${l.classNames.block.checklist.checkbox}:checked + .${l.classNames.block.checklist.text}::after {\n -webkit-animation: clepit-firework-11 0.5s ease forwards 0.1s;\n animation: clepit-firework-11 0.5s ease forwards 0.1s;\n}\n\n.${l.classNames.block.checklist.text}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Checklist input link styles */\n.${l.classNames.block.checklist.text} a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.${l.classNames.block.checklist.text} a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n@-webkit-keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@-webkit-keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@-webkit-keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@-webkit-keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@-webkit-keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n\n@keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n`,Ht='\n/* Checklist output block styles */\n.clepit-output-checklist {\n margin: 0 0 1rem 0;\n padding-left: 0;\n}\n\n.clepit-output-checklist-item {\n --text: var(--clepit-text);\n --check: var(--clepit-primary);\n --disabled: var(--clepit-text-muted);\n --border-radius: 10px;\n border-radius: var(--border-radius);\n position: relative;\n padding: 5px;\n display: grid;\n grid-template-columns: 30px auto;\n align-items: center;\n margin: 0.5rem 0;\n line-height: 1.6;\n}\n\n.clepit-output-checklist-text {\n color: var(--text);\n position: relative;\n cursor: pointer;\n display: grid;\n align-items: center;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n transition: color 0.3s ease;\n line-height: 1.6;\n}\n\n.clepit-output-checklist-text::before,\n.clepit-output-checklist-text::after {\n content: "";\n position: absolute;\n}\n\n.clepit-output-checklist-text::before {\n height: 2px;\n width: 8px;\n left: -27px;\n background: var(--check);\n border-radius: 2px;\n transition: background 0.3s ease;\n}\n\n.clepit-output-checklist-text::after {\n height: 4px;\n width: 4px;\n top: 8px;\n left: -25px;\n border-radius: 50%;\n}\n\n.clepit-output-checklist-checkbox {\n -webkit-appearance: none;\n -moz-appearance: none;\n position: relative;\n height: 15px;\n width: 15px;\n outline: none;\n border: 0;\n margin: 0 15px 0 0;\n cursor: pointer;\n background: var(--background);\n display: grid;\n align-items: center;\n pointer-events: none;\n}\n\n.clepit-output-checklist-checkbox::before,\n.clepit-output-checklist-checkbox::after {\n content: "";\n position: absolute;\n height: 2px;\n top: auto;\n background: var(--check);\n border-radius: 2px;\n}\n\n.clepit-output-checklist-checkbox::before {\n width: 0px;\n right: 60%;\n transform-origin: right bottom;\n}\n\n.clepit-output-checklist-checkbox::after {\n width: 0px;\n left: 40%;\n transform-origin: left bottom;\n}\n\n.clepit-output-checklist-checkbox:checked::before {\n -webkit-animation: clepit-check-01-11 0.4s ease forwards;\n animation: clepit-check-01-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked::after {\n -webkit-animation: clepit-check-02-11 0.4s ease forwards;\n animation: clepit-check-02-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text {\n color: var(--disabled);\n -webkit-animation: clepit-move-11 0.3s ease 0.1s forwards;\n animation: clepit-move-11 0.3s ease 0.1s forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text::before {\n background: var(--disabled);\n -webkit-animation: clepit-slice-11 0.4s ease forwards;\n animation: clepit-slice-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text::after {\n -webkit-animation: clepit-firework-11 0.5s ease forwards 0.1s;\n animation: clepit-firework-11 0.5s ease forwards 0.1s;\n}\n\n@-webkit-keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@-webkit-keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@-webkit-keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@-webkit-keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@-webkit-keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n\n@keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n',Ot=class e{static{this.placeholder="Add checklist item..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=[];return e.querySelectorAll(`.${l.classNames.block.checklist.item}`).forEach(e=>{const n=e.querySelector('input[type="checkbox"]'),a=e.querySelector(`.${l.classNames.block.checklist.text}`);n&&a&&t.push({checked:n.checked,text:m(a.innerHTML)})}),{items:t}}static render(t,n,a){l.injectStyles("clepit-checklist-input-styles",jt);const o={items:[]},i=n?{...o,...n}:o,r=l.createStyledElement("div",l.classNames.block.checklist.container,{classNames:a?.classNames?.container,styles:a?.styles?.container});return i.items.length>0?i.items.forEach(n=>e.createAndAppendChecklistItem(n,r,t,a)):e.createAndAppendChecklistItem({checked:!1,text:""},r,t,a),r}static createAndAppendChecklistItem(t,n,a,o){const i=l.createStyledElement("div",l.classNames.block.checklist.item,{classNames:o?.classNames?.item,styles:o?.styles?.item}),r=l.createStyledElement("input",l.classNames.block.checklist.checkbox,{classNames:o?.classNames?.checkbox,styles:o?.styles?.checkbox});r.type="checkbox",r.checked=t.checked;const s=l.createStyledElement("div",l.classNames.block.checklist.text,{classNames:o?.classNames?.text,styles:o?.styles?.text});s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",ne(a,"checklistItemHint",e.placeholder)),s.innerHTML=m(t.text?.trim()),e.addEventListener(a,r,"change",()=>Ds.saveBlockData(r)),e.addEventListener(a,s,"keydown",t=>{const r=t,c=n.closest(`.${l.classNames.block.container}`);if(!c)return;const d=Ds.getBlockIndex(a,c.getAttribute("data-id")),p=r.metaKey||r.ctrlKey;if(r.shiftKey)switch(r.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),d>0&&Ds.moveBlock(a,d,d-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const e=Ds.getBlocks(a);e&&d<e.length-1&&Ds.moveBlock(a,d,d+1)}else if(p)switch(r.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),Ds.removeBlock(a,d)}else if("Enter"===r.key)if(t.preventDefault(),t.stopPropagation(),h(s.innerHTML)){e.cleanupEmptyItems(n);const t=n.closest(`.${l.classNames.block.container}`);if(!t)return;const o=Ds.getBlockIndex(a,t.getAttribute("data-id"));Ds.insertBlock({data:{html:""},type:"paragraph"},a,o+1)}else e.createAndAppendChecklistItem({checked:!1,text:""},n,a,o);else if("Backspace"===r.key){if(h(s.innerHTML)){t.preventDefault(),t.stopPropagation();const e=Array.from(n.querySelectorAll(`.${l.classNames.block.checklist.item}`)),o=e.indexOf(i);if(1===e.length){const e=n.closest(`.${l.classNames.block.container}`);if(!e)return;const t=Ds.getBlockIndex(a,e.getAttribute("data-id"));if(-1===t)return;Ds.removeBlock(a,t)}else i.remove(),o>0?e[o-1].querySelector(".clepit-checklist-text")?.focus():e[o+1].querySelector(".clepit-checklist-text")?.focus()}}else{Ds.ensureActiveBlock(a);const e=Ds.getBlocks(a);switch(r.key){case"ArrowUp":t.preventDefault(),t.stopPropagation();const a=Array.from(n.querySelectorAll(`.${l.classNames.block.checklist.item}`)),o=a.indexOf(i);if(0===o){if(d>0){const t=e[d-1];t&&Ds.focusBlock(t)}}else{const e=a[o-1].querySelector(`.${l.classNames.block.checklist.text}`);e&&e.focus()}return;case"ArrowDown":t.preventDefault(),t.stopPropagation();const r=Array.from(n.querySelectorAll(`.${l.classNames.block.checklist.item}`)),s=r.indexOf(i);if(s===r.length-1){if(d<e.length-1){const t=e[d+1];t&&Ds.focusBlock(t)}}else{const e=r[s+1].querySelector(`.${l.classNames.block.checklist.text}`);e&&e.focus()}return}}}),e.addEventListener(a,s,"input",Ds.handleInput),i.appendChild(r),i.appendChild(s),n.appendChild(i),s.focus()}static cleanupEmptyItems(e){const t=Array.from(e.querySelectorAll(`.${l.classNames.block.checklist.item}`)),n=t.filter(e=>h(e.querySelector(`.${l.classNames.block.checklist.text}`)?.innerHTML||""));if(t.length===n.length){if(t.length<2)return;for(let e=1;e<n.length;e++)n[e].remove()}else n.forEach(e=>e.remove())}static isEmpty(e){const t=e.querySelectorAll(`.${l.classNames.block.checklist.item}`);return!t||Array.from(t).every(e=>h(e.querySelector(`.${l.classNames.block.checklist.text}`)?.innerHTML))}static isEmptyData(e){return 0===e.items.length||e.items.every(e=>h(e.text))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Pt=class e{static render(t,n,a,o){if(l.injectStyles("clepit-checklist-output-styles",Ht),!e.validate(t))return X();if(Ot.isEmptyData(t))return document.createElement("div");const i=t.items,r=l.createStyledElement("div","clepit-output-checklist",{classNames:o?.container,styles:a?.container});return i.forEach((e,t)=>{const n=l.createStyledElement("div","clepit-output-checklist-item",{classNames:o?.item,styles:a?.item}),i=l.createStyledElement("input","clepit-output-checklist-checkbox",{classNames:o?.checkbox,styles:a?.checkbox});i.type="checkbox",i.checked=e.checked,i.setAttribute("readonly","true");const s=l.createStyledElement("div","clepit-output-checklist-text",{classNames:o?.text,styles:a?.text});s.innerHTML=m(e.text),i.checked&&n.classList.add("checked"),n.appendChild(i),n.appendChild(s),r.appendChild(n)}),r}static draw(t,n=R){if(!e.validate(t)||Ot.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-checklist");for(const e of t.items){const t=n.create("div");t.addClass("clepit-output-checklist-item");const o=n.create("input");o.addClass("clepit-output-checklist-checkbox"),o.setAttribute("type","checkbox"),e.checked&&o.setAttribute("checked","checked"),o.setAttribute("readonly","true"),t.append(o);const i=n.create("div");i.addClass("clepit-output-checklist-text"),e.text?.trim()&&i.setHtml(e.text),t.append(i),a.append(t)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.items)}},Rt={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2m-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"></path></svg>',get input(){return Ot},label:"Checklist",get output(){return Pt},testId:"block-type-checklist",type:"checklist"},Ft={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M8.7 15.9 4.8 12l3.9-3.9c.39-.39.39-1.01 0-1.4a.984.984 0 0 0-1.4 0l-4.59 4.59c-.39.39-.39 1.02 0 1.41l4.59 4.6c.39.39 1.01.39 1.4 0s.39-1.01 0-1.4m6.6 0 3.9-3.9-3.9-3.9a.984.984 0 0 1 0-1.4c.39-.39 1.01-.39 1.4 0l4.59 4.59c.39.39.39 1.02 0 1.41l-4.59 4.6c-.39.39-1.01.39-1.4 0a.984.984 0 0 1 0-1.4"></path></svg>',get input(){return ge},label:"Code",get output(){return Se},section:"media",testId:"block-type-code",type:"code"},Vt="\n.clepit-collapsible {\n display: block;\n}\n.clepit-collapsible > summary {\n display: flex;\n align-items: flex-start;\n gap: 6px;\n cursor: pointer;\n font-weight: 600;\n list-style: none;\n}\n.clepit-collapsible > summary::-webkit-details-marker {\n display: none;\n}\n.clepit-collapsible > summary::before {\n content: '';\n flex: 0 0 auto;\n width: 8px;\n height: 8px;\n margin-top: 7px;\n border-right: 2px solid currentColor;\n border-bottom: 2px solid currentColor;\n transform: rotate(-45deg);\n transition: transform 120ms ease;\n}\n.clepit-collapsible[open] > summary::before {\n transform: rotate(45deg);\n}\n.clepit-collapsible__children {\n padding-left: 22px;\n}\n.clepit-collapsible__children > * + * {\n margin-top: 8px;\n}\n",Ut=`${Vt}\n.clepit-collapsible__title-input {\n border: none;\n outline: none;\n background: transparent;\n font: inherit;\n font-weight: 600;\n width: 100%;\n}\n.clepit-collapsible__add-child {\n border: none;\n background: transparent;\n cursor: pointer;\n font: inherit;\n opacity: 0.6;\n padding: 4px 0;\n}\n.clepit-collapsible__add-child:hover {\n opacity: 1;\n}\n.clepit-collapsible__child-row {\n display: flex;\n align-items: flex-start;\n gap: 4px;\n}\n.clepit-collapsible__child-row > :first-child {\n flex: 1 1 auto;\n}\n.clepit-collapsible__remove-child {\n border: none;\n background: transparent;\n cursor: pointer;\n opacity: 0.4;\n padding: 2px;\n}\n.clepit-collapsible__remove-child:hover {\n opacity: 1;\n}\n`,Wt=Vt,Kt=/* @__PURE__ */new WeakMap;var Gt=class e{static{this.placeholder="Section title"}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.classList.contains("clepit-collapsible")?e:e.querySelector(".clepit-collapsible");if(!t)return{children:[],html:"",open:!1};const n=t.querySelector(".clepit-collapsible__title"),a=t.open??!1,o=Kt.get(t)??[],i=[];return t.querySelectorAll(".clepit-collapsible__child").forEach((e,t)=>{const n=o[t],a=e.getAttribute("data-child-type")??n?.type,r=a?function(e){return Lr.find(t=>t.type===e)}(a):void 0;if(r){const t=r.input.save(e);i.push({...n?.id?{id:n.id}:{},data:t,type:r.type})}else n&&i.push(n)}),{children:i,html:m(n?.innerHTML),open:a}}static render(t,n,a){l.injectStyles("collapsible-input",Ut);const o={children:[],html:"",open:!0},i=n?{...o,...n}:o,r=l.createStyledElement("details","clepit-collapsible clepit-collapsible--input",{classNames:a?.classNames?.section,styles:a?.styles?.section});r.open=i.open??!0,Kt.set(r,[...i.children??[]]);const s=document.createElement("summary"),c=document.createElement("span");c.className="clepit-collapsible__title",c.setAttribute("contenteditable","true"),c.setAttribute("data-placeholder",ne(t,"collapsibleTitleHint",e.placeholder)),i.html&&(c.innerHTML=m(i.html)),s.appendChild(c),r.appendChild(s);const d=document.createElement("div");return d.className="clepit-collapsible__children",(i.children??[]).forEach(n=>{d.appendChild(e.renderChild(t,n))}),r.appendChild(d),e.addEventListener(t,c,"keydown",Ds.handleKeydown),e.addEventListener(t,c,"input",Ds.handleInput),r}static renderChild(e,t){const n=document.createElement("div");n.className="clepit-collapsible__child";const a=Ds.renderTool(t.type,t.data,e);if(a)n.setAttribute("data-child-type",t.type),n.appendChild(a);else{const e=document.createElement("div");e.className="clepit-collapsible__unknown-child",e.textContent=`Unsupported block: ${t.type}`,n.appendChild(e)}return n}static isEmpty(e){const t=e.querySelector(".clepit-collapsible");if(!t)return!0;const n=t.querySelector(".clepit-collapsible__title"),a=t.querySelectorAll(".clepit-collapsible__child").length>0;return h(n?.innerHTML)&&!a}static isEmptyData(e){return h(e.html)&&0===(e.children??[]).length}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Jt="\n.clepit-collection {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n color: inherit;\n}\n.clepit-collection__icon {\n font-size: 18px;\n line-height: 1;\n}\n.clepit-collection__label {\n opacity: 0.7;\n}\n",Xt=Jt,Yt=Jt,Zt=class e{static render(t,n,a,o){if(l.injectStyles("collection-output",Yt),!e.validate(t))return X();const i=l.createStyledElement("div","clepit-collection clepit-output-collection",{classNames:o?.wrapper,styles:a?.wrapper});i.setAttribute("data-collection-id",t.collectionId);const r=document.createElement("span");r.className="clepit-collection__icon",r.textContent="▦",i.appendChild(r);const s=document.createElement("span");return s.className="clepit-collection__label",s.textContent="Collection",i.appendChild(s),i}static draw(t,n=R){if(!e.validate(t))return null;const a=n.create("div");a.addClass("clepit-collection","clepit-output-collection"),a.setAttribute("data-collection-id",t.collectionId);const o=n.create("span");o.addClass("clepit-collection__icon"),o.setText("▦"),a.append(o);const i=n.create("span");return i.addClass("clepit-collection__label"),i.setText("Collection"),a.append(i),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.collectionId&&e.collectionId.length>0}},Qt="\n.clepit-columns {\n display: flex;\n gap: 16px;\n align-items: flex-start;\n}\n.clepit-columns__column {\n flex: 1 1 0;\n min-width: 0;\n}\n.clepit-columns__column > * + * {\n margin-top: 8px;\n}\n@media (max-width: 640px) {\n .clepit-columns {\n flex-direction: column;\n }\n}\n",en=`${Qt}\n.clepit-columns__add-child,\n.clepit-columns__add-column {\n border: none;\n background: transparent;\n cursor: pointer;\n font: inherit;\n opacity: 0.6;\n padding: 4px 0;\n}\n.clepit-columns__add-child:hover,\n.clepit-columns__add-column:hover {\n opacity: 1;\n}\n`,tn=Qt,nn=class e{static render(t,n,a,o){if(l.injectStyles("columns-output",tn),!e.validate(t))return X();const i=l.createStyledElement("div","clepit-columns clepit-output-columns",{classNames:o?.container,styles:a?.container});for(const r of t.columns){const t=l.createStyledElement("div","clepit-columns__column",{classNames:o?.column,styles:a?.column});for(const a of r)t.appendChild(e.renderChild(a,n));i.appendChild(t)}return i}static renderChild(e,t){const n=Lr.find(t=>t.type===e.type);if(!n){const t=document.createElement("div");return t.className="clepit-columns__unknown-child",t.textContent=`Unsupported block: ${e.type}`,t}return n.output.render(e.data,t)}static draw(t,n=R,a){if(!e.validate(t))return null;const o=n.create("div");o.addClass("clepit-columns","clepit-output-columns");for(const e of t.columns){const t=n.create("div");t.addClass("clepit-columns__column");for(const o of e){const e=Bi(o,n,a);e&&t.append(e)}o.append(t)}return o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.columns)&&e.columns.length>=2&&e.columns.length<=4&&e.columns.every(e=>Array.isArray(e))}},an="\n.clepit-date {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 2px 8px;\n border-radius: 6px;\n background: rgba(127, 127, 127, 0.12);\n font-variant-numeric: tabular-nums;\n}\n",on=`${an}\n.clepit-date--input {\n cursor: pointer;\n border: none;\n font: inherit;\n}\n`,rn=an,sn=/^(\d{4})-(\d{2})-(\d{2})$/;function ln(e){const t=sn.exec(e.trim());if(!t)return null;const n=Number(t[1]),a=Number(t[2]),o=Number(t[3]),i=new Date(Date.UTC(n,a-1,o));return i.getUTCFullYear()!==n||i.getUTCMonth()!==a-1||i.getUTCDate()!==o?null:i}var cn=class e{static render(t,n,a,o){l.injectStyles("date-output",rn);const i=e.validate(t)?ln(t.date):null;if(!i)return X();const r=l.createStyledElement("time","clepit-date clepit-output-date",{classNames:o?.pill,styles:a?.pill});return r.dateTime=t.date,r.textContent=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}).format(i),r}static draw(t,n=R){const a=e.validate(t)?ln(t.date):null;if(!a)return null;const o=n.create("time");return o.addClass("clepit-date","clepit-output-date"),o.setAttribute("datetime",t.date),o.setText(new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}).format(a)),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.date}},dn='\n/* Output delimiter styles */\n.clepit-output-delimiter {\n margin: 2rem 0;\n text-align: center;\n}\n\n.clepit-output-delimiter[data-variant="stars"] {\n font-size: 1.5rem;\n font-weight: 300;\n letter-spacing: 8px;\n margin: 0; /* Remove margin for star variant */\n}\n\n.clepit-output-delimiter hr[data-variant="line"] {\n border: none;\n height: 2px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 20px 0;\n}\n\n.clepit-output-delimiter[data-variant="line"] {\n margin: 0; /* Remove container margin for line variant */\n}\n',pn=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{variant:e.querySelector(".clepit-delimiter")?.getAttribute("data-variant")||"line"}}static render(t,n,a){l.injectStyles("clepit-delimiter-input-styles",'\n/* Delimiter block styles */\n.clepit-delimiter-container {\n margin: 0.5rem 0;\n text-align: center;\n}\n\n.clepit-delimiter {\n border: none;\n height: 2px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 20px 0;\n}\n\n.clepit-delimiter[data-variant="stars"] {\n height: auto;\n background: none;\n font-size: 24px;\n letter-spacing: 8px;\n margin: 0; /* Remove margin for star variant */\n}\n\n');const o={variant:"line"},i=n?{...o,...n}:o,r=l.createStyledElement("div","clepit-delimiter-container",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});if(r.setAttribute("contenteditable","true"),r.setAttribute("tabindex","0"),"stars"===i.variant){const e=l.createStyledElement("div","clepit-delimiter",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});e.setAttribute("data-variant",i.variant),e.textContent="***",r.appendChild(e)}else{const e=l.createStyledElement("hr","clepit-delimiter",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});e.setAttribute("data-variant",i.variant),r.appendChild(e)}return e.addEventListener(t,r,"keydown",e=>{const n=e,a=r.closest(`.${l.classNames.block.container}`);if(!a)return;const o=Ds.getBlockIndex(t,a.getAttribute("data-id")),i=n.metaKey||n.ctrlKey;if(n.shiftKey)switch(n.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),o>0&&Ds.moveBlock(t,o,o-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const n=Ds.getBlocks(t);n&&o<n.length-1&&Ds.moveBlock(t,o,o+1)}else if(i)switch(n.key){case"Delete":case"Backspace":e.preventDefault(),e.stopPropagation(),Ds.removeBlock(t,o)}else if("Enter"===n.key)n.preventDefault(),n.stopPropagation(),Ds.insertBlock({data:{html:""},type:"paragraph"},t,o+1);else if("Backspace"===n.key)n.preventDefault(),n.stopPropagation(),Ds.removeBlock(t,o);else{Ds.ensureActiveBlock(t);const a=Ds.getBlocks(t);switch(n.key){case"ArrowUp":if(e.preventDefault(),e.stopPropagation(),o>0){const e=a[o-1];e&&Ds.focusBlock(e)}return;case"ArrowDown":if(e.preventDefault(),e.stopPropagation(),o<a.length-1){const e=a[o+1];e&&Ds.focusBlock(e)}return}}}),r.focus(),r}static changeVariant(t,n,a){const o=C.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-variant")===n)return;const i={variant:n},r={classNames:o.config.classNames?.blocks?.delimiter,styles:o.config.styles?.blocks?.delimiter},s=Ds.getBlockIndex(a,t.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id")),c=e.render(a,i,r);t.replaceWith(c),C.getState().updateBlockData(a,s,i)}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},un=class e{static render(t,n,a,o){if(l.injectStyles("clepit-delimiter-output-styles",dn),!e.validate(t))return X();if(pn.isEmptyData(t))return document.createElement("div");const i=t.variant,r=l.createStyledElement("div","clepit-output-delimiter",{classNames:o?.[i],styles:a?.[i]});if("stars"===i)r.innerHTML="***",r.setAttribute("data-variant","stars");else{const e=document.createElement("hr");e.setAttribute("data-variant","line"),e.className="clepit-delimiter",r.appendChild(e)}return r}static draw(t,n=R){if(!e.validate(t)||pn.isEmptyData(t))return null;const a=n.create("div");if(a.addClass("clepit-output-delimiter"),"stars"===t.variant)return a.setHtml("***"),a.setAttribute("data-variant","stars"),a;const o=n.create("hr");return o.setAttribute("data-variant","line"),o.addClass("clepit-delimiter"),a.append(o),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.variant}},hn="\n.clepit-doc-card {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n cursor: pointer;\n color: inherit;\n text-decoration: none;\n}\n.clepit-doc-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-doc-card__icon {\n font-size: 20px;\n line-height: 1;\n}\n.clepit-doc-card__title {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-doc-card__description {\n opacity: 0.7;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n",mn=hn,gn=hn,bn=class e{static render(t,n,a,o){if(l.injectStyles("doc-card-output",gn),!e.validate(t))return X();const i=l.createStyledElement("a","clepit-doc-card clepit-output-doc-card",{classNames:o?.card,styles:a?.card});i.setAttribute("data-page-id",t.pageId),n?.docHref&&(i.href=n.docHref(t.pageId));const r=document.createElement("span");r.className="clepit-doc-card__icon",r.textContent=t.icon??"📄",i.appendChild(r);const s=document.createElement("span"),c=document.createElement("span");if(c.className="clepit-doc-card__title",c.textContent=t.title||"Untitled",s.appendChild(c),t.description){const e=document.createElement("span");e.className="clepit-doc-card__description",e.textContent=t.description,s.appendChild(e)}return i.appendChild(s),i}static draw(t,n=R,a){if(!e.validate(t))return null;const o=n.create("a");o.addClass("clepit-doc-card","clepit-output-doc-card"),o.setAttribute("data-page-id",t.pageId),a?.docHref&&o.setAttribute("href",a.docHref(t.pageId));const i=n.create("span");i.addClass("clepit-doc-card__icon"),i.setText(t.icon??"📄"),o.append(i);const r=n.create("span"),s=n.create("span");if(s.addClass("clepit-doc-card__title"),s.setText(t.title||"Untitled"),r.append(s),t.description){const e=n.create("span");e.addClass("clepit-doc-card__description"),e.setText(t.description),r.append(e)}return o.append(r),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.pageId&&e.pageId.length>0&&"string"==typeof e.title}},fn="\n.clepit-file {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n color: inherit;\n text-decoration: none;\n}\n.clepit-file:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-file__name {\n font-weight: 500;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-file__size {\n opacity: 0.6;\n font-size: 12px;\n}\n",vn=`${fn}\n.clepit-file__upload {\n border: 1px dashed rgba(127, 127, 127, 0.5);\n background: transparent;\n cursor: pointer;\n font: inherit;\n padding: 10px 12px;\n border-radius: 8px;\n}\n`,yn=fn;function xn(e){return null==e?"":e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}var kn=class e{static render(t,n,a,o){if(l.injectStyles("file-output",yn),!e.validate(t))return X();const i=l.createStyledElement("a","clepit-file clepit-output-file",{classNames:o?.row,styles:a?.row});i.href=t.url,i.setAttribute("download",t.name),i.setAttribute("rel","noopener noreferrer");const r=document.createElement("span");r.className="clepit-file__name",r.textContent=t.name,i.appendChild(r);const s=xn(t.size);if(s){const e=document.createElement("span");e.className="clepit-file__size",e.textContent=s,i.appendChild(e)}return i}static draw(t,n=R){if(!e.validate(t))return null;const a=n.create("a");a.addClass("clepit-file","clepit-output-file"),a.setAttribute("href",t.url),a.setAttribute("download",t.name),a.setAttribute("rel","noopener noreferrer");const o=n.create("span");o.addClass("clepit-file__name"),o.setText(t.name),a.append(o);const i=xn(t.size);if(i){const e=n.create("span");e.addClass("clepit-file__size"),e.setText(i),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&("string"==typeof e.url&&0!==e.url.length&&("string"==typeof e.name&&0!==e.name.length&&/^https?:\/\//i.test(e.url)))}},wn='\n.clepit-glance {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n padding: 12px 14px;\n}\n\n/* A variant tints the surface only. Text keeps the reading colours the rest of\n * the page uses, so a glance stays as legible as the prose around it. */\n.clepit-glance[data-variant="info"] {\n background: var(--clepit-primary-bg);\n}\n\n.clepit-glance[data-variant="success"] {\n background: var(--clepit-success-bg);\n}\n\n.clepit-glance[data-variant="warning"] {\n background: var(--clepit-warning-bg);\n}\n\n.clepit-glance[data-variant="error"] {\n background: var(--clepit-error-bg);\n}\n\n.clepit-glance-caption {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 0 0 8px;\n text-transform: uppercase;\n}\n\n/* Labels form a single vertical rail whatever their length, so the reader scans\n * one column for the question and one for the answer. */\n.clepit-glance-rows {\n column-gap: 16px;\n display: grid;\n grid-template-columns: max-content 1fr;\n margin: 0;\n row-gap: 4px;\n}\n\n.clepit-glance-label {\n color: var(--clepit-text-subtle);\n font-size: 14px;\n}\n\n.clepit-glance-value {\n color: var(--clepit-text);\n font-size: 14px;\n margin: 0;\n}\n\n.clepit-glance-value code {\n background: var(--clepit-code-bg);\n border-radius: 4px;\n font-family: \'SF Mono\', \'Monaco\', \'Roboto Mono\', monospace;\n font-size: 13px;\n padding: 1px 5px;\n}\n\n.clepit-glance-value a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-glance-value a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* A single-column stack below the narrowest tablet: a max-content label column\n * squeezes the value to a few characters once the viewport is phone width. */\n@media (max-width: 600px) {\n .clepit-glance-rows {\n grid-template-columns: 1fr;\n row-gap: 2px;\n }\n\n .clepit-glance-value {\n margin: 0 0 6px;\n }\n}\n',Cn="At a glance",An=class e{static render(t,n,a,o){if(l.injectStyles("clepit-glance-output-styles",wn),!e.validate(t))return X();if(0===t.rows.length)return document.createElement("div");const i=l.createStyledElement("div","clepit-glance",{classNames:o?.wrapper,styles:a?.wrapper});i.setAttribute("data-variant",t.variant??"plain"),i.setAttribute("data-testid","glance");const r=p("p","clepit-glance-caption");r.textContent=t.caption?.trim()?t.caption:Cn,i.appendChild(r);const s=p("dl","clepit-glance-rows");for(const e of t.rows){const t=p("dt","clepit-glance-label");t.textContent=e.label,s.appendChild(t);const n=p("dd","clepit-glance-value");n.innerHTML=m(e.html),s.appendChild(n)}return i.appendChild(s),i}static draw(t,n=R){if(!e.validate(t)||0===t.rows.length)return null;const a=n.create("div");a.addClass("clepit-glance"),a.setAttribute("data-variant",t.variant??"plain"),a.setAttribute("data-testid","glance");const o=n.create("p");o.addClass("clepit-glance-caption"),o.setText(t.caption?.trim()?t.caption:Cn),a.append(o);const i=n.create("dl");i.addClass("clepit-glance-rows");for(const e of t.rows){const t=n.create("dt");t.addClass("clepit-glance-label"),t.setText(e.label),i.append(t);const a=n.create("dd");a.addClass("clepit-glance-value"),a.setHtml(e.html),i.append(a)}return a.append(i),a}static validate(e){return null!=e&&"object"==typeof e&&(!!Array.isArray(e.rows)&&e.rows.every(e=>null!==e&&"object"==typeof e&&"string"==typeof e.label&&"string"==typeof e.html))}},Sn="\n/* Output header styles */\n.clepit-output-header {\n margin: 0 0 1rem 0;\n font-weight: 600;\n color: var(--clepit-text);\n}\n\nh1.clepit-output-header {\n font-size: 2.5rem;\n line-height: 1.2;\n}\n\nh2.clepit-output-header {\n font-size: 2rem;\n line-height: 1.3;\n}\n\nh3.clepit-output-header {\n font-size: 1.75rem;\n line-height: 1.4;\n}\n\nh4.clepit-output-header {\n font-size: 1.5rem;\n line-height: 1.4;\n}\n\nh5.clepit-output-header {\n font-size: 1.25rem;\n line-height: 1.4;\n}\n\nh6.clepit-output-header {\n font-size: 1rem;\n line-height: 1.4;\n}\n\n/* Output header inline code styling */\n.clepit-output-header code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n/* Output header marker brush effect */\n.clepit-output-header mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-header mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Output header link styles */\n.clepit-output-header a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-header a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Responsive Design */\n@media (max-width: 768px) {\n h1.clepit-output-header {\n font-size: 2rem;\n }\n\n h2.clepit-output-header {\n font-size: 1.75rem;\n }\n\n h3.clepit-output-header {\n font-size: 1.5rem;\n }\n}\n",En=class e{static{this.placeholder="Enter heading..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${l.classNames.block.header}`),n=t?.getAttribute("data-level")||"h1";return{html:m(t?.innerHTML),level:n}}static render(t,n,a){l.injectStyles("clepit-header-input-styles",'\n/* Header block styles */\n.clepit-header {\n outline: none;\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 20px;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content {\n font-weight: bold;\n margin: 16px 0 8px 0;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h1 {\n font-size: 32px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h2 {\n font-size: 24px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h3 {\n font-size: 20px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h4 {\n font-size: 18px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h5 {\n font-size: 16px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h6 {\n font-size: 14px;\n margin: 0;\n color: inherit;\n}\n\n/* Header placeholder styles */\n.clepit-header[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Header link styles */\n.clepit-header a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-header a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Header inline code styling */\n.clepit-header code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Header marker brush effect */\n.clepit-header mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-header mark::before {\n content: \'\';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 100 20\' preserveAspectRatio=\'none\'><path d=\'M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z\' fill=\'%23FFE047\'/></svg>") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark\'s stacking context */\n}\n\n');const o={html:"",level:"h1"},i=n?{...o,...n}:o,r=i.level??"h1",s=l.createStyledElement(r,l.classNames.block.header,{classNames:a?.classNames?.[r],styles:a?.styles?.[r]});return s.setAttribute("data-level",r),s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",ne(t,"headerHint",e.placeholder)),s.innerHTML=m(i.html),e.addEventListener(t,s,"keydown",Ds.handleKeydown),e.addEventListener(t,s,"input",Ds.handleInput),s}static changeLevel(t,n,a){const o=C.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-level")===n)return;const i={html:t.innerHTML,level:n},r={classNames:o.config.classNames?.blocks?.header,margins:o.config.margins,styles:o.config.styles?.blocks?.header},s=Ds.getBlockIndex(a,t.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id")),c=e.render(a,i,r);t.replaceWith(c),C.getState().updateBlockData(a,s,i)}static isEmpty(e){return h(e.querySelector(`.${l.classNames.block.header}`)?.innerHTML)}static isEmptyData(e){return h(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Ln=class e{static render(t,n,a,o){if(l.injectStyles("clepit-header-output-styles",Sn),!e.validate(t))return X();if(En.isEmptyData(t))return document.createElement("div");const i=t.level||"h1",r=l.createStyledElement(i,"clepit-output-header",{classNames:o?.[i],styles:a?.[i]});return r.innerHTML=m(t.html),r}static draw(t,n=R){if(!e.validate(t)||En.isEmptyData(t))return null;const a=n.create(t.level||"h1");return a.addClass("clepit-output-header"),t.html&&a.setHtml(t.html),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},Nn=`\n/* Image block styles */\n.${l.classNames.block.image.container} {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-image-caption {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool="image"] .clepit-block-content {\n text-align: center;\n}\n\n.clepit-block[data-tool="image"] .clepit-block-content img {\n max-width: 100%;\n height: auto;\n border-radius: 4px;\n}\n\n/* Image Block Enhanced Styles */\n.${l.classNames.block.image.container} {\n margin: 16px 0;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 100%;\n box-sizing: border-box;\n}\n\n.${l.classNames.block.image.wrapper} {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.${l.classNames.block.image.wrapper}:hover {\n opacity: 0.9;\n}\n\n.clepit-image {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n display: block;\n}\n\n.clepit-image-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-image-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-image-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-image-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Image caption styling */\n.clepit-image-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Image caption placeholder styles */\n.clepit-image-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Image Drop Area */\n.${l.classNames.block.image.dropArea} {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n min-height: 120px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n}\n\n.${l.classNames.block.image.dropArea}:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-image-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-image-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-image-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n margin-bottom: 8px;\n}\n\n.clepit-image-drop-subtext {\n font-size: 14px;\n color: var(--clepit-text-subtle);\n line-height: 1.4;\n}\n\n.clepit-image-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Image Loading State */\n.clepit-image-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-image-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-image-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Image Error State */\n.clepit-image-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-image-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-image-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-image-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-image-error-retry:hover {\n background: var(--clepit-error);\n}\n\n.clepit-image-refusal {\n display: flex;\n flex-direction: column;\n gap: 6px;\n align-items: center;\n margin: 16px 0;\n padding: 14px 12px;\n text-align: center;\n border: 1px dashed var(--clepit-border);\n border-radius: 8px;\n}\n\n.clepit-image-refusal-title {\n font-size: 14.5px;\n font-weight: 600;\n color: var(--clepit-text);\n}\n\n.clepit-image-refusal-body {\n max-width: 44ch;\n font-size: 13px;\n line-height: 1.5;\n color: var(--clepit-text-muted);\n}\n\n.clepit-image-refusal-actions {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n justify-content: center;\n}\n\n.clepit-image-refusal-action {\n display: inline-flex;\n align-items: center;\n height: 26px;\n padding: 0 10px;\n font-size: 12px;\n font-weight: 550;\n color: var(--clepit-bg);\n white-space: nowrap;\n text-decoration: none;\n background: var(--clepit-primary);\n border-radius: 6px;\n}\n\n.clepit-image-refusal-action:hover {\n background: var(--clepit-primary-hover);\n}\n\n.clepit-image-refusal-remove {\n display: inline-flex;\n align-items: center;\n height: 28px;\n padding: 0 10px;\n font: inherit;\n font-size: 13px;\n font-weight: 550;\n color: var(--clepit-text);\n white-space: nowrap;\n background: none;\n border: 0;\n border-radius: 6px;\n cursor: pointer;\n}\n\n.clepit-image-refusal-remove:hover {\n background: var(--clepit-block-highlight-bg);\n}\n\n/* Image delete button */\n.${l.classNames.block.imageDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${l.classNames.block.imageDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Image drop area delete button */\n.clepit-image-drop-area .${l.classNames.block.imageDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-image-drop-area .${l.classNames.block.imageDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,Bn="\n/* Output image styles */\n.clepit-output-image-container {\n margin: 1rem 0;\n text-align: center;\n}\n\n.clepit-output-image {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n}\n\n.clepit-output-image-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Image wrapper positioning */\n.clepit-image-wrapper {\n position: relative;\n cursor: pointer;\n display: flex;\n margin-bottom: 10px;\n}\n.clepit-output-image-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-output-image-wrapper--center {\n justify-content: center;\n}\n\n.clepit-output-image-wrapper--right {\n justify-content: flex-end;\n}\n",Mn=class extends Error{constructor(e){super(e.title),this.notice=e,this.name="UploadRefusal"}},$n=class e{static{this.placeholder="Add a caption..."}static{this.validTypes=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/ico","image/x-icon","image/avif","image/heic"]}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("img"),n=e.querySelector(`.${l.classNames.block.image.captionEditable}`),a=e.querySelector(".clepit-image-wrapper");let o="center";return a&&(o=a.classList.contains("clepit-image-wrapper--left")?"left":a.classList.contains("clepit-image-wrapper--right")?"right":"center"),{alignment:o,alt:t?.getAttribute("alt")||"",caption:m(n?.innerHTML),url:t?.getAttribute("src")||""}}static render(t,n,a,o){l.injectStyles("clepit-image-input-styles",Nn);const i={alt:"",caption:"",url:""},r=a?{...i,...a}:i,s=l.createStyledElement("div",l.classNames.block.image.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return r.url?e.renderImage(s,r,t,n,o):e.renderDropArea(s,t,n,o),s}static renderImage(t,n,a,o,i){t.innerHTML="";const r=l.createStyledElement("div",l.classNames.block.image.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("clepit-image-wrapper--left");break;case"center":r.classList.add("clepit-image-wrapper--center");break;case"right":r.classList.add("clepit-image-wrapper--right")}const s=l.createStyledElement("img","clepit-image",{classNames:i?.classNames?.container,styles:i?.styles?.container});s.alt=n?.alt||"",s.src=n?.url||"",s.classList.add("clepit-image");const c=l.createStyledElement("div","clepit-image-caption-container",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});c.classList.add("clepit-image-caption-container");const d=l.createStyledElement("div",l.classNames.block.image.captionEditable,{classNames:i?.classNames?.caption,styles:i?.styles?.caption});d.setAttribute("contenteditable","true"),d.setAttribute("data-placeholder",ne(o,"mediaCaptionHint",e.placeholder)),d.innerHTML=m(n?.caption),e.addEventListener(o,d,"keydown",Ds.handleKeydown),e.addEventListener(o,d,"input",Ds.handleInput),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),r.appendChild(s),c.appendChild(d),t.appendChild(r),t.appendChild(c),d.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const i=l.createStyledElement("div",l.classNames.block.image.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});i.setAttribute("tabindex","0"),i.setAttribute("data-testid","image-drop"),i.classList.add("clepit-drop-area");const r=l.createStyledElement("div","clepit-image-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});r.textContent="📷";const s=l.createStyledElement("div","clepit-image-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text}),c=document.createElement("strong");c.setAttribute("data-testid","image-drop-title"),c.textContent=ne(a,"imageDropTitle","Drop an image here");const d=document.createElement("span");d.className="clepit-image-click-text",d.setAttribute("data-testid","image-drop-action"),d.textContent=ne(a,"imageDropAction","or click to select"),s.append(c,document.createElement("br"),d);const p=l.createStyledElement("div","clepit-image-drop-subtext",{classNames:o?.classNames?.dropArea?.subtext,styles:o?.styles?.dropArea?.subtext});p.setAttribute("data-testid","image-drop-formats"),p.textContent=ne(a,"imageDropFormats","Supports JPEG, PNG, GIF, WebP, SVG, and other image formats");const u=l.createStyledElement("button",`${l.classNames.block.imageDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});u.type="button",u.textContent="✕",u.setAttribute("data-testid","image-drop-delete");const h=ne(a,"delete","Delete block");u.setAttribute("aria-label",h),i.appendChild(r),i.appendChild(s),i.appendChild(p),i.appendChild(u);const m=C.getState().getInstance(a),g=m?.config.classNames?.tooltips,b=m?.config.styles?.tooltips;ke(u,h,"below",g,b),e.addEventListener(a,u,"click",e=>{e.preventDefault(),e.stopPropagation();const t=u.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");t&&Ds.removeBlock(a,Ds.getBlockIndex(a,t))}),e.addEventListener(a,i,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,i,"dragleave",()=>{i.classList.remove("clepit-image-drop-area--dragover")}),e.addEventListener(a,i,"dragover",e=>{e.preventDefault(),e.stopPropagation(),i.classList.add("clepit-image-drop-area--dragover")}),e.addEventListener(a,i,"drop",r=>{r.preventDefault(),r.stopPropagation(),i.classList.remove("clepit-image-drop-area--dragover"),e.handleFileDrop(r,t,n,a,o)}),e.addEventListener(a,i,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,i,"mousedown",e=>{e.preventDefault(),e.stopPropagation()}),t.appendChild(i)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidImageFile(t)?e.processImageFile(t,n,a,o,i):e.showInvalidType(n,o)}}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="image/*",i.classList.add("clepit-hidden-input"),i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidImageFile(i)?e.processImageFile(i,t,n,a,o):e.showInvalidType(t,a)}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static isValidImageFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("image/")}static async processImageFile(t,n,a,o,i){e.showLoading(n,ne(o,"imageUploading","Uploading image..."));try{let r=await a(t);if(r){e.renderImage(n,{alignment:"center",alt:t.name,caption:"",url:r},a,o,i);const s=n.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");s&&C.getState().updateBlockData(o,Ds.getBlockIndex(o,s),Ds.getBlockData(s).data)}else e.showUploadFailed(n,o)}catch(r){if(r instanceof Mn)return void e.showRefusal(n,o,r.notice);console.error("Image upload error:",r),e.showUploadFailed(n,o)}}static showRefusal(t,n,a){t.innerHTML="";const o=l.createStyledElement("div","clepit-image-refusal",void 0);o.setAttribute("data-testid","image-refusal"),o.setAttribute("role","status");const i=document.createElement("span");i.className="clepit-image-refusal-title",i.setAttribute("data-testid","image-refusal-title"),i.textContent=a.title;const r=document.createElement("span");r.className="clepit-image-refusal-body",r.setAttribute("data-testid","image-refusal-body"),r.textContent=a.body;const s=document.createElement("span");if(s.className="clepit-image-refusal-actions",a.action&&/^https?:\/\//i.test(a.action.href)){const e=document.createElement("a");e.className="clepit-image-refusal-action",e.setAttribute("data-testid","image-refusal-action"),e.setAttribute("href",a.action.href),e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer"),e.textContent=a.action.label,s.appendChild(e)}const c=document.createElement("button");c.type="button",c.className="clepit-image-refusal-remove",c.setAttribute("data-testid","image-refusal-remove"),c.textContent=a.remove,e.addEventListener(n,c,"click",e=>{e.preventDefault(),e.stopPropagation();const t=c.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");t&&Ds.removeBlock(n,Ds.getBlockIndex(n,t))}),s.appendChild(c),o.append(i,r,s),t.appendChild(o)}static showLoading(e,t){e.innerHTML="";const n=l.createStyledElement("div","clepit-image-loading",void 0);n.setAttribute("data-testid","image-uploading"),n.textContent=t,e.appendChild(n)}static showUploadFailed(t,n){e.showError(t,ne(n,"imageUploadFailed","Failed to upload image. Please try again."),"image-upload-failed")}static showInvalidType(t,n){e.showError(t,ne(n,"imageInvalidType","Please select a valid image file (JPEG, PNG, GIF, WebP, SVG, BMP, TIFF, ICO, AVIF, HEIC, JXL, and more)"),"image-invalid-type")}static showError(e,t,n){e.innerHTML="";const a=l.createStyledElement("div","clepit-image-error",void 0);a.setAttribute("data-testid",n),a.textContent=t,e.appendChild(a)}static setAlignment(e,t){const n=e.querySelector(".clepit-image-wrapper");n&&(n.classList.remove("clepit-image-wrapper--left","clepit-image-wrapper--center","clepit-image-wrapper--right"),n.classList.add(`clepit-image-wrapper--${t}`));const a=Ds.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&C.getState().partialUpdateBlockData(a,Ds.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${l.classNames.block.image.wrapper} img`),n=e.querySelector(`.${l.classNames.block.image.captionEditable}`);let a=!1,o=!1;return t&&t.getAttribute("src")?.trim()||(a=!0),n?h(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return!e.url?.trim()&&h(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},In=class e{static render(t,n,a,o){if(l.injectStyles("clepit-image-output-styles",Bn),!e.validate(t))return X();if($n.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alt||r||"",c=l.createStyledElement("div","clepit-output-image-container",{classNames:o?.container,styles:a?.container}),d=l.createStyledElement("div","clepit-output-image-wrapper");if(t.alignment)switch(t.alignment){case"left":d.classList.add("clepit-output-image-wrapper--left");break;case"center":d.classList.add("clepit-output-image-wrapper--center");break;case"right":d.classList.add("clepit-output-image-wrapper--right")}const u=p("img","clepit-output-image");if(u.src=i,u.alt=s,d.appendChild(u),c.appendChild(d),r){const e=l.createStyledElement("figcaption","clepit-output-image-caption",{classNames:o?.caption,styles:a?.caption});e.innerHTML=m(r),c.appendChild(e)}return c}static draw(t,n=R){if(!e.validate(t)||$n.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-image-container");const o=n.create("div");o.addClass("clepit-output-image-wrapper");const i=t.alignment??"";i&&o.addClass(`clepit-output-image-wrapper--${i}`);const r=n.create("img");if(r.addClass("clepit-output-image"),r.setAttribute("src",t.url),r.setAttribute("alt",t.alt||t.caption||""),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-image-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},Tn=Le,_n=Le,qn=(e,t)=>{if("string"!=typeof e){if(Array.isArray(e))for(const n of e)qn(n,t);else if(e&&"object"==typeof e){const n=e;if("embed"===n.type&&n.data&&"object"==typeof n.data){const e=n.data;e.issue&&"object"==typeof e.issue&&t.push({...e.issue,url:e.issue.url||e.url||""})}for(const e of Object.values(n))qn(e,t)}}else e.includes("clepit-issue")&&t.push(...We(e))},Dn=class e{static collect(e,t){const n=[];qn(e??[],n);const a=/* @__PURE__ */new Set,o=[];for(const i of n)i.url&&!a.has(i.url)&&(a.add(i.url),o.push(t?.[i.url]?{...t[i.url],url:i.url}:i));return o}static render(t,n,a,o){l.injectStyles("issues-output",_n);const i=e.collect(n?.documentBlocks,n?.issues);if(0===i.length){const e=l.createStyledElement("div","clepit-issues__empty clepit-output-issues",{classNames:o,styles:a});return e.setAttribute("data-testid","issues-empty"),e.textContent=$e(n?.issueLabels,"linkedIssuesEmpty"),e}const r=J(e.table(i,R,n?.issueLabels));return l.applyStyling(r,{classNames:o,styles:a}),r}static draw(t,n=R,a){if(null==t||"object"!=typeof t)return null;const o=e.collect(a?.documentBlocks,a?.issues);return 0===o.length?null:e.table(o,n,a?.issueLabels)}static table(e,t,n){const a=t.create("table");a.addClass("clepit-issues","clepit-output-issues"),a.setAttribute("data-testid","issues-table");const o=t.create("thead"),i=t.create("tr");for(const s of["columnIssue","columnTitle","columnStatus","columnAssignee"]){const e=t.create("th");e.setText($e(n,s)),i.append(e)}o.append(i),a.append(o);const r=t.create("tbody");for(const s of e){const e=t.create("tr");e.setAttribute("data-testid","issues-row"),e.setAttribute("data-issue-url",s.url);const a=t.create("td"),o=t.create("a");d(s.url)&&o.setAttribute("href",s.url),o.setAttribute("rel","noopener noreferrer nofollow"),o.setAttribute("target","_blank"),o.setText(s.key||s.title||s.url),a.append(o),e.append(a);const i=t.create("td");i.setText(s.key?s.title:""),e.append(i);const l=t.create("td");if(!s.reason){const e=t.create("span");e.addClass("clepit-issue__state"),e.setAttribute("data-issue-category",s.category),e.setText(He(s,n)),l.append(e)}e.append(l);const c=t.create("td");c.setText(s.reason?"":s.assigneeName||$e(n,"unassigned")),e.append(c),r.append(e)}return a.append(r),a}},zn="\n/* Output list styles */\n.clepit-output-list {\n margin: 0 0 1rem 0;\n padding-left: 2rem;\n}\n\n.clepit-output-list-item {\n margin: 0.5rem 0;\n line-height: 1.6;\n}\n\n/* Output list link styles */\n.clepit-output-list a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-list a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output list inline code styling */\n.clepit-output-list li code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n/* Output list marker brush effect */\n.clepit-output-list li mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-list li mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Responsive Design */\n@media (max-width: 768px) {\n .clepit-output-list {\n padding-left: 1.5rem;\n }\n}\n",jn=class e{static{this.placeholder="Enter list item..."}static{this.defaultType="unordered"}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(t){const n=t.getAttribute("data-type")||e.defaultType,a=[];return t.querySelectorAll("li").forEach(e=>a.push(m(e.innerHTML))),{items:a,type:n}}static render(t,n,a){l.injectStyles("clepit-list-input-styles","\n/* List block styles */\n.clepit-list {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 16px;\n}\n\n.clepit-list-item {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content {\n padding-left: 40px;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content ul,\n.clepit-block[data-tool=\"list\"] .clepit-block-content ol {\n margin: 0;\n padding-left: 20px;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content li {\n margin: 4px 0;\n}\n\n/* List item placeholder styles */\n.clepit-list-item[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* List item link styles */\n.clepit-list-item a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-list-item a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* List item inline code styling */\n.clepit-list-item code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* List item marker brush effect */\n.clepit-list-item mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-list-item mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o={items:[],type:e.defaultType},i=n?{...o,...n}:o,r="ordered"===i.type?"ol":"ul",s=l.createStyledElement(r,l.classNames.block.list.container,{classNames:a?.classNames?.[i.type]?.container,styles:a?.styles?.[i.type]?.container});s.setAttribute("data-type",i.type);const c=a?.classNames?.[i.type]?.item,d=a?.styles?.[i.type]?.item;return i.items.length>0?i.items.forEach(n=>e.createAndAppendListItem(n,s,t,c,d)):e.createAndAppendListItem("",s,t,c,d),s}static createAndAppendListItem(t,n,a,o,i){const r=l.createStyledElement("li",l.classNames.block.list.item,{classNames:o,styles:i});r.innerHTML=m(t),r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",ne(a,"listItemHint",e.placeholder)),e.addEventListener(a,r,"keydown",t=>{const s=t,c=n.closest(`.${l.classNames.block.container}`);if(!c)return;const d=Ds.getBlockIndex(a,c.getAttribute("data-id")),p=s.metaKey||s.ctrlKey;if(s.shiftKey)switch(s.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),d>0&&Ds.moveBlock(a,d,d-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const e=Ds.getBlocks(a);e&&d<e.length-1&&Ds.moveBlock(a,d,d+1)}else if(p)switch(s.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),Ds.removeBlock(a,d)}else if("Enter"===s.key)if(t.preventDefault(),t.stopPropagation(),h(r.innerHTML)){e.cleanupEmptyItems(n);const t=n.closest(`.${l.classNames.block.container}`);if(!t)return;const o=Ds.getBlockIndex(a,t.getAttribute("data-id"));Ds.insertBlock({data:{html:""},type:"paragraph"},a,o+1)}else e.createAndAppendListItem("",n,a,o,i);else if("Backspace"===s.key){if(h(r.innerHTML)){t.preventDefault(),t.stopPropagation();const e=Array.from(n.querySelectorAll("li")),o=e.indexOf(r);if(1===e.length){const e=n.closest(`.${l.classNames.block.container}`);if(!e)return;const t=Ds.getBlockIndex(a,e.getAttribute("data-id"));if(-1===t)return;Ds.removeBlock(a,t)}else r.remove(),o>0?e[o-1].focus():e[o+1].focus()}}else{Ds.ensureActiveBlock(a);const e=Ds.getBlocks(a);switch(s.key){case"ArrowUp":t.preventDefault(),t.stopPropagation();const a=Array.from(n.querySelectorAll(`.${l.classNames.block.list.item}`)),o=a.indexOf(r);if(0===o){if(d>0){const t=e[d-1];t&&Ds.focusBlock(t)}}else{const e=a[o-1];e&&e.focus()}return;case"ArrowDown":t.preventDefault(),t.stopPropagation();const i=Array.from(n.querySelectorAll(`.${l.classNames.block.list.item}`)),s=i.indexOf(r);if(s===i.length-1){if(d<e.length-1){const t=e[d+1];t&&Ds.focusBlock(t)}}else{const e=i[s+1];e&&e.focus()}return}}}),e.addEventListener(a,r,"input",Ds.handleInput),n.appendChild(r),r.focus()}static changeType(t,n,a){const o=C.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-type")===n)return;const i={items:[...t.querySelectorAll("li")||[]].map(e=>e.innerHTML),type:n},r={classNames:o.config.classNames?.blocks?.list,styles:o.config.styles?.blocks?.list},s=Ds.getBlockIndex(a,t.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id")),c=e.render(a,i,r);t.replaceWith(c),C.getState().updateBlockData(a,s,i)}static cleanupEmptyItems(e){const t=Array.from(e.querySelectorAll("li")),n=t.filter(e=>h(e.innerHTML));if(t.length===n.length){if(t.length<2)return;for(let e=1;e<n.length;e++)n[e].remove()}else n.forEach(e=>e.remove())}static isEmpty(e){const t=e.querySelectorAll(`.${l.classNames.block.list.item}`);return!t||Array.from(t).every(e=>h(e.innerHTML))}static isEmptyData(e){return 0===e.items.length||e.items.every(e=>h(e))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Hn=class e{static render(t,n,a,o){if(l.injectStyles("clepit-list-output-styles",zn),!e.validate(t))return X();if(jn.isEmptyData(t))return document.createElement("div");const i=t.items,r="ordered"===t.type?"ordered":"unordered",s=l.createStyledElement("ordered"===r?"ol":"ul","clepit-output-list",{classNames:o?.[r]?.container,styles:a?.[r]?.container});return i.forEach((e,t)=>{const n=l.createStyledElement("li","clepit-output-list-item",{classNames:o?.[r]?.item,styles:a?.[r]?.item});n.innerHTML=m(e),s.appendChild(n)}),s}static draw(t,n=R){if(!e.validate(t)||jn.isEmptyData(t))return null;const a="ordered"===t.type,o=n.create(a?"ol":"ul");o.addClass("clepit-output-list");for(const e of t.items){const t=n.create("li");t.addClass("clepit-output-list-item"),e?.trim()&&t.setHtml(e),o.append(t)}return o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.items)&&"string"==typeof e.type}},On="\n.clepit-openapi {\n display: flex;\n flex-direction: column;\n gap: 40px;\n margin: 16px 0;\n}\n\n/* Groups and operations are separated by rhythm, never by rules — the same\n * house style the tables follow. */\n.clepit-openapi-group {\n display: flex;\n flex-direction: column;\n gap: 14px;\n}\n\n/* An eyebrow label rather than a heading, matching the uppercase group headings\n * in the docs sidebar so the reference echoes the nav. */\n.clepit-openapi-group-title {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 0;\n text-transform: uppercase;\n}\n\n.clepit-openapi-operation {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n\n/* The head is a tinted strip so an operation reads as one bounded unit in a\n * page of a dozen. */\n.clepit-openapi-operation-head {\n align-items: center;\n background: color-mix(in oklab, var(--clepit-text) 4%, transparent);\n border-bottom: 1px solid var(--clepit-border);\n display: flex;\n flex-wrap: wrap;\n gap: 10px;\n padding: 10px 14px;\n}\n\n.clepit-openapi-operation-body {\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 14px;\n}\n\n.clepit-openapi-method {\n border-radius: 4px;\n color: var(--clepit-bg);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.04em;\n padding: 3px 8px;\n}\n\n.clepit-openapi-method[data-method=\"GET\"] { background: var(--clepit-success); }\n.clepit-openapi-method[data-method=\"POST\"],\n.clepit-openapi-method[data-method=\"PUT\"],\n.clepit-openapi-method[data-method=\"PATCH\"] { background: var(--clepit-primary); }\n.clepit-openapi-method[data-method=\"DELETE\"] { background: var(--clepit-error); }\n\n.clepit-openapi-path {\n color: var(--clepit-text);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 14px;\n}\n\n.clepit-openapi-host {\n color: var(--clepit-text-subtle);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 12px;\n margin-left: auto;\n}\n\n.clepit-openapi-summary {\n color: var(--clepit-text);\n font-size: 16px;\n font-weight: 600;\n margin: 0;\n}\n\n.clepit-openapi-description {\n color: var(--clepit-text-muted);\n margin: 0;\n}\n\n.clepit-openapi-section-title {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 4px 0 0;\n text-transform: uppercase;\n}\n\n/* A table has no scroll surface of its own — a cell the house style cannot\n * break (a long host URL) would otherwise force the table, and every ancestor\n * up to the page itself, wider than the viewport. */\n.clepit-openapi-table-scroll {\n max-width: 100%;\n overflow-x: auto;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n}\n\n.clepit-openapi-table {\n border-collapse: collapse;\n font-size: 14px;\n width: 100%;\n}\n\n.clepit-openapi-table th {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n color: var(--clepit-text-subtle);\n font-weight: 600;\n padding: 6px 8px;\n text-align: left;\n}\n\n/* House style: no horizontal dividers between rows. Zebra striping is what\n * separates them instead. */\n.clepit-openapi-table td {\n color: var(--clepit-text);\n padding: 7px 8px;\n vertical-align: top;\n}\n\n.clepit-openapi-table tr:nth-child(even) td {\n background: var(--clepit-surface);\n}\n\n.clepit-openapi-name {\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n overflow-wrap: anywhere;\n}\n\n.clepit-openapi-type {\n color: var(--clepit-text-muted);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n}\n\n.clepit-openapi-required {\n color: var(--clepit-error);\n font-size: 12px;\n}\n\n.clepit-openapi-badge {\n background: var(--clepit-primary-bg);\n border-radius: 4px;\n color: var(--clepit-primary);\n font-size: 12px;\n padding: 2px 8px;\n}\n\n.clepit-openapi-status {\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-weight: 600;\n}\n\n.clepit-openapi-status[data-kind=\"success\"] { color: var(--clepit-success); }\n.clepit-openapi-status[data-kind=\"client\"] { color: var(--clepit-warning); }\n.clepit-openapi-status[data-kind=\"server\"] { color: var(--clepit-error); }\n\n/* One response at a time behind a status tab strip. */\n.clepit-openapi-responses {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.clepit-openapi-response-tabs {\n border-bottom: 1px solid var(--clepit-border);\n display: flex;\n flex-wrap: wrap;\n gap: 16px;\n margin-bottom: 4px;\n}\n\n.clepit-openapi-response-tab {\n background: none;\n border: 0;\n border-bottom: 2px solid transparent;\n color: var(--clepit-text-muted);\n cursor: pointer;\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 12px;\n margin-bottom: -1px;\n padding: 6px 0;\n}\n\n.clepit-openapi-response-tab[aria-selected=\"true\"] {\n border-bottom-color: var(--clepit-primary);\n color: var(--clepit-text);\n font-weight: 600;\n}\n\n.clepit-openapi-response-tab:focus-visible {\n outline: 2px solid var(--clepit-primary);\n outline-offset: 2px;\n}\n\n.clepit-openapi-response-description {\n color: var(--clepit-text-muted);\n margin: 0;\n}\n\n/* Tabs hide three quarters of the contract from a printed page, so print gets\n * every response expanded and the strip removed. */\n@media print {\n .clepit-openapi-response-tabs { display: none; }\n .clepit-openapi-response { display: block !important; }\n .clepit-openapi-response + .clepit-openapi-response { margin-top: 10px; }\n}\n\n.clepit-openapi-servers {\n color: var(--clepit-text-muted);\n font-size: 14px;\n margin: 0;\n}\n",Pn=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Rn=(e,t)=>{const n={children:[],cyclic:!1,nullable:!1,required:!1,type:"unknown"};if(!Pn(e))return n;if("string"==typeof e.$ref){const o=(a=e.$ref).split("/").pop()??a;if(n.ref=o,t.stack.has(o))return n.cyclic=!0,n.type=o,n;const i=t.schemas[o];if(void 0===i)return n;t.stack.add(o);const r=Rn(i,t);return t.stack.delete(o),r.ref=o,r}var a;"string"==typeof e.description&&(n.description=e.description),"string"==typeof e.format&&(n.format=e.format),Array.isArray(e.enum)&&(n.enum=e.enum.map(e=>String(e)));const o=["allOf","anyOf","oneOf"].find(t=>Array.isArray(e[t]));if(o){const a=e[o].map(e=>Rn(e,t));if("allOf"===o){n.type="object";for(const e of a)n.children.push(...e.children);return n}const i=a.filter(e=>"null"!==e.type&&!("unknown"===e.type&&e.nullable));return(a.length!==i.length||a.some(e=>e.nullable))&&(n.nullable=!0),n.type=i.map(e=>e.ref??e.type).join(" | ")||"unknown",n.children.push(...i.flatMap(e=>e.children)),n}if(n.type=((e,t)=>{const n=e.type;if(Array.isArray(n)){const e=n.filter(e=>"string"==typeof e);return e.includes("null")&&(t.nullable=!0),e.find(e=>"null"!==e)??"unknown"}return"string"==typeof n?n:"unknown"})(e,n),"array"===n.type){const a=Rn(e.items,t);return n.type=`${a.ref??a.type}[]`,n.children.push(...a.children),n}return"object"===n.type&&((e,t,n)=>{if(!Pn(e.properties))return;const a=Array.isArray(e.required)?e.required.filter(e=>"string"==typeof e):[];for(const[o,i]of Object.entries(e.properties)){const e=Rn(i,n);e.name=o,e.required=a.includes(o),t.children.push(e)}})(e,n,t),n},Fn=(e,t)=>Rn(e,{schemas:t,stack:/* @__PURE__ */new Set}),Vn=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Un=e=>{if(!Vn(e))return"string";const t=Array.isArray(e.type)?e.type.find(e=>"null"!==e):e.type;if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];switch(t){case"array":return[];case"boolean":return!0;case"integer":case"number":return 0;case"object":return{};default:return"string"}},Wn=e=>{if(!Vn(e)||!Vn(e.properties))return;const t={};for(const[n,a]of Object.entries(e.properties))t[n]=Un(a);return t},Kn=e=>e.security[0],Gn=(e,t)=>{return`${t}${n=e.path,n.replace(/\{([^}]+)\}/g,":$1")}`;var n},Jn={bash:{build:(e,t)=>{const n=[`curl -X ${e.method} "${Gn(e,t)}"`],a=Kn(e);var o;a&&n.push(` -H "Authorization: Bearer $${o=a,o.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()}"`);const i=Wn(e.request);return i&&(n.push(' -H "Content-Type: application/json"'),n.push(` -d '${JSON.stringify(i)}'`)),n.join(" \\\n")},label:"cURL"},dart:{build:(e,t)=>{const n=Wn(e.request),a=e.method.toLowerCase(),o=[` Uri.parse('${Gn(e,t)}'),`],i=[],r=Kn(e);return r&&i.push(` 'Authorization': 'Bearer $${r}',`),n&&i.push(" 'Content-Type': 'application/json',"),i.length>0&&o.push(" headers: {",...i," },"),n&&o.push(` body: jsonEncode(${JSON.stringify(n)}),`),[`final response = await http.${a}(`,...o,");"].join("\n")},label:"Dart"},python:{build:(e,t)=>{const n=Wn(e.request),a=e.method.toLowerCase(),o=[` "${Gn(e,t)}",`],i=Kn(e);var r;return i&&o.push(` headers={"Authorization": f"Bearer {${r=i,r.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}}"},`),n&&o.push(` json=${JSON.stringify(n)},`),[`response = requests.${a}(`,...o,")"].join("\n")},label:"Python"},typescript:{build:(e,t)=>{const n=Wn(e.request),a=[],o=Kn(e);o&&a.push(` Authorization: \`Bearer \${${o}}\`,`),n&&a.push(" 'Content-Type': 'application/json',");const i=[` method: '${e.method}',`];return a.length>0&&i.push(" headers: {",...a," },"),n&&i.push(` body: JSON.stringify(${JSON.stringify(n,null,2).replace(/\n/g,"\n ")}),`),[`const response = await fetch('${Gn(e,t)}', {`,...i,"});","","const data = await response.json();"].join("\n")},label:"TypeScript"}},Xn=["bash","typescript","dart","python"],Yn=["get","post","put","patch","delete"],Zn=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Qn=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),ea=(e,t,n)=>!!e&&(!!e.tags?.some(e=>t.includes(e))||(e.paths?.includes(n)??!1)),ta=e=>(Array.isArray(e.parameters)?e.parameters:[]).filter(Zn).map(e=>({..."string"==typeof e.description?{description:e.description}:{},in:"path"===e.in||"header"===e.in?e.in:"query",name:String(e.name??""),required:!0===e.required,...void 0===e.schema?{}:{schema:e.schema}})),na=e=>Zn(e.responses)?Object.entries(e.responses).map(([e,t])=>{const n=Zn(t)?t:{},a=Zn(n.content)?n.content:void 0,o=a&&Zn(a["application/json"])?a["application/json"]:void 0;return{description:"string"==typeof n.description?n.description:"",...void 0===o?.schema?{}:{schema:o.schema},status:e}}):[],aa=e=>{if(!Zn(e.requestBody))return;const t=Zn(e.requestBody.content)?e.requestBody.content:void 0;return(t&&Zn(t["application/json"])?t["application/json"]:void 0)?.schema},oa=e=>{if(!Array.isArray(e.security))return[];const t=e.security.find(Zn);return t?Object.keys(t):[]},ia=e=>{if(!Array.isArray(e.servers))return;const t=e.servers.find(Zn);return"string"==typeof t?.url?t.url:void 0},ra=(e,t)=>e[0]??t.split("/").filter(Boolean)[0]??"default",sa=(e,t)=>{const n=Zn(e)?e:{},a=Zn(n.info)?n.info:{},o=Zn(n.components)?n.components:{},i={groups:[],schemas:Zn(o.schemas)?o.schemas:{},servers:(Array.isArray(n.servers)?n.servers:[]).filter(Zn).map(e=>({..."string"==typeof e.description?{description:e.description}:{},url:String(e.url??"")})),title:"string"==typeof a.title?a.title:"",version:"string"==typeof a.version?a.version:""},r=Zn(n.paths)?n.paths:{},s=/* @__PURE__ */new Map;for(const[l,c]of Object.entries(r))if(Zn(c))for(const e of Yn){const n=c[e];if(!Zn(n))continue;const a=(Array.isArray(n.tags)?n.tags:[]).filter(e=>"string"==typeof e),o=!0===n["x-internal"],i=t.include?.paths?.includes(l)??!1;if(o&&!i)continue;if(ea(t.exclude,a,l))continue;if(t.include&&!i&&!ea(t.include,a,l))continue;const r={..."string"==typeof n.description?{description:n.description}:{},id:Qn(`${e}-${l}`),internal:o,method:e.toUpperCase(),params:ta(n),path:l,...void 0===aa(n)?{}:{request:aa(n)},responses:na(n),security:oa(n),...void 0===ia(n)?{}:{server:ia(n)},summary:"string"==typeof n.summary?n.summary:l,tags:a},d=ra(a,l),p=s.get(d);p?p.operations.push(r):s.set(d,{id:Qn(d),operations:[r],title:d})}return i.groups=[...s.values()],i},la=(e,t,n,a)=>{const o=e.create(t);return n&&o.addClass(...n.split(" ")),void 0!==a&&o.setText(a),o},ca=(e,t)=>{const n=la(e,"div","clepit-openapi-table-scroll");return n.append(t),n},da=(e,t,n,a)=>{const o=la(e,"p","clepit-openapi-section-title",t);return o.setAttribute("data-testid",`openapi-section-${n}-${a}`),o},pa=e=>{const t=e.ref&&"object"===e.type?e.ref:e.type,n=e.enum?e.enum.join(" | "):t;return e.nullable?`${n} | null`:n},ua=(e,t=0)=>t>6?pa(e):e.type.endsWith("[]")?0===e.children.length?[]:[Object.fromEntries(e.children.map(e=>[e.required?e.name:`${e.name}?`,ua(e,t+1)]))]:e.children.length>0?Object.fromEntries(e.children.map(e=>[e.required?e.name:`${e.name}?`,ua(e,t+1)])):pa(e),ha=e=>{const t=Number.parseInt(e,10);return t>=200&&t<300?"success":t>=400&&t<500?"client":t>=500?"server":"other"},ma=(e,t,n,a)=>{const o=la(e,"section","clepit-openapi-operation");o.setAttribute("data-testid",`openapi-operation-${t.id}`);const i=t.server??a.defaultServer??n.servers[0]?.url??"";o.setAttribute("data-server",i);const r=la(e,"div","clepit-openapi-operation-head"),s=la(e,"span","clepit-openapi-method",t.method);s.setAttribute("data-method",t.method),s.setAttribute("data-testid",`openapi-method-${t.id}`);const l=la(e,"span","clepit-openapi-path",t.path);if(l.setAttribute("data-testid",`openapi-path-${t.id}`),r.append(s),r.append(l),i){const n=la(e,"span","clepit-openapi-host",i);n.setAttribute("data-testid",`openapi-host-${t.id}`),r.append(n)}o.append(r);const c=la(e,"div","clepit-openapi-operation-body"),d=la(e,"h3","clepit-openapi-summary",t.summary);d.setAttribute("id",t.id),c.append(d),t.description&&c.append(la(e,"p","clepit-openapi-description",t.description));const p=la(e,"div","clepit-openapi-security");p.setAttribute("data-testid",`openapi-security-${t.id}`),p.append(la(e,"span","clepit-openapi-section-title","Auth")),p.appendText(" "),p.append(la(e,"span","clepit-openapi-badge",t.security.length>0?t.security.join(", "):"public")),c.append(p);const u=((e,t,n)=>{if(0===t.params.length)return null;const a=la(e,"table","clepit-openapi-table");a.setAttribute("data-testid",`openapi-params-${t.id}`);const o=e.create("tr");for(const i of["Name","In","Type","Description"])o.append(la(e,"th","clepit-openapi-th",i));a.append(o);for(const i of t.params){const t=e.create("tr"),o=la(e,"td","clepit-openapi-name",i.name);i.required&&o.append(la(e,"span","clepit-openapi-required"," required")),t.append(o),t.append(la(e,"td","clepit-openapi-cell",i.in)),t.append(la(e,"td","clepit-openapi-type",pa(Fn(i.schema,n.schemas)))),t.append(la(e,"td","clepit-openapi-cell",i.description??"")),a.append(t)}return a})(e,t,n);if(u&&(c.append(da(e,"Parameters","parameters",t.id)),c.append(ca(e,u))),void 0!==t.request){const a=Fn(t.request,n.schemas);if(a.children.length>0){c.append(da(e,"Body","body",t.id));const n=la(e,"div","clepit-openapi-body");n.setAttribute("data-testid",`openapi-body-${t.id}`);const o=Se.draw({code:JSON.stringify(ua(a),null,2),language:"json",showCopy:!0},e);o&&n.append(o),c.append(n)}}t.responses.length>0&&(c.append(da(e,"Responses","responses",t.id)),c.append(((e,t,n)=>{const a=la(e,"div","clepit-openapi-responses");a.setAttribute("data-testid",`openapi-responses-${t.id}`);const o=la(e,"div","clepit-openapi-response-tabs");o.setAttribute("role","tablist"),o.setAttribute("data-testid",`openapi-response-tabs-${t.id}`);const i=[],r=1===t.responses.length;t.responses.forEach((a,s)=>{const l=la(e,"div","clepit-openapi-response");l.setAttribute("id",`${t.id}-response-${a.status}`),l.setAttribute("role","tabpanel"),l.setAttribute("data-status",a.status),l.setAttribute("data-testid",`openapi-response-${t.id}-${a.status}`),0!==s&&l.setAttribute("hidden","");const c=la(e,"p","clepit-openapi-response-description");if(r){const t=la(e,"span","clepit-openapi-status",a.status);t.setAttribute("data-kind",ha(a.status)),c.append(t),c.appendText(` ${a.description}`)}else c.setText(a.description);if(l.append(c),void 0!==a.schema){const t=Fn(a.schema,n.schemas);if(t.children.length>0){const n=Se.draw({code:JSON.stringify(ua(t),null,2),language:"json",showCopy:!0},e,{deferHighlight:0!==s});n&&l.append(n)}}i.push(l);const d=la(e,"button","clepit-openapi-response-tab",a.status);d.setAttribute("type","button"),d.setAttribute("role","tab"),d.setAttribute("aria-controls",`${t.id}-response-${a.status}`),d.setAttribute("aria-selected",0===s?"true":"false"),d.setAttribute("tabindex",0===s?"0":"-1"),d.setAttribute("data-kind",ha(a.status)),d.setAttribute("data-testid",`openapi-response-tab-${t.id}-${a.status}`),o.append(d)}),r||a.append(o);for(const s of i)a.append(s);return a})(e,t,n)));const h=((e,t,n)=>n.flatMap(n=>{const a=Jn[n];return a?[{code:a.build(e,t),label:a.label,language:n}]:[]}))(t,i,a.snippetLanguages??Xn);if(h.length>0){c.append(da(e,"Try it","try-it",t.id));const n=Se.draw({code:h[0].code,language:h[0].language,showCopy:!0,syncKey:"api-reference",variants:h},e);n&&c.append(n)}return o.append(c),o},ga=class e{static draw(t,n=R){if(!e.validate(t))return null;const a=sa(t.spec,t),o=la(n,"div","clepit-openapi");if(a.servers.length>0){const e=la(n,"table","clepit-openapi-table clepit-openapi-servers");e.setAttribute("data-testid","openapi-servers");const t=n.create("tr");t.append(la(n,"th","clepit-openapi-th","Host")),t.append(la(n,"th","clepit-openapi-th","Serves")),e.append(t);for(const o of a.servers){const t=n.create("tr");t.append(la(n,"td","clepit-openapi-name",o.url)),t.append(la(n,"td","clepit-openapi-cell",o.description??"")),e.append(t)}o.append(ca(n,e))}for(const e of a.groups){const i=la(n,"section","clepit-openapi-group");i.setAttribute("data-testid",`openapi-group-${e.id}`);const r=la(n,"h2","clepit-openapi-group-title",e.title);r.setAttribute("id",e.id),i.append(r);for(const o of e.operations)i.append(ma(n,o,a,t));o.append(i)}return o}static render(t,n,a,o){if(l.injectStyles("clepit-openapi-output-styles",On),!e.validate(t))return X();const i=J(e.draw(t,R));o?.container&&i.classList.add(o.container),a?.container&&Object.assign(i.style,a.container),e.attach(i);for(const e of[...i.querySelectorAll(".clepit-output-code-container")])Se.activateFromMarkup(e);return i}static activate(t){const n=[e.attach(t)];for(const e of[...t.querySelectorAll(".clepit-output-code-container")])n.push(Se.activateFromMarkup(e));return()=>{for(const e of n)e()}}static attach(e){const t=[],n=(e,n,a)=>{e.addEventListener(n,a),t.push({event:n,handler:a,target:e})};for(const o of[...e.querySelectorAll(".clepit-openapi-responses")]){const e=[...o.querySelectorAll(".clepit-openapi-response-tab")],t=[...o.querySelectorAll(".clepit-openapi-response")],a=n=>{e.forEach((e,t)=>{e.setAttribute("aria-selected",t===n?"true":"false"),e.tabIndex=t===n?0:-1}),t.forEach((e,t)=>{e.hidden=t!==n,t===n&&Se.reveal(e)})};e.forEach((t,o)=>{n(t,"click",()=>a(o)),n(t,"keydown",t=>{const n=t.key,i="ArrowRight"===n?1:"ArrowLeft"===n?-1:0,r="Home"===n?0:"End"===n?e.length-1:0===i?-1:(o+i+e.length)%e.length;-1!==r&&(t.preventDefault(),a(r),e[r]?.focus())})})}const a=()=>Se.reveal(e);return window.addEventListener("beforeprint",a),t.push({event:"beforeprint",handler:a,target:window}),()=>{for(const{event:e,handler:n,target:a}of t)a.removeEventListener(e,n)}}static validate(e){return null!=e&&"object"==typeof e&&("string"==typeof e.url&&e.url.length>0||"object"==typeof e.spec&&null!==e.spec&&!Array.isArray(e.spec))}},ba="\n/* Output paragraph styles */\n.clepit-output-paragraph {\n margin: 0 0 1rem 0;\n line-height: 1.6;\n color: var(--clepit-text);\n}\n\n/* Output paragraph inline code styling */\n.clepit-output-paragraph code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n/* Output paragraph marker brush effect */\n.clepit-output-paragraph mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-paragraph mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Output paragraph link styles */\n.clepit-output-paragraph a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-paragraph a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n",fa=class e{static{this.placeholder="Start writing..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{html:m(e.querySelector(`.${l.classNames.block.paragraph}`)?.innerHTML)}}static render(t,n,a){l.injectStyles("clepit-paragraph-input-styles","\n/* Paragraph block styles */\n.clepit-paragraph {\n outline: none;\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 20px;\n}\n\n.clepit-block[data-tool=\"paragraph\"] .clepit-block-content {\n font-size: 16px;\n line-height: 1.6;\n}\n\n/* Paragraph placeholder styles */\n.clepit-paragraph[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Paragraph link styles */\n.clepit-paragraph a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-paragraph a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Paragraph inline code styling */\n.clepit-paragraph code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Paragraph marker brush effect */\n.clepit-paragraph mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-paragraph mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o=l.createStyledElement("div",l.classNames.block.paragraph,{classNames:a?.classNames,styles:a?.styles});return o.setAttribute("contenteditable","true"),o.setAttribute("data-placeholder",C.getState().getInstance(t)?.config.placeholder||e.placeholder),o.innerHTML=m(n?.html),e.addEventListener(t,o,"keydown",Ds.handleKeydown),e.addEventListener(t,o,"input",Ds.handleInput),o}static isEmpty(e){return h(e.querySelector(`.${l.classNames.block.paragraph}`)?.innerHTML)}static isEmptyData(e){return h(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},va=class e{static render(t,n,a,o){if(l.injectStyles("clepit-paragraph-output-styles",ba),!e.validate(t))return X();const i=l.createStyledElement("p","clepit-output-paragraph",{classNames:o,styles:a});return fa.isEmptyData(t)?(i.appendChild(document.createElement("br")),i):(i.innerHTML=m(t.html),i)}static draw(t,n=R){if(!e.validate(t))return null;const a=n.create("p");return a.addClass("clepit-output-paragraph"),fa.isEmptyData(t)?(a.append(n.create("br")),a):(t.html&&a.setHtml(t.html),a)}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},ya=`\n/* Quote block styles */\n.${l.classNames.block.quote.container} {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n padding: 16px 20px;\n margin: 16px 16px 16px 0;\n position: relative;\n}\n\n.${l.classNames.block.quote.text} {\n font-size: 1.2em;\n line-height: 1.6;\n font-family: cursive, serif;\n font-style: italic;\n margin-bottom: 15px;\n padding: 4px 6px;\n}\n\n.${l.classNames.block.quote.author} {\n color: var(--clepit-text-muted);\n font-size: 0.9em;\n font-style: normal;\n font-family: inherit;\n text-align: right;\n margin-top: 10px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n.${l.classNames.block.quote.author}:focus {\n outline: none;\n}\n\n.${l.classNames.block.quote.divider} {\n height: 1px;\n margin: 15px 0;\n background: linear-gradient(to right, transparent, var(--clepit-border-subtle), transparent);\n}\n\n/* Quote placeholder styles */\n.${l.classNames.block.quote.text}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n.${l.classNames.block.quote.author}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Quote link styles */\n.${l.classNames.block.quote.text} a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.${l.classNames.block.quote.text} a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Quote inline code styling */\n.${l.classNames.block.quote.text} code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n`,xa="\n/* Output quote styles */\n.clepit-output-quote-container {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n padding: 12px 14px;\n margin: 20px 0;\n position: relative;\n}\n\n.clepit-output-quote-author {\n color: var(--clepit-text-muted);\n font-size: 0.9em;\n font-style: normal;\n font-family: inherit;\n text-align: right;\n margin-top: 10px;\n}\n\n.clepit-output-quote-divider {\n height: 1px;\n margin: 15px 0;\n background: linear-gradient(to right, transparent, var(--clepit-border-subtle), transparent);\n}\n\n.clepit-output-quote-text {\n font-size: 1.2em;\n line-height: 1.6;\n font-family: cursive, serif;\n font-style: italic;\n margin-bottom: 15px;\n}\n\n.clepit-output-quote-content {\n /* Content styling handled by parent */\n}\n\n/* Output quote link styles */\n.clepit-output-quote a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-quote a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output quote inline code styling */\n.clepit-output-quote code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n.clepit-output-quote cite code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n/* Output quote marker brush effect */\n.clepit-output-quote mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-quote mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n.clepit-output-quote cite mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-quote cite mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n",ka=class e{static{this.placeholder="Enter quote..."}static{this.authorPlaceholder="Enter author..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${l.classNames.block.quote.text}`),n=e.querySelector(`.${l.classNames.block.quote.author}`);return{author:m(n?.innerHTML),html:m(t?.innerHTML)}}static render(t,n,a){l.injectStyles("clepit-quote-input-styles",ya);const o=n||{author:"",html:""},i=l.createStyledElement("div",l.classNames.block.quote.container,{classNames:a?.classNames?.container,styles:a?.styles?.container}),r=l.createStyledElement("div",l.classNames.block.quote.text,{classNames:a?.classNames?.text,styles:a?.styles?.text}),s=l.createStyledElement("div",l.classNames.block.quote.author,{classNames:a?.classNames?.author,styles:a?.styles?.author});if(r.innerHTML=m(o.html),r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",ne(t,"quoteBodyHint",e.placeholder)),s.innerHTML=m(o.author),s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",ne(t,"quoteAuthorHint",e.authorPlaceholder)),e.addEventListener(t,r,"keydown",e.handleKeydown),e.addEventListener(t,r,"input",Ds.handleInput),e.addEventListener(t,s,"keydown",e.handleKeydown),e.addEventListener(t,s,"input",Ds.handleInput),i.appendChild(r),o.author){const e=l.createStyledElement("div",l.classNames.block.quote.divider,{classNames:a?.classNames?.divider,styles:a?.styles?.divider});i.appendChild(e)}return i.appendChild(s),i}static handleKeydown(e){const t=e,n=e.currentTarget,a=n.closest(`.${l.classNames.block.container}`),o=Ds.getEditorId(a);if(!o)return;const i=Ds.getBlockIndex(o,a.getAttribute("data-id")),r=a.querySelector(`.${l.classNames.block.quote.text}`),s=a.querySelector(`.${l.classNames.block.quote.author}`),c=t.metaKey||t.ctrlKey;if(t.shiftKey)switch(t.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),i>0&&Ds.moveBlock(o,i,i-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const t=Ds.getBlocks(o);t&&i<t.length-1&&Ds.moveBlock(o,i,i+1)}else if(c)switch(t.key){case"Delete":case"Backspace":e.preventDefault(),e.stopPropagation(),Ds.removeBlock(o,i)}else if("Enter"===t.key)t.preventDefault(),t.stopPropagation(),Ds.insertBlock({data:{html:""},type:"paragraph"},o,i+1);else if("Backspace"===t.key){if(!h(n.innerHTML))return;t.preventDefault(),t.stopPropagation(),n===r?Ds.removeBlock(o,i):n===s&&(h(r.innerHTML)?Ds.removeBlock(o,i):r.focus())}else if("ArrowUp"===t.key)if(t.preventDefault(),t.stopPropagation(),n===r){const e=a.previousElementSibling;e&&Ds.focusBlock(e)}else r.focus();else if("ArrowDown"===t.key)if(t.preventDefault(),t.stopPropagation(),n===s){const e=a.nextElementSibling;e&&Ds.focusBlock(e)}else s.focus()}static handleKeydownInAuthorInput(e){const t=e,n=e.currentTarget,a=n.closest(`.${l.classNames.block.container}`),o=Ds.getEditorId(a);if(o)if("Enter"!==t.key||t.shiftKey){if("Backspace"===t.key){if(n.innerHTML?.trim()&&"<br>"!==n.innerHTML.trim())return;t.preventDefault(),t.stopPropagation();const e=a.querySelector(`.${l.classNames.block.quote.text}`);e&&e.focus()}}else{t.preventDefault(),t.stopPropagation();const e=Ds.getBlockIndex(o,a.getAttribute("data-id"));Ds.insertBlock({data:{html:""},type:"paragraph"},o,e+1)}}static isEmpty(e){const t=e.querySelector(`.${l.classNames.block.quote.text}`),n=e.querySelector(`.${l.classNames.block.quote.author}`);let a=!1,o=!1;return t?h(t.innerHTML)&&(a=!0):a=!0,n?h(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return h(e.html)&&h(e.author)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},wa=class e{static render(t,n,a,o){if(l.injectStyles("clepit-quote-output-styles",xa),!e.validate(t))return X();if(ka.isEmptyData(t))return document.createElement("div");const i=t.author||"",r=l.createStyledElement("div","clepit-output-quote-container",{classNames:o?.container,styles:a?.container}),s=l.createStyledElement("div","clepit-output-quote-text",{classNames:o?.text,styles:a?.text}),c=p("div","clepit-output-quote-content");if(c.innerHTML=m(t.html),s.appendChild(c),r.appendChild(s),i){const e=l.createStyledElement("div","clepit-output-quote-divider",{classNames:o?.divider,styles:a?.divider});r.appendChild(e);const t=l.createStyledElement("div","clepit-output-quote-author",{classNames:o?.author,styles:a?.author});t.textContent=`— ${i}`,r.appendChild(t)}return r.querySelectorAll(`span.${l.classNames.block.tooltip}[data-tooltip]`).forEach(e=>{const t=e;t.hasAttribute("data-tooltip-initialized")||(ke(t,String(t.getAttribute("data-tooltip")||""),"above",n?.tooltipClassNames,void 0),t.setAttribute("data-tooltip-initialized","true"))}),r}static draw(t,n=R){if(!e.validate(t)||ka.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-quote-container");const o=n.create("div");o.addClass("clepit-output-quote-text");const i=n.create("div");if(i.addClass("clepit-output-quote-content"),t.html?.trim()&&i.setHtml(t.html),o.append(i),a.append(o),t.author){const e=n.create("div");e.addClass("clepit-output-quote-divider"),a.append(e);const o=n.create("div");o.addClass("clepit-output-quote-author"),o.setText(`— ${t.author}`),a.append(o)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},Ca="\n.clepit-sketch {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n overflow: hidden;\n}\n.clepit-sketch__canvas {\n display: block;\n width: 100%;\n height: 240px;\n touch-action: none;\n}\n.clepit-sketch--input .clepit-sketch__canvas {\n cursor: crosshair;\n}\n",Aa=Ca,Sa=Ca,Ea="http://www.w3.org/2000/svg";function La(e){return e&&/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(e.trim())?e.trim():"#000000"}function Na(e){if(e.length<4)return"";const t=[`M ${e[0]} ${e[1]}`];for(let n=2;n+1<e.length;n+=2)t.push(`L ${e[n]} ${e[n+1]}`);return t.join(" ")}var Ba=class e{static render(t,n,a,o){if(l.injectStyles("sketch-output",Sa),!e.validate(t))return X();const i=l.createStyledElement("div","clepit-sketch clepit-output-sketch",{classNames:o?.wrapper,styles:a?.wrapper}),r=document.createElementNS(Ea,"svg");r.setAttribute("class","clepit-sketch__canvas"),r.setAttribute("viewBox","0 0 1000 240"),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("role","img");for(const s of t.strokes??[]){const t=Na(s.points??[]);if(!t)continue;const n=document.createElementNS(Ea,"path");n.setAttribute("d",t),n.setAttribute("fill","none"),n.setAttribute("stroke",La(s.color)),n.setAttribute("stroke-width",String(e.safeWidth(s))),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),r.appendChild(n)}return i.appendChild(r),i}static draw(t,n=R){if(!e.validate(t))return null;const a=n.create("div");a.addClass("clepit-sketch","clepit-output-sketch");const o=n.createNS(Ea,"svg");o.setAttribute("class","clepit-sketch__canvas"),o.setAttribute("viewBox","0 0 1000 240"),o.setAttribute("preserveAspectRatio","none"),o.setAttribute("role","img");for(const i of t.strokes??[]){const t=Na(i.points??[]);if(!t)continue;const a=n.createNS(Ea,"path");a.setAttribute("d",t),a.setAttribute("fill","none"),a.setAttribute("stroke",La(i.color)),a.setAttribute("stroke-width",String(e.safeWidth(i))),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),o.append(a)}return a.append(o),a}static safeWidth(e){const t=Number(e.width);return Number.isFinite(t)&&t>0&&t<=64?t:2}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.strokes)}},Ma=`\n/* Table block styles */\n.clepit-table-container {\n position: relative;\n display: block;\n max-width: 100%;\n overflow-x: auto;\n overflow-y: visible; /* allow buttons to be visible outside */\n margin: 16px 0;\n padding: 20px;\n}\n\n.clepit-table {\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n background: var(--clepit-bg);\n border-radius: var(--clepit-radius-md);\n border: 1px solid var(--clepit-border);\n}\n\n.clepit-table-controls {\n display: flex;\n gap: 6px;\n margin: 6px 0;\n}\n\n.clepit-table-btn {\n border: 1px solid var(--clepit-border);\n background: var(--clepit-surface);\n border-radius: 4px;\n padding: 2px 6px;\n font-size: 12px;\n color: var(--clepit-text);\n cursor: pointer;\n}\n\n.clepit-table-btn:hover {\n background: var(--clepit-surface-2);\n}\n\n.clepit-table-corner {\n width: 28px;\n min-width: 28px;\n border-right: 1px solid var(--clepit-border);\n}\n\n.${l.classNames.block.table.headerCell} {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n border-right: 1px solid var(--clepit-border);\n padding: 10px 12px;\n font-weight: 600;\n min-width: 120px;\n vertical-align: top;\n text-align: left;\n position: relative;\n}\n\n.${l.classNames.block.table.cell} {\n border-right: 1px solid var(--clepit-border);\n border-bottom: 1px solid var(--clepit-border);\n padding: 10px 12px;\n min-width: 120px;\n vertical-align: top;\n text-align: left;\n}\n\n/* Zebra striping: odd white, even light grey */\n.clepit-table-tbody tr:nth-child(odd) .${l.classNames.block.table.cell} {\n background: var(--clepit-bg);\n}\n\n.clepit-table-tbody tr:nth-child(even) .${l.classNames.block.table.cell} {\n background: var(--clepit-surface);\n}\n\n.${l.classNames.block.table.caption} {\n margin: 8px 0 0 0; /* full width, no horizontal margins */\n width: 100%;\n padding: 10px 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n background: var(--clepit-surface);\n font-size: 13px;\n outline: none;\n flex: 1;\n min-width: 0;\n}\n\n.${l.classNames.block.table.caption}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: rgba(0, 0, 0, 0.6);\n font-style: italic;\n}\n\n/* Table Download Switch Container */\n.clepit-table-download-switch {\n margin: 8px 0 0 0;\n padding: 6px 8px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 13px;\n}\n\n.${l.classNames.block.table.headerCell}:focus,\n.clepit-table-cell:focus {\n outline: 2px solid var(--clepit-primary);\n outline-offset: -2px;\n}\n\n/* Table placeholder styles */\n.${l.classNames.block.table.headerCell}[data-placeholder]:empty::before,\n.${l.classNames.block.table.cell}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Table container */\n.clepit-table-container {\n overflow: visible;\n position: relative;\n}\n\n.clepit-table-scroll-container {\n overflow-x: auto;\n overflow-y: visible;\n max-width: 100%;\n}\n\n/* Table caption download container */\n.clepit-table-caption-download-container {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-top: 8px;\n}\n\n.clepit-table-download-switch {\n flex-shrink: 0;\n}\n\n`,$a="\n/* Output table styles */\n.clepit-output-table-container {\n margin: 1rem 0;\n overflow-x: auto;\n}\n\n.clepit-output-table {\n width: 100%;\n border-collapse: collapse;\n border: 0;\n overflow: hidden;\n background: var(--clepit-bg);\n}\n\n/* House style: rows carry no horizontal dividers and no column rules. Rows are\n * told apart by zebra striping, which is what does that job instead — removing\n * the rules is not a licence to remove the banding too. */\n/* These four rules were assigned from JavaScript, one element at a time, which\n * is a browser call inside a render path. In a stylesheet they cost nothing to\n * a page that draws without a browser, and a caller's own inline style still\n * wins over them exactly as it did before. */\n.clepit-output-table-wrapper {\n overflow: hidden;\n width: 100%;\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n margin-bottom: 1rem;\n}\n\n.clepit-output-table-scroller {\n overflow-x: auto;\n}\n\n.clepit-output-table {\n table-layout: auto;\n margin-top: 0;\n margin-bottom: 0;\n border-radius: 0;\n}\n\n.clepit-output-table th,\n.clepit-output-table td {\n padding: 10px 12px;\n text-align: left;\n min-width: 120px;\n max-width: 400px;\n}\n\n.clepit-output-table th {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n color: var(--clepit-text);\n font-weight: 600;\n}\n\n.clepit-output-table tbody tr:nth-child(odd) {\n background: var(--clepit-bg);\n}\n\n.clepit-output-table tbody tr:nth-child(even) {\n background: var(--clepit-surface);\n}\n\n/* No hover state: a rendered table is display, not a control. A row that\n * changes colour under the pointer reads as clickable when it is not. */\n\n/* Table Output Caption */\n.clepit-output-table-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Make footer cell neutral so caption styles are visible */\n.clepit-output-table tfoot td,\n.clepit-output-table tfoot .clepit-output-table-caption-cell {\n padding: 0;\n border: 0;\n background: transparent;\n}\n\n.clepit-output-table-download-btn {\n margin-left: auto;\n width: 24px;\n height: 24px;\n border: none;\n outline: none;\n cursor: pointer;\n border-radius: 50%;\n background: transparent;\n transition: background-color 0.2s ease, transform 0.2s ease;\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.clepit-output-table-download-btn:hover {\n background: var(--clepit-bg);\n}\n\n.clepit-output-table-download-btn:hover .clepit-download-icon {\n stroke: var(--clepit-primary);\n}\n\n.clepit-output-table-download-btn:active {\n transform: scale(0.95);\n}\n\n.clepit-download-icon {\n width: 20px;\n height: 20px;\n stroke: var(--clepit-text-muted);\n transition: stroke 0.2s ease;\n}\n\n.clepit-output-table-footer-container {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 8px 12px;\n background: var(--clepit-surface);\n border-top: 1px solid var(--clepit-border);\n}\n";function Ia(){if("undefined"==typeof navigator)return"unknown";const e=navigator.platform.toLowerCase(),t=navigator.userAgent.toLowerCase();return e.includes("mac")||t.includes("mac")?"mac":e.includes("win")||t.includes("win")?"windows":e.includes("linux")||t.includes("linux")?"linux":"unknown"}function Ta(){return"mac"===Ia()?"⌘":"Ctrl"}function _a(){return"mac"===Ia()?"⌥":"Alt"}function qa(e){return"mac"===Ia()?e.join(""):e.join(" + ")}var Da=e=>qa([Ta(),e]),za=e=>qa([Ta(),{down:"↓",left:"←",right:"→",up:"↑"}[e]]),ja=()=>qa([Ta(),"B"]),Ha=()=>qa([Ta(),"⌫"]),Oa=()=>qa([Ta(),"⌦"]),Pa=()=>qa([Ta(),"I"]),Ra=()=>qa([Ta(),"K"]),Fa=e=>qa([Ta(),_a(),e]),Va=()=>qa([Ta(),"U"]),Ua=class e{static{this.defaultCols=3}static{this.defaultRows=3}static{this.headerPlaceholder="Enter header..."}static{this.cellPlaceholder="Enter text..."}static{this.captionPlaceholder="Add a caption..."}static{this.defaultData={caption:"",data:Array.from({length:e.defaultRows},()=>Array.from({length:e.defaultCols},()=>"")),showDownload:!1}}static{this.eventListenersMap={}}static addEventListener(t,n,a,o,i){n.addEventListener(a,o,i);const r=e.eventListenersMap[t]||[];r.push({element:n,event:a,handler:o,options:i}),e.eventListenersMap[t]=r}static save(t){const n=t.querySelector("table");if(!n)return e.defaultData;const a=n.querySelector("thead tr"),o=a?Array.from(a.querySelectorAll(`.${l.classNames.block.table.headerCell}`)):[],i=[],r=[];for(const e of o)r.push(m(e.innerHTML));i.push(r);const s=n.querySelectorAll("tbody tr");for(const e of Array.from(s)){const t=Array.from(e.querySelectorAll(`.${l.classNames.block.table.cell}`)),n=[];for(const e of t)n.push(m(e.innerHTML));i.push(n)}const c=(t.querySelector(".clepit-table-download-switch")?.querySelector('input[type="checkbox"]'))?.checked||!1;return{caption:m(t.querySelector(`.${l.classNames.block.table.caption}`)?.innerHTML||""),data:i,showDownload:c}}static render(t,n,a){l.injectStyles("clepit-table-input-styles",Ma);const o=n?{...e.defaultData,...n}:e.defaultData,i=l.createStyledElement("div","clepit-table-container",{classNames:a?.classNames?.container,styles:a?.styles?.container}),r=l.createStyledElement("table","clepit-table",{classNames:a?.classNames?.table,styles:a?.styles?.table}),s=l.createStyledElement("thead","clepit-table-thead",{classNames:a?.classNames?.table,styles:a?.styles?.table}),c=e.createRow(t,o.data[0],!0);s.appendChild(c),r.appendChild(s);const d=l.createStyledElement("tbody","clepit-table-tbody",{classNames:a?.classNames?.table,styles:a?.styles?.table});for(let l=1;l<o.data.length;l++){const n=e.createRow(t,o.data[l]);d.appendChild(n)}r.appendChild(d);const p=l.createStyledElement("div","clepit-table-scroll-container");p.appendChild(r),i.appendChild(p);const u=l.createStyledElement("button","clepit-table-btn clepit-row-menu-btn",{classNames:a?.classNames?.rowMenuButton,styles:a?.styles?.rowMenuButton});u.style.position="absolute",u.style.display="none",u.style.zIndex="1000",u.textContent="⋮",u.setAttribute("aria-label",ne(t,"tableRowActions","Row actions")),i.appendChild(u);const h=l.createStyledElement("button","clepit-table-btn clepit-col-menu-btn",{classNames:a?.classNames?.columnMenuButton,styles:a?.styles?.columnMenuButton});h.style.position="absolute",h.style.display="none",h.style.zIndex="1000",h.textContent="⋯",h.setAttribute("aria-label",ne(t,"tableColumnActions","Column actions")),i.appendChild(h);let g=null,b=-1,f=null;e.addEventListener(t,i,"mouseleave",()=>(u.style.display="none",h.style.display="none",void(f&&(f.remove(),f=null))));const v=e=>{g=e;const t=e.getBoundingClientRect(),n=i.getBoundingClientRect(),a=t.top-n.top+t.height/2-12;u.style.left="4px",u.style.top=`${Math.max(4,a)}px`,u.style.display="flex"},y=e=>{if(b=Array.from(c.querySelectorAll(`.${l.classNames.block.table.headerCell}`)).indexOf(e),b<0)return;const t=e.getBoundingClientRect(),n=i.getBoundingClientRect(),a=t.left-n.left+t.width/2-12,o=t.top-n.top-20;h.style.left=`${a}px`,h.style.top=`${Math.max(4,o)}px`,h.style.display="flex"};e.addEventListener(t,d,"mouseover",e=>{const t=e.target.closest("tr");t&&v(t)}),e.addEventListener(t,s,"mouseover",e=>{const t=e.target.closest(`.${l.classNames.block.table.headerCell}`);t&&y(t)}),e.addEventListener(t,d,"mouseover",e=>{const t=e.target.closest(`.${l.classNames.block.table.cell}`);if(!t)return;const n=t.closest("tr");if(!n)return;const a=Array.from(n.querySelectorAll(`.${l.classNames.block.table.cell}`)).indexOf(t);if(a>=0){const e=c.querySelectorAll(`.${l.classNames.block.table.headerCell}`)[a];e&&y(e)}v(n)});const x=()=>{g&&"none"!==u.style.display&&v(g);const e=c.querySelectorAll(`.${l.classNames.block.table.headerCell}`)[b];e&&"none"!==h.style.display&&y(e)};e.addEventListener(t,window,"scroll",x,{passive:!0}),e.addEventListener(t,p,"scroll",x,{passive:!0}),e.addEventListener(t,u,"click",n=>{if(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation?.(),!g)return;const o=Array.from(d.querySelectorAll("tr")),r=o.indexOf(g),s=u.getBoundingClientRect(),p=i.getBoundingClientRect();e.createMenu(t,i,u,h,[{icon:"↑",label:ne(t,"moveUp","Move up"),onClick:()=>{r>0&&(d.insertBefore(g,o[r-1]),Ds.saveBlockData(g))},shortcut:za("up"),testId:"table-row-move-up"},{icon:"↓",label:ne(t,"moveDown","Move down"),onClick:()=>{r>=0&&r<o.length-1&&(d.insertBefore(o[r+1],g),Ds.saveBlockData(g))},shortcut:za("down"),testId:"table-row-move-down"},{icon:"+",label:ne(t,"tableInsertAbove","Insert above"),onClick:()=>{const n=c.querySelectorAll(`.${l.classNames.block.table.headerCell}`).length||3,a=e.createRow(t,Array.from({length:n},()=>""));d.insertBefore(a,g),Ds.saveBlockData(g)},testId:"table-row-insert-above"},{icon:"+",label:ne(t,"tableInsertBelow","Insert below"),onClick:()=>{const n=c.querySelectorAll(`.${l.classNames.block.table.headerCell}`).length||3,a=e.createRow(t,Array.from({length:n},()=>""));g.nextSibling?d.insertBefore(a,g.nextSibling):d.appendChild(a),Ds.saveBlockData(g)},testId:"table-row-insert-below"},{icon:"×",isDanger:!0,label:ne(t,"delete","Delete"),onClick:()=>{o.length>1&&(g.remove(),Ds.saveBlockData(g))},shortcut:Ha(),testId:"table-row-delete"}],s.left-p.left,s.bottom-p.top+4,a,f)}),e.addEventListener(t,h,"click",n=>{if(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation?.(),b<0)return;const o=Array.from(c.querySelectorAll(`.${l.classNames.block.table.headerCell}`)),r=h.getBoundingClientRect(),s=i.getBoundingClientRect();e.createMenu(t,i,u,h,[{icon:"←",label:ne(t,"tableMoveLeft","Move left"),onClick:()=>{if(b<=0)return;const e=b,t=o[e-1],n=o[e];t&&n&&c.insertBefore(n,t),d.querySelectorAll("tr").forEach(t=>{const n=Array.from(t.querySelectorAll(`.${l.classNames.block.table.cell}`)),a=n[e-1],o=n[e];a&&o&&t.insertBefore(o,a)}),b=e-1,Ds.saveBlockData(c)},shortcut:za("left"),testId:"table-column-move-left"},{icon:"→",label:ne(t,"tableMoveRight","Move right"),onClick:()=>{const e=b;if(e<0||e>=o.length-1)return;const t=o[e],n=o[e+1];t&&n&&c.insertBefore(n,t),d.querySelectorAll("tr").forEach(t=>{const n=Array.from(t.querySelectorAll(`.${l.classNames.block.table.cell}`)),a=n[e],o=n[e+1];a&&o&&t.insertBefore(o,a)}),b=e+1,Ds.saveBlockData(c)},shortcut:za("right"),testId:"table-column-move-right"},{icon:"+",label:ne(t,"tableInsertLeft","Insert left"),onClick:()=>{const n=b,a=e.createHeaderCell(t,"");c.insertBefore(a,o[n]),d.querySelectorAll("tr").forEach(a=>{const o=e.createCell(t,""),i=a.querySelectorAll(`.${l.classNames.block.table.cell}`);i[n]?a.insertBefore(o,i[n]):a.appendChild(o)}),Ds.saveBlockData(c)},testId:"table-column-insert-left"},{icon:"+",label:ne(t,"tableInsertRight","Insert right"),onClick:()=>{const n=b+1,a=o[b]?.nextSibling||null,i=e.createHeaderCell(t,"");c.insertBefore(i,a),d.querySelectorAll("tr").forEach(a=>{const o=e.createCell(t,""),i=a.querySelectorAll(`.${l.classNames.block.table.cell}`);i[n]?a.insertBefore(o,i[n]):a.appendChild(o)}),Ds.saveBlockData(c)},testId:"table-column-insert-right"},{icon:"×",isDanger:!0,label:ne(t,"delete","Delete"),onClick:()=>{const e=c.querySelectorAll(`.${l.classNames.block.table.headerCell}`);if(b<0||e.length<=1)return;const t=e[b];t?.parentElement?.removeChild(t),d.querySelectorAll("tr").forEach(e=>{const t=e.querySelectorAll(`.${l.classNames.block.table.cell}`);t[b]&&t[b].parentElement?.removeChild(t[b])}),Ds.saveBlockData(c)},shortcut:Oa(),testId:"table-column-delete"}],r.left-s.left,r.bottom-s.top+4,a,f)});Array.from(d.querySelectorAll("tr")).forEach(n=>(n=>{e.addEventListener(t,n,"mouseenter",()=>v(n))})(n)),Array.from(c.querySelectorAll(`.${l.classNames.block.table.headerCell}`)).forEach(n=>{return a=n,void e.addEventListener(t,a,"mouseenter",()=>y(a));var a});const k=l.createStyledElement("div","clepit-table-caption-download-container",{classNames:a?.classNames?.container,styles:a?.styles?.container});k.style.display="flex",k.style.alignItems="center",k.style.gap="8px",k.style.marginTop="8px";const w=l.createStyledElement("div",`${l.classNames.block.table.caption}`,{classNames:a?.classNames?.caption,styles:a?.styles?.caption});w.contentEditable="true",w.setAttribute("tabindex","0"),w.setAttribute("data-placeholder",ne(t,"tableCaptionHint",e.captionPlaceholder)),w.style.flex="1",w.style.minWidth="0",w.innerHTML=m(o.caption),e.addEventListener(t,w,"input",Ds.handleInput),e.addEventListener(t,w,"keydown",e.handleKeydown),e.addEventListener(t,w,"click",e.handleClick),k.appendChild(w);const A=l.createStyledElement("div",`${l.classNames.block.table.downloadSwitch}`);A.style.flexShrink="0";const S=me.create({checked:o.showDownload||!1,label:ne(t,"tableAllowDownload","Allow download"),offLabel:ne(t,"switchOff","Off"),onLabel:ne(t,"switchOn","On"),onToggle:e=>{const n=i.closest(`.${l.classNames.block.container}`);if(n){const a=n.getAttribute("data-id");a&&C.getState().partialUpdateBlockData(t,Ds.getBlockIndex(t,a),{showDownload:e})}}});A.appendChild(S),k.appendChild(A),i.appendChild(k);return e.addEventListener(t,i,"focusin",()=>{const e=document.activeElement;if(e&&i.contains(e))if(e.classList.contains(l.classNames.block.table.cell)){const t=e.closest("tr");t&&(g=t,v(t))}else e.classList.contains(l.classNames.block.table.headerCell)&&y(e)}),i}static createRow(t,n,a){const o=C.getState().getInstance(t),i=o?.config.classNames?.blocks?.table?.row,r=o?.config.styles?.blocks?.table?.row,s=l.createStyledElement("tr",a?`${l.classNames.block.table.headerRow}`:`${l.classNames.block.table.row}`,{classNames:i,styles:r});for(let l=0;l<n.length;l++)s.appendChild(a?e.createHeaderCell(t,n[l]):e.createCell(t,n[l]));return s.querySelector(`.${l.classNames.block.table.cell}`)?.focus(),s}static createCell(t,n){const a=C.getState().getInstance(t),o=a?.config.classNames?.blocks?.table?.cell,i=a?.config.styles?.blocks?.table?.cell,r=l.createStyledElement("td",`${l.classNames.block.table.cell}`,{classNames:o,styles:i});return r.contentEditable="true",r.setAttribute("tabindex","0"),r.setAttribute("data-placeholder",ne(t,"tableCellHint",e.cellPlaceholder)),r.innerHTML=m(n),e.addEventListener(t,r,"input",Ds.handleInput),e.addEventListener(t,r,"keydown",e.handleKeydown),e.addEventListener(t,r,"click",e.handleClick),r}static createHeaderCell(t,n){const a=C.getState().getInstance(t),o=a?.config.classNames?.blocks?.table?.header,i=a?.config.styles?.blocks?.table?.header,r=l.createStyledElement("th",`${l.classNames.block.table.headerCell}`,{classNames:o,styles:i});return r.contentEditable="true",r.setAttribute("tabindex","0"),r.setAttribute("data-placeholder",ne(t,"tableHeaderHint",e.headerPlaceholder)),r.innerHTML=m(n),e.addEventListener(t,r,"input",Ds.handleInput),e.addEventListener(t,r,"keydown",e.handleKeydown),e.addEventListener(t,r,"click",e.handleClick),r}static handleAction(t,n){const a=n.querySelector("table");if(a)switch(t){case"addRow":return e.addRow(a);case"removeRow":return e.removeRow(a);case"addColumn":return e.addColumn(a);case"removeColumn":return e.removeColumn(a)}}static addRow(t){const n=t.querySelector("tbody");if(!n)return;const a=Ds.getEditorId(t);if(!a)return;const o=t.querySelector("thead tr")?.querySelectorAll("th").length||e.defaultData.data[0].length,i=e.createRow(a,Array.from({length:o},()=>""));n.appendChild(i)}static removeRow(e){const t=e.querySelector("tbody");if(!t)return;const n=t.querySelectorAll("tr");n.length>1&&t.removeChild(n[n.length-1])}static addColumn(t){const n=Ds.getEditorId(t);if(!n)return;const a=t.querySelector("thead tr"),o=t.querySelector("tbody");if(!a||!o)return;const i=e.createHeaderCell(n,"");a.appendChild(i),o.querySelectorAll("tr").forEach(t=>{const a=e.createCell(n,"");t.appendChild(a)})}static removeColumn(e){const t=e.querySelector("thead tr"),n=e.querySelector("tbody");if(!t||!n)return;const a=t.querySelectorAll("th");a.length>1&&(t.removeChild(a[a.length-1]),n.querySelectorAll("tr").forEach(e=>{const t=e.querySelectorAll("td");t.length>1&&e.removeChild(t[t.length-1])}))}static createMenu(t,n,a,o,i,r,s,c,d){d&&(d.remove(),d=null);const p=l.createStyledElement("div","clepit-block-operations-menu clepit-table-menu",{classNames:c?.classNames?.menu,styles:c?.styles?.menu});p.classList.add("clepit-block-operations-menu--visible"),p.style.position="absolute",p.style.zIndex="20",p.style.left=`${r}px`,p.style.top=`${s}px`,p.style.minWidth="180px",i.forEach(n=>{const a=l.createStyledElement("div","clepit-menu-item"+(n.isDanger?" clepit-menu-item--danger":""),{classNames:c?.classNames?.menuItem,styles:c?.styles?.menuItem});a.setAttribute("data-testid",n.testId),a.style.fontSize="14px";const o=l.createStyledElement("span","clepit-menu-icon");o.textContent=n.icon;const i=l.createStyledElement("span","clepit-menu-text");if(i.textContent=n.label,a.appendChild(o),a.appendChild(i),n.shortcut){const e=l.createStyledElement("span","clepit-menu-shortcut");e.style.marginLeft="auto",e.style.fontSize="9px",e.style.color="#666",e.style.opacity="0.7",e.textContent=n.shortcut,a.appendChild(e)}e.addEventListener(t,a,"click",e=>{e.stopPropagation(),e.stopImmediatePropagation?.(),n.onClick(),d&&(d.remove(),d=null)}),p.appendChild(a)}),n.appendChild(p),d=p;const u=e=>{p.contains(e.target)||e.target===a||e.target===o||(p.remove(),d=null,document.removeEventListener("click",u))};return setTimeout(()=>document.addEventListener("click",u),0),p}static handleClick(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget.closest(`.${l.classNames.block.container}`);t&&Ds.setActiveBlock(t)}static handleKeydown(e){const t=e,n=e.currentTarget,a=Ds.getEditorId(n);if(!a)return;const o=n.closest(`.${l.classNames.block.container}`);if(!o)return;const i=Ds.getBlockIndex(a,o.getAttribute("data-id")),r=t.metaKey||t.ctrlKey;if(t.shiftKey)switch(t.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),i>0&&Ds.moveBlock(a,i,i-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const t=Ds.getBlocks(a);t&&i<t.length-1&&Ds.moveBlock(a,i,i+1)}else if(r){const o=n.closest("table"),r=o.querySelector("tbody"),s=o.querySelector("thead tr");switch(t.key){case"ArrowUp":if(n.classList.contains(l.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr"),a=Array.from(r.querySelectorAll("tr")),o=a.indexOf(t);if(o>0){const e=Array.from(t.querySelectorAll(`.${l.classNames.block.table.cell}`)).indexOf(n);r.insertBefore(t,a[o-1]),Ds.saveBlockData(t);const i=t.querySelectorAll(`.${l.classNames.block.table.cell}`)[e];i&&i.focus()}}break;case"ArrowDown":if(n.classList.contains(l.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr"),a=Array.from(r.querySelectorAll("tr")),o=a.indexOf(t);if(o>=0&&o<a.length-1){const e=Array.from(t.querySelectorAll(`.${l.classNames.block.table.cell}`)).indexOf(n);r.insertBefore(a[o+1],t),Ds.saveBlockData(t);const i=t.querySelectorAll(`.${l.classNames.block.table.cell}`)[e];i&&i.focus()}}break;case"ArrowLeft":let t=-1;const c=Array.from(s.querySelectorAll(`.${l.classNames.block.table.headerCell}`));if(n.classList.contains(l.classNames.block.table.headerCell))t=c.indexOf(n);else if(n.classList.contains(l.classNames.block.table.cell)){const e=n.closest("tr");t=Array.from(e.querySelectorAll(`.${l.classNames.block.table.cell}`)).indexOf(n)}if(t>0){e.preventDefault(),e.stopPropagation();const a=t,i=c[a-1],r=c[a];if(i&&r&&s.insertBefore(r,i),o.querySelectorAll("tbody tr").forEach(e=>{const t=Array.from(e.querySelectorAll(`.${l.classNames.block.table.cell}`)),n=t[a-1],o=t[a];n&&o&&e.insertBefore(o,n)}),n.classList.contains(l.classNames.block.table.cell)){const e=n.closest("tr").querySelectorAll(`.${l.classNames.block.table.cell}`)[a-1];e&&e.focus()}else{r&&r.focus()}Ds.saveBlockData(s)}break;case"ArrowRight":let d=-1;const p=Array.from(s.querySelectorAll(`.${l.classNames.block.table.headerCell}`));if(n.classList.contains(l.classNames.block.table.headerCell))d=p.indexOf(n);else if(n.classList.contains(l.classNames.block.table.cell)){const e=n.closest("tr");d=Array.from(e.querySelectorAll(`.${l.classNames.block.table.cell}`)).indexOf(n)}if(d<p.length-1){e.preventDefault(),e.stopPropagation();const t=d,a=p[t],i=p[t+1];if(a&&i&&s.insertBefore(i,a),o.querySelectorAll("tbody tr").forEach(e=>{const n=Array.from(e.querySelectorAll(`.${l.classNames.block.table.cell}`)),a=n[t],o=n[t+1];a&&o&&e.insertBefore(o,a)}),n.classList.contains(l.classNames.block.table.cell)){const e=n.closest("tr").querySelectorAll(`.${l.classNames.block.table.cell}`)[t+1];e&&e.focus()}else{i&&i.focus()}Ds.saveBlockData(s)}break;case"Backspace":if(n.classList.contains(l.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr");Array.from(r.querySelectorAll("tr")).length>1&&(t.remove(),Ds.saveBlockData(t))}else e.preventDefault(),e.stopPropagation(),Ds.removeBlock(a,i);break;case"Delete":let u=-1;const h=Array.from(s.querySelectorAll(`.${l.classNames.block.table.headerCell}`));if(n.classList.contains(l.classNames.block.table.headerCell))u=h.indexOf(n);else if(n.classList.contains(l.classNames.block.table.cell)){const e=n.closest("tr");u=Array.from(e.querySelectorAll(`.${l.classNames.block.table.cell}`)).indexOf(n)}if(u>=0&&h.length>1){e.preventDefault(),e.stopPropagation();const t=h[u];t?.parentElement?.removeChild(t),o.querySelectorAll("tbody tr").forEach(e=>{const t=e.querySelectorAll(`.${l.classNames.block.table.cell}`);t[u]&&t[u].parentElement?.removeChild(t[u])}),Ds.saveBlockData(s)}else e.preventDefault(),e.stopPropagation(),Ds.removeBlock(a,i)}}else if("Enter"===t.key)e.preventDefault(),e.stopPropagation(),Ds.insertBlock({data:{html:""},type:"paragraph"},a,i+1);else if("Backspace"===t.key){const t=n.closest(`.${l.classNames.block.container}`);if(!t)return;Array.from(t.querySelectorAll(`.${l.classNames.block.table.cell},.${l.classNames.block.table.headerCell}`)).every(e=>h(e.innerHTML))&&(e.preventDefault(),e.stopPropagation(),Ds.removeBlock(a,i))}else{Ds.ensureActiveBlock(a);const o=Ds.getBlocks(a);switch(t.key){case"ArrowUp":if(e.preventDefault(),e.stopPropagation(),n.classList.contains(l.classNames.block.table.caption)){const e=n.closest(`.${l.classNames.block.container}`)?.querySelector("table");if(e){const t=e.querySelector("tbody")?.lastElementChild;if(t&&t.cells.length>0){const e=t.cells[t.cells.length-1];return void(e&&e.focus())}}}const t=n.closest("table");if(!t)return;const a=n.closest("tr"),r=Array.from(a?.cells||[]).indexOf(n);if("TBODY"===a?.parentElement?.tagName&&a===a.parentElement.firstElementChild){const e=t.querySelector("thead")?.querySelector("tr");if(e&&e.cells[r])return void e.cells[r].focus()}if(a?.previousElementSibling){const e=a.previousElementSibling.cells[r];e&&e.focus()}else if(i>0){const e=o[i-1];e&&Ds.focusBlock(e)}return;case"ArrowDown":if(e.preventDefault(),e.stopPropagation(),n.classList.contains(l.classNames.block.table.caption)){if(i<o.length-1){const e=o[i+1];e&&Ds.focusBlock(e)}return}const s=n.closest("table");if(!s)return;const c=n.closest("tr"),d=Array.from(c?.cells||[]).indexOf(n);if("THEAD"===c?.parentElement?.tagName){const e=s.querySelector("tbody")?.firstElementChild;if(e&&e.cells[d])return void e.cells[d].focus()}if(c?.nextElementSibling){const e=c.nextElementSibling.cells[d];e&&e.focus()}else{if("TBODY"===c?.parentElement?.tagName&&c===c.parentElement.lastElementChild){const e=s.closest(`.${l.classNames.block.container}`)?.querySelector(`.${l.classNames.block.table.caption}`);if(e)return void e.focus()}if(i<o.length-1){const e=o[i+1];e&&Ds.focusBlock(e)}}return;case"ArrowLeft":if(!g(n,"left"))return;e.preventDefault(),e.stopPropagation();const p=n.closest("table");if(!p)return;const u=n.closest("tr"),h=Array.from(u?.cells||[]).indexOf(n);if(h>0){const e=u?.cells[h-1];e&&e.focus()}else{if("TBODY"===u?.parentElement?.tagName&&u===u.parentElement.firstElementChild){const e=p.querySelector("thead")?.querySelector("tr");if(e&&e.cells.length>0){const t=e.cells[e.cells.length-1];return void(t&&t.focus())}}if(u?.previousElementSibling){const e=u.previousElementSibling,t=e.cells[e.cells.length-1];t&&t.focus()}}return;case"ArrowRight":if(!g(n,"right"))return;e.preventDefault(),e.stopPropagation();const m=n.closest("table");if(!m)return;const b=n.closest("tr"),f=Array.from(b?.cells||[]).indexOf(n);if(f<(b?.cells.length||0)-1){const e=b?.cells[f+1];e&&e.focus()}else{if("THEAD"===b?.parentElement?.tagName){const e=m.querySelector("tbody")?.firstElementChild;if(e&&e.cells.length>0){const t=e.cells[0];return void(t&&t.focus())}}if(b?.nextElementSibling){const e=b.nextElementSibling.cells[0];e&&e.focus()}}return}}}static isEmpty(e){const t=e.querySelector(`.${l.classNames.block.table.caption}`),n=e.querySelectorAll(`.${l.classNames.block.table.cell},.${l.classNames.block.table.headerCell}`);let a=!1,o=!1;return t?h(t.innerHTML)&&(a=!0):a=!0,n?Array.from(n).every(e=>h(e.innerHTML))&&(o=!0):o=!0,a&&o}static isEmptyData(e){return h(e.caption)&&e.data.every(e=>e.every(e=>h(e)))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Wa="http://www.w3.org/2000/svg",Ka=["M3 15C3 17.8284 3 19.2426 3.87868 20.1213C4.75736 21 6.17157 21 9 21H15C17.8284 21 19.2426 21 20.1213 20.1213C21 19.2426 21 17.8284 21 15","M12 3V16M12 16L16 11.625M12 16L8 11.625"],Ga=/^[=+@\t\r-]/,Ja=class e{static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static render(t,n,a,o,i){if(l.injectStyles("clepit-table-output-styles",$a),!e.validate(t))return X();if(Ua.isEmptyData(t))return document.createElement("div");const r=e.draw(t,R);if(!r)return document.createElement("div");const s=J(r);o?.container&&s.classList.add(o.container),a?.container&&Object.assign(s.style,a.container);const c=s.querySelector(".clepit-output-table-caption");c&&o?.caption&&c.classList.add(o.caption),c&&a?.caption&&Object.assign(c.style,a.caption);const d=s.querySelector(".clepit-output-table-footer-container");return d&&o?.footerContainer&&d.classList.add(o.footerContainer),d&&a?.footerContainer&&Object.assign(d.style,a.footerContainer),e.attach(s,t,a,o,i),s}static activate(t,n){return!e.validate(n)||Ua.isEmptyData(n)?()=>{}:e.attach(t,n)}static attach(t,n,a,o,i){const r=t.querySelector(".clepit-output-table-download-btn");if(!r)return()=>{};o?.downloadButton&&r.classList.add(o.downloadButton),a?.downloadButton&&Object.assign(r.style,a.downloadButton);const s=()=>e.downloadTableAsCSV(n);r.addEventListener("click",s);const l=i?document.getElementById(i):null;if(l){const t=e.eventListenersMap.get(l)??[];t.push({element:r,event:"click",handler:s}),e.eventListenersMap.set(l,t)}const c=i?C.getState().getInstance(i):null,d=ke(r,"Download CSV","above",c?.config.classNames?.tooltips,c?.config.styles?.tooltips);return()=>{r.removeEventListener("click",s),d()}}static draw(t,n=R){if(!e.validate(t)||Ua.isEmptyData(t))return null;const a=Array.isArray(t.data)&&t.data.length>0?t.data:[];if(0===a.length)return null;const o=n.create("div");o.addClass("clepit-output-table-wrapper");const i=n.create("div");i.addClass("clepit-output-table-scroller");const r=n.create("table");r.addClass("clepit-output-table");const s=n.create("thead"),l=n.create("tr");for(const e of a[0]??[]){const t=n.create("th");t.setText(e),l.append(t)}if(s.append(l),r.append(s),a.length>1){const e=n.create("tbody");for(const t of a.slice(1)){const a=n.create("tr");for(const e of t){const t=n.create("td");t.setText(e),a.append(t)}e.append(a)}r.append(e)}if(i.append(r),o.append(i),t.caption||t.showDownload){const a=n.create("div");if(a.addClass("clepit-output-table-footer-container"),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-table-caption"),t.caption.trim()&&e.setHtml(t.caption),a.append(e)}if(t.showDownload){const t=n.create("button");t.addClass("clepit-output-table-download-btn"),t.setAttribute("type","button"),t.setAttribute("aria-label","Download CSV"),t.append(e.drawDownloadIcon(n)),a.append(t)}o.append(a)}return o}static drawDownloadIcon(e){const t=e.createNS(Wa,"svg");t.setAttribute("class","clepit-download-icon"),t.setAttribute("width","20"),t.setAttribute("height","20"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");for(const n of Ka){const a=e.createNS(Wa,"path");a.setAttribute("d",n),a.setAttribute("stroke","currentColor"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),t.append(a)}return t}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.data)}static downloadTableAsCSV(e){const t=e.data||[];if(0===t.length)return;const n=t.map(e=>e.map(e=>{const t=(e=>Ga.test(e)&&Number.isNaN(Number(e))?`'${e}`:e)(e).replace(/"/g,'""');return t.includes(",")||t.includes('"')||t.includes("\n")||t.includes("\r")?`"${t}"`:t}).join(",")).join("\n"),a=new Blob([n],{type:"text/csv;charset=utf-8;"}),o=document.createElement("a"),i=URL.createObjectURL(a);o.setAttribute("href",i),o.setAttribute("download","table-data.csv"),o.style.visibility="hidden",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}static destroy(t){const n=document.getElementById(t);if(!n)return console.warn("TableOutput::destroy: Container not found for containerId:",t);const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n))}},Xa="\n.clepit-toc {\n display: block;\n}\n.clepit-toc__entry {\n display: block;\n padding: 2px 0;\n color: inherit;\n text-decoration: none;\n}\n.clepit-toc__entry:hover {\n text-decoration: underline;\n}\n.clepit-toc__empty {\n opacity: 0.55;\n}\n",Ya=Xa,Za=Xa,Qa={h1:0,h2:1,h3:2,h4:3,h5:4,h6:5},eo=class{static render(e,t,n,a){l.injectStyles("toc-output",Za);const o=(t?.documentBlocks??[]).filter(e=>"header"===e.type),i=l.createStyledElement("nav","clepit-toc clepit-output-toc",{classNames:a?.list,styles:n?.list});if(0===o.length){const e=document.createElement("div");return e.className="clepit-toc__empty",e.textContent="Table of contents: headings appear here",i.appendChild(e),i}return o.forEach((e,t)=>{const o=e.data,r=l.createStyledElement("a","clepit-toc__entry",{classNames:a?.entry,styles:n?.entry});r.setAttribute("data-toc-index",t.toString());const s=Qa[o.level??"h1"];r.style.paddingLeft=16*s+"px",e.id&&(r.href=`#${e.id}`),r.innerHTML=m(o.html),i.appendChild(r)}),i}static draw(e,t=R,n){if(null==e||"object"!=typeof e)return null;const a=(n?.documentBlocks??[]).filter(e=>"header"===e.type);if(0===a.length)return null;const o=t.create("nav");return o.addClass("clepit-toc","clepit-output-toc"),a.forEach((e,n)=>{const a=e.data,i=t.create("a");i.addClass("clepit-toc__entry"),i.setAttribute("data-toc-index",n.toString()),i.setAttribute("style",`padding-left: ${16*Qa[a.level??"h1"]}px;`),e.id&&i.setAttribute("href",`#${e.id}`),i.setHtml(a.html),o.append(i)}),o}},to="\n.clepit-typeset {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n padding: 12px;\n}\n.clepit-typeset__kind {\n display: block;\n opacity: 0.7;\n font-size: 0.85em;\n margin-bottom: 6px;\n}\n.clepit-typeset__kind:has(+ .clepit-typeset__title) {\n display: inline-block;\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.06em;\n margin-bottom: 0;\n text-transform: uppercase;\n}\n.clepit-typeset__title {\n display: block;\n font-size: 1em;\n font-weight: 600;\n margin: 2px 0 8px;\n opacity: 1;\n}\n.clepit-typeset__title[data-placeholder]:empty::before {\n color: inherit;\n content: attr(data-placeholder);\n font-style: italic;\n font-weight: 400;\n opacity: 0.5;\n pointer-events: none;\n}\n.clepit-typeset__source {\n display: block;\n margin: 0;\n white-space: pre-wrap;\n word-break: break-word;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n.clepit-typeset--input .clepit-typeset__source {\n outline: none;\n}\n.clepit-typeset__diagram {\n display: block;\n max-width: 100%;\n height: auto;\n}\n.clepit-typeset__node {\n fill: rgba(127, 127, 127, 0.08);\n stroke: currentColor;\n stroke-width: 1.5;\n}\n.clepit-typeset__label {\n fill: currentColor;\n font-size: 13px;\n font-family: inherit;\n}\n.clepit-typeset__edge,\n.clepit-typeset__message,\n.clepit-typeset__lifeline {\n stroke: currentColor;\n fill: none;\n}\n.clepit-typeset__lifeline {\n stroke-dasharray: 4 4;\n opacity: 0.55;\n}\n.clepit-typeset__arrowhead {\n fill: currentColor;\n}\n.clepit-typeset__edge-label {\n fill: currentColor;\n font-size: 12px;\n font-family: inherit;\n}\n.clepit-typeset__activation {\n fill: rgba(127, 127, 127, 0.3);\n stroke: currentColor;\n stroke-width: 1;\n}\n.clepit-typeset__note {\n fill: rgba(240, 200, 100, 0.18);\n stroke: currentColor;\n stroke-width: 1;\n}\n.clepit-typeset__formula {\n display: block;\n max-width: 100%;\n height: auto;\n}\n.clepit-typeset__glyph {\n fill: currentColor;\n font-family: ui-serif, Georgia, 'Times New Roman', serif;\n}\n.clepit-typeset__glyph--text {\n font-family: inherit;\n}\n.clepit-typeset__rule,\n.clepit-typeset__radical {\n fill: currentColor;\n}\n.clepit-typeset__radical {\n stroke: currentColor;\n stroke-width: 1.2;\n fill: none;\n}\n.clepit-typeset__fallback-reason {\n display: block;\n opacity: 0.7;\n font-size: 0.85em;\n margin-bottom: 6px;\n}\n",no=to,ao=to,oo=.55,io=.52,ro=(e,t,n)=>e.draw.map(e=>({...e,x:e.x+t,y:e.y+n}));function so(e,t=18){switch(e.kind){case"atom":return lo(e.text,e.style,t);case"space":return{depth:0,draw:[],height:0,width:e.width/18*t};case"row":return function(e,t){const n=[];let a=0,o=0,i=0;for(const r of e){const e=so(r,t);n.push(...ro(e,a,0)),a+=e.width,o=Math.max(o,e.height),i=Math.max(i,e.depth)}return{depth:i,draw:n,height:o,width:a}}(e.items,t);case"script":return function(e,t){const n=so(e.base,t),a=co(t),o=[...n.draw];let i=n.width,r=n.height,s=n.depth;if(null!==e.sup){const s=so(e.sup,a),l=Math.max(.62*n.height,.4*t);o.push(...ro(s,n.width,-l)),i=Math.max(i,n.width+s.width),r=Math.max(r,l+s.height)}if(null!==e.sub){const r=so(e.sub,a),l=Math.max(.5*n.depth,.22*t);o.push(...ro(r,n.width,l)),i=Math.max(i,n.width+r.width),s=Math.max(s,l+r.depth)}return{depth:s,draw:o,height:r,width:i}}(e,t);case"fraction":return function(e,t){const n=so(e.numerator,t),a=so(e.denominator,t),o=.25*t,i=.045*t,r=.18*t,s=Math.max(n.width,a.width)+.3*t,l=-(o+r+n.depth),c=-o+r+a.height;return{depth:c+a.depth,draw:[...ro(n,(s-n.width)/2,l),{kind:"rule",thickness:i,width:s,x:0,y:-o},...ro(a,(s-a.width)/2,c)],height:-l+n.height,width:s}}(e,t);case"radical":return function(e,t){const n=so(e.radicand,t),a=.6*t,o=null===e.index?null:so(e.index,co(co(t))),i=a+.6*(o?.width??0),r=n.height+.18*t,s=[{height:r+n.depth,kind:"radical",size:t,width:n.width+.2*t,x:i,y:0},...ro(n,i+.12*t,0)];null!==o&&s.push(...ro(o,.1*t,.55*-r));return{depth:n.depth,draw:s,height:r,width:i+n.width+.3*t}}(e,t);case"bigop":return function(e,t){const n=1.4*t,a=lo(e.symbol,"upright",n),o=co(t),i=null===e.upper?null:so(e.upper,o),r=null===e.lower?null:so(e.lower,o),s=Math.max(a.width,i?.width??0,r?.width??0),l=[...ro(a,(s-a.width)/2,0)];let c=a.height,d=a.depth;if(null!==i){const e=a.height+i.depth+.16*t;l.push(...ro(i,(s-i.width)/2,-e)),c=e+i.height}if(null!==r){const e=a.depth+r.height+.16*t;l.push(...ro(r,(s-r.width)/2,e)),d=e+r.depth}return{depth:d,draw:l,height:c,width:s}}(e,t);case"accent":return function(e,t){const n=so(e.base,t),a=lo(e.over,"upright",co(t)),o="_"===e.over;return{depth:o?n.depth+.2*t:n.depth,draw:[...n.draw,...ro(a,(n.width-a.width)/2,o?n.depth+.18*t:-(n.height+.04*t))],height:o?n.height:n.height+.2*t,width:n.width}}(e,t);case"delimited":return function(e,t){const n=so(e.body,t),a=n.height+n.depth,o=Math.max(t,a*(1/.55)*.62),i=""===e.open?{depth:0,draw:[],height:0,width:0}:lo(e.open,"upright",o),r=""===e.close?{depth:0,draw:[],height:0,width:0}:lo(e.close,"upright",o),s=e=>(n.height-n.depth)/2-(e.height-e.depth)/2;return{depth:Math.max(n.depth,i.depth-s(i),r.depth-s(r)),draw:[...ro(i,0,s(i)),...ro(n,i.width,0),...ro(r,i.width+n.width,s(r))],height:Math.max(n.height,i.height+s(i),r.height+s(r)),width:i.width+n.width+r.width}}(e,t);case"matrix":return function(e,t){const n=e.rows.map(e=>e.map(e=>so(e,t))),a=Math.max(...n.map(e=>e.length),0),o=[];for(let y=0;y<a;y+=1)o.push(Math.max(...n.map(e=>e[y]?.width??0),0));const i=n.map(e=>Math.max(...e.map(e=>e.height),0)),r=n.map(e=>Math.max(...e.map(e=>e.depth),0)),s=.6*t,l=.35*t,c=o.reduce((e,t)=>e+t,0)+s*Math.max(a-1,0),d=i.reduce((e,t,n)=>e+t+(r[n]??0),0)+l*Math.max(n.length-1,0),p=[];let u=-d/2;for(const[y,x]of n.entries()){u+=i[y]??0;let e=0;for(const[t,n]of x.entries()){const a=o[t]??0;p.push(...ro(n,e+(a-n.width)/2,u)),e+=a+s}u+=(r[y]??0)+l}const[h,m]=po[e.style],g=Math.max(t,.62*d),b=""===h?{depth:0,draw:[],height:0,width:0}:lo(h,"upright",g),f=""===m?{depth:0,draw:[],height:0,width:0}:lo(m,"upright",g),v=e=>(e.height-e.depth)/2;return{depth:d/2,draw:[...ro(b,0,v(b)),...p.map(e=>({...e,x:e.x+b.width})),...ro(f,b.width+c,v(f))],height:d/2,width:b.width+c+f.width}}(e,t)}}function lo(e,t,n){const a="italic"===t?oo:io;return{depth:.22*n,draw:[{kind:"glyph",size:n,style:t,text:e,x:0,y:0}],height:.72*n,width:e.length*a*n}}function co(e){return Math.max(9,.7*e)}var po={bracket:["[","]"],"double-pipe":["‖","‖"],paren:["(",")"],pipe:["|","|"],plain:["",""]};var uo={alpha:"α",beta:"β",chi:"χ",Delta:"Δ",delta:"δ",epsilon:"ϵ",eta:"η",Gamma:"Γ",gamma:"γ",iota:"ι",kappa:"κ",Lambda:"Λ",lambda:"λ",mu:"μ",nu:"ν",Omega:"Ω",omega:"ω",Phi:"Φ",Pi:"Π",Psi:"Ψ",phi:"ϕ",pi:"π",psi:"ψ",rho:"ρ",Sigma:"Σ",sigma:"σ",Theta:"Θ",tau:"τ",theta:"θ",Upsilon:"Υ",upsilon:"υ",varepsilon:"ε",varphi:"φ",vartheta:"ϑ",Xi:"Ξ",xi:"ξ",zeta:"ζ"},ho={angle:"∠",approx:"≈",ast:"∗",cap:"∩",cdot:"⋅",cup:"∪",div:"÷",equiv:"≡",exists:"∃",forall:"∀",geq:"≥",in:"∈",infty:"∞",Leftarrow:"⇐",leftarrow:"←",leftrightarrow:"↔",leq:"≤",mp:"∓",nabla:"∇",neg:"¬",neq:"≠",notin:"∉",parallel:"∥",partial:"∂",perp:"⊥",pm:"±",propto:"∝",Rightarrow:"⇒",rightarrow:"→",sim:"∼",simeq:"≃",star:"⋆",subset:"⊂",subseteq:"⊆",supset:"⊃",supseteq:"⊇",times:"×",to:"→"},mo={bigcap:"⋂",bigcup:"⋃",int:"∫",lim:"lim",oint:"∮",prod:"∏",sum:"∑"},go=["arccos","arcsin","arctan","cos","cosh","cot","csc","deg","det","dim","exp","gcd","ln","log","max","min","sec","sin","sinh","tan","tanh"],bo={bar:"‾",ddot:"¨",dot:"˙",hat:"^",tilde:"~",vec:"→"},fo={",":3,";":5,":":4,"!":-3,qquad:36,quad:18},vo={".":"","(":"(",")":")","[":"[","]":"]","\\{":"{","\\}":"}","\\|":"‖","|":"|"},yo=["catcode","csname","def","href","include","input","newcommand","renewcommand","url","write"],xo={bmatrix:"bracket",matrix:"plain",pmatrix:"paren",Vmatrix:"double-pipe",vmatrix:"pipe"},ko=/[A-Za-z0-9+\-=<>()[\]|,./!:;]/,wo=/[A-Za-z]/,Co=/[0-9]/,Ao={mathbf:"bold",mathit:"italic",mathrm:"upright",text:"text"},So=class{constructor(e){this.source=e,this.at=0}get done(){return this.at>=this.source.length}peek(e=0){return this.source[this.at+e]??""}take(){const e=this.peek();return this.at+=1,e}skipSpace(){for(;!this.done&&/\s/.test(this.peek());)this.at+=1}readCommand(){if(this.at+=1,!wo.test(this.peek()))return this.take();let e="";for(;wo.test(this.peek());)e+=this.take();return e}},Eo=class extends Error{};function Lo(e){const t=new So(e);try{const e=No(t,null);if(Mo(t))throw new Eo("a \\right appears without a matching \\left");if(!t.done)throw new Eo(`"${t.peek()}" is unexpected here`);return{ok:!0,root:e}}catch(n){if(n instanceof Eo)return{ok:!1,reason:n.message};throw n}}function No(e,t){const n=[];for(;(e.skipSpace(),!e.done)&&("}"!==t||"}"!==e.peek())&&("]"!==t||"]"!==e.peek())&&("cell"!==t||"&"!==e.peek()&&!Bo(e)&&!$o(e))&&!Mo(e);){const t=Io(e);if(null===t)break;n.push(t)}return(e=>1===e.length&&void 0!==e[0]?e[0]:{items:e,kind:"row"})(n)}function Bo(e){return"\\"===e.peek()&&"\\"===e.peek(1)}function Mo(e){return!!e.source.startsWith("\\right",e.at)&&!wo.test(e.peek(6))}function $o(e){return"\\"===e.peek()&&e.source.startsWith("\\end",e.at)}function Io(e){const t=To(e);if(null===t)return null;let n=null,a=null;for(;;){e.skipSpace();const t=e.peek();if("^"!==t&&"_"!==t)break;e.take();const o=To(e);if(null===o)throw new Eo(`"${t}" has nothing after it`);if("^"===t){if(null!==a)throw new Eo("a term carries two superscripts");a=o}else{if(null!==n)throw new Eo("a term carries two subscripts");n=o}}return null===n&&null===a?t:"bigop"===t.kind?{...t,lower:n,upper:a}:{base:t,kind:"script",sub:n,sup:a}}function To(e){if(e.skipSpace(),e.done)return null;const t=e.peek();if("}"===t||"&"===t||"^"===t||"_"===t)return null;if("{"===t){e.take();const t=No(e,"}");if("}"!==e.peek())throw new Eo("a { group is never closed");return e.take(),t}if("\\"===t)return function(e){const t=e.readCommand();if(yo.includes(t))throw new Eo(`"\\${t}" is refused for safety, not merely unsupported`);if("\\"===t)throw new Eo("a row break appears outside a matrix");if("begin"===t)return function(e){const t=qo(e),n=xo[t];if(void 0===n)throw new Eo(`the "${t}" environment is not supported yet`);const a=[];let o=[];for(let i=0;i<4096;i+=1)if(o.push(No(e,"cell")),e.skipSpace(),"&"!==e.peek()){if(!Bo(e)){if($o(e)){e.at+=4;const i=qo(e);if(i!==t)throw new Eo(`\\begin{${t}} is closed by \\end{${i}}`);return a.push(o),{kind:"matrix",rows:a,style:n}}throw new Eo(`\\begin{${t}} is never closed`)}e.at+=2,a.push(o),o=[]}else e.take();throw new Eo(`\\begin{${t}} is never closed`)}(e);if("end"===t)throw new Eo("an \\end appears without a matching \\begin");if("frac"===t||"dfrac"===t||"tfrac"===t){const t=_o(e);return{denominator:_o(e),kind:"fraction",numerator:t}}if("sqrt"===t)return function(e){e.skipSpace();let t=null;if("["===e.peek()){if(e.take(),t=No(e,"]"),"]"!==e.peek())throw new Eo("a \\sqrt index is never closed");e.take()}return{index:t,kind:"radical",radicand:_o(e)}}(e);if("left"===t)return function(e){const t=Do(e,"left"),n=No(e,null);if(!Mo(e))throw new Eo("a \\left has no matching \\right");return e.at+=6,{body:n,close:Do(e,"right"),kind:"delimited",open:t}}(e);if("right"===t)throw new Eo("a \\right appears without a matching \\left");const n=Ao[t];if(void 0!==n)return{kind:"atom",style:n,text:qo(e)};const a=bo[t];if(void 0!==a)return{base:_o(e),kind:"accent",over:a};if("overline"===t)return{base:_o(e),kind:"accent",over:"‾"};if("underline"===t)return{base:_o(e),kind:"accent",over:"_"};const o=mo[t];if(void 0!==o)return{kind:"bigop",lower:null,symbol:o,upper:null};const i=uo[t];if(void 0!==i)return{kind:"atom",style:"italic",text:i};const r=ho[t];if(void 0!==r)return{kind:"atom",style:"upright",text:r};if(go.includes(t))return{kind:"atom",style:"upright",text:t};const s=fo[t];if(void 0!==s)return{kind:"space",width:s};const l=vo[`\\${t}`];if(void 0!==l)return{kind:"atom",style:"upright",text:l};throw new Eo(`"\\${t}" is not supported yet`)}(e);if(ko.test(t))return e.take(),{kind:"atom",style:Co.test(t)?"upright":"italic",text:t};throw new Eo(`"${t}" is not a character this engine understands`)}function _o(e){if(e.skipSpace(),"{"!==e.peek()){const t=To(e);if(null===t)throw new Eo("a command is missing its argument");return t}e.take();const t=No(e,"}");if("}"!==e.peek())throw new Eo("a { group is never closed");return e.take(),t}function qo(e){if(e.skipSpace(),"{"!==e.peek())throw new Eo("a text command is missing its { group");e.take();let t="",n=1;for(;!e.done;){const a=e.peek();if("{"===a&&(n+=1),"}"===a&&(n-=1,0===n))return e.take(),t;t+=e.take()}throw new Eo("a text command’s { group is never closed")}function Do(e,t){e.skipSpace();const n=e.peek();if("\\"===n){const t=e.readCommand(),n=vo[`\\${t}`];if(void 0===n)throw new Eo(`"\\${t}" is not a delimiter this engine understands`);return n}const a=vo[n];if(void 0===a)throw new Eo(`\\${t} is missing a delimiter`);return e.take(),a}var zo={bold:{style:"normal",weight:"700"},italic:{style:"italic",weight:"400"},text:{style:"normal",weight:"400"},upright:{style:"normal",weight:"400"}};function jo(e,t,n){const a=n.createNS("http://www.w3.org/2000/svg",e);for(const[o,i]of Object.entries(t))a.setAttribute(o,String(i));return a}function Ho(e,t=R){const n=e.width+16,a=e.height+e.depth+16,o=e.height+8,i=jo("svg",{class:"clepit-typeset__formula",height:a,role:"img",viewBox:`0 0 ${n} ${a}`,width:n},t);for(const r of e.draw){if("glyph"===r.kind){const e=zo[r.style],n=jo("text",{class:"clepit-typeset__glyph","dominant-baseline":"alphabetic","font-size":r.size,"font-style":e.style,"font-weight":e.weight,x:r.x+8,y:o+r.y},t);"text"===r.style&&n.setAttribute("class","clepit-typeset__glyph clepit-typeset__glyph--text"),n.setText(r.text),i.append(n);continue}"rule"!==r.kind?i.append(Oo(r,o,t)):i.append(jo("rect",{class:"clepit-typeset__rule",height:r.thickness,width:r.width,x:r.x+8,y:o+r.y-r.thickness/2},t))}return i}function Oo(e,t,n){const a=e.x+8,o=t+e.y-e.height,i=t+e.y,r=.32*e.size;return jo("path",{class:"clepit-typeset__radical",d:[`M ${a-1.6*r} ${i-.45*e.height}`,`L ${a-.9*r} ${i-.55*e.height}`,`L ${a-.2*r} ${i}`,`L ${a+.35*r} ${o}`,`L ${a+e.width} ${o}`].join(" "),fill:"none"},n)}var Po=72,Ro=40,Fo=28,Vo=16;function Uo(e){return"flowchart"===e.kind?function(e){const t="LR"===e.direction||"RL"===e.direction,n=function(e){const t=/* @__PURE__ */new Map;for(const a of e.nodes)t.set(a.id,0);const n=function(e){const t=/* @__PURE__ */new Map;for(const o of e.edges)t.set(o.from,[...t.get(o.from)??[],o]);const n=/* @__PURE__ */new Map,a=/* @__PURE__ */new Set;for(const o of e.nodes){if(n.has(o.id))continue;n.set(o.id,"visiting");const e=[{id:o.id,index:0}];for(;e.length>0;){const o=e[e.length-1],i=t.get(o.id)??[];if(o.index>=i.length){n.set(o.id,"done"),e.pop();continue}const r=i[o.index];o.index+=1;const s=n.get(r.to);"visiting"===s?a.add(r):void 0===s&&(n.set(r.to,"visiting"),e.push({id:r.to,index:0}))}}return e.edges.filter(e=>!a.has(e))}(e);for(let a=0;a<e.nodes.length;a+=1){let e=!1;for(const a of n){if(a.from===a.to)continue;const n=(t.get(a.from)??0)+1;n>(t.get(a.to)??0)&&(t.set(a.to,n),e=!0)}if(!e)break}return t}(e),a=/* @__PURE__ */new Map;for(const b of e.nodes){const e=n.get(b.id)??0;a.set(e,[...a.get(e)??[],b.id])}const o=/* @__PURE__ */new Map;for(const b of e.nodes)o.set(b.id,Wo(b.label,Po));const i=/* @__PURE__ */new Map,r=[...a.keys()].sort((e,t)=>e-t),s=e=>t?e.length*Ro+(e.length-1)*Fo:e.reduce((e,t)=>e+(o.get(t)??Po),0)+(e.length-1)*Fo,l=Math.max(...r.map(e=>s(a.get(e)??[])),0);for(const b of r){const n=a.get(b)??[],r=Vo+b*((t?Po:Ro)+64);let c=Vo+(l-s(n))/2;for(const a of n){const n=e.nodes.find(e=>e.id===a);if(void 0===n)continue;const s=o.get(a)??Po;i.set(a,{height:Ro,id:a,label:n.label,shape:n.shape,width:s,x:t?r:c,y:t?c:r}),c+=(t?Ro:s)+Fo}}const c=e.nodes.map(e=>i.get(e.id)).filter(e=>void 0!==e),d=Math.max(...c.map(e=>e.x+e.width),0),p=Math.max(...c.map(e=>e.y+e.height),0),u=(t?p:d)+24,h=e.edges.map(e=>function(e,t,n,a){const o=t.get(e.from),i=t.get(e.to);if(void 0===o||void 0===i)return null;if(n?i.x<o.x:i.y<o.y){const t=n?{x:o.x+o.width/2,y:o.y+o.height}:{x:o.x+o.width,y:o.y+o.height/2},r=n?{x:i.x+i.width/2,y:i.y+i.height}:{x:i.x+i.width,y:i.y+i.height/2},s=n?{x:t.x,y:a}:{x:a,y:t.y},l=n?{x:r.x,y:a}:{x:a,y:r.y};return{arrow:e.arrow,label:e.label,labelX:(s.x+l.x)/2,labelY:(s.y+l.y)/2,line:e.line,points:[t,s,l,r]}}const r=n?{x:o.x+o.width,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height},s=n?{x:i.x,y:i.y+i.height/2}:{x:i.x+i.width/2,y:i.y};return{arrow:e.arrow,label:e.label,labelX:(r.x+s.x)/2,labelY:(r.y+s.y)/2,line:e.line,points:[r,s]}}(e,i,t,u)).filter(e=>null!==e),m=h.some(e=>e.points.length>2),g=t?d:Math.max(d,m?u:0);return{edges:h,height:(t?Math.max(p,m?u:0):p)+Vo,kind:"flowchart",nodes:c,width:g+Vo}}(e):function(e){const t=[];let n=Vo;for(const h of e.participants){const e=Wo(h.label,96);t.push({actor:h.actor,centerX:n+e/2,headHeight:36,headWidth:e,id:h.id,label:h.label}),n+=e+Fo}const a=e=>t.find(t=>t.id===e)?.centerX??null,o=[],i=[],r=[],s=/* @__PURE__ */new Map;let l=100;const c=(e,t)=>{const n=s.get(e),o=a(e);void 0!==n&&null!==o&&(r.push({height:Math.max(t-n,24),width:10,x:o-5,y:n}),s.delete(e))};for(const h of e.steps){if("activation"===h.kind){h.active?s.set(h.participant,l):c(h.participant,l);continue}if("note"===h.kind){const e=h.targets.map(a).filter(e=>null!==e);if(0===e.length)continue;const t=Wo(h.text,96),n=Math.min(...e),o=Math.max(...e),r="left"===h.placement?n-t-Fo:"right"===h.placement?o+Fo:(n+o)/2-t/2;i.push({height:34,text:h.text,width:t,x:r,y:l}),l+=62;continue}const e=a(h.from),t=a(h.to);null!==e&&null!==t&&(h.activate&&s.set(h.to,l),o.push({end:h.end,fromX:e,line:h.line,selfCall:h.from===h.to,text:h.text,toX:t,y:l}),l+=48,h.deactivate&&c(h.to,l))}const d=l;for(const h of[...s.keys()])c(h,d);const p=Math.max(...i.map(e=>e.x+e.width),0),u=Math.max(n-Fo+Vo,p+Vo);return{activations:r,height:d+Vo,kind:"sequence",lifelineBottom:d,lifelines:t,messages:o,notes:i,width:u}}(e)}function Wo(e,t){return Math.max(t,Math.round(7.2*e.length)+32)}var Ko=["BT","LR","RL","TB","TD"],Go=["subgraph","end","click","style","classDef","class","linkStyle","direction"],Jo=["loop","alt","else","opt","par","and","critical","option","break","rect","box","autonumber","end"],Xo=[{arrow:!0,line:"dotted",token:"-.->"},{arrow:!0,line:"thick",token:"==>"},{arrow:!0,line:"solid",token:"--\x3e"},{arrow:!1,line:"thick",token:"==="},{arrow:!1,line:"solid",token:"---"},{arrow:!1,line:"dotted",token:"-.-"}],Yo=[{end:"arrow",line:"dotted",token:"--\x3e>"},{end:"arrow",line:"solid",token:"->>"},{end:"cross",line:"dotted",token:"--x"},{end:"cross",line:"solid",token:"-x"},{end:"none",line:"dotted",token:"--\x3e"},{end:"none",line:"solid",token:"->"}],Zo=[{close:"]]",open:"[[",shape:"subroutine"},{close:"])",open:"([",shape:"stadium"},{close:"))",open:"((",shape:"circle"},{close:"]",open:"[",shape:"rect"},{close:"}",open:"{",shape:"rhombus"},{close:")",open:"(",shape:"round"}],Qo=e=>({ok:!1,reason:e});function ei(e){return e.split(/[\s(]/,1)[0]??""}function ti(e){const t=function(e){return e.split("\n").map(e=>function(e){const t=e.indexOf("%%");return-1===t?e:e.slice(0,t)}(e).trim()).filter(e=>e.length>0)}(e);if(0===t.length)return Qo("the block is empty");const[n,...a]=t,o=ei(n??"");return"sequenceDiagram"===o?function(e){const t=/* @__PURE__ */new Map,n=[],a=e=>(t.has(e)||t.set(e,{actor:!1,id:e,label:e}),e);for(const o of e){const e=ei(o);if(Jo.includes(e))return Qo(`"${e}" is not supported yet`);if("participant"===e||"actor"===e){const n=si(o,e);if(null===n)return Qo(`"${o}" is not a participant declaration this engine understands`);t.set(n.id,n);continue}if("activate"===e||"deactivate"===e){const t=o.slice(e.length).trim();if(!ri(t))return Qo(`"${o}" does not name a participant to ${e}`);n.push({active:"activate"===e,kind:"activation",participant:a(t)});continue}if("Note"===e||"note"===e){const e=li(o);if(null===e)return Qo(`"${o}" is not a note this engine understands`);for(const t of e.targets)a(t);n.push(e);continue}const i=ci(o);if(null===i)return Qo(`"${o}" is not a message this engine understands`);a(i.from),a(i.to),n.push(i)}return{model:{kind:"sequence",participants:[...t.values()],steps:n},ok:!0}}(a):"flowchart"===o||"graph"===o?function(e,t){const n=e.slice(ei(e).length).trim();if(0===n.length)return Qo('the flowchart header is missing a direction, e.g. "flowchart TD"');const a=Ko.find(e=>e===n);if(void 0===a)return Qo(`"${n}" is not a supported direction: use TD, TB, BT, LR or RL`);const o=/* @__PURE__ */new Map,i=[];for(const r of t){const e=ei(r);if(Go.includes(e))return Qo(`"${e}" is not supported yet`);if(r.includes("&"))return Qo('"&" fan-out is not supported yet');const t=ni(r,o,i);if(null!==t)return Qo(t)}return{model:{direction:a,edges:i,kind:"flowchart",nodes:[...o.values()]},ok:!0}}(n??"",a):Qo(`"${o}" diagrams are not supported yet (only flowchart and sequenceDiagram are)`)}function ni(e,t,n){const a=function(e){const t=[],n=[];let a=e.trim();for(let o=0;o<64;o+=1){const e=ai(a);if(null===e)return t.push(a.trim()),t.every(e=>e.length>0)?{links:n,terms:t}:null;t.push(a.slice(0,e.at).trim()),n.push({arrow:e.arrow,label:e.label,line:e.line}),a=a.slice(e.at+e.length)}return null}(e);if(null===a)return`"${e}" is not a node or edge this engine understands`;const o=[];for(const i of a.terms){const e=ii(i);if(null===e)return`"${i}" is not a node declaration this engine understands`;t.has(e.id)||t.set(e.id,e),o.push(e)}for(const[i,r]of a.links.entries()){const t=o[i],a=o[i+1];if(void 0===t||void 0===a)return`"${e}" has a link with nothing on one side of it`;n.push({arrow:r.arrow,from:t.id,label:r.label,line:r.line,to:a.id})}return null}function ai(e){const t=function(e){const t=/--\s+([^->|][^-]*?)\s+(-->|---|-\.->|-\.-|==>|===)/.exec(e);if(null===t||void 0===t.index)return null;const n=Xo.find(e=>e.token===t[2]);return void 0===n?null:{arrow:n.arrow,at:t.index,label:(t[1]??"").trim(),length:t[0].length,line:n.line}}(e);if(null!==t)return t;let n=null;for(const a of Xo){const t=e.indexOf(a.token);if(-1===t)continue;if(null!==n&&t>=n.at)continue;const o=oi(e,t+a.token.length);n={arrow:a.arrow,at:t,label:o.label,length:a.token.length+o.consumed,line:a.line}}return n}function oi(e,t){if("|"!==e[t])return{consumed:0,label:null};const n=e.indexOf("|",t+1);return-1===n?{consumed:0,label:null}:{consumed:n-t+1,label:e.slice(t+1,n).trim()}}function ii(e){const t=e.trim();if(0===t.length)return null;for(const n of Zo){const e=t.indexOf(n.open);if(e<=0||!t.endsWith(n.close))continue;const a=t.slice(0,e).trim(),o=t.slice(e+n.open.length,t.length-n.close.length);if(ri(a))return{id:a,label:o.trim(),shape:n.shape}}return ri(t)?{id:t,label:t,shape:"rect"}:null}function ri(e){return/^[A-Za-z_][\w-]*$/.test(e)}function si(e,t){const n=e.slice(t.length).trim(),a=/ as /.exec(n),o=(null===a?n:n.slice(0,a.index)).trim();if(!ri(o))return null;const i=null===a?o:n.slice(a.index+a[0].length).trim();return{actor:"actor"===t,id:o,label:0===i.length?o:i}}function li(e){const t=e.slice(ei(e).length).trim(),n=t.indexOf(":");if(-1===n)return null;const a=t.slice(0,n).trim(),o=t.slice(n+1).trim(),i=/^over\s+(.+)$/i.exec(a);if(null!==i){const e=(i[1]??"").split(",").map(e=>e.trim());return e.every(ri)?{kind:"note",placement:"over",targets:e,text:o}:null}const r=/^(left|right)\s+of\s+(.+)$/i.exec(a);if(null===r)return null;const s=(r[2]??"").trim();return ri(s)?{kind:"note",placement:(r[1]??"").toLowerCase(),targets:[s],text:o}:null}function ci(e){const t=e.indexOf(":");if(-1===t)return null;const n=e.slice(0,t),a=e.slice(t+1).trim();for(const o of Yo){const e=n.indexOf(o.token);if(-1===e)continue;const t=n.slice(0,e).trim(),i=n.slice(e+o.token.length).trim(),r=i.startsWith("+")||i.startsWith("-")?i[0]:null,s=null===r?i:i.slice(1).trim();if(ri(t)&&ri(s))return{activate:"+"===r,deactivate:"-"===r,end:o.end,from:t,kind:"message",line:o.line,text:a,to:s}}return null}var di={dotted:"5 4",solid:"",thick:""},pi={dotted:1.5,solid:1.5,thick:3};function ui(e,t,n){const a=n.createNS("http://www.w3.org/2000/svg",e);for(const[o,i]of Object.entries(t))a.setAttribute(o,String(i));return a}function hi(e,t,n,a,o){const i=ui("text",{class:a,"dominant-baseline":"middle","text-anchor":"middle",x:t,y:n},o);return i.setText(e),i}function mi(e,t=R){const n=ui("svg",{class:"clepit-typeset__diagram",height:e.height,role:"img",viewBox:`0 0 ${e.width} ${e.height}`,width:e.width},t);return n.append(function(e){const t=ui("defs",{},e),n=ui("marker",{id:"clepit-mermaid-arrow",markerHeight:7,markerUnits:"strokeWidth",markerWidth:7,orient:"auto-start-reverse",refX:7,refY:3.5},e);return n.append(ui("path",{class:"clepit-typeset__arrowhead",d:"M 0 0 L 7 3.5 L 0 7 z"},e)),t.append(n),t}(t)),"flowchart"===e.kind?function(e,t,n){for(const a of t.edges)bi(e,a,n);for(const a of t.nodes)gi(e,a,n)}(n,e,t):function(e,t,n){for(const a of t.lifelines){e.append(ui("line",{class:"clepit-typeset__lifeline",x1:a.centerX,x2:a.centerX,y1:a.headHeight+16,y2:t.lifelineBottom},n));const o={class:a.actor?"clepit-typeset__node clepit-typeset__actor":"clepit-typeset__node",height:a.headHeight,rx:a.actor?a.headHeight/2:4,ry:a.actor?a.headHeight/2:4,width:a.headWidth,x:a.centerX-a.headWidth/2,y:16};e.append(ui("rect",o,n)),e.append(hi(a.label,a.centerX,16+a.headHeight/2,"clepit-typeset__label",n))}for(const a of t.activations)e.append(ui("rect",{class:"clepit-typeset__activation",height:a.height,width:a.width,x:a.x,y:a.y},n));for(const a of t.messages)fi(e,a,n);for(const a of t.notes)e.append(ui("rect",{class:"clepit-typeset__note",height:a.height,width:a.width,x:a.x,y:a.y},n)),e.append(hi(a.text,a.x+a.width/2,a.y+a.height/2,"clepit-typeset__label",n))}(n,e,t),n}function gi(e,t,n){e.append(function(e,t){const{height:n,shape:a,width:o,x:i,y:r}=e,s={class:"clepit-typeset__node"};if("circle"===a)return ui("ellipse",{...s,cx:i+o/2,cy:r+n/2,rx:o/2,ry:n/2},t);if("rhombus"===a){const e=`${i+o/2},${r} ${i+o},${r+n/2} ${i+o/2},${r+n} ${i},${r+n/2}`;return ui("polygon",{...s,points:e},t)}if("stadium"===a)return ui("rect",{...s,height:n,rx:n/2,ry:n/2,width:o,x:i,y:r},t);if("round"===a)return ui("rect",{...s,height:n,rx:10,ry:10,width:o,x:i,y:r},t);if("subroutine"===a){const e=ui("g",{},t);return e.append(ui("rect",{...s,height:n,rx:8,ry:8,width:o,x:i,y:r},t)),e.append(ui("line",{...s,x1:i+6,x2:i+6,y1:r,y2:r+n},t)),e.append(ui("line",{...s,x1:i+o-6,x2:i+o-6,y1:r,y2:r+n},t)),e}return ui("rect",{...s,height:n,rx:8,ry:8,width:o,x:i,y:r},t)}(t,n)),e.append(hi(t.label,t.x+t.width/2,t.y+t.height/2,"clepit-typeset__label",n))}function bi(e,t,n){const[a,o]=t.points;if(void 0===a||void 0===o)return;const i=t.points.length>2?ui("polyline",{class:"clepit-typeset__edge",fill:"none",points:t.points.map(e=>`${e.x},${e.y}`).join(" "),"stroke-dasharray":di[t.line],"stroke-width":pi[t.line]},n):ui("line",{class:"clepit-typeset__edge","stroke-dasharray":di[t.line],"stroke-width":pi[t.line],x1:a.x,x2:o.x,y1:a.y,y2:o.y},n);if(t.arrow&&i.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(i),null!==t.label){const a=hi(t.label,t.labelX,t.labelY,"clepit-typeset__edge-label",n);a.setAttribute("paint-order","stroke"),e.append(a)}}function fi(e,t,n){const a={class:"clepit-typeset__message","stroke-dasharray":di[t.line],"stroke-width":pi[t.line]};if(t.selfCall){const o=`M ${t.fromX} ${t.y} h 28 v 18 h -28`,i=ui("path",{...a,d:o,fill:"none"},n);return"arrow"===t.end&&i.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(i),void e.append(hi(t.text,t.fromX+52,t.y+9,"clepit-typeset__edge-label",n))}const o=ui("line",{...a,x1:t.fromX,x2:t.toX,y1:t.y,y2:t.y},n);if("arrow"===t.end&&o.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(o),"cross"===t.end){const o=t.toX+(t.toX>t.fromX?-5:5);e.append(ui("line",{...a,x1:o-5,x2:o+5,y1:t.y-5,y2:t.y+5},n)),e.append(ui("line",{...a,x1:o-5,x2:o+5,y1:t.y+5,y2:t.y-5},n))}e.append(hi(t.text,(t.fromX+t.toX)/2,t.y-8,"clepit-typeset__edge-label",n))}var vi=class e{static render(t,n,a,o,i){if(l.injectStyles("typeset-output",ao),!e.validate(n))return X();const r=l.createStyledElement("div",`clepit-typeset clepit-output-typeset clepit-typeset--${t.toLowerCase()}`,{classNames:i?.wrapper,styles:o?.wrapper});if(r.setAttribute("data-language",t.toLowerCase()),n.title){const e=document.createElement("span");e.className="clepit-typeset__title",e.textContent=n.title,e.setAttribute("data-testid","typeset-title"),r.appendChild(e)}if("Mermaid"===t){const a=ti(n.source);return a.ok?(r.setAttribute("data-rendered","diagram"),r.appendChild(J(mi(Uo(a.model)))),r):e.appendFallback(r,n.source,a.reason,t)}if(0===n.source.trim().length)return e.appendFallback(r,n.source,null,t);const s=Lo(n.source);return s.ok?(r.setAttribute("data-rendered","formula"),r.appendChild(J(Ho(so(s.root)))),r):e.appendFallback(r,n.source,s.reason,t)}static appendFallback(e,t,n,a){e.setAttribute("data-rendered","source");const o=document.createElement("span");if(o.className="clepit-typeset__kind",o.textContent=a,e.prepend(o),null!==n){const t=document.createElement("span");t.className="clepit-typeset__fallback-reason",t.textContent=n,e.appendChild(t)}const i=document.createElement("pre");return i.className="clepit-typeset__source",i.textContent=t,e.appendChild(i),e}static draw(t,n,a=R){if(!e.validate(n))return null;const o=a.create("div");o.addClass("clepit-typeset","clepit-output-typeset",`clepit-typeset--${t.toLowerCase()}`),o.setAttribute("data-language",t.toLowerCase());const i=()=>{if(!n.title)return;const e=a.create("span");e.addClass("clepit-typeset__title"),e.setText(n.title),e.setAttribute("data-testid","typeset-title"),o.append(e)};if("Mermaid"===t){const r=ti(n.source);return r.ok?(o.setAttribute("data-rendered","diagram"),i(),o.append(mi(Uo(r.model),a)),o):e.drawFallback(o,n,r.reason,t,a,i)}if(0===n.source.trim().length)return e.drawFallback(o,n,null,t,a,i);const r=Lo(n.source);return r.ok?(o.setAttribute("data-rendered","formula"),i(),o.append(Ho(so(r.root),a)),o):e.drawFallback(o,n,r.reason,t,a,i)}static drawFallback(e,t,n,a,o,i){e.setAttribute("data-rendered","source");const r=o.create("span");if(r.addClass("clepit-typeset__kind"),r.setText(a),e.append(r),i(),null!==n){const t=o.create("span");t.addClass("clepit-typeset__fallback-reason"),t.setText(n),e.append(t)}const s=o.create("pre");return s.addClass("clepit-typeset__source"),s.setText(t.source),e.append(s),e}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.source&&(void 0===e.title||"string"==typeof e.title)}},yi=class{static render(e,t,n,a){return vi.render("LaTeX",e,t,n,a)}static draw(e,t=R){return vi.draw("LaTeX",e,t)}},xi=class{static render(e,t,n,a){return vi.render("Mermaid",e,t,n,a)}static draw(e,t=R){return vi.draw("Mermaid",e,t)}},ki="\n.clepit-updates {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n color: inherit;\n}\n.clepit-updates__icon {\n font-size: 18px;\n line-height: 1;\n}\n.clepit-updates__label {\n opacity: 0.7;\n}\n",wi=ki,Ci=ki,Ai=class{static render(e,t,n,a){l.injectStyles("updates-output",Ci);const o=l.createStyledElement("div","clepit-updates clepit-output-updates",{classNames:a?.wrapper,styles:n?.wrapper});e?.pageId&&o.setAttribute("data-page-id",e.pageId);const i=document.createElement("span");i.className="clepit-updates__icon",i.textContent="🕘",o.appendChild(i);const r=document.createElement("span");return r.className="clepit-updates__label",r.textContent="Updates",o.appendChild(r),o}static draw(e,t=R){if(null==e||"object"!=typeof e)return null;const n=t.create("div");n.addClass("clepit-updates","clepit-output-updates"),e.pageId&&n.setAttribute("data-page-id",e.pageId);const a=t.create("span");a.addClass("clepit-updates__icon"),a.setText("🕘"),n.append(a);const o=t.create("span");return o.addClass("clepit-updates__label"),o.setText("Updates"),n.append(o),n}},Si=`\n/* Video block styles */\n.clepit-video-container {\n margin: 16px 0;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 100%;\n box-sizing: border-box;\n}\n\n.clepit-video-wrapper {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.clepit-video-wrapper:hover {\n opacity: 0.9;\n}\n\n.clepit-video {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n display: block;\n}\n\n.clepit-video-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-video-wrapper--center {\n justify-content: center;\n}\n\n.clepit-video-wrapper--right {\n justify-content: flex-end;\n}\n\n.clepit-video-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-video-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-video-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-video-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Video caption styling */\n.clepit-video-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Video caption placeholder styles */\n.clepit-video-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Video Drop Area */\n.clepit-video-drop-area {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n}\n\n.clepit-video-drop-area:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-video-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-video-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-video-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n}\n\n.clepit-video-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Video Loading State */\n.clepit-video-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-video-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-video-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Video Error State */\n.clepit-video-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-video-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-video-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-video-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-video-error-retry:hover {\n background: var(--clepit-error);\n}\n\n/* Video caption placeholder */\n.clepit-video-caption-placeholder {\n color: var(--clepit-text-subtle);\n}\n\n/* Video delete button */\n.${l.classNames.block.videoDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${l.classNames.block.videoDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Video drop area delete button */\n.clepit-video-drop-area .${l.classNames.block.videoDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-video-drop-area .${l.classNames.block.videoDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,Ei="\n/* Output video styles */\n.clepit-output-video-container {\n margin: 1rem 0;\n text-align: center;\n}\n\n.clepit-output-video {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n}\n\n.clepit-output-video-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Output video alignment */\n.clepit-output-video-wr--left {\n justify-content: flex-start;\n}\n\n.clepit-output-video-wr--center {\n justify-content: center;\n}\n\n.clepit-output-video-wr--right {\n justify-content: flex-end;\n}\n",Li=class e{static{this.placeholder="Add a caption..."}static{this.eventListenersMap={}}static{this.validTypes=["video/mp4","video/webm","video/ogg","video/ogv"]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("video"),n=e.querySelector("iframe"),a=e.querySelector(`.${l.classNames.block.video.captionEditable}`),o=e.querySelector(`.${l.classNames.block.video.wrapper}`);let i="center";o&&(i=o.classList.contains("clepit-video-wrapper--left")?"left":o.classList.contains("clepit-video-wrapper--right")?"right":"center");let r="",s="";return t?(r=t.getAttribute("src")||"",s=t.getAttribute("alt")||""):n&&(r=n.getAttribute("src")||"",s="Embedded video"),{alignment:i,alt:s,caption:m(a?.innerHTML),url:r}}static render(t,n,a,o){l.injectStyles("clepit-video-input-styles",Si);const i=a||{alt:"",caption:"",url:""},r=l.createStyledElement("div",l.classNames.block.video.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return i.url?e.renderVideo(r,i,t,n,o):e.renderDropArea(r,t,n,o),r}static renderVideo(t,n,a,o,i){t.innerHTML="";const r=l.createStyledElement("div",l.classNames.block.video.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("clepit-video-wrapper--left");break;case"center":r.classList.add("clepit-video-wrapper--center");break;case"right":r.classList.add("clepit-video-wrapper--right")}const s=vt(n?.url||""),c=yt(n?.url||"");if(s||c){const e=l.createStyledElement("iframe",l.classNames.block.video.iframe,{classNames:i?.classNames?.container,styles:i?.styles?.container});e.src=n?.url||"",e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),e.style.maxWidth="100%",e.style.width="560px",e.style.height="315px",e.style.display="block",e.style.borderRadius="8px",r.appendChild(e)}else{const e=l.createStyledElement("video",l.classNames.block.video.video,{classNames:i?.classNames?.container,styles:i?.styles?.container});e.setAttribute("alt",n?.alt||""),e.src=n?.url||"",e.controls=!0,r.appendChild(e)}const d=l.createStyledElement("div","clepit-video-caption-container",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});d.classList.add("clepit-video-caption-container");const p=l.createStyledElement("div",l.classNames.block.video.captionEditable,{classNames:i?.classNames?.caption,styles:i?.styles?.caption});p.setAttribute("contenteditable","true"),p.setAttribute("data-placeholder",ne(o,"mediaCaptionHint",e.placeholder)),p.innerHTML=m(n?.caption),e.addEventListener(o,p,"input",Ds.handleInput),e.addEventListener(o,p,"keydown",Ds.handleKeydown),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),d.appendChild(p),t.appendChild(r),t.appendChild(d),p.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const i=l.createStyledElement("div",l.classNames.block.video.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});i.setAttribute("tabindex","0"),i.classList.add("clepit-drop-area");const r=l.createStyledElement("div","clepit-video-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});r.textContent="🎥";const s=l.createStyledElement("div","clepit-video-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text});s.innerHTML='<strong>Drop a video here</strong><br>or <span class="clepit-video-click-text">click to select</span>';const c=l.createStyledElement("button",`${l.classNames.block.videoDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});c.type="button",c.textContent="✕",i.appendChild(r),i.appendChild(s),i.appendChild(c),e.addEventListener(a,c,"click",e=>{e.preventDefault(),e.stopPropagation();const t=c.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");t&&Ds.removeBlock(a,Ds.getBlockIndex(a,t))}),e.addEventListener(a,i,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,i,"dragleave",()=>{i.classList.remove("clepit-video-drop-area--dragover")}),e.addEventListener(a,i,"dragover",e=>{e.preventDefault(),e.stopPropagation(),i.classList.add("clepit-video-drop-area--dragover")}),e.addEventListener(a,i,"drop",r=>{r.preventDefault(),r.stopPropagation(),i.classList.remove("clepit-video-drop-area--dragover"),e.handleFileDrop(r,t,n,a,o)}),e.addEventListener(a,i,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,i,"mousedown",e=>{e.preventDefault(),e.stopPropagation()});const d=a?C.getState().getInstance(a):null,p=d?.config.classNames?.tooltips,u=d?.config.styles?.tooltips;ke(c,"Delete block","below",p,u),t.appendChild(i)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidVideoFile(t)?e.processVideoFile(t,n,a,o,i):e.showError(n,"Please select a valid video file (MP4, WebM, OGV)")}}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="video/*",i.style.display="none",i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidVideoFile(i)?e.processVideoFile(i,t,n,a,o):e.showError(t,"Please select a valid video file (MP4, WebM, OGV)")}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static isValidVideoFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("video/")}static async processVideoFile(t,n,a,o,i){e.showLoading(n);try{let r=await a(t);if(r){e.renderVideo(n,{alignment:"center",alt:t.name,caption:"",url:r},a,o,i);const s=n.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id");s&&C.getState().updateBlockData(o,Ds.getBlockIndex(o,s),Ds.getBlockData(s).data)}else e.showError(n,"Failed to upload video. Please try again.")}catch(r){console.error("Video upload error:",r),e.showError(n,"Failed to upload video. Please try again.")}}static showLoading(e){e.innerHTML="";const t=l.createStyledElement("div","clepit-video-loading",void 0);t.textContent="Uploading video...",e.appendChild(t)}static showError(e,t){e.innerHTML="";const n=l.createStyledElement("div","clepit-video-error",void 0);n.textContent=t,e.appendChild(n)}static setAlignment(e,t){const n=e.querySelector(".clepit-video-wrapper");n&&(n.classList.remove("clepit-video-wrapper--left","clepit-video-wrapper--center","clepit-video-wrapper--right"),n.classList.add(`clepit-video-wrapper--${t}`));const a=Ds.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&C.getState().partialUpdateBlockData(a,Ds.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${l.classNames.block.video.wrapper} video`),n=e.querySelector(`.${l.classNames.block.video.wrapper} iframe`),a=e.querySelector(`.${l.classNames.block.video.captionEditable}`);let o=!1,i=!1,r=!1;return t&&t.getAttribute("src")?.trim()||(o=!0),n&&n.getAttribute("src")?.trim()||(i=!0),a?h(a.innerHTML)&&(r=!0):r=!0,o&&i&&r}static isEmptyData(e){return!e.url?.trim()&&h(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Ni=class e{static render(t,n,a,o){if(l.injectStyles("clepit-video-output-styles",Ei),!e.validate(t))return X();if(Li.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alignment||"center",c=l.createStyledElement("div","clepit-output-video-container",{classNames:o?.container,styles:a?.container}),d=l.createStyledElement("div","clepit-output-video-wrapper");switch(s){case"left":d.classList.add("clepit-output-video-wrapper--left");break;case"center":d.classList.add("clepit-output-video-wrapper--center");break;case"right":d.classList.add("clepit-output-video-wrapper--right")}const u=vt(i),h=yt(i);if(u||h){const e=p("iframe","clepit-output-video-iframe");e.src=i,e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),e.style.maxWidth="100%",e.style.width="560px",e.style.height="315px",e.style.display="block",e.style.borderRadius="8px",d.appendChild(e),c.appendChild(d)}else{const e=p("video","clepit-output-video");e.src=i,e.controls=!0,e.preload="metadata",e.style.maxWidth="100%",e.style.height="auto",e.style.display="block",d.appendChild(e),c.appendChild(d)}if(r){const e=l.createStyledElement("figcaption","clepit-output-video-caption",{classNames:o?.caption,styles:a?.caption});e.innerHTML=m(r),c.appendChild(e)}if(a&&(a.container&&Object.assign(c.style,a.container),a.caption)){const e=c.querySelector(".clepit-output-video-caption");e&&Object.assign(e.style,a.caption)}if(o&&(o.container&&c.classList.add(o.container),o.caption)){const e=c.querySelector(".clepit-output-video-caption");e&&e.classList.add(o.caption)}return c}static draw(t,n=R){if(!e.validate(t)||Li.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-video-container");const o=n.create("div");o.addClass("clepit-output-video-wrapper");const i=t.alignment??"center";i&&o.addClass(`clepit-output-video-wrapper--${i}`);const r=n.create("video");if(r.addClass("clepit-output-video"),r.setAttribute("src",t.url),r.setAttribute("controls","controls"),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-video-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},Bi=(e,t,n)=>{const a=Mi(e,t,n);return a&&(a.setAttribute("data-block-type",e.type),e.id&&(a.setAttribute("data-clepit-block-id",e.id),n?.anchorTargets&&a.setAttribute("id",e.id))),a},Mi=(e,t,n)=>{switch(e.type){case"alert":return Nt.draw(e.data,t);case"audio":return Dt.draw(e.data,t);case"checklist":return Pt.draw(e.data,t);case"code":return Se.draw(e.data,t,n);case"collapsible":return Ii.draw(e.data,t,n);case"collection":return Zt.draw(e.data,t);case"columns":return nn.draw(e.data,t,n);case"date":return cn.draw(e.data,t);case"delimiter":return un.draw(e.data,t);case"doc_card":return bn.draw(e.data,t,n);case"embed":return rt.draw(e.data,t,n);case"file":return kn.draw(e.data,t);case"glance":return An.draw(e.data,t);case"header":return Ln.draw(e.data,t);case"image":return In.draw(e.data,t);case"issues":return Dn.draw(e.data,t,n);case"latex":return yi.draw(e.data,t);case"list":return Hn.draw(e.data,t);case"mermaid":return xi.draw(e.data,t);case"openapi":return ga.draw(e.data,t);case"paragraph":return va.draw(e.data,t);case"quote":return wa.draw(e.data,t);case"sketch":return Ba.draw(e.data,t);case"table":return Ja.draw(e.data,t);case"toc":return eo.draw(e.data,t,n);case"updates":return Ai.draw(e.data,t);case"video":return Ni.draw(e.data,t);default:return $i(e)}},$i=e=>(console.warn("drawBlock: no drawer for block",e),null),Ii=class e{static render(t,n,a,o){if(l.injectStyles("collapsible-output",Wt),!e.validate(t))return X();const i=l.createStyledElement("details","clepit-collapsible clepit-output-collapsible",{classNames:o?.section,styles:a?.section});i.open=t.open??!1;const r=document.createElement("summary"),s=document.createElement("span");s.innerHTML=m(t.html),r.appendChild(s),i.appendChild(r);const c=document.createElement("div");c.className="clepit-collapsible__children";for(const l of t.children??[])c.appendChild(e.renderChild(l,n));return i.appendChild(c),i}static renderChild(e,t){const n=Lr.find(t=>t.type===e.type);if(!n){const t=document.createElement("div");return t.className="clepit-collapsible__unknown-child",t.textContent=`Unsupported block: ${e.type}`,t}return n.output.render(e.data,t)}static draw(t,n=R,a){if(!e.validate(t))return null;const o=n.create("details");o.addClass("clepit-collapsible","clepit-output-collapsible"),t.open&&o.setAttribute("open","");const i=n.create("summary"),r=n.create("span");r.setHtml(t.html),i.append(r),o.append(i);const s=n.create("div");s.addClass("clepit-collapsible__children");for(const e of t.children??[]){const t=Bi(e,n,a);t&&s.append(t)}return o.append(s),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"html"in e&&"string"==typeof e.html&&(void 0===e.children||Array.isArray(e.children))}},Ti={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12,2C6.48,2,2,6.48,2,12c0,5.52,4.48,10,10,10s10-4.48,10-10C22,6.48,17.52,2,12,2z M15.79,11.71l-3.08,3.08 c-0.39,0.39-1.02,0.39-1.42,0l-3.08-3.08c-0.39-0.39-0.39-1.03,0-1.42c0.39-0.39,1.02-0.39,1.41,0L12,12.67l2.38-2.38 c0.39-0.39,1.02-0.39,1.41,0C16.18,10.68,16.18,11.32,15.79,11.71z"></path></svg>',get input(){return Gt},label:"Collapsible section",get output(){return Ii},testId:"block-type-collapsible",type:"collapsible"},_i=/* @__PURE__ */new WeakMap,qi=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-collection")?e:e.querySelector(".clepit-collection");if(t){const e=_i.get(t);if(e)return e;const n=t.getAttribute("data-collection-id");if(n)return{collectionId:n}}return{collectionId:""}}static render(e,t,n){l.injectStyles("collection-input",Xt);const a=t??{collectionId:""},o=Zt.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-collection--input"),o.setAttribute("contenteditable","false"),_i.set(o,a),o}static isEmpty(t){return""===e.save(t).collectionId}static isEmptyData(e){return!e.collectionId}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Di={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><g><g><path d="M5,11h4c1.1,0,2-0.9,2-2V5c0-1.1-0.9-2-2-2H5C3.9,3,3,3.9,3,5v4C3,10.1,3.9,11,5,11z"></path><path d="M5,21h4c1.1,0,2-0.9,2-2v-4c0-1.1-0.9-2-2-2H5c-1.1,0-2,0.9-2,2v4C3,20.1,3.9,21,5,21z"></path><path d="M13,5v4c0,1.1,0.9,2,2,2h4c1.1,0,2-0.9,2-2V5c0-1.1-0.9-2-2-2h-4C13.9,3,13,3.9,13,5z"></path><path d="M15,21h4c1.1,0,2-0.9,2-2v-4c0-1.1-0.9-2-2-2h-4c-1.1,0-2,0.9-2,2v4C13,20.1,13.9,21,15,21z"></path></g></g></svg>',get input(){return qi},label:"Collection",get output(){return Zt},section:"media",testId:"block-type-collection",type:"collection"},zi=/* @__PURE__ */new WeakMap;var ji=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-columns")?e:e.querySelector(".clepit-columns");if(!t)return{columns:[[],[]]};const n=zi.get(t)??[],a=[];return t.querySelectorAll(":scope > .clepit-columns__column").forEach((e,t)=>{const o=n[t]??[],i=[];e.querySelectorAll(":scope > .clepit-columns__child").forEach((e,t)=>{const n=o[t],a=e.getAttribute("data-child-type")??n?.type,r=a?function(e){return Lr.find(t=>t.type===e)}(a):void 0;if(r){const t=r.input.save(e);i.push({...n?.id?{id:n.id}:{},data:t,type:r.type})}else n&&i.push(n)}),a.push(i)}),{columns:a.length>=2?a:[[],[]]}}static render(t,n,a){l.injectStyles("columns-input",en);const o=n&&Array.isArray(n.columns)&&n.columns.length>=2?n:{columns:[[],[]]},i=l.createStyledElement("div","clepit-columns clepit-columns--input",{classNames:a?.classNames?.container,styles:a?.styles?.container});return zi.set(i,o.columns.map(e=>[...e])),o.columns.forEach(n=>{const o=l.createStyledElement("div","clepit-columns__column",{classNames:a?.classNames?.column,styles:a?.styles?.column});n.forEach(n=>{o.appendChild(e.renderChild(t,n))}),i.appendChild(o)}),i}static renderChild(e,t){const n=document.createElement("div");n.className="clepit-columns__child";const a=Ds.renderTool(t.type,t.data,e);if(a)n.setAttribute("data-child-type",t.type),n.appendChild(a);else{const e=document.createElement("div");e.className="clepit-columns__unknown-child",e.textContent=`Unsupported block: ${t.type}`,n.appendChild(e)}return n}static isEmpty(e){const t=e.querySelector(".clepit-columns");return!t||0===t.querySelectorAll(".clepit-columns__child").length}static isEmptyData(e){return(e.columns??[]).every(e=>0===e.length)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Hi={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M14.67 5v14H9.33V5zm1 14H21V5h-5.33zm-7.34 0V5H3v14z"></path></svg>',get input(){return ji},label:"Columns",get output(){return nn},testId:"block-type-columns",type:"columns"},Oi=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{date:(e.matches('input[type="date"]')?e:e.querySelector('input[type="date"]'))?.value??""}}static render(t,n,a){l.injectStyles("date-input",on);const o=l.createStyledElement("input","clepit-date clepit-date--input",{classNames:a?.classNames?.pill,styles:a?.styles?.pill});return o.type="date",n?.date&&ln(n.date)&&(o.value=n.date),e.addEventListener(t,o,"keydown",e=>{e.stopPropagation()}),o}static isEmpty(t){return""===e.save(t).date}static isEmptyData(e){return!e.date}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Pi={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M20 3h-1V2c0-.55-.45-1-1-1s-1 .45-1 1v1H7V2c0-.55-.45-1-1-1s-1 .45-1 1v1H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-1 18H5c-.55 0-1-.45-1-1V8h16v12c0 .55-.45 1-1 1z"></path></svg>',get input(){return Oi},label:"Date",get output(){return cn},testId:"block-type-date",type:"date"},Ri={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M4 11h16v2H4z" fill-rule="evenodd"></path></svg>',get input(){return pn},label:"Delimiter",get output(){return un},testId:"block-type-delimiter",type:"delimiter"},Fi=/* @__PURE__ */new WeakMap,Vi=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-doc-card")?e:e.querySelector(".clepit-doc-card");if(t){const e=Fi.get(t);if(e)return e;const n=t.getAttribute("data-page-id");if(n)return{pageId:n,title:t.querySelector(".clepit-doc-card__title")?.textContent??""}}return{pageId:"",title:""}}static render(e,t,n){l.injectStyles("doc-card-input",mn);const a=t??{pageId:"",title:""},o=bn.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-doc-card--input"),o.setAttribute("contenteditable","false"),Fi.set(o,a),o}static isEmpty(t){return""===e.save(t).pageId}static isEmptyData(e){return!e.pageId}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Ui={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M14.59 2.59c-.38-.38-.89-.59-1.42-.59H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8.83c0-.53-.21-1.04-.59-1.41l-4.82-4.83zM15 18H9c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1zm0-4H9c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1zm-2-6V3.5L18.5 9H14c-.55 0-1-.45-1-1z"></path></svg>',get input(){return Vi},label:"Doc card",get output(){return bn},section:"media",testId:"block-type-doc-card",type:"doc_card"},Wi={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M17 7h-3c-.55 0-1 .45-1 1s.45 1 1 1h3c1.65 0 3 1.35 3 3s-1.35 3-3 3h-3c-.55 0-1 .45-1 1s.45 1 1 1h3c2.76 0 5-2.24 5-5s-2.24-5-5-5m-9 5c0 .55.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1H9c-.55 0-1 .45-1 1m2 3H7c-1.65 0-3-1.35-3-3s1.35-3 3-3h3c.55 0 1-.45 1-1s-.45-1-1-1H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h3c.55 0 1-.45 1-1s-.45-1-1-1"></path></svg>',get input(){return ht},label:"Embed",get output(){return rt},section:"media",testId:"block-type-embed",type:"embed"},Ki=/* @__PURE__ */new WeakMap,Gi=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.classList.contains("clepit-file-host")?e:e.querySelector(".clepit-file-host");if(t){const e=Ki.get(t);if(e)return e}return{name:"",url:""}}static render(t,n,a,o){l.injectStyles("file-input",vn);const i=document.createElement("div");return i.className="clepit-file-host",i.setAttribute("contenteditable","false"),a?.url&&a.name&&Ki.set(i,a),e.renderState(i,t,n,o),i}static renderState(t,n,a,o){t.innerHTML="";const i=Ki.get(t);if(!i){const i=document.createElement("button");return i.type="button",i.className="clepit-file__upload",i.setAttribute("data-testid","file-upload-button"),i.textContent="Upload file",e.addEventListener(a,i,"click",()=>{e.pick(t,n,a,o)}),void t.appendChild(i)}const r=kn.render(i,void 0,o?.styles,o?.classNames);r.removeAttribute("href"),t.appendChild(r)}static pick(t,n,a,o){const i=document.createElement("input");i.type="file",i.addEventListener("change",async()=>{const r=i.files?.[0];if(!r)return;const s=await n(r);Ki.set(t,{contentType:r.type||void 0,name:r.name,size:r.size,url:s}),e.renderState(t,n,a,o)}),i.click()}static isEmpty(t){return""===e.save(t).url}static isEmptyData(e){return!e.url}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Ji={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M16.5 6.75v10.58c0 2.09-1.53 3.95-3.61 4.15-2.39.23-4.39-1.64-4.39-3.98V5.14c0-1.31.94-2.5 2.24-2.63 1.5-.15 2.76 1.02 2.76 2.49v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6.75c0-.41-.34-.75-.75-.75s-.75.34-.75.75v8.61c0 1.31.94 2.5 2.24 2.63 1.5.15 2.76-1.02 2.76-2.49V5.17c0-2.09-1.53-3.95-3.61-4.15C9.01.79 7 2.66 7 5v12.27c0 2.87 2.1 5.44 4.96 5.71 3.29.3 6.04-2.26 6.04-5.48V6.75c0-.41-.34-.75-.75-.75s-.75.34-.75.75z"></path></svg>',get input(){return Gi},label:"File",get output(){return kn},section:"media",testId:"block-type-file",type:"file"},Xi={html:"",label:""},Yi=class e{static{this.placeholder="At a glance"}static save(e){const t=e.classList.contains("clepit-glance")?e:e.querySelector(".clepit-glance");if(!t)return{rows:[]};const n=[...t.querySelectorAll(".clepit-glance-label")],a=[...t.querySelectorAll(".clepit-glance-value")],o=n.map((e,t)=>({html:m(a[t]?.innerHTML??""),label:e.textContent??""})),i=t.getAttribute("data-variant")??"plain",r=t.querySelector(".clepit-glance-caption")?.textContent??"";return r?{caption:r,rows:o,variant:i}:{rows:o,variant:i}}static render(e,t,n){l.injectStyles("clepit-glance-input-styles","\n.clepit-glance--input {\n cursor: text;\n}\n\n.clepit-glance--input .clepit-glance-label:empty::before,\n.clepit-glance--input .clepit-glance-value:empty::before {\n color: var(--clepit-text-subtle);\n content: attr(data-placeholder);\n font-style: italic;\n pointer-events: none;\n}\n");const a=t?.rows?.length?t:{rows:[Xi]},o=An.render(a,void 0,n?.styles,n?.classNames);o.classList.add("clepit-glance--input");for(const i of o.querySelectorAll(".clepit-glance-label"))i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",ne(e,"glanceLabelHint","Label"));for(const i of o.querySelectorAll(".clepit-glance-value"))i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",ne(e,"glanceValueHint","Value"));return o}static changeVariant(t,n,a){const o=C.getState().getInstance(a);if(!o)return;if((t.getAttribute("data-variant")??"plain")===n)return;const i=Ds.getBlockIndex(a,t.closest(`.${l.classNames.block.container}`)?.getAttribute("data-id")),r={...e.save(t),variant:n},s={classNames:o.config.classNames?.blocks?.glance,margins:o.config.margins,styles:o.config.styles?.blocks?.glance},c=e.render(a,r,s);t.replaceWith(c),C.getState().updateBlockData(a,i,r)}static isEmpty(t){return e.isEmptyData(e.save(t))}static isEmptyData(e){return!e?.rows?.length||e.rows.every(e=>""===e.label.trim()&&""===m(e.html).trim())}static destroy(e){}},Zi={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><g><g><path d="M15.59,3.59C15.21,3.21,14.7,3,14.17,3H5C3.9,3,3.01,3.9,3.01,5L3,19c0,1.1,0.89,2,1.99,2H19c1.1,0,2-0.9,2-2V9.83 c0-0.53-0.21-1.04-0.59-1.41L15.59,3.59z M8,17c-0.55,0-1-0.45-1-1s0.45-1,1-1s1,0.45,1,1S8.55,17,8,17z M8,13c-0.55,0-1-0.45-1-1 s0.45-1,1-1s1,0.45,1,1S8.55,13,8,13z M8,9C7.45,9,7,8.55,7,8s0.45-1,1-1s1,0.45,1,1S8.55,9,8,9z M14,9V4.5l5.5,5.5H15 C14.45,10,14,9.55,14,9z"></path></g></g></svg>',get input(){return Yi},label:"At a glance",get output(){return An},testId:"block-type-glance",type:"glance"},Qi={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M5 5.5C5 6.33 5.67 7 6.5 7h4v10.5c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5V7h4c.83 0 1.5-.67 1.5-1.5S18.33 4 17.5 4h-11C5.67 4 5 4.67 5 5.5z"></path></svg>',get input(){return En},label:"Header",get output(){return Ln},shortcut:Fa("1"),testId:"block-type-header",type:"header"},er={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2M8.5 13.5l2.5 3.01L14.5 12l4.5 6H5z"></path></svg>',get input(){return $n},label:"Image",get output(){return In},section:"media",testId:"block-type-image",type:"image"},tr={},nr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){return{}}static render(e,t,n){l.injectStyles("issues-input",Tn);const a=C.getState().getInstance(e)?.config,o=C.getState().getData(e)?.blocks??[],i=Dn.render({},{documentBlocks:o,issueLabels:a?.issueLabels,issues:tr[e]},n?.styles,n?.classNames);return i.classList.add("clepit-issues--input"),i.setAttribute("contenteditable","false"),i}static refresh(t,n){tr[t]={...tr[t],...n};const a=document.getElementById(t);if(a)for(const o of Array.from(a.querySelectorAll(`.${l.classNames.block.container}[data-tool="issues"]`))){const n=o.querySelector(`.${l.classNames.block.content}`);if(!n)continue;const a=C.getState().getInstance(t),i={classNames:a?.config.classNames?.blocks?.issues,styles:a?.config.styles?.blocks?.issues};n.replaceChildren(e.render(t,{},i))}}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){delete tr[t];const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},ar={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M21.29,5.89l-10,10c-0.39,0.39-1.02,0.39-1.41,0l-2.83-2.83c-0.39-0.39-0.39-1.02,0-1.41l0,0c0.39-0.39,1.02-0.39,1.41,0 l2.12,2.12l9.29-9.29c0.39-0.39,1.02-0.39,1.41,0l0,0C21.68,4.87,21.68,5.5,21.29,5.89z M15.77,2.74c-1.69-0.69-3.61-0.93-5.61-0.57 C6.09,2.9,2.84,6.18,2.15,10.25C1.01,17,6.63,22.78,13.34,21.91c3.96-0.51,7.28-3.46,8.32-7.31c0.4-1.47,0.44-2.89,0.21-4.22 c-0.13-0.8-1.12-1.11-1.7-0.54v0c-0.23,0.23-0.33,0.57-0.27,0.89c0.22,1.33,0.12,2.75-0.52,4.26c-1.16,2.71-3.68,4.7-6.61,4.97 c-5.1,0.47-9.33-3.85-8.7-8.98c0.43-3.54,3.28-6.42,6.81-6.91c1.73-0.24,3.37,0.09,4.77,0.81c0.39,0.2,0.86,0.13,1.17-0.18l0,0 c0.48-0.48,0.36-1.29-0.24-1.6C16.31,2.98,16.04,2.85,15.77,2.74z"></path></svg>',get input(){return nr},label:"Linked issues",get output(){return Dn},section:"media",testId:"block-type-issues",type:"issues"},or={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5m0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5m0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5M7 19h14v-2H7zm0-6h14v-2H7zm0-8v2h14V5z"></path></svg>',get input(){return jn},label:"List",get output(){return Hn},testId:"block-type-list",type:"list"},ir="clepit-openapi__source",rr=(e,t)=>{const n=e.trim();if(""===n)return{};if(/^https?:\/\//i.test(n))return{url:n};try{return{spec:JSON.parse(n)}}catch{return t??{}}},sr=class e{static{this.placeholder="Paste an OpenAPI document, or a URL to one…"}static{this.dataMap=/* @__PURE__ */new WeakMap}static render(t,n,a){l.injectStyles("clepit-openapi-input-styles","\n.clepit-openapi-input {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.clepit-openapi__source {\n background: var(--clepit-code-bg);\n border: 1px solid var(--clepit-code-border);\n border-radius: var(--clepit-radius-md);\n color: var(--clepit-code-text);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 13px;\n max-height: 240px;\n overflow: auto;\n padding: 12px;\n white-space: pre-wrap;\n}\n\n.clepit-openapi__source[data-placeholder]:empty::before {\n color: var(--clepit-text-subtle);\n content: attr(data-placeholder);\n font-style: italic;\n pointer-events: none;\n}\n");const o=p("div","clepit-openapi-input"),i=p("div",ir);i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",ne(t,"openApiSourceHint",e.placeholder)),i.setAttribute("data-testid","openapi-source"),i.textContent=n?.url??(n?.spec?JSON.stringify(n.spec,null,2):"");const r=p("div","clepit-openapi-input__preview");return r.setAttribute("data-testid","openapi-preview"),n&&r.appendChild(ga.render(n)),i.addEventListener("input",()=>{const t=rr(i.textContent??"",e.dataMap.get(o));e.dataMap.set(o,t),r.replaceChildren(ga.render(t))}),n&&e.dataMap.set(o,n),o.appendChild(i),o.appendChild(r),o}static save(t){const n=(e=>e.classList.contains(ir)?e:e.querySelector(`.${ir}`))(t),a=t.classList.contains("clepit-openapi-input")?t:t.querySelector(".clepit-openapi-input"),o=a?e.dataMap.get(a):void 0;return rr(n?.textContent??"",o)}static isEmpty(t){return e.isEmptyData(e.save(t))}static isEmptyData(e){return void 0===e.spec&&!e.url}static destroy(e){}},lr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><g><path d="M13,13L13,13c-0.56,0.56-1.45,0.56-2,0.01L11,13c-0.55-0.55-0.55-1.44,0-1.99L11,11c0.55-0.55,1.44-0.55,1.99,0L13,11 C13.55,11.55,13.55,12.45,13,13z M12,6l2.12,2.12l2.5-2.5l-3.2-3.2c-0.78-0.78-2.05-0.78-2.83,0l-3.2,3.2l2.5,2.5L12,6z M6,12 l2.12-2.12l-2.5-2.5l-3.2,3.2c-0.78,0.78-0.78,2.05,0,2.83l3.2,3.2l2.5-2.5L6,12z M18,12l-2.12,2.12l2.5,2.5l3.2-3.2 c0.78-0.78,0.78-2.05,0-2.83l-3.2-3.2l-2.5,2.5L18,12z M12,18l-2.12-2.12l-2.5,2.5l3.2,3.2c0.78,0.78,2.05,0.78,2.83,0l3.2-3.2 l-2.5-2.5L12,18z"></path></g></svg>',get input(){return sr},label:"API reference",get output(){return ga},section:"media",testId:"block-type-openapi",type:"openapi"},cr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M20 11H4c-.55 0-1 .45-1 1s.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1M4 18h10c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1M20 6H4c-.55 0-1 .45-1 1v.01c0 .55.45 1 1 1h16c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1"></path></svg>',get input(){return fa},label:"Paragraph",get output(){return va},shortcut:Fa("0"),testId:"block-type-paragraph",type:"paragraph"},dr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"></path></svg>',get input(){return ka},label:"Quote",get output(){return wa},testId:"block-type-quote",type:"quote"},pr=/* @__PURE__ */new WeakMap,ur=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-sketch")?e:e.querySelector(".clepit-sketch");return(t?pr.get(t):void 0)??{strokes:[]}}static render(t,n,a){l.injectStyles("sketch-input",Aa);const o=n??{strokes:[]},i=Ba.render(o,void 0,a?.styles,a?.classNames);return i.classList.add("clepit-sketch--input"),i.setAttribute("contenteditable","false"),pr.set(i,o),e.attachDrawing(t,i),i}static attachDrawing(t,n){const a=n.querySelector("svg");if(!a)return;let o=null;const i=e=>{const t=a.getBoundingClientRect(),n=0===t.width?0:(e.clientX-t.left)/t.width*1e3,o=0===t.height?0:(e.clientY-t.top)/t.height*240;return[Math.round(100*n)/100,Math.round(100*o)/100]},r=()=>{const e=pr.get(n)??{strokes:[]},t=o&&o.length>=4?{strokes:[...e.strokes,{points:o}]}:e,i=Ba.render(t).querySelector("svg");i&&a.replaceChildren(...Array.from(i.childNodes))},s=[],l=(e,t)=>{a.addEventListener(e,t),s.push({element:a,event:e,handler:t})};l("pointerdown",e=>{o=i(e),e.target.setPointerCapture?.(e.pointerId)}),l("pointermove",e=>{o&&(o.push(...i(e)),r())});const c=()=>{if(o&&o.length>=4){const e=pr.get(n)??{strokes:[]};pr.set(n,{strokes:[...e.strokes,{points:o}]})}o=null,r()};l("pointerup",c),l("pointercancel",c),e.eventListenersMap[t]=[...e.eventListenersMap[t]??[],...s]}static isEmpty(t){return 0===e.save(t).strokes.length}static isEmptyData(e){return 0===(e.strokes??[]).length}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},hr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M18.85,10.39l1.06-1.06c0.78-0.78,0.78-2.05,0-2.83L18.5,5.09c-0.78-0.78-2.05-0.78-2.83,0l-1.06,1.06L18.85,10.39z M13.19,7.56l-9.05,9.05C4.05,16.7,4,16.83,4,16.96v3.54C4,20.78,4.22,21,4.5,21h3.54c0.13,0,0.26-0.05,0.35-0.15l9.05-9.05 L13.19,7.56z M19,17.5c0,2.19-2.54,3.5-5,3.5c-0.55,0-1-0.45-1-1s0.45-1,1-1c1.54,0,3-0.73,3-1.5c0-0.47-0.48-0.87-1.23-1.2 l1.48-1.48C18.32,15.45,19,16.29,19,17.5z M4.58,13.35C3.61,12.79,3,12.06,3,11c0-1.8,1.89-2.63,3.56-3.36C7.59,7.18,9,6.56,9,6 c0-0.41-0.78-1-2-1C5.74,5,5.2,5.61,5.17,5.64C4.82,6.05,4.19,6.1,3.77,5.76C3.36,5.42,3.28,4.81,3.62,4.38C3.73,4.24,4.76,3,7,3 c2.24,0,4,1.32,4,3c0,1.87-1.93,2.72-3.64,3.47C6.42,9.88,5,10.5,5,11c0,0.31,0.43,0.6,1.07,0.86L4.58,13.35z"></path></svg>',get input(){return ur},label:"Sketch",get output(){return Ba},section:"media",testId:"block-type-sketch",type:"sketch"},mr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M10 10.02h5V21h-5zM17 21h3c1.1 0 2-.9 2-2v-9h-5zm3-18H5c-1.1 0-2 .9-2 2v3h19V5c0-1.1-.9-2-2-2M3 19c0 1.1.9 2 2 2h3V10H3z"></path></svg>',get input(){return Ua},label:"Table",get output(){return Ja},section:"media",testId:"block-type-table",type:"table"},gr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){return{}}static render(e,t,n){l.injectStyles("toc-input",Ya);const a=C.getState().getData(e)?.blocks??[],o=eo.render({},{documentBlocks:a},n?.styles,n?.classNames);return o.classList.add("clepit-toc--input"),o.setAttribute("contenteditable","false"),o}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},br={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M4 9h12c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm0 4h12c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm0 4h12c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm15 0h2v-2h-2v2zm0-10v2h2V7h-2zm0 6h2v-2h-2v2z"></path></svg>',get input(){return gr},label:"Table of contents",get output(){return eo},testId:"block-type-toc",type:"toc"},fr={latex:"LaTeX",mermaid:"Mermaid"};function vr(e){const t=e.classList.contains("clepit-typeset")?e:e.querySelector(".clepit-typeset"),n=t?.querySelector(".clepit-typeset__source"),a=t?.querySelector(".clepit-typeset__title")?.textContent?.trim();return a?{source:n?.textContent??"",title:a}:{source:n?.textContent??""}}function yr(e,t,n,a){l.injectStyles("typeset-input",no);const o=n??{source:""},i=l.createStyledElement("div",`clepit-typeset clepit-output-typeset clepit-typeset--input clepit-typeset--${e}`,{classNames:a?.classNames?.wrapper,styles:a?.styles?.wrapper});i.setAttribute("data-language",e),i.setAttribute("data-rendered","source");const r=p("span","clepit-typeset__kind");r.textContent=fr[e],i.appendChild(r);const s=p("span","clepit-typeset__title");s.setAttribute("data-testid","typeset-title"),s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",t),s.textContent=o.title??"",i.appendChild(s);const c=p("pre","clepit-typeset__source");return c.setAttribute("contenteditable","true"),c.textContent=o.source,i.appendChild(c),i}var xr=class{static{this.placeholder=""}static save(e){return vr(e)}static render(e,t,n){return yr("latex",ne(e,"formulaTitleHint","What does this formula show?"),t,n)}static isEmpty(e){return""===vr(e).source.trim()}static isEmptyData(e){return!e.source.trim()}static destroy(e){}},kr=class{static{this.placeholder=""}static save(e){return vr(e)}static render(e,t,n){return yr("mermaid",ne(e,"diagramTitleHint","What does this diagram show?"),t,n)}static isEmpty(e){return""===vr(e).source.trim()}static isEmptyData(e){return!e.source.trim()}static destroy(e){}},wr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M16.5 4H7.56C6.7 4 6 4.7 6 5.56c0 .28.12.55.32.74L12.5 12l-6.18 5.7c-.2.19-.32.46-.32.74C6 19.3 6.7 20 7.56 20h8.94c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5H11l3.59-3.59c.78-.78.78-2.05 0-2.83L11 7h5.5c.83 0 1.5-.67 1.5-1.5S17.33 4 16.5 4z"></path></svg>',get input(){return xr},label:"LaTeX",get output(){return yi},section:"media",testId:"block-type-latex",type:"latex"},Cr={icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M14,10.5V11h-3v-0.5C11,9.67,10.33,9,9.5,9h-1V7h1C10.33,7,11,6.33,11,5.5v-3C11,1.67,10.33,1,9.5,1h-4C4.67,1,4,1.67,4,2.5 v3C4,6.33,4.67,7,5.5,7h1v2h-1C4.67,9,4,9.67,4,10.5v3C4,14.33,4.67,15,5.5,15h1v2h-1C4.67,17,4,17.67,4,18.5v3 C4,22.33,4.67,23,5.5,23h4c0.83,0,1.5-0.67,1.5-1.5v-3c0-0.83-0.67-1.5-1.5-1.5h-1v-2h1c0.83,0,1.5-0.67,1.5-1.5V13h3v0.5 c0,0.83,0.67,1.5,1.5,1.5h4c0.83,0,1.5-0.67,1.5-1.5v-3C21,9.67,20.33,9,19.5,9h-4C14.67,9,14,9.67,14,10.5z"></path></svg>',get input(){return kr},label:"Mermaid",get output(){return xi},section:"media",testId:"block-type-mermaid",type:"mermaid"},Ar=/* @__PURE__ */new WeakMap,Sr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-updates")?e:e.querySelector(".clepit-updates");if(t){const e=Ar.get(t);if(e)return e;const n=t.getAttribute("data-page-id");if(n)return{pageId:n}}return{}}static render(e,t,n){l.injectStyles("updates-input",wi);const a=t??{},o=Ai.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-updates--input"),o.setAttribute("contenteditable","false"),Ar.set(o,a),o}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Er=e=>e.section??"basic",Lr=[It,zt,Rt,Ft,Ti,Di,{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9m-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8z"></path></svg>',get input(){return Sr},label:"Updates",get output(){return Ai},section:"media",testId:"block-type-updates",type:"updates"},Hi,Pi,Ri,Ui,Wi,Ji,Zi,Qi,er,ar,or,lr,cr,dr,hr,wr,Cr,mr,br,{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M21 3H3c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h5v1c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-1h5c1.1 0 1.99-.9 1.99-2L23 5c0-1.11-.9-2-2-2m-1 14H4c-.55 0-1-.45-1-1V6c0-.55.45-1 1-1h16c.55 0 1 .45 1 1v10c0 .55-.45 1-1 1m-5.52-5.13-3.98 2.28c-.67.38-1.5-.11-1.5-.87V8.72c0-.77.83-1.25 1.5-.87l3.98 2.28c.67.39.67 1.35 0 1.74"></path></svg>',get input(){return Li},label:"Video",get output(){return Ni},section:"media",testId:"block-type-video",type:"video"}],Nr=["bold","inline-code","italic","link","marker","status","strikethrough","tooltip","underline"],Br=["alert","audio","checklist","code","collapsible","collection","columns","date","delimiter","doc_card","embed","file","glance","header","image","issues","latex","list","mermaid","openapi","paragraph","quote","sketch","table","toc","updates","video"],Mr=["asana","github_issues","jira","linear"],$r=["categoryCancelled","categoryDone","categoryStarted","categoryTodo","columnAssignee","columnIssue","columnStatus","columnTitle","connectAction","connectTool","linkedIssuesEmpty","noAccess","openInTool","providerUnreachable","showAsCard","unassigned","updatedRelative"],Ir=["connectGoogle","connectGoogleAction","noAccess","providerUnreachable","tryAgain","switchedOff","offerShowLive","viewOnGithub","truncated"],Tr=["editView","previewView","jsonView","copyJson","downloadJson","clearEditor","viewSwitcher"],_r=["insertLink","insertTooltip","inlineStatus","textField","urlField","tooltipField","statusLabelField","statusVariantField","urlPlaceholder","textPlaceholder","tooltipPlaceholder","statusLabelPlaceholder","cancel","apply","removeLink","statusInfo","statusSuccess","statusWarning","statusError","statusPlain"],qr=["formatText","textType","text","more","bold","italic","underline","strikethrough","inlineCode","link","highlight","status","tooltip"],Dr=["improve","shorten","lengthen","simplify","fix_grammar"],zr="clepit-block-type-selector",jr="clepit-code-language-submenu",Hr="clepit-code-theme-submenu",Or="clepit-convert-submenu",Pr="clepit-block-operations-menu";function Rr(e){return Br.includes(e)}function Fr(e,t,n){return e?.[t]??n}var Vr,Ur=class e{static{this.defaultClassName="clepit-block-toolbar"}static{this.menuAnchor="--clepit-block-toolbar"}static{this.submenuAnchorSeq=0}static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static{this.documentListeners=[]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap.get(t)||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap.set(t,i)}static addDocumentEventListener(t,n){const a=e=>n(e);document.addEventListener(t,a),e.documentListeners.push({event:t,handler:a})}static create({containerId:t,block:n}){const a=C.getState().getInstance(t);if(!a)return console.error("BlockToolbar::create: Instance not found for containerId:",t);const o=document.getElementById(t);if(!o)return console.error("BlockToolbar::create: Container not found for containerId:",t);e.eventListenersMap.has(o)||e.eventListenersMap.set(o,[]);const i=void 0!==a.config.audioUploader,r=void 0!==a.config.imageUploader,s=void 0!==a.config.videoUploader,c=a.config.classNames?.blockToolbar,d=a.config.classNames?.blockTypeMenu,u=a.config.classNames?.convertSubmenu,h=a.config.classNames?.operationsMenu,m=a.config.styles?.blockToolbar,g=a.config.styles?.blockTypeMenu,b=a.config.styles?.convertSubmenu,f=a.config.styles?.operationsMenu;e.remove(n),l.injectStyles("clepit-block-toolbar-styles",'\n.clepit-block-toolbar {\n position: absolute;\n top: 6px;\n left: 4px;\n z-index: 1000;\n display: none;\n flex-shrink: 0;\n gap: 2px;\n padding: 0;\n border: 0;\n background: transparent;\n}\n\n.clepit-block-toolbar--visible {\n display: flex !important;\n pointer-events: auto !important;\n}\n\n.clepit-block-toolbar--hidden {\n display: none !important;\n pointer-events: none !important;\n}\n\n.clepit-block--active .clepit-block-toolbar,\n.clepit-block:focus-within .clepit-block-toolbar,\n.clepit-block-toolbar[style*="display: flex"] {\n display: flex;\n pointer-events: auto;\n}\n\n@media (hover: hover) {\n .clepit-block:hover > .clepit-block-toolbar.clepit-block-toolbar--hidden {\n display: flex !important;\n pointer-events: auto !important;\n }\n}\n\n.clepit-block-toolbar-add,\n.clepit-block-toolbar-ops {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n padding: 0;\n border: 0;\n border-radius: var(--clepit-radius-md);\n background: transparent;\n color: var(--clepit-text-subtle);\n cursor: pointer;\n transition: background-color 120ms ease, color 120ms ease;\n}\n\n.clepit-block-toolbar-ops {\n cursor: grab;\n touch-action: none;\n}\n\n.clepit-block-toolbar-add svg,\n.clepit-block-toolbar-ops svg {\n display: block;\n width: 18px;\n height: 18px;\n}\n\n.clepit-block-toolbar-add:hover,\n.clepit-block-toolbar-ops:hover {\n background: var(--clepit-hover-bg);\n color: var(--clepit-text-muted);\n}\n\n.clepit-block-toolbar-add:focus-visible,\n.clepit-block-toolbar-ops:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: 1px;\n}\n\n.clepit-block[data-dragging] {\n opacity: 0.5;\n}\n\n.clepit-block[data-dragging] .clepit-block-toolbar-ops {\n cursor: grabbing;\n}\n\n.clepit-drop-line {\n position: fixed;\n top: var(--clepit-drop-line-top, 0);\n left: var(--clepit-drop-line-left, 0);\n width: var(--clepit-drop-line-width, 0);\n z-index: 1002;\n height: 2px;\n margin-top: -1px;\n border-radius: 1px;\n background: var(--clepit-primary);\n pointer-events: none;\n}\n\n@media (max-width: 768px) {\n .clepit-block-toolbar-add,\n .clepit-block-toolbar-ops {\n width: 44px;\n height: 44px;\n }\n}\n\n/* Block toolbar positioning and display classes */\n.clepit-block-toolbar--positioned {\n position: absolute;\n}\n\n.clepit-block-toolbar--menu-positioned {\n position: absolute;\n z-index: 1001;\n}\n\n.clepit-block-toolbar--submenu-positioned {\n position: absolute;\n top: 0;\n left: calc(100% + 4px);\n z-index: 998;\n}\n\n@supports (anchor-name: --a) {\n .clepit-code-language-submenu.clepit-block-toolbar--submenu-positioned,\n .clepit-code-theme-submenu.clepit-block-toolbar--submenu-positioned {\n position: fixed;\n position-area: inline-end span-block-end;\n position-try-fallbacks: flip-inline;\n inset: auto;\n margin-inline-start: 4px;\n }\n}\n\n.clepit-block-toolbar--item-hidden {\n display: none;\n}\n\n.clepit-block-toolbar--item-visible {\n display: flex;\n}\n\n.clepit-block-toolbar--separator-hidden {\n display: none;\n}\n\n.clepit-block-toolbar--separator-visible {\n display: block;\n}\n\n.clepit-block-toolbar--delete-disabled {\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n}\n\n.clepit-block-toolbar--delete-enabled {\n color: var(--clepit-error);\n}\n\n/* The toolbar stays absolutely positioned at every width. It used to go\n * position: static below 768px, which made it a flex item of .clepit-block —\n * and because it is appended after the content it landed to the RIGHT of the\n * text rather than above it, taking a further 60px off an already narrow\n * column. Absolute keeps it inside the gutter the block opens for it. */\n');const v=p("div",e.defaultClassName);v.id=`${t}-block-toolbar`,v.innerHTML="",l.applyStyling(v,{classNames:c?.container,styles:m?.container});const y=p("button","clepit-block-toolbar-add",{"data-testid":"toolbar-add-button",type:"button"});y.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M18 13h-5v5c0 .55-.45 1-1 1s-1-.45-1-1v-5H6c-.55 0-1-.45-1-1s.45-1 1-1h5V6c0-.55.45-1 1-1s1 .45 1 1v5h5c.55 0 1 .45 1 1s-.45 1-1 1"></path></svg>';const x=Fr(a.config.blockToolbarLabels,"addBlock","Add a block below");y.setAttribute("aria-label",x),ke(y,x,"above"),l.applyStyling(y,{classNames:c?.button,styles:m?.button}),e.addEventListener(o,y,"click",()=>e.showBlockTypeMenu({audioIsEnabled:i,block:n,classNames:d,containerId:t,imageIsEnabled:r,menuLabels:a.config.blockToolbarLabels,styles:g,toolLabels:a.config.blockToolLabels,videoIsEnabled:s}));const k=p("button","clepit-block-toolbar-ops",{"data-testid":"toolbar-operations-button",type:"button"});k.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"></path></svg>';const w=Fr(a.config.blockToolbarLabels,"blockActions","Drag to move, click for options");k.setAttribute("aria-label",w),ke(k,w,"above"),Ct(k,n,t),l.applyStyling(k,{classNames:c?.button,styles:m?.button}),e.addEventListener(o,k,"click",()=>e.showOperationsMenu({audioIsEnabled:i,block:n,classNames:h,containerId:t,convertSubmenuClassNames:u,convertSubmenuStyles:b,imageIsEnabled:r,operationLabels:a.config.blockToolbarLabels,styles:f,toolLabels:a.config.blockToolLabels,videoIsEnabled:s})),v.appendChild(y),v.appendChild(k),e.addEventListener(o,v,"click",e=>e.stopPropagation()),n.appendChild(v)}static showBlockTypeMenu({containerId:t,block:n,imageIsEnabled:a,videoIsEnabled:o,audioIsEnabled:i,classNames:r,styles:s,menuLabels:c,toolLabels:d}){e.closeAllMenus();const u=document.querySelector(`.${zr}`);if(u)return u.classList.remove(`${zr}--visible`),u.classList.add(`${zr}--hidden`),void setTimeout(()=>u.remove(),200);const h=p("div",zr);l.applyStyling(h,{classNames:r?.container,styles:s?.container});const m=p("input","",{placeholder:Fr(c,"searchBlocks","Search blocks..."),type:"text"});m.setAttribute("data-testid","block-type-search"),l.applyStyling(m,{classNames:r?.input,styles:s?.input}),h.appendChild(m);const g=document.querySelector(`#${t}`),b=p("div",`${zr}-items`),f=((e,t)=>t.filter(t=>kt(e,t.type)))(C.getState().getInstance(t)?.config,Lr).filter(e=>!("image"===e.type&&!a||"video"===e.type&&!o||"audio"===e.type&&!i)),v=(e=>{const t=/* @__PURE__ */new Map;for(const{shortcut:n}of e)n&&t.set(n,(t.get(n)??0)+1);return new Set([...t].filter(([,e])=>1===e).map(([e])=>e))})(f),y=(a,o)=>{b.innerHTML="";const i=o?[{key:"basic",label:Fr(c,"sectionBasic","Basic")},{key:"media",label:Fr(c,"sectionMedia","Media")}].filter(e=>a.some(t=>Er(t)===e.key)).map(e=>{const n=p("div","clepit-menu-group",{"data-testid":`block-type-section-${e.key}`,role:"group"}),a=p("p","clepit-menu-section",{id:`${t}-block-type-section-${e.key}`});return a.textContent=e.label,n.setAttribute("aria-labelledby",a.id),n.appendChild(a),b.appendChild(n),{...e,parent:n}}):[];a.forEach(a=>{const o=p("div","clepit-menu-item clepit-block-type-item");o.setAttribute("data-testid",`block-type-${a.type}`),l.applyStyling(o,{classNames:r?.item?.container,styles:s?.item?.container});const c=p("span","clepit-menu-icon "+("image"===a.type?"clepit-menu-icon--italic":""));c.innerHTML=a.icon,l.applyStyling(c,{classNames:r?.item?.icon,styles:s?.item?.icon}),o.appendChild(c);const u=p("span","clepit-menu-label");if(u.textContent=(Rr(a.type)?d?.[a.type]:void 0)??a.label,l.applyStyling(u,{classNames:r?.item?.text,styles:s?.item?.text}),o.appendChild(u),a.shortcut&&v.has(a.shortcut)){const e=p("span","clepit-menu-shortcut");e.textContent=a.shortcut,l.applyStyling(e,{classNames:r?.item?.shortcut,styles:s?.item?.shortcut}),o.appendChild(e)}e.addEventListener(g,o,"click",e=>{if(e.stopPropagation(),n){const e=Ds.getBlockIndex(t,n.getAttribute("data-id")||"");Ds.insertBlock({data:{html:""},type:a.type},t,e+1)}h.hidePopover()}),(i.find(e=>e.key===Er(a))?.parent??b).appendChild(o)})},x=e=>(Rr(e.type)?d?.[e.type]:void 0)??e.label;y(f,!0),e.addEventListener(g,m,"click",e=>e.stopPropagation()),e.addEventListener(g,m,"focus",e=>e.stopPropagation()),e.addEventListener(g,m,"input",()=>{const e=m.value.trim().toLowerCase(),t=""===e?f:f.filter(t=>[x(t),t.label,t.type].some(t=>t.toLowerCase().includes(e)));if(y(t,""===e),0===t.length){const e=p("div","clepit-not-found-message");e.textContent=Fr(c,"noBlockTypesFound","No block types found"),b.appendChild(e)}});const k=n?.querySelector('[data-testid="toolbar-add-button"]');var w,A;if(w=()=>[...b.querySelectorAll(".clepit-block-type-item")],A=()=>{"function"==typeof h.hidePopover&&h.matches(":popover-open")?h.hidePopover():h.remove(),k?.focus()},m.addEventListener("keydown",e=>{const t=w(),n=t.findIndex(e=>e.hasAttribute(At));switch(e.key){case"ArrowDown":return e.preventDefault(),void(t.length>0&&St(t,n<0?0:(n+1)%t.length));case"ArrowUp":return e.preventDefault(),void(t.length>0&&St(t,n<=0?t.length-1:n-1));case"Enter":if(n<0)return;return e.preventDefault(),void t[n]?.click();case"Escape":return e.preventDefault(),void A()}}),h.appendChild(b),h.classList.add(zr),h.setAttribute("popover","auto"),m.setAttribute("autofocus",""),n){const t=n.querySelector(`.${e.defaultClassName}`);t&&t.style.setProperty("anchor-name",e.menuAnchor)}e.menuHost(t).appendChild(h),h.addEventListener("toggle",e=>{"closed"===e.newState&&h.remove()}),"function"!=typeof h.showPopover?(h.classList.add(`${zr}--visible`),m.focus(),e.addDocumentEventListener("click",e=>{const t=e.target;h.contains(t)||n?.contains(t)||h.remove()})):h.showPopover()}static showOperationsMenu({containerId:t,block:n,classNames:a,styles:o,convertSubmenuClassNames:i,convertSubmenuStyles:r,imageIsEnabled:s,videoIsEnabled:c,audioIsEnabled:d,operationLabels:u,toolLabels:h}){e.closeAllMenus();const m=p("div",Pr);o?.container&&l.applyStyling(m,{classNames:a?.container,styles:o.container}),a?.container&&m.classList.add(a.container);const g=p("input","",{placeholder:Fr(u,"searchOperations","Search operations..."),type:"text"});g.setAttribute("data-testid","operations-search"),l.applyStyling(g,{classNames:a?.input,styles:o?.input}),m.appendChild(g);const b=document.querySelector(`#${t}`),f=p("div",`${Pr}-items`),v=n.getAttribute("data-tool");if(!v)return;const y=(e,t)=>Fr(u,e,t),x=i=>{const r=p("div","clepit-menu-item clepit-block-operation-item"+(i.danger?" clepit-menu-item--danger":""));l.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=p("span","clepit-menu-icon"+(i.textIcon?" clepit-menu-icon--text":""));i.textIcon?s.textContent=i.icon:s.innerHTML=i.icon,i.iconColor&&(s.style.color=i.iconColor),l.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const c=p("span","clepit-menu-label");if(c.textContent=i.label,l.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(c),i.shortcut){const e=p("span","clepit-menu-shortcut");e.textContent=i.shortcut,l.applyStyling(e,{classNames:a?.item?.shortcut,styles:o?.item?.shortcut}),r.appendChild(e)}if(i.submenu){const e=p("span","clepit-menu-arrow");e.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path></svg>',r.appendChild(e)}i.active&&r.classList.add("active"),"delete"===i.value&&(r.classList.add("clepit-block-toolbar--delete-enabled"),1===b.querySelectorAll(".clepit-block").length&&(r.classList.add("clepit-block-toolbar--delete-disabled"),r.setAttribute("aria-disabled","true"),r.title=y("deleteLastBlock","Cannot delete the last block"))),e.addEventListener(b,r,"click",a=>{a.stopPropagation(),i.submenu?i.submenu():(e.handleOperationSelect(i.value,n,t),m.remove())}),f.appendChild(r)},k=()=>{const e=p("div","clepit-menu-divider");l.applyStyling(e,{classNames:a?.divider,styles:o?.divider}),f.appendChild(e)},w=(e,t)=>{const a=(e=>{const t=n.querySelector(e)?.style.textAlign;return"left"===t?"left":"right"===t?"right":"center"})(t);return[{active:"left"===a,icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M14 15H4c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1zm0-8H4c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1zM4 13h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm0 8h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zM3 4c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1z"></path></svg>',label:y("alignLeft","Align left"),testId:`${e}-align-left`,value:`${e}AlignLeft`},{active:"center"===a,icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M7 16c0 .55.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1zm-3 5h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm0-8h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm3-5c0 .55.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1zM3 4c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1z"></path></svg>',label:y("alignCenter","Align center"),testId:`${e}-align-center`,value:`${e}AlignCenter`},{active:"right"===a,icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M4 21h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm6-4h10c.55 0 1-.45 1-1s-.45-1-1-1H10c-.55 0-1 .45-1 1s.45 1 1 1zm-6-4h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm6-4h10c.55 0 1-.45 1-1s-.45-1-1-1H10c-.55 0-1 .45-1 1s.45 1 1 1zM3 4c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1z"></path></svg>',label:y("alignRight","Align right"),testId:`${e}-align-right`,value:`${e}AlignRight`}]},C=(t,n,a,o)=>{const i={error:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"></path></svg>',label:y("variantError","Error")},info:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8"></path></svg>',label:y("variantInfo","Info")},plain:{icon:$t,label:y("variantPlain","Plain")},success:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"></path></svg>',label:y("variantSuccess","Success")},warning:{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 5.99 19.53 19H4.47zM12 2 1 21h22zm1 14h-2v2h2zm0-6h-2v4h2z"></path></svg>',label:y("variantWarning","Warning")}};return o.map(o=>({active:o===a,icon:i[o]?.icon??"",iconColor:e.getAlertIconColor(o),label:i[o]?.label??o,testId:`${t}-${o}`,value:`${n}${o}`}))};x({icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="m6.14 11.86-2.78 2.79c-.19.2-.19.51 0 .71l2.78 2.79c.31.32.85.09.85-.35V16H13c.55 0 1-.45 1-1s-.45-1-1-1H6.99v-1.79c0-.45-.54-.67-.85-.35m14.51-3.21-2.78-2.79c-.31-.32-.85-.09-.85.35V8H11c-.55 0-1 .45-1 1s.45 1 1 1h6.01v1.79c0 .45.54.67.85.35l2.78-2.79c.2-.19.2-.51.01-.7"></path></svg>',label:y("convert","Turn into"),submenu:()=>{document.querySelector(`.${jr}`)?.remove(),document.querySelector(`.${Hr}`)?.remove(),e.showConvertSubmenu({audioIsEnabled:d,block:n,classNames:i,containerId:t,imageIsEnabled:s,menuLabels:u,parentItem:f.querySelector('[data-testid="operation-convert"]'),parentMenu:m,styles:r,toolLabels:h,videoIsEnabled:c})},testId:"operation-convert",value:"convert"}),x({icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M13 19V7.83l4.88 4.88c.39.39 1.03.39 1.42 0s.39-1.02 0-1.41l-6.59-6.59a.996.996 0 0 0-1.41 0l-6.6 6.58a.996.996 0 1 0 1.41 1.41L11 7.83V19c0 .55.45 1 1 1s1-.45 1-1"></path></svg>',label:y("moveUp","Move up"),shortcut:"⌘⇧↑",testId:"operation-moveUp",value:"moveUp"}),x({icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M11 5v11.17l-4.88-4.88c-.39-.39-1.03-.39-1.42 0s-.39 1.02 0 1.41l6.59 6.59c.39.39 1.02.39 1.41 0l6.59-6.59a.996.996 0 1 0-1.41-1.41L13 16.17V5c0-.55-.45-1-1-1s-1 .45-1 1"></path></svg>',label:y("moveDown","Move down"),shortcut:"⌘⇧↓",testId:"operation-moveDown",value:"moveDown"});const A=(()=>{switch(v){case"image":return w("image",".clepit-image-wrapper");case"video":return w("video",".clepit-video-wrapper");case"audio":return w("audio",".clepit-audio-wrapper");case"code":return[{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M8.7 15.9 4.8 12l3.9-3.9c.39-.39.39-1.01 0-1.4a.984.984 0 0 0-1.4 0l-4.59 4.59c-.39.39-.39 1.02 0 1.41l4.59 4.6c.39.39 1.01.39 1.4 0s.39-1.01 0-1.4m6.6 0 3.9-3.9-3.9-3.9a.984.984 0 0 1 0-1.4c.39-.39 1.01-.39 1.4 0l4.59 4.59c.39.39.39 1.02 0 1.41l-4.59 4.6c-.39.39-1.01.39-1.4 0a.984.984 0 0 1 0-1.4"></path></svg>',label:y("codeLanguage","Language"),submenu:()=>e.showCodeLanguageSubmenu({block:n,classNames:i,containerId:t,menuLabels:u,parentItem:f.querySelector('[data-testid="code-language"]'),parentMenu:m,styles:r}),testId:"code-language",value:"codeLanguage"},{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><g><path d="M12,2C6.49,2,2,6.49,2,12s4.49,10,10,10c1.38,0,2.5-1.12,2.5-2.5c0-0.61-0.23-1.2-0.64-1.67c-0.08-0.1-0.13-0.21-0.13-0.33 c0-0.28,0.22-0.5,0.5-0.5H16c3.31,0,6-2.69,6-6C22,6.04,17.51,2,12,2z M17.5,13c-0.83,0-1.5-0.67-1.5-1.5c0-0.83,0.67-1.5,1.5-1.5 s1.5,0.67,1.5,1.5C19,12.33,18.33,13,17.5,13z M14.5,9C13.67,9,13,8.33,13,7.5C13,6.67,13.67,6,14.5,6S16,6.67,16,7.5 C16,8.33,15.33,9,14.5,9z M5,11.5C5,10.67,5.67,10,6.5,10S8,10.67,8,11.5C8,12.33,7.33,13,6.5,13S5,12.33,5,11.5z M11,7.5 C11,8.33,10.33,9,9.5,9S8,8.33,8,7.5C8,6.67,8.67,6,9.5,6S11,6.67,11,7.5z"></path></g></svg>',label:y("codeTheme","Theme"),submenu:()=>e.showCodeThemeSubmenu({block:n,classNames:i,containerId:t,menuLabels:u,parentItem:f.querySelector('[data-testid="code-theme"]'),parentMenu:m,styles:r}),testId:"code-theme",value:"codeTheme"}];case"embed":return ht.save(n).issue?[{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M17.63 5.84C17.27 5.33 16.67 5 16 5L5 5.01C3.9 5.01 3 5.9 3 7v10c0 1.1.9 1.99 2 1.99L16 19c.67 0 1.27-.33 1.63-.84l3.96-5.58c.25-.35.25-.81 0-1.16l-3.96-5.58z"></path></svg>',label:y("embedShowChip","Show as chip"),testId:"embed-show-chip",value:"embedShowChip"},{icon:Bt,label:y("embedShowLink","Show as link"),testId:"embed-show-link",value:"embedShowLink"},{icon:Mt,label:y("embedCopyLink","Copy link"),testId:"embed-copy-link",value:"embedCopyLink"}]:[{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M8 6.82v10.36c0 .79.87 1.27 1.54.84l8.14-5.18c.62-.39.62-1.29 0-1.69L9.54 5.98C8.87 5.55 8 6.03 8 6.82"></path></svg>',label:y("embedShowLive","Show live"),testId:"embed-show-live",value:"embedShowLive"},{icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M19 4H5c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2zm-1 14H6c-.55 0-1-.45-1-1V8h14v9c0 .55-.45 1-1 1z"></path></svg>',label:y("embedShowCard","Show as card"),testId:"embed-show-card",value:"embedShowCard"},{icon:Bt,label:y("embedShowLink","Show as link"),testId:"embed-show-link",value:"embedShowLink"},{icon:Mt,label:y("embedCopyLink","Copy link"),testId:"embed-copy-link",value:"embedCopyLink"}];case"header":{const t=e.getCurrentHeadingLevel(n);return[y("headingH1","Heading 1"),y("headingH2","Heading 2"),y("headingH3","Heading 3"),y("headingH4","Heading 4"),y("headingH5","Heading 5"),y("headingH6","Heading 6")].map((e,n)=>({active:`h${n+1}`===t,icon:`H${n+1}`,label:e,testId:`heading-h${n+1}`,textIcon:!0,value:`heading-h${n+1}`}))}case"list":{const e=n.querySelector(".clepit-list")?.getAttribute("data-type")||"unordered";return[{active:"unordered"===e,icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5m0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5m0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5M7 19h14v-2H7zm0-6h14v-2H7zm0-8v2h14V5z"></path></svg>',label:y("listUnordered","Unordered"),testId:"list-unordered",value:"listTypeunordered"},{active:"ordered"===e,icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M8 7h12c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zm12 10H8c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zm0-6H8c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zM4.5 16h-2c-.28 0-.5.22-.5.5s.22.5.5.5H4v.5h-.5c-.28 0-.5.22-.5.5s.22.5.5.5H4v.5H2.5c-.28 0-.5.22-.5.5s.22.5.5.5h2c.28 0 .5-.22.5-.5v-3c0-.28-.22-.5-.5-.5zm-2-11H3v2.5c0 .28.22.5.5.5s.5-.22.5-.5v-3c0-.28-.22-.5-.5-.5h-1c-.28 0-.5.22-.5.5s.22.5.5.5zm2 5h-2c-.28 0-.5.22-.5.5s.22.5.5.5h1.3l-1.68 1.96c-.08.09-.12.21-.12.32v.22c0 .28.22.5.5.5h2c.28 0 .5-.22.5-.5s-.22-.5-.5-.5H3.2l1.68-1.96c.08-.09.12-.21.12-.32v-.22c0-.28-.22-.5-.5-.5z"></path></svg>',label:y("listOrdered","Ordered"),testId:"list-ordered",value:"listTypeordered"}]}case"alert":return C("alert","alertVariant",n.querySelector(".clepit-alert")?.getAttribute("data-variant")||"info",["info","warning","error","success","plain"]);case"glance":return C("glance","glanceVariant",n.querySelector(".clepit-glance")?.getAttribute("data-variant")||"plain",["plain","info","warning","error","success"]);case"delimiter":{const e=n.querySelector(".clepit-delimiter")?.getAttribute("data-variant")||"line";return[{active:"line"===e,icon:$t,label:y("delimiterLine","Line"),testId:"delimiter-line",value:"delimiterVariantline"},{active:"stars"===e,icon:"***",label:y("delimiterStars","Stars"),testId:"delimiter-stars",textIcon:!0,value:"delimiterVariantstars"}]}default:return[]}})();A.length>0&&(k(),A.forEach(x)),k(),x({danger:!0,icon:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2zM18 4h-2.5l-.71-.71c-.18-.18-.44-.29-.7-.29H9.91c-.26 0-.52.11-.7.29L8.5 4H6c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1"></path></svg>',label:y("delete","Delete"),shortcut:"⌘⇧⌫",testId:"operation-delete",value:"delete"});const S=f.querySelectorAll(".clepit-block-operation-item"),E=f.querySelectorAll(".clepit-menu-divider");if(e.addEventListener(b,g,"click",e=>e.stopPropagation()),e.addEventListener(b,g,"focus",e=>e.stopPropagation()),e.addEventListener(b,g,"input",e=>{(e=>{let t=0;S.forEach(n=>{(n.querySelector(".clepit-menu-label")?.textContent?.toLowerCase()||"").includes(e.toLowerCase())?(n.classList.remove("clepit-block-toolbar--item-hidden"),n.classList.add("clepit-block-toolbar--item-visible"),t++):(n.classList.remove("clepit-block-toolbar--item-visible"),n.classList.add("clepit-block-toolbar--item-hidden"))});const n=f.querySelector(".clepit-not-found-message");if(0===t&&""!==e.trim()){if(!n){const e=p("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=y("noOperationsFound","No operations found"),f.appendChild(e)}}else n&&n.remove();E.forEach(t=>{""!==e.trim()?(t.classList.remove("clepit-block-toolbar--separator-visible"),t.classList.add("clepit-block-toolbar--separator-hidden")):(t.classList.remove("clepit-block-toolbar--separator-hidden"),t.classList.add("clepit-block-toolbar--separator-visible"))})})(e.target.value)}),e.addEventListener(b,g,"keydown",e=>{"Escape"===e.key&&m.remove()}),m.appendChild(f),m.classList.add(Pr),m.setAttribute("popover","auto"),g.setAttribute("autofocus",""),n){const t=n.querySelector(`.${e.defaultClassName}`);t&&t.style.setProperty("anchor-name",e.menuAnchor)}e.menuHost(t).appendChild(m),m.addEventListener("toggle",e=>{"closed"===e.newState&&m.remove()}),"function"!=typeof m.showPopover?(m.classList.add(`${Pr}--visible`),g.focus(),e.addDocumentEventListener("click",e=>{const t=e.target;m.contains(t)||n?.contains(t)||t.closest?.(".clepit-block-toolbar-ops")||m.remove()})):m.showPopover()}static showConvertSubmenu({containerId:t,block:n,parentItem:a,parentMenu:o,classNames:i,styles:r,imageIsEnabled:s,videoIsEnabled:c,audioIsEnabled:d,menuLabels:u,toolLabels:h}){const m=document.querySelector(`.${Or}`);m&&m.remove();const g=n.getAttribute("data-tool");if(!g)return;const b=p("div",Or);b.classList.add(Or),b.classList.add(`${Or}--hidden`),r?.container&&l.applyStyles(b,r.container),i?.container&&b.classList.add(i.container);const f=p("input","",{placeholder:Fr(u,"searchConvertOptions","Search convert options..."),type:"text"});f.setAttribute("data-testid","convert-search"),l.applyStyling(f,{classNames:i?.input,styles:r?.input}),b.appendChild(f),setTimeout(()=>f.focus(),10);const v=document.querySelector(`#${t}`),y=p("div",`${Or}-items`),x=e=>(Rr(e.type)?h?.[e.type]:void 0)??e.label,k=C.getState().getInstance(t)?.config;Lr.filter(e=>e.type!==g&&(!!kt(k,e.type)&&(!("image"===e.type&&!s||"video"===e.type&&!c||"audio"===e.type&&!d)||void 0))).sort((e,t)=>x(e).localeCompare(x(t))).forEach(a=>{const s=p("div","clepit-menu-item clepit-convert-option-item");s.setAttribute("data-testid",a.testId),l.applyStyling(s,{classNames:i?.item?.container,styles:r?.item?.container});const c=p("span","clepit-menu-icon");c.innerHTML=a.icon,l.applyStyling(c,{classNames:i?.item?.icon,styles:r?.item?.icon}),s.appendChild(c);const d=p("span","clepit-menu-label");if(d.textContent=x(a),l.applyStyling(d,{classNames:i?.item?.text,styles:r?.item?.text}),s.appendChild(d),a.shortcut){const e=p("span","clepit-menu-shortcut");e.textContent=a.shortcut,l.applyStyling(e,{classNames:i?.item?.shortcut,styles:r?.item?.shortcut}),s.appendChild(e)}e.addEventListener(v,s,"click",i=>{i.stopPropagation(),e.turnInto(n,t,a.type),o.remove()}),y.appendChild(s)});const w=y.querySelectorAll(".clepit-convert-option-item");e.addEventListener(v,f,"click",e=>e.stopPropagation()),e.addEventListener(v,f,"focus",e=>e.stopPropagation()),e.addEventListener(v,f,"input",e=>{(e=>{let t=0;w.forEach(n=>{(n.querySelector(".clepit-menu-label")?.textContent?.toLowerCase()||"").includes(e.toLowerCase())?(n.classList.remove("clepit-block-toolbar--item-hidden"),n.classList.add("clepit-block-toolbar--item-visible"),t++):(n.classList.remove("clepit-block-toolbar--item-visible"),n.classList.add("clepit-block-toolbar--item-hidden"))});const n=y.querySelector(".clepit-not-found-message");if(0===t&&""!==e.trim()){if(!n){const e=p("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=Fr(u,"noConvertOptionsFound","No convert options found"),y.appendChild(e)}}else n&&n.remove()})(e.target.value)}),e.addEventListener(v,f,"keydown",t=>{"Escape"===t.key&&e.closeMenu(Or)}),b.appendChild(y);const A="--clepit-convert-parent-"+e.submenuAnchorSeq++;a.style.setProperty("anchor-name",A),b.style.setProperty("position-anchor",A),b.classList.remove(`${Or}--hidden`),b.setAttribute("popover","auto"),e.menuHost(t).appendChild(b),b.addEventListener("toggle",e=>{"closed"===e.newState&&b.remove()}),"function"!=typeof b.showPopover?(o.appendChild(b),b.classList.add(`${Or}--visible`),e.addDocumentEventListener("click",e=>{const t=e.target;b.contains(t)||a.contains(t)||o.contains(t)||b.remove()})):b.showPopover()}static handleOperationSelect(e,t,n){if(!t)return;const a=document.querySelector(`#${n}`);if(e.startsWith("convertTo")){const a=e.replace("convertTo",""),o=t.getAttribute("data-id");return void(o&&Ds.convertBlock(o,a,n))}if(e.startsWith("heading-")){const n=e.replace("heading-","");if(-1===Ds.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector('[contenteditable="true"]');return void(o&&En.changeLevel(o,n,a.id))}if(e.startsWith("listType")){const n=e.replace("listType","");if(-1===Ds.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-list");return void(o&&jn.changeType(o,n,a.id))}if(e.startsWith("alertVariant")){const n=e.replace("alertVariant","");if(-1===Ds.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-alert");return void(o&&Lt.changeVariant(o,n,a.id))}if(e.startsWith("glanceVariant")){const n=e.replace("glanceVariant","");if(-1===Ds.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-glance");return void(o&&Yi.changeVariant(o,n,a.id))}if(e.startsWith("delimiterVariant")){const n=e.replace("delimiterVariant","");if(-1===Ds.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-delimiter");if(!o)return;return pn.changeVariant(o,n,a.id)}if(e.startsWith("tableAction")){const n=e.replace("tableAction",""),a=t.querySelector(`.${l.classNames.block.content}`);if(!a)return;return Ua.handleAction(n,a)}if(e.startsWith("embed"))return ht.handleOperation(e,t,a.id);if(e.startsWith("imageAlign"))return $n.setAlignment(t,e.replace("imageAlign","").toLowerCase());if(e.startsWith("videoAlign"))return Li.setAlignment(t,e.replace("videoAlign","").toLowerCase());if(e.startsWith("audioAlign"))return qt.setAlignment(t,e.replace("audioAlign","").toLowerCase());if(e.startsWith("codeLanguage")){const n=e.replace("codeLanguage","");if(-1===Ds.getBlockIndex(a.id,t.getAttribute("data-id")))return;return ge.updateLanguage(t,n)}if(e.startsWith("codeTheme")){const n=e.replace("codeTheme","");if(-1===Ds.getBlockIndex(a.id,t.getAttribute("data-id")))return;return ge.updateTheme(t,n)}const o=Ds.getBlockIndex(a.id,t.getAttribute("data-id"));if(-1!==o)switch(e){case"delete":Ds.removeBlock(a.id,o);break;case"moveUp":o>0&&Ds.moveBlock(a.id,o,o-1);break;case"moveDown":o<Ds.getBlocks(a.id).length-1&&Ds.moveBlock(a.id,o,o+1);break;default:console.warn(`Unknown block operation: ${e}`)}}static showCodeLanguageSubmenu({parentItem:t,parentMenu:n,block:a,containerId:o,classNames:i,menuLabels:r,styles:s}){const c=document.querySelector(`.${jr}`);c&&c.remove();const d=document.querySelector(`.${Hr}`);d&&d.remove();const u=document.getElementById(o);if(!u)return;const h=a?.querySelector(`.${l.classNames.block.code.container}`)?.getAttribute("data-language")||"javascript",m=l.createStyledElement("div",jr,{classNames:i?.container,styles:s?.container});m.classList.add(Or,"clepit-block-toolbar--submenu-positioned");const g=p("input","",{placeholder:Fr(r,"searchLanguages","Search languages..."),type:"text"});g.setAttribute("data-testid","language-search"),m.appendChild(g);const b=ge.supportedLanguages;Object.entries(b).forEach(([t,r])=>{const c=l.createStyledElement("div","clepit-menu-item clepit-code-language-item",{classNames:i?.item?.container,styles:s?.item?.container});c.setAttribute("data-testid",`code-language-${t}`);const d=l.createStyledElement("span","",{classNames:i?.item?.text,styles:s?.item?.text});d.textContent=r.name,c.appendChild(d),t===h&&c.classList.add("active"),e.addEventListener(u,c,"click",i=>{i.stopPropagation(),e.handleOperationSelect(`codeLanguage${t}`,a,o),n.remove()}),m.appendChild(c)});const f=m.querySelectorAll(".clepit-code-language-item");e.addEventListener(u,g,"click",e=>e.stopPropagation()),e.addEventListener(u,g,"input",e=>{const t=e.target.value.toLowerCase();f.forEach(e=>{const n=e.querySelector("span")?.textContent?.toLowerCase()||"";e.classList.toggle("clepit-block-toolbar--item-hidden",!n.includes(t))})});const v="--clepit-code-parent-"+e.submenuAnchorSeq++;t.style.setProperty("anchor-name",v),m.style.setProperty("position-anchor",v),n.appendChild(m),setTimeout(()=>{m.classList.remove(`${jr}--hidden`),m.classList.add(`${jr}--visible`)},10),setTimeout(()=>{const t=e=>{const a=e.target,o=m.contains(a),i=n.contains(a);o||i||(m.classList.remove(`${jr}--visible`),m.classList.add(`${jr}--hidden`),setTimeout(()=>m.remove(),200),document.removeEventListener("click",t))};e.addDocumentEventListener("click",t)},0)}static showCodeThemeSubmenu({parentItem:t,parentMenu:n,block:a,containerId:o,classNames:i,menuLabels:r,styles:s}){const c=document.querySelector(`.${Hr}`);c&&c.remove();const d=document.querySelector(`.${jr}`);d&&d.remove();const u=document.getElementById(o);if(!u)return;const h=a?.querySelector(`.${l.classNames.block.code.container}`)?.getAttribute("data-theme")||"default",m=l.createStyledElement("div",Hr,{classNames:i?.container,styles:s?.container});m.classList.add(Or,"clepit-block-toolbar--submenu-positioned");const g=p("input","",{placeholder:Fr(r,"searchThemes","Search themes..."),type:"text"});g.setAttribute("data-testid","theme-search"),m.appendChild(g);const b=ge.supportedThemes;Object.entries(b).forEach(([t,r])=>{const c=l.createStyledElement("div","clepit-menu-item clepit-code-theme-item",{classNames:i?.item?.container,styles:s?.item?.container});c.setAttribute("data-testid",`code-theme-${t}`);const d=l.createStyledElement("span","",{classNames:i?.item?.text,styles:s?.item?.text});d.textContent=r.name,c.appendChild(d),t===h&&c.classList.add("active"),e.addEventListener(u,c,"click",i=>{i.stopPropagation(),e.handleOperationSelect(`codeTheme${t}`,a,o),n.remove()}),m.appendChild(c)});const f=m.querySelectorAll(".clepit-code-theme-item");e.addEventListener(u,g,"click",e=>e.stopPropagation()),e.addEventListener(u,g,"input",e=>{const t=e.target.value.toLowerCase();f.forEach(e=>{const n=e.querySelector("span")?.textContent?.toLowerCase()||"";e.classList.toggle("clepit-block-toolbar--item-hidden",!n.includes(t))})});const v="--clepit-code-parent-"+e.submenuAnchorSeq++;t.style.setProperty("anchor-name",v),m.style.setProperty("position-anchor",v),n.appendChild(m),setTimeout(()=>{m.classList.remove(`${Hr}--hidden`),m.classList.add(`${Hr}--visible`)},10),setTimeout(()=>{const t=e=>{const a=e.target,o=m.contains(a),i=n.contains(a);o||i||(m.classList.remove(`${Hr}--visible`),m.classList.add(`${Hr}--hidden`),setTimeout(()=>m.remove(),200),document.removeEventListener("click",t))};e.addDocumentEventListener("click",t)},0)}static turnInto(e,t,n){const a=e?.getAttribute("data-tool");if(!a)return;let o;if(e){const t=e.querySelector(".clepit-block-content");"paragraph"===a?o=t.querySelector(".clepit-paragraph")?.innerText||"":"quote"===a?o=t.querySelector(".clepit-quote-text")?.innerText||"":"list"===a?o=Array.from(t.querySelectorAll(".clepit-list-item")).map(e=>e.innerText.trim()).filter(Boolean).join("\n"):"alert"===a?o=t.querySelector(".clepit-alert")?.innerText||"":"header"===a&&(o=t.querySelector(".clepit-header")?.innerText||"")}const i=e?.getAttribute("data-id");i&&Ds.convertBlock(i,n,t),setTimeout(()=>{if(!e)return;const t=e.getAttribute("data-tool");if(o&&o.trim()){const n=e.querySelector(".clepit-block-content");if("paragraph"===t){const e=n.querySelector(".clepit-paragraph");e&&(e.innerText=o)}else if("quote"===t){const e=n.querySelector(".clepit-quote-text");e&&(e.innerText=o)}else if("list"===t){const e=n.querySelector(".clepit-list");e&&(e.innerHTML="",o.split("\n").forEach(t=>{const n=document.createElement("li");n.className="clepit-list-item",n.setAttribute("contenteditable","true"),n.innerText=t,e.appendChild(n)}))}else if("alert"===t){const e=n.querySelector(".clepit-alert");e&&(e.innerText=o)}else if("header"===t){const e=n.querySelector(".clepit-header");e&&(e.innerText=o)}}},0)}static show(t,n){e.closeAllMenus(),e.hideAllToolbars(t);const a=n.querySelector(`.${e.defaultClassName}`);a&&(a.classList.add("clepit-block-toolbar--visible"),a.classList.remove("clepit-block-toolbar--hidden"))}static hide(t){document.querySelector(`.${zr}, .${Pr}, .${Or}`)||e.hideAllToolbars(t)}static menuHost(e){return document.getElementById(e)?.closest("dialog")??document.body}static hideAllToolbars(t){const n=document.getElementById(t);n&&n.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>{e.classList.remove("clepit-block-toolbar--visible"),e.classList.add("clepit-block-toolbar--hidden")})}static getCurrentHeadingLevel(e){if(!e)return"h1";const t=e.querySelector(".clepit-header");if(!t)return"h1";const n=t.getAttribute("data-level");if(n)return n;const a=t.tagName.toLowerCase();return a||"h1"}static closeMenu(e){const t=document.querySelector(`.${e}`);t&&(t.matches(":popover-open")&&"function"==typeof t.hidePopover?t.hidePopover():t.remove())}static closeAllMenus(){e.closeMenu(zr),e.closeMenu(Pr),e.closeMenu(Or)}static getAlertIconColor(e){switch(e){case"info":return"#2196f3";case"warning":return"#ff9800";case"error":return"#f44336";case"success":return"#4caf50";default:return"#666"}}static remove(t){t.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>e.remove())}static destroy(t){const n=document.getElementById(t);if(!n)return;const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n)),e.documentListeners.forEach(({event:e,handler:t})=>{document.removeEventListener(e,t)}),e.documentListeners=[],n.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>e.remove())}},Wr=class e{static{this.label="bold"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 4h6a4 4 0 0 1 0 8H7z"/><path d="M7 12h7a4 4 0 0 1 0 8H7z"/></svg>'}static{this.shortcut=ja()}static apply(e){l.injectStyles("clepit-bold-styles","\n/* Bold inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n");const t=document.createElement("strong");e.surroundContents(t),Ds.updateStateFromRange(e)}static remove(t){const n=e.findBoldElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("strong");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Ds.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findBoldElement(n)||t.cloneContents().querySelectorAll('b, strong, [style*="font-weight: bold"], [style*="font-weight:bold"]').length>0}static findBoldElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("B"===e.tagName||"STRONG"===e.tagName)return e;if("bold"===e.style.fontWeight||Number.parseInt(e.style.fontWeight)>=700)return e}return t.parentNode?e.findBoldElement(t.parentNode):null}},Kr=class e{static{this.label="inline code"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="7 8 3 12 7 16"/><polyline points="17 8 21 12 17 16"/></svg>'}static{this.shortcut=Da("E")}static apply(e,t,n){l.injectStyles("clepit-inline-code-styles","\n/* Inline code styling when <code> is within editable text */\n.clepit-paragraph code,\n.clepit-header code,\n.clepit-list-item code,\n.clepit-quote-text code,\n.clepit-quote-caption code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n/* Output inline code styling */\n.clepit-output-paragraph code,\n.clepit-output-header code,\n.clepit-output-list li code,\n.clepit-output-quote code,\n.clepit-output-quote cite code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n overflow-wrap: anywhere;\n}\n\n/* Toolbar button code styling */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n");const a=document.createElement("code");a.classList.add("clepit-inline-code"),t&&l.applyClassNames(a,t),n&&Object.entries(n).forEach(([e,t])=>{if(void 0!==t){const n=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);a.style.setProperty(n,String(t))}}),e.surroundContents(a),Ds.updateStateFromRange(e)}static remove(t){const n=e.findCodeElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("code");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Ds.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findCodeElement(n)||t.cloneContents().querySelectorAll('code, [style*="font-family: monospace"], [style*="font-family:monospace"]').length>0}static findCodeElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("CODE"===e.tagName)return e;const n=window.getComputedStyle(e);if(n.fontFamily.includes("monospace")||n.fontFamily.includes("Monaco")||n.fontFamily.includes("Menlo"))return e;if(e.style.fontFamily.includes("monospace")||e.style.fontFamily.includes("Monaco")||e.style.fontFamily.includes("Menlo"))return e}return t.parentNode?e.findCodeElement(t.parentNode):null}static updateExistingCodeElements(e,t){document.querySelectorAll("code").forEach(n=>{n instanceof HTMLElement&&(n.classList.contains("clepit-inline-code")||n.classList.add("clepit-inline-code"),e&&l.applyClassNames(n,e),t&&Object.entries(t).forEach(([e,t])=>{if(void 0!==t){const a=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);n.style.setProperty(a,String(t))}}))})}},Gr=class e{static{this.label="italic"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 4h8"/><path d="M7 20h8"/><path d="M13 4L9 20"/></svg>'}static{this.shortcut=Pa()}static apply(e){l.injectStyles("clepit-italic-styles","\n/* Italic inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n.clepit-menu-icon--italic {\n font-style: italic;\n}\n");const t=document.createElement("em");e.surroundContents(t),Ds.updateStateFromRange(e)}static remove(t){const n=e.findItalicElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("em, i");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Ds.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findItalicElement(n)||t.cloneContents().querySelectorAll('i, em, [style*="font-style: italic"], [style*="font-style:italic"]').length>0}static findItalicElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("I"===e.tagName||"EM"===e.tagName)return e;if("italic"===window.getComputedStyle(e).fontStyle)return e;if("italic"===e.style.fontStyle)return e}return t.parentNode?e.findItalicElement(t.parentNode):null}},Jr="clepit-link-styles",Xr=`\n.${l.classNames.block.link} {\n color: var(--clepit-primary);\n cursor: pointer;\n}\n\n.${l.classNames.block.link}:hover {\n color: var(--clepit-primary-hover);\n}\n\n.clepit-link-card {\n position: fixed;\n inset: auto;\n top: var(--clepit-link-card-top, 50%);\n left: var(--clepit-link-card-left, 50%);\n display: flex;\n align-items: center;\n gap: 6px;\n width: min(380px, calc(100vw - 32px));\n margin: 0;\n padding: 6px;\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-lg);\n background: var(--clepit-menu-bg);\n box-shadow: var(--clepit-menu-shadow);\n color: var(--clepit-text);\n font-family: inherit;\n box-sizing: border-box;\n}\n\n.clepit-link-card:not(:popover-open) {\n display: none;\n}\n\n.clepit-link-card-input {\n flex: 1;\n min-width: 0;\n height: 30px;\n padding: 0 8px;\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n background: var(--clepit-bg);\n color: var(--clepit-text);\n font: inherit;\n font-size: 14px;\n box-sizing: border-box;\n}\n\n.clepit-link-card-input:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: -1px;\n border-color: transparent;\n}\n\n.clepit-link-card-input[aria-invalid="true"] {\n border-color: var(--clepit-error);\n}\n\n.clepit-link-card-button {\n height: 30px;\n padding: 0 12px;\n border: 0;\n border-radius: var(--clepit-radius-md);\n font: inherit;\n font-size: 13.5px;\n font-weight: 500;\n white-space: nowrap;\n cursor: pointer;\n transition: background-color 0.15s ease;\n}\n\n.clepit-link-card-button:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: 1px;\n}\n\n.clepit-link-card-button--apply {\n background: var(--clepit-primary);\n color: var(--clepit-on-primary);\n}\n\n.clepit-link-card-button--apply:hover {\n background: var(--clepit-primary-hover);\n}\n\n.clepit-link-card-button--remove {\n background: transparent;\n color: var(--clepit-text-muted);\n}\n\n.clepit-link-card-button--remove:hover {\n background: var(--clepit-hover-bg);\n color: var(--clepit-text);\n}\n\n@media (pointer: coarse) {\n .clepit-link-card-input,\n .clepit-link-card-button {\n height: 44px;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .clepit-link-card-button {\n transition: none;\n }\n}\n`,Yr=class e{static{this.isOpen=!1}constructor(e){this.card=null,this.urlInput=null,this.handleInputKeyDown=e=>{"Enter"===e.key?(e.preventDefault(),this.applyUrl()):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),this.dismiss())},this.handleToggle=e=>{"newState"in e&&"closed"===e.newState&&this.card&&this.dismiss()},this.options=e}show(){this.card||e.isOpen||(l.injectStyles(Jr,Xr),e.isOpen=!0,this.createCard(),this.urlInput?.focus(),this.urlInput?.select())}hide(){const t=this.card;if(!t)return;this.card=null,this.urlInput=null,e.isOpen=!1,t.removeEventListener("toggle",this.handleToggle),"function"==typeof t.hidePopover&&t.matches(":popover-open")&&t.hidePopover(),t.remove();const n=document.querySelector(".clepit-toolbar");n&&(n.style.display="flex")}word(e,t){return this.options.labels?.[e]||t}createCard(){const e=p("div","clepit-link-card",{"aria-label":this.word("insertLink","Add a link"),"data-testid":"link-card",popover:"auto",role:"dialog"});this.applyStyles(e,this.options.styles?.container),this.applyClassNames(e,this.options.classNames?.container);const t=this.options.anchor;t&&(e.style.setProperty("--clepit-link-card-top",`${t.bottom+8}px`),e.style.setProperty("--clepit-link-card-left",`${t.left}px`));const n=p("input","clepit-link-card-input",{"aria-label":this.word("urlField","Link address"),"data-testid":"link-card-url",placeholder:this.word("urlPlaceholder","Paste or type a link"),type:"url"});n.value=this.options.url,this.applyStyles(n,this.options.styles?.input),this.applyClassNames(n,this.options.classNames?.input),n.addEventListener("keydown",this.handleInputKeyDown),n.addEventListener("input",()=>n.removeAttribute("aria-invalid")),this.urlInput=n;const a=p("button","clepit-link-card-button clepit-link-card-button--apply",{"data-testid":"link-card-apply",type:"button"});if(a.textContent=this.word("apply","Apply"),this.applyStyles(a,this.options.styles?.saveButton),this.applyClassNames(a,this.options.classNames?.saveButton),a.addEventListener("click",()=>this.applyUrl()),e.append(n,a),this.options.isLinked){const t=p("button","clepit-link-card-button clepit-link-card-button--remove",{"data-testid":"link-card-remove",type:"button"});t.textContent=this.word("removeLink","Remove"),this.applyStyles(t,this.options.styles?.cancelButton),this.applyClassNames(t,this.options.classNames?.cancelButton),t.addEventListener("click",()=>{this.hide(),this.options.onRemove()}),e.append(t)}document.body.appendChild(e),this.card=e,"function"==typeof e.showPopover&&(e.showPopover(),e.addEventListener("toggle",this.handleToggle));const o=document.querySelector(".clepit-toolbar");o&&(o.style.display="none")}applyUrl(){const e=this.urlInput?.value.trim()??"";if(e){if(!c(e))return this.urlInput?.setAttribute("aria-invalid","true"),void this.urlInput?.focus();this.hide(),this.options.onConfirm(this.options.text,e)}else this.dismiss()}dismiss(){this.hide(),this.options.onCancel()}applyStyles(e,t){if(t)for(const[n,a]of Object.entries(t))void 0!==a&&e.style.setProperty(n,String(a))}applyClassNames(e,t){t&&e.classList.add(t)}destroy(){this.hide(),e.isOpen=!1}},Zr=class e{static{this.label="link"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.07 0l1.76-1.76a5 5 0 0 0-7.07-7.07L10 5"/><path d="M14 11a5 5 0 0 0-7.07 0L5.17 12.76a5 5 0 0 0 7.07 7.07L14 19"/></svg>'}static{this.shortcut=Ra()}static apply(t,n,a,o){l.injectStyles(Jr,Xr);const i=e.findLinkElement(t.commonAncestorContainer),r=t.cloneRange(),s=()=>{const e=window.getSelection();return e?(e.removeAllRanges(),e.addRange(r),e):null};new Yr({anchor:t.getBoundingClientRect(),classNames:n,isLinked:null!==i,labels:o,onCancel:()=>{s()},onConfirm:(t,n)=>{try{const t=s();if(!t)return;if(i instanceof HTMLAnchorElement)return i.href=n,void e.announce(i);const a=l.createStyledElement("a",l.classNames.block.link);a.href=n,a.target="_blank",a.rel="noopener noreferrer";try{r.surroundContents(a)}catch{const e=r.extractContents();a.appendChild(e),r.insertNode(a)}const o=document.createRange();o.selectNodeContents(a),t.removeAllRanges(),t.addRange(o),e.announce(a)}catch(a){console.error("Failed to apply link:",a)}},onRemove:()=>{s(),e.remove(r)},styles:a,text:(i?.textContent??t.toString()).trim(),url:i?.getAttribute("href")??""}).show(),Ds.updateStateFromRange(t)}static announce(e){e.closest('[contenteditable="true"]')?.dispatchEvent(new Event("input",{bubbles:!0}))}static remove(t){const n=e.findLinkElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("a");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Ds.updateStateFromRange(t)}static findLinkElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("A"===e.tagName)return e}return t.parentNode?e.findLinkElement(t.parentNode):null}static isActive(t){const n=t.commonAncestorContainer;return!!e.findLinkElement(n)||t.cloneContents().querySelectorAll("a").length>0}},Qr="clepit-marker-styles",es="\n/* Marker brush effect */\n.clepit-paragraph mark,\n.clepit-header mark,\n.clepit-list-item mark,\n.clepit-quote-text mark,\n.clepit-quote-caption mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n.clepit-paragraph mark::before,\n.clepit-header mark::before,\n.clepit-list-item mark::before,\n.clepit-quote-text mark::before,\n.clepit-quote-caption mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n/* Output marker brush effect for <mark> */\n.clepit-output-paragraph mark,\n.clepit-output-header mark,\n.clepit-output-list li mark,\n.clepit-output-quote mark,\n.clepit-output-quote cite mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n.clepit-output-paragraph mark::before,\n.clepit-output-header mark::before,\n.clepit-output-list li mark::before,\n.clepit-output-quote mark::before,\n.clepit-output-quote cite mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n z-index: -1;\n}\n\n/* Marker wrapper styling */\n.clepit-marker-wrapper {\n position: relative;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n color: inherit;\n}\n\n/* Marker stroke styling */\n.clepit-marker-stroke {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n z-index: -1;\n pointer-events: none;\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n}\n\n/* Toolbar button mark styling */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n",ts=class e{static{this.label="marker"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 21l6-2 9-9a2.828 2.828 0 0 0-4-4l-9 9-2 6z"/><path d="M14 7l3 3"/></svg>'}static apply(t,n,a){l.injectStyles(Qr,es);const o=document.createElement("span");o.classList.add("clepit-marker-wrapper");const i=document.createElement("span");i.classList.add("clepit-marker-stroke");const r=t.extractContents();o.appendChild(document.createTextNode(" ")),o.appendChild(r),o.appendChild(document.createTextNode(" ")),o.insertBefore(i,o.firstChild),t.insertNode(o),t.selectNodeContents(o),e.applyUserStyles(o,i,n,a);const s=o.closest('[contenteditable="true"]');s&&s.dispatchEvent(new Event("input",{bubbles:!0})),Ds.updateStateFromRange(t)}static remove(t){const n=e.findMarkerElement(t.commonAncestorContainer);if(n){const t=n.parentElement;if(t){const a=n.previousSibling,o=n.nextSibling,i=document.createDocumentFragment();Array.from(n.childNodes).forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&e.classList?.contains("clepit-marker-stroke")||i.appendChild(e.cloneNode(!0))}),n.replaceWith(i),e.cleanupSpaces(t,a,o);const r=t.closest('[contenteditable="true"]');r&&r.dispatchEvent(new Event("input",{bubbles:!0}))}return}const a=t.cloneContents().querySelectorAll(".clepit-marker-wrapper");if(a.length>0){a.forEach(t=>{const n=t.parentElement;if(n){const a=t.previousSibling,o=t.nextSibling,i=document.createDocumentFragment();Array.from(t.childNodes).forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&e.classList?.contains("clepit-marker-stroke")||i.appendChild(e.cloneNode(!0))}),t.replaceWith(i),e.cleanupSpaces(n,a,o)}});const n=t.commonAncestorContainer.closest('[contenteditable="true"]');return void(n&&n.dispatchEvent(new Event("input",{bubbles:!0})))}const o=e.findLegacyMarkElement(t.commonAncestorContainer);if(o){const e=o.parentElement;if(e){const t=o.textContent||"",n=document.createTextNode(t);e.insertBefore(n,o),e.removeChild(o);const a=e.closest('[contenteditable="true"]');a&&a.dispatchEvent(new Event("input",{bubbles:!0}))}}Ds.updateStateFromRange(t)}static cleanupSpaces(e,t,n){const a=Array.from(e.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE);a.forEach((e,o)=>{let i=e.textContent||"";if(0===o&&t?.nodeType===Node.TEXT_NODE&&(t.textContent||"").endsWith(" ")&&i.startsWith(" ")&&(i=i.substring(1)),o===a.length-1&&n?.nodeType===Node.TEXT_NODE){const e=n.textContent||"";i.endsWith(" ")&&e.startsWith(" ")&&(i=i.substring(0,i.length-1))}e.textContent=i})}static isActive(t){if(t.collapsed)return!1;if(t.cloneContents().querySelectorAll(".clepit-marker-wrapper").length>0)return!0;if(e.findMarkerElement(t.commonAncestorContainer))return!0;const n=t.startContainer,a=t.endContainer;return!(n===t.commonAncestorContainer||!e.findMarkerElement(n))||(!(a===t.commonAncestorContainer||a===n||!e.findMarkerElement(a))||null!==e.findLegacyMarkElement(t.commonAncestorContainer))}static findMarkerElement(e){let t=e,n=0;for(;t&&n<10;){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList?.contains("clepit-marker-wrapper"))return e;if(e.classList?.contains("clepit-block")||e.classList?.contains(l.classNames.editor.container))break}t=t.parentNode,n++}return null}static findLegacyMarkElement(e){let t=e,n=0;for(;t&&n<10;){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("MARK"===e.tagName)return e;if(e.classList?.contains("clepit-block")||e.classList?.contains(l.classNames.editor.container))break;if(0===n){const t=window.getComputedStyle(e);if("yellow"===t.backgroundColor||"rgb(255, 255, 0)"===t.backgroundColor)return e;if("yellow"===e.style.backgroundColor||"rgb(255, 255, 0)"===e.style.backgroundColor)return e}}t=t.parentNode,n++}return null}static applyUserStyles(t,n,a,o){a&&l.applyClassNames(t,a),o&&Object.entries(o).forEach(([e,n])=>{if(void 0!==n&&"background"!==e){const a=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);t.style.setProperty(a,String(n))}});const i=t.style.getPropertyValue("--marker-background")||t.getAttribute("data-marker-background");if(i){const t=e.createStrokeSVG(i);return void(n.style.background=t)}if(o?.background){const t=o.background;if(t){const a=e.createStrokeSVG(String(t));return void(n.style.background=a)}}const r=t.closest(`.${l.classNames.editor.content}, .${l.classNames.renderer.content}`);if(r){const t=window.getComputedStyle(r).getPropertyValue("--clepit-marker-background");if(t&&"initial"!==t&&"inherit"!==t){const a=e.createStrokeSVG(t.trim());return void(n.style.background=a)}}const s=t.closest(`.${l.classNames.block.content}`);if(!s)return;const c=s.style.background||s.style.backgroundColor||s.style.getPropertyValue("background-color");if(c&&"initial"!==c&&"inherit"!==c){const t=e.createStrokeSVG(c);return void(n.style.background=t)}const d=window.getComputedStyle(s).backgroundColor;if(d&&"rgba(0, 0, 0, 0)"!==d&&"transparent"!==d){const t=e.createStrokeSVG(d);n.style.background=t}}static createStrokeSVG(t){const n=e.colorToHex(t);return`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='${encodeURIComponent(n)}'/></svg>") no-repeat center / 100% 100%`}static colorToHex(e){if(e.startsWith("#"))return e;if(e.startsWith("rgb")){const t=e.match(/\d+/g);if(t&&t.length>=3)return`#${parseInt(t[0]).toString(16).padStart(2,"0")}${parseInt(t[1]).toString(16).padStart(2,"0")}${parseInt(t[2]).toString(16).padStart(2,"0")}`}return{blue:"#3742FA",cyan:"#7FDBDA",green:"#2ED573",lime:"#32FF7E",orange:"#FFA502",pink:"#FF6B9D",purple:"#A55EEA",red:"#FF4757",teal:"#006266",yellow:"#FFE047"}[e.toLowerCase()]||"#FFE047"}},ns="clepit-inline-status-styles",as='\n/* Inline status — same visual language as the Alert block but inline. */\n.clepit-status {\n display: inline;\n padding: 2px 8px;\n border-radius: 4px;\n font-size: 0.9em;\n line-height: 1.5;\n vertical-align: baseline;\n}\n\n.clepit-status[data-status-variant="info"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-status[data-status-variant="success"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-status[data-status-variant="warning"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-status[data-status-variant="error"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-status[data-status-variant="plain"] {\n background: transparent;\n color: inherit;\n}\n\n/* Dialog variant picker — mirrors inline chip styling at rest, highlight on hover/selected. */\n.clepit-status-dialog-variants {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 4px;\n}\n\n.clepit-status-dialog-variant {\n appearance: none;\n -webkit-appearance: none;\n background: transparent;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 6px 12px;\n cursor: pointer;\n font-family: inherit;\n font-size: 13px;\n color: var(--clepit-text);\n transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;\n}\n\n.clepit-status-dialog-variant:hover {\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--info:hover,\n.clepit-status-dialog-variant--info[data-selected="true"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--success:hover,\n.clepit-status-dialog-variant--success[data-selected="true"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--warning:hover,\n.clepit-status-dialog-variant--warning[data-selected="true"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--error:hover,\n.clepit-status-dialog-variant--error[data-selected="true"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--plain:hover,\n.clepit-status-dialog-variant--plain[data-selected="true"] {\n background: var(--clepit-surface);\n color: var(--clepit-text);\n border-color: transparent;\n}\n',os="clepit-dialogs-styles",is="\n.clepit-dialog-overlay {\n border: none;\n padding: 0;\n background: transparent;\n max-width: none;\n max-height: none;\n}\n\n.clepit-dialog-overlay[open] {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.clepit-dialog-overlay::backdrop {\n background: rgba(0, 0, 0, 0.5);\n}\n\n.clepit-dialog-overlay:not([open]) {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.5);\n align-items: center;\n justify-content: center;\n z-index: 10000;\n}\n\n.clepit-dialog {\n position: relative;\n box-sizing: border-box;\n width: min(440px, calc(100vw - 32px));\n max-height: 80vh;\n overflow-y: auto;\n padding: 24px;\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-lg);\n background: var(--clepit-menu-bg);\n box-shadow: var(--clepit-menu-shadow);\n color: var(--clepit-text);\n font-family: inherit;\n transform: scale(0.98);\n opacity: 0;\n transition: transform 0.15s ease-out, opacity 0.15s ease-out;\n}\n\n.clepit-dialog:not(.clepit-dialog--hidden) {\n transform: scale(1);\n opacity: 1;\n}\n\n.clepit-dialog--hidden {\n transform: scale(0.98);\n opacity: 0;\n}\n\n.clepit-dialog-title {\n margin: 0 0 16px;\n font-size: 17px;\n font-weight: 600;\n line-height: 1.4;\n color: var(--clepit-text);\n}\n\n.clepit-dialog-group {\n margin-bottom: 16px;\n}\n\n.clepit-dialog-label {\n display: block;\n margin-bottom: 6px;\n font-size: 13px;\n font-weight: 500;\n color: var(--clepit-text);\n}\n\n.clepit-dialog-input {\n display: block;\n width: 100%;\n height: 36px;\n margin-bottom: 16px;\n padding: 0 10px;\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n background: var(--clepit-bg);\n color: var(--clepit-text);\n font: inherit;\n font-size: 14px;\n box-sizing: border-box;\n}\n\n.clepit-dialog-group .clepit-dialog-input {\n margin-bottom: 0;\n}\n\n.clepit-dialog-input:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: -1px;\n border-color: transparent;\n}\n\n.clepit-dialog-input::placeholder {\n color: var(--clepit-text-subtle);\n}\n\n.clepit-dialog-buttons {\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n margin-top: 24px;\n}\n\n.clepit-dialog-button {\n height: 30px;\n padding: 0 14px;\n border: 0;\n border-radius: var(--clepit-radius-md);\n font: inherit;\n font-size: 13.5px;\n font-weight: 500;\n white-space: nowrap;\n cursor: pointer;\n transition: background-color 0.15s ease;\n}\n\n.clepit-dialog-button:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: 1px;\n}\n\n.clepit-dialog-button--cancel {\n background: transparent;\n color: var(--clepit-text-muted);\n}\n\n.clepit-dialog-button--cancel:hover {\n background: var(--clepit-hover-bg);\n color: var(--clepit-text);\n}\n\n.clepit-dialog-button--save {\n background: var(--clepit-primary);\n color: var(--clepit-on-primary);\n}\n\n.clepit-dialog-button--save:hover {\n background: var(--clepit-primary-hover);\n}\n\n.clepit-dialog-button--save:disabled {\n background: var(--clepit-text-subtle);\n cursor: not-allowed;\n}\n\n@media (pointer: coarse) {\n .clepit-dialog-input,\n .clepit-dialog-button {\n height: 44px;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .clepit-dialog,\n .clepit-dialog-button {\n transition: none;\n }\n}\n",rs=["info","success","warning","error","plain"],ss={error:"statusError",info:"statusInfo",plain:"statusPlain",success:"statusSuccess",warning:"statusWarning"},ls=class e{static{this.isOpen=!1}static{this.count=0}constructor(e){this.overlay=null,this.dialog=null,this.textInput=null,this.options=e,this.variant=e.variant}show(){this.overlay||e.isOpen||(l.injectStyles(os,is),e.isOpen=!0,this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const t=this.overlay;"function"==typeof t.close&&t.open&&t.close(),t.remove(),this.overlay=null,this.dialog=null,this.textInput=null,e.isOpen=!1;const n=document.querySelector(".clepit-toolbar");n&&(n.style.display="flex")}word(e,t){return this.options.labels?.[e]||t}createDialog(){const t="clepit-status-dialog-"+ ++e.count;this.overlay=p("dialog","clepit-dialog-overlay",{"aria-labelledby":`${t}-title`}),this.applyStyles(this.overlay,this.options.styles?.overlay),this.dialog=p("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container);const n=p("h3","clepit-dialog-title",{id:`${t}-title`});n.dataset.testid="status-dialog-title",n.textContent=this.word("inlineStatus","Inline status"),this.applyStyles(n,this.options.styles?.title),this.dialog.appendChild(n);const a=p("label","clepit-dialog-label",{for:`${t}-text`});a.dataset.testid="status-dialog-text-label",a.textContent=this.word("statusLabelField","Label"),this.applyStyles(a,this.options.styles?.label),this.dialog.appendChild(a),this.textInput=p("input","clepit-dialog-input",{id:`${t}-text`}),this.textInput.type="text",this.textInput.value=this.options.text,this.textInput.dataset.testid="status-dialog-text-input",this.textInput.placeholder=this.word("statusLabelPlaceholder","Status label"),this.applyStyles(this.textInput,this.options.styles?.input),this.dialog.appendChild(this.textInput);const o=p("span","clepit-dialog-label",{id:`${t}-variant`});o.dataset.testid="status-dialog-variant-label",o.textContent=this.word("statusVariantField","Variant"),this.applyStyles(o,this.options.styles?.label),this.dialog.appendChild(o);const i=p("div","clepit-status-dialog-variants",{"aria-labelledby":`${t}-variant`,role:"radiogroup"});for(const e of rs){const t=p("button",`clepit-status-dialog-variant clepit-status-dialog-variant--${e}`);t.type="button",t.dataset.variant=e,t.dataset.testid=`status-dialog-variant-${e}`,t.textContent=this.word(ss[e],e),t.setAttribute("role","radio"),t.setAttribute("aria-checked",String(e===this.variant)),t.dataset.selected=String(e===this.variant),t.addEventListener("click",()=>{this.variant=e;for(const t of i.querySelectorAll('[role="radio"]')){const n=t.dataset.variant===e;t.dataset.selected=String(n),t.setAttribute("aria-checked",String(n))}}),i.appendChild(t)}this.dialog.appendChild(i);const r=p("div","clepit-dialog-buttons");this.applyStyles(r,this.options.styles?.buttons);const s=p("button","clepit-dialog-button clepit-dialog-button--cancel");s.type="button",s.dataset.testid="status-dialog-cancel",s.textContent=this.word("cancel","Cancel"),s.addEventListener("click",()=>this.handleCancel()),this.applyStyles(s,this.options.styles?.cancelButton),r.appendChild(s);const l=p("button","clepit-dialog-button clepit-dialog-button--save");l.type="button",l.dataset.testid="status-dialog-apply",l.textContent=this.word("apply","Apply"),l.addEventListener("click",()=>this.handleConfirm()),this.applyStyles(l,this.options.styles?.saveButton),r.appendChild(l),this.dialog.appendChild(r),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const c=this.overlay;"function"==typeof c.showModal?c.showModal():c.style.display="flex";const d=document.querySelector(".clepit-toolbar");d&&(d.style.display="none")}bindEvents(){if(!this.overlay||!this.dialog||!this.textInput)return;this.overlay.addEventListener("click",e=>{e.target===this.overlay&&this.handleCancel()});const e=e=>{"Escape"===e.key&&this.handleCancel(),"Enter"===e.key&&e.target===this.textInput&&(e.preventDefault(),this.handleConfirm())};document.addEventListener("keydown",e),this.dialog.dataset.keyHandlerRegistered="true",this.dialog.__keyHandler=e}focusFirstInput(){setTimeout(()=>this.textInput?.focus(),50)}handleConfirm(){this.textInput&&(this.options.onConfirm(this.textInput.value.trim(),this.variant),this.cleanupKeyHandler(),this.hide())}handleCancel(){this.options.onCancel(),this.cleanupKeyHandler(),this.hide()}cleanupKeyHandler(){if(!this.dialog)return;const e=this.dialog.__keyHandler;e&&document.removeEventListener("keydown",e)}applyStyles(e,t){if(t)for(const[n,a]of Object.entries(t))void 0!==a&&e.style.setProperty(n,String(a))}},cs="clepit-status",ds=class e{static{this.label="status"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="8" width="18" height="8" rx="4"/><circle cx="8" cy="12" r="1.25"/><circle cx="16" cy="12" r="1.25"/></svg>'}static apply(t,n,a,o){l.injectStyles(ns,as);const i=t.toString().trim(),r=e.findStatusElement(t.commonAncestorContainer),s=r?r.textContent??i:i,c=r?e.readVariant(r):"info",d=t.cloneRange();new ls({classNames:n,labels:o,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(d))},onConfirm:(t,n)=>{try{const a=window.getSelection();if(!a)return;if(a.removeAllRanges(),a.addRange(d),!t.trim())return void e.remove(d);if(e.unwrap(d),t!==i){d.deleteContents();const e=document.createTextNode(t);d.insertNode(e),d.selectNode(e)}const o=document.createElement("span");o.className=(e=>`${cs} ${cs}--${e}`)(n),o.dataset.statusVariant=n;try{d.surroundContents(o)}catch{const e=d.extractContents();o.appendChild(e),d.insertNode(o)}const r=document.createRange();r.selectNodeContents(o),a.removeAllRanges(),a.addRange(r);const s=o.closest('[contenteditable="true"]');s&&s.dispatchEvent(new Event("input",{bubbles:!0}))}catch(a){console.error("Failed to apply inline status:",a)}},styles:a,text:s||"status",variant:c}).show(),Ds.updateStateFromRange(t)}static remove(t){e.unwrap(t),Ds.updateStateFromRange(t)}static isActive(t){return!!e.findStatusElement(t.commonAncestorContainer)||t.cloneContents().querySelectorAll(`.${cs}`).length>0}static unwrap(t){const n=e.findStatusElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}return}const a=t.commonAncestorContainer;if(a.nodeType!==Node.ELEMENT_NODE)return;const o=a.querySelectorAll(`.${cs}`);for(const e of Array.from(o)){if(!t.intersectsNode(e))continue;const n=e.parentElement;n&&(n.insertBefore(document.createTextNode(e.textContent||""),e),n.removeChild(e))}}static findStatusElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList?.contains(cs))return e}return t.parentNode?e.findStatusElement(t.parentNode):null}static readVariant(e){const t=e.dataset.statusVariant;if(t&&["info","success","warning","error"].includes(t))return t;for(const n of["info","success","warning","error"])if(e.classList.contains(`${cs}--${n}`))return n;return"info"}},ps=class e{static{this.label="strikethrough"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M16 4H9a3 3 0 0 0-2.83 4"/><path d="M14 12a4 4 0 0 1 0 8H6"/><line x1="4" x2="20" y1="12" y2="12"/></svg>'}static apply(e){l.injectStyles("clepit-strikethrough-styles",'\n/* Strikethrough inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button s,\n.clepit-toolbar-button del,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n/* Keep strikethrough visual hint without changing size */\n.clepit-toolbar-button[data-tool="strikethrough"] {\n text-decoration: line-through;\n}\n');const t=document.createElement("s");e.surroundContents(t),Ds.updateStateFromRange(e)}static remove(t){const n=e.findStrikethroughElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll('s, del, [style*="text-decoration: line-through"], [style*="text-decoration:line-through"]');for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Ds.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findStrikethroughElement(n)||t.cloneContents().querySelectorAll('s, del, [style*="text-decoration: line-through"], [style*="text-decoration:line-through"]').length>0}static findStrikethroughElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("S"===e.tagName||"DEL"===e.tagName)return e;if(window.getComputedStyle(e).textDecoration.includes("line-through"))return e;if(e.style.textDecoration.includes("line-through"))return e}return t.parentNode?e.findStrikethroughElement(t.parentNode):null}},us="clepit-tooltip-styles",hs=`\n/* Tooltip styles - border bottom instead of text-decoration to avoid underline tool conflict */\n.${l.classNames.block.tooltip} {\n border-bottom: 1px dotted var(--clepit-text-subtle);\n cursor: help;\n}\n\n.${l.classNames.block.tooltip}:hover {\n border-bottom: 1px dotted var(--clepit-text-muted);\n}\n`,ms=class e{static{this.count=0}constructor(e){this.overlay=null,this.dialog=null,this.inputText=null,this.inputTooltip=null,this.handleKeyDown=e=>{"Escape"===e.key&&(this.options.onCancel(),this.hide())},this.handleInputKeyDown=e=>{if("Enter"===e.key){const e=this.inputText?.value.trim()||"",t=this.inputTooltip?.value.trim()||"";this.options.onConfirm(e,t),this.hide()}},this.options=e}show(){this.overlay||(l.injectStyles(os,is),document.querySelectorAll(".clepit-dialog-overlay").forEach(e=>{e!==this.overlay&&e.remove()}),this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const e=this.overlay;"function"==typeof e.close&&e.open&&e.close(),this.destroy()}word(e,t){return this.options.labels?.[e]||t}createDialog(){const t="clepit-tooltip-dialog-"+ ++e.count;this.overlay=p("dialog","clepit-dialog-overlay",{"aria-labelledby":`${t}-title`}),this.applyStyles(this.overlay,this.options.styles?.overlay),this.applyClassNames(this.overlay,this.options.classNames?.overlay),this.dialog=p("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container),this.applyClassNames(this.dialog,this.options.classNames?.container);const n=p("h3","clepit-dialog-title",{id:`${t}-title`});n.dataset.testid="tooltip-dialog-title",n.textContent=this.word("insertTooltip","Insert Tooltip"),this.applyStyles(n,this.options.styles?.title),this.applyClassNames(n,this.options.classNames?.title);const a=this.createInputGroup(this.word("textField","Text"),this.word("textPlaceholder","Text"),this.options.text,"text","tooltip-dialog-text",`${t}-text`);this.inputText=a.querySelector("input");const o=this.createInputGroup(this.word("tooltipField","Tooltip"),this.word("tooltipPlaceholder","Tooltip text"),this.options.tooltip,"text","tooltip-dialog-tooltip",`${t}-tooltip`);this.inputTooltip=o.querySelector("input");const i=this.createButtonGroup();this.dialog.appendChild(n),this.dialog.appendChild(a),this.dialog.appendChild(o),this.dialog.appendChild(i),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const r=this.overlay;"function"==typeof r.showModal?r.showModal():r.style.display="flex",this.dialog?.classList.remove("clepit-dialog--hidden");const s=document.querySelector(".clepit-toolbar");s&&(s.style.display="none"),this.options.onShow?.()}createInputGroup(e,t,n,a,o,i){const r=p("div","clepit-dialog-group");this.applyStyles(r,this.options.styles?.group),this.applyClassNames(r,this.options.classNames?.group);const s=p("label","clepit-dialog-label",{for:i});s.dataset.testid=`${o}-label`,s.textContent=e,this.applyStyles(s,this.options.styles?.label),this.applyClassNames(s,this.options.classNames?.label);const l=p("input","clepit-dialog-input",{id:i});return l.type="url"===a?"url":"text",l.value=n,l.dataset.testid=`${o}-input`,l.placeholder=t,this.applyStyles(l,this.options.styles?.input),this.applyClassNames(l,this.options.classNames?.input),r.appendChild(s),r.appendChild(l),r}createButtonGroup(){const e=p("div","clepit-dialog-buttons");this.applyStyles(e,this.options.styles?.buttons),this.applyClassNames(e,this.options.classNames?.buttons);const t=p("button","clepit-dialog-button clepit-dialog-button--cancel");t.dataset.testid="tooltip-dialog-cancel",t.textContent=this.word("cancel","Cancel"),t.type="button",this.applyStyles(t,this.options.styles?.cancelButton),this.applyClassNames(t,this.options.classNames?.cancelButton);const n=p("button","clepit-dialog-button clepit-dialog-button--save");return n.dataset.testid="tooltip-dialog-apply",n.textContent=this.word("apply","Apply"),n.type="button",this.applyStyles(n,this.options.styles?.saveButton),this.applyClassNames(n,this.options.classNames?.saveButton),t.addEventListener("click",()=>{this.options.onCancel(),this.hide()}),n.addEventListener("click",()=>{this.options.onConfirm(this.inputText?.value.trim()||"",this.inputTooltip?.value.trim()||""),this.hide()}),e.appendChild(t),e.appendChild(n),e}bindEvents(){this.overlay&&(this.overlay.addEventListener("click",e=>{e.target===this.overlay&&(this.options.onCancel(),this.hide())}),document.addEventListener("keydown",this.handleKeyDown),this.inputText&&this.inputText.addEventListener("keydown",this.handleInputKeyDown),this.inputTooltip&&this.inputTooltip.addEventListener("keydown",this.handleInputKeyDown))}focusFirstInput(){setTimeout(()=>{this.inputTooltip&&(this.inputTooltip.focus(),this.inputTooltip.select())},100)}applyStyles(e,t){t&&Object.entries(t).forEach(([t,n])=>{if(void 0!==n){const a=t.replace(/([A-Z])/g,"-$1").toLowerCase();e.style.setProperty(a,String(n))}})}applyClassNames(e,t){t&&e.classList.add(t)}destroy(){if(document.removeEventListener("keydown",this.handleKeyDown),this.overlay){this.overlay.remove(),this.overlay=null,this.dialog=null,this.inputText=null,this.inputTooltip=null;const e=document.querySelector(".clepit-toolbar");e&&(e.style.display="flex"),this.options.onHide&&this.options.onHide()}}},gs=class e{static{this.label="tooltip"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 7l-2.5 3H5a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-4.5L12 7z"/><path d="M8 13h8"/><path d="M8 16h6"/></svg>'}static apply(t,n,a,o){l.injectStyles(us,hs);const i=t.toString(),r=t.cloneRange();let s="",c=i;const d=e.findTooltipSpan(t.commonAncestorContainer);d&&(s=d.getAttribute("data-tooltip")||"",c=d.textContent||""),new ms({classNames:n.classNames,labels:o,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(r))},onConfirm:(t,o)=>{const i=window.getSelection();if(!i)return;if(i.removeAllRanges(),i.addRange(r),!o.trim())return e.remove(r),void(t!==c&&(r.deleteContents(),r.insertNode(document.createTextNode(t))));if(d){const e=d.parentElement;if(e){const t=document.createTextNode(d.textContent||"");e.insertBefore(t,d),e.removeChild(d),r.selectNode(t)}}if(t!==c){r.deleteContents();const e=document.createTextNode(t);r.insertNode(e),r.selectNode(e)}const s=l.createStyledElement("span",l.classNames.block.tooltip);s.setAttribute("data-tooltip",o),a.classNames&&l.applyClassNames(s,a.classNames),a.styles&&Object.entries(a.styles).forEach(([e,t])=>{if(void 0!==t){const n=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);s.style.setProperty(n,String(t))}});try{r.surroundContents(s)}catch{const e=r.extractContents();s.appendChild(e),r.insertNode(s)}t!==c&&s.textContent!==t&&(s.textContent=t),ke(s,o,"above",n.classNames,n.styles);const p=s.closest('[contenteditable="true"]');p&&p.dispatchEvent(new Event("input",{bubbles:!0}))},styles:n.styles,text:c,tooltip:s}).show(),Ds.updateStateFromRange(t)}static remove(t){const n=t.commonAncestorContainer,a=e.findTooltipSpan(n);if(a){const e=a.parentElement;if(!e)return;e.insertBefore(document.createTextNode(a.textContent||""),a),e.removeChild(a),t.selectNode(e)}Ds.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findTooltipSpan(n)||t.cloneContents().querySelectorAll(`span.${l.classNames.block.tooltip}`).length>0}static initializeElements(e,t){e.querySelectorAll(`span.${l.classNames.block.tooltip}`).forEach(e=>{if(e instanceof HTMLElement&&(t.classNames&&l.applyClassNames(e,t.classNames),t.styles&&Object.entries(t.styles).forEach(([t,n])=>{if(void 0!==n){const a=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(a,String(n))}}),!e.hasAttribute("data-tooltip-initialized"))){const t=e.getAttribute("data-tooltip");t&&(ke(e,t,"above"),e.setAttribute("data-tooltip-initialized","true"))}})}static findTooltipSpan(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList.contains(l.classNames.block.tooltip))return e}return t.parentNode?e.findTooltipSpan(t.parentNode):null}},bs=class e{static{this.label="underline"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 4v7a6 6 0 0 0 12 0V4"/><path d="M4 20h16"/></svg>'}static{this.shortcut=Va()}static apply(e){l.injectStyles("clepit-underline-styles",'\n/* Underline inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n/* Keep underline visual hint without changing size */\n.clepit-toolbar-button[data-tool="underline"] {\n text-decoration: underline;\n}\n');const t=document.createElement("u");e.surroundContents(t),Ds.updateStateFromRange(e)}static remove(t){const n=e.findUnderlineElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("u");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}Ds.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findUnderlineElement(n)||t.cloneContents().querySelectorAll('u, [style*="text-decoration: underline"], [style*="text-decoration:underline"]').length>0}static findUnderlineElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("U"===e.tagName)return e;if(window.getComputedStyle(e).textDecoration.includes("underline"))return e;if(e.style.textDecoration.includes("underline"))return e}return t.parentNode?e.findUnderlineElement(t.parentNode):null}},fs=()=>[Wr,Gr,bs,ps,Kr,ts,ds,Zr,gs],vs="inline-toolbar",ys=["bold","italic","underline","strikethrough"],xs=["inline code","link","marker"],ks=["status","tooltip"],ws={b:"bold",e:"inline code",i:"italic",k:"link",u:"underline"},Cs=/* @__PURE__ */new Set(["paragraph","header","list","checklist","quote"]),As={bold:"Bold",formatText:"Format text",highlight:"Highlight",inlineCode:"Inline code",italic:"Italic",link:"Link",more:"More formatting",status:"Status",strikethrough:"Strikethrough",text:"Text",textType:"Text type",tooltip:"Tooltip",underline:"Underline"},Ss={bold:"bold","inline code":"inlineCode",italic:"italic",link:"link",marker:"highlight",status:"status",strikethrough:"strikethrough",tooltip:"tooltip",underline:"underline"},Es=(e,t)=>e.inlineToolbarLabels?.[t]||As[t],Ls=(e,t)=>{const n=Ss[t.label];return n?Es(e,n):t.label},Ns={h1:"headingH1",h2:"headingH2",h3:"headingH3",h4:"headingH4",h5:"headingH5",h6:"headingH6"},Bs=class e{static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static{this.hideTimeoutMap=/* @__PURE__ */new Map}static{this.tooltipAnchorSeq=0}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap.get(t)||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap.set(t,i)}static create(t){const n=C.getState().getInstance(t);if(!n)return console.error("InlineToolbar::create: Instance not found for containerId:",t);const a=document.getElementById(t);if(!a)return console.error("InlineToolbar::create: Container not found for containerId:",t);e.eventListenersMap.has(a)||e.eventListenersMap.set(a,[]),l.injectStyles("clepit-inline-toolbar-styles","\n/* Inline Toolbar */\n.clepit-toolbar {\n position: absolute;\n left: 0;\n top: 0;\n translate: var(--clepit-toolbar-x, 0) var(--clepit-toolbar-y, 0);\n z-index: 1002;\n background: var(--clepit-toolbar-bg, var(--clepit-menu-bg));\n border: var(--clepit-toolbar-border, 1px solid var(--clepit-border));\n border-radius: 10px;\n padding: 4px;\n box-shadow: var(--clepit-toolbar-shadow, var(--clepit-menu-shadow));\n display: none;\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n white-space: nowrap;\n will-change: transform;\n}\n\n.clepit-toolbar--layout {\n display: flex;\n flex-direction: row;\n gap: 2px;\n align-items: center;\n}\n\n.clepit-toolbar--hidden {\n display: none !important;\n}\n\n.clepit-toolbar--visible {\n display: flex !important;\n transform: translateY(0) scale(1) !important;\n}\n\n@keyframes toolbarFadeIn {\n from {\n opacity: 0;\n transform: translateY(-10px) scale(0.95);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n}\n\n.clepit-toolbar-button {\n width: 30px;\n height: 30px;\n border: none;\n border-radius: 6px;\n background: transparent;\n color: var(--clepit-toolbar-color, var(--clepit-text));\n font-size: 12px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n line-height: 1;\n /* Ensure all content inside buttons inherits the same font size and styling */\n text-rendering: optimizeLegibility;\n will-change: transform, background-color, color;\n}\n\n/* Normalize SVG icon sizing in toolbar buttons */\n.clepit-toolbar-button svg {\n width: 18px;\n height: 18px;\n display: block;\n stroke: currentColor;\n}\n\n.clepit-toolbar-button:hover {\n background: var(--clepit-toolbar-hover-bg, var(--clepit-hover-bg));\n color: var(--clepit-toolbar-hover-color, var(--clepit-text));\n}\n\n.clepit-toolbar-button:focus-visible,\n.clepit-toolbar-type:focus-visible,\n.clepit-toolbar-menu-item:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: 1px;\n}\n\n.clepit-toolbar-button.active,\n.clepit-toolbar-button[aria-pressed='true'] {\n background: var(--clepit-toolbar-active-bg, var(--clepit-pressed-bg));\n color: var(--clepit-toolbar-active-color, var(--clepit-primary));\n}\n\n.clepit-toolbar-group {\n position: relative;\n display: flex;\n gap: 2px;\n align-items: center;\n}\n\n.clepit-toolbar-separator {\n flex: none;\n width: 1px;\n height: 18px;\n margin: 0 4px;\n background: var(--clepit-border);\n}\n\n.clepit-toolbar-type {\n display: inline-flex;\n gap: 2px;\n align-items: center;\n height: 30px;\n padding: 0 6px;\n border: 0;\n border-radius: 6px;\n background: transparent;\n color: var(--clepit-text);\n font: inherit;\n font-size: 13px;\n cursor: pointer;\n}\n\n.clepit-toolbar-type:hover,\n.clepit-toolbar-type[aria-expanded='true'] {\n background: var(--clepit-hover-bg);\n}\n\n.clepit-toolbar-type-chevron svg {\n display: block;\n width: 16px;\n height: 16px;\n color: var(--clepit-text-subtle);\n}\n\n.clepit-toolbar-menu {\n position: absolute;\n top: calc(100% + 8px);\n left: 0;\n z-index: 1003;\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 200px;\n padding: 6px;\n border-radius: var(--clepit-radius-lg);\n background: var(--clepit-menu-bg);\n box-shadow: var(--clepit-menu-shadow);\n}\n\n.clepit-toolbar-menu[hidden] {\n display: none;\n}\n\n.clepit-toolbar-group[data-testid='toolbar-group-more'] .clepit-toolbar-menu {\n right: 0;\n left: auto;\n}\n\n.clepit-toolbar-menu-item {\n display: flex;\n gap: 12px;\n align-items: center;\n min-height: 38px;\n padding: 8px 10px;\n border: 0;\n border-radius: var(--clepit-radius-md);\n background: transparent;\n color: var(--clepit-text);\n font: inherit;\n font-size: 14px;\n text-align: left;\n cursor: pointer;\n}\n\n.clepit-toolbar-menu-item:hover,\n.clepit-toolbar-menu-item[aria-checked='true'] {\n background: var(--clepit-hover-bg);\n}\n\n.clepit-toolbar-menu-icon {\n display: inline-flex;\n color: var(--clepit-text-muted);\n}\n\n.clepit-toolbar-menu-icon svg {\n display: block;\n width: 18px;\n height: 18px;\n}\n\n/* Ensure consistent base font size for character-based icons */\n.clepit-toolbar-button { font-size: 12px; }\n\n/* Tooltip styles */\n/* Anchored to its own button and shown by :hover / :focus-visible, so no\n * JavaScript measures or centres it. :focus-visible is not decoration: the old\n * mouseenter-only version was invisible to a keyboard user.\n *\n * Guarded by @supports — anchor positioning is Baseline 2026 at ~91%. Without\n * it the tooltip simply never shows, which is what it already did before this\n * change for anyone not using a mouse. */\n.clepit-toolbar-tooltip {\n position: absolute;\n display: none;\n z-index: 9999;\n pointer-events: none;\n}\n\n@supports (anchor-name: --a) {\n .clepit-toolbar-tooltip {\n position: fixed;\n position-area: top;\n margin-block-end: 8px;\n justify-self: anchor-center;\n opacity: 0;\n transform: translateY(8px);\n transition:\n opacity 0.15s ease-in-out,\n transform 0.15s ease-in-out,\n display 0.15s allow-discrete;\n }\n\n .clepit-toolbar-button:hover + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip {\n display: block;\n opacity: 1;\n transform: translateY(0);\n }\n\n @starting-style {\n .clepit-toolbar-button:hover + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip {\n opacity: 0;\n transform: translateY(8px);\n }\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .clepit-toolbar-tooltip {\n transition-duration: 0s;\n }\n}\n\n.clepit-toolbar-tooltip-content {\n white-space: nowrap;\n font-size: 12px;\n font-weight: 500;\n color: var(--clepit-inverse-text);\n background-color: var(--clepit-inverse-surface);\n padding: 4px 8px;\n border-radius: var(--clepit-radius-md);\n transition: transform 0.2s ease-in-out;\n}\n\n.clepit-toolbar-tooltip-arrow {\n position: absolute;\n top: 100%;\n left: 50%;\n margin-left: -4px;\n width: 0;\n height: 0;\n border-left: 4px solid transparent;\n border-right: 4px solid transparent;\n border-top: 4px solid var(--clepit-inverse-surface);\n}\n\n.clepit-toolbar-tooltip--hidden {\n display: none;\n transform: translateY(8px);\n}\n\n.clepit-toolbar-tooltip--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-toolbar-tooltip--fade-out {\n transform: translateY(5px);\n}\n\n/* Toolbar positioning and animation classes */\n.clepit-toolbar--positioned {\n position: absolute;\n}\n\n.clepit-toolbar--measurement {\n display: flex;\n visibility: hidden;\n opacity: 0;\n position: absolute;\n left: -9999px;\n top: -9999px;\n}\n\n.clepit-toolbar--show-animation {\n display: flex;\n visibility: visible;\n transform: translateY(-10px) scale(0.95);\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar--show-animation.clepit-toolbar--visible {\n transform: translateY(0) scale(1);\n}\n\n.clepit-toolbar--position-animation {\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), translate 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar--hide-animation {\n transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n transform: translateY(-5px) scale(0.98);\n}\n\n/* Rewrite menu — the sparkle-wand's action list, anchored under the toolbar */\n.clepit-toolbar-rewrite-menu {\n position: absolute;\n top: 100%;\n right: 0;\n margin-top: 4px;\n flex-direction: column;\n min-width: 160px;\n padding: 4px;\n border-radius: var(--clepit-radius-sm, 6px);\n background: var(--clepit-surface, #fff);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);\n z-index: 2;\n}\n\n.clepit-toolbar-rewrite-item {\n appearance: none;\n border: 0;\n background: transparent;\n color: var(--clepit-text-primary, inherit);\n font: inherit;\n text-align: start;\n padding: 6px 10px;\n border-radius: var(--clepit-radius-xs, 4px);\n cursor: pointer;\n}\n\n.clepit-toolbar-rewrite-item:hover,\n.clepit-toolbar-rewrite-item:focus-visible {\n background: var(--clepit-surface-hover, rgba(0, 0, 0, 0.06));\n}\n\n/* The wand stays put while a rewrite is in flight, so the toolbar does not\n reflow under the pointer mid-request. */\n.clepit-toolbar-button.busy {\n opacity: 0.5;\n pointer-events: none;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n .clepit-toolbar {\n flex-wrap: wrap;\n max-width: 200px;\n }\n}\n");const o=p("div","clepit-toolbar");o.id=`${t}-${vs}`,o.classList.add("clepit-toolbar--hidden","clepit-toolbar--layout"),l.applyStyling(o,{classNames:n.config.classNames?.inlineToolbar?.container,styles:n.config.styles?.inlineToolbar?.container}),a.appendChild(o)}static repaint(t,n){const a=C.getState().getInstance(t);if(!a)return console.error("InlineToolbar::repaint: Instance not found for containerId:",t);const o=e.getElementFromContainerId(t);if(!o)return console.error("InlineToolbar::repaint: Toolbar not found for containerId:",t);e.clearButtons(t),o.setAttribute("role","toolbar"),o.setAttribute("aria-label",Es(a.config,"formatText"));const i=(n.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?n.commonAncestorContainer:n.commonAncestorContainer.parentElement)?.closest(`.${l.classNames.block.container}`),r=i?.getAttribute("data-tool"),s=e.getFilteredTools(r,a.config),c=e=>e.map(e=>s.find(t=>t.label===e)).filter(e=>void 0!==e),d=i?e.typePicker(t,i):null,u=[];d&&u.push(d);const h=c(ys);h.length>0&&u.push(e.buttonGroup(t,"marks",h,n));const m=c(xs);m.length>0&&u.push(e.buttonGroup(t,"insert",m,n));const g=c(ks);g.length>0&&u.push(e.moreGroup(t,g,n)),u.forEach((e,t)=>{t>0&&o.appendChild(p("span","clepit-toolbar-separator",{"aria-hidden":"true"})),o.appendChild(e)}),a.config.onInlineRewrite&&e.addRewriteButton(t,n);const b=n.getBoundingClientRect(),f=document.getElementById(a.config.containerId)?.getBoundingClientRect();if(!f)return;const v=o.getBoundingClientRect(),y=v.width>0?{height:v.height,width:v.width}:((e=!1,t=fs().length)=>({height:38,width:30*(t+(e?1:0))+8}))(Boolean(a.config.onInlineRewrite),s.length),x=b.left-f.left+b.width/2-y.width/2;let k=b.top-f.top-y.height-8;k<0&&(k=b.bottom-f.top+8),e.show(a.config.containerId,x,k)}static buttonGroup(t,n,a,o){const i=p("div","clepit-toolbar-group",{"data-testid":`toolbar-group-${n}`,role:"group"});return a.forEach(n=>e.addButton(t,n,o,i)),i}static toggleMenu(e,t,n){const a=n.hidden;e.querySelectorAll(".clepit-toolbar-menu").forEach(e=>{e.hidden=!0}),e.querySelectorAll('[aria-haspopup="menu"]').forEach(e=>e.setAttribute("aria-expanded","false")),n.hidden=!a,t.setAttribute("aria-expanded",String(a))}static typePicker(t,n){const a=C.getState().getInstance(t),o=e.getElementFromContainerId(t),i=document.getElementById(t),r=n.getAttribute("data-tool");if(!(a&&o&&i&&r&&Cs.has(r)))return null;const s=n.querySelector(".clepit-header")?.getAttribute("data-level")??"h1",l="header"===r?`heading-${s}`:r,c=(e=>{const t=(t,n)=>({icon:Qi.icon,id:`heading-${t}`,label:e.blockToolbarLabels?.[Ns[t]]||n,level:t,type:"header"});return[{icon:cr.icon,id:"paragraph",label:Es(e,"text"),type:"paragraph"},t("h1","Heading 1"),t("h2","Heading 2"),t("h3","Heading 3"),t("h4","Heading 4"),t("h5","Heading 5"),t("h6","Heading 6"),{icon:or.icon,id:"list",label:e.blockToolLabels?.list||or.label,type:"list"},{icon:Rt.icon,id:"checklist",label:e.blockToolLabels?.checklist||Rt.label,type:"checklist"},{icon:dr.icon,id:"quote",label:e.blockToolLabels?.quote||dr.label,type:"quote"}]})(a.config).filter(e=>kt(a.config,e.type)),d=c.find(e=>e.id===l)?.label??Es(a.config,"text"),u=p("div","clepit-toolbar-group",{"data-testid":"toolbar-group-type",role:"group"}),h=p("button","clepit-toolbar-type",{"aria-expanded":"false","aria-haspopup":"menu","aria-label":`${Es(a.config,"textType")}: ${d}`,"data-testid":"toolbar-type-picker",type:"button"}),m=p("span","clepit-toolbar-type-label");m.textContent=d,h.appendChild(m);const g=p("span","clepit-toolbar-type-chevron",{"aria-hidden":"true"});g.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M8.12 9.29 12 13.17l3.88-3.88c.39-.39 1.02-.39 1.41 0s.39 1.02 0 1.41l-4.59 4.59c-.39.39-1.02.39-1.41 0L6.7 10.7a.996.996 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0"></path></svg>',h.appendChild(g);const b=p("div","clepit-toolbar-menu",{"data-testid":"toolbar-type-menu",role:"menu"});return b.hidden=!0,c.forEach(a=>{const o=p("button","clepit-toolbar-menu-item",{"data-testid":`toolbar-type-${a.id}`,role:"menuitemradio",type:"button"});o.setAttribute("aria-checked",String(a.id===l));const s=p("span","clepit-toolbar-menu-icon",{"aria-hidden":"true"});s.innerHTML=a.icon,o.appendChild(s);const c=p("span","clepit-toolbar-menu-label");c.textContent=a.label,o.appendChild(c),e.addEventListener(i,o,"mousedown",e=>e.preventDefault()),e.addEventListener(i,o,"click",()=>{if(b.hidden=!0,h.setAttribute("aria-expanded","false"),a.id===l)return;const e=n.querySelector(".clepit-header");if(a.level&&"header"===r&&e)En.changeLevel(e,a.level,t);else if(Ur.turnInto(n,t,a.type),a.level){const e=a.level;setTimeout(()=>{const a=n.querySelector(".clepit-header");a&&En.changeLevel(a,e,t)},0)}}),b.appendChild(o)}),e.addEventListener(i,h,"mousedown",e=>e.preventDefault()),e.addEventListener(i,h,"click",()=>e.toggleMenu(o,h,b)),u.appendChild(h),u.appendChild(b),u}static moreGroup(t,n,a){const o=C.getState().getInstance(t),i=e.getElementFromContainerId(t),r=document.getElementById(t),s=p("div","clepit-toolbar-group",{"data-testid":"toolbar-group-more",role:"group"});if(!o||!i||!r)return s;const l=Es(o.config,"more"),c=p("button","clepit-toolbar-button",{"aria-expanded":"false","aria-haspopup":"menu","aria-label":l,"data-testid":"toolbar-more",type:"button"});c.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"></path></svg>';const d=p("div","clepit-toolbar-menu",{"data-testid":"toolbar-more-menu",role:"menu"});return d.hidden=!0,n.forEach(n=>{const i=p("button","clepit-toolbar-menu-item",{"data-tool":n.label.toLowerCase(),role:"menuitem",type:"button"}),s=p("span","clepit-toolbar-menu-icon",{"aria-hidden":"true"});s.innerHTML=n.icon,i.appendChild(s);const l=p("span","clepit-toolbar-menu-label");l.textContent=Ls(o.config,n),i.appendChild(l),n.isActive(a)&&i.setAttribute("aria-pressed","true"),e.addEventListener(r,i,"mousedown",e=>e.preventDefault()),e.addEventListener(r,i,"click",()=>{d.hidden=!0,c.setAttribute("aria-expanded","false");const o=e.toggleTool(t,n,a);null!==o&&(i.classList.toggle("active",o),i.setAttribute("aria-pressed",String(o)))}),d.appendChild(i)}),e.addEventListener(r,c,"mousedown",e=>e.preventDefault()),e.addEventListener(r,c,"click",()=>e.toggleMenu(i,c,d)),s.appendChild(c),e.createTooltip(i,c,l),s.appendChild(d),s}static addRewriteButton(t,n){const a=C.getState().getInstance(t),o=a?.config.onInlineRewrite;if(!a||!o)return;const i=e.getElementFromContainerId(t),r=document.getElementById(t);if(!i||!r)return;const s=p("button","clepit-toolbar-button",{type:"button"});s.innerHTML='<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M12 2l1.6 4.4L18 8l-4.4 1.6L12 14l-1.6-4.4L6 8l4.4-1.6L12 2zm6 10l.9 2.5L21 15l-2.1.8L18 18l-.9-2.2L15 15l2.1-.5L18 12zM6 13l1.1 3L10 17l-2.9 1L6 21l-1.1-3L2 17l2.9-1L6 13z"/></svg>',s.setAttribute("data-tool","rewrite"),l.applyStyling(s,{classNames:a.config.classNames?.inlineToolbar?.button,styles:a.config.styles?.inlineToolbar?.button});const c=p("div","clepit-toolbar-rewrite-menu");c.style.display="none",c.setAttribute("data-rewrite-menu","true");for(const l of Dr){const t=p("button","clepit-toolbar-rewrite-item",{type:"button"});t.textContent=a.config.inlineRewriteLabels?.[l]??l,t.setAttribute("data-rewrite-action",l),e.addEventListener(r,t,"mousedown",e=>e.preventDefault()),e.addEventListener(r,t,"click",()=>{c.style.display="none";const e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0):null,a=t&&!t.collapsed?t:n,i=a.toString();i.trim()&&(s.classList.add("busy"),o(i,l).then(e=>{e&&(a.deleteContents(),a.insertNode(document.createTextNode(e)),r.dispatchEvent(new Event("input",{bubbles:!0})))}).catch(e=>console.error("The rewrite failed, the passage is unchanged:",e)).finally(()=>s.classList.remove("busy")))}),c.appendChild(t)}e.addEventListener(r,s,"mousedown",e=>e.preventDefault()),e.addEventListener(r,s,"click",()=>{c.style.display="none"===c.style.display?"flex":"none"}),i.appendChild(s),e.createTooltip(i,s,a.config.inlineRewriteTooltip??"rewrite"),i.appendChild(c)}static addButton(t,n,a,o){const i=C.getState().getInstance(t);if(!i)return console.error("InlineToolbar::addButton: Instance not found for containerId:",t);const r=e.getElementFromContainerId(t);if(!r)return console.error("InlineToolbar::addButton: Toolbar not found for containerId:",t);const s=p("button","clepit-toolbar-button",{type:"button"});s.innerHTML=n.icon,l.applyStyling(s,{classNames:i.config.classNames?.inlineToolbar?.button,styles:i.config.styles?.inlineToolbar?.button});const c=n.isActive(a);c&&s.classList.add("active"),s.setAttribute("aria-pressed",String(c)),s.setAttribute("data-tool",n.label.toLowerCase());const d="shortcut"in n?n.shortcut:"";s.setAttribute("aria-label",d?`${Ls(i.config,n)} ${d}`:Ls(i.config,n));const u=document.getElementById(t);u&&(e.addEventListener(u,s,"mousedown",e=>e.preventDefault()),e.addEventListener(u,s,"click",()=>{const o=e.toggleTool(t,n,a);null!==o&&(s.classList.toggle("active",o),s.setAttribute("aria-pressed",String(o)))})),(o??r).appendChild(s),e.createTooltip(r,s,s.getAttribute("aria-label")??"")}static toolForKey(t,n,a){const o=ws[a.toLowerCase()];if(o)return e.getFilteredTools(n,C.getState().getInstance(t)?.config).find(e=>e.label===o)}static toggleTool(e,t,n){const a=C.getState().getInstance(e);if(!a)return null;try{const e=window.getSelection(),o=e&&e.rangeCount>0?e.getRangeAt(0):null,i=o&&!o.collapsed?o:n;if(i&&t.isActive(i))return t.remove(i),!1;if(i){switch(t.label){case"italic":Gr.apply(i);break;case"bold":Wr.apply(i);break;case"underline":bs.apply(i);break;case"strikethrough":ps.apply(i);break;case"inline code":Kr.apply(i,a.config.classNames?.blocks?.["inline-code"],a.config.styles?.blocks?.["inline-code"]);break;case"marker":ts.apply(i,a.config.classNames?.blocks?.marker,a.config.styles?.blocks?.marker);break;case"status":ds.apply(i,a.config.classNames?.dialogs,a.config.styles?.dialogs,a.config.dialogLabels);break;case"link":Zr.apply(i,a.config.classNames?.dialogs,a.config.styles?.dialogs,a.config.dialogLabels);break;case"tooltip":gs.apply(i,{classNames:a.config.classNames?.tooltips,styles:a.config.styles?.tooltips},{classNames:a.config.classNames?.blocks?.tooltip,styles:a.config.styles?.blocks?.tooltip},a.config.dialogLabels)}return!0}return null}catch(o){return console.warn("Error applying inline tool:",o),null}}static createTooltip(t,n,a){const o=p("div","clepit-toolbar-tooltip clepit-toolbar-tooltip--hidden"),i=p("div","clepit-toolbar-tooltip-content");i.textContent=a;const r=p("div","clepit-toolbar-tooltip-arrow");i.appendChild(r),o.appendChild(i),n.insertAdjacentElement("afterend",o);const s="--clepit-inline-tool-"+e.tooltipAnchorSeq++;n.style.setProperty("anchor-name",s),o.style.setProperty("position-anchor",s),o.classList.remove("clepit-toolbar-tooltip--hidden")}static clearButtons(t){const n=e.getElementFromContainerId(t);if(!n)return console.error("InlineToolbar::clearButtons: Toolbar not found for containerId:",t);n.replaceChildren()}static show(t,n,a){const o=e.getElementFromContainerId(t);if(!o)return console.error("InlineToolbar::show: Toolbar not found for containerId:",t);const i=o.classList.contains("clepit-toolbar--visible")&&!o.classList.contains("clepit-toolbar--hidden");if(e.cancelPendingHide(t),o.classList.remove("clepit-toolbar--hidden","clepit-toolbar--hide-animation"),i){const t=Math.abs(e.offset(o,"x")-n)>1||Math.abs(e.offset(o,"y")-a)>1;o.classList.toggle("clepit-toolbar--position-animation",t)}else o.classList.remove("clepit-toolbar--position-animation"),o.classList.add("clepit-toolbar--show-animation");o.style.setProperty("--clepit-toolbar-x",`${n}px`),o.style.setProperty("--clepit-toolbar-y",`${a}px`),requestAnimationFrame(()=>{o.classList.contains("clepit-toolbar--hidden")||o.classList.add("clepit-toolbar--visible")})}static offset(e,t){return Number.parseFloat(e.style.getPropertyValue(`--clepit-toolbar-${t}`))||0}static hide(t){const n=e.getElementFromContainerId(t);if(n)if(e.cancelPendingHide(t),n.classList.contains("clepit-toolbar--visible")){n.classList.add("clepit-toolbar--hide-animation");const a=setTimeout(()=>{n.classList.remove("clepit-toolbar--visible","clepit-toolbar--hide-animation"),n.classList.add("clepit-toolbar--hidden"),e.hideTimeoutMap.delete(t)},200);e.hideTimeoutMap.set(t,a)}else n.classList.remove("clepit-toolbar--visible"),n.classList.add("clepit-toolbar--hidden")}static cancelPendingHide(t){const n=e.hideTimeoutMap.get(t);void 0!==n&&(clearTimeout(n),e.hideTimeoutMap.delete(t))}static getElementFromContainerId(e){const t=document.querySelector(`#${e}`);return t?t.querySelector(`#${t.id}-${vs}`):(console.error("InlineToolbar::getElementFromContainerId: Container not found for containerId:",e),null)}static getFilteredTools(e,t){const n=fs().filter(e=>((e,t)=>void 0===e?.allowedInlineTools||e.allowedInlineTools.includes(t))(t,e.label.replace(" ","-")));return"header"===e?n.filter(e=>"bold"!==e.label):n}static destroy(t){e.cancelPendingHide(t);const n=document.querySelector(`#${t}`);if(!n)return;const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n));const o=n.querySelector(`#${t}-${vs}`);if(!o)return console.warn("InlineToolbar::destroy: Toolbar not found for containerId:",t);o.remove()}},Ms={},$s={dismiss(e){for(const{capture:t,element:n,event:a,handler:o}of Ms[e]??[])n.removeEventListener(a,o,t);Ms[e]=[],document.querySelector(`[data-embed-offer-for="${e}"]`)?.remove()},show(e,t,n,a){$s.dismiss(e);const o=window.getSelection(),i=o?.rangeCount?o.getRangeAt(0):null;if(!i)return;i.deleteContents();const r=document.createTextNode(n);i.insertNode(r),i.setStartAfter(r),i.collapse(!0),o?.removeAllRanges(),o?.addRange(i);const s=document.getElementById(e);if(!s)return;const l=C.getState().getInstance(e)?.config,c=Ye[a.provider]??a.provider,d=document.createElement("div");d.className="clepit-embed-offer",d.setAttribute("data-testid","embed-offer"),d.setAttribute("data-embed-offer-for",e);const p=document.createElement("span");p.textContent=Ze(l?.embedLabels,"offerShowLive",{tool:c}).replace(" · Show live",""),d.appendChild(p);const u=document.createElement("button");u.type="button",u.setAttribute("data-testid","embed-offer-accept"),u.textContent=Ze(l?.embedLabels,"offerShowLive",{tool:c}).split(" · ").pop()??"Show live",d.appendChild(u);const h=i.getBoundingClientRect(),m=s.getBoundingClientRect();d.style.left=`${Math.max(0,h.left-m.left)}px`,d.style.top=h.bottom-m.top+6+"px",s.appendChild(d);const g=()=>{const a=t.getAttribute("data-id"),o=Ds.getBlockIndex(e,a);$s.dismiss(e),-1!==o&&D(e,o,!0,n)},b=t=>{const n=t.key;if("Enter"===n)return t.preventDefault(),t.stopPropagation(),void g();"Shift"!==n&&"Meta"!==n&&"Control"!==n&&"Alt"!==n&&$s.dismiss(e)},f=t=>{d.contains(t.target)||$s.dismiss(e)};u.addEventListener("click",g),document.addEventListener("keydown",b,!0),document.addEventListener("mousedown",f),Ms[e]=[{element:u,event:"click",handler:g},{capture:!0,element:document,event:"keydown",handler:b},{element:document,event:"mousedown",handler:f}]}},Is={},Ts={dismiss(e){for(const{element:t,event:n,handler:a}of Is[e]??[])t.removeEventListener(n,a);Is[e]=[],document.querySelector(`[data-issue-menu-for="${e}"]`)?.remove()},show(e,t){Ts.dismiss(e),l.injectStyles(Ee,Le);const n=document.getElementById(e);if(!n)return;const a=C.getState().getInstance(e)?.config,o=Re.read(t),i=Ie(o.tool),r=document.createElement("div");r.className="clepit-issue-menu",r.setAttribute("data-testid","issue-menu"),r.setAttribute("data-issue-menu-for",e);const s=je(o,a?.issueLabels);if(s){const t=document.createElement("div");if(t.className="clepit-issue-menu__reason",t.setAttribute("data-testid","issue-reason"),t.textContent=s,r.appendChild(t),"connect_tool"===o.reason){const t=document.createElement("button");t.type="button",t.setAttribute("data-testid","issue-connect"),t.textContent=$e(a?.issueLabels,"connectAction"),t.addEventListener("click",()=>{Ts.dismiss(e),a?.onIssueAction?.("connect",o.tool)}),r.appendChild(t)}}const c=document.createElement("a");c.href=o.url,c.target="_blank",c.rel="noopener noreferrer",c.setAttribute("data-testid","issue-open"),c.textContent=$e(a?.issueLabels,"openInTool",{tool:i}),c.addEventListener("click",()=>Ts.dismiss(e)),r.appendChild(c);const d=document.createElement("button");d.type="button",d.setAttribute("data-testid","issue-show-card"),d.textContent=$e(a?.issueLabels,"showAsCard"),d.addEventListener("click",()=>{Ts.dismiss(e),Ts.showAsCard(e,t)}),r.appendChild(d);const p=t.getBoundingClientRect(),u=n.getBoundingClientRect();r.style.left=`${Math.max(0,p.left-u.left)}px`,r.style.top=p.bottom-u.top+6+"px",n.appendChild(r);const h=t=>{"Escape"===t.key&&Ts.dismiss(e)},m=n=>{r.contains(n.target)||t.contains(n.target)||Ts.dismiss(e)};document.addEventListener("keydown",h),document.addEventListener("mousedown",m),Is[e]=[{element:document,event:"keydown",handler:h},{element:document,event:"mousedown",handler:m}]},showAsCard(e,t){const n=Re.read(t),a=t.closest(`.${l.classNames.block.container}`),o=a?.getAttribute("data-id");if(!a||!o)return;const i=Ds.getBlockIndex(e,o);if(-1===i)return;const r=t.closest('[contenteditable="true"]');t.remove();const s={data:{issue:n,url:n.url},type:"embed"};Ds.getTool(a.getAttribute("data-tool"))?.input.isEmpty(a)?Ds.replaceBlock(e,i,s):(r&&Ds.saveBlockData(r),Ds.insertBlock(s,e,i+1))}},_s={Digit0:0,Digit1:1,Digit2:2,Digit3:3,Digit4:4},qs=class e{static addListeners(t){const n=document.getElementById(t);if(!n)return console.error("EventManager::addListeners: Container not found for containerId:",t);document.addEventListener("selectionchange",e.handleSelectionChange),document.addEventListener("paste",e.handlePaste),n.addEventListener("click",e.handleClick),n.addEventListener("keydown",e.handleShortcut)}static removeListeners(t){const n=document.getElementById(t);n&&(document.removeEventListener("selectionchange",e.handleSelectionChange),document.removeEventListener("paste",e.handlePaste),n.removeEventListener("click",e.handleClick),n.removeEventListener("keydown",e.handleShortcut))}static handleShortcut(t){if(!t.metaKey&&!t.ctrlKey||t.shiftKey)return;const n=t.currentTarget,a=t.target.closest(`.${l.classNames.block.container}`);a&&(t.altKey?e.setTextBlockStyle(n.id,a,t):e.toggleInlineTool(n.id,a,t))}static toggleInlineTool(e,t,n){if(!(n.key.toLowerCase()in ws))return;const a=window.getSelection(),o=a&&a.rangeCount>0?a.getRangeAt(0):null;if(!o||o.collapsed||!t.contains(o.commonAncestorContainer))return;n.preventDefault();const i=Bs.toolForKey(e,t.getAttribute("data-tool"),n.key);i&&Bs.toggleTool(e,i,o)}static setTextBlockStyle(e,t,n){const a=_s[n.code],o=t.getAttribute("data-id"),i=t.getAttribute("data-tool");if(void 0===a||!o||"paragraph"!==i&&"header"!==i)return;if(n.preventDefault(),0===a)return void("header"===i&&Ds.convertBlock(o,"paragraph",e));"paragraph"===i&&Ds.convertBlock(o,"header",e);const r=Ds.getBlock(o)?.querySelector(`.${l.classNames.block.header}`);r&&En.changeLevel(r,`h${a}`,e)}static getInstanceAndTargetFromRange(e){const t=e.commonAncestorContainer,n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!n)return null;const a=n.closest(`.${l.classNames.editor.content}`);if(!a)return null;const o=a.getAttribute("data-container-id");if(!o)return null;const i=C.getState().getInstance(o);return i?{instance:i,target:n}:null}static handleClick(e){const t=e.currentTarget,n=e.target,a=n.closest(`a.${Te}`);if(a){if("edit"!==C.getState().getInstance(t.id)?.currentView)return;return e.preventDefault(),void Ts.show(t.id,a)}const o=n.closest(`.${l.classNames.block.link}`);if(o){const e=document.createRange();e.selectNodeContents(o);const n=C.getState().getInstance(t.id);return void(n&&Zr.apply(e,n.config.classNames?.dialogs,n.config.styles?.dialogs,n.config.dialogLabels))}const i=n.closest(`.${l.classNames.block.tooltip}`);if(i){const e=document.createRange();e.selectNodeContents(i);const n=C.getState().getInstance(t.id);return void(n&&gs.apply(e,{classNames:n.config.classNames?.tooltips,styles:n.config.styles?.tooltips},{classNames:n.config.classNames?.blocks?.tooltip,styles:n.config.styles?.blocks?.tooltip},n.config.dialogLabels))}}static handleSelectionChange(){const t=window.getSelection();if(!t||0===t.rangeCount)return;const n=t.getRangeAt(0),a=e.getInstanceAndTargetFromRange(n);if(!a)return;if("edit"!==a.instance.currentView)return void Bs.hide(a.instance.config.containerId);if(null!==document.querySelector(".clepit-dialog-overlay"))return;const o=t?.toString().trim();o&&o.length>0||t&&t.rangeCount>0&&!t.getRangeAt(0).collapsed?Bs.repaint(a.instance.config.containerId,n):Bs.hide(a.instance.config.containerId)}static handlePaste(e){const t=e.clipboardData?.getData("text/plain").trim()??"";if(!t)return;const n=document.activeElement;if(!n)return;const a=n.closest(`.${l.classNames.block.container}`);if(!a)return;const o=a.closest(`.${l.classNames.editor.container}`);if(!o)return;const i=C.getState().getInstance(o.id)?.config,r=wt(i,t);if(!r)return;const s=a.getAttribute("data-id"),c=Ds.getBlockIndex(o.id,s);if(-1===c)return;const d=Ds.getTool(a.getAttribute("data-tool"));if(!d)return;const p=d.input.isEmpty(a);if(e.preventDefault(),"issue"!==r.kind)if("embed"!==r.kind)if("image"===r.kind){const e={data:{alignment:"center",alt:"Image",caption:"",url:r.url},type:"image"};p?Ds.replaceBlock(o.id,c,e):Ds.insertBlock(e,o.id,c+1)}else{let e=r.url;r.isYouTube?e=function(e){const t=function(e){for(const t of[/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&\n?#]+)/,/youtube\.com\/embed\/([^&\n?#]+)/]){const n=e.match(t);if(n)return n[1]}return null}(e);return t?`https://www.youtube.com/embed/${t}`:null}(r.url)||r.url:r.isVimeo&&(e=function(e){const t=function(e){for(const t of[/vimeo\.com\/(\d+)/,/player\.vimeo\.com\/video\/(\d+)/]){const n=e.match(t);if(n)return n[1]}return null}(e);return t?`https://player.vimeo.com/video/${t}`:null}(r.url)||r.url);const t={data:{alignment:"center",alt:"Video",caption:"",url:e},type:"video"};p?Ds.replaceBlock(o.id,c,t):Ds.insertBlock(t,o.id,c+1)}else"offer"===(i?.pasteEmbeds??"live")?$s.show(o.id,a,t,r.embed):D(o.id,c,p,t);else gt(o.id,0,c,p,t,r.issue)}},Ds=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static createBlockElement(t,n){const a=C.getState().getInstance(n);if(!a)return console.error("BlockManager::createBlockElement: Instance not found for containerId:",n),null;const o=p("div",l.classNames.block.container);o.setAttribute("data-container-id",n),o.setAttribute("data-id",t.id??crypto.randomUUID()),o.setAttribute("data-tool",t.type),o.setAttribute("data-indent","0");const i={classNames:a.config.classNames?.blocks?.[t.type],styles:a.config.styles?.blocks?.[t.type]};let r,s;if(i.margins&&(r=i.margins.top,s=i.margins.bottom),void 0===r&&i.styles){const e=i.styles;if(e.marginTop){const t=e.marginTop;"string"==typeof t&&t.endsWith("px")?r=parseInt(t.replace("px",""),10):"number"==typeof t&&(r=t)}}if(void 0===s&&i.styles){const e=i.styles;if(e.marginBottom){const t=e.marginBottom;"string"==typeof t&&t.endsWith("px")?s=parseInt(t.replace("px",""),10):"number"==typeof t&&(s=t)}}void 0===r&&void 0!==a.config.margins?.top&&(r=a.config.margins.top),void 0===s&&void 0!==a.config.margins?.bottom&&(s=a.config.margins.bottom),void 0!==r&&(o.style.marginTop=`${r}px`),void 0!==s&&(o.style.marginBottom=`${s}px`),Ur.create({block:o,containerId:n});const c=p("div",l.classNames.block.content),d=e.renderTool(t.type,t.data,n);return d?(c.appendChild(d),e.addEventListener(n,o,"click",t=>e.focusBlock(t.currentTarget)),o.appendChild(c),v.apply(n,o),o):(console.error("BlockManager::createBlockElement: Rendered element not found for type:",t.type),null)}static insertBlock(t,n,a){e.adoptStartingBlock(n);const o=e.createBlockElement(t,n);if(!o)return null;e.renderBlock(o,n,a);const i=e.getBlockData(o.getAttribute("data-id"));return C.getState().addBlock(n,i,e.getBlockIndex(n,o.getAttribute("data-id"))),o}static removeBlock(t,n){const a=e.getBlocks(t);if(n<0||n>=a.length||1===a.length)return null;if(n>0){const t=e.getBlock(a[n-1].getAttribute("data-id"));t&&e.focusBlock(t)}else if(0===n&&a.length>1){const t=e.getBlock(a[n+1].getAttribute("data-id"));t&&e.focusBlock(t)}a[n].remove(),C.getState().removeBlock(t,n)}static replaceBlock(t,n,a){e.insertBlock(a,t,n+1),e.removeBlock(t,n)}static moveBlock(t,n,a){const o=e.getBlocks(t);if(n<0||n>=o.length||a<0||a>=o.length)return;const i=C.getState().getData(t);if(!i)return;const r=C.getState().getContentElement(t);if(!r)return;const s=o[n];o.splice(n,1),o.splice(a,0,s),0===a?r.insertBefore(s,r.firstChild):a>=o.length-1?r.appendChild(s):r.insertBefore(s,o[a+1]);const l=o.map(t=>e.getBlockData(t.getAttribute("data-id"))),c={...i,blocks:l};C.getState().setData(t,c),e.focusBlock(s)}static getBlock(e){return document.querySelector(`[data-id="${e}"]`)}static getBlocks(e){const t=document.getElementById(e);if(!t)return[];const n=t.querySelectorAll(`.${l.classNames.block.container}`);return Array.from(n)}static getActiveBlocks(e){const t=document.getElementById(e);if(!t)return[];const n=t.querySelectorAll(`.${l.classNames.block.active}`);return Array.from(n)}static getBlockIndex(t,n){return e.getBlocks(t).findIndex(e=>e.getAttribute("data-id")===n)}static getTool(e){return Lr.find(t=>t.type===e)||null}static getBlockData(t){const n=e.getBlock(t);if(!n)return{data:{html:""},type:"paragraph"};const a=n.getAttribute("data-tool"),o=a?e.getTool(a):null;if(!o)return{data:{html:""},id:t,type:"paragraph"};const i=n.querySelector(`.${l.classNames.block.content}`);return i?{data:o.input.save(i),id:t,tunes:e.getBlockTunes(n),type:a}:{data:{html:""},id:t,tunes:e.getBlockTunes(n),type:a}}static extractData(t){return{blocks:e.getBlocks(t).map(t=>e.getBlockData(t.getAttribute("data-id"))),time:Date.now(),version:"1.0.0"}}static renderTool(e,t,n){const a=C.getState().getInstance(n);if(!a)return null;const o={classNames:a.config.classNames?.blocks?.[e],styles:a.config.styles?.blocks?.[e]};switch(e){case"alert":return Lt.render(n,t,o);case"audio":return a.config.audioUploader?qt.render(a.config.audioUploader,n,t,o):(console.error("BlockManager::renderTool: Audio uploader not found for containerId:",n),null);case"code":return ge.render(n,t,o);case"collapsible":return Gt.render(n,t,o);case"columns":return ji.render(n,t,o);case"date":return Oi.render(n,t,o);case"delimiter":return pn.render(n,t,o);case"collection":return qi.render(n,t,o);case"doc_card":return Vi.render(n,t,o);case"embed":return ht.render(n,t,o);case"openapi":return sr.render(n,t,o);case"sketch":return ur.render(n,t,o);case"latex":return xr.render(n,t,o);case"mermaid":return kr.render(n,t,o);case"file":return a.config.fileUploader?Gi.render(a.config.fileUploader,n,t,o):(console.error("BlockManager::renderTool: File uploader not found for containerId:",n),null);case"glance":return Yi.render(n,t,o);case"header":return En.render(n,t,o);case"image":return a.config.imageUploader?$n.render(a.config.imageUploader,n,t,o):(console.error("BlockManager::renderTool: Image uploader not found for containerId:",n),null);case"list":return jn.render(n,t,o);case"checklist":return Ot.render(n,t,o);case"paragraph":return fa.render(n,t,o);case"quote":return ka.render(n,t,o);case"table":return Ua.render(n,t,o);case"toc":return gr.render(n,t,o);case"issues":return nr.render(n,t,o);case"updates":return Sr.render(n,t,o);case"video":return a.config.videoUploader?Li.render(a.config.videoUploader,n,t,o):(console.error("BlockManager::renderTool: Video uploader not found for containerId:",n),null);default:return null}}static focusBlock(t){const n=t.querySelector('[contenteditable="true"]');n&&n.focus({preventScroll:!0}),e.setActiveBlock(t)}static setActiveBlock(t){const n=t.getAttribute("data-container-id");for(const a of e.getActiveBlocks(n))a.classList.remove(l.classNames.block.active);t.classList.add(l.classNames.block.active),Ur.show(n,t)}static getActiveBlock(e){const t=document.getElementById(e);return t?t.querySelector(`.${l.classNames.block.active}`):null}static convertBlock(t,n,a){const o=e.getBlock(t);if(!o)return console.error("BlockManager::convertBlock: Block not found for blockId:",t);e.adoptStartingBlock(a);const i=e.getBlockData(t),r=e.getTool(n);if(!r)return console.error("BlockManager::convertBlock: New tool not found for newType:",n);const s=e.getBlockIndex(a,t);let l=i.data;if("list"===n){const e=i.data,t=e.html||e.text||"";l={items:t?[t]:[""],type:"unordered"}}else if("header"===n){const e=i.data;l={html:e.html||e.text||"",level:"h1"}}const c={data:l,id:t,type:r.type},d=e.createBlockElement(c,a);if(!d)return console.error("BlockManager::convertBlock: New block element not found for newType:",n);o.replaceWith(d);const p=e.getBlockData(d.getAttribute("data-id"));C.getState().updateBlock(a,s,p),e.focusBlock(d)}static getBlockTunes(e){const t={},n=e.querySelectorAll("[data-tune]");for(const a of n){const e=a.getAttribute("data-tune");e&&(t[e]=a.getAttribute("data-value")||!0)}return Object.keys(t).length>0?t:void 0}static updateStateFromRange(t){const n=qs.getInstanceAndTargetFromRange(t);if(!n)return;const a=n.target.closest(`.${l.classNames.block.container}`);if(!a)return;e.adoptStartingBlock(n.instance.config.containerId);const o=e.getBlockIndex(n.instance.config.containerId,a.getAttribute("data-id"));C.getState().updateBlock(n.instance.config.containerId,o,e.getBlockData(a.getAttribute("data-id")))}static renderBlock(t,n,a){const o=e.getBlocks(n),i=C.getState().getContentElement(n);if(!i)return console.error("BlockManager::renderBlock: Container not found for containerId:",n);if(void 0!==a&&a>=0)if(a<o.length){const e=o[a];i.insertBefore(t,e),o.splice(a,0,t)}else i.appendChild(t),o.push(t);else i.appendChild(t),o.push(t);e.focusBlock(t);const r=C.getState().getInstance(n);r&&gs.initializeElements(t,{classNames:r.config.classNames?.blocks?.tooltip,styles:r.config.styles?.blocks?.tooltip})}static setBlocks(t,n){e.removeAllBlocks(n),t.forEach((t,a)=>e.insertBlock(t,n,a)),C.getState().updateData(n,{blocks:t})}static renderBlocks(t,n){for(const o of e.getBlocks(n))o.remove();const a=(t,a)=>{const o=e.createBlockElement(t,n);o&&e.renderBlock(o,n,a)};if(0===t.length)return a({data:{html:""},type:"paragraph"},0);t.forEach(a)}static adoptStartingBlock(t){const n=C.getState().getInstance(t)?.data.blocks,a=e.getBlocks(t);!n||n.length>0||1!==a.length||C.getState().seedBlocks(t,[e.getBlockData(a[0].getAttribute("data-id"))])}static removeAllBlocks(t){for(const n of e.getBlocks(t))n.remove();C.getState().setData(t,{blocks:[],time:Date.now(),version:"1.0.0"})}static resetBlocks(t){e.removeAllBlocks(t),e.insertBlock({data:{html:""},type:"paragraph"},t,0)}static getEditorId(e){const t=e.closest(`.${l.classNames.editor.container}`);return t?t.id:null}static handleKeydown(t){const n=t,a=t.currentTarget,o=a.closest(`.${l.classNames.block.container}`),i=e.getEditorId(o);if(!i)return;const r=e.getBlockIndex(i,o.getAttribute("data-id")),s=n.metaKey||n.ctrlKey;if(n.shiftKey)switch(n.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),r>0&&e.moveBlock(i,r,r-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const n=e.getBlocks(i);n&&r<n.length-1&&e.moveBlock(i,r,r+1)}else if(s)switch(n.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),e.removeBlock(i,r)}else if("Enter"===n.key)n.preventDefault(),n.stopPropagation(),e.insertBlock({data:{html:""},type:"paragraph"},i,r+1);else if("Backspace"===n.key){if(!h(a.innerHTML))return;n.preventDefault(),n.stopPropagation(),e.removeBlock(i,r)}else{e.ensureActiveBlock(i);const a=e.getBlocks(i);switch(n.key){case"ArrowUp":if(t.preventDefault(),t.stopPropagation(),r>0){const t=a[r-1];t&&e.focusBlock(t)}return;case"ArrowDown":if(t.preventDefault(),t.stopPropagation(),r<a.length-1){const t=a[r+1];t&&e.focusBlock(t)}return}}}static handleInput(t){e.saveBlockData(t.currentTarget)}static ensureActiveBlock(t){const n=e.getBlocks(t);let a=e.getActiveBlock(t);if(!a){const t=document.activeElement;if(!t)return;const o=t.closest(`.${l.classNames.block.container}`);if(o)a=o,e.setActiveBlock(a);else{if(0===n.length)return;a=n[0],e.setActiveBlock(a)}}}static saveBlockData(t){const n=t.closest(`.${l.classNames.block.container}`),a=e.getEditorId(n);if(!a)return;e.adoptStartingBlock(a),v.clear(a,n);const o=n.getAttribute("data-id");C.getState().updateBlockData(a,e.getBlockIndex(a,o),e.getBlockData(o).data)}static updateBlockData(t,n,a){e.adoptStartingBlock(a);const o=e.getBlock(t);if(o){const t=o.querySelector(`.${l.classNames.block.content}`);t&&(t.innerHTML="");const i=e.renderTool(o.getAttribute("data-tool"),n,a);i&&t.appendChild(i),v.apply(a,o)}C.getState().updateBlockData(a,e.getBlockIndex(a,t),n)}static destroy(t){if(!document.getElementById(t))return;const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[]),Lr.forEach(e=>e.input.destroy(t));for(const a of e.getBlocks(t))a.remove()}},zs=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static create(t){const n=C.getState().getInstance(t);if(!n)return console.error("ActionBar::create: Instance not found for containerId:",t);l.injectStyles("clepit-action-bar-styles",'\n.clepit-action-bar {\n display: flex;\n align-items: center;\n gap: 8px;\n min-height: 40px;\n border-bottom: 1px solid var(--clepit-border);\n}\n\n.clepit-action-bar-group {\n display: flex;\n align-self: stretch;\n gap: 4px;\n}\n\n.clepit-action-bar-button {\n display: inline-flex;\n align-items: center;\n margin-bottom: -1px;\n padding: 8px 12px 10px;\n border: 0;\n border-bottom: 2px solid transparent;\n background: transparent;\n color: var(--clepit-text-muted);\n font-family: inherit;\n font-size: 13.5px;\n font-weight: 500;\n white-space: nowrap;\n cursor: pointer;\n transition: color 0.15s ease, border-color 0.15s ease;\n}\n\n.clepit-action-bar-button:hover {\n color: var(--clepit-text);\n}\n\n.clepit-action-bar-button[aria-selected="true"] {\n color: var(--clepit-text);\n border-bottom-color: var(--clepit-primary);\n}\n\n.clepit-action-bar-button:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: -2px;\n}\n\n.clepit-view-actions {\n display: flex;\n align-items: center;\n gap: 2px;\n margin-inline-start: auto;\n}\n\n.clepit-view-action-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n border: 0;\n border-radius: var(--clepit-radius-md);\n background: transparent;\n color: var(--clepit-text-muted);\n cursor: pointer;\n transition: background-color 0.15s ease, color 0.15s ease;\n}\n\n.clepit-view-action-button svg {\n width: 18px;\n height: 18px;\n}\n\n.clepit-view-action-button:hover {\n background: var(--clepit-hover-bg);\n color: var(--clepit-text);\n}\n\n.clepit-view-action-button:active {\n background: var(--clepit-pressed-bg);\n}\n\n.clepit-view-action-button:focus-visible {\n outline: 2px solid var(--clepit-focus-ring);\n outline-offset: 1px;\n}\n\n.clepit-view-action-button--copy-feedback {\n background-color: var(--clepit-success);\n color: var(--clepit-bg);\n}\n\n.clepit-action-bar ~ .clepit-editor-content {\n border-top: 0;\n border-start-start-radius: 0;\n border-start-end-radius: 0;\n}\n\n@media (pointer: coarse) {\n .clepit-action-bar-button {\n min-height: 44px;\n }\n\n .clepit-view-action-button {\n width: 44px;\n height: 44px;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .clepit-action-bar-button,\n .clepit-view-action-button {\n transition: none;\n }\n}\n');const a=document.getElementById(t);if(!a)return;const o=!1!==n.config.hasViewSwitcher,i=!1!==n.config.hasDocumentActions;if(!o&&!i)return;const r=n.config.styles?.controls?.group,s=n.config.classNames?.controls?.group,c=n.config.styles?.controls?.button,d=n.config.classNames?.controls?.button,u=n.config.styles?.tooltips,h=n.config.classNames?.tooltips,m=p("div",l.classNames.actionBar.container);e.createButtonGroup(a,m,{buttonClassNames:d,buttonStyles:c,currentView:n.currentView,groupClassNames:s,groupStyles:r,hasDocumentActions:i,hasViewSwitcher:o,labels:n.config.controlLabels,tooltipClassNames:h,tooltipStyles:u}),a.insertBefore(m,a.firstChild)}static createButtonGroup(t,n,a){const o=(e,t)=>a.labels?.[e]||t,i=o("copyJson","Copy as JSON"),r=o("downloadJson","Download as JSON"),s=o("clearEditor","Clear page");if(a.hasViewSwitcher){const i=p("div",l.classNames.actionBar.group,{"aria-label":o("viewSwitcher","Editor view"),role:"tablist"});l.applyStyling(i,{classNames:a.groupClassNames,styles:a.groupStyles});const r=[{label:o("editView","Edit"),suffix:l.idSuffixes.actionBar.editButton,testId:"action-bar-edit-button",view:"edit"},{label:o("previewView","Preview"),suffix:l.idSuffixes.actionBar.previewButton,testId:"action-bar-preview-button",view:"preview"},{label:o("jsonView","JSON"),suffix:l.idSuffixes.actionBar.jsonButton,testId:"action-bar-json-button",view:"json"}];for(const n of r){const o=n.view===a.currentView,r=p("button",l.classNames.actionBar.button,{"aria-label":n.label,"aria-selected":String(o),"data-testid":n.testId,"data-view":n.view,id:u(t.id,n.suffix),role:"tab",tabindex:o?"0":"-1",type:"button"});r.textContent=n.label,o&&r.classList.add("active"),l.applyStyling(r,{classNames:a.buttonClassNames,styles:a.buttonStyles}),e.addEventListener(t.id,r,"click",e.handleViewChange),i.appendChild(r)}e.addEventListener(t.id,i,"keydown",e.handleTabKeys),n.appendChild(i)}if(a.hasDocumentActions){const o=p("div",l.classNames.actionBar.action);l.applyStyling(o,{classNames:a.groupClassNames,styles:a.groupStyles});const c=p("button",l.classNames.actionBar.actionButton,{"aria-label":i,"data-testid":"view-copy-button",id:u(t.id,l.idSuffixes.actionBar.copyButton),type:"button"});c.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',l.applyStyling(c,{classNames:a.buttonClassNames,styles:a.buttonStyles});const d=p("button",l.classNames.actionBar.actionButton,{"aria-label":r,"data-testid":"view-download-button",id:u(t.id,l.idSuffixes.actionBar.downloadButton),type:"button"});d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7,10 12,15 17,10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',l.applyStyling(d,{classNames:a.buttonClassNames,styles:a.buttonStyles});const h=p("button",l.classNames.actionBar.actionButton,{"aria-label":s,"data-testid":"view-clear-button",id:u(t.id,l.idSuffixes.actionBar.clearButton),type:"button"});h.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',l.applyStyling(h,{classNames:a.buttonClassNames,styles:a.buttonStyles}),e.addEventListener(t.id,c,"click",e.handleCopyJson),e.addEventListener(t.id,d,"click",e.handleDownloadJson),e.addEventListener(t.id,h,"click",e.handleClearEditor),o.appendChild(c),o.appendChild(d),o.appendChild(h),n.appendChild(o),ke(c,i,"above",a.tooltipClassNames,a.tooltipStyles),ke(d,r,"above",a.tooltipClassNames,a.tooltipStyles),ke(h,s,"above",a.tooltipClassNames,a.tooltipStyles)}}static getCurrentView(e){const t=document.getElementById(e);if(!t)return console.error("ActionBar::getCurrentView: Container not found for containerId:",e),null;const n=t.querySelector(`.${l.classNames.actionBar.group}`);if(!n)return console.error("ActionBar::getCurrentView: View toggle group not found for container:",t.id),null;const a=n.querySelector(".active");return a?a.getAttribute("data-view"):(console.error("ActionBar::getCurrentView: Active button not found for container:",t.id),null)}static updateButtonStates(e,t){const n=document.getElementById(e);if(!n)return;const a=n.querySelector(`.${l.classNames.actionBar.container}`);a&&a.querySelectorAll(`#${u(e,l.idSuffixes.actionBar.editButton)}, #${u(e,l.idSuffixes.actionBar.previewButton)}, #${u(e,l.idSuffixes.actionBar.jsonButton)}`).forEach(e=>{const n=e.getAttribute("data-view")===t;e.classList.toggle("active",n),e.setAttribute("aria-selected",String(n)),e.setAttribute("tabindex",n?"0":"-1")})}static handleTabKeys(e){if(!(e instanceof KeyboardEvent))return;const t=e.currentTarget;if(!(t instanceof HTMLElement))return;const n=[...t.querySelectorAll('[role="tab"]')],a=n.findIndex(e=>e===document.activeElement);if(a<0)return;const o={ArrowLeft:a-1,ArrowRight:a+1,End:n.length-1,Home:0}[e.key];if(void 0===o)return;e.preventDefault();const i=n[(o+n.length)%n.length];i.focus(),i.click()}static handleViewChange(t){const n=t.currentTarget,a=Ds.getEditorId(n);if(!a)return;const o=n.getAttribute("data-view");o&&(C.getState().setCurrentView(a,o),e.updateButtonStates(a,o))}static handleCopyJson(e){const t=e.currentTarget,n=Ds.getEditorId(t);if(!n)return;const a=C.getState().getInstance(n);a&&(navigator.clipboard.writeText(JSON.stringify(a.data,null,2)),t.classList.add(l.classNames.actionBar.copyFeedback),setTimeout(()=>t.classList.remove(l.classNames.actionBar.copyFeedback),200))}static handleClearEditor(e){const t=e.currentTarget,n=Ds.getEditorId(t);if(!n)return;const a=C.getState().getInstance(n)?.config.onClearRequest;a?a().then(e=>{e&&Ds.resetBlocks(n)},e=>console.error("Clear was not confirmed, the page is unchanged:",e)):Ds.resetBlocks(n)}static handleDownloadJson(e){const t=e.currentTarget,n=Ds.getEditorId(t);if(!n)return;const a=Ds.getBlocks(n).map(e=>Ds.getBlockData(e.getAttribute("data-id"))),o=new Blob([JSON.stringify(a,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${n}--content.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(i)}static destroy(e){const t=document.getElementById(e);if(!t)return;const n=t.querySelector(`.${l.classNames.actionBar.container}`);n&&n.remove()}},js=`\n/* Editor Container */\n.${l.classNames.editor.container} {\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n line-height: 1.6;\n color: var(--clepit-text);\n padding: 20px; /* Normal padding - no extra left padding needed */\n outline: none;\n box-sizing: border-box;\n width: 100%;\n}\n\n.${l.classNames.editor.container}:focus {\n outline: none;\n}\n\n.${l.classNames.editor.container}[data-readonly="true"] {\n background: var(--clepit-surface);\n color: var(--clepit-text-muted);\n cursor: not-allowed;\n}\n\n/* Editor Content Container */\n.${l.classNames.editor.content} {\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n overflow-y: auto;\n padding: 16px 24px; /* Increased horizontal padding for better preview content spacing */\n background: var(--clepit-bg);\n height: 100%;\n max-height: var(--clepit-max-height, 410px);\n min-height: var(--clepit-min-height, 200px);\n}\n\n/* JSON Output */\n.${l.classNames.editor.jsonOutput} {\n margin: 0;\n padding: 16px;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n font-size: 13px;\n line-height: 1.4;\n color: var(--clepit-text); /* default readonly is black */\n overflow-x: auto;\n white-space: pre-wrap;\n word-wrap: break-word;\n outline: none;\n min-height: 100%;\n}\n\n.${l.classNames.editor.jsonOutput}:focus {\n outline: none;\n}\n\n/* Editable (allowed) -> green text */\n.${l.classNames.editor.jsonOutput}.clepit-json-editable {\n color: var(--clepit-success);\n}\n\n/* Invalid JSON -> red text */\n.${l.classNames.editor.jsonOutput}.clepit-json-error {\n color: var(--clepit-error);\n background-color: transparent;\n}\n\n.${l.classNames.editor.jsonEmpty} {\n padding: 16px;\n text-align: center;\n color: var(--clepit-text-muted);\n font-style: italic;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n /* Container and content each carried their own inset, so a phone spent 80px\n * of a ~400px editor on nested padding before a single character. */\n .${l.classNames.editor.container} {\n padding: 8px;\n }\n\n .${l.classNames.editor.content} {\n padding: 12px;\n }\n}\n`,Hs=class e{static{this.timers={}}static{this.focusHandlers={}}static start(t){if(e.stop(t),!(C.getState().getInstance(t)?.config)?.resolveIssues)return;e.run(t),e.timers[t]=setInterval(()=>{e.run(t)},3e5);const n=()=>{e.run(t)};window.addEventListener("focus",n),e.focusHandlers[t]=n}static stop(t){const n=e.timers[t];n&&clearInterval(n),delete e.timers[t];const a=e.focusHandlers[t];a&&window.removeEventListener("focus",a),delete e.focusHandlers[t]}static urls(e){const t=document.getElementById(e);if(!t)return[];const n=/* @__PURE__ */new Set;for(const a of Re.collect(t))n.add(Re.read(a).url);for(const a of Ds.getBlocks(e)){if("embed"!==a.getAttribute("data-tool"))continue;const e=ht.save(a);e.issue&&n.add(e.url)}return n.delete(""),[...n]}static async run(t){const n=e.urls(t);if(0===n.length)return;const a=await mt(t,n),o=document.getElementById(t),i=C.getState().getInstance(t)?.config;if(o&&i&&0!==Object.keys(a).length){Re.refreshAll(o,a,i.issueLabels);for(const e of Ds.getBlocks(t)){if("embed"!==e.getAttribute("data-tool"))continue;const n=ht.save(e),o=n.issue?a[n.url]:void 0;o&&ht.refreshIssue(e,t,o)}nr.refresh(t,a)}}},Os=class{static render(e){const t=C.getState().getInstance(e);t&&(Bs.create(e),l.injectStyles("clepit-block-manager-styles",'\n/* Blocks */\n.clepit-block {\n position: relative;\n margin: var(--block-margin-top, 8px) 0 var(--block-margin-bottom, 16px) 0;\n padding: 8px 0;\n padding-left: 54px;\n border-radius: 4px;\n transition: background-color 0.2s ease;\n display: flex;\n align-items: flex-start;\n gap: 6px;\n}\n\n.clepit-block--active {\n background-color: transparent;\n}\n\n.clepit-block-content {\n outline: none;\n min-height: 1.2em;\n flex: 1;\n min-width: 0; /* Allow content to shrink */\n}\n\n.clepit-block[data-showing-locale] .clepit-block-content {\n color: color-mix(in oklab, var(--clepit-text) 60%, transparent);\n}\n\n.clepit-block-showing-locale {\n display: inline-flex;\n flex: none;\n align-items: center;\n align-self: flex-start;\n height: 18px;\n margin-top: 2px;\n padding: 0 6px;\n border-radius: 999px;\n background-color: var(--clepit-surface-2);\n color: var(--clepit-text-muted);\n font-size: 11px;\n font-weight: 500;\n letter-spacing: 0.02em;\n line-height: 1;\n user-select: none;\n}\n\n/* Remove focus outline from editable elements */\n.clepit-block-content [contenteditable="true"] {\n outline: none;\n}\n\n/* Placeholder styles for all text elements */\n.clepit-block-content:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Menu animation classes */\n.clepit-block-type-selector--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-type-selector--hidden {\n display: none;\n}\n\n/* Block Operations Menu */\n.clepit-block-operations-menu {\n position: absolute;\n top: 100%;\n left: 0;\n z-index: 1001;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 200px;\n margin-top: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-operations-menu--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-operations-menu--hidden {\n display: none;\n}\n\n/* Block Type Selector */\n.clepit-block-type-selector {\n position: absolute;\n top: 100%;\n left: 0;\n z-index: 1001;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 150px;\n margin-top: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-type-selector--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-type-selector--hidden {\n display: none;\n}\n\n.clepit-menu-item {\n box-sizing: border-box;\n display: flex;\n gap: 12px;\n align-items: center;\n min-height: 38px;\n padding: 8px 10px;\n border-radius: var(--clepit-radius-md);\n color: var(--clepit-text);\n font-size: 14px;\n line-height: 1.5;\n cursor: pointer;\n transition: background-color 120ms ease;\n}\n\n.clepit-menu-item .clepit-menu-icon {\n display: inline-flex;\n flex: none;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n color: var(--clepit-text-muted);\n}\n\n.clepit-menu-item .clepit-menu-icon--text {\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0;\n}\n\n.clepit-menu-arrow svg {\n display: block;\n width: 18px;\n height: 18px;\n}\n\n.clepit-menu-icon svg {\n display: block;\n width: 18px;\n height: 18px;\n}\n\n.clepit-menu-item:hover,\n.clepit-menu-item[data-highlighted] {\n background-color: var(--clepit-hover-bg);\n}\n\n.clepit-menu-item.active {\n background-color: var(--clepit-pressed-bg);\n color: var(--clepit-primary);\n}\n\n.clepit-menu-item--danger,\n.clepit-menu-item--danger .clepit-menu-icon {\n color: var(--clepit-error);\n}\n\n.clepit-menu-item--danger:hover,\n.clepit-menu-item--danger[data-highlighted] {\n background-color: var(--clepit-danger-bg);\n}\n\n.clepit-menu-group {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.clepit-menu-group + .clepit-menu-group {\n margin-top: 6px;\n padding-top: 6px;\n border-top: 1px solid var(--clepit-border);\n}\n\n.clepit-menu-section {\n margin: 0;\n padding: 6px 10px 4px;\n color: var(--clepit-text-subtle);\n font-size: 12px;\n font-weight: 600;\n line-height: 1.4;\n}\n\n.clepit-menu-divider {\n height: 1px;\n margin: 6px 0;\n background: var(--clepit-border);\n}\n\n.clepit-menu-arrow {\n margin-left: auto;\n color: var(--clepit-text-subtle);\n}\n\n.clepit-block-type-selector input {\n width: 100%;\n min-height: 34px;\n margin-bottom: 6px;\n padding: 6px 10px;\n border: 1px solid var(--clepit-border);\n border-radius: var(--clepit-radius-md);\n background-color: var(--clepit-bg);\n color: var(--clepit-text);\n font-size: 14px;\n outline: none;\n transition: border-color 120ms ease;\n}\n\n.clepit-block-type-selector input:focus-visible {\n border-color: var(--clepit-focus-ring);\n box-shadow: 0 0 0 1px var(--clepit-focus-ring);\n}\n\n.clepit-block-type-selector input::placeholder {\n color: var(--clepit-text-subtle);\n}\n\n.clepit-block-type-selector-items {\n display: flex;\n flex-direction: column;\n gap: 2px;\n max-height: 360px;\n overflow-y: auto;\n}\n\n.clepit-not-found-message {\n padding: 8px 10px;\n color: var(--clepit-text-muted);\n font-size: 14px;\n}\n\n.clepit-menu-shortcut {\n margin-left: auto;\n padding-left: 12px;\n color: var(--clepit-text-subtle);\n font-size: 12px;\n white-space: nowrap;\n}\n\n.clepit-menu-positioned {\n position: absolute;\n z-index: 1001;\n top: var(--menu-top, 0);\n left: var(--menu-left, 0);\n}\n\n/* The block menus are popovers in the top layer. Anchor positioning puts them\n * under the block toolbar without JavaScript measuring anything.\n *\n * Guarded: anchor positioning is Baseline 2026 (Chrome 125+, Firefox 132+,\n * Safari 18.2+), roughly 91% of traffic. Browsers without it get the popover\'s\n * default centred placement rather than a second JS positioning path — the menu\n * stays usable, just not adjacent to its button. */\n.clepit-block-type-selector:popover-open,\n.clepit-block-operations-menu:popover-open {\n /* The base menu rules above still say display:none from the pre-popover\n * mechanism, and an author rule outranks the UA\'s popover reveal. Without\n * an explicit display here every menu opens into the top layer invisible. */\n display: block;\n min-width: 260px;\n margin: 0;\n border: 0;\n border-radius: var(--clepit-radius-lg);\n background: var(--clepit-menu-bg);\n box-shadow: var(--clepit-menu-shadow);\n padding: 6px;\n overflow: visible;\n}\n\n.clepit-convert-submenu:popover-open {\n display: block;\n}\n\n@supports (anchor-name: --a) {\n .clepit-block-type-selector:popover-open,\n .clepit-block-operations-menu:popover-open {\n position-anchor: --clepit-block-toolbar;\n position-area: block-end span-inline-end;\n margin-block-start: 5px;\n inset: auto;\n }\n}\n\n@supports (position-try-fallbacks: flip-block) {\n .clepit-block-type-selector:popover-open,\n .clepit-block-operations-menu:popover-open {\n position-try-fallbacks: flip-block;\n }\n}\n\n/* Convert Submenu */\n@supports (anchor-name: --a) {\n .clepit-convert-submenu:popover-open {\n position: fixed;\n position-area: inline-end span-block-end;\n margin: 0 0 0 4px;\n inset: auto;\n }\n\n .clepit-convert-submenu:popover-open {\n position-try-fallbacks: flip-inline;\n }\n}\n\n.clepit-convert-submenu {\n position: absolute;\n top: var(--submenu-top, 0);\n left: var(--submenu-left, 100%);\n z-index: var(--submenu-z-index, 1002);\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 140px;\n margin-left: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-convert-submenu--visible {\n display: block;\n opacity: 1;\n transform: translateX(0);\n}\n\n.clepit-convert-submenu--hidden {\n display: none;\n opacity: 0;\n transform: translateX(-10px);\n}\n\n/* Input styles for convert submenu */\n.clepit-convert-submenu input {\n width: 100%;\n padding: 6px 8px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 12px;\n outline: none;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-convert-submenu input:focus {\n border-color: var(--clepit-input-focus-border, var(--clepit-primary));\n box-shadow: 0 0 0 2px var(--clepit-input-focus-shadow, var(--clepit-primary-bg));\n}\n\n.clepit-convert-submenu input::placeholder {\n color: var(--clepit-input-placeholder, var(--clepit-text-subtle));\n}\n\n.clepit-convert-submenu-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-block-operation-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n}\n\n.clepit-block-operation-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-selection-bg));\n}\n\n/* Input styles for operations menu */\n.clepit-block-operations-menu input {\n width: 100%;\n padding: 8px 12px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 14px;\n margin-bottom: 8px;\n outline: none;\n transition: border-color 0.2s;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-block-operations-menu input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n.clepit-block-operations-menu input::placeholder {\n color: var(--placeholder-color, var(--clepit-text-subtle));\n}\n\n.clepit-block-operations-menu-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-block-operation-item[data-operation="delete"] {\n color: var(--clepit-error);\n}\n\n/* Convert submenu items */\n.clepit-convert-option-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n}\n\n.clepit-convert-option-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-selection-bg));\n}\n\n/* Indentation */\n.clepit-block[data-indent="1"] .clepit-block-content {\n margin-left: 20px;\n}\n\n.clepit-block[data-indent="2"] .clepit-block-content {\n margin-left: 40px;\n}\n\n.clepit-block[data-indent="3"] .clepit-block-content {\n margin-left: 60px;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n /* The 54px gutter exists to hold the block toolbar, which is only ever\n * displayed on the active block. On a phone that reserved a seventh of the\n * editor\'s width on every idle block at once, pushing the text into a narrow\n * column with empty space either side. Give the width back and let the\n * gutter open only under the block whose toolbar is actually showing. */\n /* No transition on padding-left. The block element is re-created as you\n * interact with it, so an animated gutter restarts from 0 every time and\n * never reaches its end value — the toolbar would sit on top of the text. */\n .clepit-block {\n padding-left: 0;\n }\n\n .clepit-block--active,\n .clepit-block:focus-within,\n .clepit-block:has(.clepit-block-toolbar--visible) {\n padding-left: 54px;\n }\n}\n'),Ds.renderBlocks(t.data.blocks,e))}},Ps=class e{static render(t){const n=C.getState().getInstance(t);if(!n)return;const a=document.getElementById(n.contentId);if(a)if(a.innerHTML="",n.data&&n.data.blocks&&n.data.blocks.length>0){const t=l.createStyledElement("pre",l.classNames.editor.jsonOutput);t.textContent=JSON.stringify(n.data,null,2),t.setAttribute("data-testid","json-editable-textarea"),n.config.allowJsonViewEditing&&(t.setAttribute("contenteditable","true"),t.classList.add(l.classNames.editor.jsonEditable),setTimeout(()=>t.focus(),0),e.addEventListeners(t)),a.appendChild(t)}else{const e=l.createStyledElement("div",l.classNames.editor.jsonEmpty);e.textContent="No content to display",a.appendChild(e)}}static addEventListeners(t){t.addEventListener("input",e.handleJsonInput),t.addEventListener("blur",e.validateAndUpdateJson),t.addEventListener("keydown",e.validateAndUpdateJson)}static removeEventListeners(t){t.removeEventListener("input",e.handleJsonInput),t.removeEventListener("blur",e.validateAndUpdateJson),t.removeEventListener("keydown",e.validateAndUpdateJson)}static handleJsonInput(e){const t=e.target,n=t.textContent||"",a=Ds.getEditorId(t);if(a)try{const e=JSON.parse(n);if("object"==typeof e&&null!==e){e.blocks&&Array.isArray(e.blocks)||(e.blocks=[]);const t=C.getState().getInstance(a);if(t){const n=document.querySelector(`#${t.contentId} .${l.classNames.editor.jsonOutput}`);n&&(n.classList.remove(l.classNames.editor.jsonError),t.config.allowJsonViewEditing&&n.classList.add("clepit-json-editable"));const o=t.currentView;C.getState().setData(a,e),"json"===o&&C.getState().setCurrentView(a,"json"),console.log("Store updated successfully")}}}catch{const e=C.getState().getInstance(a);if(e){const t=document.querySelector(`#${e.contentId} .${l.classNames.editor.jsonOutput}`);t&&(t.classList.add("clepit-json-error"),t.classList.remove("clepit-json-editable"))}}}static validateAndUpdateJson(t){const n=t.target,a=n.textContent||"",o=Ds.getEditorId(n);if(!o)return;const i=C.getState().getInstance(o);if(i)try{const t=JSON.parse(a);if("object"==typeof t&&null!==t){t.blocks&&Array.isArray(t.blocks)||(t.blocks=[]),Bs.hide(o),Ur.hide(o);const e=i.currentView;C.getState().setData(o,t),"json"===e&&C.getState().setCurrentView(o,"json");const n=document.querySelector(`#${i.contentId} .${l.classNames.editor.jsonOutput}`);n&&(n.classList.remove("clepit-json-error"),i.config.allowJsonViewEditing?n.classList.add("clepit-json-editable"):n.classList.remove("clepit-json-editable")),i.config.onChange&&i.config.onChange(t)}else e.markInvalid(i.contentId)}catch{e.markInvalid(i.contentId)}}static markInvalid(e){const t=document.querySelector(`#${e} .${l.classNames.editor.jsonOutput}`);t&&(t.classList.add("clepit-json-error"),t.classList.remove("clepit-json-editable"))}static destroy(t){const n=C.getState().getInstance(t);if(!n)return;const a=document.querySelector(`#${n.contentId} .${l.classNames.editor.jsonOutput}`);a&&e.removeEventListeners(a)}},Rs=class extends Error{constructor(e,t){super(t),this.code=e,this.name="ClepitError"}},Fs=/* @__PURE__ */new Set(["alert.html","audio.alt","audio.caption","checklist.items","header.html","image.alt","image.caption","list.items","paragraph.html","quote.html","table.caption","table.data","video.alt","video.caption"]),Vs=(e,t)=>Fs.has(`${e}.${t}`),Us=/* @__PURE__ */new Set(["checklist.items","list.items","table.data"]),Ws=(e,t)=>Us.has(`${e}.${t}`),Ks=(e,t,n,a)=>{if(!Array.isArray(t))return t;let o=!1;const i=e=>{const t=((e,t,n)=>{const a=Ys(e,t,n);return null===a?e:a.value})(e,n,a);return t!==e&&(o=!0),t},r=t.map(t=>{if("table"===e)return Array.isArray(t)?t.map(i):t;if("checklist"===e){if("object"!=typeof t||null===t)return t;const e=t,n=i(e.text);return n===e.text?t:{...e,text:n}}return i(t)});return o?r:t},Gs=(e,t,n,a)=>{let o=!1;const i={};for(const[r,s]of Object.entries(t)){if(Ws(e,r)){const t=Ks(e,s,n,a);i[r]=t,t!==s&&(o=!0);continue}if(!Vs(e,r)){i[r]=s;continue}const t=Ys(s,n,a);null!==t?(i[r]=t.value,t.value!==s&&(o=!0)):i[r]=s}return o?i:t},Js=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Xs=(e,t)=>Js(e)?Object.keys(e).sort():[t],Ys=(e,t,n)=>{if(void 0===e)return null;if(!Js(e))return{isFallback:t!==n,locale:n,value:e};const a=e[t];if(void 0!==a)return{isFallback:!1,locale:t,value:a};const o=e[n];if(void 0!==o)return{isFallback:!0,locale:n,value:o};const i=Object.keys(e).sort()[0];return void 0===i?null:{isFallback:!0,locale:i,value:e[i]}},Zs=(e,t,n,a)=>void 0===e?t===a?n:{[t]:n}:Js(e)?{...e,[t]:n}:t===a?n:{[a]:e,[t]:n},Qs=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),el=e=>"string"==typeof e?e:"",tl=(e,t,n,a)=>{const o=Ys(e,n,a);return null!==o&&o.value===t?e:Zs(e,n,t,a)},nl=(e,t,n)=>"table"===e?Array.isArray(t)?t.map(e=>el(n(e))).join("\0"):"":"checklist"===e?Qs(t)?el(n(t.text)):"":el(n(t)),al=(e,t,n,a,o)=>{if(!Array.isArray(n))return n;const i=Array.isArray(t)?t:[],r=e=>Ys(e,a,o)?.value,s=((e,t)=>{const n=Array.from({length:e.length+1},()=>new Array(t.length+1).fill(0));for(let c=e.length-1;c>=0;c--)for(let a=t.length-1;a>=0;a--)n[c][a]=e[c]===t[a]?n[c+1][a+1]+1:Math.max(n[c+1][a],n[c][a+1]);const a=new Array(t.length).fill(null);let o=[],i=[];const r=()=>{i.forEach((e,t)=>{a[e]=t<o.length?o[t]:null}),o=[],i=[]};let s=0,l=0;for(;s<e.length&&l<t.length;)e[s]===t[l]?(r(),a[l]=s,s++,l++):n[s+1][l]>=n[s][l+1]?o.push(s++):i.push(l++);for(;s<e.length;)o.push(s++);for(;l<t.length;)i.push(l++);return r(),a})(i.map(t=>nl(e,t,r)),n.map(t=>nl(e,t,e=>e)));return n.map((t,n)=>{const r=s[n];return((e,t,n,a,o)=>{if("table"===e){if(!Array.isArray(n))return n;const e=Array.isArray(t)?t:[];return n.map((t,n)=>tl(e[n],t,a,o))}return"checklist"===e?Qs(n)?{...n,text:tl(Qs(t)?t.text:void 0,n.text,a,o)}:n:tl(t,n,a,o)})(e,null===r?void 0:i[r],t,a,o)})},ol=(e,t,n,a,o)=>{const i={};for(const[r,s]of Object.entries(n))Ws(e,r)?i[r]=al(e,t?.[r],s,a,o):Vs(e,r)?i[r]=tl(t?.[r],s,a,o):i[r]=s;for(const[r,s]of Object.entries(t??{}))r in n||!Vs(e,r)||Ws(e,r)||Xs(s,o).some(e=>e!==a)&&(i[r]=Zs(s,a,"",o));return i},il=(e,t)=>{if(Qs(e))for(const n of Object.keys(e))t.add(n)},rl=e=>{const t=/* @__PURE__ */new Set;for(const n of e)if(Qs(n.data))for(const[e,a]of Object.entries(n.data))if(Ws(n.type,e)&&Array.isArray(a))for(const o of a)if("table"===n.type){if(Array.isArray(o))for(const e of o)il(e,t)}else"checklist"===n.type?Qs(o)&&il(o.text,t):il(o,t);else Vs(n.type,e)&&il(a,t);return[...t].sort()[0]},sl="clepit-theme-styles",ll=".clepit-editor, .clepit-renderer-content, body[data-clepit-theme]",cl=`@layer clepit.reset, clepit.tokens, clepit.blocks, clepit.overrides;\n\n${Vr=i,Object.keys(r).map(e=>`@property ${r[e]} {\n syntax: '<color>';\n inherits: true;\n initial-value: ${Vr[e]};\n}`).join("\n\n")}\n\n@property --clepit-radius-md {\n syntax: '<length>';\n inherits: true;\n initial-value: 8px;\n}\n\n@property --clepit-radius-lg {\n syntax: '<length>';\n inherits: true;\n initial-value: 12px;\n}\n\n@layer clepit.tokens {\n${s(i,{bg:"#161b22",blockHighlightBg:"rgba(0, 0, 0, 0.25)",border:"rgba(240, 246, 252, 0.1)",borderSubtle:"rgba(240, 246, 252, 0.06)",codeBg:"#1e242c",codeBorder:"rgba(240, 246, 252, 0.10)",codeComment:"rgba(240, 246, 252, 0.42)",codeFunction:"#d2a8ff",codeGutter:"rgba(240, 246, 252, 0.42)",codeKeyword:"#ff7b72",codeNumber:"#79c0ff",codePunctuation:"#c9d1d9",codeSelectionBg:"rgba(120, 129, 255, 0.18)",codeString:"#a5d6ff",codeText:"rgba(240, 246, 252, 0.92)",codeType:"#ffa657",dangerBg:"rgba(248, 113, 113, 0.12)",error:"#f87171",errorBg:"rgba(248, 113, 113, 0.12)",focusRing:"#7881ff",hoverBg:"rgba(120, 129, 255, 0.08)",info:"#60a5fa",infoBg:"rgba(96, 165, 250, 0.12)",inverseSurface:"#ffffff",inverseText:"rgba(0, 0, 0, 0.87)",marker:"rgba(255, 224, 71, 0.28)",menuBg:"#1c222a",onPrimary:"#000000",pressedBg:"rgba(120, 129, 255, 0.12)",primary:"#7881ff",primaryBg:"rgba(120, 129, 255, 0.14)",primaryHover:"#8896ff",selectionBg:"rgba(120, 129, 255, 0.18)",success:"#4ade80",successBg:"rgba(74, 222, 128, 0.12)",surface:"#1c222a",surface2:"#222a33",text:"rgba(240, 246, 252, 0.92)",textMuted:"rgba(240, 246, 252, 0.62)",textSubtle:"rgba(240, 246, 252, 0.42)",warning:"#fbbf24",warningBg:"rgba(251, 191, 36, 0.12)"},ll)}\n\n${ll} {\n color-scheme: light;\n}\n\n${ll} {\n --clepit-menu-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);\n}\n\n.clepit-editor[data-clepit-theme='auto'], .clepit-renderer-content[data-clepit-theme='auto'], body[data-clepit-theme='auto'] {\n color-scheme: light dark;\n}\n\n.clepit-editor[data-clepit-theme='dark'], .clepit-renderer-content[data-clepit-theme='dark'], body[data-clepit-theme='dark'] {\n color-scheme: dark;\n}\n\n.clepit-editor[data-clepit-theme='light'], .clepit-renderer-content[data-clepit-theme='light'], body[data-clepit-theme='light'] {\n color-scheme: light;\n}\n}\n\n@layer clepit.blocks {\n[data-clepit-block-id]:target {\n background: var(--clepit-block-highlight-bg);\n border-radius: 6px;\n scroll-margin-top: 24px;\n}\n}\n`,dl=class e{static render(t){const n=document.getElementById(t.containerId);if(!n)throw new Rs("CONTAINER_MISSING",`Container element with ID '${t.containerId}' not found`);return l.injectStyles(sl,cl),l.injectStyles(ns,as),l.injectStyles(Ee,Le),n.classList.add(l.classNames.renderer.content),l.registerEditor(t.containerId,t.theme??"auto",t.themeOverrides),n.innerHTML="",Re.applyParts(n,t.issueChip),t.data?.blocks&&Array.isArray(t.data.blocks)?(t.data.blocks.forEach((a,o)=>{const i=e.renderBlock(e.localize(a,t),o,t);i&&n.appendChild(i)}),t.issues&&Re.refreshAll(n,t.issues,t.issueLabels),n):n}static localize(e,t){if(!t.locale)return e;const n=Gs(e.type,e.data,t.locale,t.defaultLocale??t.locale);return n===e.data?e:{...e,data:n}}static renderBlock(e,t,n){const a=p("div",l.classNames.block.output);a.setAttribute("data-block-type",e.type),a.setAttribute("data-block-index",t.toString()),e.tunes&&Object.entries(e.tunes).forEach(([e,t])=>{a.setAttribute(`data-tune-${e}`,String(t))});const o=n.styles?.[e.type],i=n.classNames?.[e.type];let r,s,c,d=n.configs?.[e.type];if("paragraph"===e.type&&n.editorClassNames?.tooltips&&(d={...d,tooltipClassNames:n.editorClassNames.tooltips}),d?.margins&&(r=d.margins.top,s=d.margins.bottom),void 0===r&&void 0!==n.margins?.top&&(r=n.margins.top),void 0===s&&void 0!==n.margins?.bottom&&(s=n.margins.bottom),void 0!==r){const e=parseFloat(a.style.marginTop||"0")||0;a.style.marginTop=`${e+r}px`}if(void 0!==s){const e=parseFloat(a.style.marginBottom||"0")||0;a.style.marginBottom=`${e+s}px`}switch(e.type){case"alert":c=Nt.render(e.data,d,o,i);break;case"audio":c=Dt.render(e.data,d,o,i);break;case"code":c=Se.render(e.data,d,o,i);break;case"collapsible":c=Ii.render(e.data,d,o,i);break;case"columns":c=nn.render(e.data,d,o,i);break;case"date":c=cn.render(e.data,d,o,i);break;case"delimiter":c=un.render(e.data,d,o,i);break;case"collection":c=Zt.render(e.data,d,o,i);break;case"updates":c=Ai.render(e.data,d,o,i);break;case"glance":c=An.render(e.data,d,o,i);break;case"embed":c=rt.render(e.data,{...d,issueLabels:n.issueLabels,issues:n.issues},o,i);break;case"sketch":c=Ba.render(e.data,d,o,i);break;case"latex":c=yi.render(e.data,d,o,i);break;case"mermaid":c=xi.render(e.data,d,o,i);break;case"openapi":c=ga.render(e.data,d,o,i);break;case"doc_card":c=bn.render(e.data,d,o,i);break;case"file":c=kn.render(e.data,d,o,i);break;case"header":c=Ln.render(e.data,d,o,i);break;case"image":c=In.render(e.data,d,o,i);break;case"list":c=Hn.render(e.data,d,o,i);break;case"checklist":c=Pt.render(e.data,d,o,i);break;case"paragraph":c=va.render(e.data,d,o,i);break;case"quote":c=wa.render(e.data,d,o,i);break;case"table":c=Ja.render(e.data,d,o,i);break;case"toc":c=eo.render(e.data,{...d,documentBlocks:n.data?.blocks??[]},o,i);break;case"issues":c=Dn.render(e.data,{...d,documentBlocks:n.data?.blocks??[],issueLabels:n.issueLabels,issues:n.issues},o,i);break;case"video":c=Ni.render(e.data,d,o,i);break;default:c=null}return c?(a.appendChild(c),gs.initializeElements(a,{classNames:n.classNames?.tooltip,styles:n.styles?.tooltip}),a):null}},pl=class{static render(e){const t=C.getState().getInstance(e);t&&dl.render({classNames:t.config.classNames?.blocks,containerId:t.contentId,data:t.data,editorClassNames:t.config.classNames,margins:t.config.margins,styles:t.config.styles?.blocks})}},ul=class e{static{this.sources={}}static create(t){return e.teardown(t.containerId),e.initialize(t),zs.create(t.containerId),e.render(t.containerId),qs.addListeners(t.containerId),Hs.start(t.containerId),C.getState().setIsReady(t.containerId,!0),C.subscribe(e=>e.instances,(n,a)=>{const o=n[t.containerId];if(!o)return;const i=a[t.containerId];i&&o.currentView!==i.currentView&&e.render(t.containerId)}),{blocks:{convert:(e,n)=>Ds.convertBlock(e,n,t.containerId),count:()=>Ds.getBlocks(t.containerId).length,get:n=>Ds.getBlock(n)?e.delocalizeBlock(t.containerId,Ds.getBlockData(n)):null,getAll:()=>Ds.getBlocks(t.containerId).map(n=>e.delocalizeBlock(t.containerId,Ds.getBlockData(n.getAttribute("data-id")))),insert:(n,a,o,i)=>Ds.insertBlock(e.localizeArriving(t.containerId,{data:a,id:i??Math.random().toString(36).substring(2,11),type:n}),t.containerId,o),move:(e,n)=>Ds.moveBlock(t.containerId,e,n),remove:e=>Ds.removeBlock(t.containerId,e),update:(n,a)=>{const o=Ds.getBlock(n)?.getAttribute("data-tool")??"paragraph";Ds.updateBlockData(n,e.localizeArriving(t.containerId,{data:a,id:n,type:o}).data,t.containerId)}},blur:()=>{const e=document.activeElement;e&&document.getElementById(t.containerId)?.contains(e)&&e.blur()},data:{clear:()=>{C.getState().clearData(t.containerId),Ds.destroy(t.containerId)},clearContent:()=>Ds.destroy(t.containerId),clearStorage:()=>C.getState().clearData(t.containerId),extract:()=>e.delocalizeData(t.containerId,Ds.extractData(t.containerId)),set:n=>Ds.setBlocks(n.blocks.map(n=>e.localizeArriving(t.containerId,n)),t.containerId)},destroy:()=>e.destroy(t.containerId),focus:()=>{const e=Ds.getBlocks(t.containerId)[0];e&&Ds.focusBlock(e)},selection:{clear:()=>window.getSelection()?.removeAllRanges(),get:()=>window.getSelection(),set:e=>{const t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e.getRangeAt(0)))}},ui:{hideBlockMenu:()=>Ur.hide(t.containerId),hideToolbar:()=>Bs.hide(t.containerId),showBlockMenu:e=>Ur.show(t.containerId,e),showToolbar:(e,n)=>Bs.show(t.containerId,e,n)},view:{getCurrentView:e=>C.getState().getCurrentView(e),switchView:(e,t)=>C.getState().setCurrentView(e,t)}}}static initialize(t){console.info("Editor::initialize: Creating editor instance for containerId:",t.containerId);const n=document.getElementById(t.containerId);if(!n)throw`Unable to find container with ID ${t.containerId}`;l.injectStyles(sl,cl),l.injectStyles("clepit-editor-container-styles",js),l.injectStyles(Jr,Xr),l.injectStyles(us,hs),l.injectStyles(Qr,es),l.injectStyles(Ee,Le);const a=t.defaultLocale??t.locale??rl(t.initialData?.blocks??[]),o=t.onChange,i={allowJsonViewEditing:!1,initialView:"edit",maxHeight:0,minHeight:300,placeholder:"Start writing...",...t,defaultLocale:a,locale:t.locale??a,onChange:o&&(n=>o(e.delocalizeData(t.containerId,n)))};n.className=l.classNames.editor.container,n.setAttribute("contenteditable","false"),Re.applyParts(n,i.issueChip),l.registerEditor(t.containerId,i.theme??"auto",i.themeOverrides),i.minHeight&&n.style.setProperty("--clepit-min-height",`${i.minHeight}px`),i.maxHeight&&n.style.setProperty("--clepit-max-height",`${i.maxHeight}px`),l.applyStyles(n,i.styles?.container),l.applyClassNames(n,i.classNames?.container),i.margins&&(void 0!==i.margins.top&&n.style.setProperty("--block-margin-top",`${i.margins.top}px`),void 0!==i.margins.bottom&&n.style.setProperty("--block-margin-bottom",`${i.margins.bottom}px`));const r=`${i.containerId}-${l.idSuffixes.editorContent}`,s=p("div",l.classNames.editor.content);s.id=r,s.setAttribute("data-testid","editor-content-container"),s.setAttribute("data-container-id",t.containerId),l.applyStyles(s,i.styles?.editorContent),l.applyClassNames(s,i.classNames?.editorContent),n.appendChild(s),C.getState().addInstance(t.containerId,{config:i,contentId:r,currentView:i.initialView||"edit",data:e.localizeData(t.containerId,i.initialData,i),isReady:!1})}static localizeData(t,n,a){const o=n||{blocks:[],time:Date.now(),version:"1.0.0"};return a.locale?{...o,blocks:o.blocks.map(n=>e.localizeBlock(t,n,a))}:o}static localizeBlock(t,n,a){const o=a.locale;if(!o)return n;const i=a.defaultLocale??o;n.id&&(e.sources[t]={...e.sources[t],[n.id]:n});const r=n.data;let s=null;for(const e of(e=>Array.from(Fs).filter(t=>t.startsWith(`${e}.`)).map(t=>t.slice(e.length+1)).sort())(n.type)){const t=Ys(r[e],o,i);t?.isFallback&&(s??=t.locale,a.onLocaleFallback?.({blockId:n.id??"",field:e,requested:o,showing:t.locale}))}n.id&&v.note(t,n.id,s);const l=Gs(n.type,r,o,i);return l===r?n:{...n,data:l}}static localizeArriving(t,n){const a=C.getState().getInstance(t)?.config;return a?e.localizeBlock(t,n,a):n}static delocalizeBlock(t,n){const a=C.getState().getInstance(t)?.config,o=a?.locale;if(!o||!n.id)return n;const i=e.sources[t]?.[n.id],r=i?.data,s=void 0===i||void 0===r?void 0:i.type===n.type?r:Object.fromEntries(Object.entries(r).filter(([e])=>Vs(n.type,e)));return{...n,data:ol(n.type,s,n.data,o,a.defaultLocale??o)}}static delocalizeData(t,n){return{...n,blocks:n.blocks.map(n=>e.delocalizeBlock(t,n))}}static render(e){const t=C.getState().getInstance(e);if(!t)return;const n=document.getElementById(t.contentId);n&&(Ps.destroy(e),n.innerHTML=""),"edit"===t.currentView?Os.render(e):"preview"===t.currentView?pl.render(e):"json"===t.currentView&&Ps.render(e),t.config.onReady&&t.config.onReady()}static teardown(t){delete e.sources[t],v.forget(t),Hs.stop(t),Ts.dismiss(t),qs.removeListeners(t),zs.destroy(t),Ur.destroy(t),Bs.destroy(t),Ds.destroy(t),l.unregisterEditor(t);const n=document.getElementById(t);n&&(n.innerHTML="")}static destroy(t){e.teardown(t),C.getState().removeInstance(t)}},hl=e=>e.replace(/["\\]/g,"\\$&"),ml=e=>e.flatMap(e=>"collapsible"===e.type?[e,...ml(e.data.children??[])]:"columns"===e.type?[e,...ml(e.data.columns?.flat()??[])]:[e]),gl=(e,t)=>{const n=[];for(const a of ml(t)){if(!a.id)continue;if("code"!==a.type&&"openapi"!==a.type&&"table"!==a.type)continue;const t=e.querySelector(`[data-clepit-block-id="${hl(a.id)}"]`);if(!t||t.hasAttribute("data-clepit-activated"))continue;t.setAttribute("data-clepit-activated","");const o="code"===a.type?Se.activate(t,a.data):"openapi"===a.type?ga.activate(t):Ja.activate(t,a.data);n.push(()=>{o(),t.removeAttribute("data-clepit-activated")})}return()=>{for(const e of n)e()}},bl=/* @__PURE__ */new Set(["strong","b","em","i","u","s","del","mark","code","a","span"]),fl=/* @__PURE__ */new Set(["href","target","title","contenteditable","data-tooltip","data-status","data-status-variant","data-user-id","data-page-id","data-issue-tool","data-issue-key","data-issue-title","data-issue-state","data-issue-category","data-issue-assignee","data-issue-avatar","data-issue-updated","data-issue-url","data-issue-pull","data-issue-reason","class"]),vl=/* @__PURE__ */new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),yl=e=>" "===e||"\t"===e||"\n"===e||"\r"===e||"\f"===e,xl=e=>void 0!==e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"),kl=(e,t,n)=>{const a=e.indexOf(n,t);return-1===a?e.length:a+n.length},wl=(e,t,n)=>{let a=t,o="";for(;a<e.length&&!yl(e[a])&&"/"!==e[a]&&">"!==e[a];)o+=e[a],a+=1;const i=/* @__PURE__ */new Map;let r=!1;for(;a<e.length;){const t=e[a];if(">"===t){const e=o.toLowerCase();return{end:a+1,token:n?{tag:e,type:"close"}:{attributes:i,selfClosing:r,tag:e,type:"open"}}}if(yl(t)){a+=1;continue}if("/"===t){r=!0,a+=1;continue}r=!1;let s=t;for(a+=1;a<e.length&&!yl(e[a])&&"/"!==e[a]&&">"!==e[a]&&"="!==e[a];)s+=e[a],a+=1;let l=a;for(;yl(e[l]);)l+=1;let c="";if("="===e[l]){for(a=l+1;yl(e[a]);)a+=1;const t=e[a];if('"'===t||"'"===t){const n=e.indexOf(t,a+1);if(-1===n)return{end:e.length,token:null};c=e.slice(a+1,n),a=n+1}else for(;a<e.length&&!yl(e[a])&&">"!==e[a];)c+=e[a],a+=1}const d=s.toLowerCase();i.has(d)||i.set(d,c)}return{end:e.length,token:null}},Cl=(e,t)=>{const n=e[t+1];if(e.startsWith("\x3c!--",t))return">"===e[t+4]?{end:t+5,token:null}:e.startsWith("->",t+4)?{end:t+6,token:null}:{end:kl(e,t+4,"--\x3e"),token:null};if("!"===n||"?"===n)return{end:kl(e,t+2,">"),token:null};if("/"===n){const n=e[t+2];return void 0===n?null:">"===n?{end:t+3,token:null}:xl(n)?wl(e,t+2,!0):{end:kl(e,t+2,">"),token:null}}return xl(n)?wl(e,t+1,!1):null},Al=e=>{if(!e)return"";const t=[],n=[];for(const a of(e=>{const t=[];let n=0;for(let a=e.indexOf("<");-1!==a;a=e.indexOf("<",a)){const o=Cl(e,a);null!==o?(a>n&&t.push({type:"text",value:e.slice(n,a)}),null!==o.token&&t.push(o.token),a=o.end,n=a):a+=1}return n<e.length&&t.push({type:"text",value:e.slice(n)}),t})(e)){if("text"===a.type){t.push(a.value.replace(/</g,"&lt;").replace(/>/g,"&gt;"));continue}if("close"===a.type){if(!bl.has(a.tag))continue;const e=n.lastIndexOf(a.tag);if(-1===e)continue;t.push(`</${a.tag}>`),n.splice(e,1);continue}if(!bl.has(a.tag))continue;const e=[];for(const[t,n]of a.attributes)fl.has(t)&&("href"!==t||c(n))&&e.push(`${t}="${U(n)}"`);"a"===a.tag&&e.push('target="_blank"','rel="noopener noreferrer"'),t.push(`<${[a.tag,...e].join(" ")}>`),a.selfClosing||vl.has(a.tag)||n.push(a.tag)}for(const a of[...n].reverse())t.push(`</${a}>`);return t.join("")},Sl=()=>".clepit-public-page__notice{display:flex;flex-direction:column;gap:4px;margin:0 0 16px;padding:8px 12px;background:color-mix(in oklab, var(--clepit-info) 8%, transparent);border:1px solid color-mix(in oklab, var(--clepit-info) 35%, transparent);border-radius:8px}.clepit-public-page__notice-title{margin:0;font-size:12px;font-weight:600;color:var(--clepit-info)}.clepit-public-page__notice-body{margin:0;font-size:12px;line-height:1.55;color:var(--clepit-text-muted)}",El=e=>`<aside class="clepit-public-page__notice" data-testid="public-page-notice" role="note"><p class="clepit-public-page__notice-title">${V(e.title)}</p><p class="clepit-public-page__notice-body">${V(e.body)}</p></aside>`,Ll=e=>[e.description?`<meta name="description" content="${U(e.description)}">`:"",e.canonicalUrl?`<link rel="canonical" href="${U(e.canonicalUrl)}">`:"",...(e.alternates??[]).map(e=>`<link rel="alternate" hreflang="${U(e.hreflang)}" href="${U(e.href)}">`),`<meta property="og:title" content="${U(e.title)}">`,e.description?`<meta property="og:description" content="${U(e.description)}">`:""].join(""),Nl=()=>[cl,Et,_t,Ht,te,de(),Wt,Yt,tn,rn,dn,gn,O,yn,wn,Sn,Bn,Le,zn,On,ba,xa,Sa,$a,Za,ao,Ci,Ei].join("\n"),Bl=(e,t)=>{const n=t?.defaultLocale??t?.locale??rl(e),a=t?.locale??n,o=void 0===a?e:e.map(e=>{const t=Gs(e.type,e.data,a,n??a);return t===e.data?e:{...e,data:t}}),i=K(Al),r={...t,documentBlocks:t?.documentBlocks??o},s=o.map(e=>Bi(e,i,r)).filter(e=>null!==e).map(e=>G(e)).join("\n");return Ke(s,t?.issues,t?.issueChip,t?.issueLabels,Al)},Ml=(e,t)=>{const n=V(e.title),a=['<meta charset="utf-8">','<meta name="viewport" content="width=device-width, initial-scale=1">',e.scheme?`<meta name="color-scheme" content="${U(e.scheme)}">`:"",`<title>${n}</title>`,Ll(e),`<style>${Nl()}</style>`,e.notice?"<style>.clepit-public-page__notice{display:flex;flex-direction:column;gap:4px;margin:0 0 16px;padding:8px 12px;background:color-mix(in oklab, var(--clepit-info) 8%, transparent);border:1px solid color-mix(in oklab, var(--clepit-info) 35%, transparent);border-radius:8px}.clepit-public-page__notice-title{margin:0;font-size:12px;font-weight:600;color:var(--clepit-info)}.clepit-public-page__notice-body{margin:0;font-size:12px;line-height:1.55;color:var(--clepit-text-muted)}</style>":""].filter(Boolean);return["<!doctype html>",`<html lang="${U(e.locale??"en")}">`,`<head>${a.join("")}</head>`,e.scheme?`<body data-clepit-theme="${U(e.scheme)}">`:"<body>",'<main class="clepit-public-page">',`<h1 class="clepit-public-page__title">${n}</h1>`,...e.notice?[El(e.notice)]:[],Bl(e.blocks,{...t,anchorTargets:!0}),"</main>","</body>","</html>"].join("\n")},$l={am:[[4608,4991]],ar:[[1536,1791]],bn:[[2432,2559]],hi:[[2304,2431]],ja:[[12352,12543]],ko:[[4352,4607],[44032,55215]],ru:[[1024,1279]],zh:[[19968,40959]]},Il={de:["auch","auf","das","dem","den","der","die","ein","eine","für","ich","ist","mit","nicht","sich","sie","und","von","wir","zu"],en:["and","are","as","be","for","have","in","is","it","not","of","on","that","the","this","to","was","with","you"],es:["con","como","del","el","en","es","la","las","lo","los","no","para","por","que","se","su","un","una","y"],et:["aga","ei","et","ja","ka","kes","kui","mis","ning","nii","oli","oma","on","see","seda","siis","tema","ole","välja"],fil:["ako","ang","at","ay","hindi","ito","ka","kung","lang","may","mga","na","ng","ni","nila","para","sa","si","siya"],fr:["au","avec","ce","dans","des","du","est","et","le","les","pas","pour","qui","sur","une","nous","vous","sont","elle"],id:["ada","akan","atau","bisa","dalam","dan","dari","dengan","di","ini","itu","juga","kami","ke","pada","saya","tidak","untuk","yang"],pt:["com","da","do","em","isso","mais","não","no","os","para","pela","por","que","se","um","uma","é","está","são"],sw:["cha","hii","hiyo","ili","kama","katika","kuwa","kwa","lakini","mimi","na","ni","sana","wa","wako","ya","yake","za","la"],vi:["các","cho","có","cũng","của","khi","không","là","một","người","như","những","này","trong","và","với","được","đã","để"]},Tl=/\p{L}/u,_l=(e,t)=>t.some(([t,n])=>e>=t&&e<=n),ql=e=>{const t=(e=>e.replace(/`[^`]*`/g," ").replace(/https?:\/\/\S+/g," ").replace(/@\S+/g," "))(e);return(e=>{const t={};let n=0;for(const s of e){if(!Tl.test(s))continue;n+=1;const e=s.codePointAt(0)??0,a=Object.keys($l).find(t=>_l(e,$l[t]??[]));void 0!==a&&(t[a]=(t[a]??0)+1)}const a=t.ja??0,o=t.zh??0;a>0&&(t.ja=a+o,delete t.zh);const[i,r]=Object.entries(t).sort((e,t)=>t[1]-e[1])[0]??[null,0];return null!==i&&r>=8&&2*r>=n?i:null})(t)??(e=>{const t=e.toLowerCase().match(/[\p{L}']+/gu)??[];if(t.length<8)return null;const n=e=>100*e/t.length,[a,o]=[...Object.entries(Il).map(([e,a])=>{const o=new Set(a),i=t.filter(e=>o.has(e)).length,r="vi"===e?t.filter(e=>[...e].some(e=>"ăâđêôơưạảãấầẩẫậắằẳẵặẹẻẽếềểễệỉĩịỏọốồổỗộớờởỡợủũụứừửữựỳỷỹỵ".includes(e))).length:0;return[e,n(i+r)]})].sort((e,t)=>t[1]-e[1]);return void 0===a||0===a[1]?null:a[1]-(o?.[1]??0)>5?a[0]:null})(t)};export{Br as BLOCK_TOOLS,Tr as CONTROL_LABELS,Rs as ClepitError,_r as DIALOG_LABELS,Xe as EMBED_ENGLISH,Ir as EMBED_LABELS,Ye as EMBED_TOOL_NAMES,M as EMBED_WIRE_KEYS,ul as Editor,Dr as INLINE_REWRITE_ACTIONS,qr as INLINE_TOOLBAR_LABELS,Nr as INLINE_TOOLS,Ne as ISSUE_ENGLISH,$r as ISSUE_LABELS,Mr as ISSUE_TOOLS,Be as ISSUE_TOOL_NAMES,Re as IssueChip,dl as Renderer,l as StyleManager,Mn as UploadRefusal,gl as activateBlocks,We as chipsInHtml,pt as classifyIssueUrl,ql as detectLanguage,R as domBacking,Bi as drawBlock,Ze as embedLabel,$ as isEmbedProviderDisabled,$e as issueLabel,Ie as issueToolName,Sl as noticeStylesheet,Ll as pageMetadata,Nl as pageStylesheet,sa as parseOpenApi,Ue as readChipMarkup,Ke as refreshChipsInHtml,Bl as renderBlocks,El as renderNotice,Ml as renderPage,G as renderToString,q as resolveEmbed,Al as sanitizeHtmlWithoutDom,K as stringBacking,J as toDomElement,s as tokensToLightDarkBlock};
2
2
  //# sourceMappingURL=index.mjs.map