domaintrail 0.2.0 → 0.3.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/README.md +5 -3
- package/dist/dt.js +323 -216
- package/dist/web/{chunk-13zkn5c3.js → chunk-xn56ecvv.js} +2 -2
- package/dist/web/index.html +1 -1
- package/package.json +3 -3
|
@@ -549,8 +549,8 @@ ${n}
|
|
|
549
549
|
${(o?t.height:0)-(s?s:0)}px)`:""} ${a}`,transformOrigin:t?"0 0":"center center"}}function Vze({shape:e,src:t}){let n=Ti(),o=wpe(e),r=e.props.crop;if(o.transform&&r){let{transform:i,width:s,height:a}=o,l=(r.bottomRight.x-r.topLeft.x)*s,c=(r.bottomRight.y-r.topLeft.y)*a,u=[new T(0,0),new T(l,0),new T(l,c),new T(0,c)],f=Z1(e,{width:s,height:a});return E(Y,{children:[h("defs",{children:h("clipPath",{id:n,children:r.isCircle?h("ellipse",{cx:l/2,cy:c/2,rx:l/2,ry:c/2}):h("polygon",{points:u.map((d)=>`${d.x},${d.y}`).join(" ")})})}),h("g",{clipPath:`url(#${n})`,children:h("image",{href:t,width:s,height:a,"aria-label":e.props.altText,style:f?{...f}:{transform:i}})})]})}else return h("image",{href:t,width:e.props.w,height:e.props.h,"aria-label":e.props.altText,style:Z1(e,{width:e.props.w,height:e.props.h})})}function Cpe(e){let t=!1;return{promise:new Promise((o,r)=>{let i=tl();i.onload=()=>{if(t)return;let s=Rn().createElement("canvas");s.width=i.width,s.height=i.height;let a=s.getContext("2d");if(!a){r(Error("Could not get a 2d canvas context"));return}a.drawImage(i,0,0),o(s.toDataURL())},i.onerror=()=>{if(t)return;r(Error(`Could not load image: ${e}`))},i.crossOrigin="anonymous",i.src=e}),cancel:()=>t=!0}}var jze=new $t;class BL extends Bo{static type="line";static props=O0;static migrations=N0;options={getDefaultDisplayValues(e,t,n,o){let{color:r,size:i}=t.props;return{strokeColor:Tt(n.colors[o],r,"solid"),strokeWidth:n.strokeWidth*xn[i]}},getCustomDisplayValues(){return{}}};hideResizeHandles(e){return!0}hideRotateHandle(e){return!0}hideSelectionBoundsFg(e){return!0}hideSelectionBoundsBg(e){return!0}hideInMinimap(){return!0}getDefaultProps(){let[e,t]=Zl(2);return{dash:"draw",size:"m",color:"black",spline:"line",points:{[e]:{id:e,index:e,x:0,y:0},[t]:{id:t,index:t,x:0.1,y:0.1}},scale:1}}getGeometry(e){let t=O8(e).toGeometry();return de(t instanceof US),t}getHandles(e){return jze.get(e.props,()=>{let t=this.getGeometry(e),n=J1(e),o=n.map((r)=>({...r,id:r.id,type:"vertex",canSnap:!0}));for(let r=0;r<n.length-1;r++){let i=Ca(n[r].index,n[r+1].index),a=t.getSegments()[r].interpolateAlongEdge(0.5);o.push({id:i,type:"create",index:i,x:a.x,y:a.y,canSnap:!0})}return o.sort(Hn)})}onResize(e,t){let{scaleX:n,scaleY:o}=t;return{props:{points:jr(e.props.points,(r,{id:i,index:s,x:a,y:l})=>({id:i,index:s,x:a*n,y:l*o}))}}}onBeforeCreate(e){let{props:{points:t}}=e,n=Object.keys(t);if(n.length<2)return;let o=t[n[0]];if(n.every((i)=>{let s=t[i];return s.x===o.x&&s.y===o.y})){let i=n[n.length-1];return{...e,props:{...e.props,points:{...t,[i]:{...t[i],x:t[i].x+0.1,y:t[i].y+0.1}}}}}return}onHandleDrag(e,{handle:t}){let n=Uo(new T(t.x,t.y),this.editor);return{...e,props:{...e.props,points:{...e.props.points,[t.id]:{id:t.id,index:t.index,x:n.x,y:n.y}}}}}onHandleDragStart(e,{handle:t}){if(t.type==="create")return{...e,props:{...e.props,points:{...e.props.points,[t.index]:{id:t.index,index:t.index,x:t.x,y:t.y}}}};return}component(e){let t=Eo(),n=ze(this,e,t);return h(qr,{style:{minWidth:50,minHeight:50},children:h(Tpe,{shape:e,strokeColor:n.strokeColor,strokeWidth:n.strokeWidth})})}getIndicatorPath(e){let t=ze(this,e).strokeWidth*e.props.scale,n=O8(e),{dash:o}=e.props;return n.toPath2D({style:o==="draw"?"draw":"solid",strokeWidth:1,passes:1,randomSeed:e.id,offset:0,roundness:t*2})}toSvg(e,t){let n=ze(this,e,t.colorMode);return h(Tpe,{shouldScale:!0,shape:e,strokeColor:n.strokeColor,strokeWidth:n.strokeWidth})}getHandleSnapGeometry(e){let t=J1(e);return{points:t,getSelfSnapPoints:(n)=>{let o=this.getHandles(e).filter((r)=>r.type==="vertex").findIndex((r)=>r.id===n.id);return t.filter((r,i)=>Math.abs(i-o)>1).map(T.From)},getSelfSnapOutline:(n)=>{let o=this.getHandles(e).filter((i)=>i.type==="vertex").findIndex((i)=>i.id===n.id),r=this.getGeometry(e).getSegments().filter((i,s)=>s!==o-1&&s!==o);if(!r.length)return null;return new Dn({children:r})}}}getInterpolatedProps(e,t,n){let o=J1(e),r=J1(t),i=[],s=[],a=yh;if(o.length>r.length)for(let l=0;l<o.length;l++){if(i[l]={...o[l]},r[l]===void 0)s[l]={...r[r.length-1],id:a};else s[l]={...r[l],id:a};a=cr(a)}else if(r.length>o.length)for(let l=0;l<r.length;l++){if(s[l]={...r[l]},o[l]===void 0)i[l]={...o[o.length-1],id:a,index:a};else i[l]={...o[l],id:a,index:a};a=cr(a)}else for(let l=0;l<r.length;l++)i[l]=o[l],s[l]=r[l];return{...n>0.5?t.props:e.props,points:Object.fromEntries(i.map((l,c)=>{let u=s[c];return[l.id,{...l,x:De(l.x,u.x,n),y:De(l.y,u.y,n)}]})),scale:De(e.props.scale,t.props.scale,n)}}}function J1(e){let t=Object.values(e.props.points).sort(Hn);return t.filter((n,o)=>o===0||n.index!==t[o-1].index)}var $ze=new $t;function O8(e){return $ze.get(e,()=>{let t=J1(e).map(T.From);if(t.length===0)t.push(new T(0,0));if(t.length===1)t.push(t[0].clone().addXY(0.1,0.1));switch(e.props.spline){case"cubic":return Vt.cubicSplineThroughPoints(t,{endOffsets:0});case"line":return Vt.lineThroughPoints(t,{endOffsets:0})}})}function Tpe({shape:e,shouldScale:t=!1,forceSolid:n=!1,strokeColor:o,strokeWidth:r}){let i=O8(e),{dash:s}=e.props,a=1/e.props.scale,l=t?a:1,c=r*e.props.scale;return i.toSvg({style:s,strokeWidth:c,forceSolid:n,randomSeed:e.id,props:{transform:`scale(${l})`,stroke:o,fill:"none"}})}q();function N8({name:e,firstName:t,color:n,scale:o,variant:r}){if(r==="export")return h("div",{className:"tl-note__attribution",style:{fontSize:11,color:n,opacity:0.6},children:t});return h(xs,{content:e,side:"bottom",children:h("div",{className:"tl-note__attribution",style:{["--note-attribution-scale"]:o,fontSize:11*o,color:n,opacity:0.6},children:t})})}var Gze=Object.freeze({start:"start",middle:"center",end:"end","start-legacy":"start","end-legacy":"end","middle-legacy":"center"}),qze=Object.freeze({start:"start",middle:"middle",end:"end"});class UL extends Bo{static type="note";static props=F0;static migrations=B0;options={resizeMode:"none",AttributionComponent:N8,getDefaultDisplayValues(e,t,n,o){let{color:r,labelColor:i,font:s,size:a,align:l,verticalAlign:c}=t.props,u=n.colors[o];return{noteWidth:200,noteHeight:200,noteBackgroundColor:Tt(u,r,"noteFill"),borderColor:u.noteBorder,borderWidth:2,labelColor:i==="black"?Tt(u,r,"noteText"):Tt(u,i,"fill"),labelFontFamily:ea(n,s),labelFontSize:n.fontSize*pC[a],labelLineHeight:n.lineHeight,labelFontWeight:Lr.fontWeight,labelFontVariant:Lr.fontVariant,labelFontStyle:Lr.fontStyle,labelPadding:Ou,labelHorizontalAlign:Gze[l],labelVerticalAlign:qze[c]}},getCustomDisplayValues(){return{}}};canEdit(e){return!0}hideResizeHandles(e){let{resizeMode:t}=this.options;switch(t){case"none":return!0;case"scale":return!1;default:throw Qe(t)}}isAspectRatioLocked(e){return this.options.resizeMode==="scale"}hideSelectionBoundsFg(e){return!1}getDefaultProps(){return{color:"black",richText:Yt(""),size:"m",font:"draw",align:"middle",verticalAlign:"middle",labelColor:"black",growY:0,fontSizeAdjustment:1,url:"",scale:1,textLastEditedBy:null}}getGeometry(e){let{labelHeight:t,labelWidth:n}=this.getLabelSize(e),{scale:o}=e.props,r=ze(this,e),i=t*o,s=n*o,a=r.noteWidth*o,l=zL(e,r.noteHeight);return new Dn({children:[new $n({width:a,height:l,isFilled:!0}),new $n({x:r.labelHorizontalAlign==="start"?0:r.labelHorizontalAlign==="end"?a-s:(a-s)/2,y:r.labelVerticalAlign==="start"?0:r.labelVerticalAlign==="end"?l-i:(l-i)/2,width:s,height:i,isFilled:!0,isLabel:!0,excludeFromShapeBounds:!0})]})}getHandles(e){let{scale:t}=e.props;if(this.editor.getInstanceState().isCoarsePointer)return[];let o=this.editor.getEfficientZoomLevel();if(o*t<0.25)return[];let r=ze(this,e),i=zL(e,r.noteHeight),s=r.noteWidth*t,a=Nfe/o*t;if(o*t<0.5)return[{id:"bottom",index:"a3",type:"clone",x:s/2,y:i+a}];return[{id:"top",index:"a1",type:"clone",x:s/2,y:-a},{id:"right",index:"a2",type:"clone",x:s+a,y:i/2},{id:"bottom",index:"a3",type:"clone",x:s/2,y:i+a},{id:"left",index:"a4",type:"clone",x:-a,y:i/2}]}onResize(e,t){let{resizeMode:n}=this.options;switch(n){case"none":return;case"scale":return Cw(e,t);default:throw Qe(n)}}getText(e){return na(this.editor,e.props.richText)}getReferencedUserIds(e){return e.props.textLastEditedBy?[e.props.textLastEditedBy]:[]}getFontFaces(e){let t=sn(e.props.richText)?[]:Du(this.editor,e.props.richText,{family:`tldraw_${e.props.font}`,weight:"normal",style:"normal"}),n=ep(this.editor.getCurrentTheme(),e.props.font),o=n?[...n,...t]:t;if(e.props.textLastEditedBy&&!sn(e.props.richText))return[...o,wm.tldraw_sans.normal.normal];return o.length?o:kt}component(e){let{id:t,type:n,props:o}=e,{scale:r,richText:i,fontSizeAdjustment:s,textLastEditedBy:a}=o,l=Kze(t),c=H("shape rotation",()=>this.editor.getShapePageTransform(t)?.rotation()??0,[this.editor]),u=Eo(),f=ze(this,e,u),d=f.noteWidth*r,p=zL(e,f.noteHeight),m=xp(0.25/r),g=e.id===this.editor.getOnlySelectedShapeId(),y=V1(this.editor,e.id),S=sn(i),b=this.options.AttributionComponent,x=H("attribution",()=>{if(!a||S)return null;let w=this.editor.getAttributionDisplayName(a);if(!w)return null;return{short:w.split(" ")[0],full:w}},[a,S,this.editor]);return E(Y,{children:[E("div",{id:t,className:"tl-note__container",style:{width:d,height:p,backgroundColor:f.noteBackgroundColor,borderBottom:m?`${f.borderWidth*r}px solid ${f.borderColor}`:"none",boxShadow:m?"none":Wze(e.id,c,r)},children:[x&&b&&h(b,{shape:e,name:x.full,firstName:x.short,color:f.labelColor,scale:r,variant:"canvas"}),(g||y||!S)&&h(gd,{shapeId:t,type:n,fontFamily:f.labelFontFamily,fontSize:(s??1)*f.labelFontSize,lineHeight:f.labelLineHeight,textAlign:f.labelHorizontalAlign,verticalAlign:f.labelVerticalAlign,richText:i,isSelected:g,labelColor:f.labelColor,wrap:!0,padding:f.labelPadding,hasCustomTabBehavior:!0,showTextOutline:!1,onKeyDown:l,style:r!==1?{transform:`scale(${r})`,transformOrigin:"top left",width:f.noteWidth,height:f.noteHeight+e.props.growY}:void 0})]}),"url"in e.props&&e.props.url&&h(_l,{url:e.props.url})]})}getIndicatorPath(e){let{scale:t}=e.props,n=ze(this,e),o=new Path2D;return o.rect(0,0,n.noteWidth*t,zL(e,n.noteHeight)),o}toSvg(e,t){let n=ze(this,e,t.colorMode),o=new Z(0,0,n.noteWidth,n.noteHeight+e.props.growY),r=`note-shadow-${e.id.replace(/:/g,"_")}`;t.addExportDef({key:r,getElement:()=>E("filter",{id:r,x:"-10%",y:"-10%",width:"130%",height:"150%",children:[h("feMorphology",{in:"SourceAlpha",operator:"erode",radius:"3",result:"erode1"}),h("feGaussianBlur",{in:"erode1",stdDeviation:"3",result:"blur1"}),h("feOffset",{in:"blur1",dy:"3",result:"offsetBlur1"}),h("feComponentTransfer",{in:"offsetBlur1",result:"shadow1",children:h("feFuncA",{type:"linear",slope:"0.5"})}),h("feMorphology",{in:"SourceAlpha",operator:"erode",radius:"10",result:"erode2"}),h("feGaussianBlur",{in:"erode2",stdDeviation:"6",result:"blur2"}),h("feOffset",{in:"blur2",dy:"6",result:"offsetBlur2"}),h("feComponentTransfer",{in:"offsetBlur2",result:"shadow2",children:h("feFuncA",{type:"linear",slope:"0.5"})}),E("feMerge",{children:[h("feMergeNode",{in:"shadow1"}),h("feMergeNode",{in:"shadow2"}),h("feMergeNode",{in:"SourceGraphic"})]})]})});let{textLastEditedBy:i}=e.props,s=i&&!sn(e.props.richText)?this.editor.getAttributionDisplayName(i)??null:null,a=s?.split(" ")[0]??null,l=this.options.AttributionComponent;return E(Y,{children:[t.isDarkMode?null:h("rect",{rx:1,width:n.noteWidth,height:o.h,fill:n.noteBackgroundColor,filter:`url(#${r})`}),h("rect",{rx:1,width:n.noteWidth,height:o.h,fill:n.noteBackgroundColor}),h(yd,{fontSize:(e.props.fontSizeAdjustment??1)*n.labelFontSize,fontFamily:n.labelFontFamily,lineHeight:n.labelLineHeight,textAlign:n.labelHorizontalAlign,verticalAlign:n.labelVerticalAlign,richText:e.props.richText,labelColor:n.labelColor,bounds:o,padding:n.labelPadding,showTextOutline:!1}),a&&s&&l&&h("foreignObject",{x:0,y:0,width:n.noteWidth,height:o.h,className:"tl-export-embed-styles",children:h("div",{style:{position:"relative",width:"100%",height:"100%"},children:h(l,{shape:e,name:s,firstName:a,color:n.labelColor,scale:1,variant:"export"})})})]})}onBeforeCreate(e){return this.getNoteSizeAdjustments(e)}onBeforeDuplicate(e,t){if(sn(t.props.richText))return;return{...t,props:{...t.props,textLastEditedBy:this.editor.getAttributionUserId()}}}onBeforeUpdate(e,t){let n=!ao.default(e.props.richText,t.props.richText);if(!n&&e.props.font===t.props.font&&e.props.size===t.props.size)return;let o=t;if(n)if(sn(t.props.richText))o={...o,props:{...o.props,textLastEditedBy:null}};else o={...o,props:{...o.props,textLastEditedBy:this.editor.getAttributionUserId()}};return this.getNoteSizeAdjustments(o)??(n?o:void 0)}getInterpolatedProps(e,t,n){return{...n>0.5?t.props:e.props,scale:De(e.props.scale,t.props.scale,n)}}getNoteSizeAdjustments(e){let t=ze(this,e),{labelHeight:n,fontSizeAdjustment:o}=this.getLabelSize(e),r=Math.max(0,n-t.noteHeight);if(r!==e.props.growY||o!==e.props.fontSizeAdjustment)return{...e,props:{...e.props,growY:r,fontSizeAdjustment:o}};return}_labelSizesForNoteCache=new $t;getLabelSize(e){return this._labelSizesForNoteCache.get(e,()=>this.measureNoteLabelSize(e))}measureNoteLabelSize(e){let t=ze(this,e),{richText:n}=e.props;if(sn(n))return{labelHeight:hs(t.labelFontSize,t.labelLineHeight)+t.labelPadding*2,labelWidth:100,fontSizeAdjustment:1};let o=t.labelFontSize,r=o,i=0,{noteHeight:s,noteWidth:a}=t,l=1;do{r=Math.min(o,o-i);let c=ta(this.editor,n),u=this.editor.textMeasure.measureHtml(c,{...Lr,lineHeight:t.labelLineHeight,fontFamily:t.labelFontFamily,fontSize:r,maxWidth:t.noteWidth-t.labelPadding*2-l,disableOverflowWrapBreaking:!0,measureScrollWidth:!0});if(s=u.h+t.labelPadding*2,a=u.w+t.labelPadding*2,r<=14){let f=ta(this.editor,n),d=this.editor.textMeasure.measureHtml(f,{...Lr,lineHeight:t.labelLineHeight,fontFamily:t.labelFontFamily,fontSize:r,maxWidth:t.noteWidth-t.labelPadding*2-l});s=d.h+t.labelPadding*2,a=d.w+t.labelPadding*2;break}if(u.scrollWidth.toFixed(0)===u.w.toFixed(0))break}while(i++<50);return{labelHeight:s,labelWidth:a,fontSizeAdjustment:r===o?1:r/o}}}function Kze(e){let t=B(),n=Te(lC);return O((o)=>{let r=t.getShape(e);if(!r)return;let i=o.key==="Tab",s=(o.metaKey||o.ctrlKey)&&o.key==="Enter";if(i&&J_(t)){o.preventDefault();return}if(i||s){o.preventDefault();let a=t.getShapePageTransform(e),l=a.rotation(),c=!!(n?.dir==="rtl"||Q_(na(t,r.props.richText))),u=t.getShapeUtil(r),f=ze(u,r),p=(i?f.noteWidth+t.options.adjacentShapeMargin:f.noteHeight+t.options.adjacentShapeMargin+(s&&!o.shiftKey?r.props.growY:0))*r.props.scale,m=new T(i?o.shiftKey!=c?-1:1:0,s?o.shiftKey?-1:1:0).mul(p).add(new T(f.noteWidth/2,f.noteHeight/2).mul(r.props.scale)).rot(l).add(a.point()),g=gL(t,{shape:r,center:m,pageRotation:l,noteWidth:f.noteWidth,noteHeight:f.noteHeight});if(g)yL(t,g)}},[e,t,n?.dir])}function zL(e,t){return(t+e.props.growY)*e.props.scale}function Wze(e,t,n){let o=Fs(e),r=Math.abs(o())+0.5,i=Math.cos(t),s=5*n,a=4*n,l=6*n,c=7*n;return`0px ${Math.max(0,s-r)}px ${s}px -${s}px rgba(15, 23, 31, .6),
|
|
550
550
|
0px ${(a+r*c)*Math.max(0,i)}px ${l+r*c}px -${a+r*l}px rgba(15, 23, 31, ${(0.3+r*0.1).toFixed(2)}),
|
|
551
551
|
0px ${48*n}px ${10*n}px -${10*n}px inset rgba(15, 23, 44, ${((0.022+o()*0.005)*((1+i)/2)).toFixed(2)})`}q();var Yze=0.3,Xze=Vs("text size",(e,t)=>{e.fonts.trackFontsForShape(t);let n=e.getShapeUtil(t),o=ze(n,t);return Ipe(e,t.props,o)},{areRecordsEqual:(e,t)=>e.props===t.props});class HL extends Bo{static type="text";static props=z0;static migrations=U0;options={extraArrowHorizontalPadding:10,showTextOutline:!0,getDefaultDisplayValues(e,t,n,o){let{color:r,font:i,size:s}=t.props;return{color:Tt(n.colors[o],r,"solid"),fontFamily:ea(n,i),fontSize:n.fontSize*Sm[s],lineHeight:n.lineHeight,fontWeight:Lr.fontWeight,fontStyle:Lr.fontStyle,fontVariant:Lr.fontVariant}},getCustomDisplayValues(){return{}}};getDefaultProps(){return{color:"black",size:"m",w:8,font:"draw",textAlign:"start",autoSize:!0,scale:1,richText:Yt("")}}getMinDimensions(e){return Xze.get(this.editor,e.id)}getGeometry(e,t){let{scale:n}=e.props,{width:o,height:r}=this.getMinDimensions(e),i=t?.context??"none";return new $n({x:(i==="@tldraw/arrow-without-arrowhead"?-this.options.extraArrowHorizontalPadding:0)*n,width:(o+(i==="@tldraw/arrow-without-arrowhead"?this.options.extraArrowHorizontalPadding*2:0))*n,height:r*n,isFilled:!0,isLabel:!0})}getFontFaces(e){let t=ep(this.editor.getCurrentTheme(),e.props.font);if(t)return t;return Du(this.editor,e.props.richText,{family:`tldraw_${e.props.font}`,weight:"normal",style:"normal"})}getText(e){return na(this.editor,e.props.richText)}canEdit(e){return!0}isAspectRatioLocked(e){return!0}component(e){let{id:t,props:{richText:n,scale:o,textAlign:r}}=e,{width:i,height:s}=this.getMinDimensions(e),a=e.id===this.editor.getOnlySelectedShapeId(),l=Eo(),c=ze(this,e,l),u=Zze(t);return h(gd,{shapeId:t,classNamePrefix:"tl-text-shape",type:"text",fontFamily:c.fontFamily,fontSize:c.fontSize,lineHeight:c.lineHeight,textAlign:r==="middle"?"center":r,verticalAlign:"middle",richText:n,labelColor:c.color,isSelected:a,textWidth:i,textHeight:s,showTextOutline:this.options.showTextOutline,style:{transform:`scale(${o})`,transformOrigin:"top left"},wrap:!0,onKeyDown:u})}getIndicatorPath(e){if(e.props.autoSize&&this.editor.getEditingShapeId()===e.id)return;let t=this.editor.getShapeGeometry(e).bounds,n=new Path2D;return n.rect(0,0,t.width,t.height),n}toSvg(e,t){let n=this.editor.getShapeGeometry(e).bounds,o=n.width/(e.props.scale??1),r=n.height/(e.props.scale??1),i=ze(this,e,t.colorMode),s=Math.ceil(i.fontSize*Yze),a=new Z(-s,-s,o+s*2,r+s*2);return h(yd,{fontSize:i.fontSize,fontFamily:i.fontFamily,lineHeight:i.lineHeight,textAlign:e.props.textAlign==="middle"?"center":e.props.textAlign,verticalAlign:"middle",richText:e.props.richText,labelColor:i.color,bounds:a,padding:s,showTextOutline:this.options.showTextOutline})}onResize(e,t){let{newPoint:n,initialBounds:o,initialShape:r,scaleX:i,handle:s}=t;if(t.mode==="scale_shape"||s!=="right"&&s!=="left")return{id:e.id,type:e.type,...Cw(e,t)};else{let a=Math.max(1,Math.abs(o.width*i)),{x:l,y:c}=i<0?T.Sub(n,T.FromAngle(e.rotation).mul(a)):n;return{id:e.id,type:e.type,x:l,y:c,props:{w:a/r.props.scale,autoSize:!1}}}}onEditEnd(e){if(na(this.editor,e.props.richText).trimEnd().length===0)this.editor.deleteShapes([e.id])}onBeforeUpdate(e,t){if(!t.props.autoSize)return;let n=e.props.size!==t.props.size||e.props.textAlign!==t.props.textAlign||e.props.font!==t.props.font||e.props.scale!==1&&t.props.scale===1,o=!ao.default(e.props.richText,t.props.richText);if(!n&&!o)return;let r=this.getMinDimensions(e),i=ze(this,t),s=Ipe(this.editor,t.props,i),a=r.width*e.props.scale,l=r.height*e.props.scale,c=s.width*t.props.scale,u=s.height*t.props.scale,f;switch(t.props.textAlign){case"middle":{f=new T((c-a)/2,o?0:(u-l)/2);break}case"end":{f=new T(c-a,o?0:(u-l)/2);break}default:{if(o)break;f=new T(0,(u-l)/2);break}}if(f){f.rot(t.rotation);let{x:d,y:p}=t;return{...t,x:d-f.x,y:p-f.y,props:{...t.props,w:c}}}else return{...t,props:{...t.props,w:c}}}}function Ipe(e,t,n){let{richText:o,w:r}=t,i=16,s=t.autoSize?null:Math.max(16,Math.floor(r)),a=ta(e,o),l=e.textMeasure.measureHtml(a,{lineHeight:n.lineHeight,fontWeight:n.fontWeight,fontStyle:n.fontStyle,padding:"0px",fontFamily:n.fontFamily,fontSize:n.fontSize,maxWidth:s});return{width:s??Math.max(16,l.w+1),height:Math.max(n.fontSize,l.h)}}function Zze(e){let t=B();return O((n)=>{if(t.getEditingShapeId()!==e)return;switch(n.key){case"Enter":{if(n.ctrlKey||n.metaKey)t.complete();break}}},[t,e])}q();var Ppe=wt(Jt(),1);var F8=new $t;class VL extends Yr{static type="video";static props=H0;static migrations=V0;static handledAssetTypes=["video"];options={autoplay:!0,getDefaultDisplayValues(){return{}},getCustomDisplayValues(){return{}}};canEdit(e){return!0}isAspectRatioLocked(e){return!0}getDefaultProps(){return{w:100,h:100,assetId:null,autoplay:this.options.autoplay,url:"",altText:"",time:0,playing:!0}}createShapeForAsset(e,t){let n=e;return{id:Ke(),type:"video",x:t.x,y:t.y,opacity:1,props:{assetId:n.id,w:n.props.w,h:n.props.h}}}getAriaDescriptor(e){return e.props.altText}component(e){return h(Jze,{shape:e})}getIndicatorPath(e){let t=new Path2D;return t.rect(0,0,e.props.w,e.props.h),t}async toSvg(e,t){let n=e.props;if(!n.assetId)return null;let o=this.editor.getAsset(n.assetId);if(!o)return null;let r=F8.get(o,async()=>{let s=await t.resolveAssetUrl(o.id,n.w);if(!s)return null;let a=await lr.loadVideo(s,this.editor.getContainerDocument());return await lr.getVideoFrameAsDataUrl(a,0)}),i=await r.catch((s)=>{if(F8.items.get(o)===r)F8.items.delete(o);return console.error(`Could not export video ${o.id}`,s),null});if(!i)return null;return h("image",{href:i,width:n.w,height:n.h,"aria-label":e.props.altText})}}var Jze=xe(function({shape:t}){let n=B(),o=n.getShapeGeometry(t).bounds.w*n.getEfficientZoomLevel()>=110,r=wu(t.id),i=iC(),{Spinner:s}=kn(),{asset:a,url:l}=W1({shapeId:t.id,assetId:t.props.assetId,width:t.props.w}),c=L(null),[u,f]=G(!1),d=O((y)=>{if(!y.currentTarget)return;f(!0)},[]),[p,m]=G(!1);F(()=>{let y=c.current?.ownerDocument??n.getContainerDocument(),S=()=>m(y.fullscreenElement===c.current);return y.addEventListener("fullscreenchange",S),()=>y.removeEventListener("fullscreenchange",S)}),F(()=>{let y=c.current;if(!y)return;if(r){if(y.ownerDocument.activeElement!==y)y.focus()}},[r,u]);let g=!!a?.props.src&&!!l&&u;return E(Y,{children:[h(Gr,{id:t.id,style:{color:"var(--tl-color-text-3)",backgroundColor:g?"transparent":"var(--tl-color-low)",border:g?"none":"1px solid var(--tl-color-low-border)"},children:h("div",{className:"tl-counter-scaled",children:h("div",{className:"tl-video-container",children:!a?h(OL,{}):s&&!a.props.src?h(s,{}):l?E(Y,{children:[h("video",{ref:c,style:r?{pointerEvents:"all"}:!u?{display:"none"}:void 0,className:Ppe.default("tl-video",`tl-video-shape-${t.id.split(":")[1]}`,{"tl-video-is-fullscreen":p}),width:"100%",height:"100%",draggable:!1,playsInline:!0,autoPlay:t.props.autoplay&&!i,muted:!0,loop:!0,disableRemotePlayback:!0,disablePictureInPicture:!0,controls:r&&o,onLoadedData:d,hidden:!u,"aria-label":t.props.altText,children:h("source",{src:l})},l),!u&&s&&h(s,{})]}):null})})}),"url"in t.props&&t.props.url&&h(_l,{url:t.props.url})]})});var Q1=[HL,IL,EL,LL,UL,BL,ML,TL,DL,wp,FL,VL];function B8(e){let t=(o)=>{e.getShapeUtil("embed").resolveAspectRatio(o)},n=e.sideEffects.register({shape:{afterCreate:(o,r)=>{if(r!=="user")return;if(e.isShapeOfType(o,"embed"))t(o)},afterChange:(o,r,i)=>{if(i!=="user")return;if(e.isShapeOfType(r,"embed")&&o.props.url!==r.props.url)t(r)}},instance:{afterChange:(o,r)=>{if(o.cameraState!==r.cameraState&&r.cameraState==="idle")El(e)}},instance_page_state:{afterChange:(o,r)=>{if(o.croppingShapeId!==r.croppingShapeId){let i=e.isIn("select.crop");if(!o.croppingShapeId&&r.croppingShapeId){if(!i)e.setCurrentTool("select.crop.idle")}else if(o.croppingShapeId&&!r.croppingShapeId){if(i)e.setCurrentTool("select.idle")}}if(o.editingShapeId!==r.editingShapeId){if(!o.editingShapeId&&r.editingShapeId){if(!e.isIn("select.editing_shape")){let i=e.getEditingShape();if(i&&i.type==="text"&&e.isInAny("text.pointing","select.resizing")&&e.getInstanceState().isToolLocked)e.setCurrentTool("select.editing_shape",{target:"shape",shape:i,isCreatingTextWhileToolLocked:!0});else e.setCurrentTool("select.editing_shape",{target:"shape",shape:i})}}else if(o.editingShapeId&&!r.editingShapeId){if(e.isIn("select.editing_shape"))e.setCurrentTool("select.idle")}}}}});return()=>{n(),Sp(e)}}class z8 extends re{static id="erasing";static trackPerformance=!0;info={};scribbleId="id";markId="";excludedShapeIds=new Set;_erasingShapeIds=[];onEnter(e){this.markId=this.editor.markHistoryStoppingPoint("erase scribble begin"),this.info=e;let t=this.editor.inputs.getOriginPagePoint(),n=new Set(this.editor.getErasingShapeIds());this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter((r)=>{if(this.editor.isShapeOrAncestorLocked(r))return!0;if(this.editor.isShapeFrameLike(r)&&n.has(r.id))return!1;if(this.editor.isShapeOfType(r,"group")||this.editor.isShapeFrameLike(r)){let i=this.editor.getPointInShapeSpace(r,t);return this.editor.getShapeGeometry(r).bounds.containsPoint(i)}return!1}).map((r)=>r.id)),this._erasingShapeIds=this.editor.getShapesAtPoint(t).filter((r)=>!this.excludedShapeIds.has(r.id)).map((r)=>r.id),this.editor.setErasingShapes([...new Set([...this.editor.getErasingShapeIds(),...this._erasingShapeIds])]);let o=this.editor.scribbles.addScribble({color:"muted-1",size:12});this.scribbleId=o.id,this.update()}pushPointToScribble(){let{x:e,y:t}=this.editor.inputs.getCurrentPagePoint();this.editor.scribbles.addPoint(this.scribbleId,e,t)}onExit(){this.editor.setErasingShapes([]),this.editor.scribbles.stop(this.scribbleId)}onPointerMove(){this.update()}onPointerUp(e){this.complete(e)}onCancel(){this.cancel()}onComplete(){this.complete()}update(){let{editor:e,excludedShapeIds:t}=this,n=e.getErasingShapeIds(),o=e.inputs.getCurrentPagePoint(),r=e.inputs.getPreviousPagePoint();this.pushPointToScribble();let i=new Set(n),s=this.editor.getHitTestMargin(),a=Z.FromPoints([r,o]).expandBy(s),l=e.getShapeIdsInsideBounds(a);if(l.size===0){e.setErasingShapes(Array.from(i));return}let u=e.getCurrentPageRenderingShapesSorted().filter((f)=>l.has(f.id));for(let f of u){if(e.isShapeOfType(f,"group"))continue;let d=e.getShapeMask(f.id);if(d&&!fn(o,d))continue;let p=e.getShapeGeometry(f),m=e.getShapePageTransform(f);if(!p||!m)continue;let g=m.clone().invert(),y=g.applyToPoint(r),S=g.applyToPoint(o),{bounds:b}=p;if(b.minX-s>Math.max(y.x,S.x)||b.minY-s>Math.max(y.y,S.y)||b.maxX+s<Math.min(y.x,S.x)||b.maxY+s<Math.min(y.y,S.y))continue;if(p.hitTestLineSegment(y,S,s)){let x=e.getOutermostSelectableShape(f);if(t.has(x.id))i.add(e.getOutermostSelectableShape(f,(w)=>!t.has(w.id)).id);else i.add(x.id)}this._erasingShapeIds=[...i]}this.editor.setErasingShapes(this._erasingShapeIds.filter((f)=>!t.has(f)))}complete(e){let{editor:t}=this;t.deleteShapes(t.getCurrentPageState().erasingShapeIds),this.parent.transition("idle",e),this._erasingShapeIds=[]}cancel(){let{editor:e}=this;e.bailToMark(this.markId),this.parent.transition("idle",this.info)}}class U8 extends re{static id="idle";onEnter(e){if(!(e?.accelKey??this.editor.inputs.getAccelKey()))this.parent.maybeReturnToOriginatingTool()}onKeyUp(e){if(!Io(e))this.parent.maybeReturnToOriginatingTool()}onPointerDown(e){this.parent.transition("pointing",e)}onCancel(){let e=this.parent.info.onInteractionEnd;this.editor.setCurrentTool(e??"select")}}class H8 extends re{static id="pointing";onEnter(e){let t=e.accelKey,n=this.editor.getCurrentPageRenderingShapesSorted(),o=this.editor.inputs.getCurrentPagePoint(),r=new Set,i=r.size;for(let s=n.length,a=s-1;a>=0;a--){let l=n[a];if(this.editor.isShapeOrAncestorLocked(l)||this.editor.isShapeOfType(l,"group"))continue;if(this.editor.isPointInShape(l,o,{hitInside:!1,margin:this.editor.getHitTestMargin()})){let c=this.editor.getOutermostSelectableShape(l);if(this.editor.isShapeFrameLike(c)&&r.size>i)break;if(r.add(c.id),t)break}}this.editor.setErasingShapes([...r])}onLongPress(e){if(e.accelKey)return;this.startErasing(e)}onExit(e,t){if(t!=="erasing")this.editor.setErasingShapes([])}onPointerMove(e){if(this.editor.inputs.getIsDragging())this.startErasing(e)}onPointerUp(e){this.complete(e)}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.cancel()}startErasing(e){this.parent.transition("erasing",e)}complete(e){let t=this.editor.getErasingShapeIds();if(t.length)this.editor.markHistoryStoppingPoint("erase end"),this.editor.deleteShapes(t);this.parent.transition("idle",e)}cancel(){this.parent.transition("idle")}}class jL extends re{static id="eraser";static initial="idle";static isLockable=!1;static children(){return[U8,H8,z8]}info={};onEnter(e={}){if(this.info=e,e.onInteractionEnd)this.setCurrentToolIdMask(e.onInteractionEnd);this.editor.setCursor({type:"cross",rotation:0})}onExit(){this.setCurrentToolIdMask(void 0),this.info={}}maybeReturnToOriginatingTool(){let{onInteractionEnd:e}=this.info;if(!e)return;this.editor.setCurrentTool(e)}}class V8 extends re{static id="dragging";static trackPerformance=!0;initialCamera=new T;onEnter(){this.initialCamera=T.From(this.editor.getCamera()),this.update()}onPointerMove(){this.update()}onPointerDown(){this.parent.transition("idle")}onPointerUp(){this.complete()}onInterrupt(){this.parent.transition("idle")}onCancel(){this.parent.transition("idle")}onComplete(){this.complete()}update(){let{initialCamera:e,editor:t}=this,n=t.inputs.getCurrentScreenPoint(),o=t.inputs.getOriginScreenPoint(),r=T.Sub(n,o).div(t.getZoomLevel());if(r.len2()===0)return;t.setCamera(e.clone().add(r))}complete(){let{editor:e}=this,t=e.inputs.getPointerVelocity(),n=Math.min(t.len(),2);if(n>0.1)this.editor.slideCamera({speed:n,direction:{x:t.x,y:t.y,z:0}});this.parent.transition("idle")}}class j8 extends re{static id="idle";onEnter(){this.editor.setCursor({type:"grab",rotation:0})}onPointerDown(e){this.parent.transition("pointing",e)}onCancel(){this.editor.setCurrentTool("select")}}class $8 extends re{static id="one_finger_zooming";anchorScreenPoint=new T;initialCamera=new T;initialZoom=1;originScreenY=0;onEnter(e){let t=this.editor.getCamera();this.initialCamera=T.From(t),this.initialZoom=t.z,this.anchorScreenPoint=this.editor.inputs.getOriginScreenPoint().clone(),this.originScreenY=this.editor.inputs.getCurrentScreenPoint().y,this.editor.setCursor({type:"grab",rotation:0})}onPointerMove(e){this.editor.menus.clearOpenMenus();let t=this.editor.inputs.getCurrentScreenPoint().y,n=(this.originScreenY-t)*-1,o=Math.pow(2,n/200),r=this.clampZoom(this.initialZoom*o),{x:i,y:s}=this.initialCamera,{x:a,y:l}=this.anchorScreenPoint;this.editor.setCamera(new T(i+a/r-a/this.initialZoom,s+l/r-l/this.initialZoom,r),{immediate:!0})}onPointerUp(e){this.complete()}onPointerDown(){this.parent.transition("idle")}onComplete(){this.parent.transition("idle")}onCancel(){this.parent.transition("idle")}onInterrupt(){this.parent.transition("idle")}complete(){let e=this.editor.inputs.getPointerVelocity(),t=Math.min(e.len(),2);if(t>0.1)this.editor.slideCamera({speed:t,direction:{x:0,y:0,z:Math.sign(e.y)*0.01}});this.parent.transition("idle")}clampZoom(e){let{zoomSteps:t}=this.editor.getCameraOptions(),n=this.editor.getBaseZoom(),o=t[0]*n,r=go(t)*n;return Pe(e,o,r)}}class G8 extends re{static id="pointing";onEnter(){this.editor.stopCameraAnimation(),this.editor.setCursor({type:"grabbing",rotation:0})}onLongPress(){this.startDragging()}onPointerMove(){if(this.editor.inputs.getIsDragging())this.startDragging()}startDragging(){this.parent.transition("dragging")}onPointerUp(){this.complete()}onCancel(){this.complete()}onComplete(){this.complete()}onInterrupt(){this.complete()}complete(){this.parent.transition("idle")}}class $L extends re{static id="hand";static initial="idle";static isLockable=!1;static children(){return[j8,G8,V8,$8]}onDoubleClick(e){switch(e.phase){case"settle-down":{if(this.editor.getInstanceState().isCoarsePointer)this.transition("one_finger_zooming",e);break}case"settle-up":{let t=this.editor.inputs.getCurrentScreenPoint();this.editor.zoomIn(t,{animation:{duration:220,easing:Fo.easeOutQuint}});break}}}}class q8 extends re{static id="idle";onPointerDown(){let e=this.parent.getSessionId(),t=this.editor.scribbles.addScribbleToSession(e,{color:"laser",opacity:0.7,size:4,taper:!1});this.parent.transition("lasering",{sessionId:e,scribbleId:t.id})}}class K8 extends re{static id="lasering";static trackPerformance=!0;scribbleId="";sessionId="";onEnter(e){this.sessionId=e.sessionId,this.scribbleId=e.scribbleId,this.pushPointToScribble()}onPointerMove(){this.pushPointToScribble()}pushPointToScribble(){let{x:e,y:t}=this.editor.inputs.getCurrentPagePoint();this.editor.scribbles.addPointToSession(this.sessionId,this.scribbleId,e,t)}onTick(){this.editor.scribbles.extendSession(this.sessionId)}onPointerUp(){this.complete()}onCancel(){this.onComplete()}onComplete(){this.complete()}complete(){this.editor.scribbles.complete(this.scribbleId),this.parent.transition("idle")}}class GL extends re{static id="laser";static initial="idle";static children(){return[q8,K8]}static isLockable=!1;sessionId=null;onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onExit(){this.sessionId=null}onCancel(){if(this.sessionId&&this.editor.scribbles.isSessionActive(this.sessionId))this.editor.scribbles.clearSession(this.sessionId),this.sessionId=null,this.transition("idle");else this.editor.setCurrentTool("select")}getSessionId(){if(this.sessionId&&this.editor.scribbles.isSessionActive(this.sessionId))return this.sessionId;return this.sessionId=this.editor.scribbles.startSession({selfConsume:!1,idleTimeoutMs:this.editor.options.laserDelayMs,fadeMode:"grouped",fadeEasing:"ease-in"}),this.sessionId}}class W8 extends re{static id="brushing";static trackPerformance=!0;info={};initialSelectedShapeIds=[];excludedShapeIds=new Set;isWrapMode=!1;viewportDidChange=!1;cleanupViewportChangeReactor(){}onEnter(e){let{editor:t}=this,n=t.inputs.getAltKey();this.isWrapMode=t.user.getIsWrapMode(),t.setCursor({type:"default",rotation:0}),this.viewportDidChange=!1;let o=!0;if(this.cleanupViewportChangeReactor=zt("viewport change while brushing",()=>{if(t.getViewportPageBounds(),!o&&!this.viewportDidChange)this.viewportDidChange=!0}),n){this.parent.transition("scribble_brushing",e);return}let r=t.options.selectLockedShapes;this.excludedShapeIds=new Set(t.getCurrentPageShapes().filter((i)=>t.isShapeOfType(i,"group")||!r&&t.isShapeOrAncestorLocked(i)).map((i)=>i.id)),this.info=e,this.initialSelectedShapeIds=t.getSelectedShapeIds().slice(),this.hitTestShapes(),o=!1}onExit(){this.initialSelectedShapeIds=[],this.editor.updateInstanceState({brush:null}),this.cleanupViewportChangeReactor()}onTick({elapsed:e}){let{editor:t}=this;if(!t.inputs.getIsDragging()||t.inputs.getIsPanning())return;t.edgeScrollManager.updateEdgeScrolling(e)}onPointerMove(){this.hitTestShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(e){this.editor.setSelectedShapes(this.initialSelectedShapeIds),this.parent.transition("idle",e)}onKeyDown(e){if(this.editor.inputs.getAltKey())this.parent.transition("scribble_brushing",e);else this.hitTestShapes()}onKeyUp(){this.hitTestShapes()}complete(){this.hitTestShapes(),this.parent.transition("idle")}hitTestShapes(){let{editor:e,excludedShapeIds:t,isWrapMode:n}=this,o=e.inputs.getOriginPagePoint(),r=e.inputs.getCurrentPagePoint(),i=e.inputs.getShiftKey(),s=e.inputs.getAccelKey(),a=new Set(i?this.initialSelectedShapeIds:[]),l=n?!s:s,c=Z.FromPoints([o,r]),{corners:u}=c,f,d,p,m,g,y,S=e.getViewportPageBounds().contains(c),b=e.getCurrentPageId(),x=e.getShapeIdsInsideBounds(c);if(x.size===0){let P=e.getInstanceState().brush;if(!P||!c.equals(P))e.updateInstanceState({brush:{...c.toJson()}});let k=e.getSelectedShapeIds();if(k.length!==a.size||k.some((_)=>!a.has(_)))e.setSelectedShapes(Array.from(a));return}let v=(S&&!this.viewportDidChange?e.getCurrentPageRenderingShapesSorted():e.getCurrentPageShapesSorted()).filter((P)=>x.has(P.id));e:for(let P=0,k=v.length;P<k;P++){if(p=v[P],t.has(p.id)||a.has(p.id))continue e;if(m=e.getShapePageBounds(p),!m)continue e;if(c.contains(m)){this.handleHit(p,r,b,a,u);continue e}if(l||e.isShapeFrameLike(p))continue e;if(c.collides(m)){if(g=e.getShapePageTransform(p),!g)continue e;y=g.clone().invert().applyToPoints(u);let _=e.getShapeGeometry(p);t:for(let M=0;M<4;M++)if(f=y[M],d=y[(M+1)%4],_.hitTestLineSegment(f,d,0)){this.handleHit(p,r,b,a,u);break t}}}let C=e.getInstanceState().brush;if(!C||!c.equals(C))e.updateInstanceState({brush:{...c.toJson()}});let I=e.getSelectedShapeIds();if(I.length!==a.size||I.some((P)=>!a.has(P)))e.setSelectedShapes(Array.from(a))}onInterrupt(){this.editor.updateInstanceState({brush:null})}handleHit(e,t,n,o,r){if(e.parentId===n){o.add(e.id);return}let i=this.editor.getOutermostSelectableShape(e),s=this.editor.getShapeMask(i.id);if(s&&!tw(s,r)&&!fn(t,s))return;o.add(i.id)}}class Ml{constructor(e){this.editor=e}editor;isApplyingOwnChange=!1;changed=!1;dispose;trackedShapeIds=new Set;start(e){this.changed=!1,this.setTrackedShapeIds(e),this.dispose=this.editor.sideEffects.registerAfterChangeHandler("shape",(t,n)=>{if(this.isApplyingOwnChange||this.changed)return;if(this.trackedShapeIds.has(n.id))this.changed=!0})}stop(){this.dispose?.(),this.dispose=void 0,this.trackedShapeIds.clear()}setTrackedShapeIds(e){this.trackedShapeIds.clear();for(let t of e)this.trackedShapeIds.add(t)}clear(){this.changed=!1}getAndClearChanged(){let{changed:e}=this;return this.changed=!1,e}ignoreChanges(e){let t=this.isApplyingOwnChange;this.isApplyingOwnChange=!0;try{return e()}finally{this.isApplyingOwnChange=t}}}var Mc={bottom:"ns-resize",top:"ns-resize",left:"ew-resize",right:"ew-resize",bottom_left:"nesw-resize",bottom_right:"nwse-resize",top_left:"nwse-resize",top_right:"nesw-resize",bottom_left_rotate:"swne-rotate",bottom_right_rotate:"senw-rotate",top_left_rotate:"nwse-rotate",top_right_rotate:"nesw-rotate",mobile_rotate:"grabbing"};class Y8 extends re{static id="pointing_resize_handle";info={};pendingDoubleClick=null;updateCursor(){let e=Mc[this.info.handle];this.editor.setCursor({type:e,rotation:this.editor.getSelectionRotation()})}onEnter(e){if(this.info=e,this.pendingDoubleClick=null,typeof e.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(e.onInteractionEnd);this.updateCursor()}onExit(){this.parent.setCurrentToolIdMask(void 0)}onPointerMove(){if(this.editor.inputs.getIsDragging())this.startResizing()}onLongPress(){this.startResizing()}startResizing(){if(this.editor.getIsReadonly())return;this.parent.transition("resizing",this.info)}onPointerUp(){if(this.pendingDoubleClick){this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent(this.pendingDoubleClick);return}this.complete()}onDoubleClick(e){if(this.editor.inputs.getShiftKey()||e.phase!=="down"||e.ctrlKey||e.shiftKey)return;this.pendingDoubleClick=e}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}complete(){let{onInteractionEnd:e}=this.info;if(e){if(typeof e==="string")this.editor.setCurrentTool(e,{});else e();return}this.parent.transition("idle")}cancel(){let{onInteractionEnd:e}=this.info;if(e){if(typeof e==="string")this.editor.setCurrentTool(e,{});else e();return}this.parent.transition("idle")}}var{defineProperty:Qze,getOwnPropertyDescriptor:e5e}=Object,t5e=(e,t,n,o)=>{var r=o>1?void 0:o?e5e(t,n):t;for(var i=e.length-1,s;i>=0;i--)if(s=e[i])r=(o?s(t,n,r):s(r))||r;if(o&&r)Qze(t,n,r);return r};class qb extends re{static id="cropping";static trackPerformance=!0;info={};markId="";snapshot={};changeTracker=new Ml(this.editor);onEnter(e){if(this.info=e,typeof e.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(e.onInteractionEnd);this.markId=this.editor.markHistoryStoppingPoint("cropping"),this.snapshot=this.createSnapshot(),this.changeTracker.start(this.snapshot.shape?[this.snapshot.shape.id]:[]),this.updateShapes()}onPointerMove(){this.updateShapes()}onKeyDown(){this.updateShapes()}onKeyUp(){this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}onExit(){this.changeTracker.stop(),this.parent.setCurrentToolIdMask(void 0),this.editor.snaps.clearIndicators()}updateCursor(){if(!this.editor.getSelectedShapes()[0])return;let t=Mc[this.info.handle];this.editor.setCursor({type:t,rotation:this.editor.getSelectionRotation()})}updateShapes(){this.changeTracker.ignoreChanges(this.updateShapesIgnoringExternalChanges)}updateShapesIgnoringExternalChanges(){let{editor:e}=this;if(this.changeTracker.getAndClearChanged())this.snapshot=this.createSnapshot(e.inputs.getCurrentPagePoint()),this.changeTracker.setTrackedShapeIds(this.snapshot.shape?[this.snapshot.shape.id]:[]);let{shape:t,cursorHandleOffset:n,originPagePoint:o,initialSelectionPageBounds:r,selectionRotation:i}=this.snapshot;if(!t)return;let s=e.getShapeUtil(t.type);if(!s)return;let a=e.inputs.getShiftKey(),l=e.inputs.getAltKey(),c=Io(e.inputs),u=e.inputs.getCurrentPagePoint().clone().sub(n),f=o.clone().sub(n);if(e.getInstanceState().isGridMode&&!c){let{gridSize:x}=e.getDocumentSettings();u.snapToGrid(x)}e.snaps.clearIndicators();let d=e.user.getIsSnapMode()?!c:c,p=!1;if(d&&r&&i%Qt===0){let{nudge:x}=e.snaps.shapeBounds.snapResizeShapes({dragDelta:T.Sub(u,f),initialSelectionPageBounds:r,handle:Bh(this.info.handle,i),isAspectRatioLocked:a,isResizingFromCenter:l});u.add(x),p=!0}let m=u.clone().sub(f).rot(-i),g=t.props.crop??ys(),y=Yi(t.props,g),b=(s.onCrop?.bind(s)??tz)(t,{handle:this.info.handle,change:m,crop:g,uncroppedSize:y,initialShape:this.snapshot.shape,aspectRatioLocked:a,isResizingFromCenter:l});if(b)e.updateShapes([{id:t.id,type:t.type,...b}]);if(p&&r)this.reconcileSnapIndicators(r,T.Sub(u,f),Bh(this.info.handle,i),a,l);if(b)this.updateCursor()}reconcileSnapIndicators(e,t,n,o,r){let{editor:i}=this;if(!i.snaps.getIndicators().length)return;let s=i.getShapePageBounds(this.snapshot.shape.id);if(!s)return;let{box:a}=Z.Resize(e,n,r?t.x*2:t.x,r?t.y*2:t.y,o);if(r)a.center=e.center;let l=1;if(Math.abs(s.minX-a.minX)>l||Math.abs(s.maxX-a.maxX)>l||Math.abs(s.minY-a.minY)>l||Math.abs(s.maxY-a.maxY)>l)i.snaps.clearIndicators()}complete(){this.updateShapes(),eo(this.editor,[this.snapshot.shape.id]);let{onInteractionEnd:e}=this.info;if(e)if(typeof e==="string")this.editor.setCurrentTool(e,this.info);else e();else this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle")}cancel(){this.editor.bailToMark(this.markId),this.changeTracker.clear();let{onInteractionEnd:e}=this.info;if(e)if(typeof e==="string")this.editor.setCurrentTool(e,this.info);else e();else this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle")}createSnapshot(e=this.editor.inputs.getOriginPagePoint()){let t=this.editor.getSelectionRotation(),n=this.editor.getOnlySelectedShape(),o=this.editor.getSelectionRotatedPageBounds(),r=T.RotWith(o.getHandlePoint(this.info.handle),o.point,t),i=T.Sub(e,r),s=this.editor.getSelectionPageBounds();return{shape:n,cursorHandleOffset:i,initialSelectionPageBounds:s,selectionRotation:t,originPagePoint:e}}}t5e([St],qb.prototype,"updateShapesIgnoringExternalChanges",1);class eT extends re{static id="pointing_crop_handle";info={};pendingDoubleClick=null;onEnter(e){if(this.info=e,this.pendingDoubleClick=null,typeof e.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(e.onInteractionEnd);let t=this.editor.getSelectedShapes()[0];if(!t)return;let n=Mc[this.info.handle];this.editor.setCursor({type:n,rotation:this.editor.getSelectionRotation()}),this.editor.setCroppingShape(t.id)}onExit(){this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0)}onPointerMove(){if(this.editor.inputs.getIsDragging())this.startCropping()}onLongPress(){this.startCropping()}startCropping(){if(this.editor.getIsReadonly())return;this.parent.transition("cropping",{...this.info,onInteractionEnd:this.info.onInteractionEnd})}onPointerUp(){if(this.pendingDoubleClick){this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent(this.pendingDoubleClick);return}let{onInteractionEnd:e}=this.info;if(e){if(typeof e==="string")this.editor.setCurrentTool(e,this.info);else e();return}this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle")}onDoubleClick(e){if(this.editor.inputs.getShiftKey()||e.phase!=="down"||e.ctrlKey||e.shiftKey)return;this.pendingDoubleClick=e}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){let{onInteractionEnd:e}=this.info;if(e){if(typeof e==="string")this.editor.setCurrentTool(e,this.info);else e();return}this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle")}}function og(e,t=!1){let n=e.inputs.getCurrentPagePoint();return e.getShapeAtPoint(n,{hitInside:!1,hitLabels:t,hitLocked:e.options.selectLockedShapes,margin:e.getHitTestMargin(),renderingOnly:!0})??e.getSelectedShapeAtPoint(n)}function Kb(e){if(e.isDisposed)return!1;let t=e.inputs.getCurrentPagePoint(),n=e.getHitTestMargin(),o=e.overlays.getOverlayAtPoint(t,n),r=e.overlays.getHoveredOverlayId();if(o){e.overlays.setHoveredOverlay(o.id),e.setHoveredShape(null);let s=e.overlays.getOverlayUtil(o).getCursor(o);if(s)e.setCursor({type:s,rotation:e.getSelectionRotation()});return!0}if(r)e.setCursor({type:"default",rotation:0});return e.overlays.setHoveredOverlay(null),!1}function qL(e,t,n){if(!t)throw Error("Needs to translate a cropped shape!");let{crop:o}=t.props;if(!o)return;let r=e.inputs.getShiftKey()?Math.abs(n.x)<Math.abs(n.y)?"x":"y":null;if(r==="x")n.x=0;else if(r==="y")n.y=0;n.rot(-e.getShapePageTransform(t.id).rotation());let{w:i,h:s}=Yi(t.props,o),a=o.bottomRight.x-o.topLeft.x,l=o.bottomRight.y-o.topLeft.y,c=Ct(o),u=1-a,f=1-l;return c.topLeft.x=Pe(c.topLeft.x-n.x/i,0,u),c.topLeft.y=Pe(c.topLeft.y-n.y/s,0,f),c.bottomRight.x=c.topLeft.x+a,c.bottomRight.y=c.topLeft.y+l,{id:t.id,type:t.type,props:{crop:c}}}class X8 extends re{static id="idle";onEnter(){this.editor.setCursor({type:"default",rotation:0});let e=this.editor.getOnlySelectedShape();if(e)this.editor.setCroppingShape(e.id);Kb(this.editor)}onExit(){this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){Kb(this.editor)}onCancel(){this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})}onPointerDown(e){if(e.accelKey){this.cancel(),this.editor.root.handleEvent(e);return}switch(e.target){case"canvas":{let t=this.editor.inputs.getCurrentPagePoint(),n=this.editor.overlays.getOverlayAtPoint(t,this.editor.getHitTestMargin());if(n){let r=n.props.overlayType;if(r==="resize_handle"||r==="rotate_handle"||r==="mobile_rotate"){this.onPointerDown({...e,target:"selection",handle:n.props.handle});return}}let o=og(this.editor);if(o&&!this.editor.isShapeOfType(o,"group")){this.onPointerDown({...e,shape:o,target:"shape"});return}this.cancel(),this.editor.root.handleEvent(e);break}case"shape":{if(e.shape.id===this.editor.getCroppingShapeId()){this.editor.setCurrentTool("select.crop.pointing_crop",e);return}else if(this.editor.getShapeUtil(e.shape)?.canCrop(e.shape))this.editor.setCroppingShape(e.shape.id),this.editor.setSelectedShapes([e.shape.id]),this.editor.setCurrentTool("select.crop.pointing_crop",e);else this.cancel(),this.editor.root.handleEvent(e);break}case"selection":{switch(e.handle){case"mobile_rotate":case"top_left_rotate":case"top_right_rotate":case"bottom_left_rotate":case"bottom_right_rotate":{this.editor.setCurrentTool("select.pointing_rotate_handle",{...e,onInteractionEnd:"select.crop.idle"});break}case"top":case"right":case"bottom":case"left":case"top_left":case"top_right":case"bottom_left":case"bottom_right":{this.editor.setCurrentTool("select.crop.pointing_crop_handle",{...e,onInteractionEnd:"select.crop.idle"});break}default:this.cancel()}break}}}onDoubleClick(e){if(this.editor.inputs.getShiftKey()||e.phase!=="down")return;let t=this.editor.getCroppingShapeId();if(!t)return;let n=this.editor.getShape(t);if(!n)return;let o=this.editor.getShapeUtil(n);if(!o)return;if(e.target==="canvas"){let r=this.editor.inputs.getCurrentPagePoint(),i=this.editor.overlays.getOverlayAtPoint(r,this.editor.getHitTestMargin());if(i){let s=i.props.overlayType;if(s==="resize_handle"||s==="rotate_handle"||s==="mobile_rotate"){this.onDoubleClick({...e,target:"selection",handle:i.props.handle});return}}}if(e.target==="selection"){o.onDoubleClickEdge?.(n,e);return}this.cancel(),this.editor.root.handleEvent(e)}onKeyDown(){this.nudgeCroppingImage(!1)}onKeyRepeat(){this.nudgeCroppingImage(!0)}onKeyUp(e){switch(e.key){case"Enter":{this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{});break}}}cancel(){this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})}nudgeCroppingImage(e=!1){let{editor:{inputs:{keys:t}}}=this,n=t.has("ShiftLeft"),o=new T(0,0);if(t.has("ArrowLeft"))o.x+=1;if(t.has("ArrowRight"))o.x-=1;if(t.has("ArrowUp"))o.y+=1;if(t.has("ArrowDown"))o.y-=1;if(o.equals(new T(0,0)))return;if(n)o.mul(10);let r=this.editor.getShape(this.editor.getCroppingShapeId());if(!r)return;let i=qL(this.editor,r,o);if(i){if(!e)this.editor.markHistoryStoppingPoint("translate crop");this.editor.updateShapes([i])}}}class Z8 extends re{static id="pointing_crop";pendingDoubleClick=null;onEnter(){this.pendingDoubleClick=null}onCancel(){this.editor.setCurrentTool("select.crop.idle",{})}onPointerMove(e){if(this.editor.inputs.getIsDragging())this.startDragging(e)}onLongPress(e){this.startDragging(e)}onPointerUp(e){if(this.pendingDoubleClick){this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent(this.pendingDoubleClick);return}this.editor.setCurrentTool("select.crop.idle",e)}onDoubleClick(e){if(this.editor.inputs.getShiftKey()||e.phase!=="down"||e.ctrlKey||e.shiftKey)return;this.pendingDoubleClick=e}startDragging(e){this.editor.setCurrentTool("select.crop.translating_crop",e)}}var{defineProperty:n5e,getOwnPropertyDescriptor:o5e}=Object,r5e=(e,t,n,o)=>{var r=o>1?void 0:o?o5e(t,n):t;for(var i=e.length-1,s;i>=0;i--)if(s=e[i])r=(o?s(t,n,r):s(r))||r;if(o&&r)n5e(t,n,r);return r};class KL extends re{static id="translating_crop";info={};markId="";snapshot={};changeTracker=new Ml(this.editor);onEnter(e){this.info=e,this.snapshot=this.createSnapshot(),this.markId=this.editor.markHistoryStoppingPoint("translating_crop"),this.editor.setCursor({type:"move",rotation:0}),this.changeTracker.start(this.snapshot.shape?[this.snapshot.shape.id]:[]),this.updateShapes()}onExit(){this.changeTracker.stop(),this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}onKeyDown(e){switch(e.key){case"Alt":case"Shift":{this.updateShapes();return}}}onKeyUp(e){switch(e.key){case"Enter":{this.complete();return}case"Alt":case"Shift":this.updateShapes()}}complete(){this.updateShapes(),this.editor.setCurrentTool("select.crop.idle",this.info)}cancel(){this.editor.bailToMark(this.markId),this.changeTracker.clear(),this.editor.setCurrentTool("select.crop.idle",this.info)}createSnapshot(e=this.editor.inputs.getOriginPagePoint()){return{shape:this.editor.getOnlySelectedShape(),originPagePoint:e}}updateShapes(){this.changeTracker.ignoreChanges(this.updateShapesIgnoringExternalChanges)}updateShapesIgnoringExternalChanges(){if(this.changeTracker.getAndClearChanged())this.snapshot=this.createSnapshot(this.editor.inputs.getCurrentPagePoint()),this.changeTracker.setTrackedShapeIds(this.snapshot.shape?[this.snapshot.shape.id]:[]);let e=this.snapshot.shape;if(!e)return;let n=this.editor.inputs.getCurrentPagePoint().clone().sub(this.snapshot.originPagePoint),o=qL(this.editor,e,n);if(o)this.editor.updateShapes([o])}}r5e([St],KL.prototype,"updateShapesIgnoringExternalChanges",1);class J8 extends re{static id="crop";static initial="idle";static children(){return[X8,KL,Z8,eT,qb]}markId="";onEnter(){this.didExit=!1,this.markId=this.editor.markHistoryStoppingPoint("crop")}didExit=!1;onExit(){if(!this.didExit){if(this.didExit=!0,this.editor.getMarkIdMatching(this.markId)===this.markId)this.editor.squashToMark(this.markId)}}onCancel(){if(this.getCurrent()?.id!=="idle")return;if(!this.didExit)this.didExit=!0,this.editor.bailToMark(this.markId)}}class Q8 extends re{static id="dragging_handle";static trackPerformance=!0;shapeId;initialHandle;initialAdjacentHandle;initialPagePoint;markId;initialPageTransform;initialPageRotation;info;isPrecise=!1;onEnter(e){let{shape:t,isCreating:n,creatingMarkId:o,handle:r}=e,i=this.editor.getShapeHandles(t);if(!i){this.parent.transition("idle");return}if(this.info=e,this.isPrecise=!1,typeof e.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(e.onInteractionEnd);if(this.shapeId=t.id,this.markId="",n)if(o)this.markId=o;else{let f=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);if(f)this.markId=f}else this.markId=this.editor.markHistoryStoppingPoint("dragging handle");this.initialHandle=Ct(r),this.initialPageTransform=this.editor.getShapePageTransform(t),this.initialPageRotation=this.initialPageTransform.rotation(),this.initialPagePoint=this.editor.inputs.getOriginPagePoint().clone(),this.editor.setCursor({type:n?"cross":"grabbing",rotation:0});let s=i.slice().sort(Hn),a=s.findIndex((f)=>f.id===e.handle.id);if(this.initialAdjacentHandle=null,e.handle.snapReferenceHandleId){let f=s.find((d)=>d.id===e.handle.snapReferenceHandleId);if(f)this.initialAdjacentHandle=f}if(!this.initialAdjacentHandle){for(let f=a+1;f<s.length;f++){let d=s[f];if(d.type==="vertex"&&d.id!=="middle"&&d.id!==e.handle.id){this.initialAdjacentHandle=d;break}}if(!this.initialAdjacentHandle)for(let f=s.length-1;f>=0;f--){let d=s[f];if(d.type==="vertex"&&d.id!=="middle"&&d.id!==e.handle.id){this.initialAdjacentHandle=d;break}}}if(this.editor.isShapeOfType(t,"arrow")){let f=wn(this.editor,t)[e.handle.id];if(f){if(this.isPrecise=f.props.isPrecise,!this.isPrecise)this.resetExactTimeout()}}let l={handle:this.initialHandle,isPrecise:this.isPrecise,isCreatingShape:!!this.info.isCreating,initial:t},u=this.editor.getShapeUtil(t).onHandleDragStart?.(t,l);if(u)this.editor.updateShapes([{...u,id:t.id,type:t.type}]);this.update(),this.editor.select(this.shapeId)}exactTimeout=-1;resetExactTimeout(){let t=this.editor.getShapeUtil("arrow").options.pointingPreciseTimeout;if(this.exactTimeout!==-1)this.clearExactTimeout();this.exactTimeout=this.editor.timers.setTimeout(()=>{if(this.getIsActive()&&!this.isPrecise)this.isPrecise=!0,this.update();this.exactTimeout=-1},t)}clearExactTimeout(){if(this.exactTimeout!==-1)this.editor.timers.clearTimeout(this.exactTimeout),this.exactTimeout=-1}onPointerMove(){this.update()}onKeyDown(){this.update()}onKeyUp(){this.update()}onPointerUp(){this.complete()}onComplete(){this.update(),this.complete()}onCancel(){this.cancel()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.clearExactTimeout(),sd(this.editor),this.editor.snaps.clearIndicators(),this.editor.setCursor({type:"default",rotation:0})}complete(){this.editor.snaps.clearIndicators(),eo(this.editor,[this.shapeId]);let e=this.editor.getShape(this.shapeId);if(e){let n=this.editor.getShapeUtil(e),o={handle:this.initialHandle,isPrecise:this.isPrecise,isCreatingShape:!!this.info.isCreating,initial:this.info.shape},r=n.onHandleDragEnd?.(e,o);if(r)this.editor.updateShapes([{...r,id:e.id}])}let{onInteractionEnd:t}=this.info;if(t)if(typeof t==="string"){if(this.editor.getInstanceState().isToolLocked&&t){this.editor.setCurrentTool(t,{shapeId:this.shapeId});return}}else{t?.();return}this.parent.transition("idle")}cancel(){let e=this.editor.getShape(this.shapeId);if(e){let n=this.editor.getShapeUtil(e),o={handle:this.initialHandle,isPrecise:this.isPrecise,isCreatingShape:!!this.info.isCreating,initial:this.info.shape};n.onHandleDragCancel?.(e,o)}this.editor.bailToMark(this.markId),this.editor.snaps.clearIndicators();let{onInteractionEnd:t}=this.info;if(t){if(typeof t==="string")this.editor.setCurrentTool(t,{shapeId:this.shapeId});else t?.();return}this.parent.transition("idle")}update(){let{editor:e,shapeId:t,initialPagePoint:n}=this,{initialHandle:o,initialPageRotation:r,initialAdjacentHandle:i}=this,s=this.editor.user.getIsSnapMode(),{snaps:a}=e,l=e.inputs.getCurrentPagePoint(),c=e.inputs.getShiftKey(),u=e.inputs.getAccelKey(),f=e.inputs.getAltKey(),d=e.inputs.getPointerVelocity(),p=this.info.shape,m=e.getShape(t);if(!m)return;let g=e.getShapeUtil(m),y=e.isShapeOfType(m,"arrow")?wn(e,m)[o.id]:void 0,S=l.clone().sub(n).rot(-r).add(o);if(c&&i&&o.id!=="middle"){let C=T.Angle(i,S),P=_f(C,24)-C;S=T.RotWith(S,i,P)}e.snaps.clearIndicators();let b={...o,x:S.x,y:S.y},x=!1;if(o.canSnap&&o.snapType)Jl("canSnap is deprecated. Cannot use both canSnap and snapType together - snapping disabled. Please use only snapType.");else x=o.canSnap||o.snapType!==void 0;if(x&&(s?!u:u)){let C=a.handles.snapHandle({currentShapeId:t,handle:b});if(C)C.nudge.rot(-e.getShapePageTransform(m.id).rotation()),S.add(C.nudge),b={...o,x:S.x,y:S.y}}let w=g.onHandleDrag?.(m,{handle:b,isPrecise:this.isPrecise||f,isCreatingShape:!!this.info.isCreating,initial:p}),v={id:m.id,type:m.type,...w};if(o.type==="vertex"&&this.editor.isShapeOfType(m,"arrow")){let C=wn(e,m)[o.id];if(C){if(y?.toId!==C.toId)this.isPrecise=d.len()<0.5||f,this.resetExactTimeout()}else if(y)this.isPrecise=!1,this.resetExactTimeout()}if(w)e.updateShapes([v])}}class e9 extends re{static id="editing_shape";hitLabelOnShapeForPointerUp=null;info={};didPointerDownOnEditingShape=!1;isTextInputFocused(){let e=this.editor.getContainer(),t=this.editor.getContainerDocument();return e.contains(t.activeElement)&&gu(!1,t)}onEnter(e){let t=this.editor.getEditingShape();if(!t)throw Error("Entered editing state without an editing shape");if(this.hitLabelOnShapeForPointerUp=null,this.didPointerDownOnEditingShape=!1,this.info=e,e.isCreatingTextWhileToolLocked)this.parent.setCurrentToolIdMask("text");this.editor.setCursor({type:"default",rotation:0}),El(this.editor),this.editor.select(t)}onExit(){if(this.editor.setEditingShape(null),Sp(this.editor),this.info.isCreatingTextWhileToolLocked)this.parent.setCurrentToolIdMask(void 0)}leave(e){if(this.info.isCreatingTextWhileToolLocked)this.editor.setCurrentTool("text",{});else this.parent.transition("idle",e)}onPointerMove(e){if(this.hitLabelOnShapeForPointerUp&&this.editor.inputs.getIsDragging()){if(this.editor.getIsReadonly())return;if(this.hitLabelOnShapeForPointerUp.isLocked)return;this.editor.select(this.hitLabelOnShapeForPointerUp),this.parent.transition("translating",e),this.hitLabelOnShapeForPointerUp=null;return}if(this.didPointerDownOnEditingShape&&this.editor.inputs.isDragging){if(this.editor.getIsReadonly())return;let t=this.editor.getEditingShape();if(!t||t.isLocked)return;if(!this.isTextInputFocused()){this.editor.select(t),this.parent.transition("translating",e),this.didPointerDownOnEditingShape=!1;return}this.didPointerDownOnEditingShape=!1}switch(e.target){case"shape":case"canvas":{El(this.editor);return}}}onPointerDown(e){switch(this.hitLabelOnShapeForPointerUp=null,this.didPointerDownOnEditingShape=!1,e.target){case"canvas":{let t=og(this.editor,!0);if(t){this.onPointerDown({...e,shape:t,target:"shape"});return}break}case"shape":{let{shape:t}=e,n=this.editor.getEditingShape();if(!n)throw Error("Expected an editing shape!");let o=this.editor.getShapeUtil(t).getGeometry(t),r=l_(o),i=r.length===1?r[0]:void 0,s=this.editor.isShapeOfType(n,"text")&&na(this.editor,n.props.richText).trim()==="";if(i&&!s){let a=this.editor.getPointInShapeSpace(t,this.editor.inputs.getCurrentPagePoint());if(i.bounds.containsPoint(a,0)&&i.hitTestPoint(a))if(t.id===n.id){this.didPointerDownOnEditingShape=!0;return}else{this.hitLabelOnShapeForPointerUp=t,this.editor.markHistoryStoppingPoint("editing on pointer up"),this.editor.select(t.id);return}}else{if(t.id===n.id){if(this.editor.isShapeFrameLike(t))this.editor.setEditingShape(null),this.parent.transition("idle",e)}else{this.parent.transition("pointing_shape",e);return}return}break}}this.leave(e),this.editor.root.handleEvent(e)}onPointerUp(e){if(this.didPointerDownOnEditingShape){if(this.didPointerDownOnEditingShape=!1,!this.isTextInputFocused()){this.editor.getRichTextEditor()?.commands.focus("all");return}}let t=this.hitLabelOnShapeForPointerUp;if(!t)return;this.hitLabelOnShapeForPointerUp=null;let n=this.editor.getShapeUtil(t);if(t.isLocked)return;if(this.editor.getIsReadonly()){if(!n.canEditInReadonly(t)){this.parent.transition("pointing_shape",e);return}}this.editor.select(t.id);let o=this.editor.getEditingShape(),r=o&&o.id!==t.id;this.editor.setEditingShape(t.id);let i=Xe.isIos||Xe.isAndroid;if(!i||!r)this.editor.emit("place-caret",{shapeId:t.id,point:e.point});else if(i&&r)this.editor.emit("select-all-text",{shapeId:t.id});El(this.editor)}onComplete(e){this.editor.getContainer().focus(),this.leave(e)}onCancel(e){this.editor.getContainer().focus(),this.leave(e)}}var i5e=["[","]"," "];class t9 extends re{static id="idle";selectedShapesOnKeyDown=[];onEnter(){if(this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0}),!Kb(this.editor))El(this.editor);this.selectedShapesOnKeyDown=[]}onExit(){this.editor.updateInstanceState({isChangingStyle:!1}),Sp(this.editor)}onPointerMove(){if(!Kb(this.editor))El(this.editor);if(Yo(()=>this.editor.getInstanceState()).isChangingStyle)this.editor.updateInstanceState({isChangingStyle:!1})}onPointerDown(e){switch(e.target){case"canvas":{let t=this.editor.inputs.getCurrentPagePoint(),n=this.editor.overlays.getOverlayAtPoint(t,this.editor.getHitTestMargin());if(n){this.onPointerDown({...e,target:"overlay",overlay:n});return}let o=og(this.editor);if(o&&(this.editor.options.selectLockedShapes||!o.isLocked)){this.onPointerDown({...e,shape:o,target:"shape"});return}let r=this.editor.getSelectedShapeIds(),i=this.editor.getOnlySelectedShape();if(r.length>1||i&&!this.editor.getShapeUtil(i).hideSelectionBoundsBg(i)){if(sC(this.editor,t)){this.onPointerDown({...e,target:"selection"});return}}this.parent.transition("pointing_canvas",e);break}case"overlay":{let{overlay:t}=e,n=this.editor.overlays.getOverlayUtil(t);if(n.onPointerDown){if(n.onPointerDown(t,e)!==!1)return}let o=t.props.overlayType;if(t.type==="shape_handle"){let r=this.editor.getShape(t.props.shapeId);if(r)this.onPointerDown({...e,target:"handle",shape:r,handle:t.props.handle})}else switch(o){case"rotate_handle":{this.onPointerDown({...e,target:"selection",handle:t.props.handle});break}case"mobile_rotate":{this.onPointerDown({...e,target:"selection",handle:t.props.handle});break}case"resize_handle":{this.onPointerDown({...e,target:"selection",handle:t.props.handle});break}default:this.onPointerDown({...e,target:"selection"})}break}case"shape":{let{shape:t}=e;if(!this.editor.options.selectLockedShapes&&this.editor.isShapeOrAncestorLocked(t)){this.parent.transition("pointing_canvas",e);break}this.parent.transition("pointing_shape",e);break}case"handle":{if(this.editor.getIsReadonly())break;if(this.editor.inputs.getAltKey())this.parent.transition("pointing_shape",e);else this.parent.transition("pointing_handle",e);break}case"selection":{switch(e.handle){case"mobile_rotate":case"top_left_rotate":case"top_right_rotate":case"bottom_left_rotate":case"bottom_right_rotate":{if(e.accelKey){this.parent.transition("brushing",e);break}this.parent.transition("pointing_rotate_handle",e);break}case"top":case"right":case"bottom":case"left":case"top_left":case"top_right":case"bottom_left":case"bottom_right":{let t=this.editor.getOnlySelectedShape();if(e.ctrlKey&&this.editor.canCropShape(t))this.parent.transition("crop.pointing_crop_handle",e);else{if(e.accelKey){this.parent.transition("brushing",e);break}this.parent.transition("pointing_resize_handle",e)}break}default:{let t=this.editor.getHoveredShape();if(t&&!this.editor.getSelectedShapeIds().includes(t.id)&&(this.editor.options.selectLockedShapes||!t.isLocked)){this.onPointerDown({...e,shape:t,target:"shape"});return}this.parent.transition("pointing_selection",e)}}break}}}onDoubleClick(e){if(this.editor.inputs.getShiftKey()||e.phase!=="down")return;if(e.ctrlKey||e.shiftKey)return;switch(e.target){case"canvas":{let t=this.editor.inputs.getCurrentPagePoint(),n=this.editor.overlays.getOverlayAtPoint(t,this.editor.getHitTestMargin());if(n){if(n.type==="shape_handle"){let s=this.editor.getShape(n.props.shapeId);if(s){this.onDoubleClick({...e,target:"handle",shape:s,handle:n.props.handle});return}}let i=n.props.overlayType;if(i==="resize_handle"||i==="rotate_handle"||i==="mobile_rotate"){this.onDoubleClick({...e,target:"selection",handle:n.props.handle});return}}let o=this.editor.getHoveredShape(),r=o&&!this.editor.isShapeOfType(o,"group")?o:this.editor.getSelectedShapeAtPoint(t)??this.editor.getShapeAtPoint(t,{margin:this.editor.getHitTestMargin(),hitInside:!1,hitLocked:this.editor.options.selectLockedShapes,renderingOnly:!0});if(r){this.onDoubleClick({...e,shape:r,target:"shape"});return}if(!this.editor.inputs.getShiftKey())this.handleDoubleClickOnCanvas(e);break}case"selection":{let t=this.editor.getOnlySelectedShape();if(t){let n=this.editor.getShapeUtil(t),o=e.handle==="right"||e.handle==="left"||e.handle==="top"||e.handle==="bottom",r=e.handle==="top_left"||e.handle==="top_right"||e.handle==="bottom_right"||e.handle==="bottom_left";if(this.editor.getIsReadonly()){if(this.editor.canEditShape(t,{type:r?"double-click-corner":o?"double-click-edge":"double-click"}))this.startEditingShape(t,e,!0);break}if(o){let i=n.onDoubleClickEdge?.(t,e);if(i){this.editor.markHistoryStoppingPoint("double click edge"),this.editor.updateShapes([i]),eo(this.editor,[t.id]);return}}if(r){let i=n.onDoubleClickCorner?.(t,e);if(i){this.editor.markHistoryStoppingPoint("double click corner"),this.editor.updateShapes([i]),eo(this.editor,[t.id]);return}}if(this.editor.canCropShape(t)){this.parent.transition("crop",e);return}if(this.editor.canEditShape(t))this.startEditingShape(t,e,!0)}break}case"shape":{let{shape:t}=e,n=this.editor.getSelectedShapeIds();if(this.editor.isShapeOfType(t,"group")||this.editor.getOutermostSelectableShape(t).id!==t.id){let i=this.editor.getOutermostSelectableShape(t,(s)=>!n.includes(s.id));if(!n.includes(i.id))this.editor.markHistoryStoppingPoint("drilling into group on double click"),this.editor.select(i.id);return}let r=this.editor.getShapeUtil(t);if(this.editor.getIsReadonly()&&!r.canEditInReadonly(t))break;if(r.onDoubleClick){let i=r.onDoubleClick?.(t);if(i){this.editor.markHistoryStoppingPoint("double click shape"),this.editor.updateShapes([i]);return}}if(r.canCrop(t)&&!this.editor.isShapeOrAncestorLocked(t)){this.editor.markHistoryStoppingPoint("select and crop"),this.editor.select(e.shape?.id),this.parent.transition("crop",e);return}if(this.editor.canEditShape(t))this.startEditingShape(t,e,!0);else this.handleDoubleClickOnCanvas(e);break}case"handle":{if(this.editor.getIsReadonly())break;let{shape:t,handle:n}=e,r=this.editor.getShapeUtil(t).onDoubleClickHandle?.(t,n);if(r)this.editor.markHistoryStoppingPoint("double click handle"),this.editor.updateShapes([r]);else if(this.editor.canEditShape(t))this.startEditingShape(t,e,!0)}}}onRightClick(e){switch(e.target){case"canvas":{let t=this.editor.getSelectedShapeIds(),n=this.editor.getOnlySelectedShape(),o=this.editor.inputs.getCurrentPagePoint();if(t.length>1||n&&!this.editor.getShapeUtil(n).hideSelectionBoundsBg(n)){if(sC(this.editor,o)){this.onRightClick({...e,target:"selection"});return}}let r=this.editor.getHoveredShape(),i=r&&!this.editor.isShapeOfType(r,"group")?r:this.editor.getShapeAtPoint(o,{margin:this.editor.getHitTestMargin(),hitInside:!1,hitLabels:!0,hitLocked:!0,hitFrameInside:!0,renderingOnly:!0});if(i){this.onRightClick({...e,shape:i,target:"shape"});return}this.editor.selectNone();break}case"shape":{let{selectedShapeIds:t}=this.editor.getCurrentPageState(),{shape:n}=e,o=this.editor.getOutermostSelectableShape(n,(r)=>!t.includes(r.id));if(!t.includes(o.id)&&!this.editor.findShapeAncestor(o,(r)=>t.includes(r.id)))this.editor.markHistoryStoppingPoint("selecting shape"),this.editor.setSelectedShapes([o.id]);break}}}onCancel(){if(this.editor.getFocusedGroupId()!==this.editor.getCurrentPageId()&&this.editor.getSelectedShapeIds().length>0)this.editor.popFocusedGroupId();else this.editor.markHistoryStoppingPoint("clearing selection"),this.editor.selectNone()}onKeyDown(e){switch(this.selectedShapesOnKeyDown=this.editor.getSelectedShapes(),e.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{if(e.accelKey){if(e.shiftKey){if(e.code==="ArrowDown")this.editor.selectFirstChildShape();else if(e.code==="ArrowUp")this.editor.selectParentShape()}else this.editor.selectAdjacentShape(e.code.replace("Arrow","").toLowerCase());return}this.nudgeSelectedShapes(e,!1);return}}if(Nt.editOnType.get()){if([...e.key].length===1&&!i5e.includes(e.key)&&!e.altKey&&!e.ctrlKey&&!e.metaKey){let t=this.editor.getOnlySelectedShape();if(t&&this.editor.isShapeOfType(t,"note")&&this.editor.canEditShape(t)){this.startEditingShape(t,{...e,target:"shape",shape:t},!0);return}}}}onKeyRepeat(e){switch(e.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{if(e.accelKey){this.editor.selectAdjacentShape(e.code.replace("Arrow","").toLowerCase());return}this.nudgeSelectedShapes(e,!0);break}case"Tab":{if(this.editor.getSelectedShapes().length&&!e.altKey)this.editor.selectAdjacentShape(e.shiftKey?"prev":"next");break}}}onKeyUp(e){switch(e.key){case"Enter":{if(!this.selectedShapesOnKeyDown.length)return;let t=this.editor.getSelectedShapes();if(t.every((o)=>this.editor.isShapeOfType(o,"group"))){this.editor.setSelectedShapes(t.flatMap((o)=>this.editor.getSortedChildIdsForParent(o.id)));return}let n=this.editor.getOnlySelectedShape();if(n&&this.editor.canEditShape(n,{type:"press_enter"})){this.startEditingShape(n,{...e,target:"shape",shape:n},!0);return}if(this.editor.canCropShape(n))this.parent.transition("crop",e);break}case"Tab":{if(this.editor.getSelectedShapes().length&&!e.altKey)this.editor.selectAdjacentShape(e.shiftKey?"prev":"next");break}}}startEditingShape(e,t,n){let{editor:o}=this;if(this.editor.markHistoryStoppingPoint("editing shape"),QE(e))Sr(o,e,{selectAll:n});else o.setEditingShape(e);this.parent.transition("editing_shape",t)}isOverArrowLabelTest(e){if(!e)return!1;return CL(this.editor,e)}handleDoubleClickOnCanvas(e){if(this.editor.getIsReadonly())return;if(!this.editor.options.createTextOnCanvasDoubleClick)return;this.editor.markHistoryStoppingPoint("creating text shape");let t=Ke(),{x:n,y:o}=this.editor.inputs.getCurrentPagePoint();this.editor.createShapes([{id:t,type:"text",x:n,y:o,props:{richText:Yt(""),autoSize:!0}}]);let r=this.editor.getShape(t);if(!r)return;if(!this.editor.canEditShape(r))return;Sr(this.editor,t,{info:e})}nudgeSelectedShapes(e,t=!1){let{editor:{inputs:{keys:n}}}=this;if(e.altKey||this.editor.inputs.getIsSpacebarPanning())return;let o=n.has("ShiftLeft"),r=new T(0,0);if(n.has("ArrowLeft"))r.x-=1;if(n.has("ArrowRight"))r.x+=1;if(n.has("ArrowUp"))r.y-=1;if(n.has("ArrowDown"))r.y+=1;if(r.equals(new T(0,0)))return;if(!t)this.editor.markHistoryStoppingPoint("nudge shapes");this.editor.updateInstanceState({isChangingStyle:!0});let{gridSize:i}=this.editor.getDocumentSettings(),s=this.editor.getInstanceState().isGridMode?o?i*l5e:i:o?s5e:a5e,a=this.editor.getSelectedShapeIds();this.editor.nudgeShapes(a,r.mul(s)),eo(this.editor,a)}}var s5e=10,a5e=1,l5e=5;class n9 extends re{static id="pointing_arrow_label";shapeId="";markId="";wasAlreadySelected=!1;didDrag=!1;didCtrlOnEnter=!1;info={};updateCursor(){this.editor.setCursor({type:"grabbing",rotation:0})}onEnter(e){let{shape:t}=e;if(typeof e.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(e.onInteractionEnd);this.info=e,this.shapeId=t.id,this.didDrag=!1,this.didCtrlOnEnter=e.accelKey,this.wasAlreadySelected=this.editor.getOnlySelectedShapeId()===t.id,this.updateCursor();let o=this.editor.getShapeGeometry(t).children[1];if(!o)throw Error(`Expected to find an arrow label geometry for shape: ${t.id}`);let r=this.editor.inputs.getCurrentPagePoint(),i=this.editor.getPointInShapeSpace(t,r);if(this._labelDragOffset=T.Sub(o.center,i),this.markId=this.editor.markHistoryStoppingPoint("label-drag start"),e.shiftKey||e.accelKey){let a=this.editor.getSelectedShapeIds();this.editor.setSelectedShapes([...a,this.shapeId]);return}this.editor.setSelectedShapes([this.shapeId])}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0})}_labelDragOffset=new T(0,0);onPointerMove(){if(!this.editor.inputs.getIsDragging())return;if(this.didCtrlOnEnter){this.parent.transition("brushing",this.info);return}let t=this.editor.getShape(this.shapeId);if(!t)return;let n=this.editor.getShapeUtil("arrow").options,o=tg(this.editor,t),r=this.editor.getShapePageTransform(t.id),i=this.editor.getPointInShapeSpace(t,this.editor.inputs.getCurrentPagePoint()).add(this._labelDragOffset),s=wL(this.editor,t),a=o.uninterpolateAlongEdge(i);if(isNaN(a))a=s;let l=r.applyToPoint(o.interpolateAlongEdge(a)),c=r.applyToPoint(o.interpolateAlongEdge(s));if(T.DistMin(l,c,n.labelCenterSnapDistance/this.editor.getZoomLevel()))a=s;this.didDrag=!0,this.editor.updateShape({id:t.id,type:t.type,props:{labelPosition:a}})}onPointerUp(){let e=this.editor.getShape(this.shapeId);if(e&&!this.didDrag&&this.wasAlreadySelected&&this.editor.canEditShape(e)){Sr(this.editor,e.id);return}this.complete()}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.cancel()}complete(){let{onInteractionEnd:e}=this.info;if(e){if(typeof e==="string")this.editor.setCurrentTool(e,{});else e();return}this.parent.transition("idle")}cancel(){this.editor.bailToMark(this.markId);let{onInteractionEnd:e}=this.info;if(e){if(typeof e==="string")this.editor.setCurrentTool(e,{});else e();return}this.parent.transition("idle")}}function WL(e,t){let n=e.getSelectedShapeIds(),o=e.inputs.getCurrentPagePoint(),{shiftKey:r,altKey:i,accelKey:s}=t,a=r||s,l=e.options.selectLockedShapes,c=e.getShapeAtPoint(o,{hitInside:!1,margin:e.getHitTestMargin(),hitLabels:!0,hitLocked:l,renderingOnly:!0,filter:(u)=>l||!u.isLocked});if(c){let u=e.getOutermostSelectableShape(c);if(a&&!i)if(e.cancelDoubleClick(),n.includes(u.id))e.markHistoryStoppingPoint("deselecting shape"),e.deselect(u);else e.markHistoryStoppingPoint("shift selecting shape"),e.setSelectedShapes([...n,u.id]);else{let f=void 0;if(u===c)f=c;else if(u.id===e.getFocusedGroupId()||n.includes(u.id))f=c;else f=u;if(f&&!n.includes(f.id))e.markHistoryStoppingPoint("selecting shape"),e.select(f.id)}}else if(a)return;else{if(n.length>0)e.markHistoryStoppingPoint("selecting none"),e.selectNone();let u=e.getFocusedGroupId();if(Vn(u)){let f=e.getShape(u);if(!e.isPointInShape(f,o,{margin:0,hitInside:!0}))e.setFocusedGroup(null)}}}class o9 extends re{static id="pointing_canvas";onEnter(e){if(!(e.shiftKey||e.accelKey)){if(this.editor.getSelectedShapeIds().length>0)this.editor.markHistoryStoppingPoint("selecting none"),this.editor.selectNone()}}onPointerMove(e){if(this.editor.inputs.getIsDragging())this.parent.transition("brushing",e)}onPointerUp(e){WL(this.editor,e),this.complete()}onDoubleClick(e){if(this.editor.inputs.getShiftKey()||e.phase!=="down"||e.ctrlKey||e.shiftKey)return;this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent(e)}onComplete(){this.complete()}onCancel(){this.parent.transition("idle")}onInterrupt(){this.parent.transition("idle")}complete(){this.parent.transition("idle")}}class r9 extends re{static id="pointing_handle";didCtrlOnEnter=!1;info={};isDoubleClick=!1;onEnter(e){this.info=e,this.isDoubleClick=!1,this.didCtrlOnEnter=e.accelKey;let{shape:t}=e;if(this.editor.isShapeOfType(t,"arrow")){let n=wn(this.editor,t),o=n[e.handle.id],r=n[e.handle.id==="start"?"end":"start"],i=this.editor.getShapePageTransform(t.id);if(o)ad({editor:this.editor,pointInPageSpace:i.applyToPoint(e.handle),arrow:t,isPrecise:o.props.isPrecise,currentBinding:o,oppositeBinding:r})}this.editor.setCursor({type:"grabbing",rotation:0})}onExit(){this.editor.setHintingShapes([]),sd(this.editor),this.editor.setCursor({type:"default",rotation:0})}onPointerUp(){let{shape:e,handle:t}=this.info;if(!this.editor.getShape(e.id)){this.parent.transition("idle");return}if(this.isDoubleClick){this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent({...this.info,type:"click",name:"double_click",phase:"down"});return}if(this.editor.isShapeOfType(e,"note")){let{editor:n}=this,o=kpe(n,e,t,!1);if(o){yL(n,o);return}}this.parent.transition("idle",this.info)}onDoubleClick(e){if(this.editor.inputs.getShiftKey()||e.phase!=="down"||e.ctrlKey||e.shiftKey)return;this.isDoubleClick=!0}onPointerMove(e){let{editor:t}=this;if(t.inputs.getIsDragging())if(this.didCtrlOnEnter)this.parent.transition("brushing",e);else this.startDraggingHandle()}onLongPress(){this.startDraggingHandle()}startDraggingHandle(){let{editor:e}=this;if(e.getIsReadonly())return;let{shape:t,handle:n}=this.info;if(!e.getShape(t.id)){this.parent.transition("idle");return}if(e.isShapeOfType(t,"note")){let o=e.getShapeUtil(t),r=ze(o,t),i=e.markHistoryStoppingPoint("creating note from handle"),s=kpe(e,t,n,!0);if(s){let a=e.getPointInParentSpace(s,e.inputs.getOriginPagePoint()).sub(T.Rot(new T(r.noteWidth/2,r.noteHeight/2).mul(t.props.scale),s.rotation));e.updateShape({...s,x:a.x,y:a.y}),e.setHoveredShape(s.id).select(s.id).setCurrentTool("select.translating",{...this.info,target:"shape",shape:e.getShape(s),isCreating:!0,creatingMarkId:i,onCreate:()=>{Sr(e,s,{selectAll:!0})}});return}}this.parent.transition("dragging_handle",this.info)}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}function kpe(e,t,n,o){let r=e.getShapeUtil(t),i=ze(r,t),s=e.getShapePageTransform(t.id),a=s.point(),l=s.rotation(),u=o8(e,{pagePoint:a,pageRotation:l,growY:t.props.growY*t.props.scale,extraHeight:0,scale:t.props.scale,noteWidth:i.noteWidth,noteHeight:i.noteHeight})[n.index];if(u)return gL(e,{shape:t,center:u,pageRotation:l,noteWidth:i.noteWidth,noteHeight:i.noteHeight,forceNew:o});return}class i9 extends re{static id="pointing_rotate_handle";info={};pendingDoubleClick=null;updateCursor(){this.editor.setCursor({type:Mc[this.info.handle],rotation:this.editor.getSelectionRotation()})}onEnter(e){if(this.info=e,this.pendingDoubleClick=null,typeof e.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(e.onInteractionEnd);this.updateCursor()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){if(this.editor.inputs.getIsDragging())this.startRotating()}onLongPress(){this.startRotating()}startRotating(){if(this.editor.getIsReadonly())return;this.parent.transition("rotating",this.info)}onPointerUp(){if(this.pendingDoubleClick){this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent(this.pendingDoubleClick);return}this.complete()}onDoubleClick(e){if(this.editor.inputs.getShiftKey()||e.phase!=="down"||e.ctrlKey||e.shiftKey)return;this.pendingDoubleClick=e}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}complete(){let{onInteractionEnd:e}=this.info;if(e){if(typeof e==="string")this.editor.setCurrentTool(e,{});else e?.();return}this.parent.transition("idle")}cancel(){let{onInteractionEnd:e}=this.info;if(e){if(typeof e==="string")this.editor.setCurrentTool(e,{});else e();return}this.parent.transition("idle")}}class s9 extends re{static id="pointing_selection";info={};onEnter(e){this.info=e}onPointerUp(e){WL(this.editor,e),this.parent.transition("idle",e)}onPointerMove(e){if(this.editor.inputs.getIsDragging())this.startTranslating(e)}onLongPress(e){this.startTranslating(e)}startTranslating(e){if(this.editor.getIsReadonly())return;this.parent.transition("translating",e)}onDoubleClick(e){if(this.editor.inputs.getShiftKey()||e.phase!=="down"||e.ctrlKey||e.shiftKey)return;let t=this.editor.getHoveredShape(),n=t&&!this.editor.isShapeOfType(t,"group")?t:this.editor.getShapeAtPoint(this.editor.inputs.getCurrentPagePoint(),{hitInside:!0,margin:0,renderingOnly:!0});if(n){this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent({...e,target:"shape",shape:this.editor.getShape(n)});return}}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}class a9 extends re{static id="pointing_shape";hitShape={};hitShapeForPointerUp={};isDoubleClick=!1;didCtrlOnEnter=!1;didSelectOnEnter=!1;onEnter(e){let t=this.editor.getSelectedShapeIds(),n=this.editor.getFocusedGroupId(),o=this.editor.inputs.getCurrentPagePoint(),{shiftKey:r,altKey:i,accelKey:s}=e;this.hitShape=e.shape,this.isDoubleClick=!1,this.didCtrlOnEnter=s;let a=this.editor.getOutermostSelectableShape(e.shape);if(this.didCtrlOnEnter||this.editor.getShapeUtil(e.shape).onClick||a.id===n||t.includes(a.id)||this.editor.isAncestorSelected(a)||t.length>1&&sC(this.editor,o)){this.didSelectOnEnter=!1,this.hitShapeForPointerUp=a;return}if(this.didSelectOnEnter=!0,r&&!i){if(this.editor.cancelDoubleClick(),!t.includes(a.id))this.editor.markHistoryStoppingPoint("shift selecting shape"),this.editor.setSelectedShapes([...t,a.id])}else this.editor.markHistoryStoppingPoint("selecting shape"),this.editor.setSelectedShapes([a.id])}onPointerUp(e){let t=this.editor.getSelectedShapeIds(),n=this.editor.getFocusedGroupId(),o=this.editor.inputs.getCurrentPagePoint(),r=(e.shiftKey||e.accelKey)&&!e.altKey,i=this.editor.getShapeAtPoint(o,{margin:this.editor.getHitTestMargin(),hitInside:!0,hitLocked:this.editor.options.selectLockedShapes,renderingOnly:!0})??this.hitShape;if(!this.editor.getShape(i.id)){this.parent.transition("idle",e);return}let s=i?this.editor.getOutermostSelectableShape(i):this.hitShapeForPointerUp;if(s){let a=this.editor.getShapeUtil(s);if(a.onClick){let l=a.onClick?.(s);if(l){this.editor.markHistoryStoppingPoint("shape on click"),this.editor.updateShapes([l]),this.parent.transition("idle",e);return}}if(s.id===n){if(t.length>0)this.editor.markHistoryStoppingPoint("clearing shape ids"),this.editor.setSelectedShapes([]);else this.editor.popFocusedGroupId();this.parent.transition("idle",e);return}}if(!this.didSelectOnEnter){let a=this.editor.getOutermostSelectableShape(i,(l)=>!t.includes(l.id));if(t.includes(a.id))if(r)this.editor.markHistoryStoppingPoint("deselecting on pointer up"),this.editor.deselect(s);else if(t.includes(s.id)){if(t.length===1){let l=this.editor.getShapeUtil(s).getGeometry(s),c=l_(l),u=c.length===1?c[0]:void 0;if(u){let f=this.editor.getPointInShapeSpace(s,o);if(u.bounds.containsPoint(f,0)&&u.hitTestPoint(f)){this.editor.run(()=>{if(this.editor.markHistoryStoppingPoint("editing on pointer up"),this.editor.select(s.id),!this.editor.canEditShape(s))return;if(this.editor.setEditingShape(s.id),this.editor.setCurrentTool("select.editing_shape"),this.isDoubleClick)this.editor.emit("select-all-text",{shapeId:s.id});else this.editor.emit("place-caret",{shapeId:s.id,point:e.point})});return}}}this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.select(s.id)}else this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.select(s);else if(r){let l=this.editor.getShapeAncestors(a);this.editor.markHistoryStoppingPoint("shift deselecting on pointer up"),this.editor.setSelectedShapes([...this.editor.getSelectedShapeIds().filter((c)=>!l.find((u)=>u.id===c)),a.id])}else this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.setSelectedShapes([a.id])}this.parent.transition("idle",e)}onDoubleClick(e){if(this.isDoubleClick=!0,this.editor.inputs.getShiftKey()||e.phase!=="down"||e.ctrlKey||e.shiftKey)return;let{shape:t,...n}=e;this.parent.transition("idle"),this.parent.getCurrent()?.handleEvent({...n,target:"canvas"})}onPointerMove(e){if(this.editor.inputs.getIsDragging()){if(!this.editor.getShape(this.hitShape.id)){this.parent.transition(this.didCtrlOnEnter?"brushing":"idle",e);return}if(CL(this.editor,this.hitShape)){this.parent.transition("pointing_arrow_label",{...e,shape:this.hitShape});return}if(this.didCtrlOnEnter)this.parent.transition("brushing",e);else this.startTranslating(e)}}onLongPress(e){this.startTranslating(e)}startTranslating(e){if(this.editor.getIsReadonly())return;if(!this.didSelectOnEnter&&!this.editor.getSelectedShapeIds().length){let t=this.editor.getShape(this.hitShapeForPointerUp.id);if(!t){this.parent.transition("idle",e);return}this.editor.markHistoryStoppingPoint("selecting shape"),this.editor.setSelectedShapes([t.id])}this.editor.focus(),this.parent.transition("translating",e)}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}var{defineProperty:c5e,getOwnPropertyDescriptor:u5e}=Object,d5e=(e,t,n,o)=>{var r=o>1?void 0:o?u5e(t,n):t;for(var i=e.length-1,s;i>=0;i--)if(s=e[i])r=(o?s(t,n,r):s(r))||r;if(o&&r)c5e(t,n,r);return r};class YL extends re{static id="resizing";static trackPerformance=!0;info={};markId="";didHoldCommand=!1;didFinish=!1;creationCursorOffset={x:0,y:0};snapshot={};changeTracker=new Ml(this.editor);onEnter(e){let{isCreating:t=!1,creatingMarkId:n,creationCursorOffset:o={x:0,y:0}}=e;if(this.info=e,this.didHoldCommand=!1,this.didFinish=!1,this.markId="",typeof e.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(e.onInteractionEnd);this.creationCursorOffset=o;let r=this._createSnapshot();if(!r){this.parent.transition("idle");return}if(this.snapshot=r,t)if(n)this.markId=n;else{let i=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);if(i)this.markId=i}else this.markId=this.editor.markHistoryStoppingPoint("starting resizing");if(t)this.editor.setCursor({type:"cross",rotation:0});this.changeTracker.start(this.snapshot.shapeSnapshots.keys()),this.handleResizeStart(),this.updateShapes()}onTick({elapsed:e}){let{editor:t}=this;if(!t.inputs.getIsDragging()||t.inputs.getIsPanning())return;t.edgeScrollManager.updateEdgeScrolling(e)}onPointerMove(){this.updateShapes()}onKeyDown(){this.updateShapes()}onKeyUp(){this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}cancel(){this.didFinish=!0;let{shapeSnapshots:e}=this.snapshot;e.forEach(({shape:n})=>{let o=this.editor.getShape(n.id);if(o){let r=this.editor.getShapeUtil(n);if(!r.canResize(n))return;r.onResizeCancel?.(n,o)}}),this.editor.bailToMark(this.markId);let{onInteractionEnd:t}=this.info;if(t){if(typeof t==="string")this.editor.setCurrentTool(t,{});else t();return}this.parent.transition("idle")}complete(){if(this.didFinish=!0,eo(this.editor,this.snapshot.selectedShapeIds),this.handleResizeEnd(),this.info.isCreating&&this.info.onCreate){this.info.onCreate?.(this.editor.getOnlySelectedShape());return}let{onInteractionEnd:e}=this.info;if(e)if(typeof e==="string"){if(this.editor.getInstanceState().isToolLocked){this.editor.setCurrentTool(e,{});return}}else{e();return}this.parent.transition("idle")}handleResizeStart(){this.changeTracker.ignoreChanges(()=>{let{shapeSnapshots:e}=this.snapshot,t=[];if(e.forEach(({shape:n})=>{let o=this.editor.getShapeUtil(n);if(!o.canResize(n))return;let r=o.onResizeStart?.(n);if(r)t.push(r)}),t.length>0)this.editor.updateShapes(t)})}handleResizeEnd(){this.changeTracker.ignoreChanges(()=>{let{shapeSnapshots:e}=this.snapshot,t=[];if(e.forEach(({shape:n})=>{let o=this.editor.getShape(n.id);if(!o)return;let r=this.editor.getShapeUtil(n);if(!r.canResize(n))return;let i=r.onResizeEnd?.(n,o);if(i)t.push(i)}),t.length>0)this.editor.updateShapes(t)})}updateShapes(){this.changeTracker.ignoreChanges(this._updateShapes)}_updateShapes(){if(this.changeTracker.getAndClearChanged()){let M=this._createSnapshot(this.editor.inputs.getCurrentPagePoint());if(!M){this.parent.transition("idle");return}this.snapshot=M,this.changeTracker.setTrackedShapeIds(this.snapshot.shapeSnapshots.keys())}let{editor:e,info:t,snapshot:{frames:n,shapeSnapshots:o,selectionBounds:r,cursorHandleOffset:i,originPagePoint:s,selectedShapeIds:a,selectionRotation:l,canShapesDeform:c,initialSelectionPageBounds:u,resizeLevels:f}}=this,d=e.inputs.getAltKey(),m=e.inputs.getShiftKey()||!c;if(o.size===1){let M=[...o.values()][0];if(e.isShapeOfType(M.shape,"text"))m=!(t.handle==="left"||t.handle==="right")}let g=Io(e.inputs),y=e.inputs.getCurrentPagePoint().clone().sub(i).sub(this.creationCursorOffset),S=s.clone().sub(i);if(e.getInstanceState().isGridMode&&!g){let{gridSize:M}=e.getDocumentSettings();y.snapToGrid(M)}let b=t.handle,x=Bh(b,Math.PI);if(e.snaps.clearIndicators(),(e.user.getIsSnapMode()?!g:g)&&l%Qt===0){let{nudge:M}=e.snaps.shapeBounds.snapResizeShapes({dragDelta:T.Sub(y,S),initialSelectionPageBounds:u,handle:Bh(b,l),isAspectRatioLocked:m,isResizingFromCenter:d});y.add(M)}let v=T.RotWith(d?r.center:r.getHandlePoint(x),r.point,l),C=T.Sub(y,v).rot(-l),I=T.Sub(S,v).rot(-l),P=T.DivV(C,I);if(!Number.isFinite(P.x))P.x=1;if(!Number.isFinite(P.y))P.y=1;let k=b==="top"||b==="bottom",_=b==="left"||b==="right";if(m)if(_)P.y=Math.abs(P.x);else if(k)P.x=Math.abs(P.y);else if(Math.abs(P.x)>Math.abs(P.y))P.y=Math.abs(P.x)*(P.y<0?-1:1);else P.x=Math.abs(P.y)*(P.x<0?-1:1);else{if(k)P.x=1;if(_)P.y=1}if(!this.info.isCreating)this.updateCursor({dragHandle:b,isFlippedX:P.x<0,isFlippedY:P.y<0,rotation:l});if(o.size>1)gpe(this.editor,o,P,l,m);for(let M of f){let N=[];for(let V of M){let D=o.get(V),K=e.getResizeShapePartial(V,P,{initialShape:D.shape,initialBounds:D.bounds,initialPageTransform:D.pageTransform,dragHandle:b,mode:a.length===1&&V===a[0]?"resize_bounds":"scale_shape",scaleOrigin:v,isAspectRatioLocked:m,scaleAxisRotation:l,skipStartAndEndCallbacks:!0});if(K)N.push(K)}if(N.length>0)e.updateShapes(N)}if(g){this.didHoldCommand=!0;let M=[];for(let{id:N,children:V}of n){if(!V.length)continue;let D=o.get(N)?.shape,K=this.editor.getShape(N);if(!(D&&K))continue;let U=K.x-D.x,A=K.y-D.y,z=new T(U,A).rot(-D.rotation);if(z.x!==0||z.y!==0)for(let j of V)M.push({id:j.id,type:j.type,x:j.x-z.x,y:j.y-z.y})}if(M.length>0)this.editor.updateShapes(M)}else if(this.didHoldCommand){this.didHoldCommand=!1;let M=[];for(let{children:N}of n)for(let V of N)M.push({id:V.id,type:V.type,x:V.x,y:V.y});if(M.length>0)this.editor.updateShapes(M)}this.updateEnclosureHints()}updateEnclosureHints(){if(!this.info.isCreating)return;let e=this.editor.getOnlySelectedShape();if(!e||!this.editor.isShapeOfType(e,"frame"))return;let t=ZH(this.editor,e),n=this.editor.getHintingShapeIds();if(t.length===n.length&&t.every((o,r)=>o===n[r]))return;this.editor.setHintingShapes(t)}updateCursor({dragHandle:e,isFlippedX:t,isFlippedY:n,rotation:o}){let r=this.editor.getInstanceState().cursor,i=r.type;switch(e){case"top_left":case"bottom_right":{if(i="nwse-resize",t!==n)i="nesw-resize";break}case"top_right":case"bottom_left":{if(i="nesw-resize",t!==n)i="nwse-resize";break}}if(i===r.type&&o===r.rotation)return;this.editor.setCursor({type:i,rotation:o})}onExit(){if(this.changeTracker.stop(),this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0}),this.editor.snaps.clearIndicators(),k8(this.editor,null),this.info.isCreating&&this.editor.getHintingShapeIds().length>0)this.editor.setHintingShapes([]);if(this.info.isCreating&&!this.didFinish)this.editor.bailToMark(this.markId);this.snapshot={},this.info={}}_createSnapshot(e=this.editor.inputs.getOriginPagePoint()){let{editor:t}=this,n=t.getSelectedShapeIds(),o=t.getSelectionRotation(),r=t.getSelectionRotatedPageBounds();if(!r)return null;let i=T.RotWith(r.getHandlePoint(this.info.handle),r.point,o),s=T.Sub(e,i),a=new Map,l=[],c=(m)=>{let g=t.getShape(m);if(!g)return!1;let y=t.getShapeUtil(g),S=t.getShapePageTransform(g);if(a.set(g.id,{shape:g,bounds:t.getShapeGeometry(g).bounds,pageTransform:S,pageRotation:J.Decompose(S).rotation,isAspectRatioLocked:y.isAspectRatioLocked(g)}),t.isShapeFrameLike(g))l.push({id:g.id,children:Ae(t.getSortedChildIdsForParent(g).map((b)=>t.getShape(b)))});if(!y.canResizeChildren(g))return!1;return};n.forEach((m)=>{if(c(m)===!1)return;t.visitDescendants(m,c)});let u=![...a.values()].some((m)=>!Oh(m.pageRotation,o)||m.isAspectRatioLocked),f=[],d=new Map,p=(m)=>{let g=d.get(m);if(g!==void 0)return g;let y=0,S=t.getShape(m)?.parentId;while(S&&Vn(S)){if(a.has(S)){y=p(S)+1;break}S=t.getShape(S)?.parentId}return d.set(m,y),y};for(let m of a.keys()){let g=p(m);while(f.length<=g)f.push([]);f[g].push(m)}return{shapeSnapshots:a,selectionBounds:r,cursorHandleOffset:s,originPagePoint:e,selectionRotation:o,selectedShapeIds:n,canShapesDeform:u,initialSelectionPageBounds:this.editor.getSelectionPageBounds(),frames:l,resizeLevels:f}}}d5e([St],YL.prototype,"_updateShapes",1);var{defineProperty:f5e,getOwnPropertyDescriptor:p5e}=Object,h5e=(e,t,n,o)=>{var r=o>1?void 0:o?p5e(t,n):t;for(var i=e.length-1,s;i>=0;i--)if(s=e[i])r=(o?s(t,n,r):s(r))||r;if(o&&r)f5e(t,n,r);return r},Epe=Math.PI/180;class XL extends re{static id="rotating";static trackPerformance=!0;snapshot={};info={};markId="";changeTracker=new Ml(this.editor);onEnter(e){if(this.info=e,typeof e.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(e.onInteractionEnd);this.markId=this.editor.markHistoryStoppingPoint("rotate start");let t=aS({editor:this.editor,ids:this.editor.getSelectedShapeIds()});if(!t){this.parent.transition("idle",this.info);return}this.snapshot=t,this.changeTracker.start(t.shapeSnapshots.map((o)=>o.shape.id));let n=this._getRotationFromPointerPosition({snapToNearestDegree:!1});this.changeTracker.ignoreChanges(()=>{Wh({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!1}),snapshot:this.snapshot,stage:"start"})}),this.editor.setCursor({type:Mc[this.info.handle],rotation:n+this.snapshot.initialShapesRotation})}onExit(){this.changeTracker.stop(),this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0),this.snapshot={}}onPointerMove(){this.update()}onKeyDown(){this.update()}onKeyUp(){this.update()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}update(){this.changeTracker.ignoreChanges(this.updateShapes)}updateShapes(){if(this.changeTracker.getAndClearChanged())this.reanchorSnapshot();let e=this._getRotationFromPointerPosition({snapToNearestDegree:!1});Wh({editor:this.editor,delta:e,snapshot:this.snapshot,stage:"update"}),this.editor.setCursor({type:Mc[this.info.handle],rotation:e+this.snapshot.initialShapesRotation})}reanchorSnapshot(){let e=aS({editor:this.editor,ids:this.editor.getSelectedShapeIds()});if(!e)return;e.initialCursorAngle=e.initialPageCenter.angle(this.editor.inputs.getCurrentPagePoint()),this.snapshot=e,this.changeTracker.setTrackedShapeIds(e.shapeSnapshots.map((t)=>t.shape.id))}cancel(){let{shapeSnapshots:e}=this.snapshot;e.forEach(({shape:n})=>{let o=this.editor.getShape(n.id);if(o)this.editor.getShapeUtil(n).onRotateCancel?.(n,o)}),this.editor.bailToMark(this.markId);let{onInteractionEnd:t}=this.info;if(t){if(typeof t==="string")this.editor.setCurrentTool(t,this.info);else t();return}this.parent.transition("idle",this.info)}complete(){this.changeTracker.ignoreChanges(()=>{if(this.changeTracker.getAndClearChanged())this.reanchorSnapshot();Wh({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!0}),snapshot:this.snapshot,stage:"end"})}),eo(this.editor,this.snapshot.shapeSnapshots.map((t)=>t.shape.id));let{onInteractionEnd:e}=this.info;if(e){if(typeof e==="string")this.editor.setCurrentTool(e,this.info);else e();return}this.parent.transition("idle",this.info)}_getRotationFromPointerPosition({snapToNearestDegree:e}){let t=this.editor.inputs.getShiftKey(),n=this.editor.inputs.getCurrentPagePoint(),{initialCursorAngle:o,initialShapesRotation:r,initialPageCenter:i}=this.snapshot,s=i.angle(n)-o,a=r+s;if(t)a=_f(a,24);else if(e){if(a=Math.round(a/Epe)*Epe,this.editor.getInstanceState().isCoarsePointer){let l=_f(a,4),c=Ky(a,l);if(Math.abs(c)<D3(5))a=l}}return a-r}}h5e([St],XL.prototype,"updateShapes",1);class l9 extends re{static id="scribble_brushing";static trackPerformance=!0;hits=new Set;size=0;scribbleId="id";initialSelectedShapeIds=new Set;newlySelectedShapeIds=new Set;onEnter(){this.initialSelectedShapeIds=new Set(this.editor.getSelectedShapeIds()),this.newlySelectedShapeIds=new Set,this.size=0,this.hits.clear();let e=this.editor.scribbles.addScribble({color:"selection-stroke",opacity:0.32,size:12});this.scribbleId=e.id,this.updateScribbleSelection(!0),this.editor.updateInstanceState({brush:null})}onExit(){this.editor.scribbles.stop(this.scribbleId)}onPointerMove(){this.updateScribbleSelection(!0)}onPointerUp(){this.complete()}onKeyDown(){this.updateScribbleSelection(!1)}onKeyUp(){if(!this.editor.inputs.getAltKey())this.parent.transition("brushing");else this.updateScribbleSelection(!1)}onCancel(){this.cancel()}onComplete(){this.complete()}pushPointToScribble(){let{x:e,y:t}=this.editor.inputs.getCurrentPagePoint();this.editor.scribbles.addPoint(this.scribbleId,e,t)}updateScribbleSelection(e){let{editor:t}=this,n=this.editor.inputs.getShiftKey(),o=this.editor.inputs.getOriginPagePoint(),r=this.editor.inputs.getPreviousPagePoint(),i=this.editor.inputs.getCurrentPagePoint(),{newlySelectedShapeIds:s,initialSelectedShapeIds:a}=this;if(e)this.pushPointToScribble();let l=0,c=Z.FromPoints([r,i]).expandBy(l),u=t.getShapeIdsInsideBounds(c);if(u.size===0){let w=t.getSelectedShapeIds(),v=new Set(n?[...s,...a]:[...s]);if(w.length!==v.size||w.some((C)=>!v.has(C)))this.editor.setSelectedShapes(Array.from(v));return}let p=this.editor.getCurrentPageRenderingShapesSorted().filter((w)=>u.has(w.id)),m,g,y,S;for(let w=0,v=p.length;w<v;w++){if(m=p[w],t.isShapeOfType(m,"group")||s.has(m.id)||!t.options.selectLockedShapes&&t.isShapeOrAncestorLocked(m))continue;if(g=t.getShapeGeometry(m),t.isShapeFrameLike(m)&&g.bounds.containsPoint(t.getPointInShapeSpace(m,o)))continue;let C=t.getShapePageTransform(m);if(!g||!C)continue;let I=C.clone().invert();y=I.applyToPoint(r),S=I.applyToPoint(i);let{bounds:P}=g;if(P.minX-l>Math.max(y.x,S.x)||P.minY-l>Math.max(y.y,S.y)||P.maxX+l<Math.min(y.x,S.x)||P.maxY+l<Math.min(y.y,S.y))continue;if(g.hitTestLineSegment(y,S,l)){let k=this.editor.getOutermostSelectableShape(m),_=this.editor.getShapeMask(k.id);if(_){if(Vh(r,i,_)!==null){if(!fn(i,_))continue}}s.add(k.id)}}let b=t.getSelectedShapeIds(),x=new Set(n?[...s,...a]:[...s]);if(b.length!==x.size||b.some((w)=>!x.has(w)))this.editor.setSelectedShapes(Array.from(x))}complete(){this.updateScribbleSelection(!0),this.parent.transition("idle")}cancel(){this.editor.setSelectedShapes([...this.initialSelectedShapeIds]),this.parent.transition("idle")}}var{defineProperty:m5e,getOwnPropertyDescriptor:g5e}=Object,y5e=(e,t,n,o)=>{var r=o>1?void 0:o?g5e(t,n):t;for(var i=e.length-1,s;i>=0;i--)if(s=e[i])r=(o?s(t,n,r):s(r))||r;if(o&&r)m5e(t,n,r);return r},S5e=320,b5e=60;class ZL{constructor(e){this.editor=e,e.disposables.add(this.dispose)}editor;shapesToActuallyMove=[];draggedOverShapeIds=new Set;initialGroupIds=new Map;initialParentIds=new Map;initialIndices=new Map;initialDraggingOverShape;prevDraggingOverShape;prevPagePoint=new T;intervalTimerId=-1;startDraggingShapes(e,t,n){let{editor:o}=this;if(this.intervalTimerId!==-1)return;let r=new Set(e),i=new Set;for(let l of r){let c=o.getShapeParent(l);if(c&&o.isShapeOfType(c,"group")){if(!i.has(c))i.add(c)}}for(let l of i){let c=Ae(o.getSortedChildIdsForParent(l).map((u)=>o.getShape(u)));r.add(l);for(let u of c)r.delete(u)}this.initialParentIds.clear();for(let l of r){let c=o.getShapeParent(l);if(c)this.initialParentIds.set(l.id,c.id);this.initialIndices.set(l.id,l.index);let u=o.findShapeAncestor(l,(f)=>o.isShapeOfType(f,"group"));if(u)this.initialGroupIds.set(l.id,u.id)}let s=o.getCurrentPageShapesSorted();this.shapesToActuallyMove=Array.from(r).filter((l)=>!l.isLocked).sort((l,c)=>s.indexOf(l)-s.indexOf(c)),this.initialDraggingOverShape=o.getDraggingOverShape(t,this.shapesToActuallyMove),this.prevDraggingOverShape=void 0,this.updateDraggingShapes(t,n);let a=0;this.intervalTimerId=this.editor.timers.setInterval(()=>{if(a++,a%3&&this.editor.inputs.getPointerVelocity().len()>0.5)return;this.updateDraggingShapes(o.inputs.getCurrentPagePoint(),n)},e.length>10?S5e:b5e)}dropShapes(e){let{editor:t}=this,n=t.inputs.getCurrentPagePoint();this.updateDraggingShapes(n);let o=t.getDraggingOverShape(n,e);if(o){let r=t.getShapeUtil(o),i=_pe(t,o,e);if(i.length>0)r.onDropShapesOver?.(o,i,{initialDraggingOverShapeId:this.initialDraggingOverShape?.id??null,initialParentIds:this.initialParentIds,initialIndices:this.initialIndices})}this.dispose()}clear(){this.editor.timers.clearInterval(this.intervalTimerId),this.intervalTimerId=-1,this.initialParentIds.clear(),this.initialIndices.clear(),this.shapesToActuallyMove=[],this.initialDraggingOverShape=void 0,this.prevDraggingOverShape=void 0,this.editor.setHintingShapes([])}dispose(){this.clear()}updateDraggingShapes(e,t){let{editor:n}=this,o=Ae(this.shapesToActuallyMove.map((a)=>n.getShape(a)));if(!o.length)return;let r=n.getDraggingOverShape(e,this.shapesToActuallyMove),i=n.inputs.getCurrentPagePoint(),s=!this.prevPagePoint.equals(i);this.prevPagePoint.setTo(i),n.run(()=>{if(this.prevDraggingOverShape?.id===r?.id){if(s&&r&&Vn(r.id)&&!n.inputs.getPreviousPagePoint().equals(i))n.getShapeUtil(r).onDragShapesOver?.(r,o,{initialDraggingOverShapeId:this.initialDraggingOverShape?.id??null,initialParentIds:this.initialParentIds,initialIndices:this.initialIndices});return}let a=this.prevDraggingOverShape?this.editor.getShape(this.prevDraggingOverShape.id):void 0;if(a){let l=n.getShapeUtil(a),c=x5e(n,a,o);if(c.length>0)l.onDragShapesOut?.(a,c,{nextDraggingOverShapeId:r?.id??null,initialDraggingOverShapeId:this.initialDraggingOverShape?.id??null,initialParentIds:this.initialParentIds,initialIndices:this.initialIndices})}if(r){let l=n.getShapeUtil(r),c=_pe(n,r,o);if(c.length>0)l.onDragShapesIn?.(r,c,{initialDraggingOverShapeId:this.initialDraggingOverShape?.id??null,prevDraggingOverShapeId:this.prevDraggingOverShape?.id??null,initialParentIds:this.initialParentIds,initialIndices:this.initialIndices}),n.setHintingShapes([r.id]);else if(this.prevDraggingOverShape)n.setHintingShapes([])}else if(this.prevDraggingOverShape)n.setHintingShapes([]);t?.()}),this.prevDraggingOverShape=r}}y5e([St],ZL.prototype,"dispose",1);function _pe(e,t,n){let o=e.getShapeUtil(t);return n.filter((r)=>o.canReceiveNewChildrenOfType(t,r.type))}function x5e(e,t,n){let o=e.getShapeUtil(t);return n.filter((r)=>o.canRemoveChildrenOfType(t,r.type))}var{defineProperty:v5e,getOwnPropertyDescriptor:w5e}=Object,Lpe=(e,t,n,o)=>{var r=o>1?void 0:o?w5e(t,n):t;for(var i=e.length-1,s;i>=0;i--)if(s=e[i])r=(o?s(t,n,r):s(r))||r;if(o&&r)v5e(t,n,r);return r};class tT extends re{static id="translating";static trackPerformance=!0;info={};selectionSnapshot={};snapshot={};markId="";isCloning=!1;isCreating=!1;onCreate;dragAndDropManager=new ZL(this.editor);changeTracker=new Ml(this.editor);onEnter(e){let{isCreating:t=!1,creatingMarkId:n,onCreate:o}=e;if(!this.editor.getSelectedShapeIds()?.length){this.parent.transition("idle");return}if(this.info=e,typeof e.onInteractionEnd==="string")this.parent.setCurrentToolIdMask(e.onInteractionEnd);if(this.isCreating=t,this.markId="",t)if(n)this.markId=n;else{let r=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);if(r)this.markId=r}else this.markId=this.editor.markHistoryStoppingPoint("translating");if(this.onCreate=o,this.isCloning=!1,this.info=e,this.editor.setCursor({type:"move",rotation:0}),this.selectionSnapshot=Mpe(this.editor),this.changeTracker.start(this.selectionSnapshot.shapeSnapshots.map((r)=>r.shape.id)),!this.isCreating){if(this.editor.inputs.getAltKey()){if(this.startCloning(),this.isCloning)return}}this.snapshot=this.selectionSnapshot,this.handleStart(),this.updateShapes()}onExit(){this.changeTracker.stop(),this.parent.setCurrentToolIdMask(void 0),this.selectionSnapshot={},this.snapshot={},this.editor.snaps.clearIndicators(),this.editor.setCursor({type:"default",rotation:0}),this.dragAndDropManager.clear()}onTick({elapsed:e}){let{editor:t}=this;if(!t.inputs.getIsDragging()||t.inputs.getIsPanning())return;t.edgeScrollManager.updateEdgeScrolling(e)}onPointerMove(){this.updateShapes()}onKeyDown(){if(this.editor.inputs.getAltKey()&&!this.isCloning){if(this.startCloning(),this.isCloning)return}this.updateShapes()}onKeyUp(){if(!this.editor.inputs.getAltKey()&&this.isCloning){this.stopCloning();return}this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}startCloning(){if(this.isCreating)return;let e=Array.from(this.editor.getSelectedShapeIds());if(!this.editor.canCreateShapes(e))return;this.isCloning=!0,this.reset(),this.markId=this.editor.markHistoryStoppingPoint("translate cloning"),this.editor.duplicateShapes(Array.from(this.editor.getSelectedShapeIds())),this.snapshot=Mpe(this.editor),this.changeTracker.setTrackedShapeIds(this.snapshot.shapeSnapshots.map((t)=>t.shape.id)),this.dragAndDropManager.clear(),this.handleStart(),this.updateShapes()}stopCloning(){this.isCloning=!1,this.snapshot=this.selectionSnapshot,this.changeTracker.setTrackedShapeIds(this.snapshot.shapeSnapshots.map((e)=>e.shape.id)),this.reset(),this.markId=this.editor.markHistoryStoppingPoint("translate"),this.dragAndDropManager.clear(),this.updateShapes()}reset(){this.editor.bailToMark(this.markId),this.snapshot.lastAppliedOffset=null,this.changeTracker.clear()}complete(){this.updateShapes(),this.dragAndDropManager.dropShapes(this.snapshot.movingShapes),this.handleEnd(),eo(this.editor,this.snapshot.movingShapes.map((t)=>t.id));let{onInteractionEnd:e}=this.info;if(e)if(typeof e==="string"){if(this.editor.getInstanceState().isToolLocked){this.editor.setCurrentTool(e);return}}else{e();return}if(this.isCreating&&this.onCreate){this.onCreate(this.editor.getOnlySelectedShape());return}this.parent.transition("idle")}cancel(){let{movingShapes:e}=this.snapshot;e.forEach((n)=>{let o=this.editor.getShape(n.id);if(o)this.editor.getShapeUtil(n).onTranslateCancel?.(n,o)}),this.reset();let{onInteractionEnd:t}=this.info;if(t){if(typeof t==="string")this.editor.setCurrentTool(t);else t();return}this.parent.transition("idle",this.info)}handleStart(){this.changeTracker.ignoreChanges(()=>{let{movingShapes:e}=this.snapshot,t=[];if(e.forEach((n)=>{let r=this.editor.getShapeUtil(n).onTranslateStart?.(n);if(r)t.push(r)}),t.length>0)this.editor.updateShapes(t);this.dragAndDropManager.startDraggingShapes(Ae(this.snapshot.movingShapes.map((n)=>this.editor.getShape(n.id))),this.editor.inputs.getOriginPagePoint(),this.updateParentTransforms),this.editor.setHoveredShape(null)})}handleEnd(){this.changeTracker.ignoreChanges(()=>{let{movingShapes:e}=this.snapshot;if(this.isCloning&&e.length>0){let n=T.Average(e.map((r)=>this.editor.getShapePageTransform(r.id).point())),o=T.Sub(n,this.selectionSnapshot.averagePagePoint);if(!T.IsNaN(o))this.editor.updateInstanceState({duplicateProps:{shapeIds:e.map((r)=>r.id),offset:{x:o.x,y:o.y}}})}let t=[];if(e.forEach((n)=>{let o=this.editor.getShape(n.id);if(!o)return;let i=this.editor.getShapeUtil(n).onTranslateEnd?.(n,o);if(i)t.push(i)}),t.length>0)this.editor.updateShapes(t)})}updateShapes(){this.changeTracker.ignoreChanges(this.updateShapesIgnoringExternalChanges)}updateShapesIgnoringExternalChanges(){if(this.rescueShapesWithDeletedParents(),this.changeTracker.getAndClearChanged())this.foldExternalChangesIntoSnapshot();let{snapshot:e}=this;this.dragAndDropManager.startDraggingShapes(e.movingShapes,this.editor.inputs.getOriginPagePoint(),this.updateParentTransforms),C5e({editor:this.editor,snapshot:e});let{movingShapes:t}=e,n=[];if(t.forEach((o)=>{let r=this.editor.getShape(o.id);if(!r)return;let s=this.editor.getShapeUtil(o).onTranslate?.(o,r);if(s)n.push(s)}),n.length>0)this.editor.updateShapes(n)}foldExternalChangesIntoSnapshot(){let{editor:e,snapshot:t}=this,n=t.lastAppliedOffset??new T;for(let o of t.shapeSnapshots){let r=e.getShapePageTransform(o.shape.id);if(!r)continue;let i=r.point();o.pagePoint.x=i.x-n.x,o.pagePoint.y=i.y-n.y,o.pageRotation=r.rotation()}}rescueShapesWithDeletedParents(){let{editor:e}=this;for(let t of this.snapshot.shapeSnapshots){let n=e.getShape(t.shape.id);if(!n||jn(n.parentId)||e.getShape(n.parentId))continue;let o=t.parentTransform?J.From(J.Inverse(t.parentTransform)):J.Identity(),r=o.applyToPoint(n);e.reparentShapes([n],e.getCurrentPageId()),e.updateShape({id:n.id,type:n.type,x:r.x,y:r.y,rotation:n.rotation+o.rotation()}),t.parentTransform=null}}updateParentTransforms(){this.rescueShapesWithDeletedParents();let{editor:e,snapshot:{shapeSnapshots:t}}=this,n=[];t.forEach((o)=>{let r=e.getShape(o.shape.id);if(!r)return;n.push(r);let i=jn(r.parentId)?null:J.Inverse(e.getShapePageTransform(r.parentId));o.parentTransform=i})}}Lpe([St],tT.prototype,"updateShapesIgnoringExternalChanges",1);Lpe([St],tT.prototype,"updateParentTransforms",1);function Mpe(e){let t=[],n=[],o=e.getSelectedShapeIds(),r=Ae(o.map((d)=>{let p=e.getShape(d);if(!p)return null;t.push(p);let m=e.getShapePageTransform(d),g=m.point(),y=m.rotation();n.push(g);let S=po.isId(p.parentId)?null:J.Inverse(e.getShapePageTransform(p.parentId));return{shape:p,pagePoint:g,pageRotation:y,parentTransform:S}})),i=e.getOnlySelectedShape(),s=[];if(i)s=e.snaps.shapeBounds.getSnapPoints(i.id);else{let d=e.getSelectionPageBounds();if(d)s=d.cornersAndCenter.map((p,m)=>({id:"selection:"+m,x:p.x,y:p.y}))}let a,l,c,u=e.inputs.getOriginPagePoint(),f=r.filter((d)=>e.isShapeOfType(d.shape,"note")&&e.isPointInShape(d.shape,u));if(f.length===0);else if(f.length===1)l=f[0];else{let d=e.getCurrentPageShapesSorted();l=f.map((p)=>({snapshot:p,index:d.findIndex((m)=>m.id===p.shape.id)})).sort((p,m)=>m.index-p.index)[0]?.snapshot}if(l){let d=e.getShapeUtil(l.shape),p=ze(d,l.shape);a=mL(e,{rotation:l.pageRotation,scale:l.shape.props.scale,extraHeight:l.shape.props.growY??0,noteWidth:p.noteWidth,noteHeight:p.noteHeight,excludeShapeIds:o}),c=new T(p.noteWidth/2,p.noteHeight/2)}return{averagePagePoint:T.Average(n),movingShapes:t,shapeSnapshots:r,initialPageBounds:e.getSelectionPageBounds(),initialSnapPoints:s,noteAdjacentPositions:a,noteSnapshot:l,noteCenterOffset:c,lastAppliedOffset:null}}function C5e({editor:e,snapshot:t}){let{inputs:n}=e,{noteSnapshot:o,noteAdjacentPositions:r,noteCenterOffset:i,initialPageBounds:s,initialSnapPoints:a,shapeSnapshots:l,averagePagePoint:c}=t,u=e.inputs.getShiftKey(),f=e.inputs.getAccelKey(),d=e.getInstanceState().isGridMode,p=e.getDocumentSettings().gridSize,m=T.Sub(n.getCurrentPagePoint(),n.getOriginPagePoint()),g=u?Math.abs(m.x)<Math.abs(m.y)?"x":"y":null;if(g==="x")m.x=0;else if(g==="y")m.y=0;e.snaps.clearIndicators();let y=e.user.getIsSnapMode()?!f:f,S=!1;if(y&&e.inputs.getPointerVelocity().len()<0.5){let{nudge:v}=e.snaps.shapeBounds.snapTranslateShapes({dragDelta:m,initialSelectionPageBounds:s,lockedAxis:g,initialSelectionSnapPoints:a});m.add(v)}else if(o&&r&&i){let{scale:v}=o.shape.props,C=o.pagePoint.clone().add(m).add(i.clone().mul(v).rot(o.pageRotation)),I=hL/e.getZoomLevel(),P=new T(0,0);for(let k of r){let _=T.Sub(C,k),M=_.len();if(M<I)S=!0,I=M,P=_}m.sub(P)}let b=T.Add(c,m),x=e.snaps.getIndicators();if(d&&!f&&!S&&x.length===0)b.snapToGrid(p);let w=T.Sub(b,c);t.lastAppliedOffset=w,e.updateShapes(Ae(l.map(({shape:v,pagePoint:C,parentTransform:I})=>{let P=T.Add(C,w),k=I?J.applyToPoint(I,P):P;return{id:v.id,type:v.type,x:k.x,y:k.y}})))}class JL extends re{static id="select";static initial="idle";static isLockable=!1;reactor=void 0;static children(){return[J8,qb,t9,o9,a9,tT,W8,l9,eT,s9,Y8,e9,YL,XL,i9,n9,r9,Q8]}cleanUpDuplicateProps(){let e=this.editor.getSelectedShapeIds(),t=this.editor.getInstanceState();if(!t.duplicateProps)return;let n=new Set(t.duplicateProps.shapeIds);if(e.length===n.size&&e.every((o)=>n.has(o)))return;this.editor.updateInstanceState({duplicateProps:null})}onEnter(){this.reactor=zt("clean duplicate props",()=>{try{this.cleanUpDuplicateProps()}catch(e){console.error(e)}})}onExit(){if(this.reactor?.(),this.editor.getCurrentPageState().editingShapeId)this.editor.setEditingShape(null);if(this.editor.getCroppingShapeId())this.editor.setCroppingShape(null)}}class c9 extends re{static id="idle";info={};onEnter(e){this.info=e}onPointerDown(){this.parent.transition("pointing",this.info)}onKeyDown(e){if(e.key==="Shift")this.parent.transition("zoom_quick",this.info)}}class u9 extends re{static id="pointing";info={};onEnter(e){this.info=e}onPointerUp(){this.complete()}onPointerMove(){if(this.editor.inputs.getIsDragging())this.parent.transition("zoom_brushing",this.info)}onCancel(){this.cancel()}complete(){let e=this.editor.inputs.getCurrentScreenPoint();if(this.editor.inputs.getAltKey())this.editor.zoomOut(e,{animation:{duration:220}});else this.editor.zoomIn(e,{animation:{duration:220}});this.parent.transition("idle",this.info)}cancel(){this.parent.transition("idle",this.info)}}class d9 extends re{static id="zoom_brushing";info={};zoomBrush=new Z;onEnter(e){this.info=e,this.update()}onExit(){this.editor.updateInstanceState({zoomBrush:null})}onPointerMove(){this.update()}onPointerUp(){this.complete()}onCancel(){this.cancel()}update(){let e=this.editor.inputs.getOriginPagePoint(),t=this.editor.inputs.getCurrentPagePoint();this.zoomBrush.setTo(Z.FromPoints([e,t])),this.editor.updateInstanceState({zoomBrush:this.zoomBrush.toJson()})}cancel(){this.parent.transition("idle",this.info)}complete(){let{zoomBrush:e}=this,t=8/this.editor.getZoomLevel();if(e.width<t&&e.height<t){let n=this.editor.inputs.getCurrentScreenPoint();if(this.editor.inputs.getAltKey())this.editor.zoomOut(n,{animation:{duration:220}});else this.editor.zoomIn(n,{animation:{duration:220}})}else{let n=this.editor.inputs.getAltKey()?this.editor.getZoomLevel()/2:void 0;this.editor.zoomToBounds(e,{targetZoom:n,animation:{duration:220}})}this.parent.transition("idle",this.info)}}class f9 extends re{static id="zoom_quick";info={};qzState="idle";initialVpb=new Z;initialPp=new T;overviewZoom=1;cleanupZoomReactor(){}nextVpb=new Z;onEnter(e){let{editor:t}=this;this.info=e,this.qzState="idle",this.initialVpb=t.getViewportPageBounds(),this.initialPp=T.From(t.inputs.getCurrentPagePoint()),t.setCursor({type:"zoom-in",rotation:0});let n=this.initialVpb,o=t.getCurrentPageBounds(),r=o?Z.Expand(n,o):n.clone(),i=t.getViewportScreenBounds(),s=t.inputs.getCurrentScreenPoint(),{x:a,y:l}=s,{x:c,y:u}=this.initialPp,f=c-r.minX,d=r.maxX-c,p=u-r.minY,m=r.maxY-u,g=t.getCamera().z;if(f>0)g=Math.min(g,a/f);if(d>0)g=Math.min(g,(i.w-a)/d);if(p>0)g=Math.min(g,l/p);if(m>0)g=Math.min(g,(i.h-l)/m);if(g*=0.85,g=Math.max(t.getCameraOptions().zoomSteps[0],g),this.overviewZoom=g,t.options.quickZoomPreservesScreenBounds)this.cleanupZoomReactor=zt("zoom change in quick zoom",()=>{t.getZoomLevel(),this.updateBrush()});let{x:y,y:S,z:b}=t.getCamera(),x=b/g;if(t.setCamera(new T((y+c)*x-c,(S+u)*x-u,g)),!t.options.quickZoomPreservesScreenBounds)this.updateBrush()}onExit(){this.cleanupZoomReactor(),this.zoomToNewViewport(),this.editor.updateInstanceState({zoomBrush:null})}onPointerUp(){let e=this.info.onInteractionEnd?.split(".")[0]??"select";this.editor.setCurrentTool(e)}onCancel(){this.qzState="idle";let e=this.info.onInteractionEnd?.split(".")[0]??"select";this.editor.setCurrentTool(e)}onKeyUp(e){if(e.key==="Shift")this.parent.transition("idle",this.info)}updateBrush(){let{editor:e}=this,t=this.getNextVpb();this.nextVpb.setTo(t),e.updateInstanceState({zoomBrush:t.toJson()})}zoomToNewViewport(){let{editor:e}=this;switch(this.qzState){case"idle":e.zoomToBounds(this.initialVpb,{inset:0});break;case"moving":e.zoomToBounds(this.nextVpb,{inset:0});break}}onPointerMove(){if(this.qzState!=="moving")return;this.updateBrush()}onTick(){let{editor:e}=this;switch(this.qzState){case"idle":{let t=e.getZoomLevel();if(T.Dist2(e.inputs.getCurrentPagePoint(),this.initialPp)*t>e.options.dragDistanceSquared/t)this.qzState="moving",this.updateBrush();break}case"moving":break}}getNextVpb(){let{editor:e}=this,t,n;if(e.options.quickZoomPreservesScreenBounds){let c=this.overviewZoom/e.getCamera().z;t=this.initialVpb.w*c,n=this.initialVpb.h*c}else t=this.initialVpb.w,n=this.initialVpb.h;let{x:o,y:r}=e.inputs.getCurrentPagePoint(),i=e.getViewportScreenBounds(),s=e.inputs.getCurrentScreenPoint(),{x:a,y:l}=new T(s.x/i.w,s.y/i.h);return new Z(o-a*t,r-l*n,t,n)}}class QL extends re{static id="zoom";static initial="idle";static children(){return[c9,u9,d9,f9]}static isLockable=!1;info={};onEnter(e){this.info=e;let t=e.onInteractionEnd?.split(".")[0];this.setCurrentToolIdMask(t),this.updateCursor()}onExit(){this.setCurrentToolIdMask(void 0),this.editor.updateInstanceState({zoomBrush:null,cursor:{type:"default",rotation:0}})}onKeyDown(){this.updateCursor()}onKeyUp(e){if(this.updateCursor(),e.key.toLowerCase()==="z")this.complete()}onInterrupt(){this.complete()}complete(){let e=this.info.onInteractionEnd?.split(".")[0]??"select";this.editor.setCurrentTool(e)}updateCursor(){if(this.editor.inputs.getAltKey()&&!this.editor.isIn("zoom.zoom_quick"))this.editor.setCursor({type:"zoom-out",rotation:0});else this.editor.setCursor({type:"zoom-in",rotation:0})}}var p9=[jL,$L,GL,QL,JL];q();var Ape=wt(Jt(),1);q();var h9=Q(function({isEditing:t,text:n,handleFocus:o,handleChange:r,handleKeyDown:i,handlePaste:s,handleBlur:a,handleInputPointerDown:l,handleDoubleClick:c},u){let f=B();return h("textarea",{ref:u,className:"tl-text tl-text-input",name:"text",tabIndex:-1,disabled:!t,readOnly:!t,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",autoSave:"off",placeholder:"",spellCheck:"true",wrap:"off",dir:"auto",defaultValue:n,onFocus:o,onChange:(p)=>{r({plaintext:p.target.value})},onKeyDown:(p)=>i(p.nativeEvent),onBlur:a,onTouchEnd:f.markEventAsHandled,onContextMenu:t?(p)=>p.stopPropagation():void 0,onPointerDown:l,onPaste:s,onDoubleClick:c,onDragStart:Ie})});var T5e=xe(function({shapeId:t,type:n,text:o,labelColor:r,fontFamily:i,fontSize:s,lineHeight:a,textAlign:l,verticalAlign:c,wrap:u,isSelected:f,padding:d=0,onKeyDown:p,classNamePrefix:m,style:g,textWidth:y,textHeight:S,showTextOutline:b=!0}){let{rInput:x,isEmpty:w,isEditing:v,isReadyForEditing:C,...I}=f8(t,n,o),P=Cm.normalizeTextForDom(o||""),k=P.length>0,_=H1(l);if(!v&&!k)return null;let M=m||"tl-text";return h("div",{className:`${M}-label tl-text-wrapper tl-plain-text-wrapper`,"aria-hidden":!v,"data-hastext":!w,"data-isediting":v,"data-is-ready-for-editing":C,"data-textwrap":!!u,"data-isselected":f,style:{fontFamily:i,textAlign:l,justifyContent:l==="center"||_?"center":l==="end"?"flex-end":"flex-start",alignItems:c==="middle"?"center":c==="end"?"flex-end":"flex-start",padding:d,...g},children:E("div",{className:`${M}-label__inner tl-text-content__wrapper`,style:{fontSize:s,lineHeight:`${hs(s,a)}px`,minHeight:`${hs(s,a)}px`,minWidth:Math.ceil(y||0),color:r,width:y?Math.ceil(y):void 0,height:S?Math.ceil(S):void 0},children:[h("div",{className:Ape.default(`${M} tl-text tl-text-content`,b?"tl-text__outline":"tl-text__no-outline"),dir:"auto",children:P.split(`
|
|
552
|
-
`).map((N,V)=>h("div",{dir:"auto",children:N},V))}),(C||f)&&h(h9,{ref:x,text:o,isEditing:v,shapeId:t,...I,handleKeyDown:p??I.handleKeyDown})]})})});q();q();q();var nT={fonts:{tldraw_mono:`${bo()}/fonts/IBMPlexMono-Medium.woff2`,tldraw_mono_italic:`${bo()}/fonts/IBMPlexMono-MediumItalic.woff2`,tldraw_mono_bold:`${bo()}/fonts/IBMPlexMono-Bold.woff2`,tldraw_mono_italic_bold:`${bo()}/fonts/IBMPlexMono-BoldItalic.woff2`,tldraw_serif:`${bo()}/fonts/IBMPlexSerif-Medium.woff2`,tldraw_serif_italic:`${bo()}/fonts/IBMPlexSerif-MediumItalic.woff2`,tldraw_serif_bold:`${bo()}/fonts/IBMPlexSerif-Bold.woff2`,tldraw_serif_italic_bold:`${bo()}/fonts/IBMPlexSerif-BoldItalic.woff2`,tldraw_sans:`${bo()}/fonts/IBMPlexSans-Medium.woff2`,tldraw_sans_italic:`${bo()}/fonts/IBMPlexSans-MediumItalic.woff2`,tldraw_sans_bold:`${bo()}/fonts/IBMPlexSans-Bold.woff2`,tldraw_sans_italic_bold:`${bo()}/fonts/IBMPlexSans-BoldItalic.woff2`,tldraw_draw:`${bo()}/fonts/Shantell_Sans-Informal_Regular.woff2`,tldraw_draw_italic:`${bo()}/fonts/Shantell_Sans-Informal_Regular_Italic.woff2`,tldraw_draw_bold:`${bo()}/fonts/Shantell_Sans-Informal_Bold.woff2`,tldraw_draw_italic_bold:`${bo()}/fonts/Shantell_Sans-Informal_Bold_Italic.woff2`}};function eA(e){return le(()=>{if(!e)return nT;return{fonts:{...nT.fonts,...e?.fonts}}},[e])}var m9=["align-bottom","align-center-horizontal","align-center-vertical","align-left","align-right","align-top","alt","arrow-arc","arrow-cycle","arrow-elbow","arrow-left","arrowhead-arrow","arrowhead-bar","arrowhead-diamond","arrowhead-dot","arrowhead-none","arrowhead-square","arrowhead-triangle-inverted","arrowhead-triangle","blob","bold","bookmark","bring-forward","bring-to-front","broken","bulletList","check-circle","check","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-ne","chevrons-sw","clipboard-copied","clipboard-copy","closed","code","color","comment","corners","crop","cross-2","cross-circle","dash-dashed","dash-dotted","dash-draw","dash-solid","disconnected","discord","distribute-horizontal","distribute-vertical","dot","dots-horizontal","dots-vertical","download","drag-handle-dots","duplicate","edit","external-link","fill-fill","fill-lined-fill","fill-none","fill-pattern","fill-semi","fill-solid","follow","following","font-draw","font-mono","font-sans","font-serif","geo-arrow-down","geo-arrow-left","geo-arrow-right","geo-arrow-up","geo-check-box","geo-cloud","geo-diamond","geo-ellipse","geo-heart","geo-hexagon","geo-octagon","geo-oval","geo-pentagon","geo-rectangle","geo-rhombus-2","geo-rhombus","geo-star","geo-trapezoid","geo-triangle","geo-x-box","github","group","heading","help-circle","highlight","horizontal-align-end","horizontal-align-middle","horizontal-align-start","info-circle","italic","leading","link","list","lock","manual","menu","minus","mixed","pack","plus","question-mark-circle","question-mark","redo","reset-zoom","rotate-ccw","rotate-cw","send-backward","send-to-back","share-1","size-extra-large","size-large","size-medium","size-small","spline-cubic","spline-line","stack-horizontal","stack-vertical","status-offline","stretch-horizontal","stretch-vertical","strike","text-align-center","text-align-left","text-align-right","toggle-off","toggle-on","tool-arrow","tool-eraser","tool-frame","tool-hand","tool-highlight","tool-laser","tool-line","tool-media","tool-note","tool-pencil","tool-pointer","tool-screenshot","tool-text","trash","twitter","underline","undo","ungroup","unlock","vertical-align-end","vertical-align-middle","vertical-align-start","warning-triangle","zoom-in","zoom-out"];var oT={...nT,icons:Object.fromEntries(m9.map((e)=>[e,`${bo()}/icons/icon/0_merged.svg#${e}`])),translations:Object.fromEntries(nc.map((e)=>[e.locale,`${bo()}/translations/${e.locale}.json`])),embedIcons:Object.fromEntries(Sb.map((e)=>[e.type,`${bo()}/embed-icons/${e.type}.png`]))};function tA(e){return le(()=>{if(!e)return oT;return{fonts:Object.assign({...oT.fonts},{...e?.fonts}),icons:Object.assign({...oT.icons},{...e?.icons}),embedIcons:Object.assign({...oT.embedIcons},{...e?.embedIcons}),translations:Object.assign({...oT.translations},{...e?.translations})}},[e])}function Rpe(){let{Spinner:e}=kn();return h(SB,{children:e?h(e,{}):null})}q();var Ope=wt(Jt(),1);var g9=Wt(function({overrides:t,components:n,assetUrls:o,onUiEvent:r,forceMobile:i,mediaMimeTypes:s,children:a}){let l=yt();return h(s6.Provider,{value:s,children:h(aC,{assetUrls:tA(o),children:h(cC,{overrides:u2(t),locale:l?.user.getLocale()??hr.locale,children:h(AU,{children:h(BU,{onEvent:r,children:h(ZU,{children:h(YU,{context:"tla",children:h(W4,{children:h(OU,{forceMobile:i,children:h(AH,{overrides:n,children:h(I5e,{overrides:t,children:a})})})})})})})})})})})});function I5e({overrides:e,children:t}){let n=Jce(e);return h(ife,{overrides:n.actions,children:h(eue,{overrides:n.tools,children:t})})}q();function Dpe(){let e=B(),{addToast:t}=Jr();F(()=>{function n({name:o,count:r}){t({title:"Maximum shapes reached",description:`You've reached the maximum number of shapes allowed on ${o} (${r}). Please delete some shapes or move to a different page to continue.`,severity:"warning"})}return e.addListener("max-shapes",n),()=>{e.removeListener("max-shapes",n)}},[e,t])}var y9=xe(function({renderDebugMenuItems:t,children:n,hideUi:o,components:r,...i}){return h(g9,{...i,components:r,children:h(P5e,{hideUi:o,renderDebugMenuItems:t,children:n})})}),P5e=xe(function({children:t,hideUi:n}){return TH(),n6(),E(Y,{children:[t,n?null:h(k5e,{})]})}),k5e=xe(function(){let t=B(),n=ie(),o=jt(),r=Go(),i=H("focus",()=>t.getInstanceState().isFocusMode,[t]),s=H("debug",()=>t.getInstanceState().isDebugMode,[t]),a=xt(),l=mt(),c=H("locale",()=>t.user.getLocale(),[t]);F(()=>{a.dir=l,a.lang=c},[a,l,c]);let{SharePanel:u,TopPanel:f,MenuPanel:d,StylePanel:p,Toolbar:m,HelpMenu:g,NavigationPanel:y,HelperButtons:S,DebugPanel:b,Toasts:x,Dialogs:w,A11y:v,FollowingIndicator:C}=Fn();Dpe();let I=L(!1),P=L(-1),[k,_]=G(!1);su("update hide toolbar while delayed",()=>{if(!(Xe.isIos||Xe.isAndroid))return;if(t.getEditingShapeId()===null){if(I.current)if(I.current=!1,clearTimeout(P.current),Xe.isAndroid)P.current=t.timers.setTimeout(()=>{_(!1)},150);else _(!1);return}if(!I.current)I.current=!0,clearTimeout(P.current),_(!0)},[]);let{"toggle-focus-mode":M}=oo(),{breakpointsAbove:N,breakpointsBelow:V}=le(()=>{let D=xb.map((K,U)=>U);return{breakpointsAbove:D.slice(0,o+1).join(" "),breakpointsBelow:D.slice(o+1).join(" ")}},[o]);return E("div",{className:Ope.default("tlui-layout",{"tlui-layout__mobile":o<vt.TABLET_SM}),role:"document","data-iseditinganything":k,"data-breakpoint":o,"data-breakpoints-above":N,"data-breakpoints-below":V,children:[h(afe,{}),i?h("div",{className:"tlui-layout__top",children:h(Ve,{type:"icon",className:"tlui-focus-button",title:n("focus-mode.toggle-focus-mode"),onClick:()=>M.onSelect("menu"),children:h(ve,{icon:"dot"})})}):E(Y,{children:[E("div",{className:"tlui-layout__top",children:[E("div",{className:"tlui-layout__top__left",children:[d&&h(d,{}),S&&h(S,{})]}),h("div",{className:"tlui-layout__top__center",children:f&&h(f,{})}),E("div",{className:"tlui-layout__top__right",children:[u&&h(u,{}),p&&o>=vt.TABLET_SM&&!r&&h(p,{})]})]}),E("div",{className:"tlui-layout__bottom",children:[E("div",{className:"tlui-layout__bottom__main",children:[y&&h(y,{}),m&&h(m,{}),g&&h(g,{})]}),s&&b&&h(b,{}),v&&h(v,{})]})]}),C&&h(C,{}),x&&h(x,{}),w&&h(w,{})]})});function nA(){let{RichTextToolbar:e,ImageToolbar:t,VideoToolbar:n,CursorChatBubble:o}=Fn();return E(Y,{children:[e&&h(e,{}),t&&h(t,{}),n&&h(n,{}),o&&h(o,{})]})}var E5e=[...p9,...l8];function _5e(e,t){let{maxImageDimension:n,acceptedImageMimeTypes:o,acceptedVideoMimeTypes:r}=t,i=n!==void 0||o!==void 0,s=r!==void 0;if(!i&&!s)return e;return e.map((a)=>{if(i&&a.type==="image")return a.configure({...n!==void 0&&{maxDimension:n},...o!==void 0&&{supportedMimeTypes:o}});if(s&&a.type==="video")return a.configure({...r!==void 0&&{supportedMimeTypes:r}});return a})}function rT(e){let{children:t,maxImageDimension:n,maxAssetSize:o,acceptedImageMimeTypes:r,acceptedVideoMimeTypes:i,onMount:s,components:a={},shapeUtils:l=[],bindingUtils:c=[],assetUtils:u=[],overlayUtils:f=[],tools:d=[],embeds:p,options:m,locale:g,textOptions:y,...S}=e,b=Xs(a),x=a?.InFrontOfTheCanvas,w=le(()=>{if(S.hideUi)return x??null;if(!x)return nA;return()=>E(Y,{children:[h(nA,{}),h(x,{})]})},[S.hideUi,x]),v=le(()=>({Spinner:o1,LoadingScreen:Rpe,...b,InFrontOfTheCanvas:w}),[b,w]),C=Ii(l),I=le(()=>Yl("type",C,Q1),[C]),P=Ii(c),k=le(()=>Yl("type",P,F1),[P]),_=Ii(u),M=le(()=>_5e(Yl("type",_,KH),{maxImageDimension:n,acceptedImageMimeTypes:r,acceptedVideoMimeTypes:i}),[_,n,r,i]),N=Ii(f),V=le(()=>Yl("type",N,WH),[N]),D=Ii(d),K=le(()=>Yl("id",D,E5e),[D]),U=Ii(r??hh),A=Ii(i??by),z=m?.text??y,j=le(()=>({addFontsFromNode:PC,...z,tipTapConfig:{extensions:tp,...z?.tipTapConfig}}),[z]),R=le(()=>({...m,text:j}),[m,j]),W=le(()=>[...U,...A],[U,A]),te=eA(S.assetUrls);if(I.find((Ce)=>Ce.type==="embed")&&p)wp.setEmbedDefinitions(p);return h(aC,{assetUrls:tA(S.assetUrls),children:h(cC,{overrides:u2(S.overrides),locale:g??S.user?.userPreferences.get().locale??hr.locale,children:h(yB,{initialState:"select",...S,components:v,shapeUtils:I,bindingUtils:k,assetUtils:M,overlayUtils:V,tools:K,options:R,assetUrls:te,children:E(y9,{...S,components:v,mediaMimeTypes:W,children:[h(M5e,{maxImageDimension:n,maxAssetSize:o,acceptedImageMimeTypes:U,acceptedVideoMimeTypes:A,onMount:s}),t]})})})})}function M5e({maxImageDimension:e,maxAssetSize:t,acceptedImageMimeTypes:n,acceptedVideoMimeTypes:o,onMount:r}){let i=B(),s=Jr(),a=ie(),l=ht();fE(()=>{let f=[];f.push(B8(i)),i.fonts.requestFonts(Nz);let d=i.getThemes();for(let p of Object.values(d))for(let m of Object.keys(p.fonts)){let g=p.fonts[m];if(g.faces?.length)i.fonts.requestFonts(g.faces)}return i.once("edit",()=>l("edit",{source:"unknown"})),$z(i,{maxImageDimension:e,maxAssetSize:t,acceptedImageMimeTypes:n,acceptedVideoMimeTypes:o,toasts:s,msg:a}),f.push(i.store.props.onMount(i)),f.push(r?.(i)),()=>{f.forEach((p)=>p?.())}});let{Canvas:c}=kn(),{ContextMenu:u}=Fn();if(u)return h(u,{});if(c)return h(c,{});return null}q();var Npe={text:{tipTapConfig:{extensions:tp},addFontsFromNode:PC}},L5e=xe(function(t){let[n,o]=G(null),[r,i]=G(null),s=Ii(t.shapeUtils??[]),a=le(()=>Yl("type",s,Q1),[s]),l=Ii(t.bindingUtils??[]),c=le(()=>Yl("type",l,F1),[l]),u=pB({snapshot:t.snapshot,shapeUtils:a,assets:t.assets}),{pageId:f,bounds:d,scale:p,pixelRatio:m,background:g,padding:y,darkMode:S,preserveAspectRatio:b,format:x="svg",licenseKey:w,assetUrls:v,options:C,textOptions:I}=t,P=le(()=>({...Npe,...C,text:{...Npe.text,...C?.text??I}}),[C,I]),k=eA(v);return He(()=>{if(!r)return;if(!u)return;let _=!1,M=r.ownerDocument.createElement("div");r.appendChild(M),r.classList.add("tl-container","tl-theme__light");let N=new ye({store:u,shapeUtils:a,bindingUtils:c,tools:[],getContainer:()=>M,licenseKey:w,fontAssetUrls:k.fonts,options:P});if(f)N.setCurrentPage(f);let V=N.getCurrentPageShapeIds();async function D(){let K=await N.toImage([...V],{bounds:d,scale:p,background:g,padding:y,darkMode:S,preserveAspectRatio:b,format:x});if(!K||_)return;let U=URL.createObjectURL(K.blob);o(U),N.dispose()}return D(),()=>{_=!0}},[x,r,u,a,c,f,d,p,g,y,S,b,w,m,k,P]),F(()=>()=>{if(n)URL.revokeObjectURL(n)},[n]),h("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:n&&h("img",{src:n,referrerPolicy:"strict-origin-when-cross-origin",style:{width:"100%",height:"100%"}})})});q();var A5e=xe(function({children:t}){let n=ie(),o=jt(),r=L(null);mr(r);let i=t??h($6,{});if(o<vt.MOBILE)return null;return h("div",{ref:r,className:"tlui-help-menu",children:E(nd,{id:"help menu",children:[h(od,{children:h(Ve,{type:"help",title:n("help-menu.title"),"data-testid":"help-menu.button",children:h(ve,{icon:"question-mark",small:!0})})}),h(rd,{side:"top",align:"end",alignOffset:0,sideOffset:8,children:h(Nn,{type:"menu",sourceId:"help-menu",children:i})})]})})});var Fpe=wt(Jt(),1);q();var R5e=Q(function({children:t,className:n},o){return E(ANe,{ref:o,className:Fpe.default("tlui-button tlui-select__trigger",n),children:[t,h(RNe,{className:"tlui-select__chevron",children:h(xr,{icon:"chevron-down",label:"",small:!0})})]})});q();oM();var ca={White:"white",LightGray:"lightGray",Gray:"gray",Black:"black",Green:"green",Cyan:"cyan",Blue:"blue",Indigo:"indigo",Violet:"violet",Red:"red",Orange:"orange",Yellow:"yellow"},rg={Small:"small",Medium:"medium",Large:"large"},iT={Draw:"draw",Solid:"solid",Dashed:"dashed",Dotted:"dotted"},bd={Start:"start",Middle:"middle",End:"end",Justify:"justify"},sT={Script:"script",Sans:"sans",Serif:"serif",Mono:"mono"};var myr={[ca.White]:"black",[ca.Black]:"black",[ca.LightGray]:"grey",[ca.Gray]:"grey",[ca.Green]:"light-green",[ca.Cyan]:"green",[ca.Blue]:"light-blue",[ca.Indigo]:"blue",[ca.Orange]:"orange",[ca.Yellow]:"yellow",[ca.Red]:"red",[ca.Violet]:"light-violet"},gyr={[sT.Mono]:"mono",[sT.Sans]:"sans",[sT.Script]:"draw",[sT.Serif]:"serif"},yyr={[bd.Start]:"start",[bd.Middle]:"middle",[bd.End]:"end",[bd.Justify]:"start"},Syr={[bd.Start]:"start",[bd.Middle]:"middle",[bd.End]:"end",[bd.Justify]:"start"},byr={[rg.Small]:"s",[rg.Medium]:"l",[rg.Large]:"xl"},xyr={[rg.Small]:"m",[rg.Medium]:"l",[rg.Large]:"xl"},vyr={[iT.Solid]:"solid",[iT.Dashed]:"dashed",[iT.Dotted]:"dotted",[iT.Draw]:"draw"};var O5e=Ye({schemaVersion:co(1),storeVersion:ik,recordVersions:sk(Ne,Ye({version:ik,subTypeVersions:sk(Ne,ik).optional(),subTypeKey:Ne.optional()}))}),N5e=Ye({schemaVersion:co(2),sequences:sk(Ne,ik)}),Iyr=Ye({tldrawFileFormatVersion:Hwe,schema:Vwe("schemaVersion",{1:O5e,2:N5e}),records:ur(Ye({id:Ne,typeName:Ne}).allowUnknownProperties())});ci("tldraw","5.5.2","esm");var oA=["label","name","both"],S9=["ja","en"],F5e=S9.flatMap((e)=>oA.map((t)=>[e,t]));var Bpe=(e,t)=>Object.fromEntries(S9.map((n)=>[n,Object.fromEntries(oA.map((o)=>[o,t(e[n][o],n,o)]))])),rA=(e)=>Object.fromEntries(S9.map((t)=>[t,{label:e[t],name:e[t],both:e[t]}])),b9=["command","event","both"];function aT(e,t,n){if(n==="command")return{main:e,faded:!1};if(n==="event")return t?{main:t,faded:!1}:{main:e,faded:!0};return{main:e,sub:t&&Bpe(t,(o)=>`⇒ ${o}`),faded:!1}}var iA=19,sA=15,x9=0.85,v9=(e,t)=>zpe+(aT(e.label,e.events,t).sub?sA:0),w9=5,aA=(e,t)=>e.internal?.length?2*w9+e.internal.reduce((n,o)=>n+v9(o,t),0):0;var C9=["detail","overview","aggregates"];var zpe=21;q();var Hpe="domaintrail.lang",Vpe={added:"追加",changed:"変更",removed:"削除",none:"なし",shared:"共有",sharedTag:"共有",persistent:"永続化",transient:"非永続",persistentHint:"永続化される契約のイベント(persistent)",transientHint:"永続化しないイベント(persistent の指定なし)",noModel:"モデルがまだありません。",noDtFiles:".dt ファイルがありません",nameDisplay:"名前の表示",nameDisplayHint:"モデルの要素を、ラベル(日本語名など)と名前のどちらで表示するか",modes:{label:"ラベル",name:"名前",both:"両方"},status:{ok:"正常",invalid:"検証エラー","syntax-error":"構文エラー",empty:".dt なし"},settings:"設定",closeSettings:"設定を閉じる",theme:"テーマ",themes:{auto:"自動",light:"ライト",dark:"ダーク"},themeAuto:(e)=>`OS の設定に従う(いまは${e})`,themeHint:"画面の配色",language:"言語",langAuto:(e)=>`ブラウザの設定に従う(いまは${e})`,langHint:"画面の表示言語(モデルのラベルは変わりません)",fileCount:(e)=>`${e} ファイル`,connection:{connecting:"接続中",open:"接続済み",closed:"切断"},connectionTitle:(e)=>`サーバーとの接続: ${e}`,stale:(e)=>E(Y,{children:["構文エラーのため、最後に解析できた図を表示しています。",e,"から該当箇所へ移動できます。"]}),openExplorer:"エクスプローラを開く",closeExplorer:"エクスプローラを閉じる",openInspector:"インスペクタを開く",closeInspector:"インスペクタを閉じる",openBottom:"問題・変更を開く",closeBottom:"問題・変更を閉じる",views:{contextMap:"コンテキストマップ",structure:"構造図",catalog:"カタログ"},showAllContexts:"共有・外部の BC も表示",structureMode:"構造図の表示",structureLevels:{detail:"詳細 — すべての項目を表示",overview:"概観 — 要素の名前だけを表示",aggregates:"集約 — 集約とその関係だけを表示"},zoomToFit:"全体表示",transitionLabels:"遷移のラベル",transitionLabelModes:{command:{label:"コマンド",hint:"コマンドだけを表示"},event:{label:"イベント",hint:"発生させるドメインイベントだけを表示(イベントのない遷移はコマンドを薄く表示)"},both:{label:"両方",hint:"コマンドと、その下に発生させるドメインイベントを表示"}},pickContexts:"表示する BC を選んでください",loading:"読み込み中…",noDiagram:"表示できる図がありません",contextsToShow:"表示する BC",allContexts:"すべての BC",moreContexts:(e,t)=>`${e} ほか ${t} BC`,listSeparator:"、",hiddenContexts:(e)=>` · ${e} BC 非表示`,allStubs:"スタブをまとめて表示",showAllStubs:"すべてスタブとして表示する",hideAllStubs:"すべてのスタブを表示しない",contextStubs:(e)=>`${e} をスタブとして表示`,showStubs:"スタブとして表示する",hideStubs:"スタブを表示しない",legend:"凡例",openLegend:"凡例を開く",closeLegend:"凡例を閉じる",legendRows:{mapReferences:"ID だけで依存(ID 参照の件数)",mapDependsOn:"型も借りて依存(型の借用の件数)",owns:"所有(集約の内部)",focusReferences:"参照(ID で別の集約・BC へ)",focusValue:"値・型の借用(値オブジェクト / ユニオン / 列挙型 など)",references:"参照(ID で別の集約へ)",value:"値(値オブジェクト / ユニオンを持つ)",aggregateReferences:"参照(ID で別の集約へ。エンティティや値オブジェクトを経由するものも含む)",aggregateValue:"別の集約を値として持つ",transition:"コマンドによる遷移(⇒ 発生させるドメインイベント)"},stubNote:"点線枠の小さな箱は別の BC の要素(スタブ)",aggregateStubNote:"点線枠の小さな箱は別の BC の集約(スタブ)",arrowNote:"矢印の先が依存先",internalNote:"状態の箱の中の ↻ は状態を変えないコマンド",model:"モデル",files:"ファイル",fileKind:"ファイル",filter:"フィルタ",clearFilter:"フィルタを消す",onlyProblems:"問題のある項目だけ表示",onlyChanged:"変更された項目だけ表示",noMatches:"一致する項目はありません。",kinds:{aggregate:"集約",entity:"エンティティ",valueObject:"値オブジェクト",union:"ユニオン",primitive:"ドメインプリミティブ",id:"ID",enum:"列挙型",event:"ドメインイベント",error:"エラー",fieldSet:"項目セット",state:"状態",command:"コマンド",context:"コンテキスト"},problems:"問題",changes:"変更",noProblems:"問題はありません。",noChanges:"直前の正常モデルからの変更はありません。",catalogSections:{aggregates:"集約",entities:"エンティティ",values:"値オブジェクト・ユニオン",primitives:"ドメインプリミティブ",fieldSets:"項目セット",events:"ドメインイベント",errors:"エラー"},sharedCatalog:"共有 · どの BC からも名前で参照可",catalogEmpty:"ありません。",catalogKinds:"表示する種類",catalogNoMatches:"一致する要素はありません。",raisedByNone:"発生させるコマンドはありません",returnedByNone:"返すコマンドはありません",usedIn:(e)=>`使用 ${e} 箇所`,copyCode:"コードをコピー",counted:(e,t)=>`${e}(${t})`,tabs:{structure:"構造",states:"状態遷移",behavior:"振る舞い",events:"イベント",references:"参照",source:"ソース"},reveal:{contextMap:"コンテキストマップ",structure:"構造図",catalog:"カタログ"},backTo:(e)=>`${e} に戻る`,notInModel:(e)=>`${e} は現在のモデルにありません。`,pickElement:"エクスプローラや図で要素やファイルを選ぶと、ここに詳細が出ます。",showIn:"見る:",commandsInto:"この状態に入るコマンド",commandsOutOf:"この状態から出るコマンド",stateFields:"この状態固有のフィールド",noStateFields:"この状態固有のフィールドはありません。",stateInvariants:"不変条件(この状態のみ)",commonFieldsAt:(e)=>E(Y,{children:["共通フィールドは集約 ",e," を参照。"]}),transition:"遷移",noStates:"(状態なし)",mayRaise:"発生し得るドメインイベント(0 件以上)",mayReturn:"返し得るエラー",params:"パラメータ",noParams:"パラメータはありません。",contract:"契約",identifier:"ドメインプリミティブ(識別子)",separator:" / ",baseType:"基底型",values:"値",discriminator:"判別子",noFields:"フィールドはありません。",variantInvariants:(e)=>`不変条件(${e})`,commonFields:"共通フィールド",payload:"ペイロード",fields:"フィールド",invariants:"不変条件",allStateInvariants:"不変条件(全状態共通)",valueInvariants:"不変条件(値(value)に適用)",commands:"コマンド",states:"状態",typeDependency:"型",focusContext:"この BC だけを構造図で見る",dependencies:"依存先(この BC が使う)",dependents:"依存元(この BC を使う)",terms:"用語集(terms)",unreferenced:"どこからも参照されていません。",raisedBy:"発生させるコマンド",returnedBy:"返すコマンド",typeUses:(e)=>`型として使われている場所(${e})`,fieldSetUsers:(e)=>`使っている要素(${e})`,fromFieldSet:(e)=>`項目セット ${e} の項目`,idUses:(e,t)=>`ID(${e})で参照している場所(${t})`,raises:(e)=>`発生させるドメインイベント(${e})`,factory:"生成",origin:"発生元",raisesHint:"発生させるドメインイベント",returnsHint:"返し得るエラー",returns:(e)=>`返し得るエラー(${e})`,labelSources:{term:"用語",type:"型"}},B5e={added:"Added",changed:"Changed",removed:"Removed",none:"None",shared:"Shared",sharedTag:"shared",persistent:"Persistent",transient:"Transient",persistentHint:"Persisted by contract (persistent)",transientHint:"Not persisted (not declared persistent)",noModel:"No model yet.",noDtFiles:"No .dt files",nameDisplay:"Names",nameDisplayHint:"Whether model elements are shown by their labels, their names or both",modes:{label:"Label",name:"Name",both:"Both"},status:{ok:"OK",invalid:"Invalid","syntax-error":"Syntax error",empty:"No .dt"},settings:"Settings",closeSettings:"Close the settings",theme:"Theme",themes:{auto:"Auto",light:"Light",dark:"Dark"},themeAuto:(e)=>`Follows the OS (now ${e})`,themeHint:"The colors of the screen",language:"Language",langAuto:(e)=>`Follows the browser (now ${e})`,langHint:"The language of the screen (model labels stay as written)",fileCount:(e)=>`${e} ${e===1?"file":"files"}`,connection:{connecting:"connecting",open:"connected",closed:"disconnected"},connectionTitle:(e)=>`Connection to the server: ${e}`,stale:(e)=>E(Y,{children:["Showing the last diagram that could be parsed, because of a syntax error. See ",e," for where it is."]}),openExplorer:"Open the explorer",closeExplorer:"Close the explorer",openInspector:"Open the inspector",closeInspector:"Close the inspector",openBottom:"Open problems and changes",closeBottom:"Close problems and changes",views:{contextMap:"Context Map",structure:"Structure",catalog:"Catalog"},showAllContexts:"Also show shared and external BCs",structureMode:"Structure view",structureLevels:{detail:"Detail — show every field",overview:"Overview — show the elements’ names only",aggregates:"Aggregates — show the aggregates and their relations only"},zoomToFit:"Fit",transitionLabels:"Transition labels",transitionLabelModes:{command:{label:"Command",hint:"Show the commands only"},event:{label:"Events",hint:"Show the domain events raised only (a transition without events shows its command, faded)"},both:{label:"Both",hint:"Show the commands and, under them, the domain events raised"}},pickContexts:"Pick the BCs to show",loading:"Loading…",noDiagram:"Nothing to draw",contextsToShow:"BCs to show",allContexts:"All BCs",moreContexts:(e,t)=>`${e} and ${t} more`,listSeparator:", ",hiddenContexts:(e)=>` · ${e} hidden`,allStubs:"Show all stubs",showAllStubs:"Show all as stubs",hideAllStubs:"Hide all stubs",contextStubs:(e)=>`Show ${e} as stubs`,showStubs:"Show as stubs",hideStubs:"Hide the stubs",legend:"Legend",openLegend:"Open the legend",closeLegend:"Close the legend",legendRows:{mapReferences:"Depends by IDs only (ID references)",mapDependsOn:"Also borrows types (borrowed types)",owns:"Owns (inside an aggregate)",focusReferences:"References (by ID, another aggregate or BC)",focusValue:"Value or borrowed type (Value Object, Union, Enum…)",references:"References (by ID, another aggregate)",value:"Value (holds a Value Object or Union)",aggregateReferences:"References (by ID, another aggregate, also through entities and value objects)",aggregateValue:"Holds another aggregate as a value",transition:"Transition by a command (⇒ events it raises)"},stubNote:"Small dashed boxes are elements of other BCs (stubs)",aggregateStubNote:"Small dashed boxes are aggregates of other BCs (stubs)",arrowNote:"Arrows point at the dependency",internalNote:"↻ in a state’s box: a command that keeps the state",model:"Model",files:"Files",fileKind:"File",filter:"Filter",clearFilter:"Clear the filter",onlyProblems:"Show only items with problems",onlyChanged:"Show only changed items",noMatches:"Nothing matches.",kinds:{aggregate:"Aggregate",entity:"Entity",valueObject:"Value Object",union:"Union",primitive:"Domain Primitive",id:"ID",enum:"Enum",event:"Event",error:"Error",fieldSet:"Field set",state:"State",command:"Command",context:"Context"},problems:"Problems",changes:"Changes",noProblems:"No problems.",noChanges:"No changes since the last valid model.",catalogSections:{aggregates:"Aggregates",entities:"Entities",values:"Value Objects and Unions",primitives:"Domain Primitives",fieldSets:"Field sets",events:"Domain Events",errors:"Errors"},sharedCatalog:"Shared · referable by name from any context",catalogEmpty:"None.",catalogKinds:"Kinds to show",catalogNoMatches:"No elements match.",raisedByNone:"No command raises it",returnedByNone:"No command returns it",usedIn:(e)=>`Used in ${e} ${e===1?"place":"places"}`,copyCode:"Copy the code",counted:(e,t)=>`${e} (${t})`,tabs:{structure:"Structure",states:"States",behavior:"Behavior",events:"Events",references:"References",source:"Source"},reveal:{contextMap:"Context Map",structure:"Structure",catalog:"Catalog"},backTo:(e)=>`Back to ${e}`,notInModel:(e)=>`${e} is not in the current model.`,pickElement:"Select an element or a file in the explorer or a diagram to see its details here.",showIn:"Show in:",commandsInto:"Commands into this state",commandsOutOf:"Commands out of this state",stateFields:"Fields of this state",noStateFields:"This state has no fields of its own.",stateInvariants:"Invariants (this state only)",commonFieldsAt:(e)=>E(Y,{children:["For the common fields, see the aggregate ",e,"."]}),transition:"Transition",noStates:"(no states)",mayRaise:"Events it may raise (zero or more)",mayReturn:"Errors it may return",params:"Parameters",noParams:"No parameters.",contract:"Contract",identifier:"Domain Primitive (identifier)",separator:" / ",baseType:"Base type",values:"Values",discriminator:"Discriminator",noFields:"No fields.",variantInvariants:(e)=>`Invariants (${e})`,commonFields:"Common fields",payload:"Payload",fields:"Fields",invariants:"Invariants",allStateInvariants:"Invariants (all states)",valueInvariants:"Invariants (on the value)",commands:"Commands",states:"States",typeDependency:"type",focusContext:"Show only this BC in Structure",dependencies:"Dependencies (used by this BC)",dependents:"Dependents (using this BC)",terms:"Terms",unreferenced:"Not referenced anywhere.",raisedBy:"Commands that raise it",returnedBy:"Commands that return it",typeUses:(e)=>`Used as a type (${e})`,fieldSetUsers:(e)=>`Elements that use it (${e})`,fromFieldSet:(e)=>`A field of the field set ${e}`,idUses:(e,t)=>`Referenced by ID ${e} (${t})`,raises:(e)=>`Events it raises (${e})`,factory:"create",origin:"From",raisesHint:"Events it raises",returnsHint:"Errors it may return",returns:(e)=>`Errors it may return (${e})`,labelSources:{term:"term",type:"type"}},T9={ja:Vpe,en:B5e},I9={ja:"日本語",en:"English"},Upe=()=>navigator.languages.some((e)=>e.toLowerCase().startsWith("ja"))?"ja":"en";function jpe(e){let[t,n]=G(Upe);return F(()=>{let o=()=>n(Upe());return window.addEventListener("languagechange",o),()=>window.removeEventListener("languagechange",o)},[]),e==="auto"?t:e}var P9=Oe({lang:"ja",t:Vpe});function $pe({lang:e,children:t}){return F(()=>{document.documentElement.lang=e},[e]),h(P9.Provider,{value:{lang:e,t:T9[e]},children:t})}var Kt=()=>Te(P9).t,Gpe=()=>Te(P9).lang;var lT=(e)=>Object.values(e.elements),lA=(e)=>e.fields.filter((t)=>!t.fieldSet);function cA(e){let t=[];for(let n of lT(e)){let o=(i,s,a)=>{let l=i?z5e(i):void 0;if(!i||!l||l===n.context||!e.contexts.includes(l))return;t.push({from:n.context,to:l,kind:a??(e.elements[i]?.kind==="id"?"id":"type"),source:n.id,path:s,target:i})},r=(i,s)=>{if(i.kind==="references"&&i.target)o(i.target,s,"id");else if(i.type.kind==="ref")o(i.type.ref,s)};for(let i of lA(n))r(i,i.name);for(let i of n.fieldSets??[])o(i,"with");for(let i of n.states??[])for(let s of i.fields)r(s,`${i.name}.${s.name}`);for(let i of n.variants??[])for(let s of i.fields)r(s,`${i.name}.${s.name}`);if(n.tagType)o(n.tagType,"by");for(let i of n.commands??[]){for(let s of i.params)r(s,`${i.name}(${s.name})`);for(let s of[...i.emits,...i.errors])o(s,`${i.name} ⇒ ${U5e(s)}`)}}return t}function k9(e){let t=new Map;for(let n of e){let o=`${n.from}->${n.to}`,r=t.get(o)??{from:n.from,to:n.to,uses:[],ids:0,types:0};if(r.uses.push(n),n.kind==="id")r.ids++;else r.types++;t.set(o,r)}return[...t.values()]}function uA(e){let t=new Set(e.sharedContexts);for(let n of e.contexts){let o=lT(e).filter((r)=>r.context===n);if(o.length>0&&o.every((r)=>r.kind==="id"))t.add(n)}return t}var z5e=(e)=>e.includes(".")?e.slice(0,e.indexOf(".")):void 0,U5e=(e)=>e.slice(e.lastIndexOf(".")+1);var Cs=(e,t)=>rA({ja:`«${e}»`,en:`«${t}»`}),p0r={aggregate:Cs("集約ルート","aggregate root"),entity:Cs("エンティティ","entity"),valueObject:Cs("値オブジェクト","value object"),union:Cs("ユニオン","union")};var E9={String:"文字列",Int:"整数",Decimal:"小数",Bool:"真偽値",Timestamp:"日時",UUID:"UUID"};function qpe(e,t,n=[]){if(e.kind==="primitive")return e.name;let o=e.ref.slice(0,e.ref.indexOf("."));return o===t||n.includes(o)?e.ref.slice(o.length+1):e.ref}var h0r=new Set([..."、。,.,.))」』】!?!?ー"]);var m0r={aggregate:Cs("集約","aggregate"),entity:Cs("エンティティ","entity"),valueObject:Cs("値オブジェクト","value object"),union:Cs("ユニオン","union"),enum:Cs("列挙型","enum"),primitive:Cs("ドメインプリミティブ","primitive"),id:Cs("ID","id"),event:Cs("ドメインイベント","event"),error:Cs("エラー","error"),fieldSet:Cs("項目セット","field set")};var Ll=(e,t)=>e[t.lang][t.mode],Kpe=new Set(["context","sharedContext","aggregateBoundary"]),j5e=(e)=>Ke(`n:${e}`),$5e=(e)=>Ke(`e:${e}`),Wpe=(e)=>Ke(`ghost:${e}`),G5e=(e)=>Ke(`i:${e}`),q5e=(e,t)=>e.lines.map((n)=>({k:Ll(n.key,t),v:n.value?Ll(n.value,t):"",...n.origin&&{o:Ll(n.origin,t)}})),Al=(e)=>e.split(/[#:]/)[0];function dA(e,t){return e.getShape(t)?.meta?.elementId}function Zpe(e,t){let n=e.getCurrentPageShapes();return(n.find((r)=>r.meta.elementId===t&&r.type==="domain-node")??n.find((r)=>r.meta.elementId===t))?.id}function fA(e,t,n){let o=t.id.startsWith("structure"),r=t.textScale??1,i=Y5e(n.diagnostics,o),s=(m)=>n.diff.added.includes(m)?"added":n.diff.changed.includes(m)?"changed":"none",a=[],l=[],c=[];for(let m of t.nodes){let g=t.nodeLayout[m.id];if(!g)continue;let y=Kpe.has(m.kind),S={change:y?"none":s(m.elementId),diag:y?"none":i.get(m.elementId)??"none"},b={id:j5e(m.id),x:g.x,y:g.y,meta:{elementId:m.elementId,graphNode:m.id}};if(y)a.push({...b,type:"domain-group",props:{w:g.width,h:g.height,kind:m.kind,label:Ll(m.label,n),lines:m.lines.map((x)=>Ll(x.key,n)),scale:r,...S}});else l.push({...b,type:"domain-node",props:{...Ype(t,m,g,n),...S}}),c.push(...Xpe(t,m,g,n,(x)=>({change:s(x),diag:i.get(x)??"none"})))}let u=[];if(n.previous&&n.previous.id===t.id){let m=new Set(t.nodes.map((g)=>g.elementId));for(let g of n.previous.nodes){let y=n.previous.nodeLayout[g.id];if(!y||Kpe.has(g.kind)||m.has(g.elementId)||!n.diff.removed.includes(g.elementId))continue;u.push({id:Wpe(g.id),type:"domain-node",x:y.x,y:y.y,meta:{elementId:g.elementId,ghost:!0},props:{...Ype(n.previous,g,y,n),change:"removed",diag:"none"}});for(let S of Xpe(n.previous,g,y,n,()=>({change:"removed",diag:"none"})))u.push({...S,id:Wpe(`i:${S.meta.edge}`),meta:{...S.meta,ghost:!0}})}}let f=[];for(let m of t.edges){let g=Jpe(m,o),y=W5e(t,m,n,i.get(g)==="error"&&!o?"error":K5e(s(g)));if(y)f.push(y)}let d=[...a,...l,...u,...c,...f],p=new Set(d.map((m)=>m.id));cT(e,()=>{let m=e.getCurrentPageShapes().filter((x)=>!p.has(x.id));e.deleteShapes(m.map((x)=>x.id));let g=[],y=[];for(let x of d)(e.getShape(x.id)?y:g).push(x);e.createShapes(g),e.updateShapes(y);let S=a.filter((x)=>x.props.kind==="aggregateBoundary").map((x)=>x.id),b=a.filter((x)=>x.props.kind!=="aggregateBoundary").map((x)=>x.id);if(S.length)e.sendToBack(S);if(b.length)e.sendToBack(b);if(c.length)e.bringToFront(c.map((x)=>x.id));if(f.length)e.bringToFront(f.map((x)=>x.id))})}function Ype(e,t,n,o){return{w:n.width,h:n.height,kind:t.kind,label:Ll(t.label,o),stereotype:t.stereotype?Ll(t.stereotype,o):"",scale:e.textScale??1,rows:q5e(t,o),compartment:t.internal?.length?aA(t,e.transitionLabels??"both"):0}}function Xpe(e,t,n,o,r){if(!t.internal?.length)return[];let i=o.transitionLabels??"both",s=n.y+n.height-aA(t,e.transitionLabels??"both")+w9;return t.internal.map((a)=>{let l=aT(a.label,a.events,i),c=v9(a,i),u={id:G5e(a.id),type:"domain-internal",x:n.x+4,y:s,meta:{elementId:a.elementId,edge:a.id},props:{w:n.width-8,h:c,label:Ll(l.main,o),sub:l.sub?Ll(l.sub,o):"",faded:l.faded,scale:e.textScale??1,...r(a.elementId)}};return s+=c,u})}function cT(e,t){let n=e.getIsReadonly();if(n)e.updateInstanceState({isReadonly:!1});try{e.run(t,{history:"ignore",ignoreShapeLock:!0})}finally{if(n)e.updateInstanceState({isReadonly:!0})}}function Jpe(e,t){return t?e.source:e.id.split("|")[0]}var K5e=(e)=>e==="added"?"added":e==="changed"?"changed":"normal";function W5e(e,t,n,o){let r=e.edgeLayout[t.id];if(!r||r.points.length<2)return;let i=r.points.map((f)=>f.x),s=r.points.map((f)=>f.y);if(r.label)i.push(r.label.x),s.push(r.label.y);let a=Math.min(...i),l=Math.min(...s),c=r.label,u=t.label&&(t.kind==="transition"?aT(t.label,t.events,n.transitionLabels??"both"):{main:t.label,faded:!1});return{id:$5e(t.id),type:"domain-edge",x:a,y:l,meta:{elementId:Jpe(t,e.id.startsWith("structure")),edge:t.id},props:{points:r.points.map((f)=>({x:f.x-a,y:f.y-l})),kind:t.kind,label:u?Ll(u.main,n):"",sub:u&&"sub"in u&&u.sub?Ll(u.sub,n):"",faded:u?u.faded:!1,scale:e.textScale??1,lx:c?c.x-a:0,ly:c?c.y-l:0,lw:c?.width??0,lh:c?.height??0,tone:o}}}function Y5e(e,t){let n=new Map;for(let o of e){if(!o.elementId)continue;let r=t?[Al(o.elementId)]:[o.elementId,Al(o.elementId)];for(let i of r)if(n.get(i)!=="error")n.set(i,o.severity==="error"?"error":"warning")}return n}var pA=["aggregate","entity","valueObject","union","primitive","id","enum","fieldSet","event","error"],X5e=(e)=>e.slice(e.lastIndexOf(".")+1);var xd=(e,t,n)=>e==="name"||!n?t:e==="label"?n:`${n} (${t})`;function Wb(e,t){if(e.contexts.includes(t))return{kind:"context",name:t,label:e.contextLabels[t],shared:e.sharedContexts.includes(t)};let n=e.elements[t];if(n)return{kind:"element",el:n};let o=e.elements[Al(t)],r=o?.states?.find((s)=>s.id===t);if(o&&r)return{kind:"state",agg:o,state:r};let i=o?.commands?.find((s)=>s.id===t);if(o&&i)return{kind:"command",agg:o,command:i};return}var hA=(e)=>`file:${e}`,Yb=(e)=>e?.startsWith("file:")?e.slice(5):void 0,Qpe=(e)=>e==="aggregate"||e==="entity"||e==="valueObject"||e==="union",ehe=[{key:"aggregates",kinds:["aggregate"]},{key:"entities",kinds:["entity"]},{key:"values",kinds:["valueObject","union"]},{key:"primitives",kinds:["primitive","id","enum"]},{key:"fieldSets",kinds:["fieldSet"]},{key:"events",kinds:["event"]},{key:"errors",kinds:["error"]}],mA=(e)=>ehe.some((t)=>t.kinds.includes(e));function the(e){let t=uT(e);return ehe.map(({key:n,kinds:o})=>{let r=t.map((i)=>({context:i,items:Object.values(e.elements).filter((s)=>s.context===i&&o.includes(s.kind)).sort((s,a)=>o.indexOf(s.kind)-o.indexOf(a.kind)||s.name.localeCompare(a.name))})).filter((i)=>i.items.length>0);return{key:n,kinds:o,groups:r,count:r.reduce((i,s)=>i+s.items.length,0)}})}var nhe=(e)=>e.query.trim()!==""||e.sections.length>0||e.contexts!==null;function Z5e(e,t){let n=t.trim().toLowerCase();return!n||[e.label,e.name,e.doc].some((o)=>o?.toLowerCase().includes(n))}function ohe(e,t){return e.map((n)=>{let o=t.sections.length&&!t.sections.includes(n.key)?[]:n.groups.filter((r)=>t.contexts===null||t.contexts.includes(r.context)).map((r)=>({...r,items:r.items.filter((i)=>Z5e(i,t.query))})).filter((r)=>r.items.length>0);return{...n,groups:o,shown:o.reduce((r,i)=>r+i.items.length,0)}})}function rhe(e,t){return Object.values(e.elements).flatMap((n)=>(n.commands??[]).filter((o)=>o.emits.includes(t)||o.errors.includes(t)).map((o)=>({agg:n,command:o})))}var gA=(e,t)=>Object.values(e.elements).filter((n)=>n.fieldSets?.includes(t));function uT(e){let t=new Set(e.sharedContexts);return[...e.contexts].sort((n,o)=>Number(t.has(o))-Number(t.has(n))||n.localeCompare(o))}function vd(e,t){let n=(r)=>xd(e,r.name,r.label),o=(r,i)=>{let s=r.states?.find((a)=>a.name===i);return s?n(s):i};return{mode:e,of:n,field:n,type(r,i){let s=qpe(r,i,t?.sharedContexts??[]);if(e!=="label")return s;return r.kind==="primitive"?E9[r.name]:t?.elements[r.ref]?.label??s},primitive:(r)=>e==="label"?E9[r]??r:r,state:o,transition(r,i){if(!r.states?.length)return i.factory?"new":"";return`${i.factory?"new":i.from.map((s)=>o(r,s)).join(" | ")} → ${i.to.map((s)=>o(r,s)).join(" | ")}`},short(r){let i=t?.elements[r];if(!i)return X5e(r);return e==="both"?i.label??i.name:n(i)},id(r){let i=t?Wb(t,r):void 0;if(!i)return r;if(i.kind==="context")return xd(e,i.name,i.label);if(i.kind==="element")return n(i.el);if(i.kind==="state")return`${n(i.agg)}.${n(i.state)}`;return`${n(i.agg)}.${n(i.command)}`}}}function ihe(e){let t=Kt(),n=e.diagnostics.filter((s)=>s.severity==="error").length,o=e.diagnostics.length-n,r=e.diff.added.length+e.diff.changed.length+e.diff.removed.length,i=(s)=>{if(e.open&&e.tab===s)e.onToggle();else if(e.onTab(s),!e.open)e.onToggle()};return E("div",{className:"bottom",children:[E("div",{className:"bottom-bar",children:[E("button",{className:e.open&&e.tab==="problems"?"active":"",onClick:()=>i("problems"),children:[t.problems,n>0&&h("span",{className:"count count-error",children:n}),o>0&&h("span",{className:"count count-warning",children:o}),n+o===0&&h("span",{className:"muted",children:" 0"})]}),E("button",{className:e.open&&e.tab==="changes"?"active":"",onClick:()=>i("changes"),children:[t.changes," ",r>0?h("span",{className:"count",children:r}):h("span",{className:"muted",children:"0"})]}),h("button",{className:"icon-button bottom-toggle",onClick:e.onToggle,"data-tooltip":e.open?t.closeBottom:t.openBottom,"aria-label":e.open?t.closeBottom:t.openBottom,children:e.open?h(Sv,{size:16,"aria-hidden":!0}):h(bv,{size:16,"aria-hidden":!0})})]}),h("div",{className:"bottom-body",inert:!e.open,children:e.tab==="problems"?h(J5e,{items:e.diagnostics,onLocate:e.onLocate}):h(Q5e,{...e})})]})}function J5e({items:e,onLocate:t}){let n=Kt();if(e.length===0)return h("p",{className:"muted pad",children:n.noProblems});return h("table",{className:"problems",children:h("tbody",{children:e.map((o,r)=>E("tr",{className:`problem problem-${o.severity}`,onClick:()=>t(o),children:[h("td",{className:"problem-icon",children:o.severity==="error"?"✕":"!"}),h("td",{children:h("code",{children:o.code})}),h("td",{className:"problem-msg",children:o.message}),E("td",{className:"muted nowrap",children:[o.file,":",o.start.line,":",o.start.column]}),h("td",{className:"muted nowrap",children:o.elementId??""})]},r))})})}function Q5e({diff:e,model:t,mode:n,onSelect:o}){let r=Kt();if(!e.added.length&&!e.changed.length&&!e.removed.length)return h("p",{className:"muted pad",children:r.noChanges});let i=vd(n,t).id,s=[["added",r.added],["changed",r.changed],["removed",r.removed]];return h("div",{className:"changes",children:s.map(([a,l])=>E("div",{className:"changes-col",children:[E("h3",{children:[l," ",h("span",{className:"muted",children:e[a].length})]}),e[a].map((c)=>h("div",{className:`sub diffrow diffrow-${a}`,children:a==="removed"?h("span",{children:c}):h("a",{onClick:()=>o(c),children:i(c)})},c))]},a))})}q();function dT({persistent:e,tx:t}){return h("span",{className:`persistence-badge${e?" persistent":""}`,title:e?t.persistentHint:t.transientHint,children:e?t.persistent:t.transient})}function she({kind:e,x:t,names:n,onClick:o}){let r=n.mode==="both"&&!!t.label;return E("a",{className:"bcard-title",onClick:o,children:[h("span",{className:`bcard-band band-${e}`,"aria-hidden":!0}),h("strong",{children:r?t.label:n.of(t)}),r&&h("span",{className:"bcard-name",children:t.name})]})}function ahe({x:e,names:t}){return t.mode==="both"&&e.label?E(Y,{children:[e.label," ",h("span",{className:"bcard-name",children:e.name})]}):h(Y,{children:t.of(e)})}function _9({kind:e,id:t,x:n,names:o,onSelect:r}){return E("a",{className:"kind-link",onClick:()=>r(t),children:[h("span",{className:`tree-dot dot-${e}`,"aria-hidden":!0}),h(ahe,{x:n,names:o})]})}function lhe({fields:e,ctx:t,names:n,onSelect:o}){return h("div",{className:"bcard-fields",children:e.map((r)=>E("div",{className:"bcard-field",title:r.doc,children:[h("span",{className:"bcard-fname",children:h(ahe,{x:r,names:n})}),E("span",{className:"bcard-ftype",children:[r.type.kind==="ref"&&r.type.target?h("a",{onClick:()=>o(r.type.ref),children:n.type(r.type,t)}):n.type(r.type,t),r.multiplicity,r.fieldSet&&h("a",{className:"field-origin",onClick:()=>o(r.fieldSet),children:n.short(r.fieldSet)})]})]},r.name))})}function eUe({agg:e,c:t,names:n,onSelect:o}){let r=(i)=>i.map((s)=>{let a=e.states?.find((c)=>c.name===s),l=n.mode==="both"&&!!a?.label;return h("a",{className:"state-chip",title:l?s:void 0,onClick:()=>o(a?.id??e.id),children:l?a.label:n.state(e,s)},s)});return E("div",{className:"bcard-transition",children:[t.factory?h("span",{className:"initial-state","aria-hidden":!0,children:"●"}):r(t.from),h("span",{className:"muted",children:"→"}),r(t.to)]})}function che({agg:e,c:t,model:n,names:o,tx:r,onSelect:i}){let s=(a)=>n.elements[a]??{name:a};return E("div",{className:"bcard",children:[E("div",{className:"bcard-head",children:[h(she,{kind:"command",x:t,names:o,onClick:()=>i(t.id)}),t.factory&&h("span",{className:"factory-badge",children:r.factory})]}),(e.states?.length??0)>0&&h(eUe,{agg:e,c:t,names:o,onSelect:i}),t.params.length>0&&E("div",{className:"bcard-part",children:[h("div",{className:"bcard-caption",children:r.params}),h(lhe,{fields:t.params,ctx:e.context,names:o,onSelect:i})]}),t.emits.length+t.errors.length>0&&E("div",{className:"bcard-outcomes",children:[t.emits.length>0&&E("span",{className:"bcard-outcome",children:[h("span",{className:"muted",title:r.raisesHint,children:"⇒"}),t.emits.map((a)=>h(_9,{kind:n.elements[a]?.kind??"event",id:a,x:s(a),names:o,onSelect:i},a))]}),t.errors.length>0&&E("span",{className:"bcard-outcome",children:[h("span",{className:"muted",title:r.returnsHint,children:"✕"}),t.errors.map((a)=>h(_9,{kind:n.elements[a]?.kind??"error",id:a,x:s(a),names:o,onSelect:i},a))]})]})]})}function uhe({id:e,commands:t,model:n,names:o,tx:r,onSelect:i}){let s=n.elements[e],a=s?.kind??"error";return E("div",{className:"bcard",children:[E("div",{className:"bcard-head",children:[h(she,{kind:a,x:s??{name:e},names:o,onClick:()=>i(e)}),s?.kind==="event"&&h(dT,{persistent:!!s.persistent,tx:r})]}),s?.doc&&h("div",{className:"bcard-doc",children:s.doc}),E("div",{className:"bcard-outcome",children:[h("span",{className:"bcard-caption",children:r.origin}),t.map((l)=>h(_9,{kind:"command",id:l.id,x:l,names:o,onSelect:i},l.id))]}),s&&s.fields.length>0&&E("div",{className:"bcard-part",children:[h("div",{className:"bcard-caption",children:r.payload}),h(lhe,{fields:s.fields,ctx:s.context,names:o,onSelect:i})]})]})}function dhe(e,t){let n=new Map;for(let o of e)for(let r of o[t])n.set(r,[...n.get(r)??[],o]);return n}q();q();function Ao(e,t){let[n,o]=G(()=>{try{let i=localStorage.getItem(e);return i===null?t:JSON.parse(i)}catch{return t}}),r=O((i)=>{o(i);try{localStorage.setItem(e,JSON.stringify(i))}catch{}},[e]);return[n,r]}function fhe(e,t,n){F(()=>{if(!e)return;let o=(i)=>{if(t.current&&!t.current.contains(i.target))n()},r=(i)=>{if(i.key==="Escape")n()};return document.addEventListener("mousedown",o),document.addEventListener("keydown",r),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",r)}},[e,t,n])}function tUe(e,t,n,o){if(e<n/2)return{open:!1,size:t};return{open:!0,size:Math.round(Math.min(o,Math.max(n,e)))}}function yA(e){let t=(n)=>{n.preventDefault();let o=e.direction==="x"?n.clientX:n.clientY,r=e.size,i=e.open?r:e.collapsed,s=Math.max(e.min,typeof e.max==="function"?e.max():e.max),a=e.open,l=r,c=n.currentTarget;c.setPointerCapture(n.pointerId),document.documentElement.classList.add("resizing");let u=(d)=>{let p=(e.direction==="x"?d.clientX:d.clientY)-o,m=tUe(i+(e.invert?-p:p),r,e.min,s);if(m.size!==l)e.onResize(l=m.size);if(m.open!==a)e.onOpenChange(a=m.open)},f=()=>{document.documentElement.classList.remove("resizing"),c.removeEventListener("pointermove",u),c.removeEventListener("pointerup",f),c.removeEventListener("pointercancel",f)};c.addEventListener("pointermove",u),c.addEventListener("pointerup",f),c.addEventListener("pointercancel",f)};return h("div",{className:`resizer resizer-${e.direction}`,onPointerDown:t,role:"separator","aria-orientation":e.direction==="x"?"vertical":"horizontal"})}function SA(e){let{contexts:t,labels:n,selected:o,hidden:r=[],mode:i,onChange:s,onHiddenChange:a}=e,l=Kt(),[c,u]=G(!1),f=L(null);fhe(c,f,O(()=>u(!1),[]));let d=(P)=>xd(i,P,n[P]),p=o.length===t.length,m=(p?l.allContexts:o.length===0?l.none:o.length<=2?o.map(d).join(l.listSeparator):l.moreContexts(d(o[0]),o.length-1))+(r.length?l.hiddenContexts(r.length):""),g=(P)=>s(o.includes(P)?o.filter((k)=>k!==P):t.filter((k)=>k===P||o.includes(k))),y=(P)=>a?.(r.includes(P)?r.filter((k)=>k!==P):t.filter((k)=>k===P||r.includes(k))),S=o.length===0?[]:t.filter((P)=>!o.includes(P)),b=S.length>0&&S.every((P)=>r.includes(P)),x=r.length>0&&!b,w=L(null);F(()=>{if(w.current)w.current.indeterminate=!p&&o.length>0});let v=L(null),[C,I]=G(!1);return He(()=>{let P=v.current;if(!P)return;let k=()=>I(P.scrollWidth>P.clientWidth);k();let _=new ResizeObserver(k);return _.observe(P),()=>_.disconnect()},[m]),E("div",{className:"context-picker",ref:f,children:[E("button",{className:"context-picker-button","aria-haspopup":"listbox","aria-expanded":c,"aria-label":l.contextsToShow,"data-tooltip":C?`BC: ${m}`:void 0,onClick:()=>u(!c),children:[E("span",{ref:v,className:"context-picker-summary",children:["BC: ",m]}),h("span",{"aria-hidden":!0,children:"▾"})]}),c&&E("div",{className:"context-picker-menu",role:"listbox","aria-multiselectable":!0,children:[E("div",{className:"context-picker-row context-picker-all",children:[E("label",{className:"check",children:[h("input",{ref:w,type:"checkbox",checked:p,onChange:()=>s(p?[]:t)}),l.allContexts]}),a&&h("button",{className:"icon-button",disabled:S.length===0,"aria-label":l.allStubs,"data-tooltip":S.length===0?void 0:r.length?l.showAllStubs:l.hideAllStubs,onClick:()=>a(r.length?[]:S),children:b?h(ly,{size:14,"aria-hidden":!0}):x?h(pv,{size:14,"aria-hidden":!0}):h(ay,{size:14,"aria-hidden":!0})})]}),t.map((P)=>{let k=r.includes(P),_=o.length===0||o.includes(P);return E("div",{className:`context-picker-row${k?" context-hidden":""}`,children:[E("label",{className:"check",role:"option","aria-selected":o.includes(P),children:[h("input",{type:"checkbox",checked:o.includes(P),onChange:()=>g(P)}),d(P)]}),a&&h("button",{className:"icon-button",disabled:_,"aria-pressed":!k,"aria-label":l.contextStubs(d(P)),"data-tooltip":_?void 0:k?l.showStubs:l.hideStubs,onClick:()=>y(P),children:k?h(ly,{size:14,"aria-hidden":!0}):h(ay,{size:14,"aria-hidden":!0})})]},P)})]})]})}var nUe=(e)=>e.name;function Xb(e,t,n=nUe){let o=[],r=(i)=>i.type.kind==="ref"&&i.type.ref===t;for(let i of Object.values(e.elements)){for(let s of lA(i).filter(r))o.push({key:`${i.id}.${s.name}`,target:i.id,context:i.context,text:`${n(i)}.${n(s)}`});for(let s of i.states??[])for(let a of s.fields.filter(r))o.push({key:`${s.id}.${a.name}`,target:s.id,context:i.context,text:`${n(i)}.${n(s)}.${n(a)}`});for(let s of i.variants??[])for(let a of s.fields.filter(r))o.push({key:`${i.id}.${s.name}.${a.name}`,target:i.id,context:i.context,text:`${n(i)}.${n(s)}.${n(a)}`});for(let s of i.commands??[])for(let a of s.params.filter(r))o.push({key:`${s.id}.${a.name}`,target:s.id,context:i.context,text:`${n(i)}.${n(s)}(${n(a)})`})}return o}function phe(e){let{model:t}=e,n=Kt(),o=L(null),[r,i]=G(""),[s,a]=G([]),[l,c]=G(null),u={query:r,sections:s,contexts:l},f=nhe(u),d=the(t),p=ohe(d,u).filter((b)=>!f||b.shown>0),m=uT(t),g=vd(e.mode,t),y=new Set(t.sharedContexts),S=new Map;for(let b of e.diagnostics){if(!b.elementId)continue;let x=Al(b.elementId);if(S.get(x)!=="error")S.set(x,b.severity)}return F(()=>{if(e.selected)o.current?.querySelector(`[data-card="${CSS.escape(e.selected)}"]`)?.scrollIntoView({block:"nearest"})},[e.selected]),E("div",{className:"catalog",ref:o,children:[E("div",{className:"catalog-top",children:[E("div",{className:"catalog-filter-row",children:[E("div",{className:"explorer-filter catalog-filter",children:[h(nh,{size:14,"aria-hidden":!0}),h("input",{value:r,placeholder:n.filter,"aria-label":n.filter,onChange:(b)=>i(b.target.value),onKeyDown:(b)=>{if(b.key==="Escape")i("")}}),r&&h("button",{className:"icon-button",onClick:()=>i(""),"data-tooltip":n.clearFilter,"aria-label":n.clearFilter,children:h(Xc,{size:14,"aria-hidden":!0})})]}),h(SA,{contexts:m,labels:t.contextLabels,selected:l??m,mode:e.mode,onChange:(b)=>c(b.length===m.length?null:b)})]}),h("div",{className:"catalog-kinds",role:"group","aria-label":n.catalogKinds,children:d.map((b)=>h("button",{className:`catalog-kind kind-${b.kinds[0]}${s.length&&!s.includes(b.key)?" off":""}`,"aria-pressed":s.includes(b.key),onClick:()=>a(s.includes(b.key)?s.filter((x)=>x!==b.key):d.map((x)=>x.key).filter((x)=>x===b.key||s.includes(x))),children:n.catalogSections[b.key]},b.key))})]}),p.length===0&&h("p",{className:"muted",children:n.catalogNoMatches}),p.map((b)=>h(oUe,{section:b,hits:f?`${b.shown}/${b.count}`:void 0,...e,names:g,shared:y,severity:S},b.key))]})}function oUe(e){let{section:t,model:n,names:o}=e,r=Kt();return E("section",{className:"catalog-section",children:[E("h1",{children:[r.catalogSections[t.key],e.hits&&h("span",{className:"catalog-count",children:e.hits})]}),t.groups.length===0&&h("p",{className:"muted",children:r.catalogEmpty}),t.groups.map(({context:i,items:s})=>E("section",{className:`catalog-context${e.shared.has(i)?" catalog-shared":""}`,children:[E("h2",{children:[o.of({name:i,label:n.contextLabels[i]}),e.shared.has(i)&&h("span",{className:"shared-badge",children:r.sharedCatalog})]}),h("div",{className:"cards",children:s.map((a)=>h(rUe,{el:a,...e,shared:e.shared.has(i),severity:e.severity.get(a.id)},a.id))})]},i))]})}function rUe(e){let{el:t,model:n,names:o}=e,r=Kt(),i=e.diff.added.includes(t.id)?"added":e.diff.changed.includes(t.id)?"changed":"none",s=["card",`card-kind-${t.kind}`,`dn-change-${i}`,e.selected===t.id?"card-selected":"",e.severity?`card-${e.severity}`:""];return E("button",{className:s.filter(Boolean).join(" "),"data-card":t.id,onClick:()=>e.onSelect(t.id),title:t.doc,children:[h(iUe,{el:t,tx:r}),h(sUe,{el:t,model:n,names:o}),E("div",{className:"card-foot muted",children:[h(aUe,{el:t,model:n,names:o,shared:e.shared}),i!=="none"&&h("span",{className:`change change-${i}`,children:i==="added"?r.added:r.changed}),e.severity&&h("span",{className:`card-diag card-diag-${e.severity}`,children:e.severity==="error"?"✕":"!"})]})]})}function iUe({el:e,tx:t}){return E("div",{className:"card-head",children:[E("span",{className:"card-tags",children:[h("span",{className:`kind kind-${e.kind} tiny`,children:t.kinds[e.kind]}),e.kind==="event"&&h(dT,{persistent:!!e.persistent,tx:t})]}),h("span",{className:"card-name",title:e.label??e.name,children:e.label??e.name}),e.label&&h("span",{className:"card-subname",title:e.name,children:e.name})]})}function sUe({el:e,model:t,names:n}){let o=Kt();switch(e.kind){case"primitive":case"id":case"enum":return E(Y,{children:[e.base&&h("div",{className:"card-base",children:n.primitive(e.base)}),e.values&&h("div",{className:"chips",children:e.values.map((r)=>h("code",{children:n.of({name:r,label:e.valueLabels?.[r]})},r))}),h(bA,{invariants:e.invariants,names:n})]});case"union":return E(Y,{children:[e.discriminator&&h("div",{className:"card-base",children:e.discriminator}),h(fT,{fields:e.fields,ctx:e.context,names:n}),h("div",{className:"chips",children:(e.variants??[]).map((r)=>h("code",{children:n.of(r)},r.name))}),h(bA,{invariants:e.invariants,names:n})]});case"aggregate":return E(Y,{children:[h(fT,{fields:e.fields,ctx:e.context,names:n}),(e.states?.length??0)>0&&h("div",{className:"chips",children:e.states.map((r)=>h("code",{children:n.of(r)},r.id))}),(e.commands?.length??0)>0&&h("ul",{className:"card-commands",children:e.commands.map((r)=>E("li",{children:[n.of(r),h("span",{className:"muted",children:n.transition(e,r)})]},r.id))}),h(bA,{invariants:e.invariants,names:n})]});case"event":return e.fields.length?h(fT,{fields:e.fields,ctx:e.context,names:n}):h("span",{className:"muted",children:o.noFields});case"error":return E(Y,{children:[e.doc&&h("p",{className:"card-doc",children:e.doc}),h(fT,{fields:e.fields,ctx:e.context,names:n})]});default:return E(Y,{children:[h(fT,{fields:e.fields,ctx:e.context,names:n}),h(bA,{invariants:e.invariants,names:n})]})}}function aUe({el:e,model:t,names:n,shared:o}){let r=Kt();if(e.kind==="event"||e.kind==="error"){let l=rhe(t,e.id);if(!l.length)return h(Y,{children:e.kind==="event"?r.raisedByNone:r.returnedByNone});return E(Y,{children:["← ",l.map(({agg:c,command:u})=>`${n.of(c)}.${n.of(u)}`).join(", ")]})}if(e.kind==="fieldSet"){let l=gA(t,e.id);return h(Y,{children:l.length?`← ${l.map((c)=>n.of(c)).join(", ")}`:r.usedIn(0)})}let i=e.kind==="aggregate"?e.fields.find((l)=>l.name==="id"&&l.type.kind==="ref")?.type:void 0,s=i?.kind==="ref"?Xb(t,i.ref).filter((l)=>l.target!==e.id):Xb(t,e.id),a=[...new Set(s.map((l)=>l.context))].filter((l)=>l!==e.context);return E(Y,{children:[r.usedIn(s.length),o&&a.length>0&&E(Y,{children:[" · ",a.map((l)=>n.of({name:l,label:t.contextLabels[l]})).join(", ")]})]})}function fT({fields:e,ctx:t,names:n}){if(!e.length)return null;return h("ul",{className:"card-fields",children:e.map((o)=>E("li",{children:[h("span",{children:n.field(o)}),E("code",{children:[o.kind==="references"?"→ ":"",n.type(o.type,t),o.multiplicity,o.fieldSet&&h("span",{className:"field-origin",children:n.short(o.fieldSet)})]})]},o.name))})}function bA({invariants:e,names:t}){if(!e.length)return null;return h("ul",{className:"card-invariants",children:e.map((n)=>E("li",{children:[E("span",{children:["✓ ",t.of(n)]}),h("code",{children:n.source})]},n.name))})}q();var lUe=0.9;function hhe(e,t=1){let n=lUe/t;if(e.zoomToFit(),e.getZoomLevel()>=n)return;let o=e.getCurrentPageBounds();if(!o)return;let r=e.getViewportScreenBounds(),i=24;e.setCamera({...e.getCamera(),z:n}),e.centerOnPoint({x:Math.min(o.center.x,o.x+r.w/n/2-i),y:Math.min(o.center.y,o.y+r.h/n/2-i)})}function cUe(e){let t=[...Object.values(e.nodeLayout),...Object.values(e.edgeLayout).flatMap((n)=>[...n.label?[n.label]:[],...n.points.map((o)=>({...o,width:0,height:0}))])];return t.length?Z.Common(t.map((n)=>new Z(n.x,n.y,n.width,n.height))):void 0}function M9(e,t,n=!1){let o=cUe(t);if(o)e.zoomToBounds(o,{targetZoom:1,inset:16,animation:n?{duration:200}:void 0})}function pT(e,t){let n=Zpe(e,t);if(!n){e.selectNone();return}e.select(n);let o=e.getShapePageBounds(n);if(o&&!e.getViewportPageBounds().contains(o))e.centerOnPoint(o.center,{animation:{duration:200}})}function xA(e){F(()=>{if(!e)return;return zt("pointer cursor",()=>{let t=e.getHoveredShapeId(),n=t?e.getShape(t):void 0,o=!!n&&!n.meta.ghost,r=e.getInstanceState().cursor.type;if(o&&r==="default")e.setCursor({type:"pointer",rotation:0});else if(!o&&r==="pointer")e.setCursor({type:"default",rotation:0})})},[e])}q();function mhe(e){let t={kind:"dir",name:"",path:"",children:[]};for(let n of e){let o=n.split("/"),r=t;for(let i of o.slice(0,-1)){let s=r.path?`${r.path}/${i}`:i,a=r.children.find((l)=>l.kind==="dir"&&l.name===i);if(!a)r.children.push(a={kind:"dir",name:i,path:s,children:[]});r=a}r.children.push({kind:"file",name:o[o.length-1],path:n})}return t.children.map(ghe).sort(yhe)}function ghe(e){if(e.kind==="file")return e;let t=e;while(t.children.length===1&&t.children[0].kind==="dir"){let n=t.children[0];t={...n,name:`${t.name}/${n.name}`}}return{...t,children:t.children.map(ghe).sort(yhe)}}var yhe=(e,t)=>Number(t.kind==="dir")-Number(e.kind==="dir")||e.name.localeCompare(t.name);function L9(e){return e.kind==="file"?[e.path]:e.children.flatMap(L9)}function bhe(e){let t=Kt(),[n,o]=Ao("domaintrail.explorer.collapsed",[]),[r,i]=Ao("domaintrail.explorer.expanded",[]),[s,a]=Ao("domaintrail.explorer.sections",{model:!0,files:!0}),[l,c]=G(""),[u,f]=G(!1),[d,p]=G(!1),m=l.trim().toLowerCase(),g=m!==""||u||d,y=(R,W)=>g||(W?!n.includes(R):r.includes(R)),S=(R,W)=>{if(g)return;if(W)o(n.includes(R)?n.filter((te)=>te!==R):[...n,R]);else i(r.includes(R)?r.filter((te)=>te!==R):[...r,R])},b=e.model,x=new Map,w=(R,W)=>x.set(R,{...x.get(R),...W});for(let R of e.diagnostics){if(!R.elementId)continue;for(let W of new Set([R.elementId,Al(R.elementId)]))if(x.get(W)?.severity!=="error")w(W,{severity:R.severity})}for(let R of e.diff.added)w(R,{change:"added"});for(let R of e.diff.changed)w(R,{change:"changed"});let v=new Set;for(let R of[...e.diff.added,...e.diff.changed]){let W=b?.elements[Al(R)]?.location.file;if(W)v.add(W)}let C=(R)=>{let W=e.diagnostics.filter((te)=>R.includes(te.file));return{errors:W.filter((te)=>te.severity==="error").length,warnings:W.filter((te)=>te.severity==="warning").length}},I=(...R)=>m===""||R.some((W)=>W?.toLowerCase().includes(m)),P=(R)=>(!u||!!R?.severity)&&(!d||!!R?.change),k=L(null);F(()=>{k.current?.scrollIntoView({block:"nearest"})},[e.selected]);let _=(R,W,te,ue,Ce)=>{let ge=x.get(R),ne=e.selected===R;return E("div",{ref:ne&&te.visible?k:void 0,className:`tree-item${ne?" selected":""}`,style:{paddingLeft:8+te.depth*14},onClick:()=>e.onSelect(R),onDoubleClick:()=>e.onOpen(R),title:R,"aria-expanded":te.onToggle?te.open:void 0,children:[h(A9,{row:te}),h("span",{className:`tree-dot dot-${ue}`}),h("span",{className:"tree-text",children:W}),Ce,ge?.change&&h("span",{className:`tree-change tree-change-${ge.change}`,title:ge.change==="added"?t.added:t.changed}),ge?.severity&&h("span",{className:`tree-diag tree-diag-${ge.severity}`,children:ge.severity==="error"?"✕":"!"})]})},M=(R,W,te="tree-group")=>E("div",{className:te,style:{paddingLeft:8+W.depth*14},onClick:W.onToggle,"aria-expanded":W.open,children:[h(A9,{row:W}),R]}),N=(R)=>E(Y,{children:[R.errors>0&&h("span",{className:"count count-error",children:R.errors}),R.warnings>0&&h("span",{className:"count count-warning",children:R.warnings})]}),V=0,D=0,K=b&&uT(b).map((R)=>A(b,R)).filter(Boolean),U=mhe(e.files).map((R)=>j(R,0,!0)).filter(Boolean);return E("div",{className:"explorer",children:[E("div",{className:"explorer-head",children:[E("div",{className:"explorer-filter",children:[h(nh,{size:14,"aria-hidden":!0}),h("input",{value:l,placeholder:t.filter,"aria-label":t.filter,onChange:(R)=>c(R.target.value),onKeyDown:(R)=>{if(R.key==="Escape")c("")}}),l&&h("button",{className:"icon-button",onClick:()=>c(""),"data-tooltip":t.clearFilter,"aria-label":t.clearFilter,children:h(Xc,{size:14,"aria-hidden":!0})})]}),h("button",{className:"icon-button","aria-pressed":u,onClick:()=>f(!u),"data-tooltip":t.onlyProblems,"aria-label":t.onlyProblems,children:h(rf,{size:15,"aria-hidden":!0})}),h("button",{className:"icon-button","aria-pressed":d,onClick:()=>p(!d),"data-tooltip":t.onlyChanged,"aria-label":t.onlyChanged,children:h(fv,{size:15,"aria-hidden":!0})}),h("button",{className:"icon-button",onClick:e.onClose,"data-tooltip":t.closeExplorer,"aria-label":t.closeExplorer,children:h(nf,{size:16,"aria-hidden":!0})})]}),E("div",{className:"explorer-body",children:[h(She,{title:t.model,hits:g?V:void 0,open:s.model,onToggle:()=>a({...s,model:!s.model}),children:E("div",{className:"tree",children:[!b&&h("p",{className:"muted small pad",children:t.noModel}),b&&g&&!K?.length&&h("p",{className:"muted small pad",children:t.noMatches}),K]})}),h(She,{title:t.files,hits:g?D:void 0,open:s.files,onToggle:()=>a({...s,files:!s.files}),children:E("div",{className:"tree",children:[g&&!U.length&&h("p",{className:"muted small pad",children:t.noMatches}),U]})})]})]});function A(R,W){let te=R.contextLabels[W],ue=I(W,te),Ce=Object.values(R.elements).filter((Me)=>Me.context===W),ge=pA.map((Me)=>({kind:Me,nodes:Ce.filter((Fe)=>Fe.kind===Me).sort((Fe,tt)=>Fe.name.localeCompare(tt.name)).map((Fe)=>z(Fe,ue)).filter((Fe)=>Fe!==null)})).filter((Me)=>Me.nodes.length),ne=ue&&P(x.get(W));if(!ge.length&&!ne)return null;if(ne)V++;let Ee=R.sharedContexts.includes(W),Re=y(`ctx:${W}`,!0);return E("div",{children:[_(W,`${xd(e.mode,W,te)}${Ee?` · ${t.sharedTag}`:""}`,{depth:0,visible:!0,open:Re,onToggle:()=>S(`ctx:${W}`,!0)},Ee?"shared":"context"),h(hT,{open:Re,children:ge.map(({kind:Me,nodes:Fe})=>{let tt=`grp:${W}:${Me}`,mn=y(tt,!0);return E("div",{children:[M(E(Y,{children:[t.kinds[Me],E("span",{className:"muted",children:[" ",Fe.length]})]}),{depth:1,visible:Re,open:mn,onToggle:()=>S(tt,!0)}),h(hT,{open:mn,children:Fe.map((oe)=>oe(Re&&mn))})]},Me)})})]},W)}function z(R,W){let te=W||I(R.name,R.label),ue=(Fe)=>(te||I(Fe.name,Fe.label))&&P(x.get(Fe.id)),Ce=(R.states??[]).filter(ue),ge=(R.commands??[]).filter(ue),ne=te&&P(x.get(R.id));if(!Ce.length&&!ge.length&&!ne)return null;V+=Ce.length+ge.length+(ne?1:0);let Ee=!!(R.states?.length||R.commands?.length),Re=`agg:${R.id}`,Me=y(Re,!1);return(Fe)=>E("div",{children:[_(R.id,xd(e.mode,R.name,R.label),{depth:2,visible:Fe,...Ee&&{open:Me,onToggle:()=>S(Re,!1)}},R.kind,R.persistent&&h("span",{className:"tree-persistent",title:t.persistentHint,children:h(dv,{size:11})})),Ee&&E(hT,{open:Me,children:[Ce.map((tt)=>h("div",{children:_(tt.id,`◇ ${xd(e.mode,tt.name,tt.label)}`,{depth:3,visible:Fe&&Me},"state")},tt.id)),ge.map((tt)=>h("div",{children:_(tt.id,`${tt.factory?"+":"▶"} ${xd(e.mode,tt.name,tt.label)}`,{depth:3,visible:Fe&&Me},"command")},tt.id))]})]},R.id)}function j(R,W,te){if(R.kind==="file"){let Ee=C([R.path]),Re={severity:Ee.errors?"error":Ee.warnings?"warning":void 0,change:v.has(R.path)?"changed":void 0};if(!(I(R.path)&&P(Re)))return null;D++;let Me=hA(R.path),Fe=e.selected===Me;return E("div",{ref:Fe&&te?k:void 0,className:`tree-item${Fe?" selected":""}`,style:{paddingLeft:8+W*14},onClick:()=>e.onSelect(Me),title:R.path,children:[h(A9,{row:{depth:W,visible:te}}),h("span",{className:"tree-text",children:R.name}),Re.change&&h("span",{className:"tree-change tree-change-changed",title:t.changed}),N(Ee)]},R.path)}let ue=`dir:${R.path}`,Ce=y(ue,!0),ge=R.children.map((Ee)=>j(Ee,W+1,te&&Ce)).filter(Boolean);if(!ge.length)return null;return E("div",{children:[M(E(Y,{children:[h(Ce?hv:mv,{size:14,className:"tree-folder","aria-hidden":!0}),h("span",{className:"tree-text",title:R.path,children:R.name}),N(C(L9(R)))]}),{depth:W,visible:te,open:Ce,onToggle:()=>S(ue,!0)},"tree-item tree-dir"),h(hT,{open:Ce,children:ge})]},ue)}}function A9({row:e}){if(!e.onToggle)return h("span",{className:"tree-twisty"});let t=e.onToggle;return h("span",{className:`tree-twisty${e.open?" open":""}`,onClick:(n)=>{n.stopPropagation(),t()},children:h(sy,{size:14,"aria-hidden":!0})})}function She({title:e,hits:t,open:n,onToggle:o,children:r}){return E("section",{className:"explorer-section",children:[E("button",{type:"button",className:"pane-title explorer-section-title",onClick:o,"aria-expanded":n,children:[h("span",{className:`tree-twisty${n?" open":""}`,children:h(sy,{size:14,"aria-hidden":!0})}),e,t!==void 0&&h("span",{className:"explorer-section-hits",children:t})]}),h(hT,{open:n,children:r})]})}function hT({open:e,children:t}){return h("div",{className:`tree-children${e?" open":""}`,inert:!e,children:h("div",{className:"tree-children-inner",children:t})})}function vA({view:e,open:t,onToggle:n}){let o=Kt(),r=o.legendRows,i=e==="contextMap"?[{kind:"references",text:r.mapReferences},{kind:"dependsOn",text:r.mapDependsOn}]:e==="structureFocus"?[{kind:"owns",text:r.owns},{kind:"references",text:r.focusReferences},{kind:"value",text:r.focusValue}]:e==="aggregates"||e==="aggregatesFocus"?[{kind:"references",text:r.aggregateReferences},{kind:"value",text:r.aggregateValue}]:e==="structure"?[{kind:"owns",text:r.owns},{kind:"references",text:r.references},{kind:"value",text:r.value}]:[{kind:"transition",text:r.transition}];return E(Y,{children:[E("div",{className:`legend${t?"":" legend-closed"}`,inert:!t,children:[E("div",{className:"legend-title",children:[o.legend,h("button",{className:"icon-button",onClick:n,"data-tooltip":o.closeLegend,"aria-label":o.closeLegend,children:h(lv,{size:14,"aria-hidden":!0})})]}),i.map((s)=>E("div",{className:"legend-row",children:[E("svg",{width:"56",height:"14",className:`de de-${s.kind}`,"aria-hidden":!0,children:[h("path",{d:"M4,7 L42,7",className:"de-line"}),s.kind==="owns"&&h("path",{d:"M2,7 L9,3.5 L16,7 L9,10.5 Z",className:"de-head de-diamond"}),h("path",{d:"M54,7 L41,0.5 L41,13.5 Z",className:"de-head"})]}),h("span",{children:s.text})]},s.kind)),e==="structureFocus"&&h("div",{className:"legend-note",children:o.stubNote}),e==="aggregatesFocus"&&h("div",{className:"legend-note",children:o.aggregateStubNote}),e==="states"&&h("div",{className:"legend-note",children:o.internalNote}),h("div",{className:"legend-note",children:o.arrowNote})]}),h("button",{className:`legend-tab${t?"":" shown"}`,inert:t,onClick:n,"data-tooltip":o.openLegend,"aria-label":o.openLegend,children:h(cv,{size:14,"aria-hidden":!0})})]})}var xhe=(e,t)=>e[e.length-1]===t?e:[...e,t];function R9(e,t){for(let n=e.length-2;n>=0;n--)if(t(e[n]))return n;return-1}function vhe(e,t){let n=R9(e,t);return n<0?e:e.slice(0,n+1)}q();function whe(e,t){let n=(o,r)=>r?[`${o} ${r}`]:[];return rA({ja:[...n("ID",e),...n("型",t)].join(" · "),en:[...n("ID",e),...n("type",t)].join(" · ")})}q();var uUe=new Set(["shared","context","terms","id","primitive","enum","value","union","by","entity","aggregate","state","owns","references","create","command","from","to","emits","errors","persistent","event","error","invariant","fields","with","and","or","not","implies","in","count","exists","all","any","length","matches","true","false"]),dUe=new Set(["String","Int","Decimal","Bool","Timestamp","UUID"]),fUe=/(\/\*[\s\S]*?\*\/)|(\/\/\/[^\n]*)|(\/\/[^\n]*)|("(?:\\.|[^"\\\n])*"?)|(\b\d+(?:\.\d+)?\b)|([A-Za-z_]\w*)|(\s+|[^\sA-Za-z_\d"/]+|\/)/g;function Che(e){let t=[[]],n=(o,r)=>{r.split(`
|
|
552
|
+
`).map((N,V)=>h("div",{dir:"auto",children:N},V))}),(C||f)&&h(h9,{ref:x,text:o,isEditing:v,shapeId:t,...I,handleKeyDown:p??I.handleKeyDown})]})})});q();q();q();var nT={fonts:{tldraw_mono:`${bo()}/fonts/IBMPlexMono-Medium.woff2`,tldraw_mono_italic:`${bo()}/fonts/IBMPlexMono-MediumItalic.woff2`,tldraw_mono_bold:`${bo()}/fonts/IBMPlexMono-Bold.woff2`,tldraw_mono_italic_bold:`${bo()}/fonts/IBMPlexMono-BoldItalic.woff2`,tldraw_serif:`${bo()}/fonts/IBMPlexSerif-Medium.woff2`,tldraw_serif_italic:`${bo()}/fonts/IBMPlexSerif-MediumItalic.woff2`,tldraw_serif_bold:`${bo()}/fonts/IBMPlexSerif-Bold.woff2`,tldraw_serif_italic_bold:`${bo()}/fonts/IBMPlexSerif-BoldItalic.woff2`,tldraw_sans:`${bo()}/fonts/IBMPlexSans-Medium.woff2`,tldraw_sans_italic:`${bo()}/fonts/IBMPlexSans-MediumItalic.woff2`,tldraw_sans_bold:`${bo()}/fonts/IBMPlexSans-Bold.woff2`,tldraw_sans_italic_bold:`${bo()}/fonts/IBMPlexSans-BoldItalic.woff2`,tldraw_draw:`${bo()}/fonts/Shantell_Sans-Informal_Regular.woff2`,tldraw_draw_italic:`${bo()}/fonts/Shantell_Sans-Informal_Regular_Italic.woff2`,tldraw_draw_bold:`${bo()}/fonts/Shantell_Sans-Informal_Bold.woff2`,tldraw_draw_italic_bold:`${bo()}/fonts/Shantell_Sans-Informal_Bold_Italic.woff2`}};function eA(e){return le(()=>{if(!e)return nT;return{fonts:{...nT.fonts,...e?.fonts}}},[e])}var m9=["align-bottom","align-center-horizontal","align-center-vertical","align-left","align-right","align-top","alt","arrow-arc","arrow-cycle","arrow-elbow","arrow-left","arrowhead-arrow","arrowhead-bar","arrowhead-diamond","arrowhead-dot","arrowhead-none","arrowhead-square","arrowhead-triangle-inverted","arrowhead-triangle","blob","bold","bookmark","bring-forward","bring-to-front","broken","bulletList","check-circle","check","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-ne","chevrons-sw","clipboard-copied","clipboard-copy","closed","code","color","comment","corners","crop","cross-2","cross-circle","dash-dashed","dash-dotted","dash-draw","dash-solid","disconnected","discord","distribute-horizontal","distribute-vertical","dot","dots-horizontal","dots-vertical","download","drag-handle-dots","duplicate","edit","external-link","fill-fill","fill-lined-fill","fill-none","fill-pattern","fill-semi","fill-solid","follow","following","font-draw","font-mono","font-sans","font-serif","geo-arrow-down","geo-arrow-left","geo-arrow-right","geo-arrow-up","geo-check-box","geo-cloud","geo-diamond","geo-ellipse","geo-heart","geo-hexagon","geo-octagon","geo-oval","geo-pentagon","geo-rectangle","geo-rhombus-2","geo-rhombus","geo-star","geo-trapezoid","geo-triangle","geo-x-box","github","group","heading","help-circle","highlight","horizontal-align-end","horizontal-align-middle","horizontal-align-start","info-circle","italic","leading","link","list","lock","manual","menu","minus","mixed","pack","plus","question-mark-circle","question-mark","redo","reset-zoom","rotate-ccw","rotate-cw","send-backward","send-to-back","share-1","size-extra-large","size-large","size-medium","size-small","spline-cubic","spline-line","stack-horizontal","stack-vertical","status-offline","stretch-horizontal","stretch-vertical","strike","text-align-center","text-align-left","text-align-right","toggle-off","toggle-on","tool-arrow","tool-eraser","tool-frame","tool-hand","tool-highlight","tool-laser","tool-line","tool-media","tool-note","tool-pencil","tool-pointer","tool-screenshot","tool-text","trash","twitter","underline","undo","ungroup","unlock","vertical-align-end","vertical-align-middle","vertical-align-start","warning-triangle","zoom-in","zoom-out"];var oT={...nT,icons:Object.fromEntries(m9.map((e)=>[e,`${bo()}/icons/icon/0_merged.svg#${e}`])),translations:Object.fromEntries(nc.map((e)=>[e.locale,`${bo()}/translations/${e.locale}.json`])),embedIcons:Object.fromEntries(Sb.map((e)=>[e.type,`${bo()}/embed-icons/${e.type}.png`]))};function tA(e){return le(()=>{if(!e)return oT;return{fonts:Object.assign({...oT.fonts},{...e?.fonts}),icons:Object.assign({...oT.icons},{...e?.icons}),embedIcons:Object.assign({...oT.embedIcons},{...e?.embedIcons}),translations:Object.assign({...oT.translations},{...e?.translations})}},[e])}function Rpe(){let{Spinner:e}=kn();return h(SB,{children:e?h(e,{}):null})}q();var Ope=wt(Jt(),1);var g9=Wt(function({overrides:t,components:n,assetUrls:o,onUiEvent:r,forceMobile:i,mediaMimeTypes:s,children:a}){let l=yt();return h(s6.Provider,{value:s,children:h(aC,{assetUrls:tA(o),children:h(cC,{overrides:u2(t),locale:l?.user.getLocale()??hr.locale,children:h(AU,{children:h(BU,{onEvent:r,children:h(ZU,{children:h(YU,{context:"tla",children:h(W4,{children:h(OU,{forceMobile:i,children:h(AH,{overrides:n,children:h(I5e,{overrides:t,children:a})})})})})})})})})})})});function I5e({overrides:e,children:t}){let n=Jce(e);return h(ife,{overrides:n.actions,children:h(eue,{overrides:n.tools,children:t})})}q();function Dpe(){let e=B(),{addToast:t}=Jr();F(()=>{function n({name:o,count:r}){t({title:"Maximum shapes reached",description:`You've reached the maximum number of shapes allowed on ${o} (${r}). Please delete some shapes or move to a different page to continue.`,severity:"warning"})}return e.addListener("max-shapes",n),()=>{e.removeListener("max-shapes",n)}},[e,t])}var y9=xe(function({renderDebugMenuItems:t,children:n,hideUi:o,components:r,...i}){return h(g9,{...i,components:r,children:h(P5e,{hideUi:o,renderDebugMenuItems:t,children:n})})}),P5e=xe(function({children:t,hideUi:n}){return TH(),n6(),E(Y,{children:[t,n?null:h(k5e,{})]})}),k5e=xe(function(){let t=B(),n=ie(),o=jt(),r=Go(),i=H("focus",()=>t.getInstanceState().isFocusMode,[t]),s=H("debug",()=>t.getInstanceState().isDebugMode,[t]),a=xt(),l=mt(),c=H("locale",()=>t.user.getLocale(),[t]);F(()=>{a.dir=l,a.lang=c},[a,l,c]);let{SharePanel:u,TopPanel:f,MenuPanel:d,StylePanel:p,Toolbar:m,HelpMenu:g,NavigationPanel:y,HelperButtons:S,DebugPanel:b,Toasts:x,Dialogs:w,A11y:v,FollowingIndicator:C}=Fn();Dpe();let I=L(!1),P=L(-1),[k,_]=G(!1);su("update hide toolbar while delayed",()=>{if(!(Xe.isIos||Xe.isAndroid))return;if(t.getEditingShapeId()===null){if(I.current)if(I.current=!1,clearTimeout(P.current),Xe.isAndroid)P.current=t.timers.setTimeout(()=>{_(!1)},150);else _(!1);return}if(!I.current)I.current=!0,clearTimeout(P.current),_(!0)},[]);let{"toggle-focus-mode":M}=oo(),{breakpointsAbove:N,breakpointsBelow:V}=le(()=>{let D=xb.map((K,U)=>U);return{breakpointsAbove:D.slice(0,o+1).join(" "),breakpointsBelow:D.slice(o+1).join(" ")}},[o]);return E("div",{className:Ope.default("tlui-layout",{"tlui-layout__mobile":o<vt.TABLET_SM}),role:"document","data-iseditinganything":k,"data-breakpoint":o,"data-breakpoints-above":N,"data-breakpoints-below":V,children:[h(afe,{}),i?h("div",{className:"tlui-layout__top",children:h(Ve,{type:"icon",className:"tlui-focus-button",title:n("focus-mode.toggle-focus-mode"),onClick:()=>M.onSelect("menu"),children:h(ve,{icon:"dot"})})}):E(Y,{children:[E("div",{className:"tlui-layout__top",children:[E("div",{className:"tlui-layout__top__left",children:[d&&h(d,{}),S&&h(S,{})]}),h("div",{className:"tlui-layout__top__center",children:f&&h(f,{})}),E("div",{className:"tlui-layout__top__right",children:[u&&h(u,{}),p&&o>=vt.TABLET_SM&&!r&&h(p,{})]})]}),E("div",{className:"tlui-layout__bottom",children:[E("div",{className:"tlui-layout__bottom__main",children:[y&&h(y,{}),m&&h(m,{}),g&&h(g,{})]}),s&&b&&h(b,{}),v&&h(v,{})]})]}),C&&h(C,{}),x&&h(x,{}),w&&h(w,{})]})});function nA(){let{RichTextToolbar:e,ImageToolbar:t,VideoToolbar:n,CursorChatBubble:o}=Fn();return E(Y,{children:[e&&h(e,{}),t&&h(t,{}),n&&h(n,{}),o&&h(o,{})]})}var E5e=[...p9,...l8];function _5e(e,t){let{maxImageDimension:n,acceptedImageMimeTypes:o,acceptedVideoMimeTypes:r}=t,i=n!==void 0||o!==void 0,s=r!==void 0;if(!i&&!s)return e;return e.map((a)=>{if(i&&a.type==="image")return a.configure({...n!==void 0&&{maxDimension:n},...o!==void 0&&{supportedMimeTypes:o}});if(s&&a.type==="video")return a.configure({...r!==void 0&&{supportedMimeTypes:r}});return a})}function rT(e){let{children:t,maxImageDimension:n,maxAssetSize:o,acceptedImageMimeTypes:r,acceptedVideoMimeTypes:i,onMount:s,components:a={},shapeUtils:l=[],bindingUtils:c=[],assetUtils:u=[],overlayUtils:f=[],tools:d=[],embeds:p,options:m,locale:g,textOptions:y,...S}=e,b=Xs(a),x=a?.InFrontOfTheCanvas,w=le(()=>{if(S.hideUi)return x??null;if(!x)return nA;return()=>E(Y,{children:[h(nA,{}),h(x,{})]})},[S.hideUi,x]),v=le(()=>({Spinner:o1,LoadingScreen:Rpe,...b,InFrontOfTheCanvas:w}),[b,w]),C=Ii(l),I=le(()=>Yl("type",C,Q1),[C]),P=Ii(c),k=le(()=>Yl("type",P,F1),[P]),_=Ii(u),M=le(()=>_5e(Yl("type",_,KH),{maxImageDimension:n,acceptedImageMimeTypes:r,acceptedVideoMimeTypes:i}),[_,n,r,i]),N=Ii(f),V=le(()=>Yl("type",N,WH),[N]),D=Ii(d),K=le(()=>Yl("id",D,E5e),[D]),U=Ii(r??hh),A=Ii(i??by),z=m?.text??y,j=le(()=>({addFontsFromNode:PC,...z,tipTapConfig:{extensions:tp,...z?.tipTapConfig}}),[z]),R=le(()=>({...m,text:j}),[m,j]),W=le(()=>[...U,...A],[U,A]),te=eA(S.assetUrls);if(I.find((Ce)=>Ce.type==="embed")&&p)wp.setEmbedDefinitions(p);return h(aC,{assetUrls:tA(S.assetUrls),children:h(cC,{overrides:u2(S.overrides),locale:g??S.user?.userPreferences.get().locale??hr.locale,children:h(yB,{initialState:"select",...S,components:v,shapeUtils:I,bindingUtils:k,assetUtils:M,overlayUtils:V,tools:K,options:R,assetUrls:te,children:E(y9,{...S,components:v,mediaMimeTypes:W,children:[h(M5e,{maxImageDimension:n,maxAssetSize:o,acceptedImageMimeTypes:U,acceptedVideoMimeTypes:A,onMount:s}),t]})})})})}function M5e({maxImageDimension:e,maxAssetSize:t,acceptedImageMimeTypes:n,acceptedVideoMimeTypes:o,onMount:r}){let i=B(),s=Jr(),a=ie(),l=ht();fE(()=>{let f=[];f.push(B8(i)),i.fonts.requestFonts(Nz);let d=i.getThemes();for(let p of Object.values(d))for(let m of Object.keys(p.fonts)){let g=p.fonts[m];if(g.faces?.length)i.fonts.requestFonts(g.faces)}return i.once("edit",()=>l("edit",{source:"unknown"})),$z(i,{maxImageDimension:e,maxAssetSize:t,acceptedImageMimeTypes:n,acceptedVideoMimeTypes:o,toasts:s,msg:a}),f.push(i.store.props.onMount(i)),f.push(r?.(i)),()=>{f.forEach((p)=>p?.())}});let{Canvas:c}=kn(),{ContextMenu:u}=Fn();if(u)return h(u,{});if(c)return h(c,{});return null}q();var Npe={text:{tipTapConfig:{extensions:tp},addFontsFromNode:PC}},L5e=xe(function(t){let[n,o]=G(null),[r,i]=G(null),s=Ii(t.shapeUtils??[]),a=le(()=>Yl("type",s,Q1),[s]),l=Ii(t.bindingUtils??[]),c=le(()=>Yl("type",l,F1),[l]),u=pB({snapshot:t.snapshot,shapeUtils:a,assets:t.assets}),{pageId:f,bounds:d,scale:p,pixelRatio:m,background:g,padding:y,darkMode:S,preserveAspectRatio:b,format:x="svg",licenseKey:w,assetUrls:v,options:C,textOptions:I}=t,P=le(()=>({...Npe,...C,text:{...Npe.text,...C?.text??I}}),[C,I]),k=eA(v);return He(()=>{if(!r)return;if(!u)return;let _=!1,M=r.ownerDocument.createElement("div");r.appendChild(M),r.classList.add("tl-container","tl-theme__light");let N=new ye({store:u,shapeUtils:a,bindingUtils:c,tools:[],getContainer:()=>M,licenseKey:w,fontAssetUrls:k.fonts,options:P});if(f)N.setCurrentPage(f);let V=N.getCurrentPageShapeIds();async function D(){let K=await N.toImage([...V],{bounds:d,scale:p,background:g,padding:y,darkMode:S,preserveAspectRatio:b,format:x});if(!K||_)return;let U=URL.createObjectURL(K.blob);o(U),N.dispose()}return D(),()=>{_=!0}},[x,r,u,a,c,f,d,p,g,y,S,b,w,m,k,P]),F(()=>()=>{if(n)URL.revokeObjectURL(n)},[n]),h("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:n&&h("img",{src:n,referrerPolicy:"strict-origin-when-cross-origin",style:{width:"100%",height:"100%"}})})});q();var A5e=xe(function({children:t}){let n=ie(),o=jt(),r=L(null);mr(r);let i=t??h($6,{});if(o<vt.MOBILE)return null;return h("div",{ref:r,className:"tlui-help-menu",children:E(nd,{id:"help menu",children:[h(od,{children:h(Ve,{type:"help",title:n("help-menu.title"),"data-testid":"help-menu.button",children:h(ve,{icon:"question-mark",small:!0})})}),h(rd,{side:"top",align:"end",alignOffset:0,sideOffset:8,children:h(Nn,{type:"menu",sourceId:"help-menu",children:i})})]})})});var Fpe=wt(Jt(),1);q();var R5e=Q(function({children:t,className:n},o){return E(ANe,{ref:o,className:Fpe.default("tlui-button tlui-select__trigger",n),children:[t,h(RNe,{className:"tlui-select__chevron",children:h(xr,{icon:"chevron-down",label:"",small:!0})})]})});q();oM();var ca={White:"white",LightGray:"lightGray",Gray:"gray",Black:"black",Green:"green",Cyan:"cyan",Blue:"blue",Indigo:"indigo",Violet:"violet",Red:"red",Orange:"orange",Yellow:"yellow"},rg={Small:"small",Medium:"medium",Large:"large"},iT={Draw:"draw",Solid:"solid",Dashed:"dashed",Dotted:"dotted"},bd={Start:"start",Middle:"middle",End:"end",Justify:"justify"},sT={Script:"script",Sans:"sans",Serif:"serif",Mono:"mono"};var myr={[ca.White]:"black",[ca.Black]:"black",[ca.LightGray]:"grey",[ca.Gray]:"grey",[ca.Green]:"light-green",[ca.Cyan]:"green",[ca.Blue]:"light-blue",[ca.Indigo]:"blue",[ca.Orange]:"orange",[ca.Yellow]:"yellow",[ca.Red]:"red",[ca.Violet]:"light-violet"},gyr={[sT.Mono]:"mono",[sT.Sans]:"sans",[sT.Script]:"draw",[sT.Serif]:"serif"},yyr={[bd.Start]:"start",[bd.Middle]:"middle",[bd.End]:"end",[bd.Justify]:"start"},Syr={[bd.Start]:"start",[bd.Middle]:"middle",[bd.End]:"end",[bd.Justify]:"start"},byr={[rg.Small]:"s",[rg.Medium]:"l",[rg.Large]:"xl"},xyr={[rg.Small]:"m",[rg.Medium]:"l",[rg.Large]:"xl"},vyr={[iT.Solid]:"solid",[iT.Dashed]:"dashed",[iT.Dotted]:"dotted",[iT.Draw]:"draw"};var O5e=Ye({schemaVersion:co(1),storeVersion:ik,recordVersions:sk(Ne,Ye({version:ik,subTypeVersions:sk(Ne,ik).optional(),subTypeKey:Ne.optional()}))}),N5e=Ye({schemaVersion:co(2),sequences:sk(Ne,ik)}),Iyr=Ye({tldrawFileFormatVersion:Hwe,schema:Vwe("schemaVersion",{1:O5e,2:N5e}),records:ur(Ye({id:Ne,typeName:Ne}).allowUnknownProperties())});ci("tldraw","5.5.2","esm");var oA=["label","name","both"],S9=["ja","en"],F5e=S9.flatMap((e)=>oA.map((t)=>[e,t]));var Bpe=(e,t)=>Object.fromEntries(S9.map((n)=>[n,Object.fromEntries(oA.map((o)=>[o,t(e[n][o],n,o)]))])),rA=(e)=>Object.fromEntries(S9.map((t)=>[t,{label:e[t],name:e[t],both:e[t]}])),b9=["command","event","both"];function aT(e,t,n){if(n==="command")return{main:e,faded:!1};if(n==="event")return t?{main:t,faded:!1}:{main:e,faded:!0};return{main:e,sub:t&&Bpe(t,(o)=>`⇒ ${o}`),faded:!1}}var iA=19,sA=15,x9=0.85,v9=(e,t)=>zpe+(aT(e.label,e.events,t).sub?sA:0),w9=5,aA=(e,t)=>e.internal?.length?2*w9+e.internal.reduce((n,o)=>n+v9(o,t),0):0;var C9=["detail","overview","aggregates"];var zpe=21;q();var Hpe="domaintrail.lang",Vpe={added:"追加",changed:"変更",removed:"削除",none:"なし",shared:"共有",sharedTag:"共有",persistent:"永続化",transient:"非永続",persistentHint:"永続化される契約のイベント(persistent)",transientHint:"永続化しないイベント(persistent の指定なし)",noModel:"モデルがまだありません。",noDtFiles:".dt ファイルがありません",nameDisplay:"名前の表示",nameDisplayHint:"モデルの要素を、ラベル(日本語名など)と名前のどちらで表示するか",modes:{label:"ラベル",name:"名前",both:"両方"},status:{ok:"正常",invalid:"検証エラー","syntax-error":"構文エラー",empty:".dt なし"},settings:"設定",closeSettings:"設定を閉じる",theme:"テーマ",themes:{auto:"自動",light:"ライト",dark:"ダーク"},themeAuto:(e)=>`OS の設定に従う(いまは${e})`,themeHint:"画面の配色",language:"言語",langAuto:(e)=>`ブラウザの設定に従う(いまは${e})`,langHint:"画面の表示言語(モデルのラベルは変わりません)",fileCount:(e)=>`${e} ファイル`,connection:{connecting:"接続中",open:"接続済み",closed:"切断"},connectionTitle:(e)=>`サーバーとの接続: ${e}`,stale:(e)=>E(Y,{children:["構文エラーのため、最後に解析できた図を表示しています。",e,"から該当箇所へ移動できます。"]}),openExplorer:"エクスプローラを開く",closeExplorer:"エクスプローラを閉じる",openInspector:"インスペクタを開く",closeInspector:"インスペクタを閉じる",openBottom:"問題・変更を開く",closeBottom:"問題・変更を閉じる",views:{contextMap:"コンテキストマップ",structure:"構造図",catalog:"カタログ"},showAllContexts:"共有・外部の BC も表示",structureMode:"構造図の表示",structureLevels:{detail:"詳細 — すべての項目を表示",overview:"概観 — 要素の名前だけを表示",aggregates:"集約 — 集約とその関係だけを表示"},zoomToFit:"全体表示",transitionLabels:"遷移のラベル",transitionLabelModes:{command:{label:"コマンド",hint:"コマンドだけを表示"},event:{label:"イベント",hint:"発生させるドメインイベントだけを表示(イベントのない遷移はコマンドを薄く表示)"},both:{label:"両方",hint:"コマンドと、その下に発生させるドメインイベントを表示"}},pickContexts:"表示する BC を選んでください",loading:"読み込み中…",noDiagram:"表示できる図がありません",contextsToShow:"表示する BC",allContexts:"すべての BC",moreContexts:(e,t)=>`${e} ほか ${t} BC`,listSeparator:"、",hiddenContexts:(e)=>` · ${e} BC 非表示`,allStubs:"スタブをまとめて表示",showAllStubs:"すべてスタブとして表示する",hideAllStubs:"すべてのスタブを表示しない",contextStubs:(e)=>`${e} をスタブとして表示`,showStubs:"スタブとして表示する",hideStubs:"スタブを表示しない",legend:"凡例",openLegend:"凡例を開く",closeLegend:"凡例を閉じる",legendRows:{mapReferences:"ID だけで依存(ID 参照の件数)",mapDependsOn:"型も借りて依存(型の借用の件数)",owns:"所有(集約の内部)",focusReferences:"参照(ID で別の集約・BC へ)",focusValue:"値・型の借用(値オブジェクト / ユニオン / 列挙型 など)",references:"参照(ID で別の集約へ)",value:"値(値オブジェクト / ユニオンを持つ)",aggregateReferences:"参照(ID で別の集約へ。エンティティや値オブジェクトを経由するものも含む)",aggregateValue:"別の集約を値として持つ",transition:"コマンドによる遷移(⇒ 発生させるドメインイベント)"},stubNote:"点線枠の小さな箱は別の BC の要素(スタブ)",aggregateStubNote:"点線枠の小さな箱は別の BC の集約(スタブ)",arrowNote:"矢印の先が依存先",internalNote:"状態の箱の中の ↻ は状態を変えないコマンド",model:"モデル",files:"ファイル",fileKind:"ファイル",filter:"フィルタ",clearFilter:"フィルタを消す",onlyProblems:"問題のある項目だけ表示",onlyChanged:"変更された項目だけ表示",noMatches:"一致する項目はありません。",kinds:{aggregate:"集約",entity:"エンティティ",valueObject:"値オブジェクト",union:"ユニオン",primitive:"ドメインプリミティブ",id:"ID",enum:"列挙型",event:"ドメインイベント",error:"エラー",fieldSet:"項目セット",state:"状態",command:"コマンド",context:"コンテキスト"},problems:"問題",changes:"変更",noProblems:"問題はありません。",noChanges:"直前の正常モデルからの変更はありません。",catalogSections:{aggregates:"集約",entities:"エンティティ",values:"値オブジェクト・ユニオン",primitives:"ドメインプリミティブ",fieldSets:"項目セット",events:"ドメインイベント",errors:"エラー"},sharedCatalog:"共有 · どの BC からも名前で参照可",catalogEmpty:"ありません。",catalogKinds:"表示する種類",catalogNoMatches:"一致する要素はありません。",raisedByNone:"発生させるコマンドはありません",returnedByNone:"返すコマンドはありません",usedIn:(e)=>`使用 ${e} 箇所`,copyCode:"コードをコピー",counted:(e,t)=>`${e}(${t})`,tabs:{structure:"構造",states:"状態遷移",behavior:"振る舞い",events:"イベント",references:"参照",source:"ソース"},reveal:{contextMap:"コンテキストマップ",structure:"構造図",catalog:"カタログ"},backTo:(e)=>`${e} に戻る`,notInModel:(e)=>`${e} は現在のモデルにありません。`,pickElement:"エクスプローラや図で要素やファイルを選ぶと、ここに詳細が出ます。",showIn:"見る:",commandsInto:"この状態に入るコマンド",commandsOutOf:"この状態から出るコマンド",stateFields:"この状態固有のフィールド",noStateFields:"この状態固有のフィールドはありません。",stateInvariants:"不変条件(この状態のみ)",commonFieldsAt:(e)=>E(Y,{children:["共通フィールドは集約 ",e," を参照。"]}),transition:"遷移",noStates:"(状態なし)",mayRaise:"発生し得るドメインイベント(0 件以上)",mayReturn:"返し得るエラー",params:"パラメータ",noParams:"パラメータはありません。",contract:"契約",identifier:"ドメインプリミティブ(識別子)",separator:" / ",baseType:"基底型",values:"値",discriminator:"判別子",noFields:"フィールドはありません。",variantInvariants:(e)=>`不変条件(${e})`,commonFields:"共通フィールド",payload:"ペイロード",fields:"フィールド",invariants:"不変条件",allStateInvariants:"不変条件(全状態共通)",valueInvariants:"不変条件(値(value)に適用)",commands:"コマンド",states:"状態",typeDependency:"型",focusContext:"この BC だけを構造図で見る",dependencies:"依存先(この BC が使う)",dependents:"依存元(この BC を使う)",terms:"用語集(terms)",unreferenced:"どこからも参照されていません。",raisedBy:"発生させるコマンド",returnedBy:"返すコマンド",typeUses:(e)=>`型として使われている場所(${e})`,fieldSetUsers:(e)=>`使っている要素(${e})`,fromFieldSet:(e)=>`項目セット ${e} の項目`,idUses:(e,t)=>`ID(${e})で参照している場所(${t})`,raises:(e)=>`発生させるドメインイベント(${e})`,factory:"生成",origin:"発生元",raisesHint:"発生させるドメインイベント",returnsHint:"返し得るエラー",returns:(e)=>`返し得るエラー(${e})`,labelSources:{term:"用語",type:"型"}},B5e={added:"Added",changed:"Changed",removed:"Removed",none:"None",shared:"Shared",sharedTag:"shared",persistent:"Persistent",transient:"Transient",persistentHint:"Persisted by contract (persistent)",transientHint:"Not persisted (not declared persistent)",noModel:"No model yet.",noDtFiles:"No .dt files",nameDisplay:"Names",nameDisplayHint:"Whether model elements are shown by their labels, their names or both",modes:{label:"Label",name:"Name",both:"Both"},status:{ok:"OK",invalid:"Invalid","syntax-error":"Syntax error",empty:"No .dt"},settings:"Settings",closeSettings:"Close the settings",theme:"Theme",themes:{auto:"Auto",light:"Light",dark:"Dark"},themeAuto:(e)=>`Follows the OS (now ${e})`,themeHint:"The colors of the screen",language:"Language",langAuto:(e)=>`Follows the browser (now ${e})`,langHint:"The language of the screen (model labels stay as written)",fileCount:(e)=>`${e} ${e===1?"file":"files"}`,connection:{connecting:"connecting",open:"connected",closed:"disconnected"},connectionTitle:(e)=>`Connection to the server: ${e}`,stale:(e)=>E(Y,{children:["Showing the last diagram that could be parsed, because of a syntax error. See ",e," for where it is."]}),openExplorer:"Open the explorer",closeExplorer:"Close the explorer",openInspector:"Open the inspector",closeInspector:"Close the inspector",openBottom:"Open problems and changes",closeBottom:"Close problems and changes",views:{contextMap:"Context Map",structure:"Structure",catalog:"Catalog"},showAllContexts:"Also show shared and external BCs",structureMode:"Structure view",structureLevels:{detail:"Detail — show every field",overview:"Overview — show the elements’ names only",aggregates:"Aggregates — show the aggregates and their relations only"},zoomToFit:"Fit",transitionLabels:"Transition labels",transitionLabelModes:{command:{label:"Command",hint:"Show the commands only"},event:{label:"Events",hint:"Show the domain events raised only (a transition without events shows its command, faded)"},both:{label:"Both",hint:"Show the commands and, under them, the domain events raised"}},pickContexts:"Pick the BCs to show",loading:"Loading…",noDiagram:"Nothing to draw",contextsToShow:"BCs to show",allContexts:"All BCs",moreContexts:(e,t)=>`${e} and ${t} more`,listSeparator:", ",hiddenContexts:(e)=>` · ${e} hidden`,allStubs:"Show all stubs",showAllStubs:"Show all as stubs",hideAllStubs:"Hide all stubs",contextStubs:(e)=>`Show ${e} as stubs`,showStubs:"Show as stubs",hideStubs:"Hide the stubs",legend:"Legend",openLegend:"Open the legend",closeLegend:"Close the legend",legendRows:{mapReferences:"Depends by IDs only (ID references)",mapDependsOn:"Also borrows types (borrowed types)",owns:"Owns (inside an aggregate)",focusReferences:"References (by ID, another aggregate or BC)",focusValue:"Value or borrowed type (Value Object, Union, Enum…)",references:"References (by ID, another aggregate)",value:"Value (holds a Value Object or Union)",aggregateReferences:"References (by ID, another aggregate, also through entities and value objects)",aggregateValue:"Holds another aggregate as a value",transition:"Transition by a command (⇒ events it raises)"},stubNote:"Small dashed boxes are elements of other BCs (stubs)",aggregateStubNote:"Small dashed boxes are aggregates of other BCs (stubs)",arrowNote:"Arrows point at the dependency",internalNote:"↻ in a state’s box: a command that keeps the state",model:"Model",files:"Files",fileKind:"File",filter:"Filter",clearFilter:"Clear the filter",onlyProblems:"Show only items with problems",onlyChanged:"Show only changed items",noMatches:"Nothing matches.",kinds:{aggregate:"Aggregate",entity:"Entity",valueObject:"Value Object",union:"Union",primitive:"Domain Primitive",id:"ID",enum:"Enum",event:"Event",error:"Error",fieldSet:"Field set",state:"State",command:"Command",context:"Context"},problems:"Problems",changes:"Changes",noProblems:"No problems.",noChanges:"No changes since the last valid model.",catalogSections:{aggregates:"Aggregates",entities:"Entities",values:"Value Objects and Unions",primitives:"Domain Primitives",fieldSets:"Field sets",events:"Domain Events",errors:"Errors"},sharedCatalog:"Shared · referable by name from any context",catalogEmpty:"None.",catalogKinds:"Kinds to show",catalogNoMatches:"No elements match.",raisedByNone:"No command raises it",returnedByNone:"No command returns it",usedIn:(e)=>`Used in ${e} ${e===1?"place":"places"}`,copyCode:"Copy the code",counted:(e,t)=>`${e} (${t})`,tabs:{structure:"Structure",states:"States",behavior:"Behavior",events:"Events",references:"References",source:"Source"},reveal:{contextMap:"Context Map",structure:"Structure",catalog:"Catalog"},backTo:(e)=>`Back to ${e}`,notInModel:(e)=>`${e} is not in the current model.`,pickElement:"Select an element or a file in the explorer or a diagram to see its details here.",showIn:"Show in:",commandsInto:"Commands into this state",commandsOutOf:"Commands out of this state",stateFields:"Fields of this state",noStateFields:"This state has no fields of its own.",stateInvariants:"Invariants (this state only)",commonFieldsAt:(e)=>E(Y,{children:["For the common fields, see the aggregate ",e,"."]}),transition:"Transition",noStates:"(no states)",mayRaise:"Events it may raise (zero or more)",mayReturn:"Errors it may return",params:"Parameters",noParams:"No parameters.",contract:"Contract",identifier:"Domain Primitive (identifier)",separator:" / ",baseType:"Base type",values:"Values",discriminator:"Discriminator",noFields:"No fields.",variantInvariants:(e)=>`Invariants (${e})`,commonFields:"Common fields",payload:"Payload",fields:"Fields",invariants:"Invariants",allStateInvariants:"Invariants (all states)",valueInvariants:"Invariants (on the value)",commands:"Commands",states:"States",typeDependency:"type",focusContext:"Show only this BC in Structure",dependencies:"Dependencies (used by this BC)",dependents:"Dependents (using this BC)",terms:"Terms",unreferenced:"Not referenced anywhere.",raisedBy:"Commands that raise it",returnedBy:"Commands that return it",typeUses:(e)=>`Used as a type (${e})`,fieldSetUsers:(e)=>`Elements that use it (${e})`,fromFieldSet:(e)=>`A field of the field set ${e}`,idUses:(e,t)=>`Referenced by ID ${e} (${t})`,raises:(e)=>`Events it raises (${e})`,factory:"create",origin:"From",raisesHint:"Events it raises",returnsHint:"Errors it may return",returns:(e)=>`Errors it may return (${e})`,labelSources:{term:"term",type:"type"}},T9={ja:Vpe,en:B5e},I9={ja:"日本語",en:"English"},Upe=()=>navigator.languages.some((e)=>e.toLowerCase().startsWith("ja"))?"ja":"en";function jpe(e){let[t,n]=G(Upe);return F(()=>{let o=()=>n(Upe());return window.addEventListener("languagechange",o),()=>window.removeEventListener("languagechange",o)},[]),e==="auto"?t:e}var P9=Oe({lang:"ja",t:Vpe});function $pe({lang:e,children:t}){return F(()=>{document.documentElement.lang=e},[e]),h(P9.Provider,{value:{lang:e,t:T9[e]},children:t})}var Kt=()=>Te(P9).t,Gpe=()=>Te(P9).lang;var lT=(e)=>Object.values(e.elements),lA=(e)=>e.fields.filter((t)=>!t.fieldSet);function cA(e){let t=[];for(let n of lT(e)){let o=(i,s,a)=>{let l=i?z5e(i):void 0;if(!i||!l||l===n.context||!e.contexts.includes(l))return;t.push({from:n.context,to:l,kind:a??(e.elements[i]?.kind==="id"?"id":"type"),source:n.id,path:s,target:i})},r=(i,s)=>{if(i.kind==="references"&&i.target)o(i.target,s,"id");else if(i.type.kind==="ref")o(i.type.ref,s)};for(let i of lA(n))r(i,i.name);for(let i of n.fieldSets??[])o(i,"with");for(let i of n.states??[])for(let s of i.fields)r(s,`${i.name}.${s.name}`);for(let i of n.variants??[])for(let s of i.fields)r(s,`${i.name}.${s.name}`);if(n.tagType)o(n.tagType,"by");for(let i of n.commands??[]){for(let s of i.params)r(s,`${i.name}(${s.name})`);for(let s of[...i.emits,...i.errors])o(s,`${i.name} ⇒ ${U5e(s)}`)}}return t}function k9(e){let t=new Map;for(let n of e){let o=`${n.from}->${n.to}`,r=t.get(o)??{from:n.from,to:n.to,uses:[],ids:0,types:0};if(r.uses.push(n),n.kind==="id")r.ids++;else r.types++;t.set(o,r)}return[...t.values()]}function uA(e){let t=new Set(e.sharedContexts);for(let n of e.contexts){let o=lT(e).filter((r)=>r.context===n);if(o.length>0&&o.every((r)=>r.kind==="id"))t.add(n)}return t}var z5e=(e)=>e.includes(".")?e.slice(0,e.indexOf(".")):void 0,U5e=(e)=>e.slice(e.lastIndexOf(".")+1);var Cs=(e,t)=>rA({ja:`«${e}»`,en:`«${t}»`}),p0r={aggregate:Cs("集約ルート","aggregate root"),entity:Cs("エンティティ","entity"),valueObject:Cs("値オブジェクト","value object"),union:Cs("ユニオン","union")};var E9={String:"文字列",Int:"整数",Decimal:"小数",Bool:"真偽値",Timestamp:"日時",UUID:"UUID"};function qpe(e,t,n=[]){if(e.kind==="primitive")return e.name;let o=e.ref.slice(0,e.ref.indexOf("."));return o===t||n.includes(o)?e.ref.slice(o.length+1):e.ref}var h0r=new Set([..."、。,.,.))」』】!?!?ー"]);var m0r={aggregate:Cs("集約","aggregate"),entity:Cs("エンティティ","entity"),valueObject:Cs("値オブジェクト","value object"),union:Cs("ユニオン","union"),enum:Cs("列挙型","enum"),primitive:Cs("ドメインプリミティブ","primitive"),id:Cs("ID","id"),event:Cs("ドメインイベント","event"),error:Cs("エラー","error"),fieldSet:Cs("項目セット","field set")};var Ll=(e,t)=>e[t.lang][t.mode],Kpe=new Set(["context","sharedContext","aggregateBoundary"]),j5e=(e)=>Ke(`n:${e}`),$5e=(e)=>Ke(`e:${e}`),Wpe=(e)=>Ke(`ghost:${e}`),G5e=(e)=>Ke(`i:${e}`),q5e=(e,t)=>e.lines.map((n)=>({k:Ll(n.key,t),v:n.value?Ll(n.value,t):"",...n.origin&&{o:Ll(n.origin,t)}})),Al=(e)=>e.split(/[#:]/)[0];function dA(e,t){return e.getShape(t)?.meta?.elementId}function Zpe(e,t){let n=e.getCurrentPageShapes();return(n.find((r)=>r.meta.elementId===t&&r.type==="domain-node")??n.find((r)=>r.meta.elementId===t))?.id}function fA(e,t,n){let o=t.id.startsWith("structure"),r=t.textScale??1,i=Y5e(n.diagnostics,o),s=(m)=>n.diff.added.includes(m)?"added":n.diff.changed.includes(m)?"changed":"none",a=[],l=[],c=[];for(let m of t.nodes){let g=t.nodeLayout[m.id];if(!g)continue;let y=Kpe.has(m.kind),S={change:y?"none":s(m.elementId),diag:y?"none":i.get(m.elementId)??"none"},b={id:j5e(m.id),x:g.x,y:g.y,meta:{elementId:m.elementId,graphNode:m.id}};if(y)a.push({...b,type:"domain-group",props:{w:g.width,h:g.height,kind:m.kind,label:Ll(m.label,n),lines:m.lines.map((x)=>Ll(x.key,n)),scale:r,...S}});else l.push({...b,type:"domain-node",props:{...Ype(t,m,g,n),...S}}),c.push(...Xpe(t,m,g,n,(x)=>({change:s(x),diag:i.get(x)??"none"})))}let u=[];if(n.previous&&n.previous.id===t.id){let m=new Set(t.nodes.map((g)=>g.elementId));for(let g of n.previous.nodes){let y=n.previous.nodeLayout[g.id];if(!y||Kpe.has(g.kind)||m.has(g.elementId)||!n.diff.removed.includes(g.elementId))continue;u.push({id:Wpe(g.id),type:"domain-node",x:y.x,y:y.y,meta:{elementId:g.elementId,ghost:!0},props:{...Ype(n.previous,g,y,n),change:"removed",diag:"none"}});for(let S of Xpe(n.previous,g,y,n,()=>({change:"removed",diag:"none"})))u.push({...S,id:Wpe(`i:${S.meta.edge}`),meta:{...S.meta,ghost:!0}})}}let f=[];for(let m of t.edges){let g=Jpe(m,o),y=W5e(t,m,n,i.get(g)==="error"&&!o?"error":K5e(s(g)));if(y)f.push(y)}let d=[...a,...l,...u,...c,...f],p=new Set(d.map((m)=>m.id));cT(e,()=>{let m=e.getCurrentPageShapes().filter((x)=>!p.has(x.id));e.deleteShapes(m.map((x)=>x.id));let g=[],y=[];for(let x of d)(e.getShape(x.id)?y:g).push(x);e.createShapes(g),e.updateShapes(y);let S=a.filter((x)=>x.props.kind==="aggregateBoundary").map((x)=>x.id),b=a.filter((x)=>x.props.kind!=="aggregateBoundary").map((x)=>x.id);if(S.length)e.sendToBack(S);if(b.length)e.sendToBack(b);if(c.length)e.bringToFront(c.map((x)=>x.id));if(f.length)e.bringToFront(f.map((x)=>x.id))})}function Ype(e,t,n,o){return{w:n.width,h:n.height,kind:t.kind,label:Ll(t.label,o),stereotype:t.stereotype?Ll(t.stereotype,o):"",scale:e.textScale??1,rows:q5e(t,o),compartment:t.internal?.length?aA(t,e.transitionLabels??"both"):0}}function Xpe(e,t,n,o,r){if(!t.internal?.length)return[];let i=o.transitionLabels??"both",s=n.y+n.height-aA(t,e.transitionLabels??"both")+w9;return t.internal.map((a)=>{let l=aT(a.label,a.events,i),c=v9(a,i),u={id:G5e(a.id),type:"domain-internal",x:n.x+4,y:s,meta:{elementId:a.elementId,edge:a.id},props:{w:n.width-8,h:c,label:Ll(l.main,o),sub:l.sub?Ll(l.sub,o):"",faded:l.faded,scale:e.textScale??1,...r(a.elementId)}};return s+=c,u})}function cT(e,t){let n=e.getIsReadonly();if(n)e.updateInstanceState({isReadonly:!1});try{e.run(t,{history:"ignore",ignoreShapeLock:!0})}finally{if(n)e.updateInstanceState({isReadonly:!0})}}function Jpe(e,t){return t?e.source:e.id.split("|")[0]}var K5e=(e)=>e==="added"?"added":e==="changed"?"changed":"normal";function W5e(e,t,n,o){let r=e.edgeLayout[t.id];if(!r||r.points.length<2)return;let i=r.points.map((f)=>f.x),s=r.points.map((f)=>f.y);if(r.label)i.push(r.label.x),s.push(r.label.y);let a=Math.min(...i),l=Math.min(...s),c=r.label,u=t.label&&(t.kind==="transition"?aT(t.label,t.events,n.transitionLabels??"both"):{main:t.label,faded:!1});return{id:$5e(t.id),type:"domain-edge",x:a,y:l,meta:{elementId:Jpe(t,e.id.startsWith("structure")),edge:t.id},props:{points:r.points.map((f)=>({x:f.x-a,y:f.y-l})),kind:t.kind,label:u?Ll(u.main,n):"",sub:u&&"sub"in u&&u.sub?Ll(u.sub,n):"",faded:u?u.faded:!1,scale:e.textScale??1,lx:c?c.x-a:0,ly:c?c.y-l:0,lw:c?.width??0,lh:c?.height??0,tone:o}}}function Y5e(e,t){let n=new Map;for(let o of e){if(!o.elementId)continue;let r=t?[Al(o.elementId)]:[o.elementId,Al(o.elementId)];for(let i of r)if(n.get(i)!=="error")n.set(i,o.severity==="error"?"error":"warning")}return n}var pA=["aggregate","entity","valueObject","union","primitive","id","enum","fieldSet","event","error"],X5e=(e)=>e.slice(e.lastIndexOf(".")+1);var xd=(e,t,n)=>e==="name"||!n?t:e==="label"?n:`${n} (${t})`;function Wb(e,t){if(e.contexts.includes(t))return{kind:"context",name:t,label:e.contextLabels[t],shared:e.sharedContexts.includes(t)};let n=e.elements[t];if(n)return{kind:"element",el:n};let o=e.elements[Al(t)],r=o?.states?.find((s)=>s.id===t);if(o&&r)return{kind:"state",agg:o,state:r};let i=o?.commands?.find((s)=>s.id===t);if(o&&i)return{kind:"command",agg:o,command:i};return}var hA=(e)=>`file:${e}`,Yb=(e)=>e?.startsWith("file:")?e.slice(5):void 0,Qpe=(e)=>e==="aggregate"||e==="entity"||e==="valueObject"||e==="union",ehe=[{key:"aggregates",kinds:["aggregate"]},{key:"entities",kinds:["entity"]},{key:"values",kinds:["valueObject","union"]},{key:"primitives",kinds:["primitive","id","enum"]},{key:"fieldSets",kinds:["fieldSet"]},{key:"events",kinds:["event"]},{key:"errors",kinds:["error"]}],mA=(e)=>ehe.some((t)=>t.kinds.includes(e));function the(e){let t=uT(e);return ehe.map(({key:n,kinds:o})=>{let r=t.map((i)=>({context:i,items:Object.values(e.elements).filter((s)=>s.context===i&&o.includes(s.kind)).sort((s,a)=>o.indexOf(s.kind)-o.indexOf(a.kind)||s.name.localeCompare(a.name))})).filter((i)=>i.items.length>0);return{key:n,kinds:o,groups:r,count:r.reduce((i,s)=>i+s.items.length,0)}})}var nhe=(e)=>e.query.trim()!==""||e.sections.length>0||e.contexts!==null;function Z5e(e,t){let n=t.trim().toLowerCase();return!n||[e.label,e.name,e.doc].some((o)=>o?.toLowerCase().includes(n))}function ohe(e,t){return e.map((n)=>{let o=t.sections.length&&!t.sections.includes(n.key)?[]:n.groups.filter((r)=>t.contexts===null||t.contexts.includes(r.context)).map((r)=>({...r,items:r.items.filter((i)=>Z5e(i,t.query))})).filter((r)=>r.items.length>0);return{...n,groups:o,shown:o.reduce((r,i)=>r+i.items.length,0)}})}function rhe(e,t){return Object.values(e.elements).flatMap((n)=>(n.commands??[]).filter((o)=>o.emits.includes(t)||o.errors.includes(t)).map((o)=>({agg:n,command:o})))}var gA=(e,t)=>Object.values(e.elements).filter((n)=>n.fieldSets?.includes(t));function uT(e){let t=new Set(e.sharedContexts);return[...e.contexts].sort((n,o)=>Number(t.has(o))-Number(t.has(n))||n.localeCompare(o))}function vd(e,t){let n=(r)=>xd(e,r.name,r.label),o=(r,i)=>{let s=r.states?.find((a)=>a.name===i);return s?n(s):i};return{mode:e,of:n,field:n,type(r,i){let s=qpe(r,i,t?.sharedContexts??[]);if(e!=="label")return s;return r.kind==="primitive"?E9[r.name]:t?.elements[r.ref]?.label??s},primitive:(r)=>e==="label"?E9[r]??r:r,state:o,transition(r,i){if(!r.states?.length)return i.factory?"new":"";let s=(a)=>a.map((l)=>o(r,l)).join(" | ");return i.transitions.map((a)=>`${i.factory?"new":s(a.from)} → ${s(a.to)}`).join("; ")},short(r){let i=t?.elements[r];if(!i)return X5e(r);return e==="both"?i.label??i.name:n(i)},id(r){let i=t?Wb(t,r):void 0;if(!i)return r;if(i.kind==="context")return xd(e,i.name,i.label);if(i.kind==="element")return n(i.el);if(i.kind==="state")return`${n(i.agg)}.${n(i.state)}`;return`${n(i.agg)}.${n(i.command)}`}}}function ihe(e){let t=Kt(),n=e.diagnostics.filter((s)=>s.severity==="error").length,o=e.diagnostics.length-n,r=e.diff.added.length+e.diff.changed.length+e.diff.removed.length,i=(s)=>{if(e.open&&e.tab===s)e.onToggle();else if(e.onTab(s),!e.open)e.onToggle()};return E("div",{className:"bottom",children:[E("div",{className:"bottom-bar",children:[E("button",{className:e.open&&e.tab==="problems"?"active":"",onClick:()=>i("problems"),children:[t.problems,n>0&&h("span",{className:"count count-error",children:n}),o>0&&h("span",{className:"count count-warning",children:o}),n+o===0&&h("span",{className:"muted",children:" 0"})]}),E("button",{className:e.open&&e.tab==="changes"?"active":"",onClick:()=>i("changes"),children:[t.changes," ",r>0?h("span",{className:"count",children:r}):h("span",{className:"muted",children:"0"})]}),h("button",{className:"icon-button bottom-toggle",onClick:e.onToggle,"data-tooltip":e.open?t.closeBottom:t.openBottom,"aria-label":e.open?t.closeBottom:t.openBottom,children:e.open?h(Sv,{size:16,"aria-hidden":!0}):h(bv,{size:16,"aria-hidden":!0})})]}),h("div",{className:"bottom-body",inert:!e.open,children:e.tab==="problems"?h(J5e,{items:e.diagnostics,onLocate:e.onLocate}):h(Q5e,{...e})})]})}function J5e({items:e,onLocate:t}){let n=Kt();if(e.length===0)return h("p",{className:"muted pad",children:n.noProblems});return h("table",{className:"problems",children:h("tbody",{children:e.map((o,r)=>E("tr",{className:`problem problem-${o.severity}`,onClick:()=>t(o),children:[h("td",{className:"problem-icon",children:o.severity==="error"?"✕":"!"}),h("td",{children:h("code",{children:o.code})}),h("td",{className:"problem-msg",children:o.message}),E("td",{className:"muted nowrap",children:[o.file,":",o.start.line,":",o.start.column]}),h("td",{className:"muted nowrap",children:o.elementId??""})]},r))})})}function Q5e({diff:e,model:t,mode:n,onSelect:o}){let r=Kt();if(!e.added.length&&!e.changed.length&&!e.removed.length)return h("p",{className:"muted pad",children:r.noChanges});let i=vd(n,t).id,s=[["added",r.added],["changed",r.changed],["removed",r.removed]];return h("div",{className:"changes",children:s.map(([a,l])=>E("div",{className:"changes-col",children:[E("h3",{children:[l," ",h("span",{className:"muted",children:e[a].length})]}),e[a].map((c)=>h("div",{className:`sub diffrow diffrow-${a}`,children:a==="removed"?h("span",{children:c}):h("a",{onClick:()=>o(c),children:i(c)})},c))]},a))})}q();function dT({persistent:e,tx:t}){return h("span",{className:`persistence-badge${e?" persistent":""}`,title:e?t.persistentHint:t.transientHint,children:e?t.persistent:t.transient})}function she({kind:e,x:t,names:n,onClick:o}){let r=n.mode==="both"&&!!t.label;return E("a",{className:"bcard-title",onClick:o,children:[h("span",{className:`bcard-band band-${e}`,"aria-hidden":!0}),h("strong",{children:r?t.label:n.of(t)}),r&&h("span",{className:"bcard-name",children:t.name})]})}function ahe({x:e,names:t}){return t.mode==="both"&&e.label?E(Y,{children:[e.label," ",h("span",{className:"bcard-name",children:e.name})]}):h(Y,{children:t.of(e)})}function _9({kind:e,id:t,x:n,names:o,onSelect:r}){return E("a",{className:"kind-link",onClick:()=>r(t),children:[h("span",{className:`tree-dot dot-${e}`,"aria-hidden":!0}),h(ahe,{x:n,names:o})]})}function lhe({fields:e,ctx:t,names:n,onSelect:o}){return h("div",{className:"bcard-fields",children:e.map((r)=>E("div",{className:"bcard-field",title:r.doc,children:[h("span",{className:"bcard-fname",children:h(ahe,{x:r,names:n})}),E("span",{className:"bcard-ftype",children:[r.type.kind==="ref"&&r.type.target?h("a",{onClick:()=>o(r.type.ref),children:n.type(r.type,t)}):n.type(r.type,t),r.multiplicity,r.fieldSet&&h("a",{className:"field-origin",onClick:()=>o(r.fieldSet),children:n.short(r.fieldSet)})]})]},r.name))})}function eUe({agg:e,c:t,names:n,onSelect:o}){let r=(i)=>i.map((s)=>{let a=e.states?.find((c)=>c.name===s),l=n.mode==="both"&&!!a?.label;return h("a",{className:"state-chip",title:l?s:void 0,onClick:()=>o(a?.id??e.id),children:l?a.label:n.state(e,s)},s)});return t.transitions.map((i,s)=>E("div",{className:"bcard-transition",children:[t.factory?h("span",{className:"initial-state","aria-hidden":!0,children:"●"}):r(i.from),h("span",{className:"muted",children:"→"}),r(i.to)]},s))}function che({agg:e,c:t,model:n,names:o,tx:r,onSelect:i}){let s=(a)=>n.elements[a]??{name:a};return E("div",{className:"bcard",children:[E("div",{className:"bcard-head",children:[h(she,{kind:"command",x:t,names:o,onClick:()=>i(t.id)}),t.factory&&h("span",{className:"factory-badge",children:r.factory})]}),(e.states?.length??0)>0&&h(eUe,{agg:e,c:t,names:o,onSelect:i}),t.params.length>0&&E("div",{className:"bcard-part",children:[h("div",{className:"bcard-caption",children:r.params}),h(lhe,{fields:t.params,ctx:e.context,names:o,onSelect:i})]}),t.emits.length+t.errors.length>0&&E("div",{className:"bcard-outcomes",children:[t.emits.length>0&&E("span",{className:"bcard-outcome",children:[h("span",{className:"muted",title:r.raisesHint,children:"⇒"}),t.emits.map((a)=>h(_9,{kind:n.elements[a]?.kind??"event",id:a,x:s(a),names:o,onSelect:i},a))]}),t.errors.length>0&&E("span",{className:"bcard-outcome",children:[h("span",{className:"muted",title:r.returnsHint,children:"✕"}),t.errors.map((a)=>h(_9,{kind:n.elements[a]?.kind??"error",id:a,x:s(a),names:o,onSelect:i},a))]})]})]})}function uhe({id:e,commands:t,model:n,names:o,tx:r,onSelect:i}){let s=n.elements[e],a=s?.kind??"error";return E("div",{className:"bcard",children:[E("div",{className:"bcard-head",children:[h(she,{kind:a,x:s??{name:e},names:o,onClick:()=>i(e)}),s?.kind==="event"&&h(dT,{persistent:!!s.persistent,tx:r})]}),s?.doc&&h("div",{className:"bcard-doc",children:s.doc}),E("div",{className:"bcard-outcome",children:[h("span",{className:"bcard-caption",children:r.origin}),t.map((l)=>h(_9,{kind:"command",id:l.id,x:l,names:o,onSelect:i},l.id))]}),s&&s.fields.length>0&&E("div",{className:"bcard-part",children:[h("div",{className:"bcard-caption",children:r.payload}),h(lhe,{fields:s.fields,ctx:s.context,names:o,onSelect:i})]})]})}function dhe(e,t){let n=new Map;for(let o of e)for(let r of o[t])n.set(r,[...n.get(r)??[],o]);return n}q();q();function Ao(e,t){let[n,o]=G(()=>{try{let i=localStorage.getItem(e);return i===null?t:JSON.parse(i)}catch{return t}}),r=O((i)=>{o(i);try{localStorage.setItem(e,JSON.stringify(i))}catch{}},[e]);return[n,r]}function fhe(e,t,n){F(()=>{if(!e)return;let o=(i)=>{if(t.current&&!t.current.contains(i.target))n()},r=(i)=>{if(i.key==="Escape")n()};return document.addEventListener("mousedown",o),document.addEventListener("keydown",r),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",r)}},[e,t,n])}function tUe(e,t,n,o){if(e<n/2)return{open:!1,size:t};return{open:!0,size:Math.round(Math.min(o,Math.max(n,e)))}}function yA(e){let t=(n)=>{n.preventDefault();let o=e.direction==="x"?n.clientX:n.clientY,r=e.size,i=e.open?r:e.collapsed,s=Math.max(e.min,typeof e.max==="function"?e.max():e.max),a=e.open,l=r,c=n.currentTarget;c.setPointerCapture(n.pointerId),document.documentElement.classList.add("resizing");let u=(d)=>{let p=(e.direction==="x"?d.clientX:d.clientY)-o,m=tUe(i+(e.invert?-p:p),r,e.min,s);if(m.size!==l)e.onResize(l=m.size);if(m.open!==a)e.onOpenChange(a=m.open)},f=()=>{document.documentElement.classList.remove("resizing"),c.removeEventListener("pointermove",u),c.removeEventListener("pointerup",f),c.removeEventListener("pointercancel",f)};c.addEventListener("pointermove",u),c.addEventListener("pointerup",f),c.addEventListener("pointercancel",f)};return h("div",{className:`resizer resizer-${e.direction}`,onPointerDown:t,role:"separator","aria-orientation":e.direction==="x"?"vertical":"horizontal"})}function SA(e){let{contexts:t,labels:n,selected:o,hidden:r=[],mode:i,onChange:s,onHiddenChange:a}=e,l=Kt(),[c,u]=G(!1),f=L(null);fhe(c,f,O(()=>u(!1),[]));let d=(P)=>xd(i,P,n[P]),p=o.length===t.length,m=(p?l.allContexts:o.length===0?l.none:o.length<=2?o.map(d).join(l.listSeparator):l.moreContexts(d(o[0]),o.length-1))+(r.length?l.hiddenContexts(r.length):""),g=(P)=>s(o.includes(P)?o.filter((k)=>k!==P):t.filter((k)=>k===P||o.includes(k))),y=(P)=>a?.(r.includes(P)?r.filter((k)=>k!==P):t.filter((k)=>k===P||r.includes(k))),S=o.length===0?[]:t.filter((P)=>!o.includes(P)),b=S.length>0&&S.every((P)=>r.includes(P)),x=r.length>0&&!b,w=L(null);F(()=>{if(w.current)w.current.indeterminate=!p&&o.length>0});let v=L(null),[C,I]=G(!1);return He(()=>{let P=v.current;if(!P)return;let k=()=>I(P.scrollWidth>P.clientWidth);k();let _=new ResizeObserver(k);return _.observe(P),()=>_.disconnect()},[m]),E("div",{className:"context-picker",ref:f,children:[E("button",{className:"context-picker-button","aria-haspopup":"listbox","aria-expanded":c,"aria-label":l.contextsToShow,"data-tooltip":C?`BC: ${m}`:void 0,onClick:()=>u(!c),children:[E("span",{ref:v,className:"context-picker-summary",children:["BC: ",m]}),h("span",{"aria-hidden":!0,children:"▾"})]}),c&&E("div",{className:"context-picker-menu",role:"listbox","aria-multiselectable":!0,children:[E("div",{className:"context-picker-row context-picker-all",children:[E("label",{className:"check",children:[h("input",{ref:w,type:"checkbox",checked:p,onChange:()=>s(p?[]:t)}),l.allContexts]}),a&&h("button",{className:"icon-button",disabled:S.length===0,"aria-label":l.allStubs,"data-tooltip":S.length===0?void 0:r.length?l.showAllStubs:l.hideAllStubs,onClick:()=>a(r.length?[]:S),children:b?h(ly,{size:14,"aria-hidden":!0}):x?h(pv,{size:14,"aria-hidden":!0}):h(ay,{size:14,"aria-hidden":!0})})]}),t.map((P)=>{let k=r.includes(P),_=o.length===0||o.includes(P);return E("div",{className:`context-picker-row${k?" context-hidden":""}`,children:[E("label",{className:"check",role:"option","aria-selected":o.includes(P),children:[h("input",{type:"checkbox",checked:o.includes(P),onChange:()=>g(P)}),d(P)]}),a&&h("button",{className:"icon-button",disabled:_,"aria-pressed":!k,"aria-label":l.contextStubs(d(P)),"data-tooltip":_?void 0:k?l.showStubs:l.hideStubs,onClick:()=>y(P),children:k?h(ly,{size:14,"aria-hidden":!0}):h(ay,{size:14,"aria-hidden":!0})})]},P)})]})]})}var nUe=(e)=>e.name;function Xb(e,t,n=nUe){let o=[],r=(i)=>i.type.kind==="ref"&&i.type.ref===t;for(let i of Object.values(e.elements)){for(let s of lA(i).filter(r))o.push({key:`${i.id}.${s.name}`,target:i.id,context:i.context,text:`${n(i)}.${n(s)}`});for(let s of i.states??[])for(let a of s.fields.filter(r))o.push({key:`${s.id}.${a.name}`,target:s.id,context:i.context,text:`${n(i)}.${n(s)}.${n(a)}`});for(let s of i.variants??[])for(let a of s.fields.filter(r))o.push({key:`${i.id}.${s.name}.${a.name}`,target:i.id,context:i.context,text:`${n(i)}.${n(s)}.${n(a)}`});for(let s of i.commands??[])for(let a of s.params.filter(r))o.push({key:`${s.id}.${a.name}`,target:s.id,context:i.context,text:`${n(i)}.${n(s)}(${n(a)})`})}return o}function phe(e){let{model:t}=e,n=Kt(),o=L(null),[r,i]=G(""),[s,a]=G([]),[l,c]=G(null),u={query:r,sections:s,contexts:l},f=nhe(u),d=the(t),p=ohe(d,u).filter((b)=>!f||b.shown>0),m=uT(t),g=vd(e.mode,t),y=new Set(t.sharedContexts),S=new Map;for(let b of e.diagnostics){if(!b.elementId)continue;let x=Al(b.elementId);if(S.get(x)!=="error")S.set(x,b.severity)}return F(()=>{if(e.selected)o.current?.querySelector(`[data-card="${CSS.escape(e.selected)}"]`)?.scrollIntoView({block:"nearest"})},[e.selected]),E("div",{className:"catalog",ref:o,children:[E("div",{className:"catalog-top",children:[E("div",{className:"catalog-filter-row",children:[E("div",{className:"explorer-filter catalog-filter",children:[h(nh,{size:14,"aria-hidden":!0}),h("input",{value:r,placeholder:n.filter,"aria-label":n.filter,onChange:(b)=>i(b.target.value),onKeyDown:(b)=>{if(b.key==="Escape")i("")}}),r&&h("button",{className:"icon-button",onClick:()=>i(""),"data-tooltip":n.clearFilter,"aria-label":n.clearFilter,children:h(Xc,{size:14,"aria-hidden":!0})})]}),h(SA,{contexts:m,labels:t.contextLabels,selected:l??m,mode:e.mode,onChange:(b)=>c(b.length===m.length?null:b)})]}),h("div",{className:"catalog-kinds",role:"group","aria-label":n.catalogKinds,children:d.map((b)=>h("button",{className:`catalog-kind kind-${b.kinds[0]}${s.length&&!s.includes(b.key)?" off":""}`,"aria-pressed":s.includes(b.key),onClick:()=>a(s.includes(b.key)?s.filter((x)=>x!==b.key):d.map((x)=>x.key).filter((x)=>x===b.key||s.includes(x))),children:n.catalogSections[b.key]},b.key))})]}),p.length===0&&h("p",{className:"muted",children:n.catalogNoMatches}),p.map((b)=>h(oUe,{section:b,hits:f?`${b.shown}/${b.count}`:void 0,...e,names:g,shared:y,severity:S},b.key))]})}function oUe(e){let{section:t,model:n,names:o}=e,r=Kt();return E("section",{className:"catalog-section",children:[E("h1",{children:[r.catalogSections[t.key],e.hits&&h("span",{className:"catalog-count",children:e.hits})]}),t.groups.length===0&&h("p",{className:"muted",children:r.catalogEmpty}),t.groups.map(({context:i,items:s})=>E("section",{className:`catalog-context${e.shared.has(i)?" catalog-shared":""}`,children:[E("h2",{children:[o.of({name:i,label:n.contextLabels[i]}),e.shared.has(i)&&h("span",{className:"shared-badge",children:r.sharedCatalog})]}),h("div",{className:"cards",children:s.map((a)=>h(rUe,{el:a,...e,shared:e.shared.has(i),severity:e.severity.get(a.id)},a.id))})]},i))]})}function rUe(e){let{el:t,model:n,names:o}=e,r=Kt(),i=e.diff.added.includes(t.id)?"added":e.diff.changed.includes(t.id)?"changed":"none",s=["card",`card-kind-${t.kind}`,`dn-change-${i}`,e.selected===t.id?"card-selected":"",e.severity?`card-${e.severity}`:""];return E("button",{className:s.filter(Boolean).join(" "),"data-card":t.id,onClick:()=>e.onSelect(t.id),title:t.doc,children:[h(iUe,{el:t,tx:r}),h(sUe,{el:t,model:n,names:o}),E("div",{className:"card-foot muted",children:[h(aUe,{el:t,model:n,names:o,shared:e.shared}),i!=="none"&&h("span",{className:`change change-${i}`,children:i==="added"?r.added:r.changed}),e.severity&&h("span",{className:`card-diag card-diag-${e.severity}`,children:e.severity==="error"?"✕":"!"})]})]})}function iUe({el:e,tx:t}){return E("div",{className:"card-head",children:[E("span",{className:"card-tags",children:[h("span",{className:`kind kind-${e.kind} tiny`,children:t.kinds[e.kind]}),e.kind==="event"&&h(dT,{persistent:!!e.persistent,tx:t})]}),h("span",{className:"card-name",title:e.label??e.name,children:e.label??e.name}),e.label&&h("span",{className:"card-subname",title:e.name,children:e.name})]})}function sUe({el:e,model:t,names:n}){let o=Kt();switch(e.kind){case"primitive":case"id":case"enum":return E(Y,{children:[e.base&&h("div",{className:"card-base",children:n.primitive(e.base)}),e.values&&h("div",{className:"chips",children:e.values.map((r)=>h("code",{children:n.of({name:r,label:e.valueLabels?.[r]})},r))}),h(bA,{invariants:e.invariants,names:n})]});case"union":return E(Y,{children:[e.discriminator&&h("div",{className:"card-base",children:e.discriminator}),h(fT,{fields:e.fields,ctx:e.context,names:n}),h("div",{className:"chips",children:(e.variants??[]).map((r)=>h("code",{children:n.of(r)},r.name))}),h(bA,{invariants:e.invariants,names:n})]});case"aggregate":return E(Y,{children:[h(fT,{fields:e.fields,ctx:e.context,names:n}),(e.states?.length??0)>0&&h("div",{className:"chips",children:e.states.map((r)=>h("code",{children:n.of(r)},r.id))}),(e.commands?.length??0)>0&&h("ul",{className:"card-commands",children:e.commands.map((r)=>E("li",{children:[n.of(r),h("span",{className:"muted",children:n.transition(e,r)})]},r.id))}),h(bA,{invariants:e.invariants,names:n})]});case"event":return e.fields.length?h(fT,{fields:e.fields,ctx:e.context,names:n}):h("span",{className:"muted",children:o.noFields});case"error":return E(Y,{children:[e.doc&&h("p",{className:"card-doc",children:e.doc}),h(fT,{fields:e.fields,ctx:e.context,names:n})]});default:return E(Y,{children:[h(fT,{fields:e.fields,ctx:e.context,names:n}),h(bA,{invariants:e.invariants,names:n})]})}}function aUe({el:e,model:t,names:n,shared:o}){let r=Kt();if(e.kind==="event"||e.kind==="error"){let l=rhe(t,e.id);if(!l.length)return h(Y,{children:e.kind==="event"?r.raisedByNone:r.returnedByNone});return E(Y,{children:["← ",l.map(({agg:c,command:u})=>`${n.of(c)}.${n.of(u)}`).join(", ")]})}if(e.kind==="fieldSet"){let l=gA(t,e.id);return h(Y,{children:l.length?`← ${l.map((c)=>n.of(c)).join(", ")}`:r.usedIn(0)})}let i=e.kind==="aggregate"?e.fields.find((l)=>l.name==="id"&&l.type.kind==="ref")?.type:void 0,s=i?.kind==="ref"?Xb(t,i.ref).filter((l)=>l.target!==e.id):Xb(t,e.id),a=[...new Set(s.map((l)=>l.context))].filter((l)=>l!==e.context);return E(Y,{children:[r.usedIn(s.length),o&&a.length>0&&E(Y,{children:[" · ",a.map((l)=>n.of({name:l,label:t.contextLabels[l]})).join(", ")]})]})}function fT({fields:e,ctx:t,names:n}){if(!e.length)return null;return h("ul",{className:"card-fields",children:e.map((o)=>E("li",{children:[h("span",{children:n.field(o)}),E("code",{children:[o.kind==="references"?"→ ":"",n.type(o.type,t),o.multiplicity,o.fieldSet&&h("span",{className:"field-origin",children:n.short(o.fieldSet)})]})]},o.name))})}function bA({invariants:e,names:t}){if(!e.length)return null;return h("ul",{className:"card-invariants",children:e.map((n)=>E("li",{children:[E("span",{children:["✓ ",t.of(n)]}),h("code",{children:n.source})]},n.name))})}q();var lUe=0.9;function hhe(e,t=1){let n=lUe/t;if(e.zoomToFit(),e.getZoomLevel()>=n)return;let o=e.getCurrentPageBounds();if(!o)return;let r=e.getViewportScreenBounds(),i=24;e.setCamera({...e.getCamera(),z:n}),e.centerOnPoint({x:Math.min(o.center.x,o.x+r.w/n/2-i),y:Math.min(o.center.y,o.y+r.h/n/2-i)})}function cUe(e){let t=[...Object.values(e.nodeLayout),...Object.values(e.edgeLayout).flatMap((n)=>[...n.label?[n.label]:[],...n.points.map((o)=>({...o,width:0,height:0}))])];return t.length?Z.Common(t.map((n)=>new Z(n.x,n.y,n.width,n.height))):void 0}function M9(e,t,n=!1){let o=cUe(t);if(o)e.zoomToBounds(o,{targetZoom:1,inset:16,animation:n?{duration:200}:void 0})}function pT(e,t){let n=Zpe(e,t);if(!n){e.selectNone();return}e.select(n);let o=e.getShapePageBounds(n);if(o&&!e.getViewportPageBounds().contains(o))e.centerOnPoint(o.center,{animation:{duration:200}})}function xA(e){F(()=>{if(!e)return;return zt("pointer cursor",()=>{let t=e.getHoveredShapeId(),n=t?e.getShape(t):void 0,o=!!n&&!n.meta.ghost,r=e.getInstanceState().cursor.type;if(o&&r==="default")e.setCursor({type:"pointer",rotation:0});else if(!o&&r==="pointer")e.setCursor({type:"default",rotation:0})})},[e])}q();function mhe(e){let t={kind:"dir",name:"",path:"",children:[]};for(let n of e){let o=n.split("/"),r=t;for(let i of o.slice(0,-1)){let s=r.path?`${r.path}/${i}`:i,a=r.children.find((l)=>l.kind==="dir"&&l.name===i);if(!a)r.children.push(a={kind:"dir",name:i,path:s,children:[]});r=a}r.children.push({kind:"file",name:o[o.length-1],path:n})}return t.children.map(ghe).sort(yhe)}function ghe(e){if(e.kind==="file")return e;let t=e;while(t.children.length===1&&t.children[0].kind==="dir"){let n=t.children[0];t={...n,name:`${t.name}/${n.name}`}}return{...t,children:t.children.map(ghe).sort(yhe)}}var yhe=(e,t)=>Number(t.kind==="dir")-Number(e.kind==="dir")||e.name.localeCompare(t.name);function L9(e){return e.kind==="file"?[e.path]:e.children.flatMap(L9)}function bhe(e){let t=Kt(),[n,o]=Ao("domaintrail.explorer.collapsed",[]),[r,i]=Ao("domaintrail.explorer.expanded",[]),[s,a]=Ao("domaintrail.explorer.sections",{model:!0,files:!0}),[l,c]=G(""),[u,f]=G(!1),[d,p]=G(!1),m=l.trim().toLowerCase(),g=m!==""||u||d,y=(R,W)=>g||(W?!n.includes(R):r.includes(R)),S=(R,W)=>{if(g)return;if(W)o(n.includes(R)?n.filter((te)=>te!==R):[...n,R]);else i(r.includes(R)?r.filter((te)=>te!==R):[...r,R])},b=e.model,x=new Map,w=(R,W)=>x.set(R,{...x.get(R),...W});for(let R of e.diagnostics){if(!R.elementId)continue;for(let W of new Set([R.elementId,Al(R.elementId)]))if(x.get(W)?.severity!=="error")w(W,{severity:R.severity})}for(let R of e.diff.added)w(R,{change:"added"});for(let R of e.diff.changed)w(R,{change:"changed"});let v=new Set;for(let R of[...e.diff.added,...e.diff.changed]){let W=b?.elements[Al(R)]?.location.file;if(W)v.add(W)}let C=(R)=>{let W=e.diagnostics.filter((te)=>R.includes(te.file));return{errors:W.filter((te)=>te.severity==="error").length,warnings:W.filter((te)=>te.severity==="warning").length}},I=(...R)=>m===""||R.some((W)=>W?.toLowerCase().includes(m)),P=(R)=>(!u||!!R?.severity)&&(!d||!!R?.change),k=L(null);F(()=>{k.current?.scrollIntoView({block:"nearest"})},[e.selected]);let _=(R,W,te,ue,Ce)=>{let ge=x.get(R),ne=e.selected===R;return E("div",{ref:ne&&te.visible?k:void 0,className:`tree-item${ne?" selected":""}`,style:{paddingLeft:8+te.depth*14},onClick:()=>e.onSelect(R),onDoubleClick:()=>e.onOpen(R),title:R,"aria-expanded":te.onToggle?te.open:void 0,children:[h(A9,{row:te}),h("span",{className:`tree-dot dot-${ue}`}),h("span",{className:"tree-text",children:W}),Ce,ge?.change&&h("span",{className:`tree-change tree-change-${ge.change}`,title:ge.change==="added"?t.added:t.changed}),ge?.severity&&h("span",{className:`tree-diag tree-diag-${ge.severity}`,children:ge.severity==="error"?"✕":"!"})]})},M=(R,W,te="tree-group")=>E("div",{className:te,style:{paddingLeft:8+W.depth*14},onClick:W.onToggle,"aria-expanded":W.open,children:[h(A9,{row:W}),R]}),N=(R)=>E(Y,{children:[R.errors>0&&h("span",{className:"count count-error",children:R.errors}),R.warnings>0&&h("span",{className:"count count-warning",children:R.warnings})]}),V=0,D=0,K=b&&uT(b).map((R)=>A(b,R)).filter(Boolean),U=mhe(e.files).map((R)=>j(R,0,!0)).filter(Boolean);return E("div",{className:"explorer",children:[E("div",{className:"explorer-head",children:[E("div",{className:"explorer-filter",children:[h(nh,{size:14,"aria-hidden":!0}),h("input",{value:l,placeholder:t.filter,"aria-label":t.filter,onChange:(R)=>c(R.target.value),onKeyDown:(R)=>{if(R.key==="Escape")c("")}}),l&&h("button",{className:"icon-button",onClick:()=>c(""),"data-tooltip":t.clearFilter,"aria-label":t.clearFilter,children:h(Xc,{size:14,"aria-hidden":!0})})]}),h("button",{className:"icon-button","aria-pressed":u,onClick:()=>f(!u),"data-tooltip":t.onlyProblems,"aria-label":t.onlyProblems,children:h(rf,{size:15,"aria-hidden":!0})}),h("button",{className:"icon-button","aria-pressed":d,onClick:()=>p(!d),"data-tooltip":t.onlyChanged,"aria-label":t.onlyChanged,children:h(fv,{size:15,"aria-hidden":!0})}),h("button",{className:"icon-button",onClick:e.onClose,"data-tooltip":t.closeExplorer,"aria-label":t.closeExplorer,children:h(nf,{size:16,"aria-hidden":!0})})]}),E("div",{className:"explorer-body",children:[h(She,{title:t.model,hits:g?V:void 0,open:s.model,onToggle:()=>a({...s,model:!s.model}),children:E("div",{className:"tree",children:[!b&&h("p",{className:"muted small pad",children:t.noModel}),b&&g&&!K?.length&&h("p",{className:"muted small pad",children:t.noMatches}),K]})}),h(She,{title:t.files,hits:g?D:void 0,open:s.files,onToggle:()=>a({...s,files:!s.files}),children:E("div",{className:"tree",children:[g&&!U.length&&h("p",{className:"muted small pad",children:t.noMatches}),U]})})]})]});function A(R,W){let te=R.contextLabels[W],ue=I(W,te),Ce=Object.values(R.elements).filter((Me)=>Me.context===W),ge=pA.map((Me)=>({kind:Me,nodes:Ce.filter((Fe)=>Fe.kind===Me).sort((Fe,tt)=>Fe.name.localeCompare(tt.name)).map((Fe)=>z(Fe,ue)).filter((Fe)=>Fe!==null)})).filter((Me)=>Me.nodes.length),ne=ue&&P(x.get(W));if(!ge.length&&!ne)return null;if(ne)V++;let Ee=R.sharedContexts.includes(W),Re=y(`ctx:${W}`,!0);return E("div",{children:[_(W,`${xd(e.mode,W,te)}${Ee?` · ${t.sharedTag}`:""}`,{depth:0,visible:!0,open:Re,onToggle:()=>S(`ctx:${W}`,!0)},Ee?"shared":"context"),h(hT,{open:Re,children:ge.map(({kind:Me,nodes:Fe})=>{let tt=`grp:${W}:${Me}`,mn=y(tt,!0);return E("div",{children:[M(E(Y,{children:[t.kinds[Me],E("span",{className:"muted",children:[" ",Fe.length]})]}),{depth:1,visible:Re,open:mn,onToggle:()=>S(tt,!0)}),h(hT,{open:mn,children:Fe.map((oe)=>oe(Re&&mn))})]},Me)})})]},W)}function z(R,W){let te=W||I(R.name,R.label),ue=(Fe)=>(te||I(Fe.name,Fe.label))&&P(x.get(Fe.id)),Ce=(R.states??[]).filter(ue),ge=(R.commands??[]).filter(ue),ne=te&&P(x.get(R.id));if(!Ce.length&&!ge.length&&!ne)return null;V+=Ce.length+ge.length+(ne?1:0);let Ee=!!(R.states?.length||R.commands?.length),Re=`agg:${R.id}`,Me=y(Re,!1);return(Fe)=>E("div",{children:[_(R.id,xd(e.mode,R.name,R.label),{depth:2,visible:Fe,...Ee&&{open:Me,onToggle:()=>S(Re,!1)}},R.kind,R.persistent&&h("span",{className:"tree-persistent",title:t.persistentHint,children:h(dv,{size:11})})),Ee&&E(hT,{open:Me,children:[Ce.map((tt)=>h("div",{children:_(tt.id,`◇ ${xd(e.mode,tt.name,tt.label)}`,{depth:3,visible:Fe&&Me},"state")},tt.id)),ge.map((tt)=>h("div",{children:_(tt.id,`${tt.factory?"+":"▶"} ${xd(e.mode,tt.name,tt.label)}`,{depth:3,visible:Fe&&Me},"command")},tt.id))]})]},R.id)}function j(R,W,te){if(R.kind==="file"){let Ee=C([R.path]),Re={severity:Ee.errors?"error":Ee.warnings?"warning":void 0,change:v.has(R.path)?"changed":void 0};if(!(I(R.path)&&P(Re)))return null;D++;let Me=hA(R.path),Fe=e.selected===Me;return E("div",{ref:Fe&&te?k:void 0,className:`tree-item${Fe?" selected":""}`,style:{paddingLeft:8+W*14},onClick:()=>e.onSelect(Me),title:R.path,children:[h(A9,{row:{depth:W,visible:te}}),h("span",{className:"tree-text",children:R.name}),Re.change&&h("span",{className:"tree-change tree-change-changed",title:t.changed}),N(Ee)]},R.path)}let ue=`dir:${R.path}`,Ce=y(ue,!0),ge=R.children.map((Ee)=>j(Ee,W+1,te&&Ce)).filter(Boolean);if(!ge.length)return null;return E("div",{children:[M(E(Y,{children:[h(Ce?hv:mv,{size:14,className:"tree-folder","aria-hidden":!0}),h("span",{className:"tree-text",title:R.path,children:R.name}),N(C(L9(R)))]}),{depth:W,visible:te,open:Ce,onToggle:()=>S(ue,!0)},"tree-item tree-dir"),h(hT,{open:Ce,children:ge})]},ue)}}function A9({row:e}){if(!e.onToggle)return h("span",{className:"tree-twisty"});let t=e.onToggle;return h("span",{className:`tree-twisty${e.open?" open":""}`,onClick:(n)=>{n.stopPropagation(),t()},children:h(sy,{size:14,"aria-hidden":!0})})}function She({title:e,hits:t,open:n,onToggle:o,children:r}){return E("section",{className:"explorer-section",children:[E("button",{type:"button",className:"pane-title explorer-section-title",onClick:o,"aria-expanded":n,children:[h("span",{className:`tree-twisty${n?" open":""}`,children:h(sy,{size:14,"aria-hidden":!0})}),e,t!==void 0&&h("span",{className:"explorer-section-hits",children:t})]}),h(hT,{open:n,children:r})]})}function hT({open:e,children:t}){return h("div",{className:`tree-children${e?" open":""}`,inert:!e,children:h("div",{className:"tree-children-inner",children:t})})}function vA({view:e,open:t,onToggle:n}){let o=Kt(),r=o.legendRows,i=e==="contextMap"?[{kind:"references",text:r.mapReferences},{kind:"dependsOn",text:r.mapDependsOn}]:e==="structureFocus"?[{kind:"owns",text:r.owns},{kind:"references",text:r.focusReferences},{kind:"value",text:r.focusValue}]:e==="aggregates"||e==="aggregatesFocus"?[{kind:"references",text:r.aggregateReferences},{kind:"value",text:r.aggregateValue}]:e==="structure"?[{kind:"owns",text:r.owns},{kind:"references",text:r.references},{kind:"value",text:r.value}]:[{kind:"transition",text:r.transition}];return E(Y,{children:[E("div",{className:`legend${t?"":" legend-closed"}`,inert:!t,children:[E("div",{className:"legend-title",children:[o.legend,h("button",{className:"icon-button",onClick:n,"data-tooltip":o.closeLegend,"aria-label":o.closeLegend,children:h(lv,{size:14,"aria-hidden":!0})})]}),i.map((s)=>E("div",{className:"legend-row",children:[E("svg",{width:"56",height:"14",className:`de de-${s.kind}`,"aria-hidden":!0,children:[h("path",{d:"M4,7 L42,7",className:"de-line"}),s.kind==="owns"&&h("path",{d:"M2,7 L9,3.5 L16,7 L9,10.5 Z",className:"de-head de-diamond"}),h("path",{d:"M54,7 L41,0.5 L41,13.5 Z",className:"de-head"})]}),h("span",{children:s.text})]},s.kind)),e==="structureFocus"&&h("div",{className:"legend-note",children:o.stubNote}),e==="aggregatesFocus"&&h("div",{className:"legend-note",children:o.aggregateStubNote}),e==="states"&&h("div",{className:"legend-note",children:o.internalNote}),h("div",{className:"legend-note",children:o.arrowNote})]}),h("button",{className:`legend-tab${t?"":" shown"}`,inert:t,onClick:n,"data-tooltip":o.openLegend,"aria-label":o.openLegend,children:h(cv,{size:14,"aria-hidden":!0})})]})}var xhe=(e,t)=>e[e.length-1]===t?e:[...e,t];function R9(e,t){for(let n=e.length-2;n>=0;n--)if(t(e[n]))return n;return-1}function vhe(e,t){let n=R9(e,t);return n<0?e:e.slice(0,n+1)}q();function whe(e,t){let n=(o,r)=>r?[`${o} ${r}`]:[];return rA({ja:[...n("ID",e),...n("型",t)].join(" · "),en:[...n("ID",e),...n("type",t)].join(" · ")})}q();var uUe=new Set(["shared","context","terms","id","primitive","enum","value","union","by","entity","aggregate","state","owns","references","create","command","emits","errors","persistent","event","error","invariant","fields","with","and","or","not","implies","in","count","exists","all","any","length","matches","true","false"]),dUe=new Set(["String","Int","Decimal","Bool","Timestamp","UUID"]),fUe=/(\/\*[\s\S]*?\*\/)|(\/\/\/[^\n]*)|(\/\/[^\n]*)|("(?:\\.|[^"\\\n])*"?)|(\b\d+(?:\.\d+)?\b)|([A-Za-z_]\w*)|(\s+|[^\sA-Za-z_\d"/]+|\/)/g;function Che(e){let t=[[]],n=(o,r)=>{r.split(`
|
|
553
553
|
`).forEach((s,a)=>{if(a>0)t.push([]);if(s)t[t.length-1].push({kind:o,text:s})})};for(let o of e.matchAll(fUe)){let[r,i,s,a,l,c,u]=o;if(i||a)n("comment",r);else if(s)n("doc",r);else if(l)n("string",r);else if(c)n("number",r);else if(u){let f=o.index+r.length,d=/^\s*:/.test(e.slice(f,f+16));n(uUe.has(u)&&!d?"keyword":dUe.has(u)?"primitive":/^[A-Z]/.test(u)?"type":"name",r)}else n("plain",r)}return t}function The(e){if(!e)return[];let t=[];for(let n of Object.values(e.elements)){t.push({id:n.id,...n.location});for(let o of n.states??[])t.push({id:o.id,...o.location});for(let o of n.commands??[])t.push({id:o.id,...o.location})}return t}function Ihe(e,t){return The(e).find((n)=>n.id===t)}function pUe(e,t){return e.split(/\r?\n/).slice(t.line-1,t.endLine??t.line).join(`
|
|
554
554
|
`)}function hUe({text:e}){let t=Kt(),[n,o]=G(!1);return h("button",{className:"icon-button src-copy","data-tooltip":t.copyCode,"aria-label":t.copyCode,onClick:async(r)=>{r.stopPropagation();try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1200)}catch{}},children:n?h(av,{size:14}):h(uv,{size:14})})}function mUe(e){let t=[];for(let n=e.from;n<=e.to&&n<=e.lines.length;n++){let o=e.diagnostics?.get(n)??[],r=o.some((s)=>s.severity==="error")?"error":o.length?"warning":void 0,i=e.focus&&n>=e.focus.line&&n<=(e.focus.endLine??e.focus.line);t.push(E("div",{ref:(s)=>e.lineRef?.(n,s),className:`src-line${i?" src-focus":""}${r?` src-${r}`:""}${e.onLineClick?" src-clickable":""}`,onClick:()=>e.onLineClick?.(n),title:o.map((s)=>`${s.code}: ${s.message}`).join(`
|
|
555
555
|
`)||void 0,children:[E("span",{className:"src-gutter",children:[h("span",{className:"src-mark",children:r==="error"?"✕":r==="warning"?"!":""}),n]}),E("span",{className:"src-code",children:[e.lines[n-1].map((s,a)=>h("span",{className:`tok-${s.kind}`,children:s.text},a)),`
|
|
556
|
-
`]}),n===e.focus?.line&&e.focusAction]},n))}return h("pre",{className:"src-code-block",children:t})}function D9(e){let t=Kt(),n=e.file??e.sources[0]?.path,o=e.sources.find((f)=>f.path===n),r=le(()=>o?Che(o.text):[],[o]),i=L(new Map);F(()=>{if(!e.focus||e.focus.file!==n)return;i.current.get(e.focus.line)?.scrollIntoView({block:"center"})},[e.focus,n]);let s=new Map;for(let f of e.diagnostics.filter((d)=>d.file===n))for(let d=f.start.line;d<=f.end.line;d++)s.set(d,[...s.get(d)??[],f]);let a=The(e.model).filter((f)=>f.file===n),l=(f)=>{let d=a.filter((p)=>p.line<=f&&f<=p.endLine).sort((p,m)=>p.endLine-p.line-(m.endLine-m.line))[0];if(d)e.onSelect(d.id)},c=e.focus?.file===n?e.focus:void 0,u=c&&o?pUe(o.text,c):void 0;if(!o)return h("p",{className:"muted pad",children:t.noDtFiles});return h("div",{className:"source-view",children:h(mUe,{lines:r,from:1,to:r.length,focus:c,focusAction:u!==void 0&&h(hUe,{text:u}),diagnostics:s,onLineClick:l,lineRef:(f,d)=>d?i.current.set(f,d):i.current.delete(f)})})}var Lhe=Oe(vd("both",null)),Lc=()=>Te(Lhe);function gUe(e){switch(e.kind){case"context":return["structure"];case"state":return["structure","states","behavior","source"];case"command":return["structure","states","behavior","source"];case"element":return e.el.kind==="aggregate"?["structure","states","behavior","events","references","source"]:["structure","references","source"]}}function Phe(e){let t=[];if(e.kind==="element"){if(e.el.kind==="aggregate"||e.el.kind==="entity"||e.el.kind==="valueObject"||e.el.kind==="union")t.push("structure");if(mA(e.el.kind))t.push("catalog")}else if(e.kind==="context")t.push("contextMap","structure");return t}function Ahe(e){let{model:t,selected:n}=e,o=Kt(),r=e.backTo&&(Yb(e.backTo)??vd(e.mode,t).id(e.backTo)),i=E("div",{className:"history",children:[r&&E("button",{className:"back-button",onClick:e.onBack,"data-tooltip":o.backTo(r),"aria-label":o.backTo(r),children:[h(Cv,{size:14,"aria-hidden":!0}),h("span",{className:"back-name",children:r})]}),h("button",{className:"icon-button close-button",onClick:e.onClose,"data-tooltip":o.closeInspector,"aria-label":o.closeInspector,children:h(xv,{size:16,"aria-hidden":!0})})]}),s=Yb(n);if(s)return E("div",{className:"inspector",children:[E("div",{className:"inspector-head",children:[i,h("div",{className:"inspector-row",children:h("span",{className:"kind kind-file",children:o.fileKind})}),h("h2",{children:s}),h(Mhe,{items:e.diagnostics.filter((g)=>g.file===s)})]}),h("div",{className:"inspector-body inspector-body-full",children:h(D9,{sources:e.sources,diagnostics:e.diagnostics,model:t,file:s,focus:e.sourceFocus?.file===s?e.sourceFocus:void 0,onSelect:e.onSelect})})]});if(!t)return h("div",{className:"inspector",children:E("div",{className:"inspector-head",children:[i,h("p",{className:"muted",children:o.noModel})]})});let a=n?Wb(t,n):void 0;if(!n||!a)return h("div",{className:"inspector",children:E("div",{className:"inspector-head",children:[i,h("p",{className:"muted",children:n?o.notInModel(n):o.pickElement})]})});let l=vd(e.mode,t),c=gUe(a),u=c.includes(e.tab)?e.tab:c[0],f=e.diagnostics.filter((g)=>g.elementId===n||a.kind==="element"&&g.elementId&&Al(g.elementId)===n),d=e.diff.added.includes(n)?"added":e.diff.changed.includes(n)?"changed":void 0,p=Rhe(a),m=l.of({name:p.name,label:p.label});return h(Lhe.Provider,{value:l,children:E("div",{className:"inspector",children:[E("div",{className:"inspector-head",children:[i,E("div",{className:"inspector-row",children:[h("span",{className:`kind kind-${p.kind}`,children:o.kinds[p.kind]}),a.kind==="context"&&a.shared&&h("span",{className:"shared-badge",children:o.shared}),a.kind==="element"&&a.el.kind==="event"&&h(dT,{persistent:!!a.el.persistent,tx:o}),d&&h("span",{className:`change change-${d}`,children:d==="added"?o.added:o.changed})]}),h("h2",{children:e.mode==="both"&&p.label?p.label:m}),e.mode==="both"&&p.label&&h("div",{className:"canonical-name",children:p.name}),p.doc&&h("p",{className:"doc",children:p.doc}),Phe(a).length>0&&E("div",{className:"reveal",children:[h("span",{className:"muted small",children:o.showIn}),Phe(a).map((g)=>h("button",{onClick:()=>e.onReveal(g,n),children:o.reveal[g]},g))]}),h(Mhe,{items:f})]}),c.length>1&&h("div",{className:"subtabs",role:"tablist",children:c.map((g)=>h("button",{role:"tab","aria-selected":g===u,className:g===u?"active":"",onClick:()=>e.onTab(g),children:o.tabs[g]},g))}),h("div",{className:`inspector-body${u==="source"||u==="states"?" inspector-body-full":""}`,children:h(yUe,{...e,r:a,tab:u})})]})})}function Rhe(e){switch(e.kind){case"context":return{kind:"context",name:e.name,label:e.label};case"element":return{kind:e.el.kind,name:e.el.id,label:e.el.label,doc:e.el.doc,location:e.el.location};case"state":return{kind:"state",name:`${e.agg.name}.${e.state.name}`,label:e.state.label,doc:e.state.doc,location:e.state.location};case"command":return{kind:"command",name:`${e.agg.name}.${e.command.name}`,label:e.command.label,doc:e.command.doc,location:e.command.location}}}function yUe(e){let{r:t,tab:n,model:o,onSelect:r}=e,i=Lc(),s=Kt();if(!o)return null;if(n==="source"){let l=Rhe(t).location;if(!l)return null;let c=e.sourceFocus?.file===l.file?e.sourceFocus:l;return h(D9,{sources:e.sources,diagnostics:e.diagnostics,model:o,file:l.file,focus:c,onSelect:r})}if(n==="states")return e.statesView(t.kind==="element"?t.el.id:t.kind==="context"?t.name:t.agg.id);if(t.kind==="context")return h(SUe,{model:o,ctx:t.name,onSelect:r,onFocus:e.onFocusContext});if(t.kind==="state"){let{agg:l,state:c}=t;if(n==="behavior"){let u=(l.commands??[]).filter((d)=>d.to.includes(c.name)),f=(l.commands??[]).filter((d)=>d.from.includes(c.name));return E(Y,{children:[h(O9,{title:s.commandsInto,agg:l,model:o,commands:u,onSelect:r}),h(O9,{title:s.commandsOutOf,agg:l,model:o,commands:f,onSelect:r})]})}return E(Y,{children:[h(wA,{title:s.stateFields,fields:c.fields,ctx:l.context,onSelect:r,empty:s.noStateFields}),h(CA,{items:c.invariants,title:s.stateInvariants,labelOnly:!0}),h("p",{className:"muted small",children:s.commonFieldsAt(h("a",{onClick:()=>r(l.id),children:i.of(l)}))})]})}if(t.kind==="command"){let{agg:l,command:c}=t;if(n==="behavior")return E(Y,{children:[h(ti,{title:s.transition,children:h("code",{className:"block",children:i.transition(l,c)||s.noStates})}),h(ti,{title:s.mayRaise,children:c.emits.length?c.emits.map((u)=>h(Ehe,{model:o,id:u,onSelect:r},u)):h("span",{className:"muted",children:s.none})}),h(ti,{title:s.mayReturn,children:c.errors.length?c.errors.map((u)=>h(Ehe,{model:o,id:u,onSelect:r},u)):h("span",{className:"muted",children:s.none})})]});return E(Y,{children:[h(wA,{title:s.params,fields:c.params,ctx:l.context,onSelect:r,empty:s.noParams}),h(ti,{title:s.contract,children:E("code",{className:"block",children:[c.factory?"create ":"","command ",c.name,"(",c.params.map((u)=>`${u.name}: ${vd("name",o).type(u.type,l.context)}${u.multiplicity}`).join(", "),")"]})})]})}let a=t.el;if(n==="behavior")return E(Y,{children:[h(O9,{title:s.counted(s.commands,a.commands?.length??0),agg:a,model:o,commands:a.commands??[],onSelect:r}),h(_he,{agg:a,model:o,kind:"errors",onSelect:r})]});if(n==="events")return h(_he,{agg:a,model:o,kind:"emits",onSelect:r});if(n==="references")return h(bUe,{model:o,el:a,onSelect:r});return E(Y,{children:[a.base&&E("p",{children:[a.kind==="id"?s.identifier:s.kinds.primitive,s.separator,s.baseType,": ",h("code",{children:i.primitive(a.base)})]}),a.values&&h(ti,{title:s.values,children:h("div",{className:"chips",children:a.values.map((l)=>E("code",{children:[i.mode==="both"?l:i.of({name:l,label:a.valueLabels?.[l]}),i.mode==="both"&&a.valueLabels?.[l]&&E("span",{className:"muted",children:[" ",a.valueLabels[l]]})]},l))})}),a.kind==="union"&&E(Y,{children:[E("p",{children:[s.discriminator,": ",h("code",{children:a.discriminator}),a.tagType&&E(Y,{children:[s.separator,s.values,": ",h("a",{onClick:()=>r(a.tagType),children:i.id(a.tagType)})]})]}),(a.variants??[]).map((l)=>E("div",{title:l.doc,children:[h(wA,{title:`${i.of(l)}`,fields:l.fields,ctx:a.context,onSelect:r,empty:s.noFields}),h(CA,{items:l.invariants,title:s.variantInvariants(i.of(l))})]},l.name))]}),a.kind!=="id"&&a.kind!=="primitive"&&a.kind!=="enum"&&a.kind!=="union"&&h(wA,{title:a.states?.length?s.commonFields:a.kind==="event"||a.kind==="error"?s.payload:s.fields,fields:a.fields,ctx:a.context,onSelect:r,empty:s.noFields}),(a.kind==="aggregate"||a.kind==="entity"||a.kind==="valueObject")&&h(CA,{items:a.invariants,title:a.states?.length?s.allStateInvariants:s.invariants,labelOnly:a.kind==="aggregate"}),(a.kind==="id"||a.kind==="primitive")&&h(CA,{items:a.invariants,title:s.valueInvariants}),a.states&&a.states.length>0&&h(ti,{title:s.counted(s.states,a.states.length),children:a.states.map((l)=>E("div",{className:"sub",children:[h("a",{onClick:()=>r(l.id),children:i.of(l)}),l.fields.length>0&&E("span",{className:"muted small",children:[" ",l.fields.map((c)=>i.field(c)).join(", ")]})]},l.id))})]})}function khe({title:e,groups:t,other:n,onSelect:o}){let r=Lc(),i=Kt(),s=Gpe();if(t.length===0)return null;return h(ti,{title:i.counted(e,t.length),children:t.map((a)=>E("details",{className:"deps",children:[E("summary",{children:[h("a",{onClick:()=>o(n(a)),children:r.id(n(a))}),E("span",{className:"muted small",children:[" ",whe(a.ids,a.types)[s][r.mode]]})]}),a.uses.map((l,c)=>E("div",{className:"sub small",children:[h("a",{onClick:()=>o(l.source),children:r.id(l.source)}),E("span",{className:"muted",children:[".",l.path," → "]}),h("a",{onClick:()=>o(l.target),children:r.id(l.target)}),h("span",{className:`dep-kind dep-${l.kind}`,children:l.kind==="id"?"ID":i.typeDependency})]},c))]},n(a)))})}function SUe({model:e,ctx:t,onSelect:n,onFocus:o}){let r=Lc(),i=Kt(),s=Object.values(e.elements).filter((c)=>c.context===t),a=e.terms[t]??[],l=k9(cA(e));return E(Y,{children:[!uA(e).has(t)&&h("p",{children:h("button",{onClick:()=>o(t),children:i.focusContext})}),h(khe,{title:i.dependencies,groups:l.filter((c)=>c.from===t),other:(c)=>c.to,onSelect:n}),h(khe,{title:i.dependents,groups:l.filter((c)=>c.to===t),other:(c)=>c.from,onSelect:n}),pA.map((c)=>{let u=s.filter((f)=>f.kind===c);if(!u.length)return null;return h(ti,{title:i.counted(i.kinds[c],u.length),children:u.map((f)=>h("div",{className:"sub",children:h("a",{onClick:()=>n(f.id),children:r.of(f)})},f.id))},c)}),a.length>0&&h(ti,{title:i.terms,children:h("table",{className:"fields",children:h("tbody",{children:a.map((c)=>E("tr",{children:[h("td",{className:"flabel",children:c.label}),h("td",{className:"fname",children:c.name}),h("td",{className:"muted",children:c.doc})]},c.name))})})})]})}function bUe({model:e,el:t,onSelect:n}){let o=Lc(),r=Kt(),i=Xb(e,t.id,o.of),s=t.fields.find((u)=>u.name==="id"&&u.type.kind==="ref")?.type,a=t.kind==="aggregate"&&s?.kind==="ref"?Xb(e,s.ref,o.of).filter((u)=>u.target!==t.id):[],l=Object.values(e.elements).flatMap((u)=>(u.commands??[]).filter((f)=>f.emits.includes(t.id)||f.errors.includes(t.id)).map((f)=>({agg:u,c:f}))),c=t.kind==="fieldSet"?gA(e,t.id):[];if(!i.length&&!a.length&&!l.length&&!c.length)return h("p",{className:"muted",children:r.unreferenced});return E(Y,{children:[c.length>0&&h(ti,{title:r.fieldSetUsers(c.length),children:c.map((u)=>E("div",{className:"sub",children:[h("a",{onClick:()=>n(u.id),children:o.id(u.id)}),E("span",{className:"muted small",children:[" ",r.kinds[u.kind]]})]},u.id))}),l.length>0&&h(ti,{title:t.kind==="event"?r.raisedBy:r.returnedBy,children:l.map(({agg:u,c:f})=>h("div",{className:"sub",children:E("a",{onClick:()=>n(f.id),children:[o.of(u),".",o.of(f)]})},f.id))}),i.length>0&&h(ti,{title:r.typeUses(i.length),children:i.map((u)=>h("div",{className:"sub",children:h("a",{onClick:()=>n(u.target),children:u.text})},u.key))}),a.length>0&&h(ti,{title:r.idUses(s.kind==="ref"?o.id(s.ref):"",a.length),children:a.map((u)=>h("div",{className:"sub",children:h("a",{onClick:()=>n(u.target),children:u.text})},u.key))})]})}function O9({title:e,agg:t,model:n,commands:o,onSelect:r}){let i=Lc(),s=Kt();return E(ti,{title:e,children:[o.length===0&&h("span",{className:"muted",children:s.none}),o.map((a)=>h(che,{agg:t,c:a,model:n,names:i,tx:s,onSelect:r},a.id))]})}var xUe=(e,t)=>t.fields.map((n)=>`${e.field(n)}: ${e.type(n.type,t.context)}${n.multiplicity}`).join(", ");function Ehe({model:e,id:t,onSelect:n}){let o=Lc(),r=e.elements[t];return E("div",{className:"event-row",children:[h("a",{onClick:()=>n(t),children:o.id(t)}),r&&r.fields.length>0&&h("div",{className:"muted small mono",children:xUe(o,r)})]})}function _he({agg:e,model:t,kind:n,onSelect:o}){let r=Lc(),i=Kt(),s=dhe(e.commands??[],n);if(s.size===0&&n==="errors")return null;return E(ti,{title:n==="emits"?i.raises(s.size):i.returns(s.size),children:[s.size===0&&h("span",{className:"muted",children:i.none}),[...s].map(([a,l])=>h(uhe,{id:a,commands:l,model:t,names:r,tx:i,onSelect:o},a))]})}function Mhe({items:e}){if(e.length===0)return null;return h("div",{className:"inspector-diags",children:e.map((t,n)=>E("div",{className:`diag diag-${t.severity}`,children:[h("code",{children:t.code})," ",t.message]},n))})}function ti({title:e,children:t}){return E("section",{children:[h("h3",{children:e}),t]})}function wA({title:e,fields:t,ctx:n,onSelect:o,empty:r}){let i=Lc(),s=Kt();if(t.length===0)return r?h(ti,{title:e,children:h("span",{className:"muted",children:r})}):null;let a=(l)=>l.kind==="owns"?"◆ ":l.kind==="references"?"→ ":"";return h(ti,{title:e,children:h("table",{className:"fields",children:h("tbody",{children:t.map((l)=>E("tr",{title:l.doc,children:[i.mode==="both"&&E("td",{className:"flabel",children:[l.label,l.labelSource&&l.labelSource!=="inline"&&h("span",{className:"label-src",children:s.labelSources[l.labelSource]})]}),E("td",{className:i.mode==="label"?"flabel":"fname",children:[a(l),i.mode==="both"?l.name:i.field(l)]}),E("td",{children:[l.type.kind==="ref"&&l.type.target?h("a",{onClick:()=>o(l.type.ref),children:i.type(l.type,n)}):i.type(l.type,n),l.multiplicity,l.target&&E(Y,{children:[" ","→"," ",h("a",{className:"ref",onClick:()=>o(l.target),children:i.id(l.target)})]}),l.fieldSet&&h(vUe,{id:l.fieldSet,onSelect:o})]})]},l.name))})})})}function vUe({id:e,onSelect:t}){let n=Lc(),o=Kt();return h("a",{className:"field-origin",onClick:()=>t(e),"data-tooltip":o.fromFieldSet(n.id(e)),children:n.short(e)})}function CA({items:e,title:t,labelOnly:n}){let o=Lc();if(e.length===0)return null;return h(ti,{title:t,children:e.map((r)=>{let i=n&&!!r.label;return E("div",{className:"sub",children:[h("strong",{children:o.of(r)}),!i&&r.doc&&h("p",{className:"doc",children:r.doc}),!i&&h("code",{className:"block",children:r.source})]},r.name)})})}q();var F9=$s("none","added","changed","removed"),B9=$s("none","warning","error");class Dhe extends Yr{static type="domain-node";static props={w:Se,h:Se,kind:Ne,scale:Se,label:Ne,stereotype:Ne,rows:ur(Ye({k:Ne,v:Ne,o:Ne.optional()})),compartment:Se,change:F9,diag:B9};getDefaultProps(){return{w:160,h:60,kind:"entity",label:"",stereotype:"",scale:1,rows:[],compartment:0,change:"none",diag:"none"}}canResize=()=>!1;hideRotateHandle=()=>!0;hideResizeHandles=()=>!0;canEdit=()=>!1;component(e){let t=e.props;return h(Gr,{className:`dn dn-${t.kind} dn-change-${t.change} dn-diag-${t.diag}`,style:{width:t.w,height:t.h,["--s"]:t.scale},children:t.kind==="initial"?h("div",{className:"dn-initial",children:t.label}):E(Y,{children:[E("div",{className:"dn-head",children:[t.stereotype&&h("div",{className:"dn-stereo",children:t.stereotype}),h("div",{className:"dn-label",children:t.label})]}),t.rows.length>0&&h("div",{className:"dn-body",children:t.rows.map((n,o)=>n.v?E(Cr,{children:[h("span",{className:"dn-key",children:n.k}),E("span",{className:"dn-value",children:[n.v,n.o&&h("span",{className:"dn-origin",children:n.o})]})]},o):h("span",{className:"dn-key dn-full",children:n.k},o))}),t.compartment>0&&h("div",{className:"dn-compartment",style:{height:t.compartment}}),t.change!=="none"&&h(IUe,{change:t.change}),t.diag!=="none"&&h("div",{className:"dn-diag",children:t.diag==="error"?"✕":"!"})]})})}getIndicatorPath(e){return z9(e.props.w,e.props.h,8)}}class Ohe extends Yr{static type="domain-internal";static props={w:Se,h:Se,label:Ne,sub:Ne,faded:st,scale:Se,change:F9,diag:B9};getDefaultProps(){return{w:160,h:21,label:"",sub:"",faded:!1,scale:1,change:"none",diag:"none"}}canResize=()=>!1;hideRotateHandle=()=>!0;hideResizeHandles=()=>!0;canEdit=()=>!1;component(e){let t=e.props;return E(Gr,{className:`di di-change-${t.change} di-diag-${t.diag}`,style:{width:t.w,height:t.h,["--s"]:t.scale},children:[E("div",{className:`di-main${t.faded?" di-faded":""}`,children:["↻ ",t.label]}),t.sub&&h("div",{className:"di-sub",children:t.sub}),t.diag!=="none"&&h("div",{className:"di-diag",children:t.diag==="error"?"✕":"!"})]})}getIndicatorPath(e){return z9(e.props.w,e.props.h,4)}}class Nhe extends Yr{static type="domain-group";static props={w:Se,h:Se,kind:Ne,scale:Se,label:Ne,lines:ur(Ne),change:F9,diag:B9};getDefaultProps(){return{w:200,h:100,kind:"context",label:"",lines:[],scale:1,change:"none",diag:"none"}}canResize=()=>!1;hideRotateHandle=()=>!0;hideResizeHandles=()=>!0;canEdit=()=>!1;component(e){let t=e.props;return E(Gr,{className:`dg dg-${t.kind} dn-change-${t.change} dn-diag-${t.diag}`,style:{width:t.w,height:t.h,["--s"]:t.scale},children:[h("div",{className:"dg-label",children:t.label}),t.lines.length>0&&h("div",{className:"dg-desc",children:t.lines.map((n,o)=>h("div",{children:n},o))})]})}getIndicatorPath(e){return z9(e.props.w,e.props.h,12)}}class Fhe extends Bo{static type="domain-edge";static props={points:ur(Ye({x:Se,y:Se})),kind:Ne,scale:Se,label:Ne,sub:Ne,faded:st,lx:Se,ly:Se,lw:Se,lh:Se,tone:$s("normal","added","changed","error")};getDefaultProps(){return{points:[],kind:"owns",label:"",sub:"",faded:!1,scale:1,lx:0,ly:0,lw:0,lh:0,tone:"normal"}}canResize=()=>!1;hideRotateHandle=()=>!0;hideResizeHandles=()=>!0;canEdit=()=>!1;canBind=()=>!1;getGeometry(e){let t=e.props.points.length>=2?e.props.points:[{x:0,y:0},{x:1,y:1}];return new ps({points:t.map((n)=>new T(n.x,n.y))})}component(e){let{points:t,kind:n,label:o,sub:r,faded:i,lx:s,ly:a,lw:l,lh:c,tone:u,scale:f}=e.props;if(t.length<2)return null;let d=t.map((S,b)=>`${b?"L":"M"}${S.x},${S.y}`).join(" "),[p,m]=[t[t.length-2],t[t.length-1]],[g,y]=[t[0],t[1]];return E(qr,{className:`de de-${n} de-tone-${u}`,children:[h("path",{d,className:"de-hit"}),h("path",{d,className:"de-line"}),n==="owns"?h("path",{d:TUe(g,y),className:"de-head de-diamond"}):null,h("path",{d:CUe(p,m),className:"de-head"}),o&&l>0&&h(wUe,{label:o,sub:r,faded:i,lx:s,ly:a,lw:l,lh:c,scale:f})]})}getIndicatorPath(e){let t=new Path2D;return e.props.points.forEach((n,o)=>o?t.lineTo(n.x,n.y):t.moveTo(n.x,n.y)),t}}function wUe({label:e,sub:t,faded:n,lx:o,ly:r,lw:i,lh:s,scale:a}){let l=o+i/2,c=r+(s-(iA+(t?sA:0))*a)/2;return E(Y,{children:[h("text",{x:l,y:c+iA/2*a,className:`de-label${n?" de-faded":""}`,style:{fontSize:13*a},textAnchor:"middle",dominantBaseline:"central",children:e}),t&&h("text",{x:l,y:c+(iA+sA/2)*a,className:"de-label de-sub",style:{fontSize:13*x9*a},textAnchor:"middle",dominantBaseline:"central",children:t})]})}function Bhe(e,t){let n=Math.hypot(t.x-e.x,t.y-e.y)||1;return{x:(t.x-e.x)/n,y:(t.y-e.y)/n}}var N9=13;function CUe(e,t){let n=Bhe(e,t),o={x:-n.y,y:n.x},r={x:t.x-n.x*N9,y:t.y-n.y*N9},i=N9/2;return`M${t.x},${t.y} L${r.x+o.x*i},${r.y+o.y*i} L${r.x-o.x*i},${r.y-o.y*i} Z`}function TUe(e,t){let n=Bhe(e,t),o={x:-n.y,y:n.x},r={x:e.x+n.x*7,y:e.y+n.y*7},i={x:e.x+n.x*14,y:e.y+n.y*14};return`M${e.x},${e.y} L${r.x+o.x*4.5},${r.y+o.y*4.5} L${i.x},${i.y} L${r.x-o.x*4.5},${r.y-o.y*4.5} Z`}function z9(e,t,n){let o=new Path2D;return o.roundRect(0,0,e,t,n),o}function IUe({change:e}){let t=Kt();return h("div",{className:"dn-badge",children:t[e]})}var TA=[Dhe,Nhe,Ohe,Fhe];q();var PUe=["auto","light","dark"],kUe=["auto","ja","en"];function zhe(e){let{mode:t,onMode:n,themePreference:o,theme:r,onTheme:i,langPreference:s,lang:a,onLang:l}=e,c=Kt(),[u,f]=G(!1),d=L(null);return F(()=>{let p=d.current;if(!p)return;if(u&&!p.open)p.showModal();else if(!u&&p.open)p.close()},[u]),E("div",{className:"settings",children:[h("button",{className:"icon-button","aria-haspopup":"dialog","aria-expanded":u,"aria-label":c.settings,"data-tooltip":c.settings,onClick:()=>f(!0),children:h(wv,{size:16,"aria-hidden":!0})}),E("dialog",{ref:d,className:"settings-dialog","aria-labelledby":"settings-title",onClose:()=>f(!1),onClick:(p)=>p.target===p.currentTarget&&f(!1),children:[E("div",{className:"settings-dialog-header",children:[h("h2",{id:"settings-title",children:c.settings}),h("button",{className:"icon-button","aria-label":c.closeSettings,"data-tooltip":c.closeSettings,onClick:()=>f(!1),children:h(Xc,{size:18,"aria-hidden":!0})})]}),E("div",{className:"settings-dialog-body",children:[h(U9,{id:"settings-names",caption:c.nameDisplay,hint:c.nameDisplayHint,children:oA.map((p)=>h("button",{className:t===p?"active":"","aria-pressed":t===p,onClick:()=>n(p),children:c.modes[p]},p))}),h(U9,{id:"settings-theme",caption:c.theme,hint:o==="auto"?c.themeAuto(c.themes[r]):c.themeHint,children:PUe.map((p)=>h("button",{className:o===p?"active":"","aria-pressed":o===p,onClick:()=>i(p),children:c.themes[p]},p))}),h(U9,{id:"settings-lang",caption:c.language,hint:s==="auto"?c.langAuto(I9[a]):c.langHint,children:kUe.map((p)=>h("button",{className:s===p?"active":"","aria-pressed":s===p,onClick:()=>l(p),children:p==="auto"?c.themes.auto:I9[p]},p))})]})]})]})}function U9(e){return E("div",{className:"settings-row",children:[E("div",{className:"settings-text",children:[h("div",{className:"settings-caption",id:e.id,children:e.caption}),h("div",{className:"settings-hint",children:e.hint})]}),h("div",{className:"segmented",role:"group","aria-labelledby":e.id,children:e.children})]})}q();q();var Hhe="domaintrail.theme",Uhe="(prefers-color-scheme: dark)";function Vhe(e){let[t,n]=G(()=>matchMedia(Uhe).matches);return F(()=>{let o=matchMedia(Uhe),r=(i)=>n(i.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),e==="auto"?t?"dark":"light":e}function IA(e,t){if(document.documentElement.dataset.theme=e,t&&t.user.getUserPreferences().colorScheme!==e)t.user.updateUserPreferences({colorScheme:e})}var jhe=new Map;function $he(e){let{aggregateId:t}=e,n=Kt(),[o,r]=G(null),[i,s]=Ao("domaintrail.states.transitionLabels","both"),a=b9.includes(i)?i:"both",l=e.graphs?.[a],c=e.previous?.[a],u=L(null);xA(o),F(()=>{IA(e.theme,o)},[e.theme,o]),F(()=>{if(!o)return;return zt("remember camera",()=>{let p=o.getCamera();if(u.current===t)jhe.set(t,p)})},[o,t]),F(()=>{if(!o)return;if(!l){cT(o,()=>o.deleteShapes([...o.getCurrentPageShapeIds()])),u.current=null;return}if(fA(o,l,{diff:e.diff,diagnostics:e.diagnostics,previous:c,mode:e.mode,lang:e.lang,transitionLabels:a}),u.current!==t){let p=jhe.get(t);if(p)o.setCamera(p);else M9(o,l);if(u.current=t,e.selected)pT(o,e.selected)}},[o,l,c,e.diff,e.diagnostics,e.mode,e.lang,a,t]),F(()=>{if(o&&e.selected&&u.current)pT(o,e.selected)},[o,e.selected]);let f=H("selected element",()=>{let p=o?.getOnlySelectedShape();return p&&o?dA(o,p.id):void 0},[o]);F(()=>{if(f&&f!==e.selected)e.onSelect(f)},[f]);let d=O((p)=>{p.updateInstanceState({isReadonly:!0}),r(p)},[]);return E("div",{className:"states-canvas",children:[h(rT,{shapeUtils:TA,hideUi:!0,onMount:d}),l?E(Y,{children:[E("div",{className:"canvas-toolbar",children:[h("div",{className:"segmented small",role:"group","aria-label":n.transitionLabels,children:b9.map((p)=>h("button",{className:a===p?"active":"","aria-pressed":a===p,onClick:()=>s(p),"data-tooltip":n.transitionLabelModes[p].hint,children:n.transitionLabelModes[p].label},p))}),h("button",{onClick:()=>o&&M9(o,l,!0),children:n.zoomToFit})]}),h(vA,{view:"states",open:e.legendOpen,onToggle:e.onLegendToggle})]}):h("div",{className:"empty",children:n.noDiagram})]})}q();var kA="data-tooltip",EUe=400,Ghe=6,PA=8;function _Ue(e,t,n){let o=e.bottom+Ghe,r=e.top-Ghe-t.height,i=o+t.height<=n.height-PA||r<PA?o:r,s=(e.left+e.right)/2-t.width/2,a=Math.max(PA,Math.min(s,n.width-PA-t.width));return{left:Math.round(a),top:Math.round(i)}}var H9=(e)=>e instanceof Element?e.closest(`[${kA}]`):null;function qhe(){let[e,t]=G(null),[,n]=G(0),[o,r]=G(null),i=L(null),s=e?.getAttribute(kA);if(F(()=>{let a,l=null,c=null,u=(S,b)=>{if(clearTimeout(a),c=S,!S||!b)t(S);else a=setTimeout(()=>t(S),b)},f=()=>u(null,0),d=(S)=>{if(S.pointerType==="touch")return;let b=H9(S.target);if(b===l)return;l=b,u(S.buttons?null:b,EUe)},p=(S)=>{let b=H9(S.target);if(b?.matches(":focus-visible"))u(b,0)},m=(S)=>{if(c&&c===H9(S.target)&&c!==l)f()},g=(S)=>{if(S.key==="Escape")f()},y=()=>{l=null,f()};return document.addEventListener("pointerover",d),document.addEventListener("pointerdown",f,!0),document.addEventListener("focusin",p),document.addEventListener("focusout",m),document.addEventListener("keydown",g,!0),document.addEventListener("scroll",f,!0),document.documentElement.addEventListener("pointerleave",y),window.addEventListener("blur",y),()=>{clearTimeout(a),document.removeEventListener("pointerover",d),document.removeEventListener("pointerdown",f,!0),document.removeEventListener("focusin",p),document.removeEventListener("focusout",m),document.removeEventListener("keydown",g,!0),document.removeEventListener("scroll",f,!0),document.documentElement.removeEventListener("pointerleave",y),window.removeEventListener("blur",y)}},[]),F(()=>{if(!e)return;let l=new MutationObserver(()=>{if(e.isConnected&&!e.closest("[inert]")&&e.getAttribute(kA))n((c)=>c+1);else t(null)});return l.observe(e,{attributes:!0,attributeFilter:[kA]}),l.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["inert"]}),()=>l.disconnect()},[e]),He(()=>{let a=i.current;if(!e||!a)return r(null);if(a.showPopover&&!a.matches(":popover-open"))a.showPopover();a.style.left="0px";let l=_Ue(e.getBoundingClientRect(),a.getBoundingClientRect(),{width:window.innerWidth,height:window.innerHeight});a.style.left=`${l.left}px`,r(l)},[e,s]),!e||!s)return null;return h("div",{ref:i,className:"tooltip",popover:"manual","aria-hidden":!0,style:o?{left:o.left,top:o.top}:{visibility:"hidden"},children:s})}q();function Khe(){let[e,t]=G({current:null,previous:null,connection:"connecting"}),n=L(0);return F(()=>{let o,r=!1,i,s=()=>{o=new WebSocket(`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws`),o.onopen=()=>{n.current=0,t((a)=>({...a,connection:"open"}))},o.onmessage=(a)=>{let l=JSON.parse(a.data);t((c)=>{let u=c.current&&c.current.modelVersion!==l.modelVersion;return{current:l,previous:u?c.current:c.previous,connection:"open"}})},o.onclose=()=>{if(r)return;t((a)=>({...a,connection:"closed"})),i=setTimeout(s,Math.min(5000,500*2**n.current++))}};return s(),()=>{r=!0,clearTimeout(i),o?.close()}},[]),e}var mT=28,Whe=33,MUe=320;function LUe(){try{let e=JSON.parse(localStorage.getItem("domaintrail.displayMode")??"null");return e==="ja"?"label":e==="en"?"name":"both"}catch{return"both"}}var ig=(e)=>e.kind==="contextMap"||e.kind==="structure",AUe={detail:yv,overview:gv,aggregates:sv},RUe={detail:"structure",overview:"overview",aggregates:"aggregates"};function Yhe(){let{current:e,previous:t,connection:n}=Khe(),o=e?.model??null,[r,i]=G(null),[s,a]=G({kind:"structure"}),[l,c]=Ao("domaintrail.nameDisplay",LUe()),[u,f]=Ao(Hhe,"auto"),d=Vhe(u),[p,m]=Ao(Hpe,"auto"),g=jpe(p),y=T9[g],[S,b]=Ao("domaintrail.structureMode","detail"),x=C9.includes(S)?S:"detail",[w,v]=Ao("domaintrail.structureContexts",null),[C,I]=Ao("domaintrail.structureHiddenContexts",[]),[P,k]=Ao("domaintrail.contextMapAll",!1),[_,M]=Ao("domaintrail.layout.explorer",!0),[N,V]=Ao("domaintrail.layout.inspector",!0),[D,K]=Ao("domaintrail.layout.bottom",!1),[U,A]=Ao("domaintrail.layout.explorerWidth",260),[z,j]=Ao("domaintrail.layout.inspectorWidth",420),[R,W]=Ao("domaintrail.layout.bottomHeight",220),[te,ue]=Ao("domaintrail.layout.bottomTab","problems"),[Ce,ge]=Ao("domaintrail.layout.legend",!0),[ne,Ee]=Ao("domaintrail.inspector.tab","structure"),[Re,Me]=G([]),Fe=Re[Re.length-1],[tt,mn]=G(),oe=L(new Map),ce=L(null),Le=le(()=>(e?.focusContexts??[]).filter((pe)=>w===null||w.includes(pe)),[e?.focusContexts,w]),ft=Le.length===(e?.focusContexts??[]).length,Je=le(()=>ft?[]:Le,[ft,Le]),gt=!ft&&Le.length===0,lt=le(()=>Je.length?(e?.focusContexts??[]).filter((pe)=>C.includes(pe)&&!Je.includes(pe)):[],[e?.focusContexts,C,Je]),on=Je.length?`${Je.join("+")}|${lt.join("+")}|${x}`:"",[Qi,ua]=G(null);F(()=>{if(!on||s.kind!=="structure")return;let pe=!1,Ln=new URLSearchParams({contexts:Je.join(","),level:x,hide:lt.join(",")});return fetch(`/api/focus?${Ln}`).then((Fi)=>Fi.ok?Fi.json():null).then((Fi)=>{if(!pe&&Fi)ua({key:on,graph:Fi})}).catch(()=>{}),()=>{pe=!0}},[on,e?.modelVersion,s.kind]);let Rl=(pe,Ln)=>{if(!pe||!ig(Ln))return null;if(Ln.kind==="contextMap")return P?pe.contextMapAll:pe.contextMap;if(Ln.kind==="structure"){if(gt)return null;if(on)return Qi?.key===on?Qi.graph:void 0;return pe[RUe[x]]}return null},Ac=(pe)=>pe.kind==="structure"?on?`structure:focus:${on}`:`structure:${x}`:`${pe.kind}:${P}`,wd=Rl(e,s);F(()=>{if(!r||!e||!ig(s))return;let pe=Ac(s);if(ce.current&&ce.current!==pe)oe.current.set(ce.current,r.getCamera());let Ln=ce.current!==pe;if(!wd){cT(r,()=>r.deleteShapes([...r.getCurrentPageShapeIds()]));return}let Fi=on&&s.kind==="structure"?void 0:Rl(t,s)??void 0;if(fA(r,wd,{diff:e.diff,diagnostics:e.diagnostics,previous:Fi,mode:l,lang:g}),Ln){let j9=oe.current.get(pe);if(j9)r.setCamera(j9);else hhe(r,wd.textScale??1)}ce.current=pe},[r,e,t,s,l,x,on,Qi,P,gt,g]),F(()=>{IA(d,r)},[d,r]);let Zb=O((pe,Ln=s)=>{if(r&&ig(Ln))pT(r,pe)},[r,s]),EA=O((pe)=>mn(Ihe(o,pe)),[o]),Cd=O((pe,Ln={})=>{if(Me((Fi)=>xhe(Fi,pe)),EA(pe),Ln.highlight!==!1)Zb(pe)},[EA,Zb]),V9=(pe)=>{let Ln=Yb(pe);if(Ln)return(e?.sources??[]).some((Fi)=>Fi.path===Ln);return!o||!!Wb(o,pe)},gT=Re[R9(Re,V9)],Xhe=()=>{if(!gT)return;Me(vhe(Re,V9)),EA(gT),Zb(gT)},yT=O((pe,Ln)=>{let Fi={kind:pe};if(a(Fi),ig(Fi))requestAnimationFrame(()=>requestAnimationFrame(()=>Zb(Ln,Fi)))},[Zb]),_A=(pe)=>{Ee(pe),V(!0)},Zhe=(pe)=>{Cd(pe,{highlight:!1});let Ln=o?Wb(o,pe):void 0;if(!Ln)return;if(Ln.kind==="state"||Ln.kind==="command")_A("states");else if(Ln.kind==="context")yT("structure",pe);else if(Qpe(Ln.el.kind)){if(yT("structure",pe),Ln.el.kind==="aggregate")_A("states")}else if(mA(Ln.el.kind))yT("catalog",pe);else _A("source")},Jhe=(pe)=>{if(Cd(pe.elementId??hA(pe.file)),mn({file:pe.file,line:pe.start.line,endLine:pe.end.line}),!pe.elementId)V(!0)},MA=H("selected element",()=>{let pe=r?.getOnlySelectedShape();return pe&&r?dA(r,pe.id):void 0},[r]);F(()=>{if(MA)Cd(MA,{highlight:!1})},[MA]),xA(r);let Qhe=O((pe)=>{pe.updateInstanceState({isReadonly:!0}),window.__domaintrailEditor=pe,i(pe)},[]),Jb={added:[],changed:[],removed:[]};return h($pe,{lang:g,children:E("div",{className:"app",children:[E("header",{children:[h("div",{className:"brand",children:"DomainTrail"}),E("div",{className:"status",children:[e&&h("span",{className:`pill pill-${e.status}`,children:y.status[e.status]}),h("span",{className:"muted",children:e?`${y.fileCount(e.files.length)} · v${e.version} · ${new Date(e.updatedAt).toLocaleTimeString(g)}`:""}),h("span",{className:`conn conn-${n}`,title:y.connectionTitle(y.connection[n])})]}),h(zhe,{mode:l,onMode:c,themePreference:u,theme:d,onTheme:f,langPreference:p,lang:g,onLang:m})]}),e?.stale&&h("div",{className:"banner",children:y.stale(h("a",{onClick:()=>K(!0),children:y.problems}))}),E("div",{className:"workspace",children:[E("div",{className:`side side-left${_?" open":""}`,style:{width:_?U:mT},children:[h("div",{className:"rail",inert:_,children:h("button",{className:"icon-button",onClick:()=>M(!0),"data-tooltip":y.openExplorer,"aria-label":y.openExplorer,children:h(of,{size:16,"aria-hidden":!0})})}),h("aside",{className:"pane",style:{width:U},inert:!_,children:h(bhe,{model:o,files:e?.files??[],diagnostics:e?.diagnostics??[],diff:e?.diff??Jb,mode:l,selected:Fe,onSelect:(pe)=>{if(Cd(pe),Yb(pe))V(!0)},onOpen:Zhe,onClose:()=>M(!1)})})]}),h(yA,{direction:"x",size:U,min:180,max:480,open:_,collapsed:mT,onResize:A,onOpenChange:M}),E("section",{className:"center",children:[E("div",{className:"view-tabs",children:[h("div",{className:"view-tab-list",role:"tablist",children:["contextMap","structure","catalog"].map((pe)=>h("button",{role:"tab","aria-selected":s.kind===pe,className:s.kind===pe?"active":"",onClick:()=>a({kind:pe}),children:y.views[pe]},pe))}),E("div",{className:"view-toolbar",children:[s.kind==="contextMap"&&E("label",{className:"check small",children:[h("input",{type:"checkbox",checked:P,onChange:(pe)=>k(pe.target.checked)}),y.showAllContexts]}),s.kind==="structure"&&h(SA,{contexts:e?.focusContexts??[],labels:o?.contextLabels??{},selected:Le,hidden:lt,mode:l,onChange:(pe)=>v(pe.length===(e?.focusContexts??[]).length?null:pe),onHiddenChange:I}),s.kind==="structure"&&h("div",{className:"segmented small icons",role:"group","aria-label":y.structureMode,children:C9.map((pe)=>{let Ln=AUe[pe];return h("button",{className:x===pe?"active":"","aria-pressed":x===pe,onClick:()=>b(pe),"data-tooltip":y.structureLevels[pe],"aria-label":y.structureLevels[pe],children:h(Ln,{size:15,"aria-hidden":!0})},pe)})}),ig(s)&&h("button",{onClick:()=>r?.zoomToFit({animation:{duration:200}}),children:y.zoomToFit})]})]}),E("div",{className:"view-area",children:[h(rT,{shapeUtils:TA,hideUi:!0,onMount:Qhe}),wd&&ig(s)&&h(vA,{view:s.kind==="contextMap"?"contextMap":`${x==="aggregates"?"aggregates":"structure"}${on?"Focus":""}`,open:Ce,onToggle:()=>ge(!Ce)}),e&&!wd&&ig(s)&&h("div",{className:"empty",children:e.status==="empty"?y.noDtFiles:gt&&s.kind==="structure"?y.pickContexts:on&&s.kind==="structure"?y.loading:y.noDiagram}),s.kind==="catalog"&&o&&h(phe,{model:o,mode:l,diff:e?.diff??Jb,diagnostics:e?.diagnostics??[],selected:Fe,onSelect:(pe)=>Cd(pe)})]})]}),h(yA,{direction:"x",size:z,min:300,max:()=>window.innerWidth-(_?U:mT)-MUe,invert:!0,open:N,collapsed:mT,onResize:j,onOpenChange:V}),E("div",{className:`side side-right${N?" open":""}`,style:{width:N?z:mT},children:[h("div",{className:"rail",inert:N,children:h("button",{className:"icon-button",onClick:()=>V(!0),"data-tooltip":y.openInspector,"aria-label":y.openInspector,children:h(vv,{size:16,"aria-hidden":!0})})}),h("aside",{className:"pane",style:{width:z},inert:!N,children:h(Ahe,{model:o,mode:l,selected:Fe,diagnostics:e?.diagnostics??[],diff:e?.diff??Jb,sources:e?.sources??[],sourceFocus:tt,statesView:(pe)=>h($he,{aggregateId:pe,graphs:e?.states[pe],previous:t?.states[pe],diff:e?.diff??Jb,diagnostics:e?.diagnostics??[],mode:l,lang:g,theme:d,selected:Fe,onSelect:(Ln)=>Cd(Ln),legendOpen:Ce,onLegendToggle:()=>ge(!Ce)}),tab:ne,onTab:Ee,onSelect:(pe)=>Cd(pe),onReveal:yT,onFocusContext:(pe)=>{v([pe]),a({kind:"structure"})},backTo:gT,onBack:Xhe,onClose:()=>V(!1)})})]})]}),h(yA,{direction:"y",size:R,min:120,max:600,invert:!0,open:D,collapsed:Whe,onResize:W,onOpenChange:K}),h("div",{className:"bottom-wrap",style:{height:D?R:Whe},children:h(ihe,{tab:te,mode:l,open:D,model:o,diagnostics:e?.diagnostics??[],diff:e?.diff??Jb,onTab:ue,onToggle:()=>K(!D),onLocate:Jhe,onSelect:(pe)=>Cd(pe)})}),h(qhe,{})]})})}rv(document.getElementById("root")).render(h(Yhe,{}));
|
|
556
|
+
`]}),n===e.focus?.line&&e.focusAction]},n))}return h("pre",{className:"src-code-block",children:t})}function D9(e){let t=Kt(),n=e.file??e.sources[0]?.path,o=e.sources.find((f)=>f.path===n),r=le(()=>o?Che(o.text):[],[o]),i=L(new Map);F(()=>{if(!e.focus||e.focus.file!==n)return;i.current.get(e.focus.line)?.scrollIntoView({block:"center"})},[e.focus,n]);let s=new Map;for(let f of e.diagnostics.filter((d)=>d.file===n))for(let d=f.start.line;d<=f.end.line;d++)s.set(d,[...s.get(d)??[],f]);let a=The(e.model).filter((f)=>f.file===n),l=(f)=>{let d=a.filter((p)=>p.line<=f&&f<=p.endLine).sort((p,m)=>p.endLine-p.line-(m.endLine-m.line))[0];if(d)e.onSelect(d.id)},c=e.focus?.file===n?e.focus:void 0,u=c&&o?pUe(o.text,c):void 0;if(!o)return h("p",{className:"muted pad",children:t.noDtFiles});return h("div",{className:"source-view",children:h(mUe,{lines:r,from:1,to:r.length,focus:c,focusAction:u!==void 0&&h(hUe,{text:u}),diagnostics:s,onLineClick:l,lineRef:(f,d)=>d?i.current.set(f,d):i.current.delete(f)})})}var Lhe=Oe(vd("both",null)),Lc=()=>Te(Lhe);function gUe(e){switch(e.kind){case"context":return["structure"];case"state":return["structure","states","behavior","source"];case"command":return["structure","states","behavior","source"];case"element":return e.el.kind==="aggregate"?["structure","states","behavior","events","references","source"]:["structure","references","source"]}}function Phe(e){let t=[];if(e.kind==="element"){if(e.el.kind==="aggregate"||e.el.kind==="entity"||e.el.kind==="valueObject"||e.el.kind==="union")t.push("structure");if(mA(e.el.kind))t.push("catalog")}else if(e.kind==="context")t.push("contextMap","structure");return t}function Ahe(e){let{model:t,selected:n}=e,o=Kt(),r=e.backTo&&(Yb(e.backTo)??vd(e.mode,t).id(e.backTo)),i=E("div",{className:"history",children:[r&&E("button",{className:"back-button",onClick:e.onBack,"data-tooltip":o.backTo(r),"aria-label":o.backTo(r),children:[h(Cv,{size:14,"aria-hidden":!0}),h("span",{className:"back-name",children:r})]}),h("button",{className:"icon-button close-button",onClick:e.onClose,"data-tooltip":o.closeInspector,"aria-label":o.closeInspector,children:h(xv,{size:16,"aria-hidden":!0})})]}),s=Yb(n);if(s)return E("div",{className:"inspector",children:[E("div",{className:"inspector-head",children:[i,h("div",{className:"inspector-row",children:h("span",{className:"kind kind-file",children:o.fileKind})}),h("h2",{children:s}),h(Mhe,{items:e.diagnostics.filter((g)=>g.file===s)})]}),h("div",{className:"inspector-body inspector-body-full",children:h(D9,{sources:e.sources,diagnostics:e.diagnostics,model:t,file:s,focus:e.sourceFocus?.file===s?e.sourceFocus:void 0,onSelect:e.onSelect})})]});if(!t)return h("div",{className:"inspector",children:E("div",{className:"inspector-head",children:[i,h("p",{className:"muted",children:o.noModel})]})});let a=n?Wb(t,n):void 0;if(!n||!a)return h("div",{className:"inspector",children:E("div",{className:"inspector-head",children:[i,h("p",{className:"muted",children:n?o.notInModel(n):o.pickElement})]})});let l=vd(e.mode,t),c=gUe(a),u=c.includes(e.tab)?e.tab:c[0],f=e.diagnostics.filter((g)=>g.elementId===n||a.kind==="element"&&g.elementId&&Al(g.elementId)===n),d=e.diff.added.includes(n)?"added":e.diff.changed.includes(n)?"changed":void 0,p=Rhe(a),m=l.of({name:p.name,label:p.label});return h(Lhe.Provider,{value:l,children:E("div",{className:"inspector",children:[E("div",{className:"inspector-head",children:[i,E("div",{className:"inspector-row",children:[h("span",{className:`kind kind-${p.kind}`,children:o.kinds[p.kind]}),a.kind==="context"&&a.shared&&h("span",{className:"shared-badge",children:o.shared}),a.kind==="element"&&a.el.kind==="event"&&h(dT,{persistent:!!a.el.persistent,tx:o}),d&&h("span",{className:`change change-${d}`,children:d==="added"?o.added:o.changed})]}),h("h2",{children:e.mode==="both"&&p.label?p.label:m}),e.mode==="both"&&p.label&&h("div",{className:"canonical-name",children:p.name}),p.doc&&h("p",{className:"doc",children:p.doc}),Phe(a).length>0&&E("div",{className:"reveal",children:[h("span",{className:"muted small",children:o.showIn}),Phe(a).map((g)=>h("button",{onClick:()=>e.onReveal(g,n),children:o.reveal[g]},g))]}),h(Mhe,{items:f})]}),c.length>1&&h("div",{className:"subtabs",role:"tablist",children:c.map((g)=>h("button",{role:"tab","aria-selected":g===u,className:g===u?"active":"",onClick:()=>e.onTab(g),children:o.tabs[g]},g))}),h("div",{className:`inspector-body${u==="source"||u==="states"?" inspector-body-full":""}`,children:h(yUe,{...e,r:a,tab:u})})]})})}function Rhe(e){switch(e.kind){case"context":return{kind:"context",name:e.name,label:e.label};case"element":return{kind:e.el.kind,name:e.el.id,label:e.el.label,doc:e.el.doc,location:e.el.location};case"state":return{kind:"state",name:`${e.agg.name}.${e.state.name}`,label:e.state.label,doc:e.state.doc,location:e.state.location};case"command":return{kind:"command",name:`${e.agg.name}.${e.command.name}`,label:e.command.label,doc:e.command.doc,location:e.command.location}}}function yUe(e){let{r:t,tab:n,model:o,onSelect:r}=e,i=Lc(),s=Kt();if(!o)return null;if(n==="source"){let l=Rhe(t).location;if(!l)return null;let c=e.sourceFocus?.file===l.file?e.sourceFocus:l;return h(D9,{sources:e.sources,diagnostics:e.diagnostics,model:o,file:l.file,focus:c,onSelect:r})}if(n==="states")return e.statesView(t.kind==="element"?t.el.id:t.kind==="context"?t.name:t.agg.id);if(t.kind==="context")return h(SUe,{model:o,ctx:t.name,onSelect:r,onFocus:e.onFocusContext});if(t.kind==="state"){let{agg:l,state:c}=t;if(n==="behavior"){let u=(l.commands??[]).filter((d)=>d.transitions.some((p)=>p.to.includes(c.name))),f=(l.commands??[]).filter((d)=>d.transitions.some((p)=>p.from.includes(c.name)));return E(Y,{children:[h(O9,{title:s.commandsInto,agg:l,model:o,commands:u,onSelect:r}),h(O9,{title:s.commandsOutOf,agg:l,model:o,commands:f,onSelect:r})]})}return E(Y,{children:[h(wA,{title:s.stateFields,fields:c.fields,ctx:l.context,onSelect:r,empty:s.noStateFields}),h(CA,{items:c.invariants,title:s.stateInvariants,labelOnly:!0}),h("p",{className:"muted small",children:s.commonFieldsAt(h("a",{onClick:()=>r(l.id),children:i.of(l)}))})]})}if(t.kind==="command"){let{agg:l,command:c}=t;if(n==="behavior")return E(Y,{children:[h(ti,{title:s.transition,children:h("code",{className:"block",children:i.transition(l,c)||s.noStates})}),h(ti,{title:s.mayRaise,children:c.emits.length?c.emits.map((u)=>h(Ehe,{model:o,id:u,onSelect:r},u)):h("span",{className:"muted",children:s.none})}),h(ti,{title:s.mayReturn,children:c.errors.length?c.errors.map((u)=>h(Ehe,{model:o,id:u,onSelect:r},u)):h("span",{className:"muted",children:s.none})})]});return E(Y,{children:[h(wA,{title:s.params,fields:c.params,ctx:l.context,onSelect:r,empty:s.noParams}),h(ti,{title:s.contract,children:E("code",{className:"block",children:[c.factory?"create ":"","command ",c.name,"(",c.params.map((u)=>`${u.name}: ${vd("name",o).type(u.type,l.context)}${u.multiplicity}`).join(", "),")"]})})]})}let a=t.el;if(n==="behavior")return E(Y,{children:[h(O9,{title:s.counted(s.commands,a.commands?.length??0),agg:a,model:o,commands:a.commands??[],onSelect:r}),h(_he,{agg:a,model:o,kind:"errors",onSelect:r})]});if(n==="events")return h(_he,{agg:a,model:o,kind:"emits",onSelect:r});if(n==="references")return h(bUe,{model:o,el:a,onSelect:r});return E(Y,{children:[a.base&&E("p",{children:[a.kind==="id"?s.identifier:s.kinds.primitive,s.separator,s.baseType,": ",h("code",{children:i.primitive(a.base)})]}),a.values&&h(ti,{title:s.values,children:h("div",{className:"chips",children:a.values.map((l)=>E("code",{children:[i.mode==="both"?l:i.of({name:l,label:a.valueLabels?.[l]}),i.mode==="both"&&a.valueLabels?.[l]&&E("span",{className:"muted",children:[" ",a.valueLabels[l]]})]},l))})}),a.kind==="union"&&E(Y,{children:[E("p",{children:[s.discriminator,": ",h("code",{children:a.discriminator}),a.tagType&&E(Y,{children:[s.separator,s.values,": ",h("a",{onClick:()=>r(a.tagType),children:i.id(a.tagType)})]})]}),(a.variants??[]).map((l)=>E("div",{title:l.doc,children:[h(wA,{title:`${i.of(l)}`,fields:l.fields,ctx:a.context,onSelect:r,empty:s.noFields}),h(CA,{items:l.invariants,title:s.variantInvariants(i.of(l))})]},l.name))]}),a.kind!=="id"&&a.kind!=="primitive"&&a.kind!=="enum"&&a.kind!=="union"&&h(wA,{title:a.states?.length?s.commonFields:a.kind==="event"||a.kind==="error"?s.payload:s.fields,fields:a.fields,ctx:a.context,onSelect:r,empty:s.noFields}),(a.kind==="aggregate"||a.kind==="entity"||a.kind==="valueObject")&&h(CA,{items:a.invariants,title:a.states?.length?s.allStateInvariants:s.invariants,labelOnly:a.kind==="aggregate"}),(a.kind==="id"||a.kind==="primitive")&&h(CA,{items:a.invariants,title:s.valueInvariants}),a.states&&a.states.length>0&&h(ti,{title:s.counted(s.states,a.states.length),children:a.states.map((l)=>E("div",{className:"sub",children:[h("a",{onClick:()=>r(l.id),children:i.of(l)}),l.fields.length>0&&E("span",{className:"muted small",children:[" ",l.fields.map((c)=>i.field(c)).join(", ")]})]},l.id))})]})}function khe({title:e,groups:t,other:n,onSelect:o}){let r=Lc(),i=Kt(),s=Gpe();if(t.length===0)return null;return h(ti,{title:i.counted(e,t.length),children:t.map((a)=>E("details",{className:"deps",children:[E("summary",{children:[h("a",{onClick:()=>o(n(a)),children:r.id(n(a))}),E("span",{className:"muted small",children:[" ",whe(a.ids,a.types)[s][r.mode]]})]}),a.uses.map((l,c)=>E("div",{className:"sub small",children:[h("a",{onClick:()=>o(l.source),children:r.id(l.source)}),E("span",{className:"muted",children:[".",l.path," → "]}),h("a",{onClick:()=>o(l.target),children:r.id(l.target)}),h("span",{className:`dep-kind dep-${l.kind}`,children:l.kind==="id"?"ID":i.typeDependency})]},c))]},n(a)))})}function SUe({model:e,ctx:t,onSelect:n,onFocus:o}){let r=Lc(),i=Kt(),s=Object.values(e.elements).filter((c)=>c.context===t),a=e.terms[t]??[],l=k9(cA(e));return E(Y,{children:[!uA(e).has(t)&&h("p",{children:h("button",{onClick:()=>o(t),children:i.focusContext})}),h(khe,{title:i.dependencies,groups:l.filter((c)=>c.from===t),other:(c)=>c.to,onSelect:n}),h(khe,{title:i.dependents,groups:l.filter((c)=>c.to===t),other:(c)=>c.from,onSelect:n}),pA.map((c)=>{let u=s.filter((f)=>f.kind===c);if(!u.length)return null;return h(ti,{title:i.counted(i.kinds[c],u.length),children:u.map((f)=>h("div",{className:"sub",children:h("a",{onClick:()=>n(f.id),children:r.of(f)})},f.id))},c)}),a.length>0&&h(ti,{title:i.terms,children:h("table",{className:"fields",children:h("tbody",{children:a.map((c)=>E("tr",{children:[h("td",{className:"flabel",children:c.label}),h("td",{className:"fname",children:c.name}),h("td",{className:"muted",children:c.doc})]},c.name))})})})]})}function bUe({model:e,el:t,onSelect:n}){let o=Lc(),r=Kt(),i=Xb(e,t.id,o.of),s=t.fields.find((u)=>u.name==="id"&&u.type.kind==="ref")?.type,a=t.kind==="aggregate"&&s?.kind==="ref"?Xb(e,s.ref,o.of).filter((u)=>u.target!==t.id):[],l=Object.values(e.elements).flatMap((u)=>(u.commands??[]).filter((f)=>f.emits.includes(t.id)||f.errors.includes(t.id)).map((f)=>({agg:u,c:f}))),c=t.kind==="fieldSet"?gA(e,t.id):[];if(!i.length&&!a.length&&!l.length&&!c.length)return h("p",{className:"muted",children:r.unreferenced});return E(Y,{children:[c.length>0&&h(ti,{title:r.fieldSetUsers(c.length),children:c.map((u)=>E("div",{className:"sub",children:[h("a",{onClick:()=>n(u.id),children:o.id(u.id)}),E("span",{className:"muted small",children:[" ",r.kinds[u.kind]]})]},u.id))}),l.length>0&&h(ti,{title:t.kind==="event"?r.raisedBy:r.returnedBy,children:l.map(({agg:u,c:f})=>h("div",{className:"sub",children:E("a",{onClick:()=>n(f.id),children:[o.of(u),".",o.of(f)]})},f.id))}),i.length>0&&h(ti,{title:r.typeUses(i.length),children:i.map((u)=>h("div",{className:"sub",children:h("a",{onClick:()=>n(u.target),children:u.text})},u.key))}),a.length>0&&h(ti,{title:r.idUses(s.kind==="ref"?o.id(s.ref):"",a.length),children:a.map((u)=>h("div",{className:"sub",children:h("a",{onClick:()=>n(u.target),children:u.text})},u.key))})]})}function O9({title:e,agg:t,model:n,commands:o,onSelect:r}){let i=Lc(),s=Kt();return E(ti,{title:e,children:[o.length===0&&h("span",{className:"muted",children:s.none}),o.map((a)=>h(che,{agg:t,c:a,model:n,names:i,tx:s,onSelect:r},a.id))]})}var xUe=(e,t)=>t.fields.map((n)=>`${e.field(n)}: ${e.type(n.type,t.context)}${n.multiplicity}`).join(", ");function Ehe({model:e,id:t,onSelect:n}){let o=Lc(),r=e.elements[t];return E("div",{className:"event-row",children:[h("a",{onClick:()=>n(t),children:o.id(t)}),r&&r.fields.length>0&&h("div",{className:"muted small mono",children:xUe(o,r)})]})}function _he({agg:e,model:t,kind:n,onSelect:o}){let r=Lc(),i=Kt(),s=dhe(e.commands??[],n);if(s.size===0&&n==="errors")return null;return E(ti,{title:n==="emits"?i.raises(s.size):i.returns(s.size),children:[s.size===0&&h("span",{className:"muted",children:i.none}),[...s].map(([a,l])=>h(uhe,{id:a,commands:l,model:t,names:r,tx:i,onSelect:o},a))]})}function Mhe({items:e}){if(e.length===0)return null;return h("div",{className:"inspector-diags",children:e.map((t,n)=>E("div",{className:`diag diag-${t.severity}`,children:[h("code",{children:t.code})," ",t.message]},n))})}function ti({title:e,children:t}){return E("section",{children:[h("h3",{children:e}),t]})}function wA({title:e,fields:t,ctx:n,onSelect:o,empty:r}){let i=Lc(),s=Kt();if(t.length===0)return r?h(ti,{title:e,children:h("span",{className:"muted",children:r})}):null;let a=(l)=>l.kind==="owns"?"◆ ":l.kind==="references"?"→ ":"";return h(ti,{title:e,children:h("table",{className:"fields",children:h("tbody",{children:t.map((l)=>E("tr",{title:l.doc,children:[i.mode==="both"&&E("td",{className:"flabel",children:[l.label,l.labelSource&&l.labelSource!=="inline"&&h("span",{className:"label-src",children:s.labelSources[l.labelSource]})]}),E("td",{className:i.mode==="label"?"flabel":"fname",children:[a(l),i.mode==="both"?l.name:i.field(l)]}),E("td",{children:[l.type.kind==="ref"&&l.type.target?h("a",{onClick:()=>o(l.type.ref),children:i.type(l.type,n)}):i.type(l.type,n),l.multiplicity,l.target&&E(Y,{children:[" ","→"," ",h("a",{className:"ref",onClick:()=>o(l.target),children:i.id(l.target)})]}),l.fieldSet&&h(vUe,{id:l.fieldSet,onSelect:o})]})]},l.name))})})})}function vUe({id:e,onSelect:t}){let n=Lc(),o=Kt();return h("a",{className:"field-origin",onClick:()=>t(e),"data-tooltip":o.fromFieldSet(n.id(e)),children:n.short(e)})}function CA({items:e,title:t,labelOnly:n}){let o=Lc();if(e.length===0)return null;return h(ti,{title:t,children:e.map((r)=>{let i=n&&!!r.label;return E("div",{className:"sub",children:[h("strong",{children:o.of(r)}),!i&&r.doc&&h("p",{className:"doc",children:r.doc}),!i&&h("code",{className:"block",children:r.source})]},r.name)})})}q();var F9=$s("none","added","changed","removed"),B9=$s("none","warning","error");class Dhe extends Yr{static type="domain-node";static props={w:Se,h:Se,kind:Ne,scale:Se,label:Ne,stereotype:Ne,rows:ur(Ye({k:Ne,v:Ne,o:Ne.optional()})),compartment:Se,change:F9,diag:B9};getDefaultProps(){return{w:160,h:60,kind:"entity",label:"",stereotype:"",scale:1,rows:[],compartment:0,change:"none",diag:"none"}}canResize=()=>!1;hideRotateHandle=()=>!0;hideResizeHandles=()=>!0;canEdit=()=>!1;component(e){let t=e.props;return h(Gr,{className:`dn dn-${t.kind} dn-change-${t.change} dn-diag-${t.diag}`,style:{width:t.w,height:t.h,["--s"]:t.scale},children:t.kind==="initial"?h("div",{className:"dn-initial",children:t.label}):E(Y,{children:[E("div",{className:"dn-head",children:[t.stereotype&&h("div",{className:"dn-stereo",children:t.stereotype}),h("div",{className:"dn-label",children:t.label})]}),t.rows.length>0&&h("div",{className:"dn-body",children:t.rows.map((n,o)=>n.v?E(Cr,{children:[h("span",{className:"dn-key",children:n.k}),E("span",{className:"dn-value",children:[n.v,n.o&&h("span",{className:"dn-origin",children:n.o})]})]},o):h("span",{className:"dn-key dn-full",children:n.k},o))}),t.compartment>0&&h("div",{className:"dn-compartment",style:{height:t.compartment}}),t.change!=="none"&&h(IUe,{change:t.change}),t.diag!=="none"&&h("div",{className:"dn-diag",children:t.diag==="error"?"✕":"!"})]})})}getIndicatorPath(e){return z9(e.props.w,e.props.h,8)}}class Ohe extends Yr{static type="domain-internal";static props={w:Se,h:Se,label:Ne,sub:Ne,faded:st,scale:Se,change:F9,diag:B9};getDefaultProps(){return{w:160,h:21,label:"",sub:"",faded:!1,scale:1,change:"none",diag:"none"}}canResize=()=>!1;hideRotateHandle=()=>!0;hideResizeHandles=()=>!0;canEdit=()=>!1;component(e){let t=e.props;return E(Gr,{className:`di di-change-${t.change} di-diag-${t.diag}`,style:{width:t.w,height:t.h,["--s"]:t.scale},children:[E("div",{className:`di-main${t.faded?" di-faded":""}`,children:["↻ ",t.label]}),t.sub&&h("div",{className:"di-sub",children:t.sub}),t.diag!=="none"&&h("div",{className:"di-diag",children:t.diag==="error"?"✕":"!"})]})}getIndicatorPath(e){return z9(e.props.w,e.props.h,4)}}class Nhe extends Yr{static type="domain-group";static props={w:Se,h:Se,kind:Ne,scale:Se,label:Ne,lines:ur(Ne),change:F9,diag:B9};getDefaultProps(){return{w:200,h:100,kind:"context",label:"",lines:[],scale:1,change:"none",diag:"none"}}canResize=()=>!1;hideRotateHandle=()=>!0;hideResizeHandles=()=>!0;canEdit=()=>!1;component(e){let t=e.props;return E(Gr,{className:`dg dg-${t.kind} dn-change-${t.change} dn-diag-${t.diag}`,style:{width:t.w,height:t.h,["--s"]:t.scale},children:[h("div",{className:"dg-label",children:t.label}),t.lines.length>0&&h("div",{className:"dg-desc",children:t.lines.map((n,o)=>h("div",{children:n},o))})]})}getIndicatorPath(e){return z9(e.props.w,e.props.h,12)}}class Fhe extends Bo{static type="domain-edge";static props={points:ur(Ye({x:Se,y:Se})),kind:Ne,scale:Se,label:Ne,sub:Ne,faded:st,lx:Se,ly:Se,lw:Se,lh:Se,tone:$s("normal","added","changed","error")};getDefaultProps(){return{points:[],kind:"owns",label:"",sub:"",faded:!1,scale:1,lx:0,ly:0,lw:0,lh:0,tone:"normal"}}canResize=()=>!1;hideRotateHandle=()=>!0;hideResizeHandles=()=>!0;canEdit=()=>!1;canBind=()=>!1;getGeometry(e){let t=e.props.points.length>=2?e.props.points:[{x:0,y:0},{x:1,y:1}];return new ps({points:t.map((n)=>new T(n.x,n.y))})}component(e){let{points:t,kind:n,label:o,sub:r,faded:i,lx:s,ly:a,lw:l,lh:c,tone:u,scale:f}=e.props;if(t.length<2)return null;let d=t.map((S,b)=>`${b?"L":"M"}${S.x},${S.y}`).join(" "),[p,m]=[t[t.length-2],t[t.length-1]],[g,y]=[t[0],t[1]];return E(qr,{className:`de de-${n} de-tone-${u}`,children:[h("path",{d,className:"de-hit"}),h("path",{d,className:"de-line"}),n==="owns"?h("path",{d:TUe(g,y),className:"de-head de-diamond"}):null,h("path",{d:CUe(p,m),className:"de-head"}),o&&l>0&&h(wUe,{label:o,sub:r,faded:i,lx:s,ly:a,lw:l,lh:c,scale:f})]})}getIndicatorPath(e){let t=new Path2D;return e.props.points.forEach((n,o)=>o?t.lineTo(n.x,n.y):t.moveTo(n.x,n.y)),t}}function wUe({label:e,sub:t,faded:n,lx:o,ly:r,lw:i,lh:s,scale:a}){let l=o+i/2,c=r+(s-(iA+(t?sA:0))*a)/2;return E(Y,{children:[h("text",{x:l,y:c+iA/2*a,className:`de-label${n?" de-faded":""}`,style:{fontSize:13*a},textAnchor:"middle",dominantBaseline:"central",children:e}),t&&h("text",{x:l,y:c+(iA+sA/2)*a,className:"de-label de-sub",style:{fontSize:13*x9*a},textAnchor:"middle",dominantBaseline:"central",children:t})]})}function Bhe(e,t){let n=Math.hypot(t.x-e.x,t.y-e.y)||1;return{x:(t.x-e.x)/n,y:(t.y-e.y)/n}}var N9=13;function CUe(e,t){let n=Bhe(e,t),o={x:-n.y,y:n.x},r={x:t.x-n.x*N9,y:t.y-n.y*N9},i=N9/2;return`M${t.x},${t.y} L${r.x+o.x*i},${r.y+o.y*i} L${r.x-o.x*i},${r.y-o.y*i} Z`}function TUe(e,t){let n=Bhe(e,t),o={x:-n.y,y:n.x},r={x:e.x+n.x*7,y:e.y+n.y*7},i={x:e.x+n.x*14,y:e.y+n.y*14};return`M${e.x},${e.y} L${r.x+o.x*4.5},${r.y+o.y*4.5} L${i.x},${i.y} L${r.x-o.x*4.5},${r.y-o.y*4.5} Z`}function z9(e,t,n){let o=new Path2D;return o.roundRect(0,0,e,t,n),o}function IUe({change:e}){let t=Kt();return h("div",{className:"dn-badge",children:t[e]})}var TA=[Dhe,Nhe,Ohe,Fhe];q();var PUe=["auto","light","dark"],kUe=["auto","ja","en"];function zhe(e){let{mode:t,onMode:n,themePreference:o,theme:r,onTheme:i,langPreference:s,lang:a,onLang:l}=e,c=Kt(),[u,f]=G(!1),d=L(null);return F(()=>{let p=d.current;if(!p)return;if(u&&!p.open)p.showModal();else if(!u&&p.open)p.close()},[u]),E("div",{className:"settings",children:[h("button",{className:"icon-button","aria-haspopup":"dialog","aria-expanded":u,"aria-label":c.settings,"data-tooltip":c.settings,onClick:()=>f(!0),children:h(wv,{size:16,"aria-hidden":!0})}),E("dialog",{ref:d,className:"settings-dialog","aria-labelledby":"settings-title",onClose:()=>f(!1),onClick:(p)=>p.target===p.currentTarget&&f(!1),children:[E("div",{className:"settings-dialog-header",children:[h("h2",{id:"settings-title",children:c.settings}),h("button",{className:"icon-button","aria-label":c.closeSettings,"data-tooltip":c.closeSettings,onClick:()=>f(!1),children:h(Xc,{size:18,"aria-hidden":!0})})]}),E("div",{className:"settings-dialog-body",children:[h(U9,{id:"settings-names",caption:c.nameDisplay,hint:c.nameDisplayHint,children:oA.map((p)=>h("button",{className:t===p?"active":"","aria-pressed":t===p,onClick:()=>n(p),children:c.modes[p]},p))}),h(U9,{id:"settings-theme",caption:c.theme,hint:o==="auto"?c.themeAuto(c.themes[r]):c.themeHint,children:PUe.map((p)=>h("button",{className:o===p?"active":"","aria-pressed":o===p,onClick:()=>i(p),children:c.themes[p]},p))}),h(U9,{id:"settings-lang",caption:c.language,hint:s==="auto"?c.langAuto(I9[a]):c.langHint,children:kUe.map((p)=>h("button",{className:s===p?"active":"","aria-pressed":s===p,onClick:()=>l(p),children:p==="auto"?c.themes.auto:I9[p]},p))})]})]})]})}function U9(e){return E("div",{className:"settings-row",children:[E("div",{className:"settings-text",children:[h("div",{className:"settings-caption",id:e.id,children:e.caption}),h("div",{className:"settings-hint",children:e.hint})]}),h("div",{className:"segmented",role:"group","aria-labelledby":e.id,children:e.children})]})}q();q();var Hhe="domaintrail.theme",Uhe="(prefers-color-scheme: dark)";function Vhe(e){let[t,n]=G(()=>matchMedia(Uhe).matches);return F(()=>{let o=matchMedia(Uhe),r=(i)=>n(i.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),e==="auto"?t?"dark":"light":e}function IA(e,t){if(document.documentElement.dataset.theme=e,t&&t.user.getUserPreferences().colorScheme!==e)t.user.updateUserPreferences({colorScheme:e})}var jhe=new Map;function $he(e){let{aggregateId:t}=e,n=Kt(),[o,r]=G(null),[i,s]=Ao("domaintrail.states.transitionLabels","both"),a=b9.includes(i)?i:"both",l=e.graphs?.[a],c=e.previous?.[a],u=L(null);xA(o),F(()=>{IA(e.theme,o)},[e.theme,o]),F(()=>{if(!o)return;return zt("remember camera",()=>{let p=o.getCamera();if(u.current===t)jhe.set(t,p)})},[o,t]),F(()=>{if(!o)return;if(!l){cT(o,()=>o.deleteShapes([...o.getCurrentPageShapeIds()])),u.current=null;return}if(fA(o,l,{diff:e.diff,diagnostics:e.diagnostics,previous:c,mode:e.mode,lang:e.lang,transitionLabels:a}),u.current!==t){let p=jhe.get(t);if(p)o.setCamera(p);else M9(o,l);if(u.current=t,e.selected)pT(o,e.selected)}},[o,l,c,e.diff,e.diagnostics,e.mode,e.lang,a,t]),F(()=>{if(o&&e.selected&&u.current)pT(o,e.selected)},[o,e.selected]);let f=H("selected element",()=>{let p=o?.getOnlySelectedShape();return p&&o?dA(o,p.id):void 0},[o]);F(()=>{if(f&&f!==e.selected)e.onSelect(f)},[f]);let d=O((p)=>{p.updateInstanceState({isReadonly:!0}),r(p)},[]);return E("div",{className:"states-canvas",children:[h(rT,{shapeUtils:TA,hideUi:!0,onMount:d}),l?E(Y,{children:[E("div",{className:"canvas-toolbar",children:[h("div",{className:"segmented small",role:"group","aria-label":n.transitionLabels,children:b9.map((p)=>h("button",{className:a===p?"active":"","aria-pressed":a===p,onClick:()=>s(p),"data-tooltip":n.transitionLabelModes[p].hint,children:n.transitionLabelModes[p].label},p))}),h("button",{onClick:()=>o&&M9(o,l,!0),children:n.zoomToFit})]}),h(vA,{view:"states",open:e.legendOpen,onToggle:e.onLegendToggle})]}):h("div",{className:"empty",children:n.noDiagram})]})}q();var kA="data-tooltip",EUe=400,Ghe=6,PA=8;function _Ue(e,t,n){let o=e.bottom+Ghe,r=e.top-Ghe-t.height,i=o+t.height<=n.height-PA||r<PA?o:r,s=(e.left+e.right)/2-t.width/2,a=Math.max(PA,Math.min(s,n.width-PA-t.width));return{left:Math.round(a),top:Math.round(i)}}var H9=(e)=>e instanceof Element?e.closest(`[${kA}]`):null;function qhe(){let[e,t]=G(null),[,n]=G(0),[o,r]=G(null),i=L(null),s=e?.getAttribute(kA);if(F(()=>{let a,l=null,c=null,u=(S,b)=>{if(clearTimeout(a),c=S,!S||!b)t(S);else a=setTimeout(()=>t(S),b)},f=()=>u(null,0),d=(S)=>{if(S.pointerType==="touch")return;let b=H9(S.target);if(b===l)return;l=b,u(S.buttons?null:b,EUe)},p=(S)=>{let b=H9(S.target);if(b?.matches(":focus-visible"))u(b,0)},m=(S)=>{if(c&&c===H9(S.target)&&c!==l)f()},g=(S)=>{if(S.key==="Escape")f()},y=()=>{l=null,f()};return document.addEventListener("pointerover",d),document.addEventListener("pointerdown",f,!0),document.addEventListener("focusin",p),document.addEventListener("focusout",m),document.addEventListener("keydown",g,!0),document.addEventListener("scroll",f,!0),document.documentElement.addEventListener("pointerleave",y),window.addEventListener("blur",y),()=>{clearTimeout(a),document.removeEventListener("pointerover",d),document.removeEventListener("pointerdown",f,!0),document.removeEventListener("focusin",p),document.removeEventListener("focusout",m),document.removeEventListener("keydown",g,!0),document.removeEventListener("scroll",f,!0),document.documentElement.removeEventListener("pointerleave",y),window.removeEventListener("blur",y)}},[]),F(()=>{if(!e)return;let l=new MutationObserver(()=>{if(e.isConnected&&!e.closest("[inert]")&&e.getAttribute(kA))n((c)=>c+1);else t(null)});return l.observe(e,{attributes:!0,attributeFilter:[kA]}),l.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["inert"]}),()=>l.disconnect()},[e]),He(()=>{let a=i.current;if(!e||!a)return r(null);if(a.showPopover&&!a.matches(":popover-open"))a.showPopover();a.style.left="0px";let l=_Ue(e.getBoundingClientRect(),a.getBoundingClientRect(),{width:window.innerWidth,height:window.innerHeight});a.style.left=`${l.left}px`,r(l)},[e,s]),!e||!s)return null;return h("div",{ref:i,className:"tooltip",popover:"manual","aria-hidden":!0,style:o?{left:o.left,top:o.top}:{visibility:"hidden"},children:s})}q();function Khe(){let[e,t]=G({current:null,previous:null,connection:"connecting"}),n=L(0);return F(()=>{let o,r=!1,i,s=()=>{o=new WebSocket(`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws`),o.onopen=()=>{n.current=0,t((a)=>({...a,connection:"open"}))},o.onmessage=(a)=>{let l=JSON.parse(a.data);t((c)=>{let u=c.current&&c.current.modelVersion!==l.modelVersion;return{current:l,previous:u?c.current:c.previous,connection:"open"}})},o.onclose=()=>{if(r)return;t((a)=>({...a,connection:"closed"})),i=setTimeout(s,Math.min(5000,500*2**n.current++))}};return s(),()=>{r=!0,clearTimeout(i),o?.close()}},[]),e}var mT=28,Whe=33,MUe=320;function LUe(){try{let e=JSON.parse(localStorage.getItem("domaintrail.displayMode")??"null");return e==="ja"?"label":e==="en"?"name":"both"}catch{return"both"}}var ig=(e)=>e.kind==="contextMap"||e.kind==="structure",AUe={detail:yv,overview:gv,aggregates:sv},RUe={detail:"structure",overview:"overview",aggregates:"aggregates"};function Yhe(){let{current:e,previous:t,connection:n}=Khe(),o=e?.model??null,[r,i]=G(null),[s,a]=G({kind:"structure"}),[l,c]=Ao("domaintrail.nameDisplay",LUe()),[u,f]=Ao(Hhe,"auto"),d=Vhe(u),[p,m]=Ao(Hpe,"auto"),g=jpe(p),y=T9[g],[S,b]=Ao("domaintrail.structureMode","detail"),x=C9.includes(S)?S:"detail",[w,v]=Ao("domaintrail.structureContexts",null),[C,I]=Ao("domaintrail.structureHiddenContexts",[]),[P,k]=Ao("domaintrail.contextMapAll",!1),[_,M]=Ao("domaintrail.layout.explorer",!0),[N,V]=Ao("domaintrail.layout.inspector",!0),[D,K]=Ao("domaintrail.layout.bottom",!1),[U,A]=Ao("domaintrail.layout.explorerWidth",260),[z,j]=Ao("domaintrail.layout.inspectorWidth",420),[R,W]=Ao("domaintrail.layout.bottomHeight",220),[te,ue]=Ao("domaintrail.layout.bottomTab","problems"),[Ce,ge]=Ao("domaintrail.layout.legend",!0),[ne,Ee]=Ao("domaintrail.inspector.tab","structure"),[Re,Me]=G([]),Fe=Re[Re.length-1],[tt,mn]=G(),oe=L(new Map),ce=L(null),Le=le(()=>(e?.focusContexts??[]).filter((pe)=>w===null||w.includes(pe)),[e?.focusContexts,w]),ft=Le.length===(e?.focusContexts??[]).length,Je=le(()=>ft?[]:Le,[ft,Le]),gt=!ft&&Le.length===0,lt=le(()=>Je.length?(e?.focusContexts??[]).filter((pe)=>C.includes(pe)&&!Je.includes(pe)):[],[e?.focusContexts,C,Je]),on=Je.length?`${Je.join("+")}|${lt.join("+")}|${x}`:"",[Qi,ua]=G(null);F(()=>{if(!on||s.kind!=="structure")return;let pe=!1,Ln=new URLSearchParams({contexts:Je.join(","),level:x,hide:lt.join(",")});return fetch(`/api/focus?${Ln}`).then((Fi)=>Fi.ok?Fi.json():null).then((Fi)=>{if(!pe&&Fi)ua({key:on,graph:Fi})}).catch(()=>{}),()=>{pe=!0}},[on,e?.modelVersion,s.kind]);let Rl=(pe,Ln)=>{if(!pe||!ig(Ln))return null;if(Ln.kind==="contextMap")return P?pe.contextMapAll:pe.contextMap;if(Ln.kind==="structure"){if(gt)return null;if(on)return Qi?.key===on?Qi.graph:void 0;return pe[RUe[x]]}return null},Ac=(pe)=>pe.kind==="structure"?on?`structure:focus:${on}`:`structure:${x}`:`${pe.kind}:${P}`,wd=Rl(e,s);F(()=>{if(!r||!e||!ig(s))return;let pe=Ac(s);if(ce.current&&ce.current!==pe)oe.current.set(ce.current,r.getCamera());let Ln=ce.current!==pe;if(!wd){cT(r,()=>r.deleteShapes([...r.getCurrentPageShapeIds()]));return}let Fi=on&&s.kind==="structure"?void 0:Rl(t,s)??void 0;if(fA(r,wd,{diff:e.diff,diagnostics:e.diagnostics,previous:Fi,mode:l,lang:g}),Ln){let j9=oe.current.get(pe);if(j9)r.setCamera(j9);else hhe(r,wd.textScale??1)}ce.current=pe},[r,e,t,s,l,x,on,Qi,P,gt,g]),F(()=>{IA(d,r)},[d,r]);let Zb=O((pe,Ln=s)=>{if(r&&ig(Ln))pT(r,pe)},[r,s]),EA=O((pe)=>mn(Ihe(o,pe)),[o]),Cd=O((pe,Ln={})=>{if(Me((Fi)=>xhe(Fi,pe)),EA(pe),Ln.highlight!==!1)Zb(pe)},[EA,Zb]),V9=(pe)=>{let Ln=Yb(pe);if(Ln)return(e?.sources??[]).some((Fi)=>Fi.path===Ln);return!o||!!Wb(o,pe)},gT=Re[R9(Re,V9)],Xhe=()=>{if(!gT)return;Me(vhe(Re,V9)),EA(gT),Zb(gT)},yT=O((pe,Ln)=>{let Fi={kind:pe};if(a(Fi),ig(Fi))requestAnimationFrame(()=>requestAnimationFrame(()=>Zb(Ln,Fi)))},[Zb]),_A=(pe)=>{Ee(pe),V(!0)},Zhe=(pe)=>{Cd(pe,{highlight:!1});let Ln=o?Wb(o,pe):void 0;if(!Ln)return;if(Ln.kind==="state"||Ln.kind==="command")_A("states");else if(Ln.kind==="context")yT("structure",pe);else if(Qpe(Ln.el.kind)){if(yT("structure",pe),Ln.el.kind==="aggregate")_A("states")}else if(mA(Ln.el.kind))yT("catalog",pe);else _A("source")},Jhe=(pe)=>{if(Cd(pe.elementId??hA(pe.file)),mn({file:pe.file,line:pe.start.line,endLine:pe.end.line}),!pe.elementId)V(!0)},MA=H("selected element",()=>{let pe=r?.getOnlySelectedShape();return pe&&r?dA(r,pe.id):void 0},[r]);F(()=>{if(MA)Cd(MA,{highlight:!1})},[MA]),xA(r);let Qhe=O((pe)=>{pe.updateInstanceState({isReadonly:!0}),window.__domaintrailEditor=pe,i(pe)},[]),Jb={added:[],changed:[],removed:[]};return h($pe,{lang:g,children:E("div",{className:"app",children:[E("header",{children:[h("div",{className:"brand",children:"DomainTrail"}),E("div",{className:"status",children:[e&&h("span",{className:`pill pill-${e.status}`,children:y.status[e.status]}),h("span",{className:"muted",children:e?`${y.fileCount(e.files.length)} · v${e.version} · ${new Date(e.updatedAt).toLocaleTimeString(g)}`:""}),h("span",{className:`conn conn-${n}`,title:y.connectionTitle(y.connection[n])})]}),h(zhe,{mode:l,onMode:c,themePreference:u,theme:d,onTheme:f,langPreference:p,lang:g,onLang:m})]}),e?.stale&&h("div",{className:"banner",children:y.stale(h("a",{onClick:()=>K(!0),children:y.problems}))}),E("div",{className:"workspace",children:[E("div",{className:`side side-left${_?" open":""}`,style:{width:_?U:mT},children:[h("div",{className:"rail",inert:_,children:h("button",{className:"icon-button",onClick:()=>M(!0),"data-tooltip":y.openExplorer,"aria-label":y.openExplorer,children:h(of,{size:16,"aria-hidden":!0})})}),h("aside",{className:"pane",style:{width:U},inert:!_,children:h(bhe,{model:o,files:e?.files??[],diagnostics:e?.diagnostics??[],diff:e?.diff??Jb,mode:l,selected:Fe,onSelect:(pe)=>{if(Cd(pe),Yb(pe))V(!0)},onOpen:Zhe,onClose:()=>M(!1)})})]}),h(yA,{direction:"x",size:U,min:180,max:480,open:_,collapsed:mT,onResize:A,onOpenChange:M}),E("section",{className:"center",children:[E("div",{className:"view-tabs",children:[h("div",{className:"view-tab-list",role:"tablist",children:["contextMap","structure","catalog"].map((pe)=>h("button",{role:"tab","aria-selected":s.kind===pe,className:s.kind===pe?"active":"",onClick:()=>a({kind:pe}),children:y.views[pe]},pe))}),E("div",{className:"view-toolbar",children:[s.kind==="contextMap"&&E("label",{className:"check small",children:[h("input",{type:"checkbox",checked:P,onChange:(pe)=>k(pe.target.checked)}),y.showAllContexts]}),s.kind==="structure"&&h(SA,{contexts:e?.focusContexts??[],labels:o?.contextLabels??{},selected:Le,hidden:lt,mode:l,onChange:(pe)=>v(pe.length===(e?.focusContexts??[]).length?null:pe),onHiddenChange:I}),s.kind==="structure"&&h("div",{className:"segmented small icons",role:"group","aria-label":y.structureMode,children:C9.map((pe)=>{let Ln=AUe[pe];return h("button",{className:x===pe?"active":"","aria-pressed":x===pe,onClick:()=>b(pe),"data-tooltip":y.structureLevels[pe],"aria-label":y.structureLevels[pe],children:h(Ln,{size:15,"aria-hidden":!0})},pe)})}),ig(s)&&h("button",{onClick:()=>r?.zoomToFit({animation:{duration:200}}),children:y.zoomToFit})]})]}),E("div",{className:"view-area",children:[h(rT,{shapeUtils:TA,hideUi:!0,onMount:Qhe}),wd&&ig(s)&&h(vA,{view:s.kind==="contextMap"?"contextMap":`${x==="aggregates"?"aggregates":"structure"}${on?"Focus":""}`,open:Ce,onToggle:()=>ge(!Ce)}),e&&!wd&&ig(s)&&h("div",{className:"empty",children:e.status==="empty"?y.noDtFiles:gt&&s.kind==="structure"?y.pickContexts:on&&s.kind==="structure"?y.loading:y.noDiagram}),s.kind==="catalog"&&o&&h(phe,{model:o,mode:l,diff:e?.diff??Jb,diagnostics:e?.diagnostics??[],selected:Fe,onSelect:(pe)=>Cd(pe)})]})]}),h(yA,{direction:"x",size:z,min:300,max:()=>window.innerWidth-(_?U:mT)-MUe,invert:!0,open:N,collapsed:mT,onResize:j,onOpenChange:V}),E("div",{className:`side side-right${N?" open":""}`,style:{width:N?z:mT},children:[h("div",{className:"rail",inert:N,children:h("button",{className:"icon-button",onClick:()=>V(!0),"data-tooltip":y.openInspector,"aria-label":y.openInspector,children:h(vv,{size:16,"aria-hidden":!0})})}),h("aside",{className:"pane",style:{width:z},inert:!N,children:h(Ahe,{model:o,mode:l,selected:Fe,diagnostics:e?.diagnostics??[],diff:e?.diff??Jb,sources:e?.sources??[],sourceFocus:tt,statesView:(pe)=>h($he,{aggregateId:pe,graphs:e?.states[pe],previous:t?.states[pe],diff:e?.diff??Jb,diagnostics:e?.diagnostics??[],mode:l,lang:g,theme:d,selected:Fe,onSelect:(Ln)=>Cd(Ln),legendOpen:Ce,onLegendToggle:()=>ge(!Ce)}),tab:ne,onTab:Ee,onSelect:(pe)=>Cd(pe),onReveal:yT,onFocusContext:(pe)=>{v([pe]),a({kind:"structure"})},backTo:gT,onBack:Xhe,onClose:()=>V(!1)})})]})]}),h(yA,{direction:"y",size:R,min:120,max:600,invert:!0,open:D,collapsed:Whe,onResize:W,onOpenChange:K}),h("div",{className:"bottom-wrap",style:{height:D?R:Whe},children:h(ihe,{tab:te,mode:l,open:D,model:o,diagnostics:e?.diagnostics??[],diff:e?.diff??Jb,onTab:ue,onToggle:()=>K(!D),onLocate:Jhe,onSelect:(pe)=>Cd(pe)})}),h(qhe,{})]})})}rv(document.getElementById("root")).render(h(Yhe,{}));
|