@zuilib/text-editor 0.11.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +174 -18
- package/DRAWING_FORMAT.md +23 -21
- package/README.md +485 -67
- package/dist/chunk-32RX4GZF.js +2 -0
- package/dist/chunk-3TZVOXWX.js +16 -0
- package/dist/chunk-5VRVC56Y.js +2 -0
- package/dist/chunk-7Z3CW6Q3.js +2 -0
- package/dist/chunk-A7MCBSAZ.js +2 -0
- package/dist/chunk-AGTPMKLK.js +2 -0
- package/dist/chunk-C7VEINKX.js +2 -0
- package/dist/chunk-LDVPFZCN.js +2 -0
- package/dist/chunk-N5JWZ2VW.js +9 -0
- package/dist/chunk-QKHMJQO3.js +2 -0
- package/dist/chunk-R5PL4Q7X.js +5 -0
- package/dist/chunk-SDICQI2B.js +2 -0
- package/dist/chunk-TGVEPLDM.js +1 -0
- package/dist/chunk-XP3MZRCW.js +2 -0
- package/dist/chunk-XRJNLGI4.js +2 -0
- package/dist/chunk-YFFSTMIR.js +2 -0
- package/dist/chunk-ZXZMYJ7F.js +2 -0
- package/dist/comment-markers-BrrrAdSL.d.ts +27 -0
- package/dist/comments.d.ts +68 -0
- package/dist/comments.js +2 -0
- package/dist/drawing-data-EWzEQ1_i.d.ts +111 -0
- package/dist/drawing-preset-Ag7a7F9h.d.ts +69 -0
- package/dist/drawing.d.ts +7 -0
- package/dist/drawing.js +2 -0
- package/dist/image-node-kR1Zf5kz.d.ts +70 -0
- package/dist/images.d.ts +66 -0
- package/dist/images.js +2 -0
- package/dist/index-A4S7bRwQ.d.ts +425 -0
- package/dist/index.d.ts +36 -1394
- package/dist/index.js +1 -7449
- package/dist/lexical.d.ts +117 -0
- package/dist/lexical.js +2 -0
- package/dist/markdown.d.ts +29 -0
- package/dist/markdown.js +2 -0
- package/dist/mention-node-eSsjUpaE.d.ts +44 -0
- package/dist/mentions-plugin-gio3_XKd.d.ts +74 -0
- package/dist/mentions.d.ts +5 -0
- package/dist/mentions.js +2 -0
- package/dist/mermaid-BwGHjwpk.d.ts +553 -0
- package/dist/paste.d.ts +45 -0
- package/dist/paste.js +2 -0
- package/dist/presets-BtNPH0pa.d.ts +78 -0
- package/dist/styles.css +402 -95
- package/dist/table-grid-D70tNhp2.d.ts +459 -0
- package/package.json +52 -7
- package/dist/index.css +0 -79
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var e={$schema:"http://json-schema.org/draft-07/schema#",title:"DrawingData",description:"Vector drawing embedded in markdown as a ```drawing fenced code block (format version 3)",type:"object",required:["version","canvasHeight","shapes"],additionalProperties:!1,properties:{version:{const:3,description:"Format version; always 3"},canvasHeight:{type:"number",minimum:80,description:"Canvas height in pixels. Make it large enough to contain every shape plus ~20px margin."},canvasWidth:{type:"number",minimum:120,description:"Optional logical canvas width in pixels. When set, the drawing is scaled down to fit narrower layouts (SVG viewBox) so coordinates can assume this width. When omitted the canvas is fluid and coordinates are CSS pixels."},width:{enum:["full","text","content"],description:`Block width: "full" (default, omit it) spans the editor; "text" aligns the block with the text column (same as "full" unless the app sets a text measure); "content" fits the shapes' horizontal extent and left-aligns with the text`},title:{type:"string",description:"Optional accessible name of the drawing, read by screen readers in place of the shapes"},description:{type:"string",description:"Optional longer accessible description of what the drawing shows"},shapes:{type:"array",items:{$ref:"#/definitions/shape"},maxItems:5e3,description:"Render order: later shapes draw on top"}},definitions:{point:{type:"object",required:["x","y"],additionalProperties:!1,properties:{x:{type:"number",description:"Absolute canvas x"},y:{type:"number",description:"Absolute canvas y"}}},binding:{type:"object",description:"Where a connector endpoint attaches to a box. Omit fixedPoint to let the endpoint auto-aim from the box center at the other end.",required:["id"],additionalProperties:!1,properties:{id:{type:"string",description:"Id of the box this endpoint is attached to"},fixedPoint:{type:"array",items:{type:"number",minimum:0,maximum:1},minItems:2,maxItems:2,description:"Attach point as a ratio of the box's bounding box: [0,0] top-left, [1,1] bottom-right, [0.5,0] top edge midpoint, [1,0.5] right edge midpoint. Omitted: the endpoint auto-aims from the box center at the other end."},mode:{enum:["orbit","inside"],description:'"orbit" (default): the endpoint is projected onto the box outline with a 6px gap. "inside": the endpoint sits exactly on the fixed point.'}}},shape:{type:"object",required:["id","type","x","y","width","height","stroke","fill","strokeWidth"],additionalProperties:!1,properties:{id:{type:"string",description:"Unique within the drawing; connector bindings reference it"},type:{enum:["rect","ellipse","diamond","note","cylinder","cloud","queue","actor","arrow","line","text"],description:"Boxes (cards with label/text/footer slots): rect, ellipse, diamond, note (sticky note with a folded corner), cylinder (database), cloud, queue (horizontal cylinder), actor (stick figure; only the text slot, rendered as a name under the figure). Connectors: arrow (head at the end), line. Free-floating annotation: text."},x:{type:"number",description:"Boxes/text: left edge of the bounding box. Connectors: start point x."},y:{type:"number",description:"Boxes/text: top edge of the bounding box. Connectors: start point y."},width:{type:"number",description:"Boxes/text: width (non-negative). Connectors: delta x to the end point (may be negative)."},height:{type:"number",description:"Boxes/text: height (non-negative). Connectors: delta y to the end point (may be negative)."},stroke:{type:"string",description:"CSS color of the outline (and of any text). Palette: #1e1e1e (default), #e03131 red, #2f9e44 green, #1971c2 blue, #f08c00 orange, #7048e8 purple."},fill:{type:"string",description:'CSS color of the interior; "transparent" for none. Palette: #ffc9c9 red, #b2f2bb green, #a5d8ff blue, #ffec99 yellow, #d0bfff purple.'},strokeWidth:{type:"number",description:"Outline width; use 2"},text:{type:"string",description:"Standalone text content; center content of a box (the name under an actor); midpoint label of a connector"},label:{type:"string",description:"Boxes only (not actor): small bold heading at the top"},footer:{type:"string",description:"Boxes only (not actor): small dim line at the bottom"},startBinding:{$ref:"#/definitions/binding",description:"Connectors only: box the start point attaches to. The editor re-anchors the endpoint onto that box and keeps it attached as the box moves."},endBinding:{$ref:"#/definitions/binding",description:"Connectors only: box the end point attaches to"},bidirectional:{type:"boolean",description:"Arrows only: arrowheads on both ends"},routing:{const:"elbow",description:"Connectors only: right-angled auto-routed path. It leaves the box perpendicular to the attach side, avoids every box on the canvas and minimises bends. Ignored when waypoints are present."},elbow:{type:"number",minimum:0,maximum:1,description:"Elbow override: position of the middle segment as a fraction of the span. Applied only when the routed path is a simple three-segment Z."},waypoints:{type:"array",items:{$ref:"#/definitions/point"},description:"Connectors only: intermediate path points in canvas coordinates, ordered start to end. Takes precedence over routing."}}}}};export{e as a};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{k as $e,o as Bn,p as $n,t as zn,u as Hn,w as ae}from"./chunk-N5JWZ2VW.js";import{a as An,e as K,r as Le,s as Ln,t as ze,u as Wn}from"./chunk-LDVPFZCN.js";var de=["rect","ellipse","diamond","note","cylinder","cloud","queue","actor"],ue=["arrow","line"],pi=[...de,...ue,"text"];function A(t){return de.includes(t)}function T(t){return ue.includes(t)}var Un=320,fi=80,He=5e3,Fn=1e5,hi=2e3,xi=/^(#[0-9a-f]{3,8}|(rgba?|hsla?|oklch|oklab)\([\w.,%\s/+-]*\)|[a-z]+)$/i;function Gn(t){return typeof t=="string"&&t.length<=64&&xi.test(t)}var I=15,z=11,et=1.35,nt={version:3,canvasHeight:Un,shapes:[]},Dt=["#1e1e1e","#e03131","#2f9e44","#1971c2","#f08c00","#7048e8"],Xn=["transparent","#ffc9c9","#b2f2bb","#a5d8ff","#ffec99","#d0bfff"],Kn=0;function Ge(){return Kn+=1,`s${Date.now().toString(36)}${Kn.toString(36)}`}var Ke={top:[.5,0],right:[1,.5],bottom:[.5,1],left:[0,.5]};function Y(t){return JSON.stringify(t)}function ye(t){try{return Ye(JSON.parse(t))}catch{return nt}}var Yn=!1;function gi(t){Yn||(Yn=!0,console.warn(t))}function mi(t){if(!$t(t))return t;let{w:e,h:n,...o}=t;return{...o,width:e,height:n}}function Ye(t,e=gi){if(!$t(t)||t.version!==2&&t.version!==3||!Array.isArray(t.shapes))return nt;let n=t.version===2?t.shapes.map(mi):t.shapes;n.length>He&&(e(`Drawing has ${n.length} shapes; keeping the first ${He}`),n=n.slice(0,He));let o=n.flatMap(s=>{let l=wi(s);return l?[l]:[]}),i=new Set(o.map(s=>s.id)),r=We(t.canvasHeight,NaN),a=We(t.canvasWidth,NaN);return{version:3,canvasHeight:Number.isFinite(r)&&r>=fi?r:Un,...Number.isFinite(a)&&a>=120?{canvasWidth:a}:{},...ae(t.width)?{width:t.width}:{},...se(t.title)?{title:se(t.title)}:{},...se(t.description)?{description:se(t.description)}:{},shapes:o.map(s=>{if(!T(s.type))return s;let l=qn(s.startBinding,i,o),c=qn(s.endBinding,i,o);return l===s.startBinding&&c===s.endBinding?s:{...s,startBinding:l,endBinding:c}})}}function qn(t,e,n){if(!t||!e.has(t.id))return;let o=n.find(i=>i.id===t.id);return o&&A(o.type)?t:void 0}function $t(t){return typeof t=="object"&&t!==null}function We(t,e){return typeof t=="number"&&Number.isFinite(t)?t:e}function le(t){return typeof t=="string"&&t!==""?t:void 0}function se(t){let e=le(t)?.trim();return e?e.slice(0,hi):void 0}function ce(t){return Math.min(Fn,Math.max(-Fn,t))}function Vn(t){if(!$t(t)||typeof t.id!="string"||!t.id)return;let e={id:t.id},n=t.fixedPoint;return Array.isArray(n)&&n.length===2&&typeof n[0]=="number"&&typeof n[1]=="number"&&(e.fixedPoint=[Fe(n[0]),Fe(n[1])]),t.mode==="inside"&&(e.mode="inside"),e}function Fe(t){return Math.min(1,Math.max(0,t))}function wi(t){if(!$t(t))return null;let e=t.type;if(typeof t.id!="string"||!t.id||typeof e!="string"||!pi.includes(e)||typeof t.x!="number"||typeof t.y!="number"||typeof t.width!="number"||typeof t.height!="number"||![t.x,t.y,t.width,t.height].every(Number.isFinite))return null;let n={id:t.id,type:e,x:ce(t.x),y:ce(t.y),width:ce(t.width),height:ce(t.height),stroke:Gn(t.stroke)?t.stroke:Dt[0],fill:Gn(t.fill)?t.fill:"transparent",strokeWidth:Math.min(100,Math.max(0,We(t.strokeWidth,2)))},o=le(t.text);if(o!==void 0&&(n.text=o),A(n.type)){let i=le(t.label),r=le(t.footer);i!==void 0&&(n.label=i),r!==void 0&&(n.footer=r),n.width<0&&(n.x+=n.width,n.width=-n.width),n.height<0&&(n.y+=n.height,n.height=-n.height)}if(T(n.type)){let i=Vn(t.startBinding),r=Vn(t.endBinding);if(i&&(n.startBinding=i),r&&(n.endBinding=r),n.type==="arrow"&&t.bidirectional===!0&&(n.bidirectional=!0),t.routing==="elbow"&&(n.routing="elbow"),typeof t.elbow=="number"&&Number.isFinite(t.elbow)&&(n.elbow=Fe(t.elbow)),Array.isArray(t.waypoints)){let a=t.waypoints.flatMap(s=>$t(s)&&typeof s.x=="number"&&typeof s.y=="number"&&Number.isFinite(s.x)&&Number.isFinite(s.y)?[{x:s.x,y:s.y}]:[]);a.length&&(n.waypoints=a)}}return n}var pe={up:{x:0,y:-1},right:{x:1,y:0},down:{x:0,y:1},left:{x:-1,y:0}};function Zn(t){return t==="up"?"down":t==="down"?"up":t==="left"?"right":"left"}function jn(t){return t==="left"||t==="right"}function qe(t,e){let n=e.x-t.x,o=e.y-t.y;return Math.abs(n)>=Math.abs(o)?n>=0?"right":"left":o>=0?"down":"up"}function k(t){return{x:Math.min(t.x,t.x+t.width),y:Math.min(t.y,t.y+t.height),w:Math.abs(t.width),h:Math.abs(t.height)}}function Jn(t){if(T(t.type)||t.width>=0&&t.height>=0)return t;let e=k(t);return{...t,x:e.x,y:e.y,width:e.w,height:e.h}}function Qn(t){return{x:t.x+t.w/2,y:t.y+t.h/2}}function to(t){return Qn(k(t))}function fe(t,e){return{x:t.x-e,y:t.y-e,w:t.w+e*2,h:t.h+e*2}}function Ve(t,e,n=0){return e.x>=t.x-n&&e.x<=t.x+t.w+n&&e.y>=t.y-n&&e.y<=t.y+t.h+n}function Ue(t,e){return e.x>t.x&&e.x<t.x+t.w&&e.y>t.y&&e.y<t.y+t.h}function eo(t,e){return t.x>=e.x&&t.y>=e.y&&t.x+t.w<=e.x+e.w&&t.y+t.h<=e.y+e.h}function Lt(t){if(!t.length)return{x:0,y:0,w:0,h:0};let e=1/0,n=1/0,o=-1/0,i=-1/0;for(let r of t)e=Math.min(e,r.x),n=Math.min(n,r.y),o=Math.max(o,r.x+r.w),i=Math.max(i,r.y+r.h);return{x:e,y:n,w:o-e,h:i-n}}function kt(t,e){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function ut(t,e=40){let n=Qn(t);return Array.from({length:e},(o,i)=>{let r=i*2*Math.PI/e;return{x:n.x+t.w/2*Math.cos(r),y:n.y+t.h/2*Math.sin(r)}})}function Xe(t){return[{x:t.x,y:t.y},{x:t.x+t.w,y:t.y},{x:t.x+t.w,y:t.y+t.h},{x:t.x,y:t.y+t.h}]}function he(t,e){let n=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){let r=e[o],a=e[i];r.y>t.y!=a.y>t.y&&t.x<(a.x-r.x)*(t.y-r.y)/(a.y-r.y)+r.x&&(n=!n)}return n}function xe(t,e){let n=1/0;for(let o=0;o<e.length;o++)n=Math.min(n,bi(t,e[o],e[(o+1)%e.length]));return n}function bi(t,e,n){let o=n.x-e.x,i=n.y-e.y,r=o*o+i*i,a=r===0?0:Math.max(0,Math.min(1,((t.x-e.x)*o+(t.y-e.y)*i)/r));return Math.hypot(t.x-(e.x+o*a),t.y-(e.y+i*a))}function Ze(t,e,n,o=1e-6){let i=null;for(let r=0;r<n.length;r++){let a=n[r],s=n[(r+1)%n.length],l=s.x-a.x,c=s.y-a.y,u=e.x*c-e.y*l;if(Math.abs(u)<1e-9)continue;let x=a.x-t.x,y=a.y-t.y,m=(x*c-y*l)/u,g=(x*e.y-y*e.x)/u;m>=o&&g>=-1e-9&&g<=1+1e-9&&(i===null||m<i)&&(i=m)}return i}function ot(t,e,n){let o=n*.6,i=Math.max(1,Math.floor(e/o)),r=[];for(let a of t.split(`
|
|
3
|
+
`)){if(a.length<=i){r.push(a);continue}let s="";for(let l of a.split(" ")){for(;l.length>i;)s&&(r.push(s),s=""),r.push(l.slice(0,i)),l=l.slice(i);s?s.length+1+l.length<=i?s+=` ${l}`:(r.push(s),s=l):s=l}r.push(s)}return r}function U(t,e=I){let n=t.split(`
|
|
4
|
+
`),o=n.reduce((i,r)=>Math.max(i,r.length),0);return{w:Math.max(20,o*e*.6),h:n.length*e*et}}var xt=8;function zt(t,e,n=e){return{x:t.x+e,y:t.y+n,w:Math.max(t.w-e*2,20),h:Math.max(t.h-n*2,10)}}function Si(t){let e=(1-Math.SQRT1_2)/2;return zt(t,t.w*e,t.h*e)}var Et=t=>Math.min(18,t.w/4,t.h/4),Tt=t=>Math.min(t.h*.14,18),Rt=t=>Math.min(t.w*.12,18),Ht=.62;function ge(t,e,n,o,i,r,a=12){return Array.from({length:a+1},(s,l)=>{let c=i+(r-i)*l/a;return{x:t+n*Math.cos(c),y:e+o*Math.sin(c)}})}var gt={rect:{type:"rect",label:"Rectangle",defaultSize:{w:160,h:90},textSlots:["label","text","footer"],outline:t=>Xe(k(t)),textArea:t=>zt(k(t),xt)},ellipse:{type:"ellipse",label:"Ellipse",defaultSize:{w:160,h:90},textSlots:["label","text","footer"],outline:t=>ut(k(t)),textArea:t=>zt(Si(k(t)),2)},diamond:{type:"diamond",label:"Diamond",defaultSize:{w:170,h:100},textSlots:["label","text","footer"],outline:t=>{let e=k(t);return[{x:e.x+e.w/2,y:e.y},{x:e.x+e.w,y:e.y+e.h/2},{x:e.x+e.w/2,y:e.y+e.h},{x:e.x,y:e.y+e.h/2}]},textArea:t=>{let e=k(t);return zt(e,e.w/4,e.h/4)}},note:{type:"note",label:"Note",defaultSize:{w:160,h:110},textSlots:["label","text","footer"],defaultFill:"#ffec99",outline:t=>{let e=k(t),n=Et(e);return[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h-n},{x:e.x+e.w-n,y:e.y+e.h},{x:e.x,y:e.y+e.h}]},textArea:t=>{let e=k(t),n=Et(e);return{x:e.x+xt,y:e.y+xt,w:Math.max(e.w-xt*2,20),h:Math.max(e.h-xt*2-n/2,10)}}},cylinder:{type:"cylinder",label:"Database",defaultSize:{w:140,h:110},textSlots:["label","text","footer"],outline:t=>{let e=k(t),n=Tt(e),o=e.x+e.w/2;return[...ge(o,e.y+n,e.w/2,n,Math.PI,2*Math.PI),...ge(o,e.y+e.h-n,e.w/2,n,0,Math.PI)]},textArea:t=>{let e=k(t),n=Tt(e);return{x:e.x+xt,y:e.y+n*2+4,w:Math.max(e.w-xt*2,20),h:Math.max(e.h-n*3-8,10)}}},cloud:{type:"cloud",label:"Cloud",defaultSize:{w:180,h:110},textSlots:["label","text","footer"],outline:t=>ut(k(t)),textArea:t=>{let e=k(t);return zt(e,e.w*.17,e.h*.2)}},queue:{type:"queue",label:"Queue",defaultSize:{w:180,h:80},textSlots:["label","text","footer"],outline:t=>{let e=k(t),n=Rt(e),o=e.y+e.h/2;return[...ge(e.x+e.w-n,o,n,e.h/2,-Math.PI/2,Math.PI/2),...ge(e.x+n,o,n,e.h/2,Math.PI/2,3*Math.PI/2)]},textArea:t=>{let e=k(t),n=Rt(e);return{x:e.x+n+4,y:e.y+6,w:Math.max(e.w-n*3-8,20),h:Math.max(e.h-12,10)}}},actor:{type:"actor",label:"Actor",defaultSize:{w:90,h:120},textSlots:["text"],outline:t=>Xe(k(t)),textArea:t=>{let e=k(t),n=e.y+e.h*Ht;return{x:e.x-20,y:n,w:e.w+40,h:Math.max(e.y+e.h-n,10)}}}};function me(t){return gt[t.type]??null}var ao=6,Mi=10,Pi=.55;function Gt(t){let e=me(t);if(e)return e.outline(t);let n=k(t);return[{x:n.x,y:n.y},{x:n.x+n.w,y:n.y},{x:n.x+n.w,y:n.y+n.h},{x:n.x,y:n.y+n.h}]}function Di(t,e,n=0){let o=Gt(t);return he(e,o)?!0:n>0&&xe(e,o)<=n}function Wt(t,e,n,o=Mi){let i=null,r=1/0;for(let a=t.length-1;a>=0;a--){let s=t[a];if(s.id===n||!A(s.type)||!Di(s,e,o))continue;let l=k(s),c=l.w*l.h;c<r&&(i=s,r=c)}return i}function mt(t,e){let n=k(t),[o,i]=e?.fixedPoint??[.5,.5];return{x:n.x+n.w*o,y:n.y+n.h*i}}function ki(t,e){let n=k(t);if(n.w<1||n.h<1)return;let o=Math.min(1,Math.max(0,(e.x-n.x)/n.w)),i=Math.min(1,Math.max(0,(e.y-n.y)/n.h)),r=(1-Pi)/2;if(o>r&&o<1-r&&i>r&&i<1-r)return;let a=[[o*n.w,"fx",0],[(1-o)*n.w,"fx",1],[i*n.h,"fy",0],[(1-i)*n.h,"fy",1]];a.sort((u,x)=>u[0]-x[0]);let[,s,l]=a[0],c=s==="fx"?[l,i]:[o,l];return[no(c[0]),no(c[1])]}function no(t){return Math.round(t*1e3)/1e3}function Ei(t){let e=t?.fixedPoint;if(!e)return null;let[n,o]=e;return o<=0?n<=0||n>=1?null:"up":o>=1?n<=0||n>=1?null:"down":n<=0?"left":n>=1?"right":null}function Ft(t,e,n){let o=Ei(e);if(o)return o;let i=k(t),r=to(t),a=(n.x-r.x)/Math.max(i.w,1),s=(n.y-r.y)/Math.max(i.h,1);return Math.abs(a)>=Math.abs(s)?a>=0?"right":"left":s>=0?"down":"up"}function oo(t,e,n,o=ao){let i=mt(t,e);if(e?.mode==="inside")return i;let r=n.x-i.x,a=n.y-i.y,s=Math.hypot(r,a);if(s<1)return i;let l=r/s,c=a/s,u=Gt(t),m=!(xe(i,u)<.5)&&he(i,u)?Ze(i,{x:l,y:c},u)??0:0;return{x:i.x+l*(m+o),y:i.y+c*(m+o)}}function io(t,e,n,o=ao){let i=mt(t,e);if(e?.mode==="inside")return i;let r=pe[n],a=Gt(t),c=!(xe(i,a)<.5)&&he(i,a)?Ze(i,r,a)??0:0;return{x:i.x+r.x*(c+o),y:i.y+r.y*(c+o)}}function be(t){let e=new Map(t.map(n=>[n.id,n]));return t.map(n=>{if(!T(n.type)||!n.startBinding&&!n.endBinding)return n;let o=ro(e,n.startBinding),i=ro(e,n.endBinding);if(!o&&!i)return{...n,startBinding:void 0,endBinding:void 0};let r={x:n.x,y:n.y},a={x:n.x+n.width,y:n.y+n.height},s=n.waypoints,l=s?.length?s[0]:i?mt(i,n.endBinding):a,c=s?.length?s[s.length-1]:o?mt(o,n.startBinding):r,u=n.routing==="elbow"&&!s?.length,x=o?u?io(o,n.startBinding,Ft(o,n.startBinding,l)):oo(o,n.startBinding,l):r,y=i?u?io(i,n.endBinding,Ft(i,n.endBinding,c)):oo(i,n.endBinding,c):a,m={...n,x:x.x,y:x.y,width:y.x-x.x,height:y.y-x.y,startBinding:o?n.startBinding:void 0,endBinding:i?n.endBinding:void 0};return Ti(n,m)?n:m})}function ro(t,e){if(!e)return;let n=t.get(e.id);return n&&A(n.type)?n:void 0}function Ti(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height&&t.startBinding===e.startBinding&&t.endBinding===e.endBinding}function so(t,e){let n={x:t.x,y:t.y},o={x:t.x+t.width,y:t.y+t.height},i=Wt(e,n,t.id),r=Wt(e,o,t.id);return i&&r&&i.id===r.id?t:{...t,startBinding:i?we(i,n):void 0,endBinding:r?we(r,o):void 0}}function we(t,e){let n=ki(t,e);return n?{id:t.id,fixedPoint:n}:{id:t.id}}var Se=" ",Ri=Dt[0],je="transparent";function co(t,e={}){let n=t.shapes.filter(c=>A(c.type)),o=new Set(n.map(c=>c.id)),i=t.shapes.filter(c=>T(c.type)&&c.startBinding!==void 0&&o.has(c.startBinding.id)&&c.endBinding!==void 0&&o.has(c.endBinding.id)),r=t.shapes.filter(c=>c.type==="text"),a=Ci(n),s=c=>a.get(c)??c;return`${[`flowchart ${e.direction??Ni(i)}`,...n.map(c=>Se+Ii(c,s(c.id))),...i.map(c=>Se+_i(c,s)),...n.flatMap(c=>{let u=Ai(c,s(c.id));return u?[Se+u]:[]}),...r.map(c=>`${Se}%% note: ${(c.text??"").replace(/\s*\n\s*/g," ")}`)].join(`
|
|
5
|
+
`)}
|
|
6
|
+
`}function Ni(t){return t.length===0||t.filter(n=>Math.abs(n.width)>=Math.abs(n.height)).length*2>=t.length?"LR":"TD"}function Ci(t){let e=new Map,n=new Set;for(let o of t){let i=Oi(o.id),r=i;for(let a=2;n.has(r);a+=1)r=`${i}_${a}`;n.add(r),e.set(o.id,r)}return e}function Oi(t){let e=t.replace(/[^A-Za-z0-9_]/g,"_");return e===""||/^[0-9]/.test(e)?`n_${e}`:e}var vi={rect:["[","]"],ellipse:["([","])"],diamond:["{","}"],note:["[","]"],cylinder:["[(",")]"],cloud:["((","))"],queue:["[[","]]"],actor:["((","))"]};function Ii(t,e){let[n,o]=vi[t.type],i=[t.label,t.text,t.footer].filter(a=>a!==void 0&&a!==""),r=i.length?i.map(lo).join("<br/>"):t.id;return`${e}${n}"${r}"${o}`}function _i(t,e){let n=e(t.startBinding?.id??""),o=e(t.endBinding?.id??""),i=t.type==="line"?"---":t.bidirectional?"<-->":"-->",r=t.text?`|${lo(t.text).replace(/\|/g,"#124;")}|`:"";return`${n} ${i}${r} ${o}`}function Ai(t,e){let n=[];return t.fill!==je&&n.push(`fill:${t.fill}`),t.stroke!==Ri&&n.push(`stroke:${t.stroke}`),n.length===0?null:(t.fill===je&&n.unshift(`fill:${je}`),`style ${e} ${n.join(",")}`)}function lo(t){return t.replace(/"/g,"#quot;").replace(/</g,"#lt;").replace(/>/g,"#gt;").replace(/\r?\n/g,"<br/>")}var X={plain:{stroke:"transparent",fill:"#f1f3f5"},black:{stroke:"#1e1e1e",fill:"#1e1e1e"},gray:{stroke:"#1e1e1e",fill:"transparent"},red:{stroke:"#e03131",fill:"#ffc9c9"},green:{stroke:"#2f9e44",fill:"#b2f2bb"},blue:{stroke:"#1971c2",fill:"#a5d8ff"},orange:{stroke:"#f08c00",fill:"#ffec99"},purple:{stroke:"#7048e8",fill:"#d0bfff"}},xo=Object.keys(X),Bi=260,$i=6,Li=90,uo=40,Me=32,zi=32,Hi=120,Qe="#1e1e1e",tn=2;function Wi(t){return Kt(t)&&Array.isArray(t.boxes)}function go(t){try{let e=JSON.parse(t);return Wi(e)?Fi(Qi(e)):nt}catch{return nt}}function Fi(t){let e=Ji(t.boxes),n=new Map(e.map(d=>[d.id,d.type??"rect"])),o=new Map(e.map(d=>[d.id,Gi(d,n.get(d.id))])),i=new Set(n.keys()),r=(t.connectors??[]).filter(d=>i.has(at(d.from))&&i.has(at(d.to))&&at(d.from)!==at(d.to)),a=Yi(e,o,r,t.direction??"right"),s=e.map(d=>Ui(d,n.get(d.id),o.get(d.id),a.get(d.id))),l=new Map(s.map(d=>[d.id,ji(d)])),c=new Set(i),u=d=>{let f=c.size+1;for(;c.has(`${d}${f}`);)f+=1;let P=`${d}${f}`;return c.add(P),P},x=r.map(d=>Xi(d,l,u("c"))),y=(t.texts??[]).map(d=>Zi(d,u("t"))),m=be([...s,...x,...y]),g=m.reduce((d,f)=>{let P=k(f);return Math.max(d,P.y+P.h)},0);return Ye({version:3,...t.canvasWidth!==void 0?{canvasWidth:t.canvasWidth}:{},canvasHeight:t.canvasHeight??Math.max(Hi,Math.ceil(g+zi)),...t.width!==void 0?{width:t.width}:{},shapes:m})}function Gi(t,e){let n=gt[e],o={id:"",type:e,x:0,y:0,width:n.defaultSize.w,height:n.defaultSize.h,stroke:"",fill:"",strokeWidth:0},i=n.textArea(o),r=i.w/n.defaultSize.w,a=i.h/n.defaultSize.h,s=t.w!==void 0?Math.max(20,t.w*r):Bi,l=n.textSlots.flatMap(x=>{let y=Ki(t,x,s);return y?[y]:[]}),c=l.reduce((x,y)=>Math.max(x,y.w),0),u=l.reduce((x,y)=>x+y.h,0)+Math.max(0,l.length-1)*$i;return{w:t.w??Math.max(n.defaultSize.w,Math.ceil(c/r)),h:t.h??Math.max(n.defaultSize.h,Math.ceil(u/a))}}function Ki(t,e,n){let o=t[e];if(!o)return null;let i=e==="text"?I:z;return U(ot(o,n,i).join(`
|
|
7
|
+
`),i)}function Yi(t,e,n,o){let i=new Map,r=t.filter(f=>f.x===void 0||f.y===void 0),a=new Set(r.map(f=>f.id)),s=n.map(f=>({from:at(f.from),to:at(f.to)})).filter(f=>f.from!==f.to&&a.has(f.from)&&a.has(f.to)),l=Vi(r.map(f=>f.id),qi(r.map(f=>f.id),s)),c=[];for(let f of r){let P=l.get(f.id)??0;(c[P]??(c[P]=[])).push(f.id)}let u=o==="right"?"w":"h",x=o==="right"?"h":"w",y=c.map(f=>f.reduce((P,b)=>Math.max(P,e.get(b)[u]),0)),m=c.map(f=>f.reduce((P,b)=>P+e.get(b)[x],0)+Math.max(0,f.length-1)*uo),g=m.reduce((f,P)=>Math.max(f,P),0),d=Me;c.forEach((f,P)=>{let b=Me+(g-m[P])/2;for(let F of f){let _=e.get(F),ct=Math.round(d+(y[P]-_[u])/2),_t=Math.round(b);i.set(F,o==="right"?{x:ct,y:_t}:{x:_t,y:ct}),b+=_[x]+uo}d+=y[P]+Li});for(let f of t){let P=i.get(f.id)??{x:Me,y:Me};i.set(f.id,{x:f.x??P.x,y:f.y??P.y})}return i}function qi(t,e){let n=new Map;for(let a of e)(n.get(a.from)??n.set(a.from,[]).get(a.from)).push(a);let o=new Map,i=[],r=a=>{o.set(a,"visiting");for(let s of n.get(a)??[]){let l=o.get(s.to);l!=="visiting"&&(i.push(s),l===void 0&&r(s.to))}o.set(a,"done")};for(let a of t)o.has(a)||r(a);return i}function Vi(t,e){let n=new Map;for(let r of e)(n.get(r.to)??n.set(r.to,[]).get(r.to)).push(r.from);let o=new Map,i=r=>{let a=o.get(r);if(a!==void 0)return a;let s=(n.get(r)??[]).reduce((l,c)=>Math.max(l,i(c)+1),0);return o.set(r,s),s};for(let r of t)i(r);return o}function Ui(t,e,n,o){let i=t.color?X[t.color]:void 0,r=t.fill??i?.fill??gt[e].defaultFill??"transparent";return{id:t.id,type:e,x:o.x,y:o.y,width:n.w,height:n.h,stroke:t.stroke??i?.stroke??Qe,fill:r,strokeWidth:tn,...t.text?{text:t.text}:{},...t.label?{label:t.label}:{},...t.footer?{footer:t.footer}:{}}}function Xi(t,e,n){let o=t.type??"arrow",i=e.get(at(t.from)),r=e.get(at(t.to));return{id:t.id??n,type:o,x:i.x,y:i.y,width:r.x-i.x,height:r.y-i.y,stroke:t.stroke??(t.color?X[t.color].stroke:Qe),fill:"transparent",strokeWidth:tn,startBinding:yo(t.from),endBinding:yo(t.to),...t.text?{text:t.text}:{},...o==="arrow"&&t.bidirectional?{bidirectional:!0}:{},...t.routing==="elbow"?{routing:"elbow"}:{}}}function Zi(t,e){let n=U(t.text);return{id:t.id??e,type:"text",x:t.x,y:t.y,width:n.w,height:n.h,stroke:t.stroke??(t.color?X[t.color].stroke:Qe),fill:"transparent",strokeWidth:tn,text:t.text}}function at(t){return typeof t=="string"?t:t.id}function yo(t){return typeof t=="string"||!t.side?{id:at(t)}:{id:t.id,fixedPoint:Ke[t.side]}}function ji(t){let e=k(t);return{x:e.x+e.w/2,y:e.y+e.h/2}}function Ji(t){let e=new Set;return t.filter(n=>e.has(n.id)?!1:(e.add(n.id),!0))}function Qi(t){let e=t,n=e.boxes.flatMap(s=>{let l=tr(s);return l?[l]:[]}),o=Array.isArray(e.connectors)?e.connectors.flatMap(s=>{let l=er(s);return l?[l]:[]}):[],i=Array.isArray(e.texts)?e.texts.flatMap(s=>{let l=nr(s);return l?[l]:[]}):[],r=wt(e.canvasWidth),a=wt(e.canvasHeight);return{direction:e.direction==="down"?"down":"right",...r!==void 0?{canvasWidth:r}:{},...a!==void 0?{canvasHeight:a}:{},...ae(e.width)?{width:e.width}:{},boxes:n,connectors:o,texts:i}}function tr(t){return!Kt(t)||!H(t.id)||t.type!==void 0&&!(typeof t.type=="string"&&A(t.type))?null:nn({id:t.id,type:t.type,label:H(t.label)?t.label:void 0,text:H(t.text)?t.text:void 0,footer:H(t.footer)?t.footer:void 0,x:wt(t.x),y:wt(t.y),w:fo(t.w),h:fo(t.h),color:en(t.color),stroke:H(t.stroke)?t.stroke:void 0,fill:H(t.fill)?t.fill:void 0})}function er(t){if(!Kt(t))return null;let e=po(t.from),n=po(t.to);return!e||!n||t.type!==void 0&&!(typeof t.type=="string"&&T(t.type))?null:nn({id:H(t.id)?t.id:void 0,type:t.type,from:e,to:n,text:H(t.text)?t.text:void 0,bidirectional:t.bidirectional===!0?!0:void 0,routing:t.routing==="elbow"?"elbow":void 0,color:en(t.color),stroke:H(t.stroke)?t.stroke:void 0})}function po(t){if(H(t))return t;if(!Kt(t)||!H(t.id))return null;let e=t.side;return typeof e=="string"&&e in Ke?{id:t.id,side:e}:{id:t.id}}function nr(t){if(!Kt(t)||!H(t.text))return null;let e=wt(t.x),n=wt(t.y);return e===void 0||n===void 0?null:nn({id:H(t.id)?t.id:void 0,x:e,y:n,text:t.text,color:en(t.color),stroke:H(t.stroke)?t.stroke:void 0})}function Kt(t){return typeof t=="object"&&t!==null}function H(t){return typeof t=="string"&&t!==""}function wt(t){return typeof t=="number"&&Number.isFinite(t)?t:void 0}function fo(t){let e=wt(t);return e!==void 0&&e>0?e:void 0}function en(t){return typeof t=="string"&&xo.includes(t)?t:void 0}function nn(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}var Je={enum:xo,description:"Named color preset: outline plus, for boxes, a matching fill. `plain` has no outline and a light fill, `black` is a dark card with light text, `gray` is a dark outline on transparent (the default); the rest pair a colored outline with its pastel fill."},ho={oneOf:[{type:"string",description:"Id of a box. The connector attaches to its outline, aimed at the other end"},{type:"object",required:["id"],additionalProperties:!1,properties:{id:{type:"string",description:"Id of a box"},side:{enum:["top","right","bottom","left"],description:"Pin the endpoint to the middle of this side of the box instead of auto-aiming"}}}],description:"Box a connector end attaches to: a bare box id, or {id, side} to pick the attach edge"},fa={$schema:"http://json-schema.org/draft-07/schema#",title:"DrawingSkeleton",description:"Compact intent description of a diagram. Boxes are sized from their text and laid out automatically along the connector flow; connectors are drawn between box outlines. Only say what is on the canvas \u2014 geometry is derived",type:"object",required:["boxes"],additionalProperties:!1,properties:{direction:{enum:["right","down"],description:'Auto-layout flow direction. Boxes connected a\u2192b are placed in successive ranks along this axis ("right" = columns left to right, "down" = rows top to bottom). Default "right"'},canvasWidth:{type:"number",minimum:120,description:"Logical canvas width in px. Omit for a fluid canvas in CSS pixels"},canvasHeight:{type:"number",minimum:80,description:"Canvas height in px. Omit to fit the content"},width:{enum:["full","text","content"],description:'Block width: "text" aligns the drawing with the text column (same as "full" unless the app sets a text measure); "content" fits the drawing to its shapes and left-aligns it with the text; omit to span the editor'},boxes:{type:"array",items:{$ref:"#/definitions/box"},description:"Card-like shapes carrying up to three text slots. Order is the render order and the stacking order within a layout rank"},connectors:{type:"array",items:{$ref:"#/definitions/connector"},description:"Arrows and lines between boxes. Connectors whose from/to id does not match a box are dropped"},texts:{type:"array",items:{$ref:"#/definitions/text"},description:"Free-floating annotations not attached to any box. Prefer box slots (label/text/footer) when the text belongs to a box"}},definitions:{box:{type:"object",required:["id"],additionalProperties:!1,properties:{id:{type:"string",description:"Unique within the drawing; connectors reference it"},type:{enum:de,description:'Shape: rect (default), ellipse, diamond (decision), note (sticky note, yellow by default), cylinder (database), cloud (external system), queue (message queue), actor (stick figure; only the "text" slot renders, below the figure)'},label:{type:"string",description:"Small bold heading at the top of the box"},text:{type:"string",description:'Main content, centered. Wraps automatically; "\\n" forces a line break'},footer:{type:"string",description:"Small dim line at the bottom of the box"},x:{type:"number",description:"Top-left x in px. Omit (with y) to let the layout place the box"},y:{type:"number",description:"Top-left y in px. Omit (with x) to let the layout place the box"},w:{type:"number",exclusiveMinimum:0,description:"Width in px. Omit to size from the text (never smaller than the type default)"},h:{type:"number",exclusiveMinimum:0,description:"Height in px. Omit to size from the text (never smaller than the type default)"},color:Je,stroke:{type:"string",description:"CSS color of the outline and text; overrides the preset"},fill:{type:"string",description:'CSS color of the interior ("transparent" for none); overrides the preset'}}},connector:{type:"object",required:["from","to"],additionalProperties:!1,properties:{id:{type:"string",description:"Optional; generated when omitted"},type:{enum:ue,description:'arrow (default; arrowhead at "to") or line (no arrowheads)'},from:ho,to:ho,text:{type:"string",description:"Label rendered at the middle of the connector"},bidirectional:{type:"boolean",description:"Arrow only: arrowheads on both ends"},routing:{enum:["straight","elbow"],description:"straight (default) draws a direct line; elbow draws a right-angled path routed around the boxes"},color:Je,stroke:{type:"string",description:"CSS color of the line and label; overrides the preset"}}},text:{type:"object",required:["x","y","text"],additionalProperties:!1,properties:{id:{type:"string",description:"Optional; generated when omitted"},x:{type:"number",description:"Top-left x of the first line, in px"},y:{type:"number",description:"Top-left y of the first line, in px"},text:{type:"string",description:'Content; "\\n" forces a line break'},color:Je,stroke:{type:"string",description:"CSS color of the text; overrides the preset"}}}}};import{$applyNodeReplacement as zr,DecoratorNode as Hr}from"lexical";import{useCallback as v,useEffect as Mn,useMemo as Vo,useRef as W,useState as Q,useContext as Tr}from"react";import{$getNodeByKey as Rr}from"lexical";import{useLexicalComposerContext as Nr}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Cr}from"@lexical/react/useLexicalEditable";var mo=28,bo=14,or=60,ir=1;function So(t,e){let n=new Map(e.map(b=>[b.id,b])),o=t.startBinding?n.get(t.startBinding.id):void 0,i=t.endBinding?n.get(t.endBinding.id):void 0,r={x:t.x,y:t.y},a={x:t.x+t.width,y:t.y+t.height},s=i?mt(i,t.endBinding):a,l=o?mt(o,t.startBinding):r,c=o?Ft(o,t.startBinding,s):qe(r,a),u=i?Ft(i,t.endBinding,l):qe(a,r),x=o?wo(r,c,mo):r,y=i?wo(a,u,mo):a,m=Lt([Pe(x),Pe(y)]),g=fe(m,or),d=e.filter(b=>A(b.type)).map(b=>fe(k(b),bo)).filter(b=>rr(b,g)).filter(b=>!Ve(b,x)&&!Ve(b,y)),f=ar(x,y,c,u,d)??(jn(c)?[x,{x:y.x,y:x.y},y]:[x,{x:x.x,y:y.y},y]),P=lr([r,x,...f,y,a]);return t.elbow!==void 0&&P.length===4&&(P=dr(P,t.elbow,d)),P}function wo(t,e,n){let o=pe[e];return{x:t.x+o.x*n,y:t.y+o.y*n}}function Pe(t){return{x:t.x,y:t.y,w:0,h:0}}function rr(t,e){return t.x<=e.x+e.w&&t.x+t.w>=e.x&&t.y<=e.y+e.h&&t.y+t.h>=e.y}function ar(t,e,n,o,i){let r=new Set([t.x,e.x,(t.x+e.x)/2]),a=new Set([t.y,e.y,(t.y+e.y)/2]);for(let d of i)r.add(d.x),r.add(d.x+d.w),a.add(d.y),a.add(d.y+d.h);let s=fe(Lt([Pe(t),Pe(e),...i]),bo);r.add(s.x),r.add(s.x+s.w),a.add(s.y),a.add(s.y+s.h);let l=[...r].sort((d,f)=>d-f),c=[...a].sort((d,f)=>d-f),u=c.map((d,f)=>l.map((P,b)=>({x:P,y:d,col:b,row:f,g:1/0,f:1/0,closed:!1,visited:!1,parent:null,dir:null}))),x=u[c.indexOf(t.y)][l.indexOf(t.x)],y=u[c.indexOf(e.y)][l.indexOf(e.x)];if(x===y)return[t];let m=Math.max(1e4,kt(t,e)**2),g=new on;for(x.g=0,x.f=kt(x,y),x.visited=!0,g.push(x);g.size;){let d=g.pop();if(d.closed)continue;if(d===y)return cr(d);d.closed=!0;let f=d.dir??n;for(let[P,b]of sr(u,d)){if(b.closed||P===Zn(f)||b===y&&P===o)continue;let F={x:(d.x+b.x)/2,y:(d.y+b.y)/2};if(i.some(ct=>Ue(ct,F)))continue;let _=d.g+kt(d,b)+(P!==f?m:0);(!b.visited||_<b.g)&&(b.visited=!0,b.parent=d,b.dir=P,b.g=_,b.f=_+kt(b,y),g.push(b))}}return null}function sr(t,e){let n=[];return e.row>0&&n.push(["up",t[e.row-1][e.col]]),e.col<t[0].length-1&&n.push(["right",t[e.row][e.col+1]]),e.row<t.length-1&&n.push(["down",t[e.row+1][e.col]]),e.col>0&&n.push(["left",t[e.row][e.col-1]]),n}function cr(t){let e=[];for(let n=t;n;n=n.parent)e.push({x:n.x,y:n.y});return e.reverse()}var on=class{constructor(){this.items=[]}get size(){return this.items.length}push(e){let n=this.items;n.push(e);let o=n.length-1;for(;o>0;){let i=o-1>>1;if(n[i].f<=n[o].f)break;[n[i],n[o]]=[n[o],n[i]],o=i}}pop(){let e=this.items,n=e[0],o=e.pop();if(e.length){e[0]=o;let i=0;for(;;){let r=i*2+1,a=r+1,s=i;if(r<e.length&&e[r].f<e[s].f&&(s=r),a<e.length&&e[a].f<e[s].f&&(s=a),s===i)break;[e[s],e[i]]=[e[i],e[s]],i=s}}return n}};function lr(t){let e=[];for(let o of t){let i=e[e.length-1];i&&kt(i,o)<ir||e.push(o)}let n=[];for(let o=0;o<e.length;o++){let i=n[n.length-1],r=e[o+1],a=e[o];if(i&&r){let s=Math.abs(i.x-a.x)<.01&&Math.abs(a.x-r.x)<.01,l=Math.abs(i.y-a.y)<.01&&Math.abs(a.y-r.y)<.01;if(s||l)continue}n.push(a)}return n}function dr(t,e,n){let[o,i,r,a]=t,s=Math.abs(i.y-r.y)<.01&&Math.abs(i.x-r.x)>.01,l=Math.abs(i.x-r.x)<.01&&Math.abs(i.y-r.y)>.01,c=Math.min(.95,Math.max(.05,e)),u;if(l){let x=o.x+(a.x-o.x)*c;u=[o,{x,y:i.y},{x,y:r.y},a]}else if(s){let x=o.y+(a.y-o.y)*c;u=[o,{x:i.x,y:x},{x:r.x,y:x},a]}else return t;for(let x=0;x<u.length-1;x++){let y={x:(u[x].x+u[x+1].x)/2,y:(u[x].y+u[x+1].y)/2};if(n.some(m=>Ue(m,y)))return t}return u}function rn(t,e=[]){let n={x:t.x,y:t.y},o={x:t.x+t.width,y:t.y+t.height};return t.waypoints?.length?[n,...t.waypoints,o]:t.routing==="elbow"?So(t,e):[n,o]}function an(t,e=6){if(t.length<2)return"";if(t.length===2)return`M ${O(t[0].x)} ${O(t[0].y)} L ${O(t[1].x)} ${O(t[1].y)}`;let n=`M ${O(t[0].x)} ${O(t[0].y)}`;for(let i=1;i<t.length-1;i++){let r=t[i-1],a=t[i],s=t[i+1],l=Math.hypot(a.x-r.x,a.y-r.y),c=Math.hypot(s.x-a.x,s.y-a.y),u=Math.min(e,l/2,c/2);if(u<.5){n+=` L ${O(a.x)} ${O(a.y)}`;continue}let x={x:a.x-(a.x-r.x)/l*u,y:a.y-(a.y-r.y)/l*u},y={x:a.x+(s.x-a.x)/c*u,y:a.y+(s.y-a.y)/c*u};n+=` L ${O(x.x)} ${O(x.y)} Q ${O(a.x)} ${O(a.y)} ${O(y.x)} ${O(y.y)}`}let o=t[t.length-1];return`${n} L ${O(o.x)} ${O(o.y)}`}function O(t){return Number.isInteger(t)?String(t):t.toFixed(2)}function Yt(t,e,n){let o=n?1:-1;for(let i=e+o;i>=0&&i<t.length;i+=o){let r=t[e].x-t[i].x,a=t[e].y-t[i].y;if(Math.abs(r)>.01||Math.abs(a)>.01)return Math.atan2(a,r)}return 0}function De(t,e,n){let o=Math.PI/7;return[{x:t.x-n*Math.cos(e-o),y:t.y-n*Math.sin(e-o)},t,{x:t.x-n*Math.cos(e+o),y:t.y-n*Math.sin(e+o)}]}function Mo(t,e,n){let[o,i,r]=De(t,e,n);return`M ${O(o.x)} ${O(o.y)} L ${O(i.x)} ${O(i.y)} L ${O(r.x)} ${O(r.y)}`}function sn(t){let e=0;for(let n=1;n<t.length;n++)e+=Math.hypot(t[n].x-t[n-1].x,t[n].y-t[n-1].y);return e}function Po(t,e){if(t.type!=="arrow"||e.length<2)return[];let n=sn(e);if(n<1)return[];let o=Math.min(14,4+n/4),i=e.length-1,r=[Mo(e[i],Yt(e,i,!1),o)];return t.bidirectional&&r.push(Mo(e[0],Yt(e,0,!0),o)),r}function ke(t){if(t.length===0)return{x:0,y:0};if(t.length===1)return t[0];let e=t[Math.floor((t.length-1)/2)],n=t[Math.ceil((t.length+1)/2)-1];return{x:(e.x+n.x)/2,y:(e.y+n.y)/2}}import{jsx as R,jsxs as qt}from"react/jsx-runtime";var Vt={select:R("path",{d:"M4.5 2.5l12 6.5-5.4 1.4L8.5 16.5z",fill:"currentColor",stroke:"none"}),rect:R("rect",{x:"3",y:"4.5",width:"14",height:"11",rx:"2"}),ellipse:R("ellipse",{cx:"10",cy:"10",rx:"7",ry:"5.5"}),diamond:R("path",{d:"M10 3l7 7-7 7-7-7z"}),note:R("path",{d:"M4 3.5h12v9l-3.5 3.5H4z M12.5 16v-3.5H16"}),cylinder:qt("g",{children:[R("ellipse",{cx:"10",cy:"5.5",rx:"6",ry:"2.5"}),R("path",{d:"M4 5.5v9c0 1.4 2.7 2.5 6 2.5s6-1.1 6-2.5v-9"})]}),cloud:R("path",{d:"M6 15.5a3 3 0 0 1-.5-5.95A4.5 4.5 0 0 1 14 8.3a3.6 3.6 0 0 1 .5 7.2z"}),queue:qt("g",{children:[R("path",{d:"M5.5 5.5h9M5.5 14.5h9M5.5 5.5a2.2 4.5 0 0 0 0 9"}),R("ellipse",{cx:"14.5",cy:"10",rx:"2.2",ry:"4.5"})]}),actor:qt("g",{children:[R("circle",{cx:"10",cy:"5",r:"2.2"}),R("path",{d:"M10 7.2v5M6.5 9.2h7M10 12.2l-3 4.6M10 12.2l3 4.6"})]}),arrow:R("path",{d:"M4 16L16 4M9 4h7v7"}),line:R("path",{d:"M4 16L16 4"}),text:R("path",{d:"M4 5V3.5h12V5M10 3.5V16.5M7 16.5h6"})},Z={more:qt("g",{children:[R("rect",{x:"3",y:"3",width:"5.5",height:"5.5",rx:"1.2"}),R("circle",{cx:"14.25",cy:"5.75",r:"2.75"}),R("path",{d:"M5.75 11.5l2.75 5h-5.5z"}),R("path",{d:"M11.5 12h5.5v5h-5.5z"})]}),straight:R("path",{d:"M4 16L16 4"}),elbow:R("path",{d:"M4 16v-6h12V4"}),oneWay:R("path",{d:"M3 10h13M12 5.5L16.5 10L12 14.5"}),twoWay:R("path",{d:"M3.5 10h13M8 5.5L3.5 10L8 14.5M12 5.5L16.5 10L12 14.5"}),trash:R("path",{d:"M4 6h12M8 6V4h4v2M6 6l1 10h6l1-10M8.5 9v4M11.5 9v4"}),mermaid:qt("g",{children:[R("rect",{x:"3",y:"3.5",width:"5",height:"4",rx:"1"}),R("rect",{x:"12",y:"3.5",width:"5",height:"4",rx:"1"}),R("rect",{x:"7.5",y:"12.5",width:"5",height:"4",rx:"1"}),R("path",{d:"M5.5 7.5v2.5h9V7.5M10 10v2.5"})]}),check:R("path",{d:"M4 10.5l4 4 8-9"}),grip:R("path",{d:"M7 7h.01M7 10h.01M7 13h.01M10 7h.01M10 10h.01M10 13h.01M13 7h.01M13 10h.01M13 13h.01",strokeWidth:"2.2"})};function yt({children:t,size:e=16}){return R("svg",{viewBox:"0 0 20 20",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t})}var Ee=8,Ut=3;function cn(t,e){return{x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}}function Do(t,e,n){return t.filter(o=>{if(T(o.type)){let i=n.get(o.id)??[];return i.length>0&&i.every(r=>r.x>=e.x&&r.x<=e.x+e.w&&r.y>=e.y&&r.y<=e.y+e.h)}return eo(k(o),e)}).map(o=>o.id)}function ln(t,e,n){switch(e.mode){case"marquee":return t;case"draw":return t.map(o=>o.id===e.id?{...o,w:n.x-o.x,h:n.y-o.y}:o);case"move":{let o=n.x-e.origin.x,i=n.y-e.origin.y;return t.map(r=>{let a=e.origs.get(r.id);return a?{...r,x:a.x+o,y:a.y+i,waypoints:a.waypoints?.map(s=>({x:s.x+o,y:s.y+i}))}:r})}case"resize":{let o=e.orig,i=o.x+o.width,r=o.y+o.height,a=e.corner==="nw"||e.corner==="sw"?n.x:o.x,s=e.corner==="nw"||e.corner==="ne"?n.y:o.y,l=e.corner==="ne"||e.corner==="se"?n.x:i,c=e.corner==="sw"||e.corner==="se"?n.y:r;return t.map(u=>u.id===e.id?{...u,x:a,y:s,width:l-a,height:c-s}:u)}case"endpoint":{let o=e.orig;return t.map(i=>i.id!==e.id?i:e.end==="start"?{...i,x:n.x,y:n.y,width:o.x+o.width-n.x,height:o.y+o.height-n.y}:{...i,width:n.x-o.x,height:n.y-o.y})}case"elbow":{let o=e.vertical?e.d.x-e.a.x:e.d.y-e.a.y;if(Math.abs(o)<1)return t;let i=e.vertical?(n.x-e.a.x)/o:(n.y-e.a.y)/o,r=Math.round(Math.min(.95,Math.max(.05,i))*1e3)/1e3;return t.map(a=>a.id===e.id?{...a,elbow:r}:a)}case"waypoint":return t.map(o=>{if(o.id!==e.id||!o.waypoints)return o;let i=o.waypoints;if(e.index<0||e.index>=i.length)return o;let r=e.index===0?{x:o.x,y:o.y}:i[e.index-1],a=e.index===i.length-1?{x:o.x+o.width,y:o.y+o.height}:i[e.index+1],s=n.x,l=n.y;Math.abs(s-r.x)<Ee?s=r.x:Math.abs(s-a.x)<Ee&&(s=a.x),Math.abs(l-r.y)<Ee?l=r.y:Math.abs(l-a.y)<Ee&&(l=a.y);let c=[...i];return c[e.index]={x:s,y:l},{...o,waypoints:c}})}}function dn(t,e,n){let o=e.has(n)?e:new Set([n]);return new Map(t.filter(i=>o.has(i.id)).map(i=>[i.id,i]))}import{jsx as j,jsxs as un}from"react/jsx-runtime";var ur=Object.keys(X);function yr({name:t,active:e,onClick:n}){let o=X[t],i=K().drawing.color(t);return j("button",{type:"button",title:i,"aria-label":i,"aria-pressed":e,className:`zui-drawing-swatch ${e?"is-active":""}`,style:{backgroundColor:o.fill,borderColor:o.stroke},onClick:n})}function Xt({label:t,active:e,onClick:n,children:o,className:i}){return j("button",{type:"button",title:t,"aria-label":t,"aria-pressed":e,className:`zui-drawing-tool ${e?"is-active":""} ${i??""}`,onClick:n,children:j(yt,{children:o})})}function ko({selection:t,stroke:e,fill:n,onColor:o,onRouting:i,onDirection:r,onDelete:a}){let s=t.filter(g=>T(g.type)),l=t.filter(g=>g.type==="arrow"),c=s.length>0&&s.every(g=>g.routing==="elbow"),u=s.length>0&&s.every(g=>g.routing!=="elbow"),x=l.length>0&&l.every(g=>g.bidirectional),y=l.length>0&&l.every(g=>!g.bidirectional),m=K().drawing;return un("div",{className:"zui-drawing-props",onPointerDown:g=>g.stopPropagation(),children:[j("div",{className:"zui-drawing-props-group",role:"radiogroup","aria-label":m.colors,children:ur.map(g=>j(yr,{name:g,active:X[g].stroke===e&&X[g].fill===n,onClick:()=>o(g)},g))}),s.length>0&&un("div",{className:"zui-drawing-props-group","aria-label":m.connectorRouting,children:[j(Xt,{label:m.straight,active:u,onClick:()=>i(!1),children:Z.straight}),j(Xt,{label:m.elbow,active:c,onClick:()=>i(!0),children:Z.elbow})]}),l.length>0&&un("div",{className:"zui-drawing-props-group","aria-label":m.arrowDirection,children:[j(Xt,{label:m.oneWay,active:y,onClick:()=>r(!1),children:Z.oneWay}),j(Xt,{label:m.twoWay,active:x,onClick:()=>r(!0),children:Z.twoWay})]}),t.length>0&&j("div",{className:"zui-drawing-props-group",children:j(Xt,{label:t.length>1?m.deleteShapes(t.length):m.deleteShape,className:"zui-drawing-tool-danger",onClick:a,children:Z.trash})})]})}import{jsx as B,jsxs as yn}from"react/jsx-runtime";var Zt=7;function Te({x:t,y:e,cursor:n,square:o,onPointerDown:i,title:r}){let a={className:"zui-drawing-handle",strokeWidth:1.5,style:{cursor:n},onPointerDown:i};return o?B("rect",{...a,x:t-Zt/2,y:e-Zt/2,width:Zt,height:Zt,rx:2,children:r&&B("title",{children:r})}):B("circle",{...a,cx:t,cy:e,r:Zt/2+.5,children:r&&B("title",{children:r})})}function Eo({shape:t,points:e,onHandlePointerDown:n,onWaypointAdd:o,onWaypointRemove:i}){let r=K().drawing;if(T(t.type)){let u=t.waypoints??[],x=t.routing==="elbow"&&!u.length&&e.length===4,y=x?{x:(e[1].x+e[2].x)/2,y:(e[1].y+e[2].y)/2}:null,m=x&&Math.abs(e[1].x-e[2].x)<.01,g=e.slice(0,-1).flatMap((d,f)=>{let P=e[f+1];return Math.hypot(P.x-d.x,P.y-d.y)<28?[]:x&&f===1?[]:[{index:f,x:(d.x+P.x)/2,y:(d.y+P.y)/2}]});return yn("g",{className:"zui-drawing-selection",children:[g.map(({index:d,x:f,y:P})=>B("circle",{className:"zui-drawing-handle zui-drawing-ghost",cx:f,cy:P,r:4.5,strokeWidth:1.5,strokeDasharray:"2 2",style:{cursor:"copy"},onPointerDown:b=>o(b,t.id,d,{x:f,y:P}),children:B("title",{children:"Drag to add a bend"})},`ghost-${d}`)),u.map((d,f)=>B("g",{onDoubleClick:P=>{P.stopPropagation(),i(t.id,f)},children:B(Te,{x:d.x,y:d.y,square:!0,cursor:"move",title:r.waypoint,onPointerDown:P=>n(P,{mode:"waypoint",id:t.id,index:f})})},`wp-${f}`)),y&&B(Te,{x:y.x,y:y.y,square:!0,cursor:m?"ew-resize":"ns-resize",title:r.elbowHandle,onPointerDown:d=>n(d,{mode:"elbow",id:t.id,a:e[0],d:e[3],vertical:m})}),["start","end"].map(d=>{let f=d==="start"?e[0]:e[e.length-1];return B(Te,{x:f.x,y:f.y,cursor:"crosshair",onPointerDown:P=>n(P,{mode:"endpoint",id:t.id,end:d,orig:t})},d)})]})}let a=k(t),s=5,l=[{corner:"nw",x:a.x-s,y:a.y-s},{corner:"ne",x:a.x+a.w+s,y:a.y-s},{corner:"sw",x:a.x-s,y:a.y+a.h+s},{corner:"se",x:a.x+a.w+s,y:a.y+a.h+s}],c=t.type!=="text";return yn("g",{className:"zui-drawing-selection",children:[B(To,{rect:a,pad:s}),c&&l.map(({corner:u,x,y})=>B(Te,{x,y,square:!0,cursor:u==="nw"||u==="se"?"nwse-resize":"nesw-resize",onPointerDown:m=>n(m,{mode:"resize",id:t.id,corner:u,orig:t})},u))]})}function To({rect:t,pad:e}){return B("rect",{x:t.x-e,y:t.y-e,width:t.w+e*2,height:t.h+e*2,rx:6,fill:"none",stroke:"currentColor",strokeWidth:1,strokeDasharray:"5 4",pointerEvents:"none"})}function Ro({shapes:t,paths:e}){if(!t.length)return null;let n=t.map(o=>{if(!T(o.type))return k(o);let i=e.get(o.id)??[],r=i.map(c=>c.x),a=i.map(c=>c.y),s=Math.min(...r),l=Math.min(...a);return{x:s,y:l,w:Math.max(...r)-s,h:Math.max(...a)-l}});return yn("g",{className:"zui-drawing-selection",pointerEvents:"none",children:[n.map((o,i)=>B("rect",{x:o.x-3,y:o.y-3,width:o.w+6,height:o.h+6,rx:4,fill:"none",stroke:"currentColor",strokeWidth:1,opacity:.45},t[i].id)),B(To,{rect:Lt(n),pad:8})]})}function No({rect:t}){return B("rect",{className:"zui-drawing-selection",x:t.x,y:t.y,width:t.w,height:t.h,rx:3,fill:"currentColor",fillOpacity:.08,stroke:"currentColor",strokeWidth:1,pointerEvents:"none"})}import{jsx as q,jsxs as Re}from"react/jsx-runtime";var D=t=>Number.isInteger(t)?String(t):t.toFixed(2);function Co({shape:t,stroke:e}){let n=k(t),o=t.fill;switch(t.type){case"rect":return q("rect",{...e,x:n.x,y:n.y,width:n.w,height:n.h,rx:Math.min(8,n.w/4,n.h/4),fill:o});case"ellipse":return q("ellipse",{...e,cx:n.x+n.w/2,cy:n.y+n.h/2,rx:n.w/2,ry:n.h/2,fill:o});case"diamond":return q("polygon",{...e,points:`${D(n.x+n.w/2)},${D(n.y)} ${D(n.x+n.w)},${D(n.y+n.h/2)} ${D(n.x+n.w/2)},${D(n.y+n.h)} ${D(n.x)},${D(n.y+n.h/2)}`,fill:o});case"note":{let i=Et(n),r=n.x+n.w,a=n.y+n.h;return Re("g",{children:[q("path",{...e,d:`M ${D(n.x)} ${D(n.y)} H ${D(r)} V ${D(a-i)} L ${D(r-i)} ${D(a)} H ${D(n.x)} Z`,fill:o}),q("path",{...e,d:`M ${D(r-i)} ${D(a)} V ${D(a-i)} H ${D(r)}`,fill:"rgba(0,0,0,0.08)"})]})}case"cylinder":{let i=Tt(n),r=n.w/2,a=n.x+r;return Re("g",{children:[q("path",{...e,d:`M ${D(n.x)} ${D(n.y+i)} V ${D(n.y+n.h-i)} A ${D(r)} ${D(i)} 0 0 0 ${D(n.x+n.w)} ${D(n.y+n.h-i)} V ${D(n.y+i)}`,fill:o}),q("ellipse",{...e,cx:a,cy:n.y+i,rx:r,ry:i,fill:o})]})}case"cloud":{let i=(r,a)=>`${D(n.x+r*n.w)} ${D(n.y+a*n.h)}`;return q("path",{...e,d:`M ${i(.22,.86)} C ${i(.04,.88)} ${i(0,.58)} ${i(.16,.5)} C ${i(.08,.26)} ${i(.3,.12)} ${i(.42,.28)} C ${i(.5,.02)} ${i(.76,.04)} ${i(.78,.3)} C ${i(.98,.26)} ${i(1.04,.56)} ${i(.88,.64)} C ${i(1,.8)} ${i(.9,.9)} ${i(.76,.86)} Z`,fill:o})}case"queue":{let i=Rt(n),r=n.h/2;return Re("g",{children:[q("path",{...e,d:`M ${D(n.x+i)} ${D(n.y)} H ${D(n.x+n.w-i)} V ${D(n.y+n.h)} H ${D(n.x+i)} A ${D(i)} ${D(r)} 0 0 1 ${D(n.x+i)} ${D(n.y)} Z`,fill:o}),q("ellipse",{...e,cx:n.x+n.w-i,cy:n.y+r,rx:i,ry:r,fill:o})]})}case"actor":{let i=n.h*Ht,r=n.x+n.w/2,a=Math.max(4,Math.min(i*.16,n.w*.2)),s=n.y+a*2,l=n.y+i*.62,c=s+i*.12,u=Math.min(n.w*.32,i*.3);return Re("g",{children:[q("circle",{...e,cx:r,cy:n.y+a,r:a,fill:o}),q("path",{...e,fill:"none",d:`M ${D(r)} ${D(s)} V ${D(l)} M ${D(r-u)} ${D(c)} H ${D(r+u)} M ${D(r)} ${D(l)} L ${D(r-u)} ${D(n.y+i)} M ${D(r)} ${D(l)} L ${D(r+u)} ${D(n.y+i)}`})]})}default:return null}}function pn(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function vo(t){let e=t>>>0;return()=>{e=e+1831565813|0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function Io(t){return Math.min(4,Math.max(1,t*.03))}function _o(t){let e=vo(t^2654435769),n=e()*Math.PI*2,o=2+e();return{x:Math.cos(n)*o,y:Math.sin(n)*o}}function pr(t,e,n){let o=vo(t),i=(g,d)=>g+Math.floor(o()*d),r=n?i(2,2):1.5+o(),a=n?i(5,3):3+o()*2,s=n?i(2,2):1+o(),l=o()*Math.PI*2,c=o()*Math.PI*2,u=o()*Math.PI*2,x=e*(.55+o()*.15),y=e*.3,m=Math.PI*2;return{offset:g=>x*Math.sin(m*r*g+l)+y*Math.sin(m*a*g+c),pressure:g=>1+.3*Math.sin(m*s*g+u)}}function fr(t,e){let n=e?[...t,t[0]]:[...t],o=[],i=0;for(let l=1;l<n.length;l++){let c=Math.hypot(n[l].x-n[l-1].x,n[l].y-n[l-1].y);o.push(c),i+=c}if(i===0)return{points:[n[0]],ts:[0]};let r=[],a=[],s=0;for(let l=1;l<n.length;l++){let c=n[l-1],u=n[l],x=o[l-1],y=Math.max(1,Math.round(x/5));for(let m=0;m<y;m++){let g=m/y;r.push({x:c.x+(u.x-c.x)*g,y:c.y+(u.y-c.y)*g}),a.push((s+x*g)/i)}s+=x}return e||(r.push(n[n.length-1]),a.push(1)),{points:r,ts:a}}function hr(t,e,n){let o=t.length,i=t[n?(e-1+o)%o:Math.max(0,e-1)],r=t[n?(e+1)%o:Math.min(o-1,e+1)],a=r.x-i.x,s=r.y-i.y,l=Math.hypot(a,s)||1;return{x:-s/l,y:a/l}}var Oo=t=>Number.isInteger(t)?String(t):t.toFixed(2),Nt=t=>t.map((e,n)=>`${n===0?"M":"L"} ${Oo(e.x)} ${Oo(e.y)}`).join(" ");function Ct(t,e){if(t.length<2)return{ring:"",center:""};let{closed:n,seed:o,width:i,amplitude:r}=e,a=pr(o,r,n),{points:s,ts:l}=fr(t,n);if(s.length<2)return{ring:"",center:""};let c=[],u=[],x=[];for(let y=0;y<s.length;y++){let m=l[y],g=hr(s,y,n),d=a.offset(m),f={x:s[y].x+g.x*d,y:s[y].y+g.y*d},P=n?1:.55+.45*Math.min(1,m/.1,(1-m)/.1),b=i*a.pressure(m)*P/2;c.push(f),u.push({x:f.x+g.x*b,y:f.y+g.y*b}),x.push({x:f.x-g.x*b,y:f.y-g.y*b})}return n?{ring:`${Nt(u)} Z ${Nt([...x].reverse())} Z`,center:`${Nt(c)} Z`}:{ring:`${Nt(u)} ${Nt([...x].reverse()).replace(/^M/,"L")} Z`,center:Nt(c)}}function Ao(t,e,n=4){let o=Math.min(e,t.w/2,t.h/2);if(o<=0)return[{x:t.x,y:t.y},{x:t.x+t.w,y:t.y},{x:t.x+t.w,y:t.y+t.h},{x:t.x,y:t.y+t.h}];let i=[[t.x+t.w-o,t.y+o,-Math.PI/2],[t.x+t.w-o,t.y+t.h-o,0],[t.x+o,t.y+t.h-o,Math.PI/2],[t.x+o,t.y+o,Math.PI]],r=[];for(let[a,s,l]of i)for(let c=0;c<=n;c++){let u=l+Math.PI/2*(c/n);r.push({x:a+o*Math.cos(u),y:s+o*Math.sin(u)})}return r}function Bo(t,e=6,n=4){if(t.length<3)return[...t];let o=[t[0]];for(let i=1;i<t.length-1;i++){let r=t[i-1],a=t[i],s=t[i+1],l=Math.hypot(a.x-r.x,a.y-r.y),c=Math.hypot(s.x-a.x,s.y-a.y),u=Math.min(e,l/2,c/2);if(u<.5){o.push(a);continue}let x={x:a.x-(a.x-r.x)/l*u,y:a.y-(a.y-r.y)/l*u},y={x:a.x+(s.x-a.x)/c*u,y:a.y+(s.y-a.y)/c*u};for(let m=0;m<=n;m++){let g=m/n,d=1-g;o.push({x:d*d*x.x+2*d*g*a.x+g*g*y.x,y:d*d*x.y+2*d*g*a.y+g*g*y.y})}}return o.push(t[t.length-1]),o}function $o(t,e,n,o,i=10){let r=[];for(let a=1;a<=i;a++){let s=a/i,l=1-s;r.push({x:l*l*l*t.x+3*l*l*s*e.x+3*l*s*s*n.x+s*s*s*o.x,y:l*l*l*t.y+3*l*l*s*e.y+3*l*s*s*n.y+s*s*s*o.y})}return r}function fn(t,e,n,o,i,r,a=12){return Array.from({length:a+1},(s,l)=>{let c=i+(r-i)*l/a;return{x:t+n*Math.cos(c),y:e+o*Math.sin(c)}})}import{jsx as pt,jsxs as Ot}from"react/jsx-runtime";var Ne=t=>Number.isInteger(t)?String(t):t.toFixed(2);function Lo(t){let e=1/0,n=1/0,o=-1/0,i=-1/0;for(let r of t)r.x<e&&(e=r.x),r.x>o&&(o=r.x),r.y<n&&(n=r.y),r.y>i&&(i=r.y);return{w:o-e,h:i-n}}function zo({shape:t}){let e=k(t),n=pn(t.id),o=t.strokeWidth,i=_o(n),r=`translate(${Ne(i.x)} ${Ne(i.y)})`,a=c=>Io(Math.min(Lo(c).w,Lo(c).h)),s=(c,u,x=t.fill)=>{let y=Ct(c,{closed:!0,seed:n+u,width:o,amplitude:a(c)});return Ot("g",{children:[pt("path",{d:y.center,fill:x,stroke:"none",transform:r}),pt("path",{d:y.ring,fill:t.stroke,fillRule:"evenodd",stroke:"none"})]})},l=(c,u,x=o)=>pt("path",{d:Ct(c,{closed:!1,seed:n+u,width:x,amplitude:a(c)}).ring,fill:t.stroke,stroke:"none"});switch(t.type){case"rect":return s(Ao(e,Math.min(8,e.w/4,e.h/4)),0);case"ellipse":return s(ut(e,64),0);case"diamond":return s([{x:e.x+e.w/2,y:e.y},{x:e.x+e.w,y:e.y+e.h/2},{x:e.x+e.w/2,y:e.y+e.h},{x:e.x,y:e.y+e.h/2}],0);case"note":{let c=Et(e),u=e.x+e.w,x=e.y+e.h,y=[{x:e.x,y:e.y},{x:u,y:e.y},{x:u,y:x-c},{x:u-c,y:x},{x:e.x,y:x}],m=[{x:u-c,y:x},{x:u-c,y:x-c},{x:u,y:x-c}];return Ot("g",{children:[s(y,0),pt("path",{d:`M ${m.map(g=>`${Ne(g.x)} ${Ne(g.y)}`).join(" L ")} Z`,fill:"rgba(0,0,0,0.08)",stroke:"none"}),l(m,1)]})}case"cylinder":{let c=Tt(e),u=e.w/2,x=e.x+u,y=[{x:e.x,y:e.y+c},{x:e.x,y:e.y+e.h-c},...fn(x,e.y+e.h-c,u,c,Math.PI,0,16),{x:e.x+e.w,y:e.y+c}],m=Ct(y,{closed:!1,seed:n+0,width:o,amplitude:a(y)});return Ot("g",{children:[pt("path",{d:`${m.center} Z`,fill:t.fill,stroke:"none",transform:r}),pt("path",{d:m.ring,fill:t.stroke,stroke:"none"}),s(ut({x:e.x,y:e.y,w:e.w,h:c*2},48),1)]})}case"cloud":{let c=(g,d)=>({x:e.x+g*e.w,y:e.y+d*e.h}),u=c(.22,.86),x=[[c(.04,.88),c(0,.58),c(.16,.5)],[c(.08,.26),c(.3,.12),c(.42,.28)],[c(.5,.02),c(.76,.04),c(.78,.3)],[c(.98,.26),c(1.04,.56),c(.88,.64)],[c(1,.8),c(.9,.9),c(.76,.86)]],y=[u],m=u;for(let[g,d,f]of x)y.push(...$o(m,g,d,f,8)),m=f;return s(y,0)}case"queue":{let c=Rt(e),u=e.h/2,x=[{x:e.x+c,y:e.y},{x:e.x+e.w-c,y:e.y},{x:e.x+e.w-c,y:e.y+e.h},{x:e.x+c,y:e.y+e.h},...fn(e.x+c,e.y+u,c,u,Math.PI/2,3*Math.PI/2,16).slice(1,-1)];return Ot("g",{children:[s(x,0),s(ut({x:e.x+e.w-c*2,y:e.y,w:c*2,h:e.h},48),1)]})}case"actor":{let c=e.h*Ht,u=e.x+e.w/2,x=Math.max(4,Math.min(c*.16,e.w*.2)),y=e.y+x*2,m=e.y+c*.62,g=y+c*.12,d=Math.min(e.w*.32,c*.3);return Ot("g",{children:[s(ut({x:u-x,y:e.y,w:x*2,h:x*2},32),0),l([{x:u,y},{x:u,y:m}],1),l([{x:u-d,y:g},{x:u+d,y:g}],2),l([{x:u-d,y:e.y+c},{x:u,y:m},{x:u+d,y:e.y+c}],3)]})}default:return null}}function Ho({shape:t,points:e}){if(e.length<2)return null;let n=pn(t.id),o=sn(e),i=Math.min(3,Math.max(.8,o*.015)),r=t.strokeWidth,a=Ct(Bo(e),{closed:!1,seed:n,width:r,amplitude:i}),s=[];if(t.type==="arrow"&&o>=1){let l=Math.min(14,4+o/4),c=e.length-1;s.push(De(e[c],Yt(e,c,!1),l)),t.bidirectional&&s.push(De(e[0],Yt(e,0,!0),l))}return Ot("g",{fill:t.stroke,stroke:"none",children:[pt("path",{d:a.ring}),s.map((l,c)=>pt("path",{d:Ct(l,{closed:!1,seed:n+1+c,width:r*1.15,amplitude:.8}).ring},c))]})}import{Fragment as wr,jsx as $,jsxs as jt}from"react/jsx-runtime";import{createElement as xn}from"react";var st=12,gn=160;function Oe(t){let e=me(t);return{area:e?e.textArea(t):k(t),slots:e?e.textSlots:["label","text","footer"]}}function mn(t,e){let{area:n,slots:o}=Oe(t),i=(e-n.y)/Math.max(n.h,1);return i<.3&&o.includes("label")?"label":i>.7&&o.includes("footer")?"footer":o.includes("text")?"text":o[0]}var Ce={userSelect:"none"};function xr(t){let e=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t);if(!e)return 1;let n=e[1].length===3?e[1].replace(/./g,a=>a+a):e[1],[o,i,r]=[0,2,4].map(a=>parseInt(n.slice(a,a+2),16)/255);return .2126*o+.7152*i+.0722*r}function wn(t){return t.stroke==="transparent"||t.stroke==="none"?"#1e1e1e":xr(t.fill)<.35?"#ffffff":t.stroke}var hn={userSelect:"none",pointerEvents:"none"};function gr({shape:t,hideField:e,showHints:n}){let{area:o,slots:i}=Oe(t),r=o.x+o.w/2,a=Math.max(o.w,20),s=n&&o.h>=56&&o.w>=44,l=ot(t.text??"",a,I),c=ot(t.label??"",a,z),u=ot(t.footer??"",a,z),x=I*et,y=z*et,m=o.y+o.h/2-(l.length-1)*x/2+I*.35,g={fill:wn(t),textAnchor:"middle"};return jt("g",{children:[i.includes("label")&&e!=="label"&&(t.label?c.map((d,f)=>xn("text",{...g,key:f,x:r,y:o.y+z+f*y,fontSize:z,fontWeight:600,letterSpacing:.3,opacity:.85,style:Ce},d)):s&&$("text",{...g,x:r,y:o.y+z,fontSize:z,opacity:.3,style:hn,children:"Label"})),i.includes("text")&&e!=="text"&&(t.text?l.map((d,f)=>xn("text",{...g,key:f,x:r,y:m+f*x,fontSize:I,style:Ce},d)):s&&$("text",{...g,x:r,y:m,fontSize:I,opacity:.3,style:hn,children:"Text"})),i.includes("footer")&&e!=="footer"&&(t.footer?u.map((d,f)=>xn("text",{...g,key:f,x:r,y:o.y+o.h-3-(u.length-1-f)*y,fontSize:z,opacity:.65,style:Ce},d)):s&&$("text",{...g,x:r,y:o.y+o.h-3,fontSize:z,opacity:.3,style:hn,children:"Footer"}))]})}function mr({shape:t,points:e}){let n=t.text??"",o=ot(n,gn,st),i=U(o.join(`
|
|
8
|
+
`),st),{x:r,y:a}=ke(e),s=st*et,l=a-(o.length-1)*s/2+st*.35;return jt("g",{children:[$("rect",{x:r-i.w/2-5,y:a-i.h/2-3,width:i.w+10,height:i.h+6,rx:5,className:"zui-drawing-label-plate",opacity:.94}),o.map((c,u)=>$("text",{x:r,y:l+u*s,fill:t.stroke,fontSize:st,textAnchor:"middle",style:Ce,children:c},u))]})}function Wo({shape:t,points:e,hideField:n,showHints:o,ink:i=!1}){let r={stroke:t.stroke,strokeWidth:t.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round"};if(A(t.type))return jt("g",{children:[i?$(zo,{shape:t}):$(Co,{shape:t,stroke:r}),$(gr,{shape:t,hideField:n,showHints:o})]});if(T(t.type)){let a=e??[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y+t.height}];return jt("g",{children:[i?$(Ho,{shape:t,points:a}):jt(wr,{children:[$("path",{...r,d:an(a),fill:"none"}),Po(t,a).map((s,l)=>$("path",{...r,d:s,fill:"none"},l))]}),t.text&&n!=="text"&&$(mr,{shape:t,points:a})]})}return $("text",{x:t.x,y:t.y+I,fill:t.stroke,fontSize:I,style:{userSelect:"none",whiteSpace:"pre"},children:(t.text??"").split(`
|
|
9
|
+
`).map((a,s)=>$("tspan",{x:t.x,dy:s===0?0:I*et,children:a},s))})}function Fo({shape:t,points:e}){if(T(t.type)&&e)return $("path",{d:an(e),fill:"none",stroke:"transparent",strokeWidth:16});let n=k(t);return $("rect",{x:n.x-2,y:n.y-2,width:Math.max(n.w,8)+4,height:Math.max(n.h,8)+4,fill:"transparent",stroke:"none"})}import{useEffect as br,useRef as Go,useState as Sr}from"react";import{jsx as Mr}from"react/jsx-runtime";function Ko({shape:t,field:e,points:n,onCommit:o}){let i=t[e]??"",[r,a]=Sr(i),s=Go(null),l=Go(r);l.current=r,br(()=>{let y=s.current;if(!y)return;y.focus(),y.select();let m=d=>{if(d.stopPropagation(),(d.key==="Home"||d.key==="End")&&!d.shiftKey&&!d.metaKey&&!d.ctrlKey){d.preventDefault();let f=y.value,P=d.key==="Home"?y.selectionStart:y.selectionEnd,b=d.key==="Home"?f.lastIndexOf(`
|
|
10
|
+
`,P-1)+1:(f.indexOf(`
|
|
11
|
+
`,P)+1||f.length+1)-1;y.setSelectionRange(b,b);return}d.key==="Enter"&&!d.shiftKey?(d.preventDefault(),o(t.id,e,l.current)):d.key==="Escape"&&(d.preventDefault(),o(t.id,e,i))},g=d=>d.stopPropagation();return y.addEventListener("keydown",m),y.addEventListener("keyup",g),y.addEventListener("keypress",g),()=>{y.removeEventListener("keydown",m),y.removeEventListener("keyup",g),y.removeEventListener("keypress",g)}},[]);let c={color:wn(t),fontFamily:"var(--zui-drawing-font)",lineHeight:et};if(t.type==="text"){let y=U(r||" ");Object.assign(c,{left:t.x,top:t.y,fontSize:I,width:Math.max(80,y.w+20),height:y.h+2,whiteSpace:"pre-wrap"})}else if(T(t.type)){let y=ot(r,gn,st),m=U(y.join(`
|
|
12
|
+
`)||" ",st),g=Math.max(70,m.w+16),d=m.h+4,f=ke(n??[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y+t.height}]);Object.assign(c,{left:f.x-g/2,top:f.y-d/2,width:g,height:d,fontSize:st,textAlign:"center",whiteSpace:"pre-wrap"})}else{let{area:y}=Oe(t),m=e==="text"?I:z,g=Math.max(y.w,40),f=ot(r,g,m).length*m*et+2,P=e==="label"?y.y-1:e==="footer"?y.y+y.h-f+1:y.y+y.h/2-f/2;Object.assign(c,{left:y.x,top:P,width:g,height:f,fontSize:m,fontWeight:e==="label"?600:void 0,letterSpacing:e==="label"?.3:void 0,opacity:e==="text"?1:e==="label"?.85:.65,textAlign:"center",whiteSpace:"pre-wrap"})}let u=K().drawing,x=e==="label"?u.labelPlaceholder:e==="footer"?u.footerPlaceholder:u.textPlaceholder;return Mr("textarea",{ref:s,className:"zui-drawing-text-input",style:c,value:r,placeholder:x,spellCheck:!1,onChange:y=>a(y.target.value),onBlur:()=>o(t.id,e,r),onPointerDown:y=>y.stopPropagation()})}import{useEffect as Pr,useRef as Dr,useState as bn}from"react";import{Fragment as Er,jsx as J,jsxs as vt}from"react/jsx-runtime";var kr=[{tool:"select",label:"select"},{tool:"rect",label:"rect"},{tool:"ellipse",label:"ellipse"},{tool:"diamond",label:"diamond"},{tool:"arrow",label:"arrow"},{tool:"line",label:"line"},{tool:"text",label:"text"}],Yo=["note","cylinder","cloud","queue","actor"];function Sn({label:t,active:e,onClick:n,children:o,className:i,pressed:r}){return J("button",{type:"button",title:t,"aria-label":t,"aria-pressed":r??e,className:`zui-drawing-tool ${e?"is-active":""} ${i??""}`,onClick:n,[ze]:"",children:J(yt,{children:o})})}function qo({tool:t,onToolChange:e,width:n,onWidthChange:o,onCopyMermaid:i,properties:r}){let[a,s]=bn(!1),[l,c]=bn("note"),[u,x]=bn(!1),y=Dr(null),m=Wn(),g=K(),d=g.drawing;Pr(()=>{if(!a)return;let b=_=>{y.current?.contains(_.target)||s(!1)},F=_=>{_.key==="Escape"&&s(!1)};return document.addEventListener("pointerdown",b),document.addEventListener("keydown",F),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",F)}},[a]);let f=Yo.includes(t),P=f?Vt[t]:Vt[l];return vt(Er,{children:[vt("div",{className:"zui-drawing-toolbar-group",role:"toolbar","aria-label":d.tools,...m,children:[kr.map(({tool:b,label:F})=>J(Sn,{label:d[F],active:t===b,onClick:()=>e(b),children:Vt[b]},b)),vt("div",{className:"zui-drawing-more",ref:y,children:[vt("button",{type:"button",title:d.moreShapes,"aria-label":d.moreShapes,"aria-haspopup":"menu","aria-expanded":a,className:`zui-drawing-tool zui-drawing-tool-more ${f?"is-active":""}`,onClick:()=>s(b=>!b),[ze]:"",children:[J(yt,{children:P}),J("span",{className:"zui-drawing-caret","aria-hidden":"true"})]}),a&&J("div",{className:"zui-drawing-popover",role:"menu",children:Yo.map(b=>vt("button",{type:"button",role:"menuitemradio","aria-checked":t===b,className:`zui-drawing-popover-item ${t===b?"is-active":""}`,onClick:()=>{c(b),e(b),s(!1)},children:[J(yt,{size:18,children:Vt[b]}),J("span",{children:d[b]})]},b))})]})]}),r,vt("div",{className:"zui-drawing-toolbar-group zui-drawing-toolbar-group-end",children:[J(Sn,{label:u?d.copiedMermaid:d.copyMermaid,className:u?"is-success":"",onClick:()=>{i().then(b=>{b&&(x(!0),setTimeout(()=>x(!1),1600))})},children:u?Z.check:Z.mermaid}),J("span",{className:"zui-drawing-toolbar-divider"}),zn.map(({preset:b,label:F,icon:_,width:ct})=>J(Sn,{label:g.layout[F],active:Hn(n)===b,onClick:()=>o(ct),children:_},b))]})]})}import{jsx as L,jsxs as ve}from"react/jsx-runtime";var Or=120,vr=1200,Ir={full:"",text:"is-text-width",content:"is-content-width"},_r=240,Ar=40,bt=new Set;function Br(t,e){let n=0;for(let o of t)if(T(o.type))for(let i of e.get(o.id)??[])n=Math.max(n,i.x);else{let i=k(o);n=Math.max(n,i.x+i.w)}return Math.max(_r,Math.ceil(n+Ar))}function $r(t){let e=new Map;for(let n of t)T(n.type)&&e.set(n.id,rn(n,t));return e}function Pn({nodeKey:t,data:e}){let[n]=Nr(),o=Cr(),[i,r]=Q(e.shapes),[a,s]=Q(e.canvasHeight),[l,c]=Q(e.width??"full"),u=Tr(An)?.drawingStyle==="ink",x=K().drawing,[y,m]=Q("select"),[g,d]=Q(bt),[f,P]=Q(null),[b,F]=Q(Dt[0]),[_,ct]=Q(Xn[0]),[_t,En]=Q(null),[Ie,Tn]=Q(null),[Rn,Nn]=Q(1),Qt=W(null),te=W(null),tt=W(null),ee=W(null),_e=W(null),St=W(null),ne=W(Y(e)),G=W(i);G.current=i;let Ae=W(a);Ae.current=a;let Cn=W(l);Cn.current=l;let At=W(g);At.current=g;let lt=Vo(()=>$r(i),[i]),oe=e.canvasWidth,V=oe??(l==="content"?Br(i,lt):null);Mn(()=>{let p=Y(e);p!==ne.current&&(ne.current=p,r(e.shapes),s(e.canvasHeight),c(e.width??"full"),d(bt),P(null))},[e]),Mn(()=>{let p=te.current;if(!V||!p||typeof ResizeObserver>"u"){Nn(1);return}let h=()=>{let w=p.getBoundingClientRect();Nn(w.width>0?w.width/V:1)};h();let S=new ResizeObserver(h);return S.observe(p),()=>S.disconnect()},[V]);let Bt=v((p,h)=>{let S=h?.width??Cn.current,w=h?.width===void 0&&e.width!==void 0,M={version:3,...oe?{canvasWidth:oe}:{},canvasHeight:h?.height??Ae.current,...S!=="full"||w?{width:S}:{},...e.title?{title:e.title}:{},...e.description?{description:e.description}:{},shapes:p},E=Y(M);E!==ne.current&&(ne.current=E,n.update(()=>{let N=Rr(t);Dn(N)&&N.setData(M)}))},[n,t,oe,e.width,e.title,e.description]),C=v((p,h)=>{r(S=>{let w=be(p(S));return h?.commit&&Bt(w),w})},[Bt]),it=v(p=>{let h=te.current;if(!h)return{x:0,y:0};let S=h.getScreenCTM();if(!S){let M=h.getBoundingClientRect();return{x:p.clientX-M.left,y:p.clientY-M.top}}let w=S.inverse();return{x:w.a*p.clientX+w.c*p.clientY+w.e,y:w.b*p.clientX+w.d*p.clientY+w.f}},[]),ht=Vo(()=>i.filter(p=>g.has(p.id)),[i,g]),Mt=ht.length===1?ht[0]:null,rt=v((p,h)=>{P({id:p,field:h}),d(new Set([p]))},[]),ie=p=>{te.current?.setPointerCapture(p.pointerId)},jo=v(p=>{if(!o||f||p.button!==0)return;let h=it(p);if(ie(p),y==="select"){p.shiftKey||d(bt),tt.current={mode:"marquee",origin:h,current:h,additive:p.shiftKey};return}if(y==="text"){let E=Ge(),N=U("");C(dt=>[...dt,{id:E,type:"text",x:h.x,y:h.y-I/2,width:N.w,height:N.h,stroke:b,fill:"transparent",strokeWidth:2,text:""}]),m("select"),d(new Set([E])),ee.current=E;return}let S=Ge(),w=A(y)?gt[y]:null,M=w?_==="transparent"&&w.defaultFill?w.defaultFill:_:"transparent";tt.current={mode:"draw",id:S,origin:h},d(bt),C(E=>[...E,{id:S,type:y,x:h.x,y:h.y,width:0,height:0,stroke:b,fill:M,strokeWidth:2}])},[o,f,it,y,b,_,C,rt]),Jo=v((p,h)=>{if(!o||y!=="select"||f||p.button!==0)return;p.stopPropagation();let S=it(p);ie(p);let w=At.current;if(p.shiftKey){if(w.has(h.id)){let dt=new Set(w);dt.delete(h.id),d(dt);return}let N=new Set(w).add(h.id);d(N),tt.current={mode:"move",clickedId:h.id,origin:S,origs:dn(G.current,N,h.id),wasSelected:!1};return}let M=w.size===1&&w.has(h.id),E=w.has(h.id)?w:new Set([h.id]);w.has(h.id)||d(E),tt.current={mode:"move",clickedId:h.id,origin:S,origs:dn(G.current,E,h.id),wasSelected:M}},[o,y,f,it]),Qo=v((p,h)=>{if(!(!o||p.button!==0)&&(p.stopPropagation(),ie(p),tt.current=h,h.mode==="endpoint")){let S=h.end==="start"?"startBinding":"endBinding";C(w=>w.map(M=>M.id===h.id?{...M,[S]:void 0}:M))}},[o,C]),On=v(()=>{St.current=null;let p=_e.current,h=tt.current;if(!(!p||!h)){if(h.mode==="marquee"){h.current=p,Tn({origin:h.origin,current:p});return}if(C(S=>ln(S,h,p)),h.mode==="endpoint"||h.mode==="draw"&&T(G.current.find(S=>S.id===h.id)?.type??"")){let S=Wt(G.current,p,h.id);En(w=>w===(S?.id??null)?w:S?.id??null)}}},[C]),ti=v(p=>{tt.current&&(_e.current=it(p),St.current===null&&(St.current=requestAnimationFrame(On)))},[it,On]),vn=v(p=>{let h=tt.current;if(tt.current=null,St.current!==null&&(cancelAnimationFrame(St.current),St.current=null),_e.current=null,En(null),ee.current){let w=ee.current;ee.current=null,rt(w,"text");return}if(!h)return;let S=it(p);if(h.mode==="marquee"){Tn(null);let w=cn(h.origin,S);if(w.w<Ut&&w.h<Ut)return;let M=Do(G.current,w,lt);d(E=>h.additive?new Set([...E,...M]):new Set(M));return}if(h.mode==="move"&&h.wasSelected){let w=Math.abs(S.x-h.origin.x)>Ut||Math.abs(S.y-h.origin.y)>Ut,M=G.current.find(E=>E.id===h.clickedId);if(!w&&M){C(E=>ln(E,h,h.origin)),M.type==="text"||T(M.type)?rt(M.id,"text"):rt(M.id,mn(M,h.origin.y));return}}if(h.mode==="draw"){let w=G.current.find(M=>M.id===h.id);if(w&&Math.abs(w.width)<4&&Math.abs(w.height)<4){if(w&&A(w.type)){let M=gt[w.type].defaultSize;C(E=>E.map(N=>N.id===h.id?{...N,x:N.x-M.w/2,y:N.y-M.h/2,w:M.w,h:M.h}:N),{commit:!0}),m("select"),d(new Set([h.id]))}else C(M=>M.filter(E=>E.id!==h.id));return}w&&T(w.type)&&C(M=>M.map(E=>E.id===h.id?so(E,M):E)),m("select"),d(new Set([h.id]))}h.mode==="endpoint"&&C(w=>w.map(M=>{if(M.id!==h.id)return M;let E=h.end==="start"?{x:M.x,y:M.y}:{x:M.x+M.width,y:M.y+M.height},N=Wt(w,E,M.id),dt=h.end==="start"?M.endBinding:M.startBinding;if(N&&N.id===dt?.id)return M;let yi=h.end==="start"?"startBinding":"endBinding";return{...M,[yi]:N?we(N,E):void 0}})),C(w=>w.map(Jn),{commit:!0})},[it,lt,C,rt]),Be=v(()=>{let p=At.current;p.size&&(P(null),d(bt),C(h=>h.filter(S=>!p.has(S.id)&&!(S.startBinding&&p.has(S.startBinding.id))&&!(S.endBinding&&p.has(S.endBinding.id))),{commit:!0}))},[C]),In=W(f);In.current=f,Mn(()=>{let p=Qt.current;if(!p||!o)return;let h=S=>{if(In.current)return;let w=At.current;if((S.key==="Delete"||S.key==="Backspace")&&w.size)S.preventDefault(),S.stopPropagation(),Be();else if(S.key==="Enter"&&w.size===1){let[M]=w,E=G.current.find(N=>N.id===M);E&&(S.preventDefault(),S.stopPropagation(),rt(E.id,"text"))}else S.key==="a"&&(S.metaKey||S.ctrlKey)&&!S.shiftKey&&!S.altKey?(S.preventDefault(),S.stopPropagation(),d(new Set(G.current.map(M=>M.id)))):S.key==="Escape"&&(S.stopPropagation(),d(bt),m("select"))};return p.addEventListener("keydown",h),()=>p.removeEventListener("keydown",h)},[o,Be,rt]);let Pt=v(p=>{let h=At.current;h.size&&C(S=>S.map(w=>h.has(w.id)?p(w):w),{commit:!0})},[C]),ei=v(p=>{let h=X[p];F(h.stroke),ct(h.fill),Pt(S=>A(S.type)?{...S,stroke:h.stroke,fill:h.fill}:{...S,stroke:h.stroke==="transparent"?Dt[0]:h.stroke})},[Pt]),ni=v(p=>Pt(h=>T(h.type)?{...h,routing:p?"elbow":void 0,elbow:void 0,waypoints:void 0}:h),[Pt]),oi=v(p=>Pt(h=>h.type==="arrow"?{...h,bidirectional:p||void 0}:h),[Pt]),ii=v(p=>{c(p),Bt(G.current,{width:p})},[Bt]),ri=v((p,h,S,w)=>{!o||p.button!==0||(p.stopPropagation(),ie(p),C(M=>M.map(E=>{if(E.id!==h||!T(E.type))return E;let N=rn(E,M).slice(1,-1),dt=[...N.slice(0,S),w,...N.slice(S)];return{...E,waypoints:dt,routing:void 0,elbow:void 0}})),tt.current={mode:"waypoint",id:h,index:S})},[o,C]),ai=v((p,h)=>{C(S=>S.map(w=>{if(w.id!==p||!w.waypoints)return w;let M=w.waypoints.filter((E,N)=>N!==h);return{...w,waypoints:M.length?M:void 0}}),{commit:!0})},[C]),si=v((p,h,S)=>{P(null),Qt.current?.focus({preventScroll:!0}),C(w=>w.flatMap(M=>M.id!==p?[M]:M.type==="text"?S.trim()===""?[]:[{...M,text:S,...U(S)}]:[{...M,[h]:S.trim()===""?void 0:S}]),{commit:!0})},[C]),ci=v(async()=>{let p={version:3,canvasHeight:Ae.current,shapes:G.current};try{return await navigator.clipboard.writeText(co(p)),!0}catch{return!1}},[]),re=i.find(p=>p.id===f?.id)??null,_n=_t?i.find(p=>p.id===_t):null,li=Mt?.stroke??ht[0]?.stroke??b,di=Mt?.fill??ht[0]?.fill??_,ui=y==="select"?"default":y==="text"?"text":"crosshair";return ve("div",{ref:Qt,className:`zui-drawing-canvas ${Ir[l]} ${o?"is-editable":""} ${u?"is-ink":""}`,tabIndex:o?0:void 0,onFocus:()=>n.dispatchCommand(Le,t),onBlur:p=>{Qt.current?.contains(p.relatedTarget)||n.dispatchCommand(Le,null)},children:[o&&L("div",{className:"zui-drawing-toolbar",onPointerDown:p=>p.stopPropagation(),children:L(qo,{tool:y,onToolChange:p=>{m(p),p!=="select"&&d(bt)},width:l,onWidthChange:ii,onCopyMermaid:ci,properties:L("div",{className:"zui-drawing-props-host",children:L(ko,{selection:ht,stroke:li,fill:di,onColor:ei,onRouting:ni,onDirection:oi,onDelete:Be})})})}),ve("div",{className:"zui-drawing-stage",children:[ve("svg",{ref:te,className:"zui-drawing-surface",role:"img","aria-label":e.title??x.canvas,"aria-description":e.description,style:{height:V?void 0:a,width:V??void 0,maxWidth:"100%",aspectRatio:V?`${V} / ${a}`:void 0,cursor:ui},viewBox:V?`0 0 ${V} ${a}`:void 0,preserveAspectRatio:"xMinYMin meet",onPointerDown:jo,onPointerMove:ti,onPointerUp:vn,onPointerCancel:vn,onDoubleClick:p=>{if(!o)return;let S=p.target.closest("[data-shape-id]")?.getAttribute("data-shape-id"),w=S?i.find(M=>M.id===S):null;w&&(w.type==="text"||T(w.type)?rt(w.id,"text"):rt(w.id,mn(w,it(p).y)))},children:[i.map(p=>ve("g",{"data-shape-id":p.id,className:`zui-drawing-shape ${g.has(p.id)?"is-selected":""}`,style:{cursor:o&&y==="select"?"move":void 0},onPointerDown:h=>Jo(h,p),children:[L(Fo,{shape:p,points:lt.get(p.id)}),p.id===f?.id&&p.type==="text"?null:L(Wo,{shape:p,ink:u,points:lt.get(p.id),hideField:p.id===f?.id?f.field:null,showHints:o&&y==="select"&&Mt?.id===p.id&&p.id!==f?.id})]},p.id)),_n&&L("polygon",{className:"zui-drawing-selection zui-drawing-bind-target",points:Gt(_n).map(p=>`${p.x},${p.y}`).join(" "),fill:"currentColor",fillOpacity:.06,stroke:"currentColor",strokeWidth:2,strokeLinejoin:"round",pointerEvents:"none"}),Mt&&o&&!f&&L(Eo,{shape:Mt,points:lt.get(Mt.id)??[],onHandlePointerDown:Qo,onWaypointAdd:ri,onWaypointRemove:ai}),ht.length>1&&o&&L(Ro,{shapes:ht,paths:lt}),Ie&&L(No,{rect:cn(Ie.origin,Ie.current)})]}),o&&i.length===0&&L("div",{className:"zui-drawing-empty","aria-hidden":"true",children:"Pick a shape above, then click or drag on the canvas"}),re&&f&&L("div",{className:"zui-drawing-overlay",style:{transform:`scale(${Rn})`,width:V??void 0,height:V?a:void 0},children:L(Ko,{shape:re,field:f.field,points:lt.get(re.id),onCommit:si},`${re.id}:${f.field}`)}),o&&L(Lr,{height:a,scale:Rn,onChange:s,onCommit:p=>Bt(G.current,{height:p})})]})]})}function Lr({height:t,scale:e,onChange:n,onCommit:o}){let i=W(null),r=W(t);r.current=t;let a=l=>Math.round(Math.min(vr,Math.max(Or,l))),s=K().drawing.resize;return L("div",{className:"zui-drawing-resize",title:s,role:"separator","aria-orientation":"horizontal",onPointerDown:l=>{l.preventDefault(),l.stopPropagation(),l.currentTarget.setPointerCapture(l.pointerId),i.current={startY:l.clientY,orig:t}},onPointerMove:l=>{let c=i.current;c&&n(a(c.orig+(l.clientY-c.startY)/Math.max(e,.05)))},onPointerUp:()=>{i.current&&(i.current=null,o(r.current))},children:L(yt,{size:14,children:Z.grip})})}import{jsx as Gr}from"react/jsx-runtime";var Wr=64,Jt=new Map;function Fr(t){let e=Jt.get(t);if(e)return e;let n=ye(t);if(Jt.size>=Wr){let o=Jt.keys().next().value;o!==void 0&&Jt.delete(o)}return Jt.set(t,n),n}var ft=class t extends Hr{static getType(){return"drawing"}static clone(e){return new t(e.__data,e.__key)}constructor(e,n){super(n),this.__data=e}static importJSON(e){return It(e.data)}exportJSON(){return{data:this.__data,type:"drawing",version:1}}createDOM(e){let n=document.createElement("div"),o=e.theme.drawing;return n.className=typeof o=="string"?o:"zui-drawing",n}updateDOM(){return!1}exportDOM(){let e=document.createElement("pre");return e.setAttribute("data-drawing",this.__data),{element:e}}static importDOM(){return{pre:e=>e.hasAttribute("data-drawing")?{conversion:n=>({node:It(Y(ye(n.getAttribute("data-drawing")??"")))}),priority:2}:null}}getData(){return Fr(this.getLatest().__data)}setData(e){let n=this.getWritable();n.__data=Y(e)}getBlockWidth(){return this.getData().width??"full"}setBlockWidth(e){let{width:n,...o}=this.getData();this.setData(e==="full"?o:{...o,width:e})}isInline(){return!1}decorate(e,n){return Gr(Pn,{nodeKey:this.getKey(),data:this.getData()})}};function It(t=Y(nt)){return zr(new ft(t))}function Dn(t){return t instanceof ft}var Uo=/^```\s*$/,Xo={dependencies:[ft],export:t=>Dn(t)?`\`\`\`drawing
|
|
13
|
+
${t.getLatest().__data}
|
|
14
|
+
\`\`\``:null,regExpStart:/^```drawing\s*$/,regExpEnd:Uo,replace:(t,e,n,o,i,r)=>{if(!r||e!=null||i==null)return!1;let a=ye(i.join(`
|
|
15
|
+
`).trim());t.append(It(Y(a)))},type:"multiline-element"},Zo={dependencies:[ft],export:()=>null,regExpStart:/^```diagram\s*$/,regExpEnd:Uo,replace:(t,e,n,o,i,r)=>{if(!r||e!=null||i==null)return!1;let a=go(i.join(`
|
|
16
|
+
`).trim());t.append(It(Y(a)))},type:"multiline-element"};import{useEffect as Kr}from"react";import{useLexicalComposerContext as Yr}from"@lexical/react/LexicalComposerContext";import{COMMAND_PRIORITY_EDITOR as qr}from"lexical";import{$insertNodeToNearestRoot as Vr}from"@lexical/utils";function kn(){let[t]=Yr();return Kr(()=>t.registerCommand(Ln,e=>{let n=e?.width,o=n===void 0?nt:{version:3,canvasHeight:nt.canvasHeight,width:n,shapes:[]};return Vr(It(Y(o))),!0},qr),[t]),null}import{jsx as Zr}from"react/jsx-runtime";var Ur=[...Bn,ft],Xr=[$e,Xo,Zo,...$n.filter(t=>t!==$e)],sc={nodes:Ur,transformers:Xr,plugins:Zr(kn,{})};export{de as a,ue as b,pi as c,A as d,nt as e,Dt as f,Xn as g,Ke as h,Y as i,ye as j,Ye as k,gt as l,Wt as m,we as n,co as o,X as p,Wi as q,go as r,Fi as s,fa as t,ft as u,It as v,Dn as w,Xo as x,Zo as y,kn as z,Ur as A,Xr as B,sc as C};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{a,c as g}from"./chunk-XRJNLGI4.js";import{$applyNodeReplacement as c,TextNode as p}from"lexical";function u(e){return e.replace(/[%)\s]/g,t=>t===")"?"%29":encodeURIComponent(t))}function m(e){try{return decodeURIComponent(e)}catch{return e}}var o=class e extends p{static getType(){return"mention"}static clone(t){return new e(t.__id,t.__name,t.__trigger,t.__key)}constructor(t,n,r="@",i){super(r+n,i),this.__id=t,this.__name=n,this.__trigger=r}static importJSON(t){return s(t.mentionId,t.mentionName,t.trigger).updateFromJSON(t)}exportJSON(){return{...super.exportJSON(),type:"mention",version:1,mentionId:this.__id,mentionName:this.__name,trigger:this.__trigger}}createDOM(t){let n=super.createDOM(t),r=t.theme.mention;return n.className=typeof r=="string"?r:"zui-mention",n.setAttribute("data-mention",this.__id),n.setAttribute("data-slot","mention"),n.spellcheck=!1,n}exportDOM(){let t=document.createElement("span");return t.setAttribute("data-lexical-mention",this.__id),t.setAttribute("data-trigger",this.__trigger),t.textContent=this.getTextContent(),{element:t}}static importDOM(){return{span:t=>t.hasAttribute("data-lexical-mention")?{conversion:n=>{let r=n.getAttribute("data-trigger")??"@",i=n.textContent??"",d=i.startsWith(r)?i.slice(r.length):i;return{node:s(n.getAttribute("data-lexical-mention")??"",d,r)}},priority:2}:null}}getMentionId(){return this.getLatest().__id}getMentionName(){return this.getLatest().__name}getTrigger(){return this.getLatest().__trigger}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}isTextEntity(){return!0}};function s(e,t,n="@"){let r=new o(e,t,n);return r.setMode("token").toggleDirectionless(),c(r)}function l(e){return e instanceof o}var _=/\[([^\w\s\]\\])((?:\\.|[^\]\\])+)\]\(mention:([^)\s]+)\)/,M=/\[([^\w\s\]\\])((?:\\.|[^\]\\])+)\]\(mention:([^)\s]+)\)$/,h={dependencies:[o],export:e=>l(e)?`[${e.getTrigger()}${a(e.getMentionName())}](mention:${u(e.getMentionId())})`:null,importRegExp:_,regExp:M,replace:(e,t)=>{let[,n,r,i]=t;e.replace(s(m(i),g(r),n))},trigger:")",type:"text-match"};export{o as a,s as b,l as c,h as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{a as I,b as E,c as m}from"./chunk-XRJNLGI4.js";import{c as d}from"./chunk-YFFSTMIR.js";import{useCallback as O,useEffect as L,useRef as D,useState as T}from"react";import{$applyNodeReplacement as C,$getNodeByKey as R,$getSelection as $,$isNodeSelection as k,CLICK_COMMAND as z,COMMAND_PRIORITY_LOW as w,DecoratorNode as v}from"lexical";import{useLexicalComposerContext as P}from"@lexical/react/LexicalComposerContext";import{useLexicalNodeSelection as K}from"@lexical/react/useLexicalNodeSelection";import{useLexicalEditable as B}from"@lexical/react/useLexicalEditable";import{mergeRegister as W}from"@lexical/utils";import{jsx as l,jsxs as Q}from"react/jsx-runtime";function M(t){return t.replace(/[\s()]/g,e=>e==="("?"%28":e===")"?"%29":encodeURIComponent(e))}var G={altText:"Alt text",altPlaceholder:"Describe the image",uploading:"Uploading image",insertImage:"Insert image"},S=new WeakMap;function ie(t,e){S.set(t,e)}function H(t){return S.get(t)??G}function U({nodeKey:t,src:e,alt:r,title:n,pending:a}){let[s]=P(),A=B(),[x,h,b]=K(t),u=H(s),p=D(null),[c,y]=T(r);L(()=>y(r),[r]),L(()=>W(s.registerCommand(z,i=>{let g=i.target;return!(g instanceof Node)||!p.current?.contains(g)||g instanceof HTMLElement&&g.closest("input")?!1:(i.shiftKey||b(),h(!0),!0)},w)),[s,h,b]);let N=O(()=>{s.update(()=>{let i=R(t);f(i)&&i.getAlt()!==c&&i.setAlt(c)})},[s,t,c]);return a?l("span",{ref:p,className:"zui-image-pending",role:"progressbar","aria-label":u.uploading,"aria-busy":"true","data-slot":"image-pending",children:l("span",{className:"zui-image-spinner","aria-hidden":"true"})}):Q("span",{ref:p,className:`zui-image-frame${x?" is-selected":""}`,"data-slot":"image",children:[l("img",{src:e,alt:r,title:n,draggable:!1}),x&&A&&l("span",{className:"zui-image-alt","data-slot":"image-alt",children:l("input",{type:"text",className:"zui-text-editor-link-input","aria-label":u.altText,placeholder:u.altPlaceholder,value:c,onChange:i=>y(i.target.value),onBlur:N,onKeyDown:i=>{(i.key==="Enter"||i.key==="Escape")&&(i.preventDefault(),N(),s.focus())}})})]})}var o=class t extends v{static getType(){return"image"}static clone(e){return new t(e.__src,e.__alt,e.__title,e.__pending,e.__key)}constructor(e,r="",n,a=!1,s){super(s),this.__src=M(e),this.__alt=r,this.__title=n,this.__pending=a}static importJSON(e){return _({src:e.src,alt:e.alt,title:e.title})}exportJSON(){return{type:"image",version:1,src:this.__src,alt:this.__alt,title:this.__title}}createDOM(e){let r=document.createElement("span"),n=e.theme.image;return r.className=typeof n=="string"?n:"zui-image",r}updateDOM(){return!1}exportDOM(){let e=document.createElement("img");return e.setAttribute("src",this.__src),e.setAttribute("alt",this.__alt),this.__title&&e.setAttribute("title",this.__title),{element:e}}static importDOM(){return{img:()=>({conversion:e=>{let r=e.getAttribute("src")??"";return!r||!d(r)?null:{node:_({src:r,alt:e.getAttribute("alt")??"",title:e.getAttribute("title")??void 0})}},priority:1})}}isInline(){return!0}isKeyboardSelectable(){return!0}getSrc(){return this.getLatest().__src}getAlt(){return this.getLatest().__alt}getTitle(){return this.getLatest().__title}isPending(){return this.getLatest().__pending}setSrc(e){let r=this.getWritable();return r.__src=M(e),r}setAlt(e){let r=this.getWritable();return r.__alt=e,r}setPending(e){let r=this.getWritable();return r.__pending=e,r}getTextContent(){return this.__pending?"":this.__alt}decorate(){return l(U,{nodeKey:this.__key,src:this.__src,alt:this.__alt,title:this.__title,pending:this.__pending})}};function _({src:t,alt:e="",title:r,pending:n=!1}){return C(new o(t,e,r,n))}function f(t){return t instanceof o}function ne(){let t=$();if(!k(t))return null;let e=t.getNodes();return e.length===1&&f(e[0])?e[0]:null}function J(t){let e=I(t.getAlt()),r=t.getTitle();return r?`} "${E(r)}")`:`})`}var Y=/!\[((?:\\.|[^\]\\])*)\]\(([^()\s]+)(?:\s"((?:\\.|[^"\\])*)")?\)/,F=/!\[((?:\\.|[^\]\\])*)\]\(([^()\s]+)(?:\s"((?:\\.|[^"\\])*)")?\)$/,se={dependencies:[o],export:t=>f(t)?t.isPending()?"":J(t):null,importRegExp:Y,regExp:F,replace:(t,e)=>{let[,r,n,a]=e;d(n)&&t.replace(_({src:n,alt:m(r),title:a===void 0?void 0:m(a)}))},trigger:")",type:"text-match"};export{G as a,ie as b,o as c,_ as d,f as e,ne as f,se as g};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{$createTextNode as l,$getRoot as c,$isElementNode as m}from"lexical";import{$createMarkNode as u,$isMarkNode as a,$unwrapMarkNode as p,MarkNode as g}from"@lexical/mark";import{$dfs as d}from"@lexical/utils";var x=/<!-- zui:comment ([^\s>]+) -->([\s\S]*?)<!-- \/zui:comment -->/,M=/<!-- zui:comment ([^\s>]+) -->([\s\S]*?)<!-- \/zui:comment -->$/;function $(e,t){return`<!-- zui:comment ${e.join(",")} -->${t}<!-- /zui:comment -->`}function N(e){return e.split(",").filter(t=>t.length>0)}var C={dependencies:[g],export:(e,t)=>a(e)?$(e.getIDs(),t(e)):null,importRegExp:x,regExp:M,replace:(e,t)=>{let[,r,o]=t,i=u(N(r)),n=l(o);return n.setFormat(e.getFormat()),i.append(n),e.replace(i),n},type:"text-match"};function f(){return d(c()).map(e=>e.node).filter(a)}function I(){let e=[];for(let t of f())for(let r of t.getIDs())e.includes(r)||e.push(r);return e}function z(e){let t=!1;for(let r of f())r.hasID(e)&&(t=!0,r.getIDs().length===1?p(r):r.deleteID(e));return t}function E(e){let t=0,r=o=>{if(o.is(e))return!0;if(m(o)){let i=o.getChildren();for(let n=0;n<i.length;n++){let s=i[n];if(r(s))return!0;m(s)&&!s.isInline()&&n<i.length-1&&(t+=2)}return!1}return t+=o.getTextContentSize(),!1};return r(c()),t}export{$ as a,N as b,C as c,f as d,I as e,z as f,E as g};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{b as G,e as S,g as Q,h as I,n as p,r as V,s as X,t as Y,u as j}from"./chunk-LDVPFZCN.js";import{b as z}from"./chunk-YFFSTMIR.js";import{$createParagraphNode as Le,$getNodeByKey as De,$getSelection as Oe,$isRangeSelection as Ee}from"lexical";import{$findMatchingParent as Ae}from"@lexical/utils";import{$createTableCellNode as Ie,$createTableRowNode as _e,$isTableCellNode as _,$isTableNode as Pe,$isTableRowNode as J,$isTableSelection as Fe,TableCellHeaderStates as T}from"@lexical/table";function y(e){return e.getChildren().filter(J)}function g(e){return e.getChildren().filter(_)}function O(e){let t=e?g(e):[];return t.length>0&&t.every(o=>o.hasHeaderState(T.ROW))}function F(e){let t=y(e)[0];return t?g(t).length:0}function P(e){return Ie(e).append(Le())}function E(e,t,o){let l=y(e),a=l[Math.max(0,Math.min(t,l.length-1))],i=a?g(a):[];i[Math.max(0,Math.min(o,i.length-1))]?.selectStart()}function He(){let e=Oe(),t=null;if(Fe(e)?t=De(e.anchor.key):Ee(e)&&(t=e.anchor.getNode()),!t)return null;let o=Ae(t,l=>_(l));return _(o)?o:null}function R(){let e=He(),t=e?.getParent(),o=t?.getParent();if(!e||!J(t)||!Pe(o))return null;let l=y(o);return{row:l.indexOf(t),column:g(t).indexOf(e),rows:l.length,columns:F(o),hasHeader:O(l[0])}}function Rt(e){let t=[];for(let o=e.hasHeader?1:0;o<=e.rows;o++)t.push(o);return t}function Ke(e){return e.rows>1}function Ue(e,t,o=0){let l=y(e),a=O(l[0])?1:0,i=Math.max(a,Math.min(t,l.length)),d=l[Math.max(0,i-1)]??l[0],m=d?g(d):[],h=_e();for(let x of m)h.append(P(x.hasHeaderState(T.COLUMN)?T.COLUMN:T.NO_STATUS));return m.length===0&&h.append(P(T.NO_STATUS)),i>=l.length?e.append(h):l[i].insertBefore(h),E(e,i,o),h}function qe(e,t,o=0){let l=y(e),a=l[t];if(!a||l.length<2)return!1;let i=t===0&&O(a);a.remove();let d=y(e);if(i)for(let m of g(d[0]))m.setHeaderStyles(T.ROW,T.ROW);return E(e,t,o),!0}function Z(e,t){let o=R();return o?Ue(e,t==="below"?o.row+1:o.row,o.column):null}function ee(e){let t=R();return!t||!Ke(t)?!1:qe(e,t.row,t.column)}function Bt(e){let t=[];for(let o=0;o<=e.columns;o++)t.push(o);return t}function ze(e){return e.columns>1}function Ge(e,t,o=0){let l=Math.max(0,Math.min(t,F(e)));for(let a of y(e)){let i=g(a),d=P(O(a)?T.ROW:T.NO_STATUS);l<i.length?i[l].insertBefore(d):a.append(d)}E(e,o,l)}function Qe(e,t,o=0){let l=F(e);if(t<0||t>=l||l<2)return!1;for(let a of y(e))g(a)[t]?.remove();return E(e,o,t),!0}function te(e,t){let o=R();return o?(Ge(e,t==="after"?o.column+1:o.column,o.row),!0):!1}function oe(e){let t=R();return!t||!ze(t)?!1:Qe(e,t.column,t.row)}import{useCallback as u,useEffect as Ve,useRef as Xe,useState as f}from"react";import{$createParagraphNode as Ye,$getNodeByKey as ie,$getSelection as v,$isRangeSelection as L,$isRootOrShadowRoot as je,CAN_REDO_COMMAND as Je,CAN_UNDO_COMMAND as Ze,COMMAND_PRIORITY_LOW as H,FORMAT_TEXT_COMMAND as et,REDO_COMMAND as tt,UNDO_COMMAND as ot}from"lexical";import{useLexicalComposerContext as nt}from"@lexical/react/LexicalComposerContext";import{INSERT_TABLE_COMMAND as lt}from"@lexical/table";import{$findMatchingParent as K,mergeRegister as rt}from"@lexical/utils";import{$setBlocksType as at}from"@lexical/selection";import{$createHeadingNode as it,$createQuoteNode as ct,$isHeadingNode as st,$isQuoteNode as dt}from"@lexical/rich-text";import{$isListNode as ne,INSERT_CHECK_LIST_COMMAND as ut,INSERT_ORDERED_LIST_COMMAND as bt,INSERT_UNORDERED_LIST_COMMAND as ht,REMOVE_LIST_COMMAND as le}from"@lexical/list";import{$isLinkNode as mt,TOGGLE_LINK_COMMAND as pt}from"@lexical/link";var Tt=["bold","italic","underline","strikethrough","code"];function ce(e){return e!==null&&typeof e.getBlockWidth=="function"&&typeof e.setBlockWidth=="function"}function $(){let e=v();if(!L(e))return null;let t=e.anchor.getNode(),o=t.getKey()==="root"?t:K(t,l=>{let a=l.getParent();return a!==null&&je(a)});if(o===null)return null;if(ne(o)){let a=(K(t,i=>ne(i)&&i.getParent()?.getType()!=="listitem")??o).getListType();return a==="bullet"?"bullet":a==="number"?"number":"check"}return st(o)?o.getTag():dt(o)?"quote":"paragraph"}function re(){let e=v();if(!L(e))return null;let t=K(e.anchor.getNode(),mt);return t?{key:t.getKey(),url:t.getURL()}:null}function ae(e){if(e===null)return null;let t=ie(e);return ce(t)?t.getBlockWidth():null}function B(){let[e]=nt(),{newBlockWidth:t}=G(),[o,l]=f(new Set),[a,i]=f(!1),[d,m]=f(!1),[h,x]=f(null),[de,ue]=f(null),[be,he]=f(null),[me,pe]=f(null),[Te,U]=f(!1),A=Xe(null),[fe,q]=f(null);Ve(()=>rt(e.registerUpdateListener(({editorState:r})=>{r.read(()=>{let c=p();x(c?Q(c):null),ue(c?R():null),q(ae(A.current)),he($());let b=re();pe(w=>w?.key===b?.key&&w?.url===b?.url?w:b);let W=v();if(!L(W)){l(new Set),U(!1);return}U(!W.isCollapsed());let C=new Set;for(let w of Tt)W.hasFormat(w)&&C.add(w);l(C)})}),e.registerCommand(V,r=>(A.current=r,q(e.getEditorState().read(()=>ae(r))),!1),H),e.registerCommand(Ze,r=>(i(r),!1),H),e.registerCommand(Je,r=>(m(r),!1),H)),[e]);let ke=u(r=>{e.dispatchCommand(et,r)},[e]),ye=u(({rows:r=3,columns:c=3,width:b=t.table}={})=>{let W=e.getEditorState().read(()=>p()?.getKey());e.dispatchCommand(lt,{columns:String(c),rows:String(r),includeHeaders:{rows:!0,columns:!1}}),b!==void 0&&e.update(()=>{let C=p();C&&C.getKey()!==W&&I(C,{width:b},{explicitWidth:!0})})},[e,t.table]),ge=u(({width:r=t.drawing}={})=>{e.dispatchCommand(X,r===void 0?void 0:{width:r})},[e,t.drawing]),Ne=u(r=>{if(r==="bullet"||r==="number"||r==="check"){if(e.getEditorState().read($)===r){e.dispatchCommand(le,void 0);return}let b=r==="bullet"?ht:r==="number"?bt:ut;e.dispatchCommand(b,void 0);return}e.update(()=>{let c=v();L(c)&&(($()==="bullet"||$()==="number"||$()==="check")&&e.dispatchCommand(le,void 0),at(c,()=>r==="paragraph"?Ye():r==="quote"?ct():it(r)))})},[e]),Me=u(r=>{r!==null&&!e.getEditorState().read(()=>{let b=v();return L(b)?!b.isCollapsed()||re()!==null:!1})||e.dispatchCommand(pt,r)},[e]),M=u(r=>{e.update(()=>{let c=p();c&&I(c,r)})},[e]),Ce=u(r=>M({width:r}),[M]),we=u(r=>M({density:r}),[M]),Re=u((r="below")=>{e.update(()=>{let c=p();c&&Z(c,r)})},[e]),Be=u(()=>{e.update(()=>{let r=p();r&&ee(r)})},[e]),xe=u((r="after")=>{e.update(()=>{let c=p();c&&te(c,r)})},[e]),We=u(()=>{e.update(()=>{let r=p();r&&oe(r)})},[e]),Se=u(r=>{let c=A.current;if(c===null){M({width:r});return}e.update(()=>{let b=ie(c);ce(b)&&b.setBlockWidth(r)})},[e,M]),$e=u(()=>{e.dispatchCommand(ot,void 0)},[e]),ve=u(()=>{e.dispatchCommand(tt,void 0)},[e]);return{editor:e,activeFormats:o,toggleFormat:ke,blockType:be,setBlockType:Ne,link:me,setLink:Me,hasSelection:Te,insertTable:ye,insertDrawing:ge,blockWidth:fe??h?.width??null,setBlockWidth:Se,tableWidth:h?.width??null,setTableWidth:Ce,tableDensity:h?.density??null,setTableDensity:we,tableCell:de,insertTableRow:Re,deleteTableRow:Be,insertTableColumn:xe,deleteTableColumn:We,canUndo:a,canRedo:d,undo:$e,redo:ve}}import{Fragment as D,jsx as n,jsxs as k}from"react/jsx-runtime";function Qt({children:e,className:t,label:o}){let l=j();return n("div",{className:`zui-text-editor-toolbar ${t??""}`,role:"toolbar","aria-label":o,"data-slot":"toolbar",...l,children:e??k(D,{children:[n(kt,{}),n(se,{}),n(gt,{}),n(se,{}),n(Nt,{})]})})}function se(){return n("div",{className:"zui-text-editor-toolbar-divider",role:"separator","aria-orientation":"vertical"})}function N({label:e,onClick:t,children:o,active:l=!1,disabled:a=!1,className:i}){return n("button",{type:"button",title:e,"aria-label":e,"aria-pressed":l,disabled:a,className:`zui-text-editor-toolbar-button ${l?"is-active":""} ${i??""}`,onMouseDown:d=>d.preventDefault(),onClick:t,[Y]:"",children:o})}function s({children:e,strokeWidth:t=1.5}){return n("svg",{viewBox:"0 0 20 20",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e})}var ft=[{format:"bold",label:"bold",icon:n(s,{strokeWidth:1.8,children:n("path",{d:"M6 3.5h5a3 3 0 0 1 0 6H6zm0 6h6a3 3 0 0 1 0 6H6z"})})},{format:"italic",label:"italic",icon:n(s,{strokeWidth:1.6,children:n("path",{d:"M8.5 3.5h6M5.5 16.5h6M11.5 3.5l-3 13"})})},{format:"strikethrough",label:"strikethrough",icon:n(s,{strokeWidth:1.6,children:n("path",{d:"M4 10h12M13.5 5.5c-.6-1.2-2-2-3.5-2-2 0-3.5 1.2-3.5 2.8 0 .5.1.9.4 1.3m-.4 5c.5 1.6 2 2.9 3.9 2.9 2 0 3.6-1.2 3.6-2.9 0-.4-.1-.8-.2-1.1"})})},{format:"code",label:"code",icon:n(s,{strokeWidth:1.6,children:n("path",{d:"M7.5 6L4 10l3.5 4M12.5 6L16 10l-3.5 4"})})}];function kt(){let{editor:e,activeFormats:t,toggleFormat:o,link:l,setLink:a,hasSelection:i}=B(),d=S().toolbar;return k(D,{children:[ft.map(({format:m,label:h,icon:x})=>n(N,{label:d[h],active:t.has(m),onClick:()=>o(m),children:x},m)),n(N,{label:l?d.removeLink:d.link,active:l!==null,disabled:l===null&&!i,onClick:()=>l?a(null):e.dispatchCommand(z,void 0),children:n(s,{strokeWidth:1.6,children:n("path",{d:"M8.5 11.5l3-3M11 6.5l1.5-1.5a2.5 2.5 0 0 1 3.5 3.5L14.5 10M9 13.5L7.5 15a2.5 2.5 0 0 1-3.5-3.5L5.5 10"})})})]})}var yt=[{type:"h1",label:"heading1",icon:n(s,{strokeWidth:1.6,children:n("path",{d:"M3 4.5v11M3 10h7M10 4.5v11M14.5 15.5v-6l-1.5 1"})})},{type:"h2",label:"heading2",icon:n(s,{strokeWidth:1.6,children:n("path",{d:"M3 4.5v11M3 10h7M10 4.5v11M13.5 10.5a1.5 1.5 0 0 1 3 0c0 1.5-3 2.5-3 5h3.2"})})},{type:"h3",label:"heading3",icon:n(s,{strokeWidth:1.6,children:n("path",{d:"M3 4.5v11M3 10h7M10 4.5v11M13.5 9.5h3l-2 2.5a1.5 1.5 0 1 1-1.2 2.5"})})},{type:"bullet",label:"bulletList",icon:k(s,{strokeWidth:1.6,children:[n("path",{d:"M7 5.5h10M7 10h10M7 14.5h10"}),n("circle",{cx:"3.5",cy:"5.5",r:"0.8",fill:"currentColor"}),n("circle",{cx:"3.5",cy:"10",r:"0.8",fill:"currentColor"}),n("circle",{cx:"3.5",cy:"14.5",r:"0.8",fill:"currentColor"})]})},{type:"number",label:"numberedList",icon:n(s,{strokeWidth:1.6,children:n("path",{d:"M8 5.5h9M8 10h9M8 14.5h9M3 4l1-.5v3.5M2.8 11.5a1 1 0 0 1 2 0c0 1-2 1.5-2 2.5h2.2"})})},{type:"check",label:"checklist",icon:n(s,{strokeWidth:1.6,children:n("path",{d:"M9 5.5h8M9 10h8M9 14.5h8M2.5 6l1.5 1.5 2.5-3M2.5 10.5l1.5 1.5 2.5-3"})})},{type:"quote",label:"quote",icon:n(s,{strokeWidth:1.6,children:n("path",{d:"M4 5v10M8 6h8M8 10h8M8 14h5"})})}];function gt(){let{blockType:e,setBlockType:t}=B(),o=S().toolbar;return n(D,{children:yt.map(({type:l,label:a,icon:i})=>n(N,{label:o[a],active:e===l,onClick:()=>t(e===l?"paragraph":l),children:i},l))})}function Nt({drawing:e=!0}={}){let{insertTable:t,insertDrawing:o}=B(),l=S().toolbar;return k(D,{children:[n(N,{label:l.insertTable,onClick:()=>t(),children:k(s,{children:[n("rect",{x:"3",y:"3.5",width:"14",height:"13",rx:"1.5"}),n("path",{d:"M3 8h14M8 8v8.5M13 8v8.5"})]})}),e&&n(N,{label:l.insertDrawing,onClick:()=>o(),children:k(s,{children:[n("rect",{x:"3",y:"5",width:"8",height:"6",rx:"1.5"}),n("path",{d:"M13.5 8h3M14.5 6.5L17.5 8l-3 1.5"}),n("ellipse",{cx:"13",cy:"14.5",rx:"4",ry:"2.8"})]})})]})}function Vt(){let{canUndo:e,canRedo:t,undo:o,redo:l}=B(),a=S().toolbar;return k(D,{children:[n(N,{label:a.undo,onClick:o,disabled:!e,children:k(s,{children:[n("path",{d:"M7 6L3.5 9.5 7 13"}),n("path",{d:"M3.5 9.5H12a4 4 0 0 1 0 8h-1"})]})}),n(N,{label:a.redo,onClick:l,disabled:!t,children:k(s,{children:[n("path",{d:"M13 6l3.5 3.5L13 13"}),n("path",{d:"M16.5 9.5H8a4 4 0 0 0 0 8h1"})]})})]})}export{He as a,R as b,Rt as c,Ke as d,Ue as e,qe as f,Z as g,ee as h,Bt as i,ze as j,Ge as k,Qe as l,te as m,oe as n,B as o,Qt as p,se as q,N as r,kt as s,gt as t,Nt as u,Vt as v};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{d as k,f as B,g as H}from"./chunk-A7MCBSAZ.js";import{a as h,b as R}from"./chunk-SDICQI2B.js";import{useCallback as U,useEffect as y,useMemo as ee,useRef as g,useState as x}from"react";import{useLexicalComposerContext as te}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as oe}from"@lexical/react/useLexicalEditable";import{$getSelection as E,$isRangeSelection as M,$isTextNode as S,COMMAND_PRIORITY_EDITOR as q,COMMAND_PRIORITY_HIGH as ne,KEY_DOWN_COMMAND as re,SELECTION_CHANGE_COMMAND as se,createCommand as ae}from"lexical";import{$createMarkNode as F,$getMarkIDs as ie,$isMarkNode as Y,$wrapSelectionInMarkNode as le,MarkNode as de}from"@lexical/mark";import{$findMatchingParent as ce,mergeRegister as G,registerNestedElementResolver as me}from"@lexical/utils";import{Fragment as j,jsx as f,jsxs as p}from"react/jsx-runtime";var ue={add:"Add comment",comments:"Comments",resolve:"Resolve",reopen:"Reopen",remove:"Delete comment",resolved:"Resolved",unknown:t=>`Comment ${t}`},Se={mark:"zui-comment",markOverlap:"zui-comment-overlap"},fe=ae("ADD_COMMENT_COMMAND");function ge(){let t=typeof crypto<"u"?crypto:void 0;return t&&typeof t.randomUUID=="function"?t.randomUUID():`c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function pe(t){return(t.metaKey||t.ctrlKey)&&t.shiftKey&&!t.altKey&&t.key.toLowerCase()==="m"}function ve(t){let n=E();if(!M(n)||n.isCollapsed())return null;let l=n.getTextContent();if(l.trim()==="")return null;let[r]=n.isBackward()?[n.focus]:[n.anchor],a=H(r.getNode())+(S(r.getNode())?r.offset:0);le(n,n.isBackward(),t,o=>F(o));let c=k().filter(o=>o.hasID(t)),m=c[c.length-1]?.getLastDescendant();return S(m)&&m.select(m.getTextContentSize(),m.getTextContentSize()),{id:t,quote:l,range:{start:a,end:a+l.length},resolved:!1}}function Ce(){let t=E();if(!M(t)||!t.isCollapsed())return[];let n=t.anchor.getNode();if(S(n)){let r=ie(n,t.anchor.offset);if(r&&r.length>0)return r;let a=n.getPreviousSibling();if(t.anchor.offset===0&&Y(a))return a.getIDs()}let l=ce(n,Y);return l?l.getIDs():[]}function W(t,n){let l=new Set(n.filter(r=>r.resolved).map(r=>r.id));t.getEditorState().read(()=>{for(let r of k()){let a=t.getElementByKey(r.getKey());if(!a)continue;let c=r.getIDs();a.classList.add("zui-comment"),a.setAttribute("data-slot","comment"),a.setAttribute("data-comment-ids",c.join(",")),a.classList.toggle("is-resolved",c.length>0&&c.every(m=>l.has(m)))}})}function ye({comments:t,onAdd:n,onResolve:l,onDelete:r,createId:a=ge,labels:c,renderComment:m}){let[o]=te(),A=oe(),u=ee(()=>({...ue,...c}),[c]),[L,J]=x(null),[b,Q]=x([]),[I,w]=x(null),T=g(n);T.current=n;let $=g(l);$.current=l;let O=g(r);O.current=r;let z=g(a);z.current=a;let _=g(t);_.current=t;let P=g(null),K=g(null),C=U(()=>{let e=ve(z.current());return e&&T.current?.(e),e!==null},[]),V=U(()=>{let e=!1;return o.update(()=>{e=C()},{discrete:!0}),e},[o,C]);y(()=>me(o,de,e=>F(e.getIDs()),(e,i)=>{for(let d of e.getIDs())i.addID(d)}),[o]),y(()=>G(o.registerCommand(fe,()=>C(),q),o.registerCommand(re,e=>{if(!pe(e))return!1;if(e.preventDefault(),C())return!0;let i=P.current?.querySelector("button");return i?(i.focus(),!0):!1},ne)),[o,C]),y(()=>{let e=()=>{let{hasRange:i,ids:d,key:v}=o.getEditorState().read(()=>{let s=E(),D=M(s)&&!s.isCollapsed()&&s.getTextContent().trim()!=="",N=M(s)?s.anchor.getNode().getKey():null;return{hasRange:D,ids:Ce(),key:N}});K.current=v,J(A&&i?h(o,R(o,v),"above"):null),Q(s=>s.length===d.length&&s.every((D,N)=>D===d[N])?s:d)};return e(),G(o.registerUpdateListener(e),o.registerCommand(se,()=>(e(),!1),q))},[o,A]),y(()=>{if(b.length===0){w(null);return}w(h(o,R(o,K.current),"below"))},[o,b]),y(()=>(W(o,t),o.registerUpdateListener(()=>W(o,_.current))),[o,t]);let X=e=>{let i=t.find(d=>d.id===e);$.current?.(e,!(i?.resolved??!1))},Z=e=>{o.update(()=>{B(e)}),O.current?.(e)};return p(j,{children:[L&&f("div",{className:"zui-text-editor-comment-add",style:L,"data-slot":"comment-add",children:p("button",{type:"button",className:"zui-text-editor-toolbar-button",title:u.add,onMouseDown:e=>e.preventDefault(),onClick:()=>V(),children:[p("svg",{viewBox:"0 0 20 20",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[f("path",{d:"M3 5.5A1.5 1.5 0 0 1 4.5 4h11A1.5 1.5 0 0 1 17 5.5v7a1.5 1.5 0 0 1-1.5 1.5H8l-4 3v-3h.5A1.5 1.5 0 0 1 3 12.5z"}),f("path",{d:"M10 7v5M7.5 9.5h5"})]}),f("span",{children:u.add})]})}),I&&b.length>0&&f("div",{ref:P,className:"zui-text-editor-comments",style:I,role:"group","aria-label":u.comments,"data-slot":"comments",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),o.getRootElement()?.focus({preventScroll:!0}),o.focus())},children:b.map(e=>{let i=t.find(s=>s.id===e)??{id:e,quote:"",resolved:!1},d=t.some(s=>s.id===e),v={resolve:()=>X(e),remove:()=>Z(e)};return f("div",{className:`zui-text-editor-comment${i.resolved?" is-resolved":""}`,"data-comment-id":e,children:m?m(i,v):p(j,{children:[p("div",{className:"zui-text-editor-comment-quote",children:[d?i.quote:u.unknown(e),i.resolved&&p("span",{className:"zui-text-editor-comment-state",children:[" ",u.resolved]})]}),p("div",{className:"zui-text-editor-comment-actions",children:[d&&f("button",{type:"button",className:"zui-text-editor-toolbar-button",onMouseDown:s=>s.preventDefault(),onClick:v.resolve,children:i.resolved?u.reopen:u.resolve}),f("button",{type:"button",className:"zui-text-editor-toolbar-button",onMouseDown:s=>s.preventDefault(),onClick:v.remove,children:u.remove})]})]})},e)})})]})}export{ue as a,Se as b,fe as c,ye as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{createContext as N,useContext as I}from"react";var b=N(null);function Y(){let e=I(b);if(!e)throw new Error("@zuilib/text-editor: this component must be rendered inside <MarkdownEditor> or <MarkdownEditor.Root>");return e}import{useContext as $}from"react";var m={placeholder:"Start writing...",toolbar:{bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",code:"Inline code",link:"Link",removeLink:"Remove link",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",paragraph:"Paragraph",bulletList:"Bullet list",numberedList:"Numbered list",checklist:"Checklist",quote:"Quote",insertTable:"Insert table",insertDrawing:"Insert drawing",undo:"Undo",redo:"Redo",linkUrl:"Link URL",linkUrlPlaceholder:"https://",linkApply:"Apply"},count:(e,t)=>t===void 0?String(e):`${e} / ${t}`,limitExceeded:e=>`Over the limit of ${e} characters`,limitRestored:e=>`Within the limit of ${e} characters`,outline:{show:"Show outline",hide:"Hide outline",title:"Table of contents",empty:"No headings",untitled:"Untitled"},collapsibleHeadings:{collapse:"Collapse section",expand:"Expand section",collapsed:"Section collapsed",expanded:"Section expanded"},table:{settings:"Table settings",rowInserted:"Row inserted",rowDeleted:"Row deleted",columnInserted:"Column inserted",columnDeleted:"Column deleted",addRow:"Add row",addColumn:"Add column",insertRowBefore:e=>`Insert row before row ${e}`,insertColumnBefore:e=>`Insert column before column ${e}`,deleteRow:e=>`Delete row ${e}`,deleteColumn:e=>`Delete column ${e}`},layout:{compact:"Compact (shrink to content, tight rows)",comfortable:"Comfortable (text width)",full:"Full width"},drawing:{canvas:"Drawing",tools:"Drawing tools",select:"Select",rect:"Rectangle",ellipse:"Ellipse",diamond:"Diamond",arrow:"Arrow",line:"Line",text:"Text",note:"Note",cylinder:"Database",cloud:"Cloud",queue:"Queue",actor:"Actor",moreShapes:"More shapes",copyMermaid:"Copy as Mermaid",copiedMermaid:"Copied Mermaid to clipboard",colors:"Color",color:e=>`Color ${e}`,connectorRouting:"Connector routing",straight:"Straight connector",elbow:"Elbow connector (auto-routed)",arrowDirection:"Arrow direction",oneWay:"One-way arrow",twoWay:"Two-way arrow",deleteShape:"Delete shape",deleteShapes:e=>`Delete ${e} shapes`,resize:"Drag to resize the canvas",waypoint:"Drag to move, double-click to remove",elbowHandle:"Slide the middle segment",labelPlaceholder:"Label",textPlaceholder:"Text",footerPlaceholder:"Footer"}};function S(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function R(e,t){if(!S(e)||!S(t))return t===void 0?e:t;let n={...e};for(let r of Object.keys(t))r in e&&(n[r]=R(e[r],t[r]));return n}function Z(e){return e?R(m,e):m}function ee(){return $(b)?.labels??m}import{$getNodeByKey as W,$getSelection as P,$isRangeSelection as B}from"lexical";import{$findMatchingParent as _}from"@lexical/utils";import{$isTableNode as f,$isTableSelection as H}from"@lexical/table";var D={width:"full",density:"comfortable"},k="--zui-text-editor-block-bleed",g={width:{full:{},content:{width:"auto","table-layout":"auto",[k]:"0px"},text:{[k]:"0px"}},density:{comfortable:{},compact:{"--zui-table-cell-padding":"0.25rem 0.5rem","--zui-table-font-size":"0.8125rem"},spacious:{"--zui-table-cell-padding":"0.875rem 1rem","--zui-table-font-size":"0.9375rem"}}},C=Object.keys(g),y="--zui-table-width";function h(e){let t=new Map;for(let n of e.split(";")){let r=n.indexOf(":");if(r===-1)continue;let o=n.slice(0,r).trim(),l=n.slice(r+1).trim();o&&l&&t.set(o,l)}return t}function z(e){return[...e].map(([t,n])=>`${t}: ${n}`).join("; ")}function M(e){return Object.entries(g[e])}function T(e,t){for(let[n,r]of M(t)){let o=Object.entries(r);if(o.length!==0&&o.every(([l,a])=>e.get(l)===a))return n}return D[t]}function F(e,t,n){for(let[,r]of M(t))for(let o of Object.keys(r))e.delete(o);for(let[r,o]of Object.entries(g[t][n]))e.set(r,o)}function A(e){let t=h(e.getStyle());return{width:T(t,"width"),density:T(t,"density")}}function v(e,t,n={}){let r=h(e.getStyle());for(let o of C){let l=t[o];l!==void 0&&F(r,o,l)}t.width!==void 0&&(n.explicitWidth?r.set(y,t.width):r.delete(y)),e.setStyle(z(r))}function ie(e){let t=h(e.getStyle());return t.get(y)===T(t,"width")}function le(e){return A(e).width}function se(e,t){v(e,{width:t})}function ae(e){return A(e).density}function de(e,t){v(e,{density:t})}function ce(){let e=P();if(H(e)){let n=W(e.tableKey);return f(n)?n:null}if(!B(e))return null;let t=_(e.anchor.getNode(),n=>f(n));return f(t)?t:null}var j=/^<!--\s*([a-z]+\s*:\s*[a-z]+(?:\s*;\s*[a-z]+\s*:\s*[a-z]+)*)\s*;?\s*-->\s*$/;function L(e,t){return t in g[e]}var ue="<!-- width: content -->";function ge(e){let t=j.exec(e);if(!t)return null;let n={},r=!1;for(let o of t[1].split(";")){let[l,a]=o.split(":").map(i=>i.trim());l!=="width"&&l!=="density"||(r=!0,l==="width"&&L("width",a)&&(n.width=a),l==="density"&&L("density",a)&&(n.density=a))}return r?n:null}function pe(e,t={}){let n=C.filter(r=>e[r]!==D[r]||r==="width"&&t.explicitWidth).map(r=>`${r}: ${e[r]}`);return n.length>0?`<!-- ${n.join("; ")} -->`:null}import{createCommand as K}from"lexical";var fe=K("DRAWING_FOCUS_COMMAND"),ye=K("INSERT_DRAWING_COMMAND");import{useCallback as w,useEffect as U,useRef as x}from"react";var G="data-toolbar-item",E=`[${G}]`;function q(e,t,n,r="horizontal",o=!1){if(n===0)return null;let[l,a]=r==="vertical"?["ArrowUp","ArrowDown"]:o?["ArrowRight","ArrowLeft"]:["ArrowLeft","ArrowRight"],i=Math.max(0,t);switch(e){case l:return(i-1+n)%n;case a:return(i+1)%n;case"Home":return 0;case"End":return n-1;default:return null}}function O(e){return Array.from(e.querySelectorAll(E)).filter(t=>{if(t.disabled)return!1;let n=t.closest('[role="menu"], [role="listbox"]');return!n||!e.contains(n)})}function we(e="horizontal"){let t=x(null),n=x(null),r=x(!1),o=w(i=>{let s=t.current;if(!s)return;let d=O(s),c=i&&d.includes(i)?i:d.includes(n.current)?n.current:d[0]??null;n.current=c;for(let u of d)u.tabIndex=u===c?0:-1},[]);U(()=>{let i=t.current;if(!i||(r.current=typeof getComputedStyle=="function"&&getComputedStyle(i).direction==="rtl",o(null),typeof MutationObserver>"u"))return;let s=new MutationObserver(()=>o(null));return s.observe(i,{childList:!0,subtree:!0,attributeFilter:["disabled"]}),()=>s.disconnect()},[o]);let l=w(i=>{let s=i.target;s!==n.current&&s.matches(E)&&o(s)},[o]),a=w(i=>{let s=t.current;if(!s||i.altKey||i.ctrlKey||i.metaKey)return;let d=i.target;if(!d.matches(E)||d.closest('[role="menu"], [role="listbox"]'))return;let c=O(s),u=c.indexOf(d),p=q(i.key,u,c.length,e,r.current);p!==null&&(i.preventDefault(),o(c[p]),c[p].focus())},[e,o]);return{ref:t,onKeyDown:a,onFocus:l,"aria-orientation":e}}export{b as a,Y as b,m as c,Z as d,ee as e,D as f,A as g,v as h,ie as i,le as j,se as k,ae as l,de as m,ce as n,ue as o,ge as p,pe as q,fe as r,ye as s,G as t,we as u};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{g as q,h as H,i as J,p as X,q as Y}from"./chunk-LDVPFZCN.js";var u=String.raw`//[^\n]*`,p=String.raw`/\*[^]*?(?:\*/|$)`,Z=String.raw`#[^\n]*`,f=String.raw`"(?:[^"\\\n]|\\[^])*"?`,h=String.raw`'(?:[^'\\\n]|\\[^])*'?`,O=String.raw`"""[^]*?(?:"""|$)`,Pe=String.raw`'''[^]*?(?:'''|$)`,V=String.raw`\`(?:[^\`\\]|\\[^])*\`?`,w=String.raw`\b(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)[a-zA-Z]*\b`,T=String.raw`@[\w.]+`,d=String.raw`(?<=\.\s*)[A-Za-z_$][\w$]*\b(?!\s*\()`,y=String.raw`[-+*/%=!<>&|^~?:]+`,g=String.raw`[{}()\[\];,.]`;var $t=String.raw`(?<=^|\n)[ \t]*#[ \t]*\w+[^\n]*`,tt={name:"c",aliases:["h","cpp","c++","cc","cxx","hpp","hh"],rules:[{type:"comment",match:u},{type:"comment",match:p},{type:"meta",match:$t},{type:"string",match:f},{type:"string",match:h},{type:"number",match:w},{type:"property",match:d},{type:"operator",match:String.raw`->|::|`+y},{type:"punctuation",match:g}],keywords:["auto","break","case","const","continue","default","do","else","enum","extern","for","goto","if","inline","register","restrict","return","sizeof","static","struct","switch","typedef","union","volatile","while","catch","class","const_cast","constexpr","consteval","delete","dynamic_cast","explicit","export","final","friend","mutable","namespace","new","noexcept","operator","override","private","protected","public","reinterpret_cast","static_cast","template","this","throw","try","typename","using","virtual"],types:["bool","char","double","float","int","long","short","signed","unsigned","void","wchar_t","size_t","ssize_t","int8_t","int16_t","int32_t","int64_t","uint8_t","uint16_t","uint32_t","uint64_t"],constants:["true","false","NULL","nullptr"],callIsFunction:!0,capitalizedIsType:!0};var et={name:"css",aliases:["scss","less","postcss"],rules:[{type:"comment",match:p},{type:"comment",match:u},{type:"keyword",match:String.raw`@[\w-]+|!\s*important\b`},{type:"variable",match:String.raw`--[\w-]+|\$[\w-]+`},{type:"string",match:f},{type:"string",match:h},{type:"tag",match:String.raw`(?<=(?:^|[{};]|\*/)\s*)[^{};@\s][^{};]*?(?=\s*\{)`},{type:"property",match:String.raw`(?<=[{;(]\s*)[-\w]+(?=\s*:)`},{type:"constant",match:String.raw`#[\da-fA-F]{3,8}\b`},{type:"function",match:String.raw`[-\w]+(?=\()`},{type:"number",match:String.raw`(?<![\w-])[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?(?:%|[a-zA-Z]+)?`},{type:"punctuation",match:String.raw`[{}()\[\];:,]`},{type:"operator",match:String.raw`[>+~*/=]`}]};var L=String.raw`[^\n]*`,M=String.raw`(?<=^|\n)`,rt={name:"diff",aliases:["patch"],rules:[{type:"comment",match:M+String.raw`(?:diff |index |--- |\+\+\+ |Index: |={3,}|\*{3} )`+L},{type:"meta",match:M+String.raw`@@`+L},{type:"inserted",match:M+String.raw`\+`+L},{type:"deleted",match:M+"-"+L}]};var nt={name:"go",aliases:["golang"],rules:[{type:"comment",match:u},{type:"comment",match:p},{type:"string",match:String.raw`\`[^\`]*\`?`},{type:"string",match:f},{type:"string",match:h},{type:"number",match:w},{type:"property",match:d},{type:"operator",match:String.raw`:=|<-|\.\.\.|`+y},{type:"punctuation",match:g}],keywords:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],types:["any","bool","byte","comparable","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"],builtins:["append","cap","clear","close","complex","copy","delete","imag","len","make","max","min","new","panic","print","println","real","recover"],constants:["true","false","nil","iota"],callIsFunction:!0,capitalizedIsType:!1};var at={name:"java",rules:[{type:"comment",match:u},{type:"comment",match:p},{type:"string",match:O},{type:"string",match:f},{type:"string",match:h},{type:"meta",match:T},{type:"number",match:w},{type:"property",match:d},{type:"operator",match:String.raw`->|::|`+y},{type:"punctuation",match:g}],keywords:["abstract","assert","break","case","catch","class","const","continue","default","do","else","enum","extends","final","finally","for","goto","if","implements","import","instanceof","interface","native","new","package","permits","private","protected","public","record","return","sealed","static","strictfp","super","switch","synchronized","this","throw","throws","transient","try","var","volatile","while","yield"],types:["boolean","byte","char","double","float","int","long","short","void"],constants:["true","false","null"],callIsFunction:!0,capitalizedIsType:!0};var Bt=String.raw`(?<=(?:^|[=(,:;!&|?{}\[+\-*%<>~^]|\breturn|\btypeof|\bcase|\bof|\bin)\s*)/(?![/*])(?:[^/\\\n\[]|\\[^]|\[(?:[^\]\\\n]|\\[^])*\])+/[dgimsuyv]*`,Gt=String.raw`(?<=<\/?)[A-Za-z][\w.:-]*`,v=[{type:"comment",match:u},{type:"comment",match:p},{type:"string",match:V},{type:"string",match:f},{type:"string",match:h},{type:"regex",match:Bt},{type:"meta",match:T},{type:"number",match:w},{type:"property",match:d},{type:"tag",match:Gt},{type:"operator",match:String.raw`=>|\.\.\.|`+y},{type:"punctuation",match:g}],U=["as","async","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","new","of","package","private","protected","public","return","set","static","super","switch","this","throw","try","typeof","var","void","while","with","yield"],$=["Array","BigInt","Boolean","Date","Error","JSON","Map","Math","Number","Object","Promise","Proxy","Reflect","RegExp","Set","String","Symbol","WeakMap","WeakSet","console","document","globalThis","window","parseFloat","parseInt","setTimeout","setInterval","clearTimeout","clearInterval","fetch","require","process"],B=["true","false","null","undefined","NaN","Infinity"],ot={name:"javascript",aliases:["js","jsx","mjs","cjs"],rules:v,keywords:U,builtins:$,constants:B,callIsFunction:!0,capitalizedIsType:!0};var it={name:"json",aliases:["jsonc","json5"],rules:[{type:"comment",match:String.raw`//[^\n]*|/\*[^]*?(?:\*/|$)`},{type:"property",match:String.raw`"(?:[^"\\\n]|\\[^])*"(?=\s*:)`},{type:"string",match:String.raw`"(?:[^"\\\n]|\\[^])*"?`},{type:"number",match:String.raw`-?\b\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b`},{type:"punctuation",match:String.raw`[{}\[\]:,]`}],constants:["true","false","null"]};var st={name:"kotlin",aliases:["kt","kts"],rules:[{type:"comment",match:u},{type:"comment",match:p},{type:"string",match:O},{type:"string",match:f},{type:"string",match:h},{type:"meta",match:T},{type:"number",match:w},{type:"property",match:d},{type:"operator",match:String.raw`->|\.\.|\?:|!!|`+y},{type:"punctuation",match:g}],keywords:["abstract","actual","annotation","as","break","by","catch","class","companion","const","constructor","continue","crossinline","data","do","else","enum","expect","external","final","finally","for","fun","get","if","import","in","infix","init","inline","inner","interface","internal","is","lateinit","noinline","object","open","operator","out","override","package","private","protected","public","reified","return","sealed","set","super","suspend","tailrec","this","throw","try","typealias","val","value","var","vararg","when","where","while"],builtins:["it","println","print","listOf","mutableListOf","mapOf","mutableMapOf","setOf","mutableSetOf","arrayOf","emptyList","emptyMap","lazy","require","check","error","TODO","apply","also","let","run","with","takeIf","takeUnless","repeat"],constants:["true","false","null"],callIsFunction:!0,capitalizedIsType:!0};var G=String.raw`(?<=^|\n)`,lt={name:"markdown",aliases:["md","mdx"],rules:[{type:"comment",match:String.raw`<!--[^]*?(?:-->|$)`},{type:"string",match:String.raw`\`\`\`[^]*?(?:\`\`\`|$)|\`[^\`\n]*\``},{type:"keyword",match:G+String.raw`#{1,6}[ \t][^\n]*`},{type:"meta",match:G+String.raw`(?:>|[-*+]|\d+\.)(?=\s)`},{type:"tag",match:String.raw`\*\*[^*\n]+\*\*|__[^_\n]+__`},{type:"variable",match:String.raw`(?<![*\w])\*[^*\n]+\*(?!\w)|(?<![_\w])_[^_\n]+_(?!\w)`},{type:"function",match:String.raw`!?\[[^\]\n]*\](?=\()`},{type:"string",match:String.raw`(?<=\]\()[^)\n]*(?=\))`},{type:"punctuation",match:G+String.raw`(?:---+|\*\*\*+|___+)(?=\n|$)`}]};var ct={name:"html",aliases:["xml","svg","xhtml","vue","markup","rss","atom"],rules:[{type:"comment",match:String.raw`<!--[^]*?(?:-->|$)`},{type:"string",match:String.raw`<!\[CDATA\[[^]*?(?:\]\]>|$)`},{type:"meta",match:String.raw`<![\w]+[^>]*>?|<\?[^]*?(?:\?>|$)`},{type:"tag",match:String.raw`(?<=<\/?)[A-Za-z][\w:.-]*`},{type:"string",match:String.raw`(?<=<[^>]*=\s*)(?:"[^"]*"|'[^']*')`},{type:"attr",match:String.raw`(?<=<[^>]*\s)[^\s"'<>/=]+`},{type:"punctuation",match:String.raw`<\/?|\/?>|(?<=<[^>]*)=`},{type:"constant",match:String.raw`&#?\w+;`}]};var R=String.raw`(?:\b[rRbBuUfF]{1,2})?`,Dt=String.raw`\b(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?[jJ]?)\b`,mt={name:"python",aliases:["py","py3"],rules:[{type:"comment",match:Z},{type:"string",match:R+String.raw`"""[^]*?(?:"""|$)`},{type:"string",match:R+String.raw`'''[^]*?(?:'''|$)`},{type:"string",match:R+String.raw`"(?:[^"\\\n]|\\[^])*"?`},{type:"string",match:R+String.raw`'(?:[^'\\\n]|\\[^])*'?`},{type:"meta",match:String.raw`@[\w.]+`},{type:"number",match:Dt},{type:"property",match:d},{type:"operator",match:String.raw`->|:=|\*\*|//|[-+*/%=!<>&|^~@]+`},{type:"punctuation",match:g+"|:"}],keywords:["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal","not","or","pass","raise","return","try","while","with","yield"],builtins:["self","cls","print","len","range","enumerate","zip","map","filter","sorted","reversed","open","input","abs","min","max","sum","any","all","iter","next","isinstance","issubclass","getattr","setattr","hasattr","super","type","id","hash","repr","format","vars","dir"],types:["int","float","str","bytes","bool","list","dict","set","tuple","object","complex","frozenset"],constants:["True","False","None","Ellipsis","NotImplemented"],callIsFunction:!0,capitalizedIsType:!0};var Pt=String.raw`\b(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)(?:[iuf](?:8|16|32|64|128|size))?\b`,pt={name:"rust",aliases:["rs"],rules:[{type:"comment",match:u},{type:"comment",match:p},{type:"meta",match:String.raw`#!?\[[^\]\n]*\]`},{type:"string",match:String.raw`b?r#*"[^]*?(?:"#*|$)`},{type:"string",match:String.raw`b?"(?:[^"\\]|\\[^])*"?`},{type:"string",match:String.raw`b?'(?:[^'\\\n]|\\[^])'`},{type:"variable",match:String.raw`'[a-z_]\w*\b(?!')`},{type:"function",match:String.raw`\b[a-z_]\w*!(?=[\s(\[{])`},{type:"number",match:Pt},{type:"property",match:d},{type:"operator",match:String.raw`->|=>|::|\.\.=?|`+y},{type:"punctuation",match:g+"|#"}],keywords:["as","async","await","break","const","continue","crate","dyn","else","enum","extern","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","Self","static","struct","super","trait","type","union","unsafe","use","where","while"],types:["bool","char","f32","f64","i8","i16","i32","i64","i128","isize","str","u8","u16","u32","u64","u128","usize","String","Vec","Option","Result","Box","Rc","Arc","HashMap","HashSet"],constants:["true","false","None","Some","Ok","Err"],callIsFunction:!0,capitalizedIsType:!0};var ut={name:"shell",aliases:["sh","bash","zsh","console","shellsession"],rules:[{type:"variable",match:String.raw`\$\{[^}\n]*\}|\$\w+|\$[@#?*!$-]`},{type:"comment",match:String.raw`(?<=^|\s)#[^\n]*`},{type:"string",match:String.raw`"(?:[^"\\\n]|\\[^])*"?`},{type:"string",match:String.raw`'[^'\n]*'?`},{type:"punctuation",match:String.raw`(?<=^|\n)[$#](?=\s)`},{type:"attr",match:String.raw`(?<=\s)--?[A-Za-z][\w-]*`},{type:"operator",match:String.raw`\|\|?|&&?|;;?|[<>]+|=`},{type:"punctuation",match:String.raw`[(){}\[\]]`}],identifier:String.raw`[A-Za-z_][\w.-]*`,keywords:["if","then","else","elif","fi","for","while","until","do","done","case","esac","in","function","select","time","return","exit","local","export","readonly","declare","set","unset","shift","source","alias","break","continue"],builtins:["echo","cd","ls","pwd","cat","grep","sed","awk","mkdir","rm","cp","mv","chmod","chown","curl","wget","git","npm","pnpm","yarn","npx","node","python","python3","pip","docker","kubectl","sudo","test","printf","read","eval","exec","trap","wait","kill","ps","tar","zip","unzip","touch","find","xargs","sort","uniq","head","tail","wc","tee","which","env","ssh","scp","make","cargo","go","brew","apt","apt-get","gradle","mvn","java","jq","true","false"]};var dt={name:"sql",aliases:["mysql","postgres","postgresql","pgsql","plsql","sqlite","soql"],caseInsensitive:!0,rules:[{type:"comment",match:String.raw`--[^\n]*`},{type:"comment",match:p},{type:"string",match:String.raw`'(?:[^'\n]|'')*'?`},{type:"variable",match:String.raw`[@:]\w+|\$\d+`},{type:"number",match:String.raw`\b\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b`},{type:"operator",match:String.raw`\|\||::|[-+*/%=<>!]+`},{type:"punctuation",match:String.raw`[(),;.]`}],keywords:["add","all","alter","and","as","asc","begin","between","by","cascade","case","check","column","commit","constraint","create","cross","default","delete","desc","distinct","drop","else","end","except","exists","foreign","from","full","group","having","if","in","index","inner","insert","intersect","into","is","join","key","left","like","limit","not","null","offset","on","or","order","outer","primary","references","returning","right","rollback","select","set","table","then","top","transaction","truncate","union","unique","update","using","values","view","when","where","with","recursive","ilike","over","partition","window","rows","range","fetch","first","next","only","nulls","last","explain","analyze","grant","revoke","schema","database","trigger","procedure","function","returns","declare","cursor","loop","while","for","exec","execute","merge","matched","replace","ignore","conflict","do","nothing","nowait","lock","share","lateral","natural","any","some","escape"],types:["int","integer","bigint","smallint","tinyint","varchar","char","text","boolean","bool","date","timestamp","timestamptz","time","interval","decimal","numeric","float","real","double","serial","bigserial","uuid","json","jsonb","bytea","blob","array","money","precision","varying"],builtins:["count","sum","avg","min","max","coalesce","now","cast","concat","lower","upper","length","substring","round","trim","nullif","greatest","least","array_agg","string_agg","json_agg","row_number","rank","dense_rank","date_trunc","extract","current_date","current_timestamp","current_user","exists","abs","ceil","floor","random","generate_series"],constants:["true","false","null","unknown"],callIsFunction:!0};var zt=String.raw`(?<=<)[A-Za-z_$][\w$]*(?=[,>\s|&\[])`,gt={name:"typescript",aliases:["ts","tsx","mts","cts"],rules:[{type:"type",match:zt},...v],keywords:[...U,"abstract","asserts","declare","infer","is","keyof","module","namespace","override","readonly","satisfies","type","unique","accessor","out"],types:["any","bigint","boolean","never","null","number","object","string","symbol","undefined","unknown","void"],builtins:[...$,"Partial","Required","Readonly","Record","Pick","Omit","Exclude","Extract","NonNullable","ReturnType","Parameters","Awaited"],constants:B,callIsFunction:!0,capitalizedIsType:!0};var Ft=String.raw`(?<=^|\n)`,Wt=String.raw`(?<=^|\n|\s|-\s)(?:"(?:[^"\\\n]|\\[^])*"|'(?:[^'\n]|'')*'|[^\s"'#\-\[\]{},:!&*?|>][^:#\n]*?)(?=:(?:\s|$))`,ft={name:"yaml",aliases:["yml"],rules:[{type:"comment",match:String.raw`(?<=^|\s)#[^\n]*`},{type:"meta",match:Ft+String.raw`(?:---|\.\.\.)(?=\s|$)`},{type:"property",match:Wt},{type:"variable",match:String.raw`[&*][\w-]+`},{type:"meta",match:String.raw`![\w!/:-]*`},{type:"string",match:String.raw`"(?:[^"\\\n]|\\[^])*"?`},{type:"string",match:String.raw`'(?:[^'\n]|'')*'?`},{type:"punctuation",match:String.raw`(?<=:\s*)[|>][-+]?\d*(?=[ \t]*(?:\n|$|#))`},{type:"punctuation",match:String.raw`(?<=^|\n|\s)-(?=\s)|[\[\]{},:]`},{type:"constant",match:String.raw`(?<=:\s)~(?=\s|$)`},{type:"number",match:String.raw`(?<![\w.-])[-+]?(?:0x[\da-fA-F]+|\d[\d_]*(?:\.\d*)?(?:[eE][+-]?\d+)?|\.inf|\.nan)(?![\w.-])`}],constants:["true","false","null","yes","no","on","off","True","False","Null","Yes","No","On","Off","TRUE","FALSE","NULL","YES","NO","ON","OFF"]};var ht=[ot,gt,st,at,tt,mt,nt,pt,it,ft,ut,dt,et,ct,rt,lt];var z="plain",D={name:z,aliases:["plaintext","text","txt"],rules:[]},N=new Map,yt=!1;function F(t){return t.trim().toLowerCase()}function P(t){for(let e of[t.name,...t.aliases??[]])N.set(F(e),t)}function A(){if(!yt){yt=!0,P(D);for(let t of ht)P(t)}}function Ir(t){A(),P(t)}function kr(t){return A(),N.has(F(t))}function vr(t){if(A(),!t)return D;let e=F(t);return N.get(e)??(e.startsWith("diff-")?N.get("diff"):void 0)??D}function Ur(){return A(),[...new Set([...N.values()].map(t=>t.name))].sort()}import{$applyNodeReplacement as jt,$createLineBreakNode as Kt,$createTextNode as Qt,ElementNode as qt}from"lexical";var E=class t extends qt{static getType(){return"frontmatter"}static clone(e){return new t(e.__key)}constructor(e){super(e)}createDOM(e){let r=document.createElement("div"),n=e.theme.frontmatter;return r.className=typeof n=="string"?n:"zui-frontmatter",r}updateDOM(){return!1}static importJSON(e){return St()}exportJSON(){return{...super.exportJSON(),type:"frontmatter",version:1}}isInline(){return!1}canBeEmpty(){return!1}canIndent(){return!1}};function St(){return jt(new E)}function Ht(t){return t instanceof E}var wt=/^---\s*$/,Et={dependencies:[E],export:t=>{if(!Ht(t))return null;let e=t.getTextContent();return e?`---
|
|
3
|
+
${e}
|
|
4
|
+
---`:`---
|
|
5
|
+
---`},regExpStart:wt,regExpEnd:wt,replace:(t,e,r,n,s,l)=>{if(!l||e!=null||s==null||t.getChildrenSize()!==0)return!1;let o=[...s];for(;o.length>0&&o[0].length===0;)o.shift();for(;o.length>0&&o[o.length-1].length===0;)o.pop();let a=St();o.forEach((m,i)=>{i>0&&a.append(Kt()),a.append(Qt(m))}),t.append(a)},type:"multiline-element"};import{$isParagraphNode as Nt,$isTextNode as Ct}from"lexical";import{$convertFromMarkdownString as Jt,$convertToMarkdownString as Xt,TRANSFORMERS as _t}from"@lexical/markdown";import{$createTableCellNode as Yt,$createTableNode as Zt,$createTableRowNode as Vt,$isTableCellNode as I,$isTableNode as W,$isTableRowNode as C,TableCellHeaderStates as _,TableCellNode as te,TableNode as ee,TableRowNode as re}from"@lexical/table";var xt=/^\|(.+)\|\s?$/,ne=/^(\| ?:?-+:? ?)+\|\s?$/,ae=/(?<!\\)\|/,Tt="text-align";function oe(t){let e=t.trim(),r=e.startsWith(":"),n=e.endsWith(":");return r&&n?"center":n?"right":r?"left":null}function ie(t){return t==="center"?":---:":t==="right"?"---:":t==="left"?":---":"---"}function se(t){let e=t.getStyle().match(/(?:^|;)\s*text-align\s*:\s*(left|center|right)\s*(?:;|$)/);return e?e[1]:null}function le(t,e){let r=t.getStyle().split(";").map(n=>n.trim()).filter(n=>n&&!n.replace(/\s/g,"").startsWith(`${Tt}:`));e&&r.push(`${Tt}: ${e}`),t.setStyle(r.join("; "))}function ce(t,e){for(let r of t.getChildren())C(r)&&r.getChildren().forEach((n,s)=>{I(n)&&e[s]&&le(n,e[s])})}function me(t){if(!Nt(t)||t.getChildrenSize()!==1)return null;let e=t.getFirstChild();return Ct(e)?X(e.getTextContent()):null}function pe(t){let e=t.getFirstChild();return C(e)?e.getChildrenSize():0}function j(t){let e=t.replace(/\\n/g,`
|
|
6
|
+
`).replace(/\\\|/g,"|"),r=Yt(_.NO_STATUS);return Jt(e,_t,r,!0),r}function ue(t){return Xt(_t,t,!0).replace(/\|/g,"\\|").replace(/\n/g,"\\n")}function bt(t){let e=t.match(xt);return!e||!e[1]?null:e[1].split(ae).map(r=>j(r.trim()))}function de(t,e){let r=t.getFirstChild(),n=I(r)?r.__headerState:_.NO_STATUS;for(;t.getChildrenSize()<e;)t.append(j("").setHeaderStyles(n,n))}var Ot={dependencies:[ee,re,te],export:t=>{if(!W(t))return null;let e=[],r=Y(q(t),{explicitWidth:J(t)});r&&e.push(r);for(let n of t.getChildren()){if(!C(n))continue;let s=[],l=[],o=!1;for(let a of n.getChildren())I(a)&&(s.push(ue(a)),l.push(se(a)),a.__headerState===_.ROW&&(o=!0));e.push(`| ${s.join(" | ")} |`),o&&e.push(`| ${l.map(ie).join(" | ")} |`)}return e.join(`
|
|
7
|
+
`)},regExp:xt,replace:(t,e,r)=>{if(ne.test(r[0])){let i=t.getPreviousSibling();if(!i||!W(i))return;let c=i.getLastChild();if(!c||!C(c))return;c.getChildren().forEach(S=>{I(S)&&S.setHeaderStyles(_.ROW,_.ROW)}),ce(i,r[0].split("|").slice(1,-1).map(oe)),t.remove();return}let n=bt(r[0]);if(n==null)return;let s=[n],l=t.getPreviousSibling(),o=n.length;for(;l&&!(!Nt(l)||l.getChildrenSize()!==1);){let i=l.getFirstChild();if(!Ct(i))break;let c=bt(i.getTextContent());if(c==null)break;o=Math.max(o,c.length),s.unshift(c);let S=l.getPreviousSibling();l.remove(),l=S}let a=Zt();for(let i of s){let c=Vt();a.append(c);for(let S=0;S<o;S++)c.append(S<i.length?i[S]:j(""))}let m=t.getPreviousSibling();if(W(m)){let i=Math.max(pe(m),o);for(let c of[...m.getChildren(),...a.getChildren()])C(c)&&de(c,i);m.append(...a.getChildren()),t.remove()}else{let i=me(m);i&&(H(a,i,{explicitWidth:!0}),m?.remove()),t.replace(a)}a.selectEnd()},type:"element"};import{$isListItemNode as ge,$isListNode as Lt,ListItemNode as fe,ListNode as he}from"@lexical/list";var x=/^([ \t]*)(?:[-*+]|\d{1,}\.)\s/,k=4;function ye(t){let e=0;for(let r of t)e+=r===" "?k:1;return e}function we(t,e){let r=e;for(;r<t.length&&x.test(t[r]);)r++;let n=[];for(let a=e;a<r;a++)n.push(ye(t[a].match(x)[1]));if(n.every(a=>a%k===0))return r;let s=t[e].match(x)[1],l=(s.match(/\t/g)??[]).length+Math.floor((s.match(/ /g)??[]).length/k),o=[n[0]];for(let a=1;a<n.length;a++){let m=n[a];for(;o.length>1&&m<o[o.length-1];)o.pop();m>o[o.length-1]&&o.push(m);let i=l+o.length-1,c=t[e+a];t[e+a]=" ".repeat(i*k)+c.slice(c.match(x)[1].length)}return r}function Mt(t,e,r){let n=[],s=t.getListType(),l=0,o=r+" ";for(let a of t.getChildren()){if(!ge(a))continue;let m=a.getFirstChild();if(a.getChildrenSize()===1&&Lt(m)){n.push(Mt(m,e,o));continue}let i=s==="number"?`${t.getStart()+l}. `:s==="check"?`- [${a.getChecked()?"x":" "}] `:"- ";n.push(r+i+e(a)),o=r+" ".repeat(s==="number"?i.length:2),l++}return n.join(`
|
|
8
|
+
`)}var Rt={dependencies:[he,fe],export:(t,e)=>Lt(t)?Mt(t,e,""):null,regExpStart:x,handleImportAfterStartMatch:({lines:t,startLineIndex:e})=>(we(t,e),null),replace:()=>!1,type:"multiline-element"};import{CODE as At}from"@lexical/markdown";import{$isCodeNode as It}from"@lexical/code";var Se=/^[ \t]*```([^`\n]*)/,kt="--zui-code-meta",Ee=/(?:^|;)\s*--zui-code-meta\s*:\s*"((?:[^"\\]|\\.)*)"\s*(?:;|$)/;function Te(t){let e=t.getStyle().match(Ee);return e?e[1].replace(/\\(.)/g,"$1"):""}function be(t,e){let r=t.getStyle().split(";").map(n=>n.trim()).filter(n=>n&&!n.startsWith(kt));e&&r.push(`${kt}: "${e.replace(/["\\]/g,"\\$&")}"`),t.setStyle(r.join("; "))}function Ne(t){let e=t.trim(),r=e.search(/\s/);return r===-1?[e,""]:[e.slice(0,r),e.slice(r).trim()]}var vt={...At,regExpStart:Se,replace:(t,e,r,n,s,l)=>{let[o,a]=Ne(r[1]??""),m=[...r];m[1]=o;let i=At.replace(t,e,m,n,s,l);if(i===!1)return!1;let c=t.getLastChild();return a&&!e&&It(c)&&be(c,a),i},export:t=>{if(!It(t))return null;let e=t.getLanguage(),r=Te(t),n=(e===z?"":e||"")+(r?" "+r:""),s=t.getTextContent();return"```"+n+(s?`
|
|
9
|
+
`+s:"")+"\n```"}};import{CHECK_LIST as Ut,CODE as Ce,TRANSFORMERS as _e}from"@lexical/markdown";import{HeadingNode as xe,QuoteNode as Oe}from"@lexical/rich-text";import{ListItemNode as Le,ListNode as Me}from"@lexical/list";import{CodeHighlightNode as Re,CodeNode as Ae}from"@lexical/code";import{AutoLinkNode as Ie,LinkNode as ke}from"@lexical/link";import{TableCellNode as ve,TableNode as Ue,TableRowNode as $e}from"@lexical/table";var Be=[xe,Me,Le,Oe,Ae,Re,Ie,ke,E,Ue,$e,ve],Ge=[Et,Rt,Ut,Ot,vt,..._e.filter(t=>t!==Ce)],sn={nodes:Be,transformers:Ge};function ln(t,e){return e===void 0?[...t]:typeof e=="function"?[...e(t)]:[...e,...t.filter(r=>!e.includes(r))]}function cn(t){return t.filter(e=>e.type!=="multiline-element"&&e!==Ut)}var De=["full","text","content"];function pn(t){return typeof t=="string"&&De.includes(t)}import{Fragment as K,jsx as b,jsxs as Q}from"react/jsx-runtime";var dn=[{preset:"compact",label:"compact",width:"content",density:"compact",icon:Q(K,{children:[b("path",{d:"M3 4v12M17 4v12"}),b("path",{d:"M5.5 10h3M11.5 10h3M6.5 7.5L9 10l-2.5 2.5M13.5 7.5L11 10l2.5 2.5"})]})},{preset:"comfortable",label:"comfortable",width:"text",density:"comfortable",icon:Q(K,{children:[b("path",{d:"M3 4v12M17 4v12"}),b("path",{d:"M6.5 7h7M6.5 10h7M6.5 13h4.5"})]})},{preset:"full",label:"full",width:"full",density:"comfortable",icon:Q(K,{children:[b("path",{d:"M3 4v12M17 4v12"}),b("path",{d:"M6 10h8M8.5 7.5L6 10l2.5 2.5M11.5 7.5L14 10l-2.5 2.5"})]})}];function gn(t){return t==="content"?"compact":t==="text"?"comfortable":"full"}export{ht as a,z as b,D as c,Ir as d,kr as e,vr as f,Ur as g,E as h,St as i,Ht as j,Et as k,Ot as l,Rt as m,vt as n,Be as o,Ge as p,sn as q,ln as r,cn as s,dn as t,gn as u,De as v,pn as w};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{a as y,b,d as I,e as R}from"./chunk-7Z3CW6Q3.js";import{r as E}from"./chunk-AGTPMKLK.js";import{c as f}from"./chunk-YFFSTMIR.js";import{useEffect as L,useMemo as T,useRef as A}from"react";import{useLexicalComposerContext as O}from"@lexical/react/LexicalComposerContext";import{DRAG_DROP_PASTE as F}from"@lexical/rich-text";import{$getNodeByKey as x,$getSelection as k,$insertNodes as P,$isRangeSelection as v,COMMAND_PRIORITY_EDITOR as _,COMMAND_PRIORITY_LOW as B,createCommand as D}from"lexical";import{mergeRegister as G}from"@lexical/utils";import{Fragment as K,jsx as u,jsxs as N}from"react/jsx-runtime";var U=D("INSERT_IMAGE_COMMAND"),S=D("UPLOAD_IMAGES_COMMAND");function $(o,t){return t?t.includes(o.type):o.type.startsWith("image/")}function w({upload:o,maxSize:t,accept:s,onError:d,labels:m}){let[e]=O(),c=T(()=>({...y,...m}),[m]),M=A(o);M.current=o;let a=A(d);return a.current=d,L(()=>{b(e,c)},[e,c]),L(()=>{let C=r=>{let p=!1;for(let n of r){if(!$(n,s)){a.current?.({type:"unsupported",file:n});continue}if(t!==void 0&&n.size>t){a.current?.({type:"too-large",file:n,maxSize:t});continue}p=!0;let g=I({src:"",pending:!0});P([g]);let h=g.getKey();M.current(n).then(i=>{e.update(()=>{let l=x(h);if(R(l)){if(!f(i.src)){l.remove(),a.current?.({type:"unsafe-src",src:i.src});return}l.setSrc(i.src).setAlt(i.alt??"").setPending(!1)}})},i=>{e.update(()=>{let l=x(h);R(l)&&l.remove()}),a.current?.({type:"upload",file:n,error:i})})}return p};return G(e.registerCommand(F,r=>C(r),B),e.registerCommand(S,r=>C(r),_),e.registerCommand(U,({src:r,alt:p,title:n})=>{if(!f(r))return a.current?.({type:"unsafe-src",src:r}),!1;let g=k();return v(g)?(P([I({src:r,alt:p,title:n})]),!0):!1},_))},[e,s,t]),null}function V({accept:o="image/*",labels:t}){let[s]=O(),d=A(null),m=t?.insertImage??y.insertImage;return N(K,{children:[u(E,{label:m,onClick:()=>d.current?.click(),children:N("svg",{viewBox:"0 0 20 20",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[u("rect",{x:"3",y:"4",width:"14",height:"12",rx:"1.5"}),u("circle",{cx:"7.5",cy:"8.5",r:"1.5"}),u("path",{d:"M17 13l-4-4-6 6"})]})}),u("input",{ref:d,type:"file",accept:o,multiple:!0,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:e=>{let c=Array.from(e.target.files??[]);e.target.value="",c.length>0&&s.focus(()=>s.dispatchCommand(S,c))}})]})}export{U as a,S as b,w as c,V as d};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{b as he,c as tt,f as ye,q as ee,r as bt,s as xt,t as Et,u as Tt}from"./chunk-N5JWZ2VW.js";import{b as Q,c as st,d as at,e as j,f as ut,g as ct,h as dt,i as mt,j as ft,k as pt,l as gt,m as ht,n as yt,o as Ct,p as Lt,q as te,r as oe,s as be,t as xe,u as Ce,v as Ee}from"./chunk-AGTPMKLK.js";import{a as nt,b as _,d as rt,e as L,g as it,h as lt,n as O,u as Rt}from"./chunk-LDVPFZCN.js";import{b as ot,c as K}from"./chunk-YFFSTMIR.js";var Te=globalThis;Te.Prism?Te.Prism.manual=!0:Te.Prism={manual:!0};var po=String.raw`[A-Za-z_$][\w$]*`,go=String.raw`\s+`,ho=/^[A-Z][A-Z\d_]+$/,yo=/^[A-Z]/,kt=new WeakMap;function bo(e){return new RegExp(`${e}|`).exec("").length-1}function xo(e){let t=kt.get(e);if(t)return t;let o=[...e.rules,"whitespace","identifier"],r=o.map(c=>c==="whitespace"?go:c==="identifier"?e.identifier??po:c.match),n=[],i=1;for(let c of r)n.push(i),i+=1+bo(c);let l=new RegExp(r.map(c=>`(${c})`).join("|"),e.caseInsensitive?"yi":"y"),s=new Map,u=(c,m)=>{for(let f of c??[])s.set(e.caseInsensitive?f.toLowerCase():f,m)};u(e.builtins,"builtin"),u(e.types,"type"),u(e.constants,"constant"),u(e.keywords,"keyword");let a={regex:l,groupStarts:n,rules:o,words:s};return kt.set(e,a),a}function Co(e,t){let o=t;for(;e[o]===" "||e[o]===" ";)o++;return e[o]==="("}function Eo(e,t,o,r,n){let i=o.get(t.caseInsensitive?e.toLowerCase():e);if(i)return i;if(t.capitalizedIsType){if(ho.test(e))return"constant";if(yo.test(e))return"type"}return t.callIsFunction&&Co(r,n)?"function":"text"}function To(e,t){let{groupStarts:o,rules:r}=t;for(let n=0;n<o.length;n++)if(e[o[n]]!==void 0)return r[n];throw new Error("zui code lexer: no alternative matched")}function ne(e,t){let o=xo(t),r=[],n=(u,a)=>{let c=r[r.length-1];c&&c.type===u?r[r.length-1]={type:u,text:c.text+a}:r.push({type:u,text:a})},i=0,l=0,s=u=>{u>l&&n("text",e.slice(l,u))};for(;i<e.length;){o.regex.lastIndex=i;let u=o.regex.exec(e);if(u===null||u[0].length===0){i+=1;continue}let a=u[0],c=i+a.length,m=To(u,o),f;m==="whitespace"?f="text":m==="identifier"?f=Eo(a,t,o.words,e,c):f=m.type,f!=="text"&&(s(i),n(f,a),l=c),i=c}return s(e.length),r}import{$createLineBreakNode as Ro,$createTabNode as Lo,$nodesOfType as ko}from"lexical";import{$createCodeHighlightNode as So,CodeNode as St,registerCodeHighlighting as wo}from"@lexical/code";import{mergeRegister as vo}from"@lexical/utils";var Po=2e5;function wt(e,t){return e.length>Po?tt:ye(t)}var vt={defaultLanguage:he,tokenize(e,t){return ne(e,wt(e,t)).map(o=>o.type==="text"?o.text:{type:o.type,alias:"",content:o.text})},$tokenize(e,t){let o=e.getTextContent(),r=[];for(let{type:n,text:i}of ne(o,wt(o,t))){let l=n==="text"?void 0:n;for(let s of i.split(/(\n|\t)/))s===`
|
|
3
|
+
`?r.push(Ro()):s===" "?r.push(Lo()):s.length>0&&r.push(So(s,l))}return r}};function No(e){let o=globalThis.Prism?.languages;return!o||Object.prototype.hasOwnProperty.call(o,e)?!1:(o[e]={},!0)}function Re(e){let t=vo(e.registerNodeTransform(St,o=>{let r=o.getLanguage();r&&No(r)&&o.markDirty()}),wo(e,vt));return e.update(()=>{for(let o of ko(St))o.markDirty()},{tag:["history-merge","skip-dom-selection"]}),t}var Le=["comment","string","number","keyword","builtin","type","function","property","variable","constant","operator","punctuation","tag","attr","regex","meta","inserted","deleted"];import{useEffect as Pt,useRef as Nt}from"react";import{useLexicalComposerContext as zo}from"@lexical/react/LexicalComposerContext";import{$convertFromMarkdownString as Mo,$convertToMarkdownString as Io}from"@lexical/markdown";import{$createRangeSelection as $o,$getRoot as Ao,$getSelection as Bo,$isElementNode as ke,$isRangeSelection as Ko,$isTextNode as zt,$setSelection as Oo}from"lexical";var Se="initial-load",Do=8,_o=1e3;function Ho(e,t){if(t.size>0)return!0;for(let o of e.values())if(o)return!0;return!1}var we=class{constructor(t=Do,o=_o,r=()=>Date.now()){this.capacity=t;this.staleMs=o;this.now=r;this.entries=[]}push(t){let o=this.entries.findIndex(r=>r.value===t);o!==-1&&this.entries.splice(o,1),this.entries.push({value:t,at:this.now()}),this.entries.length>this.capacity&&this.entries.shift()}isEcho(t){let o=this.entries.length;if(o===0)return!1;if(this.entries[o-1].value===t)return!0;let r=this.now();return this.entries.some(n=>n.value===t&&r-n.at<=this.staleMs)}get last(){let t=this.entries.length;return t===0?null:this.entries[t-1].value}};function Fo(e){let t=[],o=e;for(;o!==null;){let r=o.getParent();if(r===null)break;t.unshift(o.getIndexWithinParent()),o=r}return t}function Mt(e){return{path:Fo(e.getNode()),offset:e.offset,type:e.type}}function It(e){let t=Ao();for(let r of e.path){if(!ke(t))return null;let n=t.getChildAtIndex(r);if(n===null)return null;t=n}let o=zt(t)?t.getTextContentSize():ke(t)?t.getChildrenSize():0;return e.type==="text"&&!zt(t)||e.type==="element"&&!ke(t)?null:[t,Math.min(e.offset,o)]}function Go(e,t){let o=Bo(),r=Ko(o)?{anchor:Mt(o.anchor),focus:Mt(o.focus)}:null;if(Mo(e,t),r===null)return;let n=It(r.anchor),i=It(r.focus);if(n===null||i===null)return;let l=$o();l.anchor.set(n[0].getKey(),n[1],r.anchor.type),l.focus.set(i[0].getKey(),i[1],r.focus.type),Oo(l)}function Uo(e,t,o){let r=e.getRootElement(),n=r!==null&&typeof document<"u"&&document.activeElement===r;e.update(()=>Go(t,o),{tag:n?[Se]:[Se,"skip-dom-selection"]})}function ve({markdown:e,onValueChange:t,transformers:o}){let[r]=zo(),n=Nt(new we),i=Nt(t);return i.current=t,Pt(()=>{e===void 0||n.current.isEcho(e)||(n.current.push(e),Uo(r,e,o))},[r,e]),Pt(()=>r.registerUpdateListener(({editorState:l,dirtyElements:s,dirtyLeaves:u,tags:a})=>{Ho(s,u)&&(a.has(Se)||l.read(()=>{let c=Io(o);c!==n.current.last&&(n.current.push(c),i.current?.(c))}))}),[r]),null}var Pe={ltr:"text-start",rtl:"text-end",placeholder:"text-muted-foreground opacity-50",paragraph:"zui-paragraph mb-2",heading:{h1:"zui-heading zui-heading-1 text-4xl font-bold mb-4",h2:"zui-heading zui-heading-2 text-3xl font-bold mb-3",h3:"zui-heading zui-heading-3 text-2xl font-bold mb-2",h4:"zui-heading zui-heading-4 text-xl font-bold mb-2",h5:"zui-heading zui-heading-5 text-lg font-bold mb-1",h6:"zui-heading zui-heading-6 text-base font-bold mb-1"},list:{listitem:"ms-8",listitemChecked:"line-through opacity-50",listitemUnchecked:"",nested:{listitem:"ms-8"},checklist:"zui-checklist",ol:"zui-list zui-list-ordered list-decimal ms-4",ul:"zui-list zui-list-unordered list-disc ms-4"},link:"text-primary underline hover:opacity-80 cursor-pointer",text:{bold:"font-bold",code:"bg-muted px-1.5 py-0.5 rounded-sm font-mono text-sm",italic:"italic",strikethrough:"line-through",subscript:"text-xs align-sub",superscript:"text-xs align-super",underline:"underline",underlineStrikethrough:"underline line-through"},code:"zui-code bg-muted rounded-md p-4 font-mono text-sm block my-2 overflow-x-auto",codeHighlight:Object.fromEntries(Le.map(e=>[e,`zui-token zui-token-${e}`])),quote:"zui-quote border-s-4 border-border ps-4 italic",frontmatter:"zui-frontmatter",table:"zui-table",tableCell:"zui-table-cell",tableCellHeader:"zui-table-cell-header",tableSelected:"zui-table-selected",tableSelection:"zui-table-selection",drawing:"zui-drawing"};function $t(e,t){let o={...e};for(let[r,n]of Object.entries(t)){let i=o[r];o[r]=typeof n=="object"&&n!==null&&typeof i=="object"&&i!==null?{...i,...n}:n}return o}import{useEffect as At,useRef as Wo,useState as Bt}from"react";import{useLexicalComposerContext as Yo}from"@lexical/react/LexicalComposerContext";import{$getRoot as Kt}from"lexical";import{Fragment as Vo,jsx as Ot,jsxs as qo}from"react/jsx-runtime";function W({className:e}={}){let[t]=Yo(),{mode:o,rawValue:r,maxLength:n,labels:i}=_(),[l,s]=Bt(()=>t.getEditorState().read(()=>Kt().getTextContentSize())),[u,a]=Bt(""),c=Wo(!1);At(()=>t.registerUpdateListener(({editorState:x})=>{s(x.read(()=>Kt().getTextContentSize()))}),[t]);let m=o==="edit-raw"?r.length:l,f=n!==void 0&&m>n;return At(()=>{f!==c.current&&(c.current=f,n!==void 0&&a(f?i.limitExceeded(n):i.limitRestored(n)))},[f,n,i]),qo(Vo,{children:[Ot("div",{className:`zui-text-editor-count ${f?"is-over":""} ${e??""}`,"data-slot":"count",children:i.count(m,n)}),n!==void 0&&Ot("div",{className:"zui-text-editor-live",role:"status","aria-live":"polite","aria-atomic":"true","data-slot":"count-status",children:u})]})}import{useCallback as Yt,useEffect as le,useMemo as Y,useRef as Z,useState as Ut,useSyncExternalStore as qn}from"react";import{LexicalComposer as Zn}from"@lexical/react/LexicalComposer";import{HistoryPlugin as Xn}from"@lexical/react/LexicalHistoryPlugin";import{ListPlugin as Jn}from"@lexical/react/LexicalListPlugin";import{CheckListPlugin as Qn}from"@lexical/react/LexicalCheckListPlugin";import{LinkPlugin as jn}from"@lexical/react/LexicalLinkPlugin";import{MarkdownShortcutPlugin as er}from"@lexical/react/LexicalMarkdownShortcutPlugin";import{AutoFocusPlugin as tr}from"@lexical/react/LexicalAutoFocusPlugin";import{TablePlugin as or}from"@lexical/react/LexicalTablePlugin";import{$convertFromMarkdownString as nr}from"@lexical/markdown";import{$getRoot as rr,createEditor as ir}from"lexical";import{useLexicalComposerContext as Vt}from"@lexical/react/LexicalComposerContext";import{useEffect as Zo}from"react";import{useLexicalComposerContext as Xo}from"@lexical/react/LexicalComposerContext";import{$isListItemNode as Jo,$isListNode as Dt,ListNode as Qo}from"@lexical/list";import{$getNodeByKey as jo,TextNode as en}from"lexical";var tn=/^\[(\s|x)?\]\s/i;function Ne(){let[e]=Xo();return Zo(()=>{let t=e.registerMutationListener(Qo,r=>{e.getEditorState().read(()=>{for(let[n,i]of r){if(i==="destroyed")continue;let l=e.getElementByKey(n),s=jo(n);l&&Dt(s)&&(l.__lexicalListType=s.getListType())}})}),o=e.registerNodeTransform(en,r=>{let n=r.getParent();if(!Jo(n)||n.getFirstChild()?.getKey()!==r.getKey())return;let i=n.getParent();if(!Dt(i)||i.getListType()==="check")return;let l=r.getTextContent(),s=l.match(tn);if(!s)return;let u=s[1]==="x"||s[1]==="X";r.setTextContent(l.slice(s[0].length)),i.setListType("check"),n.setChecked(u),r.select(0,0)});return()=>{t(),o()}},[e]),null}import{useEffect as on}from"react";import{useLexicalComposerContext as nn}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as rn,$getSelection as ln,$isLineBreakNode as sn,$isParagraphNode as an,$isRangeSelection as un,$isRootOrShadowRoot as _t,COMMAND_PRIORITY_LOW as cn,KEY_ARROW_DOWN_COMMAND as dn,TextNode as mn}from"lexical";import{$createCodeNode as fn,$isCodeNode as pn}from"@lexical/code";var gn=/^```(\w[\w-]*)?$/;function ze(){let[e]=nn();return on(()=>{let t=e.registerNodeTransform(mn,r=>{let n=r.getParent();if(!an(n)||n.getFirstChild()?.getKey()!==r.getKey())return;let i=n.getParent();if(!i||!_t(i))return;let s=r.getTextContent().trimEnd().match(gn);if(!s)return;let u=s[1]||void 0,a=fn(u);n.replace(a),a.selectEnd()}),o=e.registerCommand(dn,()=>{let r=ln();if(!un(r)||!r.isCollapsed())return!1;let n=r.anchor,i=n.getNode(),l=i;for(;l.getParent()&&!_t(l.getParent());)l=l.getParent();if(!pn(l))return!1;let s=l.getParent();if(!s||s.getLastChild()?.getKey()!==l.getKey())return!1;let u=m=>sn(m)||m.getTextContent().includes(`
|
|
4
|
+
`),a;if(i.getKey()===l.getKey())a=l.getChildren().slice(n.offset).some(u);else if(i.getTextContent().slice(n.offset).includes(`
|
|
5
|
+
`))a=!0;else{let m=i;for(;m.getParent()&&m.getParent().getKey()!==l.getKey();)m=m.getParent();a=m.getNextSiblings().some(u)}if(a)return!1;let c=rn();return l.insertAfter(c),c.selectStart(),!0},cn);return()=>{t(),o()}},[e]),null}import{useEffect as hn}from"react";import{useLexicalComposerContext as yn}from"@lexical/react/LexicalComposerContext";function Me(){let[e]=yn();return hn(()=>Re(e),[e]),null}import{useEffect as bn,useRef as Ht}from"react";import{useLexicalComposerContext as xn}from"@lexical/react/LexicalComposerContext";import{$getRoot as Cn,$getSelection as En,$isRangeSelection as Tn,RootNode as Rn}from"lexical";import{$trimTextContentFromAnchor as Ln}from"@lexical/selection";import{mergeRegister as kn}from"@lexical/utils";function Ie(){return Cn().getTextContentSize()}function $e({maxLength:e,onCharacterCountChange:t}){let[o]=xn(),r=Ht(t);r.current=t;let n=Ht(null);return bn(()=>{let i=s=>{n.current!==s&&(n.current=s,r.current?.(s))},l=!0;return queueMicrotask(()=>{l&&i(o.getEditorState().read(Ie))}),kn(()=>{l=!1},o.registerUpdateListener(({editorState:s,dirtyElements:u,dirtyLeaves:a})=>{u.size===0&&a.size===0||i(s.read(Ie))}),e===void 0?()=>{}:o.registerNodeTransform(Rn,s=>{let u=En();if(!Tn(u)||!u.isCollapsed())return;let a=o.getEditorState().read(Ie),c=s.getTextContentSize();if(c===a)return;let m=c-e;m>0&&Ln(o,u.anchor,m)}))},[o,e]),null}import{useEffect as Sn}from"react";import{useLexicalComposerContext as wn}from"@lexical/react/LexicalComposerContext";import{$hasUpdateTag as vn,PASTE_TAG as Pn}from"lexical";import{LinkNode as Nn}from"@lexical/link";function Ae(){let[e]=wn();return Sn(()=>e.registerNodeTransform(Nn,t=>{if(!(!vn(Pn)||K(t.getURL()))){for(let o of t.getChildren())t.insertBefore(o);t.remove()}}),[e]),null}import{useEffect as Dn}from"react";import{useLexicalComposerContext as _n}from"@lexical/react/LexicalComposerContext";import{$getSelection as Hn,$isRangeSelection as Fn,COMMAND_PRIORITY_HIGH as Gn,KEY_DOWN_COMMAND as Un}from"lexical";import{useEffect as zn,useState as Ft}from"react";import{useLexicalComposerContext as Mn}from"@lexical/react/LexicalComposerContext";import{jsx as In}from"react/jsx-runtime";var re=new Map;function v(e,t){re.get(e)?.(t)}function ie(){let[e]=Mn(),[t,o]=Ft(!1),[r,n]=Ft("");return zn(()=>{if(re.has(e))return;let i=!1;return re.set(e,l=>{i=!i,n(i?l:`${l}\xA0`)}),o(!0),()=>{re.delete(e),o(!1)}},[e]),t?In("div",{className:"zui-text-editor-live",role:"status","aria-live":"polite","aria-atomic":"true",children:r}):null}import{useEffect as $n}from"react";import{useLexicalComposerContext as An}from"@lexical/react/LexicalComposerContext";import{COMMAND_PRIORITY_HIGH as Bn,KEY_DOWN_COMMAND as Kn}from"lexical";function On(e){return!(e.metaKey||e.ctrlKey)||!e.altKey?null:e.key==="Enter"?e.shiftKey?"insert-before":"insert-after":e.key==="Backspace"&&e.shiftKey?"delete":null}function Be({labels:e}={}){let[t]=An(),o=L().table,r=e?.inserted??o.columnInserted,n=e?.deleted??o.columnDeleted;return $n(()=>t.registerCommand(Kn,i=>{let l=On(i);if(!l)return!1;let s=O();return s?(i.preventDefault(),l==="delete"?yt(s)&&v(t,n):ht(s,l==="insert-after"?"after":"before")&&v(t,r),!0):!1},Bn),[t,r,n]),null}import{Fragment as Yn,jsx as Gt,jsxs as Vn}from"react/jsx-runtime";function Wn(e){let t=e.metaKey||e.ctrlKey;return e.altKey?null:e.key==="Enter"&&t?e.shiftKey?"insert-above":"insert-below":e.key==="Backspace"&&t&&e.shiftKey?"delete":e.key==="Tab"&&!t&&!e.shiftKey?"tab":null}function Ke({labels:e,columnLabels:t}={}){let[o]=_n(),r=L().table,n=e?.inserted??r.rowInserted,i=e?.deleted??r.rowDeleted;return Dn(()=>o.registerCommand(Un,l=>{let s=Wn(l);if(!s)return!1;let u=O(),a=Q();if(!u||!a)return!1;if(s==="tab"){let c=Hn();return!(a.row===a.rows-1&&a.column===a.columns-1)||!Fn(c)||!c.isCollapsed()?!1:(l.preventDefault(),j(u,a.rows),v(o,n),!0)}return l.preventDefault(),s==="delete"?dt(u)&&v(o,i):ct(u,s==="insert-above"?"above":"below")&&v(o,n),!0},Gn),[o,n,i]),Vn(Yn,{children:[Gt(Be,{labels:t}),Gt(ie,{})]})}import{Fragment as pr,jsx as E,jsxs as Wt}from"react/jsx-runtime";var lr={};function qt(e){console.error(e)}function sr(e,t){let o=ir({namespace:"ZuiTextEditorInit",nodes:t.nodes,onError:qt});return o.update(()=>nr(e,t.sync),{discrete:!0}),o.getEditorState()}var ar=()=>()=>{};function ur(){return qn(ar,()=>!0,()=>!1)}function cr({state:e}){let t=e.read(()=>rr().getChildren().map(o=>o.getTextContent()));return E("div",{className:"zui-text-editor-body",children:E("div",{className:"zui-text-editor-main",children:E("div",{className:"zui-text-editor-content","aria-readonly":"true",children:t.map((o,r)=>E("p",{children:o},r))})})})}function dr({readOnly:e}){let[t]=Vt();return le(()=>{t.setEditable(!e)},[t,e]),null}function mr({onEditorReady:e}){let[t]=Vt();return le(()=>{e?.(t)},[t,e]),null}function fr(e,t){let o=Z(e);o.current=e;let r=Z(null),n=Z(null);return le(()=>()=>{if(r.current===null)return;clearTimeout(r.current),r.current=null;let i=n.current;n.current=null,i!==null&&o.current?.(i)},[]),Yt(i=>{if(t<=0){o.current?.(i);return}r.current!==null&&clearTimeout(r.current),n.current=i,r.current=setTimeout(()=>{r.current=null,n.current=null,o.current?.(i)},t)},[t])}function Oe({value:e,defaultValue:t,onValueChange:o,debounceMs:r=0,readOnly:n=!1,className:i,mode:l="edit-rich",autoFocus:s=!1,maxTextWidth:u,newBlockWidth:a=lr,drawingStyle:c="clean",onError:m=qt,nodes:f,transformers:x,nodeClassNames:C,onEditorReady:R,labels:y,maxLength:p,onCharacterCountChange:d,id:h,name:g,"aria-label":z,"aria-labelledby":S,"aria-describedby":T,"aria-invalid":M,"aria-required":I,preset:w=ee,children:$}){let[A]=Ut(()=>{let D=bt(w.transformers,x);return{nodes:[...w.nodes,...f??[]],sync:D,shortcuts:xt(D),theme:C?$t(Pe,C):Pe}}),[fe,pe]=Ut(t??""),b=e??fe,k=Z(m);k.current=m;let F=fr(o,r),G=Yt(D=>{pe(D),F(D)},[F]),U=Y(()=>l==="view"?sr(b,A):null,[]),B=Y(()=>({namespace:"ZuiTextEditor",theme:A.theme,onError:D=>k.current(D),nodes:A.nodes,editable:!n&&l!=="view",editorState:U?JSON.stringify(U.toJSON()):void 0}),[]),J=ur(),Je=Y(()=>rt(y),[y]),Qe=Y(()=>({id:h,name:g,"aria-label":z,"aria-labelledby":S,"aria-describedby":T,"aria-invalid":M,"aria-required":I}),[h,g,z,S,T,M,I]),fo=Y(()=>({mode:l,readOnly:n,autoFocus:s,rawValue:b,onRawChange:G,newBlockWidth:a,drawingStyle:c,labels:Je,maxLength:p,field:Qe}),[l,n,s,b,G,a,c,Je,p,Qe]),ge=l==="edit-raw",je=Y(()=>u!==void 0?{"--zui-text-editor-measure":u}:void 0,[u]),et=Z(d);return et.current=d,le(()=>{ge&&et.current?.(b.length)},[ge,b]),U&&!J?E("div",{className:`zui-text-editor ${i??""}`,style:je,children:E(cr,{state:U})}):E(Zn,{initialConfig:B,children:E(nt.Provider,{value:fo,children:Wt("div",{className:`zui-text-editor ${i??""}`,style:je,children:[E(mr,{onEditorReady:R}),$,!ge&&Wt(pr,{children:[E(ve,{markdown:b,onValueChange:G,transformers:A.sync}),(p!==void 0||d!==void 0)&&E($e,{maxLength:p,onCharacterCountChange:d}),E(Xn,{}),E(Jn,{}),E(Qn,{}),E(Ne,{}),E(ze,{}),E(Me,{}),E(or,{}),E(Ke,{}),E(jn,{validateUrl:K}),E(Ae,{}),E(er,{transformers:A.shortcuts}),E(dr,{readOnly:n||l==="view"}),s&&E(tr,{}),w.plugins]})]})})})}import{RichTextPlugin as ei}from"@lexical/react/LexicalRichTextPlugin";import{ContentEditable as ti}from"@lexical/react/LexicalContentEditable";import{LexicalErrorBoundary as oi}from"@lexical/react/LexicalErrorBoundary";import{useCallback as se,useEffect as gr,useLayoutEffect as hr,useRef as De,useState as _e}from"react";import{$getRoot as yr,$getSelection as br,$isRangeSelection as xr}from"lexical";import{useLexicalComposerContext as Cr}from"@lexical/react/LexicalComposerContext";import{$isHeadingNode as He}from"@lexical/rich-text";import{jsx as ae,jsxs as Lr}from"react/jsx-runtime";var Zt={h1:1,h2:2,h3:3,h4:4,h5:5,h6:6},Er={hidden:new Set,headings:[]};function Tr(e,t){if(e.hidden.size!==t.hidden.size||e.headings.length!==t.headings.length)return!1;for(let o of e.hidden)if(!t.hidden.has(o))return!1;return e.headings.every((o,r)=>o.key===t.headings[r].key&&o.folded===t.headings[r].folded)}function Rr(e,t){return e.length===t.length&&e.every((o,r)=>{let n=t[r];return o.key===n.key&&o.folded===n.folded&&o.top===n.top&&o.height===n.height})}function Fe({labels:e}={}){let[t]=Cr(),[o,r]=_e(new Set),[n,i]=_e(Er),[l,s]=_e([]),u=De(o);u.current=o;let a=De(n);a.current=n;let c={...L().collapsibleHeadings,...e},m=se(()=>{t.getEditorState().read(()=>{let y=yr().getChildren(),p=u.current,d=new Set,h=[];for(let S=0;S<y.length;S++){let T=y[S];if(!He(T))continue;let M=Zt[T.getTag()]??6,I=p.has(T.getKey());if(h.push({key:T.getKey(),folded:I}),!!I)for(let w=S+1;w<y.length;w++){let $=y[w];if(He($)&&(Zt[$.getTag()]??6)<=M)break;d.add($.getKey())}}let g=br();if(xr(g)){let S=g.anchor.getNode().getTopLevelElement();if(S&&d.has(S.getKey())){let T=S.getPreviousSibling();for(;T;){if(He(T)&&p.has(T.getKey())){let M=T.getKey();r(I=>{let w=new Set(I);return w.delete(M),w});return}T=T.getPreviousSibling()}}}let z={hidden:d,headings:h};Tr(a.current,z)||(a.current=z,i(z))})},[t]),f=De(new Set),x=se(()=>{let{hidden:y,headings:p}=a.current,d=new Set;for(let h of y){let g=t.getElementByKey(h);g&&(d.add(g),g.style.display!=="none"&&(g.style.display="none"))}for(let h of f.current)!d.has(h)&&h.style.display==="none"&&(h.style.display="");f.current=d;for(let{key:h,folded:g}of p)t.getElementByKey(h)?.classList.toggle("zui-heading-folded",g)},[t]),C=se(()=>{let y=a.current.headings.map(({key:p,folded:d})=>{let h=t.getElementByKey(p);return{key:p,folded:d,top:h?.offsetTop??0,height:h?.offsetHeight??0}});s(p=>Rr(p,y)?p:y)},[t]);hr(()=>{x(),C()},[n,x,C]),gr(()=>{m();let y=()=>{m(),x(),C()},p=t.registerUpdateListener(y),d=t.getRootElement(),h=typeof ResizeObserver<"u"?new ResizeObserver(C):null;return d&&h&&h.observe(d),()=>{p(),h?.disconnect()}},[t,m,x,C,o]);let R=se(y=>{let p=!u.current.has(y);r(d=>{let h=new Set(d);return h.has(y)?h.delete(y):h.add(y),h}),v(t,p?c.collapsed:c.expanded)},[t,c.collapsed,c.expanded]);return Lr("div",{className:"zui-text-editor-fold-gutter",children:[ae(ie,{}),l.map(({key:y,folded:p,top:d,height:h})=>ae("button",{type:"button",className:`zui-text-editor-fold ${p?"is-folded":""}`,style:{top:d+Math.max(0,(Math.min(h,44)-18)/2)},title:p?c.expand:c.collapse,"aria-label":p?c.expand:c.collapse,"aria-expanded":!p,onClick:()=>R(y),children:ae("svg",{viewBox:"0 0 20 20",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:ae("path",{d:"M6 8l4 4 4-4"})})},y))]})}import{useCallback as kr,useEffect as V,useRef as Xt,useState as Ge}from"react";import{useLexicalComposerContext as Sr}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as wr}from"@lexical/react/useLexicalEditable";import{$createRangeSelection as vr,$getSelection as Jt,$isRangeSelection as Qt,$setSelection as Pr,COMMAND_PRIORITY_LOW as Nr}from"lexical";import{$isLinkNode as zr,$toggleLink as Mr}from"@lexical/link";import{$findMatchingParent as Ir}from"@lexical/utils";import{jsx as X,jsxs as Ar}from"react/jsx-runtime";function jt(e){return{key:e.key,offset:e.offset,type:e.type}}function eo(e,t){return e.key===t.key&&e.offset===t.offset&&e.type===t.type}function to(e,t){let o=e.getRootElement()?.parentElement;if(!t||!o)return null;let r=o.getBoundingClientRect();return{top:t.bottom-r.top+o.scrollTop+4,insetInlineStart:Math.max(0,t.left-r.left+o.scrollLeft)}}function $r(e,t){let r=e.getRootElement()?.ownerDocument.defaultView?.getSelection();if(r&&r.rangeCount>0){let i=r.getRangeAt(0).getBoundingClientRect();if(i.width>0||i.height>0)return i}let n=e.getElementByKey(t);return n?n.getBoundingClientRect():null}function Ue(){let[e]=Sr(),t=wr(),{link:o,setLink:r}=Ct(),n=L(),[i,l]=Ge(""),[s,u]=Ge(null),[a,c]=Ge(null),m=Xt(null),f=Xt(null),x=o?.key??null,C=o?.url??"";V(()=>{l(C)},[x,C]),V(()=>{x!==null&&c(null)},[x]),V(()=>e.registerCommand(ot,()=>{let d=Jt();if(!Qt(d))return!1;if(Ir(d.anchor.getNode(),zr))return m.current?.focus(),!0;if(d.isCollapsed())return!1;let h=to(e,$r(e,d.anchor.key));return h?(l(""),c({anchor:jt(d.anchor),focus:jt(d.focus),style:h}),!0):!1},Nr),[e]),V(()=>{if(a!==null)return e.registerUpdateListener(({editorState:d})=>{d.read(()=>{let g=Jt();return Qt(g)&&eo(a.anchor,g.anchor)&&eo(a.focus,g.focus)})||c(null)})},[e,a]),V(()=>{a!==null&&m.current?.focus()},[a]),V(()=>{if(a!==null){u(a.style);return}if(x===null){u(null);return}let d=e.getElementByKey(x);u(to(e,d?d.getBoundingClientRect():null))},[e,x,C,a]);let R=kr(()=>c(null),[]);if(!t||s===null||x===null&&a===null)return null;let y=()=>{let d=i.trim();if(a!==null){if(d===""||!K(d))return;c(null),e.update(()=>{let h=vr();h.anchor.set(a.anchor.key,a.anchor.offset,a.anchor.type),h.focus.set(a.focus.key,a.focus.offset,a.focus.type),Pr(h),Mr(d)});return}d===""?r(null):K(d)&&r(d)},p=i.trim()!==""&&!K(i);return Ar("div",{ref:f,className:"zui-text-editor-link-bubble",role:"group","aria-label":n.toolbar.link,style:s,"data-slot":"link-bubble",onBlur:d=>{a!==null&&!(d.relatedTarget instanceof Node&&f.current?.contains(d.relatedTarget))&&R()},children:[X("input",{ref:m,type:"url",className:"zui-text-editor-link-input","aria-label":n.toolbar.linkUrl,"aria-invalid":p||void 0,placeholder:n.toolbar.linkUrlPlaceholder,value:i,onChange:d=>l(d.target.value),onKeyDown:d=>{d.key==="Enter"?(d.preventDefault(),y(),e.focus()):d.key==="Escape"&&(d.preventDefault(),R(),e.focus())}}),X("button",{type:"button",className:"zui-text-editor-toolbar-button",onClick:y,disabled:p,children:n.toolbar.linkApply}),X("button",{type:"button",className:"zui-text-editor-toolbar-button",title:n.toolbar.removeLink,"aria-label":n.toolbar.removeLink,onClick:()=>{a!==null?R():r(null),e.focus()},children:X("svg",{viewBox:"0 0 20 20",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",children:X("path",{d:"M5 5l10 10M15 5L5 15"})})})]})}import{useCallback as lo}from"react";import{useLexicalComposerContext as Xr}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as Jr}from"@lexical/react/useLexicalEditable";import{useCallback as oo,useEffect as Br,useRef as Kr,useState as no}from"react";import{useLexicalComposerContext as Or}from"@lexical/react/LexicalComposerContext";import{jsx as q,jsxs as Dr}from"react/jsx-runtime";var We={row:28,column:24};function ue({axis:e,box:t,lanes:o,current:r,insertable:n,canDelete:i,onInsert:l,onDelete:s,labels:u}){let[a]=Or(),c=L().table,m=Kr(null),[f,x]=no(!1),[C,R]=no(null),y=We[e],p=e==="row",d=oo(b=>{if(b<o.length)return o[b].start;let k=o[o.length-1];return k?k.start+k.size:0},[o]),h=oo(b=>{let k=m.current?.getBoundingClientRect();k&&R(p?b.clientY-k.top:b.clientX-k.left)},[p]);if(Br(()=>{let b=m.current;b&&x(getComputedStyle(b).direction==="rtl")},[]),o.length===0)return null;let g=(()=>{if(C===null)return{mode:"insert",index:o.length};let b=o.length,k=Number.POSITIVE_INFINITY;for(let B of n){let J=Math.abs(d(B)-C);J<k&&(k=J,b=B)}let F=o.findIndex(B=>C>=B.start&&C<B.start+B.size),G=o[F],U=G?Math.min(10,G.size*.3):0;return!i||F===-1||k<=U?{mode:"insert",index:b}:{mode:"delete",index:F}})(),z=b=>p?{top:b}:{left:b},S=b=>p?{top:b.start+3,height:Math.max(4,b.size-6)}:{left:b.start+3,width:Math.max(4,b.size-6)},T=p?{insetInlineStart:y,width:t.width}:{top:y,height:t.height},M=f?t.right:t.left,I=o[Math.min(r,o.length-1)],w=g.mode==="insert"&&g.index===o.length,$=g.mode==="delete"?(p?c.deleteRow:c.deleteColumn)(g.index+1):w?p?c.addRow:c.addColumn:(p?c.insertRowBefore:c.insertColumnBefore)(g.index+1),A={inserted:p?c.rowInserted:c.columnInserted,deleted:p?c.rowDeleted:c.columnDeleted,...u},fe=()=>{g.mode==="insert"?l(g.index):s(g.index),v(a,g.mode==="insert"?A.inserted:A.deleted)},pe=g.mode==="insert"?{...z(d(g.index)),...T}:p?{top:o[g.index].start,height:o[g.index].size,...T}:{left:o[g.index].start,width:o[g.index].size,...T};return Dr("div",{ref:m,className:`zui-table-rail is-${e}`,style:p?{top:t.top,insetInlineStart:M-y,width:y,height:t.height}:{top:t.top-y,insetInlineStart:M,width:t.width,height:y},onPointerMove:h,onPointerLeave:()=>R(null),children:[q("div",{className:"zui-table-rail-marker",style:S(I),"aria-hidden":!0}),q("button",{type:"button",className:`zui-table-rail-handle is-${g.mode} ${C===null?"is-resting":""}`,style:z(g.mode==="insert"?d(g.index):o[g.index].start+o[g.index].size/2),title:$,"aria-label":$,onMouseDown:b=>b.preventDefault(),onClick:fe,children:q("svg",{viewBox:"0 0 12 12",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:g.mode==="insert"?q("path",{d:"M6 2.5v7M2.5 6h7"}):q("path",{d:"M2.5 6h7"})})}),q("div",{className:`zui-table-rail-preview is-${g.mode}`,style:pe,"aria-hidden":!0})]})}import{jsx as ce}from"react/jsx-runtime";function _r({children:e}){return ce("svg",{viewBox:"0 0 20 20",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:e})}function Ye({settings:e,style:t,onSettings:o}){let r=Rt(),n=L();return ce("div",{className:"zui-table-settings",role:"toolbar","aria-label":n.table.settings,style:t,...r,children:Et.map(({preset:i,label:l,icon:s,width:u,density:a})=>ce(oe,{label:n.layout[l],active:Tt(e.width)===i,onClick:()=>o({width:u,density:a}),children:ce(_r,{children:s})},i))})}import{useCallback as Hr,useEffect as ro,useRef as Fr,useState as Gr}from"react";import{useLexicalComposerContext as Ur}from"@lexical/react/LexicalComposerContext";function Wr(e,t){return e.top===t.top&&e.left===t.left&&e.right===t.right&&e.width===t.width&&e.height===t.height}function io(e,t){return e.length===t.length&&e.every((o,r)=>o.start===t[r].start&&o.size===t[r].size)}function Yr(e,t){return e===t?!0:!e||!t?!1:e.key===t.key&&e.settings===t.settings&&e.position===t.position&&Wr(e.box,t.box)&&io(e.rows,t.rows)&&io(e.columns,t.columns)}function Vr(e,t){return e.row===t.row&&e.column===t.column&&e.rows===t.rows&&e.columns===t.columns&&e.hasHeader===t.hasHeader}function qr(e,t){return e.width===t.width&&e.density===t.density}function Zr(e,t,o,r){let n=e.getBoundingClientRect(),i=t.getBoundingClientRect(),l=Array.from(e.querySelectorAll(":scope > tbody > tr, :scope > tr")),s=l.map(m=>{let f=m.getBoundingClientRect();return{start:f.top-n.top,size:f.height}}),u={top:n.top-i.top,left:n.left-i.left,right:i.right-n.right,width:n.width,height:n.height},c=o!==null&&o.key===r&&o.columns.length===(l[0]?.children.length??0)&&o.box.width===u.width&&o.box.height===u.height?o.columns:Array.from(l[0]?.children??[]).map(m=>{let f=m.getBoundingClientRect();return{start:f.left-n.left,size:f.width}});return{box:u,rows:s,columns:c}}function Ve(){let[e]=Ur(),[t,o]=Gr(null),r=Fr(t);r.current=t;let n=Hr(()=>{let l=e.getEditorState().read(()=>{let x=O(),C=Q();return x&&C?{key:x.getKey(),settings:it(x),position:C}:null}),s=l?e.getElementByKey(l.key):null,u=e.getRootElement()?.parentElement,a=r.current;if(!l||!s||!u){a!==null&&o(null);return}let c=a&&a.key===l.key&&qr(a.settings,l.settings)?a.settings:l.settings,m=a&&Vr(a.position,l.position)?a.position:l.position,f={key:l.key,settings:c,position:m,...Zr(s,u,a,l.key)};Yr(a,f)||(r.current=f,o(f))},[e]);ro(()=>{n();let l=e.registerUpdateListener(n),s=e.getRootElement(),u=typeof ResizeObserver<"u"?new ResizeObserver(n):null;return s&&u&&u.observe(s),()=>{l(),u?.disconnect()}},[e,n]);let i=t?.key??null;return ro(()=>{if(i===null||typeof ResizeObserver>"u")return;let l=e.getElementByKey(i);if(!l)return;let s=new ResizeObserver(n);return s.observe(l),()=>s.disconnect()},[e,i,n]),t}import{Fragment as Qr,jsx as qe,jsxs as jr}from"react/jsx-runtime";function Ze(){let[e]=Xr(),t=Jr(),o=Ve(),r=lo(l=>{e.update(()=>{let s=O();s&&l(s)})},[e]),n=lo(l=>r(s=>lt(s,l)),[r]);if(!t||!o)return null;let{position:i}=o;return jr(Qr,{children:[qe(Ye,{settings:o.settings,style:{top:o.box.top-We.column,right:o.box.right},onSettings:n}),qe(ue,{axis:"row",box:o.box,lanes:o.rows,current:i.row,insertable:st(i),canDelete:at(i),onInsert:l=>r(s=>j(s,l,i.column)),onDelete:l=>r(s=>ut(s,l,i.column))}),qe(ue,{axis:"column",box:o.box,lanes:o.columns,current:i.column,insertable:mt(i),canDelete:ft(i),onInsert:l=>r(s=>pt(s,l,i.row)),onDelete:l=>r(s=>gt(s,l,i.row))})]})}import{Fragment as ni,jsx as P,jsxs as Xe}from"react/jsx-runtime";function de({placeholder:e,collapsible:t=!0,showCharacterCount:o=!1,children:r}){let{mode:n,readOnly:i,autoFocus:l,rawValue:s,onRawChange:u,labels:a,maxLength:c,field:m}=_(),f=e??a.placeholder,{name:x,...C}=m;return n==="edit-raw"?Xe(ni,{children:[P("textarea",{...m,className:"zui-text-editor-textarea",value:s,onChange:R=>u(R.target.value),placeholder:f,readOnly:i,autoFocus:l,maxLength:c,spellCheck:!1}),o&&P(W,{})]}):Xe("div",{className:"zui-text-editor-body",children:[Xe("div",{className:"zui-text-editor-main",children:[P(ei,{contentEditable:P(ti,{...C,className:"zui-text-editor-content","aria-placeholder":f,placeholder:P("div",{className:"zui-text-editor-placeholder",children:f})}),ErrorBoundary:oi}),t&&P(Fe,{}),P(Ze,{}),P(Ue,{}),o&&P(W,{}),x!==void 0&&P("input",{type:"hidden",name:x,value:s,readOnly:!0})]}),r]})}import{useCallback as ri,useEffect as ao,useState as so}from"react";import{useLexicalComposerContext as ii}from"@lexical/react/LexicalComposerContext";import{TableOfContentsPlugin as li}from"@lexical/react/LexicalTableOfContentsPlugin";import{jsx as H,jsxs as uo}from"react/jsx-runtime";var si={h1:0,h2:1,h3:2,h4:3,h5:4,h6:5};function ai(e,t){ao(()=>{for(let[o]of t)e.getElementByKey(o)?.setAttribute("data-outline-key",o)},[e,t])}function ui({editor:e,entries:t,activeKey:o,onSelect:r}){ai(e,t);let n=L().outline;return uo("nav",{className:"zui-text-editor-outline-list","aria-label":n.title,children:[t.length===0&&H("div",{className:"zui-text-editor-outline-empty",children:n.empty}),t.map(([i,l,s])=>H("button",{type:"button",className:`zui-text-editor-outline-item ${i===o?"is-active":""}`,style:{paddingInlineStart:`${.5+si[s]*.75}rem`},onClick:()=>r(i),children:l||n.untitled},i))]})}function me(){let[e]=ii(),[t,o]=so(!1),[r,n]=so(null),i=L().outline;ao(()=>{let s=e.getRootElement(),u=s?.closest(".zui-text-editor");if(!s||!(u instanceof HTMLElement))return;let a=0,c=()=>{cancelAnimationFrame(a),a=requestAnimationFrame(()=>{let f=s.querySelectorAll("h1, h2, h3, h4, h5, h6"),x=u.scrollTop+80,C=null;for(let R of f)R.offsetTop<=x&&(C=R.getAttribute("data-outline-key"));n(C)})};c(),u.addEventListener("scroll",c,{passive:!0});let m=e.registerUpdateListener(c);return()=>{cancelAnimationFrame(a),u.removeEventListener("scroll",c),m()}},[e]);let l=ri(s=>{e.getEditorState().read(()=>{e.getElementByKey(s)?.scrollIntoView({behavior:"smooth",block:"start"})})},[e]);return H(li,{children:s=>uo("div",{className:`zui-text-editor-outline ${t?"is-collapsed":""}`,children:[H("button",{type:"button",className:"zui-text-editor-outline-toggle",title:t?i.show:i.hide,"aria-label":t?i.show:i.hide,"aria-expanded":!t,onClick:()=>o(u=>!u),children:H("svg",{viewBox:"0 0 20 20",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:H("path",{d:"M4 5h12M4 10h8M4 15h10"})})}),!t&&H(ui,{editor:e,entries:s,activeKey:r,onSelect:l})]})})}import{jsx as N,jsxs as mo}from"react/jsx-runtime";function co({children:e,className:t}){let{mode:o,readOnly:r}=_();return o!=="edit-rich"||r?null:N(Lt,{className:t,children:e})}function Ea(e=ee){let t=e.plugins!==void 0,o={format:N(be,{}),block:N(xe,{}),insert:N(Ce,{drawing:t}),history:N(Ee,{})};function r(i){return N(Oe,{preset:e,...i})}function n({placeholder:i,toolbar:l=!0,outline:s=!1,collapsible:u=!0,showCharacterCount:a=!1,children:c,...m}){return mo(r,{...m,children:[l===!0&&mo(co,{children:[o.format,N(te,{}),o.block,N(te,{}),o.insert]}),typeof l=="function"&&l(o),N(de,{placeholder:i,collapsible:u,showCharacterCount:a,children:s&&N(me,{})}),c]})}return n.Root=r,n.Content=de,n.Toolbar=co,n.ToolbarButton=oe,n.ToolbarDivider=te,n.FormatButtons=be,n.BlockButtons=xe,n.InsertButtons=Ce,n.HistoryButtons=Ee,n.Outline=me,n.CharacterCount=W,n}export{ne as a,vt as b,Re as c,Le as d,Se as e,Go as f,Uo as g,Pe as h,$t as i,W as j,Ea as k};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
function c(o,e,n="below"){let t=o.getRootElement()?.parentElement;if(!t||!e)return null;let l=t.getBoundingClientRect();return{top:n==="below"?e.bottom-l.top+t.scrollTop+4:e.top-l.top+t.scrollTop-4,insetInlineStart:Math.max(0,e.left-l.left+t.scrollLeft),...n==="above"?{transform:"translateY(-100%)"}:{}}}function r(){if(typeof window>"u")return null;let o=window.getSelection();if(!o||o.rangeCount===0)return null;let e=o.getRangeAt(0);if(typeof e.getBoundingClientRect!="function")return null;let n=e.getBoundingClientRect();if(n.width===0&&n.height===0){let t=e.startContainer,l=t instanceof Element?t:t.parentElement;return l?l.getBoundingClientRect():null}return n}function u(o,e){let n=r();if(n)return n;if(e===null)return null;let t=o.getElementByKey(e);return t?t.getBoundingClientRect():null}export{c as a,u as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use client';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{b as K,c as Z}from"./chunk-5VRVC56Y.js";import{a as j,b as ee}from"./chunk-SDICQI2B.js";import{useCallback as te,useEffect as y,useId as ge,useMemo as Y,useRef as h,useState as E}from"react";import{useLexicalComposerContext as de}from"@lexical/react/LexicalComposerContext";import{useLexicalEditable as me}from"@lexical/react/useLexicalEditable";import{$createTextNode as ne,$getNodeByKey as fe,$getSelection as le,$isRangeSelection as ae,$isTextNode as ce,COMMAND_PRIORITY_EDITOR as re,COMMAND_PRIORITY_HIGH as x,SELECTION_CHANGE_COMMAND as ye,KEY_ARROW_DOWN_COMMAND as pe,KEY_ARROW_UP_COMMAND as Me,KEY_ENTER_COMMAND as Ne,KEY_ESCAPE_COMMAND as Re,KEY_TAB_COMMAND as Ce,createCommand as he}from"lexical";import{mergeRegister as oe}from"@lexical/utils";import{Fragment as Ie,jsx as v,jsxs as se}from"react/jsx-runtime";var Ee={suggestions:l=>`Suggestions for ${l}`,noResults:"No matches",loading:"Searching"},xe=he("INSERT_MENTION_COMMAND"),ve=40;function ie(l){return l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $e(l,a,s){let u=l.slice(0,a);for(let m of s){let c=new RegExp(`(?:^|[\\s(\\[])(${ie(m)})([^\\s${ie(m)}]{0,${ve}})$`).exec(u);if(!c)continue;let r=c.index+c[0].length-c[1].length-c[2].length;return{trigger:m,query:c[2],from:r}}return null}function Ae(l){let a=le();if(!ae(a)||!a.isCollapsed())return null;let s=a.anchor.getNode();if(!ce(s)||Z(s)||s.hasFormat("code")||s.getMode()!=="normal")return null;let u=$e(s.getTextContent(),a.anchor.offset,l);return u?{...u,key:s.getKey()}:null}function _e({trigger:l="@",search:a,render:s,triggers:u,maxItems:m=8,labels:_,onSelect:c}){let[r]=de(),z=me(),I=Y(()=>({...Ee,..._}),[_]),g=Y(()=>u??(a?[{trigger:l,search:a,render:s}]:[]),[u,l,a,s]),p=Y(()=>g.map(e=>e.trigger),[g]),M=ge(),[i,$]=E(null),[N,O]=E([]),[B,A]=E(!1),[R,T]=E(0),[H,U]=E(null),b=h(null),S=h(i);S.current=i;let D=h(N);D.current=N;let G=h(R);G.current=R;let W=h(c);W.current=c,y(()=>{if(!z||p.length===0){$(null);return}let e=()=>{let t=r.getEditorState().read(()=>Ae(p)),o=t?`${t.key}:${t.from}:${t.trigger}:${t.query}`:null;t&&b.current===o||(o!==null&&(b.current=null),$(n=>n&&t&&n.key===t.key&&n.from===t.from&&n.trigger===t.trigger&&n.query===t.query?n:t))};return e(),oe(r.registerUpdateListener(e),r.registerCommand(ye,()=>(e(),!1),re))},[r,z,p]);let q=i?.query??null,L=i?.trigger??null;y(()=>{if(L===null||q===null){O([]),A(!1);return}let e=g.find(o=>o.trigger===L);if(!e)return;let t=!0;return A(!0),e.search(q).then(o=>{t&&(O(o.slice(0,m)),T(0),A(!1))}).catch(()=>{t&&(O([]),A(!1))}),()=>{t=!1}},[g,L,q,m]),y(()=>{if(!i){U(null);return}U(j(r,ee(r,i.key)))},[r,i]);let w=te(()=>{let e=S.current;e&&(b.current=`${e.key}:${e.from}:${e.trigger}:${e.query}`),$(null)},[]),P=te(e=>{let t=S.current;if(!t)return;let o=g.find(n=>n.trigger===t.trigger);r.update(()=>{let n=fe(t.key);if(!ce(n))return;let d=n.getTextContent(),f=t.from+t.trigger.length+t.query.length,Q=d.slice(t.from,f);if(Q!==t.trigger+t.query)return;let X=n.splitText(t.from,f).find(ue=>ue.getTextContent()===Q);if(!X)return;let J=K(e.id,e.name,t.trigger);X.replace(J);let V=ne(" ");J.insertAfter(V),V.select(1,1)}),$(null),o&&W.current?.(e,t.trigger)},[r,g]),C=i!==null;y(()=>{if(!C)return;let e=o=>n=>{let d=D.current.length;return d===0?!1:(n?.preventDefault(),T(f=>(f+o+d)%d),!0)},t=o=>{let n=D.current[G.current];return n?(o?.preventDefault(),P(n),!0):!1};return oe(r.registerCommand(pe,e(1),x),r.registerCommand(Me,e(-1),x),r.registerCommand(Ne,t,x),r.registerCommand(Ce,t,x),r.registerCommand(Re,o=>(o?.preventDefault(),w(),!0),x))},[r,C,P,w]),y(()=>r.registerCommand(xe,({id:e,name:t,trigger:o})=>{let n=le();if(!ae(n))return!1;let d=K(e,t,o??p[0]??"@"),f=ne(" ");return n.insertNodes([d,f]),!0},re),[r,p]);let k=C&&N[R]?`${M}-${R}`:null;if(y(()=>{let e=r.getRootElement();if(e&&C)return e.setAttribute("aria-controls",M),k?e.setAttribute("aria-activedescendant",k):e.removeAttribute("aria-activedescendant"),()=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-activedescendant")}},[r,C,M,k]),!i||H===null)return null;let F=g.find(e=>e.trigger===i.trigger)?.render;return se("div",{className:"zui-text-editor-mentions",style:H,"data-slot":"mentions",children:[v("div",{role:"listbox",id:M,"aria-label":I.suggestions(i.trigger),"aria-busy":B||void 0,children:N.map((e,t)=>{let o=t===R;return v("div",{id:`${M}-${t}`,role:"option","aria-selected":o,className:`zui-text-editor-mention-option${o?" is-active":""}`,onMouseDown:n=>n.preventDefault(),onMouseMove:()=>T(t),onClick:()=>P(e),children:F?F(e,{active:o,query:i.query,trigger:i.trigger}):se(Ie,{children:[v("span",{className:"zui-text-editor-mention-name",children:e.name}),e.hint&&v("span",{className:"zui-text-editor-mention-hint",children:e.hint})]})},e.id)})}),N.length===0&&v("div",{className:"zui-text-editor-mention-empty",role:"status",children:B?I.loading:I.noResults})]})}export{Ee as a,xe as b,$e as c,_e as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{createCommand as o}from"lexical";var r=["http:","https:","mailto:","tel:"],a=/^[a-z][a-z0-9+.-]*:/i,m=o("EDIT_LINK_COMMAND");function c(n){let t=n.trim();if(t==="")return!1;let e=a.exec(t);return e?r.includes(e[0].toLowerCase()):!0}export{r as a,m as b,c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{c as b}from"./chunk-YFFSTMIR.js";import{useEffect as L,useRef as z}from"react";import{useLexicalComposerContext as H}from"@lexical/react/LexicalComposerContext";import{$generateNodesFromDOM as M}from"@lexical/html";import{$insertGeneratedNodes as k}from"@lexical/clipboard";import{$addUpdateTag as _,$getSelection as U,$isRangeSelection as $,COMMAND_PRIORITY_HIGH as B,PASTE_COMMAND as W,PASTE_TAG as q}from"lexical";var N=new Set(["p","h1","h2","h3","h4","h5","h6","ul","ol","li","blockquote","pre","code","table","thead","tbody","tfoot","tr","th","td","br","hr","strong","em","b","i","s","del","u","a","img","sub","sup"]),R=new Set(["script","style","meta","link","title","head","noscript","template","iframe","object","embed","button","input","select","textarea","svg","canvas","colgroup","col","caption"]),w={a:["href","title"],img:["src","alt","title"],td:["colspan","rowspan"],th:["colspan","rowspan"],ol:["start"]};function P(e){return(e.getAttribute("style")??"").toLowerCase().replace(/\s/g,"")}function v(e){let o=P(e),r=[];return/font-weight:(bold|bolder|[6-9]00)/.exec(o)&&r.push("strong"),/font-style:italic/.test(o)&&r.push("em"),/text-decoration:[^;]*line-through/.test(o)&&r.push("s"),r}function A(e){return e.tagName.toLowerCase()==="b"&&/font-weight:normal/.test(P(e))}var T=/msolist/i,O=/^[·•●■○–\-o]\s*$/,S=/^(\d+[.)]|[a-z][.)]|[ivx]+[.)])\s*$/i;function p(e){let o=e.parentNode;if(o){for(;e.firstChild;)o.insertBefore(e.firstChild,e);o.removeChild(e)}}function C(e,o,r){let n=e.createElement(r);for(;o.firstChild;)n.appendChild(o.firstChild);return o.parentNode?.replaceChild(n,o),n}function D(e){let o=Array.from(e.body.querySelectorAll("p")).filter(n=>T.test(n.getAttribute("class")??"")),r=null;for(let n of o){let l=n.firstChild,i=(l?.textContent?.replace(/ /g," ")??"").trim(),m=S.test(i),a=O.test(i);if(!m&&!a){r=null;continue}l&&n.removeChild(l);let s=m?"ol":"ul",c=n.previousElementSibling;r&&c===r&&r.tagName.toLowerCase()===s||(r=e.createElement(s),n.parentNode?.insertBefore(r,n));let f=e.createElement("li");for(;n.firstChild;)f.appendChild(n.firstChild);r.appendChild(f),n.parentNode?.removeChild(n)}}function u(e,o,r){let n=Array.from(o.childNodes);for(let l of n){if(l.nodeType===8){o.removeChild(l);continue}if(l.nodeType!==1)continue;let t=l,i=t.tagName.toLowerCase();if(R.has(i)||i.includes(":")){i.includes(":")?p(t):o.removeChild(t);continue}if(A(t)){u(e,t,r),p(t);continue}if(i==="span"||i==="font"||i==="div"||i==="section"||i==="article"){u(e,t,r);let a=i==="span"?v(t):[];if(a.length>0){let s=t;for(let c of a)s=C(e,s,c);s.removeAttribute("style")}else p(t);continue}if((i==="b"||i==="i")&&(t=C(e,t,i==="b"?"strong":"em")),i==="a"&&(!r.links||!b(t.getAttribute("href")??""))){u(e,t,r),p(t);continue}if(i==="img"&&!r.images){o.removeChild(t);continue}if(i==="table"&&!r.tables){let a=Array.from(t.querySelectorAll("td, th"));for(let s of a){u(e,s,r);let c=e.createElement("p");for(;s.firstChild;)c.appendChild(s.firstChild);t.parentNode?.insertBefore(c,t)}o.removeChild(t);continue}if(!N.has(t.tagName.toLowerCase())){u(e,t,r),p(t);continue}let m=w[t.tagName.toLowerCase()]??[];for(let a of Array.from(t.attributes))m.includes(a.name)||t.removeAttribute(a.name);u(e,t,r)}}function h(e,o={}){let r={tables:o.tables??!0,links:o.links??!0,images:o.images??!0},n=new DOMParser().parseFromString(e,"text/html");return D(n),u(n,n.body,r),n.body.innerHTML}function g(e){return/docs-internal-guid|urn:schemas-microsoft-com|class="?Mso|data-pm-slice|confluence|WordDocument|xmlns:o=/i.test(e)}function y({when:e="rich-sources",transform:o,tables:r,links:n,images:l}={}){let[t]=H(),i=z(o);return i.current=o,L(()=>t.registerCommand(W,m=>{let a=m.clipboardData;if(!a)return!1;let s=m.target;if(s instanceof HTMLElement&&s.closest("input, textarea"))return!1;let c=a.getData("text/html");if(!c||e==="rich-sources"&&!g(c))return!1;let f=U();if(!$(f))return!1;m.preventDefault();let d=h(c,{tables:r,links:n,images:l});i.current&&(d=i.current(d));let E=new DOMParser().parseFromString(d,"text/html"),x=M(t,E);return _(q),k(t,x,f),!0},B),[t,e,r,n,l]),null}export{h as a,g as b,y as c};
|